-
Notifications
You must be signed in to change notification settings - Fork 902
Expand file tree
/
Copy pathauthorization-page.html
More file actions
193 lines (181 loc) · 5.97 KB
/
Copy pathauthorization-page.html
File metadata and controls
193 lines (181 loc) · 5.97 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
<!doctype html>
<html>
<head>
<meta charset="UTF-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<title>Mock - OAuth Provider</title>
</head>
<body class="text-foreground bg-background">
<div id="root"></div>
<script>
/*
* This file's purpose is to provide a way to develop the UI without
* running a full featured OAuth server. It mocks the server responses and
* provides configuration data to the UI.
*
* This file is not part of the production build.
*
* Start the development server with the following command from the
* oauth-provider root:
*
* ```sh
* pnpm run start:ui
* ```
*
* Then open the browser at http://localhost:5173/
*/
</script>
<style>
:root {
--branding-color-primary: 10 122 255;
--branding-color-primary-contrast: 255 255 255;
--branding-color-error: 244 11 66;
--branding-color-warning: 251 86 7;
--branding-color-success: 2 195 154;
/* Auth screen background demo (branding.background); mock-assets are dev-only. */
--branding-background-light-image: url('/mock-assets/illustration-light.png');
--branding-background-dark-image: url('/mock-assets/illustration-dark.png');
}
</style>
<script type="module">
import {
buildMockFetch,
accounts,
customizationData,
accountDeviceSessions,
currentDeviceId,
} from './src/mock-api.ts'
/*
* Client branding configuration
*/
// Use an "http://" URL to test the "an app on your device" flow
const clientId = 'https://example.com/client.json'
const clientName = 'My App'
const clientPolicyUri = 'https://bsky.app'
const clientTosUri = 'https://bsky.app'
const clientLogoUri = 'https://picsum.photos/200'
// Mock data
const requestUri = 'foo-bar'
document.cookie = `csrf-${requestUri}=xyz; path=/`
const lexicons = [
{
lexicon: 1,
id: 'com.atproto.moderation.basePermissions',
defs: {
main: {
type: 'permission-set',
title: 'Moderation',
'title:lang': { fr: 'Modération' },
detail: 'Create moderation reports',
'detail:lang': {
'fr-FR': 'Créer des rapports de modération',
},
permissions: [
{
type: 'permission',
resource: 'rpc',
aud: '*',
lxm: ['com.atproto.moderation.createReport'],
},
],
},
},
},
{
lexicon: 1,
id: 'com.example.calendar.basePermissions',
defs: {
main: {
type: 'permission-set',
title: 'Calendar',
'title:lang': { fr: 'Calendrier' },
detail: 'Manage your events and RSVPs',
'detail:lang': {
'fr-BE': 'Gérer vos événements et réponses',
},
permissions: [
{
type: 'permission',
resource: 'rpc',
inheritAud: true,
lxm: [
'com.example.calendar.listEvents',
'com.example.calendar.getEventDetails',
'com.example.calendar.getEventRsvps',
],
},
{
type: 'permission',
resource: 'repo',
collection: [
'com.example.calendar.event',
'com.example.calendar.rsvp',
],
},
{
type: 'permission',
resource: 'blob',
accept: ['image/*', 'video/*'],
},
],
},
},
},
]
window.__customizationData = customizationData
window.__sessions =
accountDeviceSessions.get(currentDeviceId)?.map((s, i, a) => ({
account: accounts.get(s.did),
loginRequired: s.loginRequired,
consentRequired: a.length > 0,
})) ?? []
window.__authorizeData = {
requestUri,
clientId: clientId,
clientMetadata: {
client_id: clientId,
client_name: clientName,
policy_uri: clientPolicyUri,
tos_uri: clientTosUri,
logo_uri: clientLogoUri,
},
clientTrusted: false,
clientFirstParty: false,
permissionSets: Object.fromEntries(
lexicons.map((l) => [l.id, l.defs.main]),
),
loginHint: undefined, // 'alice.test'
uiLocales: undefined, // 'en'
scope: [
'atproto',
'account:email',
'include:com.atproto.moderation.basePermissions',
'include:com.example.calendar.basePermissions?aud=did:web:example.com%23foo',
// 'account:status?action=manage',
// 'account:repo?action=manage',
// 'transition:email',
// 'transition:generic',
// 'transition:chat.bsky',
// 'identity:*',
// 'identity:handle',
// 'blob:image/*',
// 'blob:video/*',
// 'repo:app.bsky.feed.post?action=create',
// 'repo:app.bsky.feed.like?action=create',
// 'repo:app.bsky.graph.follow?action=create',
// 'repo:*?action=delete',
// 'rpc:*?aud=did:web:bsky.app#bsky_appview',
// 'rpc:app.bsky.feed.getFeed?aud=*',
// 'rpc:app.bsky.feed.getFeedSkeleton?aud=*',
// 'rpc:com.atproto.moderation.createReport?aud=*',
].join(' '),
}
Object.defineProperty(window, 'fetch', {
writable: true,
configurable: true,
value: buildMockFetch(),
})
await import('./src/authorization-page.tsx')
</script>
</body>
</html>