@atproto/oauth-client-browser 0.1.0 → 0.1.1

Sign up to get free protection for your applications and to get access to all the features.
package/README.md ADDED
@@ -0,0 +1,325 @@
1
+ # ATPROTO OAuth Client for the Browser
2
+
3
+ This package provides an OAuth bases `@atproto/api` agent interface for the
4
+ browser. It implements all the OAuth features required by [ATPROTO] (PKCE, DPoP,
5
+ etc.).
6
+
7
+ `@atproto/oauth-client-browser` is destined to front-end applications that do
8
+ not have a back-end server to manage OAuth sessions.
9
+
10
+ > [!IMPORTANT]
11
+ >
12
+ > When a backend server is available, it is recommended to use
13
+ > [`@atproto/oauth-client-node`](https://www.npmjs.com/package/@atproto/oauth-client-node)
14
+ > to manage OAuth sessions from the server side, and use a session cookie to map
15
+ > the OAuth session to the front-end. Because this mechanism allows the backend
16
+ > to invalidate OAuth credentials at scale, this method is more secure than
17
+ > managing OAuth sessions from the front-end directly. Thanks to the added
18
+ > security, the OAuth server will provide longer lived tokens when issued to a
19
+ > BFF (Backend-for-frontend).
20
+
21
+ ## Setup
22
+
23
+ ### Client ID
24
+
25
+ The `client_id` is what identifies your application to the OAuth server. It is
26
+ used to fetch the client metadata, and to initiate the OAuth flow. The
27
+ `client_id` must be a URL that points to the [client
28
+ metadata](#client-metadata).
29
+
30
+ ### Client Metadata
31
+
32
+ Your OAuth client metadata should be hosted at a URL that corresponds to the
33
+ `client_id` of your application. This URL should return a JSON object with the
34
+ client metadata. The client metadata should be configured according to the
35
+ needs of your application, and must respect the [ATPROTO] spec.
36
+
37
+ ```json
38
+ {
39
+ // Must be the same URL as the one used to obtain this JSON object
40
+ "client_id": "https://my-app.com/client-metadata.json",
41
+ "client_name": "My App",
42
+ "client_uri": "https://my-app.com",
43
+ "logo_uri": "https://my-app.com/logo.png",
44
+ "tos_uri": "https://my-app.com/tos",
45
+ "policy_uri": "https://my-app.com/policy",
46
+ "redirect_uris": ["https://my-app.com/callback"],
47
+ "scope": "profile email offline_access",
48
+ "grant_types": ["authorization_code", "refresh_token"],
49
+ "response_types": ["code"],
50
+ "token_endpoint_auth_method": "none",
51
+ "application_type": "web",
52
+ "dpop_bound_access_tokens": true
53
+ }
54
+ ```
55
+
56
+ The client metadata is used to instantiate an OAuth client. There are two ways
57
+ of doing this:
58
+
59
+ 1. Either you "burn" the metadata into your application:
60
+
61
+ ```typescript
62
+ import { BrowserOAuthClient } from '@atproto/oauth-client-browser'
63
+
64
+ const client = new BrowserOAuthClient({
65
+ clientMetadata: {
66
+ // Exact same JSON object as the one returned by the client_id URL
67
+ },
68
+ // ...
69
+ })
70
+ ```
71
+
72
+ 2. Or you load it asynchronously from the URL:
73
+
74
+ ```typescript
75
+ import { OAuthClient } from '@atproto/oauth-client-browser'
76
+
77
+ const client = await BrowserOAuthClient.load({
78
+ clientId: 'https://my-app.com/client-metadata.json',
79
+ // ...
80
+ })
81
+ ```
82
+
83
+ If performances are important to you, it is recommended to burn the metadata
84
+ into the script. Server side rendering techniques can also be used to inject the
85
+ metadata into the script at runtime.
86
+
87
+ ### Handle Resolver
88
+
89
+ Whenever you application will initiate an OAuth flow, it will start to resolve
90
+ the (user provider) APTROTO handle of the user. This is typically done though a
91
+ DNS request. However, since DNS resolution is not available in the browser, a
92
+ backend service must be provided.
93
+
94
+ > [!CAUTION]
95
+ >
96
+ > Not using a handle resolver service hosted by you will leak the user's IP
97
+ > address (and associated ATPROTO handle) to any service you rely on to perform
98
+ > the resolution. This is a privacy concern, that you should be aware of, and
99
+ > that you **must** warn your users about. Bluesky declines any responsibility
100
+ > in case of misusage of the handle resolver service.
101
+
102
+ If a `string` or `URL` object is used as `handleResolver`, the library will
103
+ expect this value to be the URL of a service running the
104
+ `com.atproto.identity.resolveHandle` XRPC Lexicon method.
105
+
106
+ > [!TIP]
107
+ >
108
+ > If you host your own PDS, you can use it's URL as a handle resolver.
109
+
110
+ ```typescript
111
+ import { BrowserOAuthClient } from '@atproto/oauth-client-browser'
112
+
113
+ const client = new BrowserOAuthClient({
114
+ handleResolver: 'https://my-pds.example.com',
115
+ // ...
116
+ })
117
+ ```
118
+
119
+ Alternatively, if a "DNS over HTTPS" (DoH) service is available, it can be used
120
+ to resolve the handle. In this case, the `handleResolver` should be initialized
121
+ with a `AtprotoDohHandleResolver` instance:
122
+
123
+ ```typescript
124
+ import {
125
+ BrowserOAuthClient,
126
+ AtprotoDohHandleResolver,
127
+ } from '@atproto/oauth-client-browser'
128
+
129
+ const client = new BrowserOAuthClient({
130
+ handleResolver: new AtprotoDohHandleResolver('https://my-doh.example.com'),
131
+ // ...
132
+ })
133
+ ```
134
+
135
+ ### Other configuration options
136
+
137
+ In addition to [Client Metadata](#client-metadata) and [Handle
138
+ Resolver](#handle-resolver), the `BrowserOAuthClient` constructor accepts the
139
+ following optional configuration options:
140
+
141
+ - `fetch`: A custom wrapper around the `fetch` function. This can be useful to
142
+ add custom headers, logging, or to use a different fetch implementation.
143
+ Defaults to `window.fetch`.
144
+
145
+ - `responseMode`: `query` or `fragment`. Determines how the authorization
146
+ response is returned to the client. Defaults to `fragment`.
147
+
148
+ - `plcDirectoryUrl`: The URL of the PLC directory. This will typically not be
149
+ needed unless you run an entire ATPROTO stack locally. Defaults to
150
+ `https://plc.directory`.
151
+
152
+ ## Usage
153
+
154
+ Once the `client` is setup, it can be used to initiate & manage OAuth sessions.
155
+
156
+ ### Initializing the client
157
+
158
+ The client will manage the sessions for you. In order to do so, it must first
159
+ initialize itself. Note that this operation must be performed once (and **only
160
+ once**) whenever the web app is loaded.
161
+
162
+ ```typescript
163
+ const result: undefined | { agent: OAuthAgent; state?: string } =
164
+ await client.init()
165
+
166
+ if (result) {
167
+ const { agent, state } = result
168
+ if (state != null) {
169
+ console.log(`${agent.sub} was successfully authenticated (state: ${state})`)
170
+ } else {
171
+ console.log(`${agent.sub} was restored (last active session)`)
172
+ }
173
+ }
174
+ ```
175
+
176
+ The return value can be used to determine if the client was able to restore the
177
+ last used session (`agent` is defined) or if the current navigation is the
178
+ result of an authorization redirect (both `agent` and `state` are defined).
179
+
180
+ ### Initiating an OAuth flow
181
+
182
+ In order to initiate an OAuth flow, we must fist determine which PDS the
183
+ authentication flow will be initiated from. This means that the user must
184
+ provide one of the following information:
185
+
186
+ - The user's ATPROTO handle
187
+ - The user's ATPROTO DID
188
+ - A PDS/Entryway URL
189
+
190
+ Using that information, the OAuthClient will resolve all the needed information
191
+ to initiate the OAuth flow, and redirect the user to the OAuth server.
192
+
193
+ ```typescript
194
+ try {
195
+ await client.signIn('my.handle.com', {
196
+ state: 'some value needed later',
197
+ prompt: 'none', // Attempt to sign in without user interaction (SSO)
198
+ ui_locales: 'fr-CA fr en', // Only supported by some OAuth servers (requires OpenID Connect support + i18n support)
199
+ signal: new AbortController().signal, // Optional, allows to cancel the sign in (and destroy the pending authorization, for better security)
200
+ })
201
+
202
+ console.log('Never executed')
203
+ } catch (err) {
204
+ console.log('The user aborted the authorization process by navigating "back"')
205
+ }
206
+ ```
207
+
208
+ The returned promise will never resolve (because the user will be redirected to
209
+ the OAuth server). The promise will reject if the user cancels the sign in
210
+ (using an `AbortSignal`), or if the user navigates back from the OAuth server
211
+ (because of browser's back-forward cache).
212
+
213
+ ### Handling the OAuth response
214
+
215
+ When the user is redirected back to the application, the OAuth response will be
216
+ available in the URL. The `BrowserOAuthClient` will automatically detect the
217
+ response and handle it when `client.init()` is called.
218
+
219
+ ### Restoring a session
220
+
221
+ The client keeps an internal store of all the sessions that it manages.
222
+ Regardless of the agent that was returned from the `client.init()` call,
223
+ any other session can be loaded into a new agent using the `client.restore()`
224
+ method.
225
+
226
+ ```ts
227
+ const aliceAgent = await client.restore('did:plc:alice')
228
+ const bobAgent = await client.restore('did:plc:bob')
229
+ ```
230
+
231
+ In its current form, the client does not expose methods to list all sessions
232
+ in its store. The app will have to keep track of those itself.
233
+
234
+ ### Watching for session invalidation
235
+
236
+ The client will emit events whenever a session becomes unavailable, allowing to
237
+ trigger global behaviors (e.g. show the login page).
238
+
239
+ ```ts
240
+ client.addEventListener(
241
+ 'deleted',
242
+ (
243
+ event: CustomEvent<{
244
+ sub: string
245
+ cause: TokenRefreshError | TokenRevokedError | TokenInvalidError
246
+ }>,
247
+ ) => {
248
+ const { sub, cause } = event.detail
249
+ console.error(`Session for ${sub} is no longer available (cause: ${cause})`)
250
+ },
251
+ )
252
+ ```
253
+
254
+ ## Usage with `@atproto/api`
255
+
256
+ The `@atproto/api` package provides a way to interact with the `com.atproto` and
257
+ `app.bsky` XRPC lexicons through the `ApiAgent` interface. The `agent` returned
258
+ by the `BrowserOAuthClient` extend the `ApiAgent` class, allowing to use the
259
+ `BrowserOAuthClient` as a regular `ApiAgent` (akin to `AtpAgent` class
260
+ instances).
261
+
262
+ ```typescript
263
+ const aliceAgent = await client.restore('did:plc:alice')
264
+ ```
265
+
266
+ Any refresh of the credentials will happen under the hood, and the new tokens
267
+ will be saved in the session store (in the browser's indexed DB).
268
+
269
+ ## Advances use-cases
270
+
271
+ ### Using in development (localhost)
272
+
273
+ The OAuth server must be able to fetch the `client_metadata` object. The best
274
+ way to do this if you didn't already deployed your app is to use a tunneling
275
+ service like [ngrok](https://ngrok.com/).
276
+
277
+ The `client_id` will then be something like
278
+ `https://<your-ngrok-id>.ngrok.io/<path_to_your_client_metadata>`.
279
+
280
+ There is however a special case for loopback clients. A loopback client is a
281
+ client that runs on `localhost`. In this case, the OAuth server will not be able
282
+ to fetch the `client_metadata` object because `localhost` is not accessible from
283
+ the outside. To work around this, ATPROTO OAuth server are required to support
284
+ this case by providing an hard coded `client_metadata` object for the client.
285
+
286
+ This has several restrictions:
287
+
288
+ 1. There is no way of configuring the client metadata (name, logo, etc.)
289
+ 2. The validity of the refresh tokens (if any) will be very limited (typically 1
290
+ day)
291
+ 3. Silent-sign-in will not be allowed
292
+ 4. Only `http://127.0.0.1:<any_port>` and `http://[::1]:<any_port>` can be used
293
+ as origin for your app, and **not** `http://localhost:<any_port>`. This
294
+ library will automatically redirect the user to an IP based origin
295
+ (`http://127.0.0.1:<port>`) when visiting an origin with `localhost`.
296
+
297
+ Using a loopback client is only recommended for development purposes. A loopback
298
+ client can be instantiated like this:
299
+
300
+ ```typescript
301
+ import { BrowserOAuthClient } from '@atproto/oauth-client-browser'
302
+
303
+ const client = new BrowserOAuthClient({
304
+ handleResolver: 'https://bsky.social',
305
+ // Only works if the current origin is a loopback address:
306
+ clientMetadata: undefined,
307
+ })
308
+ ```
309
+
310
+ If you need to use a special `redirect_uris`, you can configure them like this:
311
+
312
+ ```typescript
313
+ import { BrowserOAuthClient } from '@atproto/oauth-client-browser'
314
+
315
+ const client = new BrowserOAuthClient({
316
+ handleResolver: 'https://bsky.social',
317
+ // Note that the origin of the "client_id" URL must be "http://localhost" when
318
+ // using this configuration, regardless of the actual hostname ("127.0.0.1" or
319
+ // "[::1]"), port or pathname. Only the `redirect_uris` must contain the
320
+ // actual url that will be used to redirect the user back to the application.
321
+ clientMetadata: `http://localhost?redirect_uri=${encodeURIComponent('http://127.0.0.1:8080/callback')}`,
322
+ })
323
+ ```
324
+
325
+ [ATPROTO]: https://atproto.com/ 'AT Protocol'
@@ -1,58 +1,41 @@
1
1
  /// <reference types="node" />
2
2
  import { HandleResolver } from '@atproto-labs/handle-resolver';
3
- import { AuthorizeOptions, OAuthAgent, OAuthClient, Session, TokenSet } from '@atproto/oauth-client';
4
- import { OAuthClientId, OAuthClientMetadataInput, OAuthResponseMode } from '@atproto/oauth-types';
5
- import { DatabaseStore } from './browser-oauth-database.js';
3
+ import { AuthorizeOptions, Fetch, OAuthAgent, OAuthClient } from '@atproto/oauth-client';
4
+ import { OAuthClientIdDiscoverable, OAuthClientIdLoopback, OAuthClientMetadataInput } from '@atproto/oauth-types';
6
5
  export type BrowserOAuthClientOptions = {
7
6
  clientMetadata?: OAuthClientMetadataInput;
8
- handleResolver?: HandleResolver | string | URL;
9
- responseMode?: OAuthResponseMode;
7
+ handleResolver: HandleResolver | string | URL;
8
+ responseMode?: 'query' | 'fragment';
10
9
  plcDirectoryUrl?: string | URL;
11
- crypto?: typeof globalThis.crypto;
12
- fetch?: typeof globalThis.fetch;
10
+ fetch?: Fetch;
13
11
  };
14
- type EventDetails = {
15
- updated: TokenSet;
16
- deleted: {
17
- sub: string;
18
- };
19
- };
20
- type CustomEventListener<T extends keyof EventDetails = keyof EventDetails> = (event: CustomEvent<EventDetails[T]>) => void;
21
- type WrappedSessionStore = Disposable & DatabaseStore<Session>;
22
12
  export type BrowserOAuthClientLoadOptions = Omit<BrowserOAuthClientOptions, 'clientMetadata'> & {
23
- clientId: OAuthClientId;
13
+ clientId: OAuthClientIdDiscoverable | OAuthClientIdLoopback;
24
14
  signal?: AbortSignal;
25
15
  };
26
- export declare class BrowserOAuthClient extends OAuthClient {
16
+ export declare class BrowserOAuthClient extends OAuthClient implements Disposable {
27
17
  static load({ clientId, ...options }: BrowserOAuthClientLoadOptions): Promise<BrowserOAuthClient>;
28
- readonly sessionStore: WrappedSessionStore;
29
- private readonly eventTarget;
30
- private readonly database;
31
- constructor({ clientMetadata, handleResolver, responseMode, plcDirectoryUrl, crypto, fetch, }?: BrowserOAuthClientOptions);
32
- addEventListener<T extends keyof EventDetails>(type: T, callback: CustomEventListener<T> | null, options?: AddEventListenerOptions | boolean): void;
33
- removeEventListener(type: string, callback: CustomEventListener | null, options?: EventListenerOptions | boolean): void;
34
- restoreAll(): Promise<{
35
- [k: string]: OAuthAgent;
36
- }>;
37
- init(sub?: string, refresh?: boolean): Promise<{
18
+ readonly [Symbol.dispose]: () => void;
19
+ constructor({ handleResolver, clientMetadata, responseMode, plcDirectoryUrl, fetch, }: BrowserOAuthClientOptions);
20
+ init(refresh?: boolean): Promise<{
38
21
  agent: OAuthAgent;
39
22
  state: string | null;
40
23
  } | {
41
24
  agent: OAuthAgent;
42
25
  } | undefined>;
43
- signIn(input: string, options?: AuthorizeOptions & {
44
- signal?: AbortSignal;
26
+ restore(sub: string, refresh?: boolean): Promise<OAuthAgent>;
27
+ revoke(sub: string): Promise<void>;
28
+ signIn(input: string, options: AuthorizeOptions & {
29
+ display: 'popup';
45
30
  }): Promise<OAuthAgent>;
31
+ signIn(input: string, options?: AuthorizeOptions): Promise<never>;
46
32
  signInRedirect(input: string, options?: AuthorizeOptions): Promise<never>;
47
- signInPopup(input: string, options?: Omit<AuthorizeOptions, 'state'> & {
48
- signal?: AbortSignal;
49
- }): Promise<OAuthAgent>;
33
+ signInPopup(input: string, options?: Omit<AuthorizeOptions, 'state'>): Promise<OAuthAgent>;
50
34
  private readCallbackParams;
51
35
  signInCallback(): Promise<{
52
36
  agent: OAuthAgent;
53
37
  state: string | null;
54
38
  } | null>;
55
- [Symbol.asyncDispose](): Promise<void>;
39
+ dispose(): void;
56
40
  }
57
- export {};
58
41
  //# sourceMappingURL=browser-oauth-client.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser-oauth-client.d.ts","sourceRoot":"","sources":["../src/browser-oauth-client.ts"],"names":[],"mappings":";AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,+BAA+B,CAAA;AAC9D,OAAO,EACL,gBAAgB,EAChB,UAAU,EAEV,WAAW,EACX,OAAO,EACP,QAAQ,EACT,MAAM,uBAAuB,CAAA;AAC9B,OAAO,EACL,aAAa,EACb,wBAAwB,EACxB,iBAAiB,EAKlB,MAAM,sBAAsB,CAAA;AAE7B,OAAO,EAEL,aAAa,EACd,MAAM,6BAA6B,CAAA;AAKpC,MAAM,MAAM,yBAAyB,GAAG;IACtC,cAAc,CAAC,EAAE,wBAAwB,CAAA;IACzC,cAAc,CAAC,EAAE,cAAc,GAAG,MAAM,GAAG,GAAG,CAAA;IAC9C,YAAY,CAAC,EAAE,iBAAiB,CAAA;IAChC,eAAe,CAAC,EAAE,MAAM,GAAG,GAAG,CAAA;IAE9B,MAAM,CAAC,EAAE,OAAO,UAAU,CAAC,MAAM,CAAA;IACjC,KAAK,CAAC,EAAE,OAAO,UAAU,CAAC,KAAK,CAAA;CAChC,CAAA;AAED,KAAK,YAAY,GAAG;IAClB,OAAO,EAAE,QAAQ,CAAA;IACjB,OAAO,EAAE;QAAE,GAAG,EAAE,MAAM,CAAA;KAA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6B;IAezE,QAAQ,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE,MAAM,IAAI,CAAA;gBAEzB,EACV,cAAc,EACd,cAEC,EAED,YAAyB,EACzB,eAA2B,EAC3B,KAAiB,GAClB,EAAE,yBAAyB;IAyEtB,IAAI,CAAC,OAAO,CAAC,EAAE,OAAO;;;;;;IAqBtB,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,OAAO;IAMtC,MAAM,CAAC,GAAG,EAAE,MAAM;IAKxB,MAAM,CACJ,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,gBAAgB,GAAG;QAAE,OAAO,EAAE,OAAO,CAAA;KAAE,GAC/C,OAAO,CAAC,UAAU,CAAC;IACtB,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,KAAK,CAAC;IAS3D,cAAc,CAClB,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,KAAK,CAAC;IAqBX,WAAW,CACf,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,IAAI,CAAC,gBAAgB,EAAE,OAAO,CAAC,GACxC,OAAO,CAAC,UAAU,CAAC;IA+EtB,OAAO,CAAC,kBAAkB;IAuBpB,cAAc;;;;IAqFpB,OAAO;CAGR"}
@@ -1,4 +1,5 @@
1
1
  "use strict";
2
+ var _a;
2
3
  Object.defineProperty(exports, "__esModule", { value: true });
3
4
  exports.BrowserOAuthClient = void 0;
4
5
  const oauth_client_1 = require("@atproto/oauth-client");
@@ -7,97 +8,47 @@ const browser_oauth_database_js_1 = require("./browser-oauth-database.js");
7
8
  const browser_runtime_implementation_js_1 = require("./browser-runtime-implementation.js");
8
9
  const errors_js_1 = require("./errors.js");
9
10
  const util_js_1 = require("./util.js");
10
- const initEvent = (type, detail) => new CustomEvent(type, { detail, cancelable: false, bubbles: false });
11
11
  const NAMESPACE = `@@atproto/oauth-client-browser`;
12
12
  //- Popup channel
13
13
  const POPUP_CHANNEL_NAME = `${NAMESPACE}(popup-channel)`;
14
14
  const POPUP_STATE_PREFIX = `${NAMESPACE}(popup-state):`;
15
- //- Deleted channel
16
- const deletedChannel = new BroadcastChannel(`${NAMESPACE}(deleted-channel)`);
17
- const wrapSessionStore = (dbStore, eventTarget) => {
18
- const store = {
19
- getKeys: async () => {
20
- return dbStore.getKeys();
21
- },
22
- get: async (sub) => {
23
- return dbStore.get(sub);
24
- },
25
- set: async (sub, session) => {
26
- await dbStore.set(sub, session);
27
- eventTarget.dispatchEvent(initEvent('updated', session.tokenSet));
28
- },
29
- del: async (sub) => {
30
- await dbStore.del(sub);
31
- deletedChannel.postMessage(sub);
32
- eventTarget.dispatchEvent(initEvent('deleted', { sub }));
33
- },
34
- clear: async () => {
35
- await dbStore.clear?.();
36
- },
37
- [Symbol.dispose]: () => {
38
- deletedChannel.removeEventListener('message', onMessage);
39
- },
40
- };
41
- const onMessage = (event) => {
42
- // Listen for "deleted" events from other windows. The content will already
43
- // have been deleted from the store so we only need to notify the listeners.
44
- if (event.source !== window) {
45
- const sub = event.data;
46
- eventTarget.dispatchEvent(initEvent('deleted', { sub }));
47
- }
48
- };
49
- deletedChannel.addEventListener('message', onMessage);
50
- return store;
51
- };
15
+ const syncChannel = new BroadcastChannel(`${NAMESPACE}(synchronization-channel)`);
52
16
  class BrowserOAuthClient extends oauth_client_1.OAuthClient {
53
17
  static async load({ clientId, ...options }) {
54
18
  if ((0, oauth_types_1.isOAuthClientIdLoopback)(clientId)) {
55
- return new BrowserOAuthClient({
56
- clientMetadata: (0, oauth_types_1.atprotoLoopbackClientMetadata)(clientId),
57
- ...options,
58
- });
19
+ const clientMetadata = (0, oauth_types_1.atprotoLoopbackClientMetadata)(clientId);
20
+ return new BrowserOAuthClient({ clientMetadata, ...options });
59
21
  }
60
22
  else if ((0, oauth_types_1.isOAuthClientIdDiscoverable)(clientId)) {
61
- const fetch = options?.fetch ?? globalThis.fetch;
62
- const request = new Request(clientId, {
63
- redirect: 'error',
64
- signal: options.signal,
65
- });
66
- const response = await fetch(request);
67
- if (response.status !== 200) {
68
- throw new TypeError(`Failed to fetch client metadata: ${response.status}`);
69
- }
70
- const mime = response.headers.get('content-type')?.split(';')[0].trim();
71
- if (mime !== 'application/json') {
72
- throw new TypeError(`Invalid content type: ${mime}`);
73
- }
74
- const json = await response.json();
75
- options.signal?.throwIfAborted();
76
- return new BrowserOAuthClient({
77
- clientMetadata: oauth_types_1.oauthClientMetadataSchema.parse(json),
23
+ const clientMetadata = await oauth_client_1.OAuthClient.fetchMetadata({
24
+ clientId,
78
25
  ...options,
79
26
  });
27
+ return new BrowserOAuthClient({ clientMetadata, ...options });
80
28
  }
81
29
  else {
82
30
  throw new TypeError(`Invalid client id: ${clientId}`);
83
31
  }
84
32
  }
85
- constructor({ clientMetadata, handleResolver = 'https://bsky.social',
86
- // "fragment" is safer as it is not sent to the server
87
- responseMode = 'fragment', plcDirectoryUrl = 'https://plc.directory', crypto = globalThis.crypto, fetch = globalThis.fetch, } = {}) {
33
+ constructor({ handleResolver, clientMetadata = (0, oauth_types_1.atprotoLoopbackClientMetadata)((0, util_js_1.buildLoopbackClientId)(window.location)),
34
+ // "fragment" is a safer default as the query params will not be sent to the server
35
+ responseMode = 'fragment', plcDirectoryUrl = undefined, fetch = undefined, }) {
36
+ if (!globalThis.crypto?.subtle) {
37
+ throw new Error('WebCrypto API is required');
38
+ }
39
+ if (!['query', 'fragment'].includes(responseMode)) {
40
+ // Make sure "form_post" is not used as it is not supported in the browser
41
+ throw new TypeError(`Invalid response mode: ${responseMode}`);
42
+ }
88
43
  const database = new browser_oauth_database_js_1.BrowserOAuthDatabase();
89
- const eventTarget = new EventTarget();
90
- const sessionStore = wrapSessionStore(database.getSessionStore(), eventTarget);
91
44
  super({
92
- clientMetadata: clientMetadata == null
93
- ? (0, oauth_types_1.atprotoLoopbackClientMetadata)((0, util_js_1.buildLoopbackClientId)(window.location))
94
- : clientMetadata,
45
+ clientMetadata,
95
46
  responseMode,
96
47
  fetch,
97
- runtimeImplementation: new browser_runtime_implementation_js_1.BrowserRuntimeImplementation(crypto),
98
48
  plcDirectoryUrl,
99
49
  handleResolver,
100
- sessionStore,
50
+ runtimeImplementation: new browser_runtime_implementation_js_1.BrowserRuntimeImplementation(),
51
+ sessionStore: database.getSessionStore(),
101
52
  stateStore: database.getStateStore(),
102
53
  didCache: database.getDidCache(),
103
54
  handleCache: database.getHandleCache(),
@@ -105,49 +56,70 @@ class BrowserOAuthClient extends oauth_client_1.OAuthClient {
105
56
  authorizationServerMetadataCache: database.getAuthorizationServerMetadataCache(),
106
57
  protectedResourceMetadataCache: database.getProtectedResourceMetadataCache(),
107
58
  });
108
- Object.defineProperty(this, "sessionStore", {
59
+ Object.defineProperty(this, _a, {
109
60
  enumerable: true,
110
61
  configurable: true,
111
62
  writable: true,
112
63
  value: void 0
113
64
  });
114
- Object.defineProperty(this, "eventTarget", {
115
- enumerable: true,
116
- configurable: true,
117
- writable: true,
118
- value: void 0
65
+ // TODO: replace with AsyncDisposableStack once they are standardized
66
+ const ac = new AbortController();
67
+ const { signal } = ac;
68
+ this[Symbol.dispose] = () => ac.abort();
69
+ signal.addEventListener('abort', () => database[Symbol.asyncDispose](), {
70
+ once: true,
119
71
  });
120
- Object.defineProperty(this, "database", {
121
- enumerable: true,
122
- configurable: true,
123
- writable: true,
124
- value: void 0
72
+ // Keep track of the current session
73
+ this.addEventListener('deleted', ({ detail: { sub } }) => {
74
+ if (localStorage.getItem(`${NAMESPACE}(sub)`) === sub) {
75
+ localStorage.removeItem(`${NAMESPACE}(sub)`);
76
+ }
125
77
  });
126
- this.sessionStore = sessionStore;
127
- this.eventTarget = eventTarget;
128
- this.database = database;
129
- fixLocation(this.clientMetadata);
130
- }
131
- addEventListener(type, callback, options) {
132
- this.eventTarget.addEventListener(type, callback, options);
133
- }
134
- removeEventListener(type, callback, options) {
135
- this.eventTarget.removeEventListener(type, callback, options);
136
- }
137
- async restoreAll() {
138
- const subs = await this.sessionStore.getKeys();
139
- return Object.fromEntries(await Promise.all(subs.map(async (sub) => [sub, await this.restore(sub, false)])));
78
+ // Session synchronization across tabs
79
+ for (const type of ['deleted', 'updated']) {
80
+ this.sessionGetter.addEventListener(type, ({ detail }) => {
81
+ // Notify other tabs when a session is deleted or updated
82
+ syncChannel.postMessage([type, detail]);
83
+ });
84
+ }
85
+ syncChannel.addEventListener('message', (event) => {
86
+ if (event.source !== window) {
87
+ // Trigger listeners when an event is received from another tab
88
+ const [type, detail] = event.data;
89
+ this.dispatchCustomEvent(type, detail);
90
+ }
91
+ },
92
+ // Remove the listener when the client is disposed
93
+ { signal });
140
94
  }
141
- async init(sub, refresh) {
95
+ async init(refresh) {
96
+ await fixLocation(this.clientMetadata);
142
97
  const signInResult = await this.signInCallback();
143
98
  if (signInResult) {
99
+ localStorage.setItem(`${NAMESPACE}(sub)`, signInResult.agent.sub);
144
100
  return signInResult;
145
101
  }
146
- else if (sub) {
147
- const agent = await this.restore(sub, refresh);
148
- return { agent };
102
+ const sub = localStorage.getItem(`${NAMESPACE}(sub)`);
103
+ if (sub) {
104
+ try {
105
+ const agent = await this.restore(sub, refresh);
106
+ return { agent };
107
+ }
108
+ catch (err) {
109
+ localStorage.removeItem(`${NAMESPACE}(sub)`);
110
+ throw err;
111
+ }
149
112
  }
150
113
  }
114
+ async restore(sub, refresh) {
115
+ const agent = await super.restore(sub, refresh);
116
+ localStorage.setItem(`${NAMESPACE}(sub)`, agent.sub);
117
+ return agent;
118
+ }
119
+ async revoke(sub) {
120
+ localStorage.removeItem(`${NAMESPACE}(sub)`);
121
+ return super.revoke(sub);
122
+ }
151
123
  async signIn(input, options) {
152
124
  if (options?.display === 'popup') {
153
125
  return this.signInPopup(input, options);
@@ -161,7 +133,10 @@ class BrowserOAuthClient extends oauth_client_1.OAuthClient {
161
133
  window.location.href = url.href;
162
134
  // back-forward cache
163
135
  return new Promise((resolve, reject) => {
164
- setTimeout(() => reject(new Error('User navigated back')), 5e3);
136
+ setTimeout((err) => {
137
+ // Take the opportunity to proactively cancel the pending request
138
+ this.abortRequest(url).then(() => reject(err), (reason) => reject(new AggregateError([err, reason])));
139
+ }, 5e3, new Error('User navigated back'));
165
140
  });
166
141
  }
167
142
  async signInPopup(input, options) {
@@ -212,7 +187,7 @@ class BrowserOAuthClient extends oauth_client_1.OAuthClient {
212
187
  const sub = result.value;
213
188
  try {
214
189
  options?.signal?.throwIfAborted();
215
- resolve(await this.restore(sub));
190
+ resolve(await this.restore(sub, false));
216
191
  }
217
192
  catch (err) {
218
193
  reject(err);
@@ -250,7 +225,8 @@ class BrowserOAuthClient extends oauth_client_1.OAuthClient {
250
225
  // Replace the current history entry without the params (this will prevent
251
226
  // the following code to run again if the user refreshes the page)
252
227
  history.replaceState(null, '', location.pathname);
253
- const sendResult = (message) => {
228
+ // Utility function to send the result of the popup to the parent window
229
+ const sendPopupResult = (message) => {
254
230
  const popupChannel = new BroadcastChannel(POPUP_CHANNEL_NAME);
255
231
  return new Promise((resolve) => {
256
232
  const cleanup = (result) => {
@@ -259,9 +235,6 @@ class BrowserOAuthClient extends oauth_client_1.OAuthClient {
259
235
  popupChannel.close();
260
236
  resolve(result);
261
237
  };
262
- const onTimeout = () => {
263
- cleanup(false);
264
- };
265
238
  const onMessage = ({ data }) => {
266
239
  if ('ack' in data && message.key === data.key)
267
240
  cleanup(true);
@@ -269,13 +242,13 @@ class BrowserOAuthClient extends oauth_client_1.OAuthClient {
269
242
  popupChannel.addEventListener('message', onMessage);
270
243
  popupChannel.postMessage(message);
271
244
  // Receiving of "ack" should be very fast, giving it 500 ms anyway
272
- const timer = setTimeout(onTimeout, 500);
245
+ const timer = setTimeout(cleanup, 500, false);
273
246
  });
274
247
  };
275
248
  return this.callback(params)
276
249
  .then(async (result) => {
277
250
  if (result.state?.startsWith(POPUP_STATE_PREFIX)) {
278
- const receivedByParent = await sendResult({
251
+ const receivedByParent = await sendPopupResult({
279
252
  key: result.state.slice(POPUP_STATE_PREFIX.length),
280
253
  result: {
281
254
  status: 'fulfilled',
@@ -292,7 +265,7 @@ class BrowserOAuthClient extends oauth_client_1.OAuthClient {
292
265
  .catch(async (err) => {
293
266
  if (err instanceof oauth_client_1.OAuthCallbackError &&
294
267
  err.state?.startsWith(POPUP_STATE_PREFIX)) {
295
- await sendResult({
268
+ await sendPopupResult({
296
269
  key: err.state.slice(POPUP_STATE_PREFIX.length),
297
270
  result: {
298
271
  status: 'rejected',
@@ -316,13 +289,12 @@ class BrowserOAuthClient extends oauth_client_1.OAuthClient {
316
289
  throw err;
317
290
  });
318
291
  }
319
- async [Symbol.asyncDispose]() {
320
- // TODO This should be implemented using a DisposableStack
321
- await this.sessionStore[Symbol.dispose]();
322
- await this.database[Symbol.asyncDispose]();
292
+ dispose() {
293
+ this[Symbol.dispose]();
323
294
  }
324
295
  }
325
296
  exports.BrowserOAuthClient = BrowserOAuthClient;
297
+ _a = Symbol.dispose;
326
298
  /**
327
299
  * Since "localhost" is often used either in IP mode or in hostname mode,
328
300
  * and because the redirect uris must use the IP mode, we need to make sure
@@ -333,18 +305,20 @@ exports.BrowserOAuthClient = BrowserOAuthClient;
333
305
  * redirect uris.
334
306
  */
335
307
  function fixLocation(clientMetadata) {
336
- if (clientMetadata.client_id !== 'http://localhost/')
308
+ if (!(0, oauth_types_1.isOAuthClientIdLoopback)(clientMetadata.client_id))
337
309
  return;
338
310
  if (window.location.hostname !== 'localhost')
339
311
  return;
340
312
  const locationUrl = new URL(window.location.href);
341
313
  for (const uri of clientMetadata.redirect_uris) {
342
314
  const url = new URL(uri);
343
- if (url.port === locationUrl.port &&
315
+ if ((url.hostname === '127.0.0.1' || url.hostname === '[::1]') &&
316
+ (!url.port || url.port === locationUrl.port) &&
344
317
  url.protocol === locationUrl.protocol &&
345
- (url.hostname === '127.0.0.1' || url.hostname === '[::1]')) {
346
- window.location.hostname = url.hostname;
347
- // Prevent APP from loading on the wrong hostname
318
+ url.pathname === locationUrl.pathname) {
319
+ url.port = locationUrl.port;
320
+ window.location.href = url.href;
321
+ // Prevent init() on the wrong origin
348
322
  throw new Error('Redirecting to loopback IP...');
349
323
  }
350
324
  }
@@ -1 +1 @@
1
- {"version":3,"file":"browser-oauth-client.js","sourceRoot":"","sources":["../src/browser-oauth-client.ts"],"names":[],"mappings":";;;AACA,wDAO8B;AAC9B,sDAQ6B;AAE7B,2EAGoC;AACpC,2FAAkF;AAClF,2CAA+D;AAC/D,uCAAiD;AAqBjD,MAAM,SAAS,GAAG,CAChB,IAAO,EACP,MAAuB,EACvB,EAAE,CAAC,IAAI,WAAW,CAAC,IAAI,EAAE,EAAE,MAAM,EAAE,UAAU,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,CAAC,CAAA;AAEzE,MAAM,SAAS,GAAG,gCAAgC,CAAA;AAElD,iBAAiB;AAEjB,MAAM,kBAAkB,GAAG,GAAG,SAAS,iBAAiB,CAAA;AACxD,MAAM,kBAAkB,GAAG,GAAG,SAAS,gBAAgB,CAAA;AAcvD,mBAAmB;AAEnB,MAAM,cAAc,GAAG,IAAI,gBAAgB,CAAC,GAAG,SAAS,mBAAmB,CAAC,CAAA;AAG5E,MAAM,gBAAgB,GAAG,CACvB,OAA+B,EAC/B,WAAwB,EACxB,EAAE;IACF,MAAM,KAAK,GAAwB;QACjC,OAAO,EAAE,KAAK,IAAI,EAAE;YAClB,OAAO,OAAO,CAAC,OAAO,EAAE,CAAA;QAC1B,CAAC;QACD,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,EAAE;YACjB,OAAO,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAA;QACzB,CAAC;QACD,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,OAAO,EAAE,EAAE;YAC1B,MAAM,OAAO,CAAC,GAAG,CAAC,GAAG,EAAE,OAAO,CAAC,CAAA;YAE/B,WAAW,CAAC,aAAa,CAAC,SAAS,CAAC,SAAS,EAAE,OAAO,CAAC,QAAQ,CAAC,CAAC,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AAQ,KAAK,WAAW;QAAE,OAAM;IAEpD,MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAEjD,KAAK,MAAM,GAAG,IAAI,cAAc,CAAC,aAAa,EAAE,CAAC;QAC/C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAA;QACxB,IACE,CAAC,GAAG,CAAC,QAAQ,KAAK,WAAW,IAAI,GAAG,CAAC,QAAQ,KAAK,OAAO,CAAC;YAC1D,CAAC,CAAC,GAAG,CAAC,IAAI,IAAI,GAAG,CAAC,IAAI,KAAK,WAAW,CAAC,IAAI,CAAC;YAC5C,GAAG,CAAC,QAAQ,KAAK,WAAW,CAAC,QAAQ;YACrC,GAAG,CAAC,QAAQ,KAAK,WAAW,CAAC,QAAQ,EACrC,CAAC;YACD,GAAG,CAAC,IAAI,GAAG,WAAW,CAAC,IAAI,CAAA;YAC3B,MAAM,CAAC,QAAQ,CAAC,IAAI,GAAG,GAAG,CAAC,IAAI,CAAA;YAE/B,qCAAqC;YACrC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAA;QAClD,CAAC;IACH,CAAC;IAED,MAAM,IAAI,KAAK,CACb,iDAAiD,WAAW,EAAE,CAC/D,CAAA;AACH,CAAC"}
@@ -30,9 +30,7 @@ export type Schema = {
30
30
  authorizationServerMetadataCache: Item<OAuthAuthorizationServerMetadata>;
31
31
  protectedResourceMetadataCache: Item<OAuthProtectedResourceMetadata>;
32
32
  };
33
- export type DatabaseStore<V extends Value> = SimpleStore<string, V> & {
34
- getKeys: () => Promise<string[]>;
35
- };
33
+ export type DatabaseStore<V extends Value> = SimpleStore<string, V>;
36
34
  export type BrowserOAuthDatabaseOptions = {
37
35
  name?: string;
38
36
  durability?: 'strict' | 'relaxed';
@@ -1 +1 @@
1
- {"version":3,"file":"browser-oauth-database.d.ts","sourceRoot":"","sources":["../src/browser-oauth-database.ts"],"names":[],"mappings":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CAAC,GAAG,WAAW,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAA;QAC1E,MAAM,EAAE,CAAC,OAAO,EAAE,MAAM,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,KAAK,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC,CAAA;QAC3D,SAAS,EAAE,CAAC,KAAK,EAAE,CAAC,KAAK,IAAI,GAAG,IAAI,CAAA;KACrC,GACA,aAAa,CAAC,CAAC,CAAC;IAqCnB,eAAe,IAAI,aAAa,CAAC,OAAO,CAAC;IAiBzC,aAAa,IAAI,aAAa,CAAC,iBAAiB,CAAC;IAcjD,iBAAiB,IAAI,SAAS,GAAG,aAAa,CAAC,MAAM,CAAC;IAQtD,WAAW,IAAI,SAAS,GAAG,aAAa,CAAC,WAAW,CAAC;IAQrD,cAAc,IAAI,SAAS,GAAG,aAAa,CAAC,cAAc,CAAC;IAQ3D,mCAAmC,IAC/B,SAAS,GACT,aAAa,CAAC,gCAAgC,CAAC;IAQnD,iCAAiC,IAC7B,SAAS,GACT,aAAa,CAAC,8BAA8B,CAAC;IAQ3C,OAAO;IAaP,CAAC,MAAM,CAAC,YAAY,CAAC;CAc5B"}
@@ -72,10 +72,6 @@ class BrowserOAuthDatabase {
72
72
  // Item found and valid. Decode
73
73
  return decode(item.value);
74
74
  },
75
- getKeys: async () => {
76
- const keys = await this.run(name, 'readonly', (store) => store.getAllKeys());
77
- return keys.filter((key) => typeof key === 'string');
78
- },
79
75
  set: async (key, value) => {
80
76
  // Create encoded item record
81
77
  const item = {
@@ -165,10 +161,15 @@ class BrowserOAuthDatabase {
165
161
  }
166
162
  async [(_BrowserOAuthDatabase_dbPromise = new WeakMap(), _BrowserOAuthDatabase_cleanupInterval = new WeakMap(), Symbol.asyncDispose)]() {
167
163
  clearInterval(__classPrivateFieldGet(this, _BrowserOAuthDatabase_cleanupInterval, "f"));
164
+ __classPrivateFieldSet(this, _BrowserOAuthDatabase_cleanupInterval, undefined, "f");
168
165
  const dbPromise = __classPrivateFieldGet(this, _BrowserOAuthDatabase_dbPromise, "f");
169
166
  __classPrivateFieldSet(this, _BrowserOAuthDatabase_dbPromise, Promise.reject(new Error('Database has been disposed')), "f");
170
- const db = await dbPromise;
171
- await (db[Symbol.asyncDispose] || db[Symbol.dispose]).call(db);
167
+ // Avoid "unhandled promise rejection"
168
+ __classPrivateFieldGet(this, _BrowserOAuthDatabase_dbPromise, "f").catch(() => null);
169
+ // Spec recommends not to throw errors in dispose
170
+ const db = await dbPromise.catch(() => null);
171
+ if (db)
172
+ await (db[Symbol.asyncDispose] || db[Symbol.dispose]).call(db);
172
173
  }
173
174
  }
174
175
  exports.BrowserOAuthDatabase = BrowserOAuthDatabase;
@@ -1 +1 @@
1
- {"version":3,"file":"browser-oauth-database.js","sourceRoot":"","sources":["../src/browser-oauth-database.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAIA,0DAAqD;AAOrD,oDAAyD;AAazD,SAAS,SAAS,CAAC,GAAQ;IACzB,IAAI,CAAC,CAAC,GAAG,YAAY,4BAAY,CAAC,IAAI,CAAC,GAAG,CAAC,GAAG,EAAE,CAAC;QAC/C,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAA;IACvC,CAAC;IACD,OAAO;QACL,KAAK,EAAE,GAAG,CAAC,GAAG;QACd,OAAO,EAAE,GAAG,CAAC,aAAa;KAC3B,CAAA;AACH,CAAC;AAED,KAAK,UAAU,SAAS,CAAC,OAAmB;IAC1C,OAAO,4BAAY,CAAC,WAAW,CAAC,OAAO,CAAC,OAAO,EAAE,OAAO,CAAC,KAAK,CAAC,CAAA;AACjE,CAAC;AA4BD,MAAM,MAAM,GAA6B;IACvC,OAAO;IACP,SAAS;IAET,UAAU;IACV,gBAAgB;IAChB,aAAa;IACb,kCAAkC;IAClC,gCAAgC;CACjC,CAAA;AAQD,MAAa,oBAAoB;IAI/B,YAAY,OAAqC;QAHjD,kDAA+B;QAC/B,wDAAiD;QAG/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C,WAAW,CAAC,IAAI,CAAC;iBACjB,KAAK,CAAC,WAAW,CAAC;iBAClB,SAAS,CAAC,WAAW,CAAC,UAAU,CAAC,IAAI,CAAC,GAAG,EAAE,CAAC,CAAC,CACjD,CAAA;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,0GAAC,MAAM,CAAC,YAAY,EAAC;QACzB,aAAa,CAAC,uBAAA,IAAI,6CAAiB,CAAC,CAAA;QACpC,uBAAA,IAAI,yCAAoB,SAAS,MAAA,CAAA;QAEjC,MAAM,SAAS,GAAG,uBAAA,IAAI,uCAAW,CAAA;QACjC,uBAAA,IAAI,mCAAc,OAAO,CAAC,MAAM,CAAC,IAAI,KAAK,CAAC,4BAA4B,CAAC,CAAC,MAAA,CAAA;QAEzE,sCAAsC;QACtC,uBAAA,IAAI,uCAAW,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;QAEjC,iDAAiD;QACjD,MAAM,EAAE,GAAG,MAAM,SAAS,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,IAAI,CAAC,CAAA;QAC5C,IAAI,EAAE;YAAE,MAAM,CAAC,EAAE,CAAC,MAAM,CAAC,YAAY,CAAC,IAAI,EAAE,CAAC,MAAM,CAAC,OAAO,CAAC,CAAC,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACxE,CAAC;CACF;AAxLD,oDAwLC"}
@@ -1,10 +1,9 @@
1
- import { DigestAlgorithm, Key, RuntimeImplementation } from '@atproto/oauth-client';
1
+ import { DigestAlgorithm, Key, RuntimeImplementation, RuntimeLock } from '@atproto/oauth-client';
2
2
  export declare class BrowserRuntimeImplementation implements RuntimeImplementation {
3
- private crypto;
4
- requestLock: (<T>(name: string, fn: () => T | PromiseLike<T>) => Promise<T>) | undefined;
5
- constructor(crypto?: Crypto);
3
+ requestLock: RuntimeLock | undefined;
4
+ constructor();
6
5
  createKey(algs: string[]): Promise<Key>;
7
6
  getRandomValues(byteLength: number): Uint8Array;
8
- digest(bytes: Uint8Array, algorithm: DigestAlgorithm): Promise<Uint8Array>;
7
+ digest(data: Uint8Array, { name }: DigestAlgorithm): Promise<Uint8Array>;
9
8
  }
10
9
  //# sourceMappingURL=browser-runtime-implementation.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser-runtime-implementation.d.ts","sourceRoot":"","sources":["../src/browser-runtime-implementation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,GAAG,EACH,qBAAqB,EACtB,MAAM,uBAAuB,CAAA;AAE9B,qBAAa,4BAA6B,YAAW,qBAAqB;IAO5D,OAAO,CAAC,MAAM;IAL1B,WAAW,aACG,MAAM,MAAM,MAAM,CAAC,GAAG,YAAY,CAAC,CAAC,KAAG,QAAQ,CAAC,CAAC,cAElD;gBAEO,MAAM,SAAoB;IAiBxC,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAI7C,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU;IAMzC,MAAM,CACV,KAAK,EAAE,UAAU,EACjB,SAAS,EAAE,eAAe,GACzB,OAAO,CAAC,UAAU,CAAC;CAOvB"}
1
+ {"version":3,"file":"browser-runtime-implementation.d.ts","sourceRoot":"","sources":["../src/browser-runtime-implementation.ts"],"names":[],"mappings":"AACA,OAAO,EACL,eAAe,EACf,GAAG,EACH,qBAAqB,EACrB,WAAW,EACZ,MAAM,uBAAuB,CAAA;AAU9B,qBAAa,4BAA6B,YAAW,qBAAqB;IACxE,WAAW,0BAAoB;;IAmBzB,SAAS,CAAC,IAAI,EAAE,MAAM,EAAE,GAAG,OAAO,CAAC,GAAG,CAAC;IAI7C,eAAe,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU;IAIzC,MAAM,CACV,IAAI,EAAE,UAAU,EAChB,EAAE,IAAI,EAAE,EAAE,eAAe,GACxB,OAAO,CAAC,UAAU,CAAC;CAYvB"}
@@ -2,28 +2,25 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.BrowserRuntimeImplementation = void 0;
4
4
  const jwk_webcrypto_1 = require("@atproto/jwk-webcrypto");
5
+ /**
6
+ * @see {@link // https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request}
7
+ */
8
+ const nativeRequestLock = navigator.locks?.request
9
+ ? (name, fn) => navigator.locks.request(name, { mode: 'exclusive' }, async () => fn())
10
+ : undefined;
5
11
  class BrowserRuntimeImplementation {
6
- constructor(crypto = globalThis.crypto) {
7
- Object.defineProperty(this, "crypto", {
8
- enumerable: true,
9
- configurable: true,
10
- writable: true,
11
- value: crypto
12
- });
13
- // https://developer.mozilla.org/en-US/docs/Web/API/LockManager/request
12
+ constructor() {
14
13
  Object.defineProperty(this, "requestLock", {
15
14
  enumerable: true,
16
15
  configurable: true,
17
16
  writable: true,
18
- value: navigator.locks?.request
19
- ? (name, fn) => navigator.locks.request(name, { mode: 'exclusive' }, async () => fn())
20
- : undefined
17
+ value: nativeRequestLock
21
18
  });
22
- if (!crypto?.subtle) {
19
+ if (typeof crypto !== 'object' || !crypto?.subtle) {
23
20
  throw new Error('Crypto with CryptoSubtle is required. If running in a browser, make sure the current page is loaded over HTTPS.');
24
21
  }
25
22
  if (!this.requestLock) {
26
- // There is no real need to polyfill this on older browsers. The
23
+ // There is no real need to polyfill this on older browsers. Indeed, the
27
24
  // oauth-client library will try and recover from concurrency issues when
28
25
  // refreshing tokens.
29
26
  console.warn('Locks API not available. You should consider using a more recent browser.');
@@ -33,24 +30,20 @@ class BrowserRuntimeImplementation {
33
30
  return jwk_webcrypto_1.WebcryptoKey.generate(algs);
34
31
  }
35
32
  getRandomValues(byteLength) {
36
- const bytes = new Uint8Array(byteLength);
37
- this.crypto.getRandomValues(bytes);
38
- return bytes;
33
+ return crypto.getRandomValues(new Uint8Array(byteLength));
39
34
  }
40
- async digest(bytes, algorithm) {
41
- const buffer = await this.crypto.subtle.digest(digestAlgorithmToSubtle(algorithm), bytes);
42
- return new Uint8Array(buffer);
35
+ async digest(data, { name }) {
36
+ switch (name) {
37
+ case 'sha256':
38
+ case 'sha384':
39
+ case 'sha512': {
40
+ const buf = await crypto.subtle.digest(`SHA-${name.slice(3)}`, data);
41
+ return new Uint8Array(buf);
42
+ }
43
+ default:
44
+ throw new Error(`Unsupported digest algorithm: ${name}`);
45
+ }
43
46
  }
44
47
  }
45
48
  exports.BrowserRuntimeImplementation = BrowserRuntimeImplementation;
46
- function digestAlgorithmToSubtle({ name, }) {
47
- switch (name) {
48
- case 'sha256':
49
- case 'sha384':
50
- case 'sha512':
51
- return `SHA-${name.slice(-3)}`;
52
- default:
53
- throw new TypeError(`Unknown hash algorithm ${name}`);
54
- }
55
- }
56
49
  //# sourceMappingURL=browser-runtime-implementation.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"browser-runtime-implementation.js","sourceRoot":"","sources":["../src/browser-runtime-implementation.ts"],"names":[],"mappings":";;;AAAA,0DAAqD;AAOrD,MAAa,4BAA4B;IAOvC,YAAoB,SAAS,UAAU,CAAC,MAAM;QAAlC;;;;mBAAQ,MAAM;WAAoB;QAN9C,uEAAuE;QACvE;;;;mBAAc,SAAS,CAAC,KAAK,EAAE,OAAO;gBACpC,CAAC,CAAC,CAAI,IAAY,EAAE,EAA4B,EAAc,EAAE,CAC5D,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,KAAK,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;gBAC1E,CAAC,CAAC,SAAS;WAAA;QAGX,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CACb,iHAAiH,CAClH,CAAA;QACH,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,gEAAgE;YAChE,yEAAyE;YACzE,qBAAqB;YACrB,OAAO,CAAC,IAAI,CACV,2EAA2E,CAC5E,CAAA;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,IAAc;QAC5B,OAAO,4BAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IACpC,CAAC;IAED,eAAe,CAAC,UAAkB;QAChC,MAAM,KAAK,GAAG,IAAI,UAAU,CAAC,UAAU,CAAC,CAAA;QACxC,IAAI,CAAC,MAAM,CAAC,eAAe,CAAC,KAAK,CAAC,CAAA;QAClC,OAAO,KAAK,CAAA;IACd,CAAC;IAED,KAAK,CAAC,MAAM,CACV,KAAiB,EACjB,SAA0B;QAE1B,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,MAAM,CAAC,MAAM,CAAC,MAAM,CAC5C,uBAAuB,CAAC,SAAS,CAAC,EAClC,KAAK,CACN,CAAA;QACD,OAAO,IAAI,UAAU,CAAC,MAAM,CAAC,CAAA;IAC/B,CAAC;CACF;AA5CD,oEA4CC;AAED,SAAS,uBAAuB,CAAC,EAC/B,IAAI,GACY;IAChB,QAAQ,IAAI,EAAE,CAAC;QACb,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ,CAAC;QACd,KAAK,QAAQ;YACX,OAAO,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,EAAE,CAAA;QAChC;YACE,MAAM,IAAI,SAAS,CAAC,0BAA0B,IAAI,EAAE,CAAC,CAAA;IACzD,CAAC;AACH,CAAC"}
1
+ {"version":3,"file":"browser-runtime-implementation.js","sourceRoot":"","sources":["../src/browser-runtime-implementation.ts"],"names":[],"mappings":";;;AAAA,0DAAqD;AAQrD;;GAEG;AACH,MAAM,iBAAiB,GAA4B,SAAS,CAAC,KAAK,EAAE,OAAO;IACzE,CAAC,CAAC,CAAI,IAAY,EAAE,EAA4B,EAAc,EAAE,CAC5D,SAAS,CAAC,KAAK,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,IAAI,EAAE,WAAW,EAAE,EAAE,KAAK,IAAI,EAAE,CAAC,EAAE,EAAE,CAAC;IAC1E,CAAC,CAAC,SAAS,CAAA;AAEb,MAAa,4BAA4B;IAGvC;QAFA;;;;mBAAc,iBAAiB;WAAA;QAG7B,IAAI,OAAO,MAAM,KAAK,QAAQ,IAAI,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CACb,iHAAiH,CAClH,CAAA;QACH,CAAC;QAED,IAAI,CAAC,IAAI,CAAC,WAAW,EAAE,CAAC;YACtB,wEAAwE;YACxE,yEAAyE;YACzE,qBAAqB;YACrB,OAAO,CAAC,IAAI,CACV,2EAA2E,CAC5E,CAAA;QACH,CAAC;IACH,CAAC;IAED,KAAK,CAAC,SAAS,CAAC,IAAc;QAC5B,OAAO,4BAAY,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IACpC,CAAC;IAED,eAAe,CAAC,UAAkB;QAChC,OAAO,MAAM,CAAC,eAAe,CAAC,IAAI,UAAU,CAAC,UAAU,CAAC,CAAC,CAAA;IAC3D,CAAC;IAED,KAAK,CAAC,MAAM,CACV,IAAgB,EAChB,EAAE,IAAI,EAAmB;QAEzB,QAAQ,IAAI,EAAE,CAAC;YACb,KAAK,QAAQ,CAAC;YACd,KAAK,QAAQ,CAAC;YACd,KAAK,QAAQ,CAAC,CAAC,CAAC;gBACd,MAAM,GAAG,GAAG,MAAM,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,OAAO,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;gBACpE,OAAO,IAAI,UAAU,CAAC,GAAG,CAAC,CAAA;YAC5B,CAAC;YACD;gBACE,MAAM,IAAI,KAAK,CAAC,iCAAiC,IAAI,EAAE,CAAC,CAAA;QAC5D,CAAC;IACH,CAAC;CACF;AA3CD,oEA2CC"}
package/dist/index.d.ts CHANGED
@@ -1,10 +1,6 @@
1
1
  import './disposable-polyfill/index.js';
2
- export * from '@atproto-labs/did-resolver';
3
- export { AppViewHandleResolver, AtprotoHandleResolver, } from '@atproto-labs/handle-resolver';
4
- export * from '@atproto/did';
5
2
  export * from '@atproto/jwk-webcrypto';
6
3
  export * from '@atproto/oauth-client';
7
- export * from '@atproto/oauth-types';
8
4
  export * from './browser-oauth-client.js';
9
5
  export * from './errors.js';
10
6
  export { buildLoopbackClientId } from './util.js';
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAA;AAEvC,cAAc,4BAA4B,CAAA;AAC1C,OAAO,EACL,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,+BAA+B,CAAA;AAEtC,cAAc,cAAc,CAAA;AAC5B,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AACrC,cAAc,sBAAsB,CAAA;AAEpC,cAAc,2BAA2B,CAAA;AACzC,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,gCAAgC,CAAA;AAEvC,cAAc,wBAAwB,CAAA;AACtC,cAAc,uBAAuB,CAAA;AAErC,cAAc,2BAA2B,CAAA;AACzC,cAAc,aAAa,CAAA;AAC3B,OAAO,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAA"}
package/dist/index.js CHANGED
@@ -14,16 +14,10 @@ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
14
  for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
15
  };
16
16
  Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.buildLoopbackClientId = exports.AtprotoHandleResolver = exports.AppViewHandleResolver = void 0;
17
+ exports.buildLoopbackClientId = void 0;
18
18
  require("./disposable-polyfill/index.js");
19
- __exportStar(require("@atproto-labs/did-resolver"), exports);
20
- var handle_resolver_1 = require("@atproto-labs/handle-resolver");
21
- Object.defineProperty(exports, "AppViewHandleResolver", { enumerable: true, get: function () { return handle_resolver_1.AppViewHandleResolver; } });
22
- Object.defineProperty(exports, "AtprotoHandleResolver", { enumerable: true, get: function () { return handle_resolver_1.AtprotoHandleResolver; } });
23
- __exportStar(require("@atproto/did"), exports);
24
19
  __exportStar(require("@atproto/jwk-webcrypto"), exports);
25
20
  __exportStar(require("@atproto/oauth-client"), exports);
26
- __exportStar(require("@atproto/oauth-types"), exports);
27
21
  __exportStar(require("./browser-oauth-client.js"), exports);
28
22
  __exportStar(require("./errors.js"), exports);
29
23
  var util_js_1 = require("./util.js");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAuC;AAEvC,6DAA0C;AAC1C,iEAGsC;AAFpC,wHAAA,qBAAqB,OAAA;AACrB,wHAAA,qBAAqB,OAAA;AAGvB,+CAA4B;AAC5B,yDAAsC;AACtC,wDAAqC;AACrC,uDAAoC;AAEpC,4DAAyC;AACzC,8CAA2B;AAC3B,qCAAiD;AAAxC,gHAAA,qBAAqB,OAAA"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA,0CAAuC;AAEvC,yDAAsC;AACtC,wDAAqC;AAErC,4DAAyC;AACzC,8CAA2B;AAC3B,qCAAiD;AAAxC,gHAAA,qBAAqB,OAAA"}
@@ -1,2 +1,3 @@
1
+ export declare function handleRequest<T>(request: IDBRequest<T>, onSuccess: (result: T) => void, onError: (error: Error) => void): void;
1
2
  export declare function promisify<T>(request: IDBRequest<T>): Promise<T>;
2
3
  //# sourceMappingURL=util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/indexed-db/util.ts"],"names":[],"mappings":"AAAA,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,cAmBlD"}
1
+ {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../../src/indexed-db/util.ts"],"names":[],"mappings":"AAAA,wBAAgB,aAAa,CAAC,CAAC,EAC7B,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,EACtB,SAAS,EAAE,CAAC,MAAM,EAAE,CAAC,KAAK,IAAI,EAC9B,OAAO,EAAE,CAAC,KAAK,EAAE,KAAK,KAAK,IAAI,QAgBhC;AAED,wBAAgB,SAAS,CAAC,CAAC,EAAE,OAAO,EAAE,UAAU,CAAC,CAAC,CAAC,cAIlD"}
@@ -1,24 +1,27 @@
1
1
  "use strict";
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.promisify = void 0;
3
+ exports.promisify = exports.handleRequest = void 0;
4
+ function handleRequest(request, onSuccess, onError) {
5
+ const cleanup = () => {
6
+ request.removeEventListener('success', success);
7
+ request.removeEventListener('error', error);
8
+ };
9
+ const success = () => {
10
+ onSuccess(request.result);
11
+ cleanup();
12
+ };
13
+ const error = () => {
14
+ onError(request.error || new Error('Unknown error'));
15
+ cleanup();
16
+ };
17
+ request.addEventListener('success', success);
18
+ request.addEventListener('error', error);
19
+ }
20
+ exports.handleRequest = handleRequest;
4
21
  function promisify(request) {
5
- const promise = new Promise((resolve, reject) => {
6
- const cleanup = () => {
7
- request.removeEventListener('success', success);
8
- request.removeEventListener('error', error);
9
- };
10
- const success = () => {
11
- resolve(request.result);
12
- cleanup();
13
- };
14
- const error = () => {
15
- reject(request.error);
16
- cleanup();
17
- };
18
- request.addEventListener('success', success);
19
- request.addEventListener('error', error);
22
+ return new Promise((resolve, reject) => {
23
+ handleRequest(request, resolve, reject);
20
24
  });
21
- return promise;
22
25
  }
23
26
  exports.promisify = promisify;
24
27
  //# sourceMappingURL=util.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../../src/indexed-db/util.ts"],"names":[],"mappings":";;;AAAA,SAAgB,SAAS,CAAI,OAAsB;IACjD,MAAM,OAAO,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Ae,CAAC,CAAC,CAAA;QACpD,OAAO,EAAE,CAAA;IACX,CAAC,CAAA;IACD,OAAO,CAAC,gBAAgB,CAAC,SAAS,EAAE,OAAO,CAAC,CAAA;IAC5C,OAAO,CAAC,gBAAgB,CAAC,OAAO,EAAE,KAAK,CAAC,CAAA;AAC1C,CAAC;AAnBD,sCAmBC;AAED,SAAgB,SAAS,CAAI,OAAsB;IACjD,OAAO,IAAI,OAAO,CAAI,CAAC,OAAO,EAAE,MAAM,EAAE,EAAE;QACxC,aAAa,CAAC,OAAO,EAAE,OAAO,EAAE,MAAM,CAAC,CAAA;IACzC,CAAC,CAAC,CAAA;AACJ,CAAC;AAJD,8BAIC"}
package/dist/util.d.ts CHANGED
@@ -15,4 +15,18 @@ export declare function buildLoopbackClientId(location: {
15
15
  pathname: string;
16
16
  port: string;
17
17
  }, localhost?: string): string;
18
+ interface TypedBroadcastChannelEventMap<T> {
19
+ message: MessageEvent<T>;
20
+ messageerror: MessageEvent<T>;
21
+ }
22
+ export interface TypedBroadcastChannel<T> extends EventTarget {
23
+ readonly name: string;
24
+ close(): void;
25
+ postMessage(message: T): void;
26
+ addEventListener<K extends keyof TypedBroadcastChannelEventMap<T>>(type: K, listener: (this: BroadcastChannel, ev: TypedBroadcastChannelEventMap<T>[K]) => any, options?: boolean | AddEventListenerOptions): void;
27
+ addEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | AddEventListenerOptions): void;
28
+ removeEventListener<K extends keyof TypedBroadcastChannelEventMap<T>>(type: K, listener: (this: BroadcastChannel, ev: TypedBroadcastChannelEventMap<T>[K]) => any, options?: boolean | EventListenerOptions): void;
29
+ removeEventListener(type: string, listener: EventListenerOrEventListenerObject, options?: boolean | EventListenerOptions): void;
30
+ }
31
+ export {};
18
32
  //# sourceMappingURL=util.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAEA,MAAM,MAAM,QAAQ,CAAC,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OAAO,CAAC,EAAE,OAAO,GAAG,oBAAoB,GACvC,IAAI,CAAA;CACR"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/oauth-client-browser",
3
- "version": "0.1.0",
3
+ "version": "0.1.1",
4
4
  "license": "MIT",
5
5
  "description": "ATPROTO OAuth client for the browser (relies on WebCrypto & Indexed DB)",
6
6
  "keywords": [
@@ -31,14 +31,14 @@
31
31
  "dist"
32
32
  ],
33
33
  "dependencies": {
34
- "@atproto-labs/did-resolver": "0.1.0",
35
- "@atproto-labs/handle-resolver": "0.1.0",
36
- "@atproto-labs/simple-store": "0.1.0",
34
+ "@atproto-labs/did-resolver": "0.1.1",
35
+ "@atproto-labs/handle-resolver": "0.1.1",
36
+ "@atproto-labs/simple-store": "0.1.1",
37
37
  "@atproto/did": "0.1.0",
38
- "@atproto/jwk": "0.1.0",
39
- "@atproto/jwk-webcrypto": "0.1.0",
40
- "@atproto/oauth-client": "0.1.0",
41
- "@atproto/oauth-types": "0.1.0"
38
+ "@atproto/jwk": "0.1.1",
39
+ "@atproto/jwk-webcrypto": "0.1.1",
40
+ "@atproto/oauth-client": "0.1.1",
41
+ "@atproto/oauth-types": "0.1.1"
42
42
  },
43
43
  "devDependencies": {
44
44
  "@rollup/plugin-commonjs": "^25.0.7",
@@ -59,10 +59,10 @@
59
59
  "rollup-plugin-serve": "^1.1.1",
60
60
  "tailwindcss": "^3.4.1",
61
61
  "typescript": "^5.3.3",
62
- "@atproto/api": "0.12.19",
63
- "@atproto/oauth-client": "0.1.0",
64
- "@atproto/oauth-client-browser": "0.1.0",
65
- "@atproto/oauth-types": "0.1.0",
62
+ "@atproto/api": "0.12.24",
63
+ "@atproto/oauth-client": "0.1.1",
64
+ "@atproto/oauth-client-browser": "0.1.1",
65
+ "@atproto/oauth-types": "0.1.1",
66
66
  "@atproto/xrpc": "0.5.0"
67
67
  },
68
68
  "scripts": {