@atcute/oauth-browser-client 2.0.2 → 3.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +100 -244
- package/dist/agents/exchange.d.ts +2 -1
- package/dist/agents/exchange.d.ts.map +1 -1
- package/dist/agents/exchange.js +3 -4
- package/dist/agents/exchange.js.map +1 -1
- package/dist/agents/server-agent.d.ts +5 -5
- package/dist/agents/server-agent.d.ts.map +1 -1
- package/dist/agents/server-agent.js +5 -9
- package/dist/agents/server-agent.js.map +1 -1
- package/dist/agents/sessions.d.ts.map +1 -1
- package/dist/agents/sessions.js +16 -1
- package/dist/agents/sessions.js.map +1 -1
- package/dist/agents/user-agent.js +2 -2
- package/dist/agents/user-agent.js.map +1 -1
- package/dist/dpop.d.ts +2 -4
- package/dist/dpop.d.ts.map +1 -1
- package/dist/dpop.js +6 -79
- package/dist/dpop.js.map +1 -1
- package/dist/environment.d.ts +3 -3
- package/dist/environment.d.ts.map +1 -1
- package/dist/environment.js.map +1 -1
- package/dist/index.d.ts +3 -11
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -11
- package/dist/index.js.map +1 -1
- package/dist/resolvers.d.ts +92 -4
- package/dist/resolvers.d.ts.map +1 -1
- package/dist/resolvers.js +7 -7
- package/dist/resolvers.js.map +1 -1
- package/dist/store/db.d.ts +49 -6
- package/dist/store/db.d.ts.map +1 -1
- package/dist/types/client-assertion.d.ts +2 -3
- package/dist/types/client-assertion.d.ts.map +1 -1
- package/dist/types/server.d.ts +2 -56
- package/dist/types/server.d.ts.map +1 -1
- package/dist/types/token.d.ts +8 -20
- package/dist/types/token.d.ts.map +1 -1
- package/dist/utils/dpop-key.d.ts +10 -0
- package/dist/utils/dpop-key.d.ts.map +1 -0
- package/dist/utils/dpop-key.js +13 -0
- package/dist/utils/dpop-key.js.map +1 -0
- package/dist/utils/runtime.d.ts +0 -6
- package/dist/utils/runtime.d.ts.map +1 -1
- package/dist/utils/runtime.js +0 -16
- package/dist/utils/runtime.js.map +1 -1
- package/lib/agents/exchange.ts +10 -11
- package/lib/agents/server-agent.ts +14 -17
- package/lib/agents/sessions.ts +23 -2
- package/lib/agents/user-agent.ts +2 -2
- package/lib/dpop.ts +7 -108
- package/lib/environment.ts +3 -3
- package/lib/index.ts +12 -12
- package/lib/resolvers.ts +15 -13
- package/lib/store/db.ts +6 -6
- package/lib/types/client-assertion.ts +2 -4
- package/lib/types/server.ts +2 -57
- package/lib/types/token.ts +10 -24
- package/lib/utils/dpop-key.ts +24 -0
- package/lib/utils/runtime.ts +0 -22
- package/package.json +12 -8
- package/dist/types/client.d.ts +0 -38
- package/dist/types/client.d.ts.map +0 -1
- package/dist/types/client.js +0 -2
- package/dist/types/client.js.map +0 -1
- package/dist/types/dpop.d.ts +0 -10
- package/dist/types/dpop.d.ts.map +0 -1
- package/dist/types/dpop.js +0 -2
- package/dist/types/dpop.js.map +0 -1
- package/dist/types/identity.d.ts +0 -6
- package/dist/types/identity.d.ts.map +0 -1
- package/dist/types/identity.js +0 -2
- package/dist/types/identity.js.map +0 -1
- package/dist/types/par.d.ts +0 -5
- package/dist/types/par.d.ts.map +0 -1
- package/dist/types/par.js +0 -2
- package/dist/types/par.js.map +0 -1
- package/dist/utils/identity-resolver.d.ts +0 -7
- package/dist/utils/identity-resolver.d.ts.map +0 -1
- package/dist/utils/identity-resolver.js +0 -8
- package/dist/utils/identity-resolver.js.map +0 -1
- package/lib/types/client.ts +0 -82
- package/lib/types/dpop.ts +0 -9
- package/lib/types/identity.ts +0 -12
- package/lib/types/par.ts +0 -4
- package/lib/utils/identity-resolver.ts +0 -12
package/README.md
CHANGED
|
@@ -1,32 +1,47 @@
|
|
|
1
1
|
# @atcute/oauth-browser-client
|
|
2
2
|
|
|
3
|
-
minimal OAuth browser client
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
3
|
+
minimal OAuth browser client for AT Protocol.
|
|
4
|
+
|
|
5
|
+
```sh
|
|
6
|
+
npm install @atcute/oauth-browser-client
|
|
7
|
+
```
|
|
8
|
+
|
|
9
|
+
## client metadata
|
|
10
|
+
|
|
11
|
+
your app needs an OAuth client metadata document hosted at a public URL. this tells authorization
|
|
12
|
+
servers about your app:
|
|
13
|
+
|
|
14
|
+
```json
|
|
15
|
+
{
|
|
16
|
+
"client_id": "https://example.com/oauth-client-metadata.json",
|
|
17
|
+
"client_name": "My App",
|
|
18
|
+
"client_uri": "https://example.com",
|
|
19
|
+
"redirect_uris": ["https://example.com/oauth/callback"],
|
|
20
|
+
"scope": "atproto transition:generic",
|
|
21
|
+
"grant_types": ["authorization_code", "refresh_token"],
|
|
22
|
+
"response_types": ["code"],
|
|
23
|
+
"token_endpoint_auth_method": "none",
|
|
24
|
+
"application_type": "web",
|
|
25
|
+
"dpop_bound_access_tokens": true
|
|
26
|
+
}
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
the `client_id` must be the URL where this document is hosted. see the
|
|
30
|
+
[OAuth client metadata spec](https://docs.bsky.app/docs/advanced-guides/oauth-client#client-metadata)
|
|
31
|
+
for all available fields.
|
|
16
32
|
|
|
17
33
|
## usage
|
|
18
34
|
|
|
19
|
-
###
|
|
35
|
+
### configuration
|
|
20
36
|
|
|
21
|
-
|
|
22
|
-
along with the resolvers that will be used to resolve and verify account details. this call should
|
|
23
|
-
be placed before any other calls you make with this library.
|
|
37
|
+
call `configureOAuth` before using any other functions from this library:
|
|
24
38
|
|
|
25
39
|
```ts
|
|
26
|
-
import { configureOAuth
|
|
40
|
+
import { configureOAuth } from '@atcute/oauth-browser-client';
|
|
27
41
|
|
|
28
42
|
import {
|
|
29
43
|
CompositeDidDocumentResolver,
|
|
44
|
+
LocalActorResolver,
|
|
30
45
|
PlcDidDocumentResolver,
|
|
31
46
|
WebDidDocumentResolver,
|
|
32
47
|
XrpcHandleResolver,
|
|
@@ -37,16 +52,10 @@ configureOAuth({
|
|
|
37
52
|
client_id: 'https://example.com/oauth-client-metadata.json',
|
|
38
53
|
redirect_uri: 'https://example.com/oauth/callback',
|
|
39
54
|
},
|
|
40
|
-
identityResolver:
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
//
|
|
45
|
-
// NOTE: Bluesky may log handle resolutions and requester info per their privacy
|
|
46
|
-
// policy. consider the privacy implications of this arrangement and change this
|
|
47
|
-
// setup if unsuitable for your use case.
|
|
48
|
-
handleResolver: new XrpcHandleResolver({ serviceUrl: 'https://public.api.bsky.app' }),
|
|
49
|
-
|
|
55
|
+
identityResolver: new LocalActorResolver({
|
|
56
|
+
handleResolver: new XrpcHandleResolver({
|
|
57
|
+
serviceUrl: 'https://public.api.bsky.app',
|
|
58
|
+
}),
|
|
50
59
|
didDocumentResolver: new CompositeDidDocumentResolver({
|
|
51
60
|
methods: {
|
|
52
61
|
plc: new PlcDidDocumentResolver(),
|
|
@@ -57,104 +66,63 @@ configureOAuth({
|
|
|
57
66
|
});
|
|
58
67
|
```
|
|
59
68
|
|
|
60
|
-
|
|
69
|
+
> [!NOTE]
|
|
70
|
+
> this example uses Bluesky's AppView for handle resolution since web apps lack direct DNS access.
|
|
71
|
+
> Bluesky may log handle resolutions per their privacy policy - consider the implications for your
|
|
72
|
+
> use case.
|
|
61
73
|
|
|
62
|
-
|
|
63
|
-
identifier or service along with the scope of the authorization, which should either match the one
|
|
64
|
-
in your client metadata, or a reduced set of it.
|
|
74
|
+
### starting authorization
|
|
65
75
|
|
|
66
76
|
```ts
|
|
67
77
|
import { createAuthorizationUrl } from '@atcute/oauth-browser-client';
|
|
68
78
|
|
|
69
79
|
const authUrl = await createAuthorizationUrl({
|
|
70
80
|
target: { type: 'account', identifier: 'mary.my.id' },
|
|
71
|
-
// or { type: 'pds', serviceUrl: 'https://bsky.social' }
|
|
72
81
|
scope: 'atproto transition:generic transition:chat.bsky',
|
|
73
82
|
});
|
|
74
83
|
|
|
75
|
-
|
|
76
|
-
await sleep(200);
|
|
77
|
-
|
|
78
|
-
// redirect the user to sign in and authorize the app
|
|
84
|
+
await sleep(200); // let browser persist local storage
|
|
79
85
|
window.location.assign(authUrl);
|
|
80
|
-
|
|
81
|
-
// if this is on an async function, ideally the function should never ever resolve.
|
|
82
|
-
// the only way it should resolve at this point is if the user aborted the authorization
|
|
83
|
-
// by returning back to this page (thanks to back-forward page caching)
|
|
84
|
-
await new Promise((_resolve, reject) => {
|
|
85
|
-
const listener = () => {
|
|
86
|
-
reject(new Error(`user aborted the login request`));
|
|
87
|
-
};
|
|
88
|
-
|
|
89
|
-
window.addEventListener('pageshow', listener, { once: true });
|
|
90
|
-
});
|
|
91
86
|
```
|
|
92
87
|
|
|
93
88
|
### finalizing authorization
|
|
94
89
|
|
|
95
|
-
|
|
96
|
-
parameters that have been provided.
|
|
90
|
+
on your redirect URL, extract the parameters and finalize:
|
|
97
91
|
|
|
98
92
|
```ts
|
|
99
|
-
import {
|
|
93
|
+
import { Client } from '@atcute/client';
|
|
100
94
|
import { OAuthUserAgent, finalizeAuthorization } from '@atcute/oauth-browser-client';
|
|
101
95
|
|
|
102
|
-
//
|
|
103
|
-
// parameters assigned in the hash, not the search string.
|
|
96
|
+
// server redirects with params in hash, not search string
|
|
104
97
|
const params = new URLSearchParams(location.hash.slice(1));
|
|
105
98
|
|
|
106
|
-
//
|
|
107
|
-
// scrub it from history to prevent this authorization state to be replayed,
|
|
108
|
-
// just for good measure.
|
|
99
|
+
// scrub params from URL to prevent replay
|
|
109
100
|
history.replaceState(null, '', location.pathname + location.search);
|
|
110
101
|
|
|
111
|
-
|
|
112
|
-
const session = await finalizeAuthorization(params);
|
|
113
|
-
|
|
114
|
-
// now you can start making requests!
|
|
102
|
+
const { session } = await finalizeAuthorization(params);
|
|
115
103
|
const agent = new OAuthUserAgent(session);
|
|
104
|
+
const rpc = new Client({ handler: agent });
|
|
116
105
|
|
|
117
|
-
|
|
118
|
-
{
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
const { data } = await rpc.get('com.atproto.identity.resolveHandle', {
|
|
122
|
-
params: {
|
|
123
|
-
handle: 'mary.my.id',
|
|
124
|
-
},
|
|
125
|
-
});
|
|
126
|
-
}
|
|
127
|
-
|
|
128
|
-
// or, use it directly!
|
|
129
|
-
{
|
|
130
|
-
const response = await agent.handle('/xrpc/com.atproto.identity.resolveHandle?handle=mary.my.id');
|
|
131
|
-
}
|
|
106
|
+
const { data } = await rpc.get('com.atproto.identity.resolveHandle', {
|
|
107
|
+
params: { handle: 'mary.my.id' },
|
|
108
|
+
});
|
|
132
109
|
```
|
|
133
110
|
|
|
134
|
-
the
|
|
135
|
-
|
|
136
|
-
who was last signed in for your own UI, as the sessions stored by the database is not guaranteed to
|
|
137
|
-
be permanent (mostly if they don't come with a refresh token.)
|
|
138
|
-
|
|
139
|
-
### resuming existing sessions
|
|
111
|
+
the session is persisted internally - don't store it elsewhere. track signed-in DIDs yourself for
|
|
112
|
+
your UI, as sessions without refresh tokens may expire.
|
|
140
113
|
|
|
141
|
-
|
|
142
|
-
resume.
|
|
114
|
+
### resuming sessions
|
|
143
115
|
|
|
144
116
|
```ts
|
|
145
|
-
import { XRPC } from '@atcute/client';
|
|
146
117
|
import { OAuthUserAgent, getSession } from '@atcute/oauth-browser-client';
|
|
147
118
|
|
|
148
|
-
const session = await getSession('did:plc:ia76kvnndjutgedggx2ibrem', {
|
|
149
|
-
|
|
119
|
+
const session = await getSession('did:plc:ia76kvnndjutgedggx2ibrem', {
|
|
120
|
+
allowStale: true,
|
|
121
|
+
});
|
|
150
122
|
const agent = new OAuthUserAgent(session);
|
|
151
|
-
const rpc = new XRPC({ handler: agent });
|
|
152
123
|
```
|
|
153
124
|
|
|
154
|
-
###
|
|
155
|
-
|
|
156
|
-
you can manually remove sessions via `deleteStoredSession`, but ideally, you should revoke the token
|
|
157
|
-
first before doing so.
|
|
125
|
+
### signing out
|
|
158
126
|
|
|
159
127
|
```ts
|
|
160
128
|
import { OAuthUserAgent, deleteStoredSession, getSession } from '@atcute/oauth-browser-client';
|
|
@@ -164,49 +132,39 @@ const did = 'did:plc:ia76kvnndjutgedggx2ibrem';
|
|
|
164
132
|
try {
|
|
165
133
|
const session = await getSession(did, { allowStale: true });
|
|
166
134
|
const agent = new OAuthUserAgent(session);
|
|
167
|
-
|
|
168
135
|
await agent.signOut();
|
|
169
|
-
} catch
|
|
170
|
-
//
|
|
171
|
-
deleteStoredSession(did);
|
|
136
|
+
} catch {
|
|
137
|
+
deleteStoredSession(did); // fallback if signOut fails
|
|
172
138
|
}
|
|
173
139
|
```
|
|
174
140
|
|
|
175
|
-
## confidential client mode
|
|
141
|
+
## confidential client mode
|
|
176
142
|
|
|
177
|
-
by default,
|
|
178
|
-
|
|
179
|
-
|
|
143
|
+
by default, this library operates as a **public client** with shorter session lifetimes. for
|
|
144
|
+
longer-lived sessions, set up a [client assertion backend][client-assertion-backend] to enable
|
|
145
|
+
**confidential client mode**.
|
|
180
146
|
|
|
181
|
-
|
|
182
|
-
|
|
147
|
+
[client-assertion-backend]:
|
|
148
|
+
https://github.com/bluesky-social/proposals/tree/main/0010-client-assertion-backend
|
|
183
149
|
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
### setup
|
|
187
|
-
|
|
188
|
-
configure the client with a function to fetch client assertions from your backend:
|
|
150
|
+
add `fetchClientAssertion` to your config. the backend API is entirely up to you - this is just one
|
|
151
|
+
example:
|
|
189
152
|
|
|
190
153
|
```ts
|
|
191
|
-
import { configureOAuth } from '@atcute/oauth-browser-client';
|
|
192
|
-
|
|
193
154
|
configureOAuth({
|
|
194
155
|
// ... existing config
|
|
195
156
|
|
|
196
|
-
async fetchClientAssertion({
|
|
197
|
-
const
|
|
157
|
+
async fetchClientAssertion({ aud, createDpopProof }) {
|
|
158
|
+
const htu = 'https://example.com/api/client-assertion';
|
|
159
|
+
const dpop = await createDpopProof(htu);
|
|
198
160
|
|
|
199
|
-
const response = await fetch(
|
|
161
|
+
const response = await fetch(htu, {
|
|
200
162
|
method: 'POST',
|
|
201
|
-
headers: {
|
|
202
|
-
|
|
203
|
-
'content-type': 'application/json',
|
|
204
|
-
},
|
|
205
|
-
body: JSON.stringify({ jkt, aud }),
|
|
163
|
+
headers: { dpop, 'content-type': 'application/json' },
|
|
164
|
+
body: JSON.stringify({ aud }),
|
|
206
165
|
});
|
|
207
166
|
|
|
208
167
|
const data = await response.json();
|
|
209
|
-
|
|
210
168
|
return {
|
|
211
169
|
client_assertion_type: 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer',
|
|
212
170
|
client_assertion: data.assertion,
|
|
@@ -215,127 +173,41 @@ configureOAuth({
|
|
|
215
173
|
});
|
|
216
174
|
```
|
|
217
175
|
|
|
218
|
-
|
|
219
|
-
|
|
176
|
+
your backend validates the dpop proof and signs a client assertion jwt containing `iss`, `sub` (both
|
|
177
|
+
your client id), `aud` (authorization server), `exp`, `jti` (unique nonce), and `cnf: { jkt }` (the
|
|
178
|
+
allowed key thumbprint derived from the proof).
|
|
220
179
|
|
|
221
|
-
your
|
|
222
|
-
|
|
180
|
+
update your client metadata for confidential mode - replace `token_endpoint_auth_method` with
|
|
181
|
+
`private_key_jwt`, add `token_endpoint_auth_signing_alg: "ES256"`, and add a `jwks_uri` pointing to
|
|
182
|
+
your public keys.
|
|
223
183
|
|
|
224
|
-
|
|
225
|
-
interface ClientAssertionJwt {
|
|
226
|
-
/** your client ID */
|
|
227
|
-
iss: string;
|
|
228
|
-
/** also your client ID */
|
|
229
|
-
sub: string;
|
|
230
|
-
/** the authorization server receiving this token */
|
|
231
|
-
aud: string;
|
|
232
|
-
/** when this token expires */
|
|
233
|
-
exp: number;
|
|
234
|
-
/** unique nonce */
|
|
235
|
-
jti: string;
|
|
236
|
-
/** asserts that this jkt is allowed */
|
|
237
|
-
cnf: { jkt: string };
|
|
238
|
-
}
|
|
239
|
-
```
|
|
184
|
+
## local development with Vite
|
|
240
185
|
|
|
241
|
-
|
|
242
|
-
code, etc.)
|
|
243
|
-
|
|
244
|
-
### client metadata updates
|
|
245
|
-
|
|
246
|
-
your OAuth client metadata document must also be updated for confidential clients:
|
|
247
|
-
|
|
248
|
-
```json
|
|
249
|
-
{
|
|
250
|
-
"client_id": "https://example.com/oauth-client-metadata.json",
|
|
251
|
-
"client_name": "My App",
|
|
252
|
-
"redirect_uris": ["https://example.com/oauth/callback"],
|
|
253
|
-
"scope": "atproto transition:generic",
|
|
254
|
-
"token_endpoint_auth_method": "private_key_jwt",
|
|
255
|
-
"token_endpoint_auth_signing_alg": "ES256",
|
|
256
|
-
"jwks_uri": "https://example.com/oauth-jwks.json"
|
|
257
|
-
}
|
|
258
|
-
```
|
|
259
|
-
|
|
260
|
-
the `jwks_uri` should expose the public keys used to sign client assertions. it should return a JSON
|
|
261
|
-
Web Key Set (JWKS) document:
|
|
262
|
-
|
|
263
|
-
```json
|
|
264
|
-
{
|
|
265
|
-
"keys": [
|
|
266
|
-
{
|
|
267
|
-
"kty": "EC",
|
|
268
|
-
"crv": "P-256",
|
|
269
|
-
"x": "base64url-encoded-x-coordinate",
|
|
270
|
-
"y": "base64url-encoded-y-coordinate",
|
|
271
|
-
"use": "sig",
|
|
272
|
-
"kid": "key-identifier",
|
|
273
|
-
"alg": "ES256"
|
|
274
|
-
}
|
|
275
|
-
]
|
|
276
|
-
}
|
|
277
|
-
```
|
|
278
|
-
|
|
279
|
-
the public keys in the JWKS must correspond to the private keys your backend uses to sign client
|
|
280
|
-
assertions. multiple keys can be listed to support key rotation.
|
|
281
|
-
|
|
282
|
-
## additional guide
|
|
283
|
-
|
|
284
|
-
### configuring your Vite project
|
|
285
|
-
|
|
286
|
-
you might want to configure the server options in your Vite config so you'll never end up visiting
|
|
287
|
-
your app in `localhost`, which is specifically forbidden by AT Protocol's OAuth, let's change it so
|
|
288
|
-
it'll always use `127.0.0.1`:
|
|
186
|
+
AT Protocol OAuth forbids `localhost` - use `127.0.0.1` instead:
|
|
289
187
|
|
|
290
188
|
```ts
|
|
291
|
-
|
|
189
|
+
// vite.config.ts
|
|
292
190
|
import { defineConfig } from 'vite';
|
|
191
|
+
import metadata from './public/oauth-client-metadata.json' with { type: 'json' };
|
|
293
192
|
|
|
294
193
|
const SERVER_HOST = '127.0.0.1';
|
|
295
194
|
const SERVER_PORT = 12520;
|
|
296
195
|
|
|
297
196
|
export default defineConfig({
|
|
298
|
-
server: {
|
|
299
|
-
host: SERVER_HOST,
|
|
300
|
-
port: SERVER_PORT,
|
|
301
|
-
},
|
|
302
|
-
});
|
|
303
|
-
```
|
|
304
|
-
|
|
305
|
-
additionally, to make it easier to develop locally and deploy to production, you should consider
|
|
306
|
-
adding a plugin that'll inject the necessary values for you through environment variables:
|
|
307
|
-
|
|
308
|
-
```ts
|
|
309
|
-
/// vite.config.ts
|
|
310
|
-
import metadata from './public/oauth-client-metadata.json' with { type: 'json' };
|
|
311
|
-
|
|
312
|
-
export default defineConfig({
|
|
313
|
-
// ...
|
|
314
|
-
|
|
197
|
+
server: { host: SERVER_HOST, port: SERVER_PORT },
|
|
315
198
|
plugins: [
|
|
316
|
-
// injects OAuth-related environment variables
|
|
317
199
|
{
|
|
318
200
|
config(_conf, { command }) {
|
|
319
201
|
if (command === 'build') {
|
|
320
202
|
process.env.VITE_OAUTH_CLIENT_ID = metadata.client_id;
|
|
321
203
|
process.env.VITE_OAUTH_REDIRECT_URI = metadata.redirect_uris[0];
|
|
322
204
|
} else {
|
|
323
|
-
const redirectUri = (
|
|
324
|
-
|
|
325
|
-
|
|
326
|
-
})();
|
|
327
|
-
|
|
328
|
-
const clientId =
|
|
329
|
-
`http://localhost` +
|
|
330
|
-
`?redirect_uri=${encodeURIComponent(redirectUri)}` +
|
|
205
|
+
const redirectUri = `http://${SERVER_HOST}:${SERVER_PORT}${new URL(metadata.redirect_uris[0]).pathname}`;
|
|
206
|
+
process.env.VITE_OAUTH_CLIENT_ID =
|
|
207
|
+
`http://localhost?redirect_uri=${encodeURIComponent(redirectUri)}` +
|
|
331
208
|
`&scope=${encodeURIComponent(metadata.scope)}`;
|
|
332
|
-
|
|
333
|
-
process.env.VITE_DEV_SERVER_PORT = '' + SERVER_PORT;
|
|
334
|
-
process.env.VITE_OAUTH_CLIENT_ID = clientId;
|
|
335
209
|
process.env.VITE_OAUTH_REDIRECT_URI = redirectUri;
|
|
336
210
|
}
|
|
337
|
-
|
|
338
|
-
process.env.VITE_CLIENT_URI = metadata.client_uri;
|
|
339
211
|
process.env.VITE_OAUTH_SCOPE = metadata.scope;
|
|
340
212
|
},
|
|
341
213
|
},
|
|
@@ -343,25 +215,7 @@ export default defineConfig({
|
|
|
343
215
|
});
|
|
344
216
|
```
|
|
345
217
|
|
|
346
|
-
|
|
347
|
-
|
|
348
|
-
```ts
|
|
349
|
-
/// src/vite-env.d.ts
|
|
350
|
-
|
|
351
|
-
interface ImportMetaEnv {
|
|
352
|
-
readonly VITE_DEV_SERVER_PORT?: string;
|
|
353
|
-
readonly VITE_CLIENT_URI: string;
|
|
354
|
-
readonly VITE_OAUTH_CLIENT_ID: string;
|
|
355
|
-
readonly VITE_OAUTH_REDIRECT_URI: string;
|
|
356
|
-
readonly VITE_OAUTH_SCOPE: string;
|
|
357
|
-
}
|
|
358
|
-
|
|
359
|
-
interface ImportMeta {
|
|
360
|
-
readonly env: ImportMetaEnv;
|
|
361
|
-
}
|
|
362
|
-
```
|
|
363
|
-
|
|
364
|
-
et voilà! you can now use this to configure the client.
|
|
218
|
+
then use environment variables in your code:
|
|
365
219
|
|
|
366
220
|
```ts
|
|
367
221
|
configureOAuth({
|
|
@@ -371,13 +225,15 @@ configureOAuth({
|
|
|
371
225
|
},
|
|
372
226
|
// ...
|
|
373
227
|
});
|
|
374
|
-
|
|
375
|
-
// ... later during sign-in process
|
|
376
|
-
const authUrl = await createAuthorizationUrl({
|
|
377
|
-
// ...
|
|
378
|
-
scope: import.meta.env.VITE_OAUTH_SCOPE,
|
|
379
|
-
});
|
|
380
228
|
```
|
|
381
229
|
|
|
382
|
-
|
|
383
|
-
|
|
230
|
+
## caveats
|
|
231
|
+
|
|
232
|
+
- **minimal implementation**: only ES256 DPoP keys, requires PKCE and DPoP-bound PAR
|
|
233
|
+
- **no IndexedDB**: works in Safari lockdown mode but can't use non-exportable keys as [recommended
|
|
234
|
+
by DPoP spec][dpop-spec]
|
|
235
|
+
- **limited testing**: works in personal projects but consider the [reference
|
|
236
|
+
implementation][oauth-atproto-lib] for production
|
|
237
|
+
|
|
238
|
+
[dpop-spec]: https://datatracker.ietf.org/doc/html/rfc9449#section-2-4
|
|
239
|
+
[oauth-atproto-lib]: https://npm.im/@atproto/oauth-client-browser
|
|
@@ -1,4 +1,5 @@
|
|
|
1
1
|
import type { ActorIdentifier } from '@atcute/lexicons';
|
|
2
|
+
import type { OAuthPrompt } from '@atcute/oauth-types';
|
|
2
3
|
import type { Session } from '../types/token.js';
|
|
3
4
|
export type AuthorizeTargetOptions = {
|
|
4
5
|
type: 'account';
|
|
@@ -11,7 +12,7 @@ export interface AuthorizeOptions {
|
|
|
11
12
|
target: AuthorizeTargetOptions;
|
|
12
13
|
scope: string;
|
|
13
14
|
state?: unknown;
|
|
14
|
-
prompt?:
|
|
15
|
+
prompt?: OAuthPrompt | (string & {});
|
|
15
16
|
display?: 'page' | 'popup' | 'touch' | 'wap';
|
|
16
17
|
locale?: string;
|
|
17
18
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exchange.d.ts","sourceRoot":"","sources":["../../lib/agents/exchange.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"exchange.d.ts","sourceRoot":"","sources":["../../lib/agents/exchange.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,kBAAkB,CAAC;AAExD,OAAO,KAAK,EAAoC,WAAW,EAAE,MAAM,qBAAqB,CAAC;AAOzF,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAKjD,MAAM,MAAM,sBAAsB,GAC/B;IAAE,IAAI,EAAE,SAAS,CAAC;IAAC,UAAU,EAAE,eAAe,CAAA;CAAE,GAChD;IAAE,IAAI,EAAE,KAAK,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,CAAC;AAEvC,MAAM,WAAW,gBAAgB;IAChC,MAAM,EAAE,sBAAsB,CAAC;IAC/B,KAAK,EAAE,MAAM,CAAC;IACd,KAAK,CAAC,EAAE,OAAO,CAAC;IAChB,MAAM,CAAC,EAAE,WAAW,GAAG,CAAC,MAAM,GAAG,EAAE,CAAC,CAAC;IACrC,OAAO,CAAC,EAAE,MAAM,GAAG,OAAO,GAAG,OAAO,GAAG,KAAK,CAAC;IAC7C,MAAM,CAAC,EAAE,MAAM,CAAC;CAChB;AAED;;;;GAIG;AACH,eAAO,MAAM,sBAAsB,6CAwDlC,CAAC;AAEF;;;;GAIG;AACH,eAAO,MAAM,qBAAqB;;;EA8CjC,CAAC"}
|
package/dist/agents/exchange.js
CHANGED
|
@@ -1,8 +1,7 @@
|
|
|
1
|
+
import { generateDpopKey, generatePkce } from '@atcute/oauth-crypto';
|
|
1
2
|
import { nanoid } from 'nanoid';
|
|
2
|
-
import { createES256Key } from '../dpop.js';
|
|
3
3
|
import { CLIENT_ID, database, REDIRECT_URI } from '../environment.js';
|
|
4
4
|
import { AuthorizationError, LoginError } from '../errors.js';
|
|
5
|
-
import { generatePKCE } from '../utils/runtime.js';
|
|
6
5
|
import { resolveFromIdentifier, resolveFromService } from '../resolvers.js';
|
|
7
6
|
import { OAuthServerAgent } from './server-agent.js';
|
|
8
7
|
import { storeSession } from './sessions.js';
|
|
@@ -30,8 +29,8 @@ export const createAuthorizationUrl = async (options) => {
|
|
|
30
29
|
: identity.did
|
|
31
30
|
: undefined;
|
|
32
31
|
const sid = nanoid(24);
|
|
33
|
-
const pkce = await
|
|
34
|
-
const dpopKey = await
|
|
32
|
+
const pkce = await generatePkce();
|
|
33
|
+
const dpopKey = await generateDpopKey(['ES256']);
|
|
35
34
|
const params = {
|
|
36
35
|
display: reqs.display,
|
|
37
36
|
ui_locales: reqs.locale,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"exchange.js","sourceRoot":"","sources":["../../lib/agents/exchange.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"exchange.js","sourceRoot":"","sources":["../../lib/agents/exchange.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,eAAe,EAAE,YAAY,EAAE,MAAM,sBAAsB,CAAC;AAGrE,OAAO,EAAE,MAAM,EAAE,MAAM,QAAQ,CAAC;AAEhC,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AACtE,OAAO,EAAE,kBAAkB,EAAE,UAAU,EAAE,MAAM,cAAc,CAAC;AAC9D,OAAO,EAAE,qBAAqB,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAG5E,OAAO,EAAE,gBAAgB,EAAE,MAAM,mBAAmB,CAAC;AACrD,OAAO,EAAE,YAAY,EAAE,MAAM,eAAe,CAAC;AAe7C;;;;GAIG;AACH,MAAM,CAAC,MAAM,sBAAsB,GAAG,KAAK,EAAE,OAAyB,EAAgB,EAAE,CAAC;IACxF,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,KAAK,GAAG,IAAI,EAAE,GAAG,IAAI,EAAE,GAAG,OAAO,CAAC;IAEzD,IAAI,QAAkF,CAAC;IACvF,QAAQ,MAAM,CAAC,IAAI,EAAE,CAAC;QACrB,KAAK,SAAS,EAAE,CAAC;YAChB,QAAQ,GAAG,MAAM,qBAAqB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;YAC1D,MAAM;QACP,CAAC;QACD,KAAK,KAAK,EAAE,CAAC;YACZ,QAAQ,GAAG,MAAM,kBAAkB,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;QACxD,CAAC;IACF,CAAC;IAED,MAAM,EAAE,QAAQ,EAAE,QAAQ,EAAE,GAAG,QAAQ,CAA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AAM,KAAK,GAAG,MAAM,CAAC,KAAK,IAAI,IAAI,CAAC;IAEnC,IAAI,MAAM,KAAK,IAAI,EAAE,CAAC;QACrB,MAAM,IAAI,UAAU,CAAC,0BAA0B,CAAC,CAAC;IAClD,CAAC;SAAM,IAAI,MAAM,KAAK,QAAQ,CAAC,MAAM,EAAE,CAAC;QACvC,MAAM,IAAI,UAAU,CAAC,iBAAiB,CAAC,CAAC;IACzC,CAAC;IAED,iCAAiC;IACjC,MAAM,MAAM,GAAG,IAAI,gBAAgB,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IACvD,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,GAAG,MAAM,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC;IAEzE,kBAAkB;IAClB,MAAM,GAAG,GAAG,IAAI,CAAC,GAAG,CAAC;IACrB,MAAM,OAAO,GAAY,EAAE,OAAO,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC;IAElD,MAAM,YAAY,CAAC,GAAG,EAAE,OAAO,CAAC,CAAC;IAEjC,OAAO,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC;AAAA,CAC1B,CAAC"}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
1
|
import type { Did } from '@atcute/lexicons';
|
|
2
|
-
import type
|
|
3
|
-
import type { OAuthParResponse } from '
|
|
2
|
+
import { type DpopPrivateJwk } from '@atcute/oauth-crypto';
|
|
3
|
+
import type { AtprotoOAuthTokenResponse, OAuthParResponse } from '@atcute/oauth-types';
|
|
4
4
|
import type { PersistedAuthorizationServerMetadata } from '../types/server.js';
|
|
5
|
-
import type { ExchangeInfo,
|
|
5
|
+
import type { ExchangeInfo, TokenInfo } from '../types/token.js';
|
|
6
6
|
export declare class OAuthServerAgent {
|
|
7
7
|
#private;
|
|
8
|
-
constructor(metadata: PersistedAuthorizationServerMetadata, dpopKey:
|
|
8
|
+
constructor(metadata: PersistedAuthorizationServerMetadata, dpopKey: DpopPrivateJwk);
|
|
9
9
|
request(endpoint: 'pushed_authorization_request', payload: Record<string, unknown>): Promise<OAuthParResponse>;
|
|
10
|
-
request(endpoint: 'token', payload: Record<string, unknown>): Promise<
|
|
10
|
+
request(endpoint: 'token', payload: Record<string, unknown>): Promise<AtprotoOAuthTokenResponse>;
|
|
11
11
|
request(endpoint: 'revocation', payload: Record<string, unknown>): Promise<any>;
|
|
12
12
|
request(endpoint: 'introspection', payload: Record<string, unknown>): Promise<any>;
|
|
13
13
|
revoke(token: string): Promise<void>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-agent.d.ts","sourceRoot":"","sources":["../../lib/agents/server-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;
|
|
1
|
+
{"version":3,"file":"server-agent.d.ts","sourceRoot":"","sources":["../../lib/agents/server-agent.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,EAAyB,KAAK,cAAc,EAAE,MAAM,sBAAsB,CAAC;AAClF,OAAO,KAAK,EAAE,yBAAyB,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAMvF,OAAO,KAAK,EAAE,oCAAoC,EAAE,MAAM,oBAAoB,CAAC;AAC/E,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAIjE,qBAAa,gBAAgB;;IAK5B,YAAY,QAAQ,EAAE,oCAAoC,EAAE,OAAO,EAAE,cAAc,EAIlF;IAEK,OAAO,CACZ,QAAQ,EAAE,8BAA8B,EACxC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC9B,OAAO,CAAC,gBAAgB,CAAC,CAAC;IACvB,OAAO,CAAC,QAAQ,EAAE,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC;IACjG,OAAO,CAAC,QAAQ,EAAE,YAAY,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IAChF,OAAO,CAAC,QAAQ,EAAE,eAAe,EAAE,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC;IA0CnF,MAAM,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC,CAIzC;IAEK,YAAY,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;QAAE,IAAI,EAAE,YAAY,CAAC;QAAC,KAAK,EAAE,SAAS,CAAA;KAAE,CAAC,CAcrG;IAEK,OAAO,CAAC,EAAE,GAAG,EAAE,KAAK,EAAE,EAAE;QAAE,GAAG,EAAE,GAAG,CAAC;QAAC,KAAK,EAAE,SAAS,CAAA;KAAE,GAAG,OAAO,CAAC,SAAS,CAAC,CAqBhF;CAqDD"}
|
|
@@ -1,4 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { createDpopProofSigner } from '@atcute/oauth-crypto';
|
|
2
|
+
import { createDPoPFetch } from '../dpop.js';
|
|
2
3
|
import { CLIENT_ID, fetchClientAssertion, REDIRECT_URI } from '../environment.js';
|
|
3
4
|
import { FetchResponseError, OAuthResponseError, TokenRefreshError } from '../errors.js';
|
|
4
5
|
import { resolveFromIdentifier } from '../resolvers.js';
|
|
@@ -20,16 +21,11 @@ export class OAuthServerAgent {
|
|
|
20
21
|
}
|
|
21
22
|
if ((endpoint === 'token' || endpoint === 'pushed_authorization_request') &&
|
|
22
23
|
fetchClientAssertion !== undefined) {
|
|
23
|
-
const
|
|
24
|
-
if (jkt === undefined) {
|
|
25
|
-
throw new Error(`DPoP key missing jkt field`);
|
|
26
|
-
}
|
|
24
|
+
const sign = createDpopProofSigner(this.#dpopKey);
|
|
27
25
|
const assertion = await fetchClientAssertion({
|
|
28
|
-
jkt: jkt,
|
|
29
26
|
aud: this.#metadata.issuer,
|
|
30
|
-
createDpopProof: async (url) => {
|
|
31
|
-
|
|
32
|
-
return await sign('POST', url, undefined, undefined);
|
|
27
|
+
createDpopProof: async (url, nonce) => {
|
|
28
|
+
return await sign('POST', url, nonce, undefined);
|
|
33
29
|
},
|
|
34
30
|
});
|
|
35
31
|
payload = { ...payload, ...assertion };
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"server-agent.js","sourceRoot":"","sources":["../../lib/agents/server-agent.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"server-agent.js","sourceRoot":"","sources":["../../lib/agents/server-agent.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,qBAAqB,EAAuB,MAAM,sBAAsB,CAAC;AAGlF,OAAO,EAAE,eAAe,EAAE,MAAM,YAAY,CAAC;AAC7C,OAAO,EAAE,SAAS,EAAE,oBAAoB,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAClF,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AACzF,OAAO,EAAE,qBAAqB,EAAE,MAAM,iBAAiB,CAAC;AAGxD,OAAO,EAAE,IAAI,EAAE,MAAM,kBAAkB,CAAC;AACxC,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,MAAM,OAAO,gBAAgB;IAC5B,MAAM,CAAe;IACrB,SAAS,CAAuC;IAChD,QAAQ,CAAiB;IAEzB,YAAY,QAA8C,EAAE,OAAuB,EAAE;QACpF,IAAI,CAAC,SAAS,GAAG,QAAQ,CAAC;QAC1B,IAAI,CAAC,QAAQ,GAAG,OAAO,CAAC;QACxB,IAAI,CAAC,MAAM,GAAG,eAAe,CAAC,OAAO,EAAE,IAAI,CAAC,CAAC;IAAA,CAC7C;IASD,KAAK,CAAC,OAA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S,CAAC,qCAAqC,CAAC,CAAC;QAC5D,CAAC;QAED,MAAM,KAAK,GAAG,IAAI,CAAC,qBAAqB,CAAC,GAAG,CAAC,CAAC;QAC9C,MAAM,QAAQ,GAAG,MAAM,qBAAqB,CAAC,GAAU,CAAC,CAAC;QAEzD,IAAI,QAAQ,CAAC,QAAQ,CAAC,MAAM,KAAK,IAAI,CAAC,SAAS,CAAC,MAAM,EAAE,CAAC;YACxD,MAAM,IAAI,SAAS,CAAC,wBAAwB,QAAQ,CAAC,QAAQ,CAAC,MAAM,EAAE,CAAC,CAAC;QACzE,CAAC;QAED,OAAO;YACN,KAAK,EAAE,KAAK;YACZ,IAAI,EAAE;gBACL,GAAG,EAAE,GAAU;gBACf,GAAG,EAAE,QAAQ,CAAC,QAAQ,CAAC,GAAG;gBAC1B,MAAM,EAAE,IAAI,CAAC,QAAQ,CAAC,QAAQ,EAAE;oBAC/B,QAAQ;oBACR,wBAAwB;oBACxB,wBAAwB;oBACxB,uCAAuC;oBACvC,qBAAqB;oBACrB,gBAAgB;iBAChB,CAAC;aACF;SACD,CAAC;IAAA,CACF;CACD"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../lib/agents/sessions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,
|
|
1
|
+
{"version":3,"file":"sessions.d.ts","sourceRoot":"","sources":["../../lib/agents/sessions.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAc,OAAO,EAAE,MAAM,mBAAmB,CAAC;AAM7D,MAAM,WAAW,iBAAiB;IACjC,MAAM,CAAC,EAAE,WAAW,CAAC;IACrB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,UAAU,CAAC,EAAE,OAAO,CAAC;CACrB;AAKD,eAAO,MAAM,UAAU,+FAuEtB,CAAC;AAEF,eAAO,MAAM,YAAY,wEAOxB,CAAC;AAEF,eAAO,MAAM,mBAAmB,0CAE/B,CAAC;AAEF,eAAO,MAAM,kBAAkB,mCAE9B,CAAC"}
|