@atproto/oauth-client-expo 0.0.8 → 0.0.10

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/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @atproto/oauth-client-expo
2
2
 
3
+ ## 0.0.10
4
+
5
+ ### Patch Changes
6
+
7
+ - [#4642](https://github.com/bluesky-social/atproto/pull/4642) [`a23d132`](https://github.com/bluesky-social/atproto/commit/a23d13268ccfd51a54d21256469b8cb43f7b07df) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Remove dependency on `event-target-polyfill`
8
+
9
+ - Updated dependencies [[`a23d132`](https://github.com/bluesky-social/atproto/commit/a23d13268ccfd51a54d21256469b8cb43f7b07df), [`a23d132`](https://github.com/bluesky-social/atproto/commit/a23d13268ccfd51a54d21256469b8cb43f7b07df), [`a23d132`](https://github.com/bluesky-social/atproto/commit/a23d13268ccfd51a54d21256469b8cb43f7b07df), [`a23d132`](https://github.com/bluesky-social/atproto/commit/a23d13268ccfd51a54d21256469b8cb43f7b07df), [`a23d132`](https://github.com/bluesky-social/atproto/commit/a23d13268ccfd51a54d21256469b8cb43f7b07df)]:
10
+ - @atproto/oauth-client@0.6.0
11
+ - @atproto/oauth-client-browser@0.3.41
12
+
13
+ ## 0.0.9
14
+
15
+ ### Patch Changes
16
+
17
+ - [#4606](https://github.com/bluesky-social/atproto/pull/4606) [`78fee14`](https://github.com/bluesky-social/atproto/commit/78fee144ff46ffc4585f318c72eea98e4357ba7b) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Add iOS specific options on authentication web-view
18
+
19
+ - [#4606](https://github.com/bluesky-social/atproto/pull/4606) [`78fee14`](https://github.com/bluesky-social/atproto/commit/78fee144ff46ffc4585f318c72eea98e4357ba7b) Thanks [@matthieusieben](https://github.com/matthieusieben)! - Remove dev logs
20
+
3
21
  ## 0.0.8
4
22
 
5
23
  ### Patch Changes
@@ -1,5 +1,5 @@
1
1
  import type { AuthorizeOptions, OAuthClient, OAuthSession } from '@atproto/oauth-client';
2
- export interface ExpoOAuthClientInterface extends OAuthClient, Disposable {
2
+ export interface ExpoOAuthClientInterface extends OAuthClient, AsyncDisposable {
3
3
  signIn(input: string, options?: AuthorizeOptions): Promise<OAuthSession>;
4
4
  handleCallback(): Promise<null | OAuthSession>;
5
5
  }
@@ -1 +1 @@
1
- {"version":3,"file":"expo-oauth-client-interface.d.ts","sourceRoot":"","sources":["../src/expo-oauth-client-interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,YAAY,EACb,MAAM,uBAAuB,CAAA;AAE9B,MAAM,WAAW,wBAAyB,SAAQ,WAAW,EAAE,UAAU;IACvE,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;IACxE,cAAc,IAAI,OAAO,CAAC,IAAI,GAAG,YAAY,CAAC,CAAA;CAC/C"}
1
+ {"version":3,"file":"expo-oauth-client-interface.d.ts","sourceRoot":"","sources":["../src/expo-oauth-client-interface.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,WAAW,EACX,YAAY,EACb,MAAM,uBAAuB,CAAA;AAE9B,MAAM,WAAW,wBAAyB,SAAQ,WAAW,EAAE,eAAe;IAC5E,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,gBAAgB,GAAG,OAAO,CAAC,YAAY,CAAC,CAAA;IACxE,cAAc,IAAI,OAAO,CAAC,IAAI,GAAG,YAAY,CAAC,CAAA;CAC/C"}
@@ -1 +1 @@
1
- {"version":3,"file":"expo-oauth-client-interface.js","sourceRoot":"","sources":["../src/expo-oauth-client-interface.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AuthorizeOptions,\n OAuthClient,\n OAuthSession,\n} from '@atproto/oauth-client'\n\nexport interface ExpoOAuthClientInterface extends OAuthClient, Disposable {\n signIn(input: string, options?: AuthorizeOptions): Promise<OAuthSession>\n handleCallback(): Promise<null | OAuthSession>\n}\n"]}
1
+ {"version":3,"file":"expo-oauth-client-interface.js","sourceRoot":"","sources":["../src/expo-oauth-client-interface.ts"],"names":[],"mappings":"","sourcesContent":["import type {\n AuthorizeOptions,\n OAuthClient,\n OAuthSession,\n} from '@atproto/oauth-client'\n\nexport interface ExpoOAuthClientInterface extends OAuthClient, AsyncDisposable {\n signIn(input: string, options?: AuthorizeOptions): Promise<OAuthSession>\n handleCallback(): Promise<null | OAuthSession>\n}\n"]}
@@ -7,6 +7,6 @@ export declare class ExpoOAuthClient extends OAuthClient implements ExpoOAuthCli
7
7
  constructor(options: ExpoOAuthClientOptions);
8
8
  handleCallback(): Promise<null | OAuthSession>;
9
9
  signIn(input: string, options?: AuthorizeOptions): Promise<OAuthSession>;
10
- [Symbol.dispose](): void;
10
+ [Symbol.asyncDispose](): Promise<void>;
11
11
  }
12
12
  //# sourceMappingURL=expo-oauth-client.native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"expo-oauth-client.native.d.ts","sourceRoot":"","sources":["../src/expo-oauth-client.native.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,YAAY,EACb,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAYpE,eAAO,MAAM,uBAAuB,QAA0C,CAAA;AAG9E,qBAAa,eACX,SAAQ,WACR,YAAW,wBAAwB;;gBAIvB,OAAO,EAAE,sBAAsB;IA8BrC,cAAc,IAAI,OAAO,CAAC,IAAI,GAAG,YAAY,CAAC;IAI9C,MAAM,CACV,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,YAAY,CAAC;IAuCxB,CAAC,MAAM,CAAC,OAAO,CAAC;CAGjB"}
1
+ {"version":3,"file":"expo-oauth-client.native.d.ts","sourceRoot":"","sources":["../src/expo-oauth-client.native.ts"],"names":[],"mappings":"AACA,OAAO,EACL,gBAAgB,EAChB,WAAW,EACX,YAAY,EAEb,MAAM,uBAAuB,CAAA;AAE9B,OAAO,EAAE,wBAAwB,EAAE,MAAM,+BAA+B,CAAA;AACxE,OAAO,EAAE,sBAAsB,EAAE,MAAM,6BAA6B,CAAA;AAYpE,eAAO,MAAM,uBAAuB,QAA0C,CAAA;AAS9E,qBAAa,eACX,SAAQ,WACR,YAAW,wBAAwB;;gBAIvB,OAAO,EAAE,sBAAsB;IAwBrC,cAAc,IAAI,OAAO,CAAC,IAAI,GAAG,YAAY,CAAC;IAI9C,MAAM,CACV,KAAK,EAAE,MAAM,EACb,OAAO,CAAC,EAAE,gBAAgB,GACzB,OAAO,CAAC,YAAY,CAAC;IAsClB,CAAC,MAAM,CAAC,YAAY,CAAC;CAG5B"}
@@ -57,6 +57,11 @@ import { ExpoKey } from './utils/expo-key';
57
57
  import { AuthorizationServerMetadataCache, DidCache, DpopNonceCache, HandleCache, ProtectedResourceMetadataCache, SessionStore, StateStore, } from './utils/stores';
58
58
  export const CUSTOM_URI_SCHEME_REGEX = /^(?:[^.]+(?:\.[^.]+)+):\/(?:[^/].*)?$/;
59
59
  const isCustomUriScheme = (uri) => CUSTOM_URI_SCHEME_REGEX.test(uri);
60
+ const runtimeImplementation = {
61
+ createKey: async (algs) => ExpoKey.generate(algs),
62
+ digest: async (bytes, { name }) => NativeModule.digest(bytes, name),
63
+ getRandomValues: async (length) => NativeModule.getRandomValues(length),
64
+ };
60
65
  export class ExpoOAuthClient extends OAuthClient {
61
66
  #disposables;
62
67
  constructor(options) {
@@ -67,11 +72,7 @@ export class ExpoOAuthClient extends OAuthClient {
67
72
  ...options,
68
73
  responseMode: options.responseMode ?? 'query',
69
74
  keyset: undefined,
70
- runtimeImplementation: {
71
- createKey: async (algs) => ExpoKey.generate(algs),
72
- digest: async (bytes, { name }) => NativeModule.digest(bytes, name),
73
- getRandomValues: async (length) => NativeModule.getRandomValues(length),
74
- },
75
+ runtimeImplementation,
75
76
  sessionStore: stack.use(new SessionStore()),
76
77
  stateStore: stack.use(new StateStore()),
77
78
  didCache: stack.use(new DidCache()),
@@ -80,7 +81,6 @@ export class ExpoOAuthClient extends OAuthClient {
80
81
  authorizationServerMetadataCache: stack.use(new AuthorizationServerMetadataCache()),
81
82
  protectedResourceMetadataCache: stack.use(new ProtectedResourceMetadataCache()),
82
83
  });
83
- stack.defer(() => super[Symbol.dispose]?.());
84
84
  this.#disposables = stack.move();
85
85
  }
86
86
  catch (e_1) {
@@ -105,9 +105,10 @@ export class ExpoOAuthClient extends OAuthClient {
105
105
  redirect_uri: redirectUri,
106
106
  display: options?.display ?? 'touch',
107
107
  });
108
- console.debug('openAuthSessionAsync', { url, redirectUri });
109
- const result = await openAuthSessionAsync(url.toString(), redirectUri);
110
- console.debug('AUTH SESSION RESULT', result);
108
+ const result = await openAuthSessionAsync(url.toString(), redirectUri, {
109
+ dismissButtonStyle: 'cancel', // iOS only
110
+ preferEphemeralSession: false, // iOS only
111
+ });
111
112
  if (result.type === 'success') {
112
113
  const callbackUrl = new URL(result.url);
113
114
  const params = this.responseMode === 'fragment'
@@ -122,7 +123,7 @@ export class ExpoOAuthClient extends OAuthClient {
122
123
  throw new Error(`Authentication cancelled: ${result.type}`);
123
124
  }
124
125
  }
125
- [Symbol.dispose]() {
126
+ async [Symbol.asyncDispose]() {
126
127
  this.#disposables.dispose();
127
128
  }
128
129
  }
@@ -1 +1 @@
1
- {"version":3,"file":"expo-oauth-client.native.js","sourceRoot":"","sources":["../src/expo-oauth-client.native.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,OAAO,EAAE,oBAAoB,EAAE,MAAM,kBAAkB,CAAA;AACvD,OAAO,EAEL,WAAW,GAEZ,MAAM,uBAAuB,CAAA;AAC9B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MAAM,WAAW,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YACvC,MAAM,MAAM,GACV,IAAI,CAAC,YAAY,KAAK,UAAU;gBAC9B,CAAC,CAAC,IAAI,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAChD,CAAC,CAAC,WAAW,CAAC,YAAY,CAAA;YAE9B,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;gBAC9C,YAAY,EAAE,WAAW;aAC1B,CAAC,CAAA;YACF,OAAO,OAAO,CAAA;QAChB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,6BAA6B,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;QAC7D,CAAC;IACH,CAAC;IAED,CAAC,MAAM,CAAC,OAAO,CAAC;QACd,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAA;IAC7B,CAAC;CACF","sourcesContent":["import { openAuthSessionAsync } from 'expo-web-browser'\nimport {\n AuthorizeOptions,\n OAuthClient,\n OAuthSession,\n} from '@atproto/oauth-client'\nimport { default as NativeModule } from './ExpoAtprotoOAuthClientModule'\nimport { ExpoOAuthClientInterface } from './expo-oauth-client-interface'\nimport { ExpoOAuthClientOptions } from './expo-oauth-client-options'\nimport { ExpoKey } from './utils/expo-key'\nimport {\n AuthorizationServerMetadataCache,\n DidCache,\n DpopNonceCache,\n HandleCache,\n ProtectedResourceMetadataCache,\n SessionStore,\n StateStore,\n} from './utils/stores'\n\nexport const CUSTOM_URI_SCHEME_REGEX = /^(?:[^.]+(?:\\.[^.]+)+):\\/(?:[^/].*)?$/\nconst isCustomUriScheme = (uri: string) => CUSTOM_URI_SCHEME_REGEX.test(uri)\n\nexport class ExpoOAuthClient\n extends OAuthClient\n implements ExpoOAuthClientInterface\n{\n readonly #disposables: DisposableStack\n\n constructor(options: ExpoOAuthClientOptions) {\n using stack = new DisposableStack()\n\n super({\n ...options,\n responseMode: options.responseMode ?? 'query',\n keyset: undefined,\n runtimeImplementation: {\n createKey: async (algs) => ExpoKey.generate(algs),\n digest: async (bytes, { name }) => NativeModule.digest(bytes, name),\n getRandomValues: async (length) => NativeModule.getRandomValues(length),\n },\n sessionStore: stack.use(new SessionStore()),\n stateStore: stack.use(new StateStore()),\n didCache: stack.use(new DidCache()),\n handleCache: stack.use(new HandleCache()),\n dpopNonceCache: stack.use(new DpopNonceCache()),\n authorizationServerMetadataCache: stack.use(\n new AuthorizationServerMetadataCache(),\n ),\n protectedResourceMetadataCache: stack.use(\n new ProtectedResourceMetadataCache(),\n ),\n })\n\n stack.defer(() => super[Symbol.dispose]?.())\n\n this.#disposables = stack.move()\n }\n\n async handleCallback(): Promise<null | OAuthSession> {\n return null\n }\n\n async signIn(\n input: string,\n options?: AuthorizeOptions,\n ): Promise<OAuthSession> {\n const redirectUri =\n options?.redirect_uri ??\n this.clientMetadata.redirect_uris.find(isCustomUriScheme)\n\n if (!redirectUri) {\n throw new TypeError(\n 'A redirect URI with a custom scheme is required for Expo OAuth.',\n )\n }\n\n const url = await this.authorize(input, {\n ...options,\n redirect_uri: redirectUri,\n display: options?.display ?? 'touch',\n })\n\n console.debug('openAuthSessionAsync', { url, redirectUri })\n\n const result = await openAuthSessionAsync(url.toString(), redirectUri)\n\n console.debug('AUTH SESSION RESULT', result)\n\n if (result.type === 'success') {\n const callbackUrl = new URL(result.url)\n const params =\n this.responseMode === 'fragment'\n ? new URLSearchParams(callbackUrl.hash.slice(1))\n : callbackUrl.searchParams\n\n const { session } = await this.callback(params, {\n redirect_uri: redirectUri,\n })\n return session\n } else {\n throw new Error(`Authentication cancelled: ${result.type}`)\n }\n }\n\n [Symbol.dispose]() {\n this.#disposables.dispose()\n }\n}\n"]}
1
+ {"version":3,"file":"expo-oauth-client.native.js","sourceRoot":"","sources":["../src/expo-oauth-client.native.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;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,WAAW,GAAG,IAAI,GAAG,CAAC,MAAM,CAAC,GAAG,CAAC,CAAA;YACvC,MAAM,MAAM,GACV,IAAI,CAAC,YAAY,KAAK,UAAU;gBAC9B,CAAC,CAAC,IAAI,eAAe,CAAC,WAAW,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;gBAChD,CAAC,CAAC,WAAW,CAAC,YAAY,CAAA;YAE9B,MAAM,EAAE,OAAO,EAAE,GAAG,MAAM,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE;gBAC9C,YAAY,EAAE,WAAW;aAC1B,CAAC,CAAA;YACF,OAAO,OAAO,CAAA;QAChB,CAAC;aAAM,CAAC;YACN,MAAM,IAAI,KAAK,CAAC,6BAA6B,MAAM,CAAC,IAAI,EAAE,CAAC,CAAA;QAC7D,CAAC;IACH,CAAC;IAED,KAAK,CAAC,CAAC,MAAM,CAAC,YAAY,CAAC;QACzB,IAAI,CAAC,YAAY,CAAC,OAAO,EAAE,CAAA;IAC7B,CAAC;CACF","sourcesContent":["import { openAuthSessionAsync } from 'expo-web-browser'\nimport {\n AuthorizeOptions,\n OAuthClient,\n OAuthSession,\n RuntimeImplementation,\n} from '@atproto/oauth-client'\nimport { default as NativeModule } from './ExpoAtprotoOAuthClientModule'\nimport { ExpoOAuthClientInterface } from './expo-oauth-client-interface'\nimport { ExpoOAuthClientOptions } from './expo-oauth-client-options'\nimport { ExpoKey } from './utils/expo-key'\nimport {\n AuthorizationServerMetadataCache,\n DidCache,\n DpopNonceCache,\n HandleCache,\n ProtectedResourceMetadataCache,\n SessionStore,\n StateStore,\n} from './utils/stores'\n\nexport const CUSTOM_URI_SCHEME_REGEX = /^(?:[^.]+(?:\\.[^.]+)+):\\/(?:[^/].*)?$/\nconst isCustomUriScheme = (uri: string) => CUSTOM_URI_SCHEME_REGEX.test(uri)\n\nconst runtimeImplementation: RuntimeImplementation = {\n createKey: async (algs) => ExpoKey.generate(algs),\n digest: async (bytes, { name }) => NativeModule.digest(bytes, name),\n getRandomValues: async (length) => NativeModule.getRandomValues(length),\n}\n\nexport class ExpoOAuthClient\n extends OAuthClient\n implements ExpoOAuthClientInterface\n{\n readonly #disposables: DisposableStack\n\n constructor(options: ExpoOAuthClientOptions) {\n using stack = new DisposableStack()\n\n super({\n ...options,\n responseMode: options.responseMode ?? 'query',\n keyset: undefined,\n runtimeImplementation,\n sessionStore: stack.use(new SessionStore()),\n stateStore: stack.use(new StateStore()),\n didCache: stack.use(new DidCache()),\n handleCache: stack.use(new HandleCache()),\n dpopNonceCache: stack.use(new DpopNonceCache()),\n authorizationServerMetadataCache: stack.use(\n new AuthorizationServerMetadataCache(),\n ),\n protectedResourceMetadataCache: stack.use(\n new ProtectedResourceMetadataCache(),\n ),\n })\n\n this.#disposables = stack.move()\n }\n\n async handleCallback(): Promise<null | OAuthSession> {\n return null\n }\n\n async signIn(\n input: string,\n options?: AuthorizeOptions,\n ): Promise<OAuthSession> {\n const redirectUri =\n options?.redirect_uri ??\n this.clientMetadata.redirect_uris.find(isCustomUriScheme)\n\n if (!redirectUri) {\n throw new TypeError(\n 'A redirect URI with a custom scheme is required for Expo OAuth.',\n )\n }\n\n const url = await this.authorize(input, {\n ...options,\n redirect_uri: redirectUri,\n display: options?.display ?? 'touch',\n })\n\n const result = await openAuthSessionAsync(url.toString(), redirectUri, {\n dismissButtonStyle: 'cancel', // iOS only\n preferEphemeralSession: false, // iOS only\n })\n\n if (result.type === 'success') {\n const callbackUrl = new URL(result.url)\n const params =\n this.responseMode === 'fragment'\n ? new URLSearchParams(callbackUrl.hash.slice(1))\n : callbackUrl.searchParams\n\n const { session } = await this.callback(params, {\n redirect_uri: redirectUri,\n })\n return session\n } else {\n throw new Error(`Authentication cancelled: ${result.type}`)\n }\n }\n\n async [Symbol.asyncDispose]() {\n this.#disposables.dispose()\n }\n}\n"]}
@@ -1,4 +1,3 @@
1
1
  import 'core-js/proposals/explicit-resource-management';
2
- import 'event-target-polyfill';
3
2
  import 'react-native-url-polyfill/auto';
4
3
  //# sourceMappingURL=polyfill.native.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"polyfill.native.d.ts","sourceRoot":"","sources":["../src/polyfill.native.ts"],"names":[],"mappings":"AAAA,OAAO,gDAAgD,CAAA;AACvD,OAAO,uBAAuB,CAAA;AAC9B,OAAO,gCAAgC,CAAA"}
1
+ {"version":3,"file":"polyfill.native.d.ts","sourceRoot":"","sources":["../src/polyfill.native.ts"],"names":[],"mappings":"AAAA,OAAO,gDAAgD,CAAA;AACvD,OAAO,gCAAgC,CAAA"}
@@ -1,4 +1,3 @@
1
1
  import 'core-js/proposals/explicit-resource-management';
2
- import 'event-target-polyfill';
3
2
  import 'react-native-url-polyfill/auto';
4
3
  //# sourceMappingURL=polyfill.native.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"polyfill.native.js","sourceRoot":"","sources":["../src/polyfill.native.ts"],"names":[],"mappings":"AAAA,OAAO,gDAAgD,CAAA;AACvD,OAAO,uBAAuB,CAAA;AAC9B,OAAO,gCAAgC,CAAA","sourcesContent":["import 'core-js/proposals/explicit-resource-management'\nimport 'event-target-polyfill'\nimport 'react-native-url-polyfill/auto'\n"]}
1
+ {"version":3,"file":"polyfill.native.js","sourceRoot":"","sources":["../src/polyfill.native.ts"],"names":[],"mappings":"AAAA,OAAO,gDAAgD,CAAA;AACvD,OAAO,gCAAgC,CAAA","sourcesContent":["import 'core-js/proposals/explicit-resource-management'\nimport 'react-native-url-polyfill/auto'\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@atproto/oauth-client-expo",
3
- "version": "0.0.8",
3
+ "version": "0.0.10",
4
4
  "license": "MIT",
5
5
  "description": "ATPROTO OAuth client for Expo applications",
6
6
  "authors": [
@@ -33,13 +33,12 @@
33
33
  },
34
34
  "dependencies": {
35
35
  "core-js": "^3",
36
- "event-target-polyfill": "^0.0.4",
37
36
  "expo-web-browser": "^15.0.8",
38
37
  "react-native-mmkv": "^3.3.3",
39
38
  "react-native-url-polyfill": "^3.0.0",
40
- "@atproto-labs/simple-store": "0.3.0",
41
- "@atproto/oauth-client": "0.5.14",
42
- "@atproto/oauth-client-browser": "0.3.40"
39
+ "@atproto-labs/simple-store": "^0.3.0",
40
+ "@atproto/oauth-client": "^0.6.0",
41
+ "@atproto/oauth-client-browser": "^0.3.41"
43
42
  },
44
43
  "peerDependencies": {
45
44
  "expo": "*",
@@ -4,7 +4,7 @@ import type {
4
4
  OAuthSession,
5
5
  } from '@atproto/oauth-client'
6
6
 
7
- export interface ExpoOAuthClientInterface extends OAuthClient, Disposable {
7
+ export interface ExpoOAuthClientInterface extends OAuthClient, AsyncDisposable {
8
8
  signIn(input: string, options?: AuthorizeOptions): Promise<OAuthSession>
9
9
  handleCallback(): Promise<null | OAuthSession>
10
10
  }
@@ -3,6 +3,7 @@ import {
3
3
  AuthorizeOptions,
4
4
  OAuthClient,
5
5
  OAuthSession,
6
+ RuntimeImplementation,
6
7
  } from '@atproto/oauth-client'
7
8
  import { default as NativeModule } from './ExpoAtprotoOAuthClientModule'
8
9
  import { ExpoOAuthClientInterface } from './expo-oauth-client-interface'
@@ -21,6 +22,12 @@ import {
21
22
  export const CUSTOM_URI_SCHEME_REGEX = /^(?:[^.]+(?:\.[^.]+)+):\/(?:[^/].*)?$/
22
23
  const isCustomUriScheme = (uri: string) => CUSTOM_URI_SCHEME_REGEX.test(uri)
23
24
 
25
+ const runtimeImplementation: RuntimeImplementation = {
26
+ createKey: async (algs) => ExpoKey.generate(algs),
27
+ digest: async (bytes, { name }) => NativeModule.digest(bytes, name),
28
+ getRandomValues: async (length) => NativeModule.getRandomValues(length),
29
+ }
30
+
24
31
  export class ExpoOAuthClient
25
32
  extends OAuthClient
26
33
  implements ExpoOAuthClientInterface
@@ -34,11 +41,7 @@ export class ExpoOAuthClient
34
41
  ...options,
35
42
  responseMode: options.responseMode ?? 'query',
36
43
  keyset: undefined,
37
- runtimeImplementation: {
38
- createKey: async (algs) => ExpoKey.generate(algs),
39
- digest: async (bytes, { name }) => NativeModule.digest(bytes, name),
40
- getRandomValues: async (length) => NativeModule.getRandomValues(length),
41
- },
44
+ runtimeImplementation,
42
45
  sessionStore: stack.use(new SessionStore()),
43
46
  stateStore: stack.use(new StateStore()),
44
47
  didCache: stack.use(new DidCache()),
@@ -52,8 +55,6 @@ export class ExpoOAuthClient
52
55
  ),
53
56
  })
54
57
 
55
- stack.defer(() => super[Symbol.dispose]?.())
56
-
57
58
  this.#disposables = stack.move()
58
59
  }
59
60
 
@@ -81,11 +82,10 @@ export class ExpoOAuthClient
81
82
  display: options?.display ?? 'touch',
82
83
  })
83
84
 
84
- console.debug('openAuthSessionAsync', { url, redirectUri })
85
-
86
- const result = await openAuthSessionAsync(url.toString(), redirectUri)
87
-
88
- console.debug('AUTH SESSION RESULT', result)
85
+ const result = await openAuthSessionAsync(url.toString(), redirectUri, {
86
+ dismissButtonStyle: 'cancel', // iOS only
87
+ preferEphemeralSession: false, // iOS only
88
+ })
89
89
 
90
90
  if (result.type === 'success') {
91
91
  const callbackUrl = new URL(result.url)
@@ -103,7 +103,7 @@ export class ExpoOAuthClient
103
103
  }
104
104
  }
105
105
 
106
- [Symbol.dispose]() {
106
+ async [Symbol.asyncDispose]() {
107
107
  this.#disposables.dispose()
108
108
  }
109
109
  }
@@ -1,3 +1,2 @@
1
1
  import 'core-js/proposals/explicit-resource-management'
2
- import 'event-target-polyfill'
3
2
  import 'react-native-url-polyfill/auto'