@symbiote-native/auth-session 0.0.0-stage → 0.1.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.
Files changed (179) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +157 -2
  3. package/build/angular/index.d.ts +2 -0
  4. package/build/angular/index.js +3 -0
  5. package/build/angular/use-auth-request.d.ts +7 -0
  6. package/build/angular/use-auth-request.js +11 -0
  7. package/build/core/auth-request-controllers.d.ts +44 -0
  8. package/build/core/auth-request-controllers.js +122 -0
  9. package/build/core/auth-request-hooks.d.ts +67 -0
  10. package/build/core/auth-request-hooks.js +75 -0
  11. package/build/core/auth-request.d.ts +29 -0
  12. package/build/core/auth-request.js +161 -0
  13. package/build/core/auth-request.types.d.ts +46 -0
  14. package/build/core/auth-request.types.js +23 -0
  15. package/build/core/auth-session.d.ts +10 -0
  16. package/build/core/auth-session.js +37 -0
  17. package/build/core/auth-session.types.d.ts +27 -0
  18. package/build/core/auth-session.types.js +1 -0
  19. package/build/core/base64.d.ts +1 -0
  20. package/build/core/base64.js +28 -0
  21. package/build/core/discovery.d.ts +57 -0
  22. package/build/core/discovery.js +29 -0
  23. package/build/core/errors.d.ts +29 -0
  24. package/build/core/errors.js +74 -0
  25. package/build/core/fetch.d.ts +15 -0
  26. package/build/core/fetch.js +40 -0
  27. package/build/core/index.d.ts +24 -0
  28. package/build/core/index.js +14 -0
  29. package/build/core/pkce.d.ts +9 -0
  30. package/build/core/pkce.js +41 -0
  31. package/build/core/prompt-string.d.ts +2 -0
  32. package/build/core/prompt-string.js +5 -0
  33. package/build/core/providers/facebook.d.ts +16 -0
  34. package/build/core/providers/facebook.js +43 -0
  35. package/build/core/providers/google-exchange-controller.d.ts +10 -0
  36. package/build/core/providers/google-exchange-controller.js +73 -0
  37. package/build/core/providers/google.d.ts +22 -0
  38. package/build/core/providers/google.js +52 -0
  39. package/build/core/providers/provider-hook-setup.d.ts +19 -0
  40. package/build/core/providers/provider-hook-setup.js +78 -0
  41. package/build/core/providers/provider-utils.d.ts +2 -0
  42. package/build/core/providers/provider-utils.js +8 -0
  43. package/build/core/providers/provider.types.d.ts +5 -0
  44. package/build/core/providers/provider.types.js +1 -0
  45. package/build/core/query-params.d.ts +5 -0
  46. package/build/core/query-params.js +12 -0
  47. package/build/core/session-result.d.ts +6 -0
  48. package/build/core/session-result.js +4 -0
  49. package/build/core/token-request.d.ts +89 -0
  50. package/build/core/token-request.js +328 -0
  51. package/build/core/token-request.types.d.ts +52 -0
  52. package/build/core/token-request.types.js +14 -0
  53. package/build/react/index.d.ts +3 -0
  54. package/build/react/index.js +2 -0
  55. package/build/react/use-auth-request.d.ts +20 -0
  56. package/build/react/use-auth-request.js +52 -0
  57. package/build/solid/index.d.ts +2 -0
  58. package/build/solid/index.js +2 -0
  59. package/build/solid/use-auth-request.d.ts +6 -0
  60. package/build/solid/use-auth-request.js +10 -0
  61. package/build/svelte/index.d.ts +2 -0
  62. package/build/svelte/index.js +2 -0
  63. package/build/svelte/use-auth-request.svelte.d.ts +28 -0
  64. package/build/svelte/use-auth-request.svelte.js +11 -0
  65. package/build/vue/index.d.ts +2 -0
  66. package/build/vue/index.js +2 -0
  67. package/build/vue/use-auth-request.d.ts +7 -0
  68. package/build/vue/use-auth-request.js +12 -0
  69. package/build-ngc/angular/index.d.ts +2 -0
  70. package/build-ngc/angular/index.js +4 -0
  71. package/build-ngc/angular/index.js.map +1 -0
  72. package/build-ngc/angular/use-auth-request.d.ts +7 -0
  73. package/build-ngc/angular/use-auth-request.js +12 -0
  74. package/build-ngc/angular/use-auth-request.js.map +1 -0
  75. package/build-ngc/core/auth-request-controllers.d.ts +44 -0
  76. package/build-ngc/core/auth-request-controllers.js +123 -0
  77. package/build-ngc/core/auth-request-controllers.js.map +1 -0
  78. package/build-ngc/core/auth-request-hooks.d.ts +67 -0
  79. package/build-ngc/core/auth-request-hooks.js +76 -0
  80. package/build-ngc/core/auth-request-hooks.js.map +1 -0
  81. package/build-ngc/core/auth-request.d.ts +29 -0
  82. package/build-ngc/core/auth-request.js +162 -0
  83. package/build-ngc/core/auth-request.js.map +1 -0
  84. package/build-ngc/core/auth-request.types.d.ts +46 -0
  85. package/build-ngc/core/auth-request.types.js +24 -0
  86. package/build-ngc/core/auth-request.types.js.map +1 -0
  87. package/build-ngc/core/auth-session.d.ts +10 -0
  88. package/build-ngc/core/auth-session.js +38 -0
  89. package/build-ngc/core/auth-session.js.map +1 -0
  90. package/build-ngc/core/auth-session.types.d.ts +27 -0
  91. package/build-ngc/core/auth-session.types.js +2 -0
  92. package/build-ngc/core/auth-session.types.js.map +1 -0
  93. package/build-ngc/core/base64.d.ts +1 -0
  94. package/build-ngc/core/base64.js +29 -0
  95. package/build-ngc/core/base64.js.map +1 -0
  96. package/build-ngc/core/discovery.d.ts +57 -0
  97. package/build-ngc/core/discovery.js +30 -0
  98. package/build-ngc/core/discovery.js.map +1 -0
  99. package/build-ngc/core/errors.d.ts +29 -0
  100. package/build-ngc/core/errors.js +75 -0
  101. package/build-ngc/core/errors.js.map +1 -0
  102. package/build-ngc/core/fetch.d.ts +15 -0
  103. package/build-ngc/core/fetch.js +41 -0
  104. package/build-ngc/core/fetch.js.map +1 -0
  105. package/build-ngc/core/index.d.ts +24 -0
  106. package/build-ngc/core/index.js +15 -0
  107. package/build-ngc/core/index.js.map +1 -0
  108. package/build-ngc/core/pkce.d.ts +9 -0
  109. package/build-ngc/core/pkce.js +42 -0
  110. package/build-ngc/core/pkce.js.map +1 -0
  111. package/build-ngc/core/prompt-string.d.ts +2 -0
  112. package/build-ngc/core/prompt-string.js +6 -0
  113. package/build-ngc/core/prompt-string.js.map +1 -0
  114. package/build-ngc/core/providers/facebook.d.ts +16 -0
  115. package/build-ngc/core/providers/facebook.js +44 -0
  116. package/build-ngc/core/providers/facebook.js.map +1 -0
  117. package/build-ngc/core/providers/google-exchange-controller.d.ts +10 -0
  118. package/build-ngc/core/providers/google-exchange-controller.js +74 -0
  119. package/build-ngc/core/providers/google-exchange-controller.js.map +1 -0
  120. package/build-ngc/core/providers/google.d.ts +22 -0
  121. package/build-ngc/core/providers/google.js +53 -0
  122. package/build-ngc/core/providers/google.js.map +1 -0
  123. package/build-ngc/core/providers/provider-hook-setup.d.ts +19 -0
  124. package/build-ngc/core/providers/provider-hook-setup.js +79 -0
  125. package/build-ngc/core/providers/provider-hook-setup.js.map +1 -0
  126. package/build-ngc/core/providers/provider-utils.d.ts +2 -0
  127. package/build-ngc/core/providers/provider-utils.js +9 -0
  128. package/build-ngc/core/providers/provider-utils.js.map +1 -0
  129. package/build-ngc/core/providers/provider.types.d.ts +5 -0
  130. package/build-ngc/core/providers/provider.types.js +2 -0
  131. package/build-ngc/core/providers/provider.types.js.map +1 -0
  132. package/build-ngc/core/query-params.d.ts +5 -0
  133. package/build-ngc/core/query-params.js +13 -0
  134. package/build-ngc/core/query-params.js.map +1 -0
  135. package/build-ngc/core/session-result.d.ts +6 -0
  136. package/build-ngc/core/session-result.js +5 -0
  137. package/build-ngc/core/session-result.js.map +1 -0
  138. package/build-ngc/core/token-request.d.ts +89 -0
  139. package/build-ngc/core/token-request.js +329 -0
  140. package/build-ngc/core/token-request.js.map +1 -0
  141. package/build-ngc/core/token-request.types.d.ts +52 -0
  142. package/build-ngc/core/token-request.types.js +15 -0
  143. package/build-ngc/core/token-request.types.js.map +1 -0
  144. package/package.json +151 -3
  145. package/src/angular/index.ts +11 -0
  146. package/src/angular/use-auth-request.ts +30 -0
  147. package/src/core/auth-request-controllers.ts +233 -0
  148. package/src/core/auth-request-hooks.ts +342 -0
  149. package/src/core/auth-request.ts +199 -0
  150. package/src/core/auth-request.types.ts +55 -0
  151. package/src/core/auth-session.ts +63 -0
  152. package/src/core/auth-session.types.ts +29 -0
  153. package/src/core/base64.ts +33 -0
  154. package/src/core/discovery.ts +102 -0
  155. package/src/core/errors.ts +102 -0
  156. package/src/core/fetch.ts +71 -0
  157. package/src/core/index.ts +97 -0
  158. package/src/core/pkce.ts +60 -0
  159. package/src/core/prompt-string.ts +8 -0
  160. package/src/core/providers/facebook.ts +66 -0
  161. package/src/core/providers/google-exchange-controller.ts +117 -0
  162. package/src/core/providers/google.ts +81 -0
  163. package/src/core/providers/provider-hook-setup.ts +117 -0
  164. package/src/core/providers/provider-utils.ts +18 -0
  165. package/src/core/providers/provider.types.ts +6 -0
  166. package/src/core/query-params.ts +20 -0
  167. package/src/core/session-result.ts +15 -0
  168. package/src/core/token-request.ts +452 -0
  169. package/src/core/token-request.types.ts +60 -0
  170. package/src/react/index.ts +11 -0
  171. package/src/react/use-auth-request.ts +151 -0
  172. package/src/solid/index.ts +10 -0
  173. package/src/solid/use-auth-request.ts +24 -0
  174. package/src/svelte/index.ts +10 -0
  175. package/src/svelte/svelte-ambient.d.ts +3 -0
  176. package/src/svelte/svelte-compile.test-helper.ts +7 -0
  177. package/src/svelte/use-auth-request.svelte.ts +22 -0
  178. package/src/vue/index.ts +10 -0
  179. package/src/vue/use-auth-request.ts +38 -0
@@ -0,0 +1,74 @@
1
+ // The automatic code exchange of upstream's Google `useAuthRequest`, as a cell that follows the
2
+ // prompt result and swaps in the exchanged authentication once it arrives
3
+ import { createResourceController } from '@symbiote-native/engine';
4
+ import { createAuthCell } from '../auth-request-controllers';
5
+ import { isSuccessResult } from '../session-result';
6
+ import { AccessTokenRequest } from '../token-request';
7
+ import { discovery as googleDiscovery } from './google';
8
+ // The result to exchange, or null when there is nothing to do: a code and no authentication yet,
9
+ // unless the caller decided explicitly
10
+ function exchangeableResult(result, override) {
11
+ if (!isSuccessResult(result))
12
+ return null;
13
+ const shouldExchange = override ?? (Boolean(result.params.code) && !result.authentication);
14
+ return shouldExchange ? result : null;
15
+ }
16
+ // Trades the code for tokens and folds them into the result, as the hook does upstream
17
+ async function exchangeCode(toExchange, request, exchange) {
18
+ const exchangeRequest = new AccessTokenRequest({
19
+ clientId: exchange.clientId,
20
+ clientSecret: exchange.clientSecret,
21
+ redirectUri: exchange.redirectUri,
22
+ scopes: exchange.scopes,
23
+ code: toExchange.params.code ?? '',
24
+ extraParams: { code_verifier: request?.codeVerifier || '' },
25
+ });
26
+ const authentication = await exchangeRequest.performAsync(googleDiscovery);
27
+ return {
28
+ ...toExchange,
29
+ params: {
30
+ id_token: authentication?.idToken || '',
31
+ access_token: authentication.accessToken,
32
+ ...toExchange.params,
33
+ },
34
+ authentication,
35
+ };
36
+ }
37
+ function isSameKey(a, b) {
38
+ return (a.result === b.result &&
39
+ a.request?.codeVerifier === b.request?.codeVerifier &&
40
+ a.exchange.clientId === b.exchange.clientId &&
41
+ a.exchange.redirectUri === b.exchange.redirectUri &&
42
+ a.exchange.clientSecret === b.exchange.clientSecret &&
43
+ a.exchange.shouldAutoExchangeCode === b.exchange.shouldAutoExchangeCode &&
44
+ a.exchange.scopes?.join(',') === b.exchange.scopes?.join(','));
45
+ }
46
+ export function createGoogleExchangeController() {
47
+ // The last published value stays visible while the next exchange runs
48
+ let lastPublished = null;
49
+ const controller = createResourceController(({ result, request, exchange }) => {
50
+ let isMounted = true;
51
+ const stop = () => {
52
+ isMounted = false;
53
+ };
54
+ const toExchange = exchangeableResult(result, exchange.shouldAutoExchangeCode);
55
+ if (!toExchange) {
56
+ lastPublished = result;
57
+ return { cell: createAuthCell(result), stop };
58
+ }
59
+ const cell = createAuthCell(lastPublished);
60
+ void exchangeCode(toExchange, request, exchange).then(merged => {
61
+ if (!isMounted)
62
+ return;
63
+ lastPublished = merged;
64
+ cell.set(merged);
65
+ });
66
+ return { cell, stop };
67
+ }, resource => resource.stop(), isSameKey);
68
+ return {
69
+ resolve: (result, request, exchange) => controller.resolve({ result, request, exchange }).cell,
70
+ flushDispose: controller.flushDispose,
71
+ dispose: controller.dispose,
72
+ };
73
+ }
74
+ //# sourceMappingURL=google-exchange-controller.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google-exchange-controller.js","sourceRoot":"","sources":["../../../src/core/providers/google-exchange-controller.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,0EAA0E;AAE1E,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AC,EAAE,IAAI,EAAE,CAAC;QAChD,CAAC;QACD,MAAM,IAAI,GAAG,cAAc,CAA4B,aAAa,CAAC,CAAC;QACtE,KAAK,YAAY,CAAC,UAAU,EAAE,OAAO,EAAE,QAAQ,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,EAAE;YAC7D,IAAI,CAAC,SAAS;gBAAE,OAAO;YACvB,aAAa,GAAG,MAAM,CAAC;YACvB,IAAI,CAAC,GAAG,CAAC,MAAM,CAAC,CAAC;QACnB,CAAC,CAAC,CAAC;QACH,OAAO,EAAE,IAAI,EAAE,IAAI,EAAE,CAAC;IACxB,CAAC,EACD,QAAQ,CAAC,EAAE,CAAC,QAAQ,CAAC,IAAI,EAAE,EAC3B,SAAS,CACV,CAAC;IAEF,OAAO;QACL,OAAO,EAAE,CAAC,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,EAAE,CACrC,UAAU,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,OAAO,EAAE,QAAQ,EAAE,CAAC,CAAC,IAAI;QACxD,YAAY,EAAE,UAAU,CAAC,YAAY;QACrC,OAAO,EAAE,UAAU,CAAC,OAAO;KAC5B,CAAC;AACJ,CAAC"}
@@ -0,0 +1,22 @@
1
+ import type { IAuthRequestConfig } from '../auth-request.types';
2
+ import { AuthRequest } from '../auth-request';
3
+ import type { IDiscoveryDocument } from '../discovery';
4
+ import type { IProviderAuthRequestConfig } from './provider.types';
5
+ export declare const discovery: IDiscoveryDocument;
6
+ export type IGoogleAuthRequestConfig = IProviderAuthRequestConfig & {
7
+ /** If the user's email is known ahead of time, supply it as the default option. */
8
+ loginHint?: string;
9
+ /** Lets the user switch accounts, where possible. @default false */
10
+ selectAccount?: boolean;
11
+ webClientId?: string;
12
+ iosClientId?: string;
13
+ androidClientId?: string;
14
+ /** Exchange the response code for a token in the hook, on by default for the code flow */
15
+ shouldAutoExchangeCode?: boolean;
16
+ };
17
+ /** Extends `AuthRequest`, applying Google's minimum scopes and an id-token nonce. */
18
+ export declare class GoogleAuthRequest extends AuthRequest {
19
+ nonce?: string;
20
+ constructor({ language, loginHint, selectAccount, extraParams, clientSecret, ...config }: IGoogleAuthRequestConfig);
21
+ getAuthRequestConfigAsync(): Promise<IAuthRequestConfig>;
22
+ }
@@ -0,0 +1,53 @@
1
+ import { Prompt, ResponseType } from '../auth-request.types';
2
+ import { AuthRequest } from '../auth-request';
3
+ import { generateHexStringAsync } from '../pkce';
4
+ import { applyRequiredScopes } from './provider-utils';
5
+ const MINIMUM_SCOPES = [
6
+ 'openid',
7
+ 'https://www.googleapis.com/auth/userinfo.profile',
8
+ 'https://www.googleapis.com/auth/userinfo.email',
9
+ ];
10
+ export const discovery = {
11
+ authorizationEndpoint: 'https://accounts.google.com/o/oauth2/v2/auth',
12
+ tokenEndpoint: 'https://oauth2.googleapis.com/token',
13
+ revocationEndpoint: 'https://oauth2.googleapis.com/revoke',
14
+ userInfoEndpoint: 'https://openidconnect.googleapis.com/v1/userinfo',
15
+ };
16
+ /** Extends `AuthRequest`, applying Google's minimum scopes and an id-token nonce. */
17
+ export class GoogleAuthRequest extends AuthRequest {
18
+ nonce;
19
+ constructor({ language, loginHint, selectAccount, extraParams = {}, clientSecret, ...config }) {
20
+ const inputParams = { ...extraParams };
21
+ if (language)
22
+ inputParams.hl = language;
23
+ if (loginHint)
24
+ inputParams.login_hint = loginHint;
25
+ if (selectAccount)
26
+ inputParams.prompt = Prompt.SelectAccount;
27
+ const scopes = applyRequiredScopes(config.scopes, MINIMUM_SCOPES);
28
+ const isImplicit = config.responseType === ResponseType.Token ||
29
+ config.responseType === ResponseType.IdToken;
30
+ if (isImplicit) {
31
+ config.usePKCE = false;
32
+ }
33
+ // Google rejects a client secret unless the code flow is used.
34
+ const inputClientSecret = config.responseType && config.responseType !== ResponseType.Code
35
+ ? clientSecret
36
+ : undefined;
37
+ super({
38
+ ...config,
39
+ clientSecret: inputClientSecret,
40
+ scopes,
41
+ extraParams: inputParams,
42
+ });
43
+ }
44
+ async getAuthRequestConfigAsync() {
45
+ const { extraParams = {}, ...config } = await super.getAuthRequestConfigAsync();
46
+ if (config.responseType === ResponseType.IdToken && !extraParams.nonce) {
47
+ this.nonce = this.nonce ?? (await generateHexStringAsync(16));
48
+ extraParams.nonce = this.nonce;
49
+ }
50
+ return { ...config, extraParams };
51
+ }
52
+ }
53
+ //# sourceMappingURL=google.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"google.js","sourceRoot":"","sources":["../../../src/core/providers/google.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,EAAE,WAAW,EAAE,MAAM,iBAAiB,CAAC;AAE9C,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,kBAAkB,CAAC;AAGvD,MAAM,cAAc,GAAG;IACrB,QAAQ;IACR,kDAAkD;IAClD,gDAAgD;CACjD,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAuB;IAC3C,qBAAqB,EAAE,8CAA8C;IACrE,aAAa,EAAE,qCAAqC;IACpD,kBAAkB,EAAE,sCAAsC;IAC1D,gBAAgB,EAAE,kDAAkD;CACrE,CAAC;AAcF,qFAAqF;AACrF,MAAM,OAAO,iBAAkB,SAAQ,WAAW;IAChD,KAAK,CAAU;IAEf,YAAY,EACV,QAAQ,EACR,SAAS,EACT,aAAa,EACb,WAAW,GAAG,EAAE,EAChB,YAAY,EACZ,GAAG,MAAM,EACgB;QACzB,MAAM,WAAW,GAAG,EAAE,GAAG,WAAW,EAAE,CAAC;QACvC,IAAI,QAAQ;YAAE,WAAW,CAAC,EAAE,GAAG,QAAQ,CAAC;QACxC,IAAI,SAAS;YAAE,WAAW,CAAC,UAAU,GAAG,SAAS,CAAC;QAClD,IAAI,aAAa;YAAE,WAAW,CAAC,MAAM,GAAG,MAAM,CAAC,aAAa,CAAC;QAE7D,MAAM,MAAM,GAAG,mBAAmB,CAAC,MAAM,CAAC,MAAM,EAAE,cAAc,CAAC,CAAC;QAClE,MAAM,UAAU,GACd,MAAM,CAAC,YAAY,KAAK,YAAY,CAAC,KAAK;YAC1C,MAAM,CAAC,YAAY,KAAK,YAAY,CAAC,OAAO,CAAC;QAC/C,IAAI,UAAU,EAAE,CAAC;YACf,MAAM,CAAC,OAAO,GAAG,KAAK,CAAC;QACzB,CAAC;QACD,+DAA+D;QAC/D,MAAM,iBAAiB,GACrB,MAAM,CAAC,YAAY,IAAI,MAAM,CAAC,YAAY,KAAK,YAAY,CAAC,IAAI;YAC9D,CAAC,CAAC,YAAY;YACd,CAAC,CAAC,SAAS,CAAC;QAEhB,KAAK,CAAC;YACJ,GAAG,MAAM;YACT,YAAY,EAAE,iBAAiB;YAC/B,MAAM;YACN,WAAW,EAAE,WAAW;SACzB,CAAC,CAAC;IACL,CAAC;IAEQ,KAAK,CAAC,yBAAyB;QACtC,MAAM,EAAE,WAAW,GAAG,EAAE,EAAE,GAAG,MAAM,EAAE,GACnC,MAAM,KAAK,CAAC,yBAAyB,EAAE,CAAC;QAC1C,IAAI,MAAM,CAAC,YAAY,KAAK,YAAY,CAAC,OAAO,IAAI,CAAC,WAAW,CAAC,KAAK,EAAE,CAAC;YACvE,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,IAAI,CAAC,MAAM,sBAAsB,CAAC,EAAE,CAAC,CAAC,CAAC;YAC9D,WAAW,CAAC,KAAK,GAAG,IAAI,CAAC,KAAK,CAAC;QACjC,CAAC;QACD,OAAO,EAAE,GAAG,MAAM,EAAE,WAAW,EAAE,CAAC;IACpC,CAAC;CACF"}
@@ -0,0 +1,19 @@
1
+ import type { IAuthSessionRedirectUriOptions } from '../auth-session.types';
2
+ import type { IFacebookAuthRequestConfig } from './facebook';
3
+ import type { IGoogleAuthRequestConfig } from './google';
4
+ /** What the automatic code exchange needs, upstream reads the same fields off the hook config */
5
+ export type IGoogleExchangeParams = {
6
+ clientId: string;
7
+ clientSecret?: string;
8
+ redirectUri: string;
9
+ scopes?: string[];
10
+ shouldAutoExchangeCode?: boolean;
11
+ };
12
+ export type IGoogleRequestSetup = {
13
+ requestConfig: IGoogleAuthRequestConfig;
14
+ exchange: IGoogleExchangeParams;
15
+ };
16
+ export declare function resolveGoogleRequestSetup(config?: Partial<IGoogleAuthRequestConfig>, redirectUriOptions?: Partial<IAuthSessionRedirectUriOptions>): IGoogleRequestSetup;
17
+ /** Upstream only asks for `id_token` directly on web, so off web the default flow applies */
18
+ export declare function toGoogleIdTokenConfig(config: Partial<IGoogleAuthRequestConfig>): Partial<IGoogleAuthRequestConfig>;
19
+ export declare function resolveFacebookRequestSetup(config?: Partial<IFacebookAuthRequestConfig>, redirectUriOptions?: Partial<IAuthSessionRedirectUriOptions>): IFacebookAuthRequestConfig;
@@ -0,0 +1,79 @@
1
+ // The config each provider hook derives before it loads a request, kept pure so every adapter's
2
+ // hook shares one copy of upstream's `useMemo` blocks
3
+ import { Platform } from 'react-native';
4
+ import { applicationId } from '@symbiote-native/application';
5
+ import { Prompt, ResponseType } from '../auth-request.types';
6
+ import { makeRedirectUri } from '../auth-session';
7
+ import { invariantClientId } from './provider-utils';
8
+ function clientIdProperty() {
9
+ return Platform.select({
10
+ ios: 'iosClientId',
11
+ android: 'androidClientId',
12
+ default: 'webClientId',
13
+ });
14
+ }
15
+ function pickClientId(config, providerName) {
16
+ const propertyName = clientIdProperty();
17
+ const clientId = config[propertyName] ?? config.clientId;
18
+ invariantClientId(propertyName, clientId, providerName);
19
+ return clientId;
20
+ }
21
+ function resolveGoogleResponseType(config) {
22
+ // Allow overrides
23
+ if (typeof config.responseType !== 'undefined')
24
+ return config.responseType;
25
+ // Installed apps auto exchange the code for the token and the id token, no secret needed
26
+ return ResponseType.Code;
27
+ }
28
+ function resolveGoogleExtraParams(config) {
29
+ const output = { ...config.extraParams };
30
+ if (config.language)
31
+ output.hl = config.language;
32
+ if (config.loginHint)
33
+ output.login_hint = config.loginHint;
34
+ if (config.selectAccount)
35
+ output.prompt = Prompt.SelectAccount;
36
+ return output;
37
+ }
38
+ export function resolveGoogleRequestSetup(config = {}, redirectUriOptions = {}) {
39
+ const clientId = pickClientId(config, 'Google');
40
+ const redirectUri = config.redirectUri ??
41
+ makeRedirectUri({
42
+ native: `${applicationId}:/oauthredirect`,
43
+ ...redirectUriOptions,
44
+ });
45
+ return {
46
+ requestConfig: {
47
+ ...config,
48
+ responseType: resolveGoogleResponseType(config),
49
+ extraParams: resolveGoogleExtraParams(config),
50
+ clientId,
51
+ redirectUri,
52
+ },
53
+ exchange: {
54
+ clientId,
55
+ clientSecret: config.clientSecret,
56
+ redirectUri,
57
+ scopes: config.scopes,
58
+ shouldAutoExchangeCode: config.shouldAutoExchangeCode,
59
+ },
60
+ };
61
+ }
62
+ /** Upstream only asks for `id_token` directly on web, so off web the default flow applies */
63
+ export function toGoogleIdTokenConfig(config) {
64
+ return { ...config, responseType: undefined };
65
+ }
66
+ export function resolveFacebookRequestSetup(config = {}, redirectUriOptions = {}) {
67
+ const clientId = pickClientId(config, 'Facebook');
68
+ const redirectUri = config.redirectUri ??
69
+ makeRedirectUri({
70
+ // The redirect URI is fb + client ID on native
71
+ native: `fb${clientId}://authorize`,
72
+ ...redirectUriOptions,
73
+ });
74
+ const extraParams = { ...config.extraParams };
75
+ if (config.language)
76
+ extraParams.locale = config.language;
77
+ return { ...config, extraParams, clientId, redirectUri };
78
+ }
79
+ //# sourceMappingURL=provider-hook-setup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-hook-setup.js","sourceRoot":"","sources":["../../../src/core/providers/provider-hook-setup.ts"],"names":[],"mappings":"AAAA,gGAAgG;AAChG,sDAAsD;AAEtD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,aAAa,EAAE,MAAM,8BAA8B,CAAC;AAC7D,OAAO,EAAE,MAAM,EAAE,YAAY,EAAE,MAAM,uBAAuB,CAAC;AAC7D,OAAO,E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Scopes: string[]): string[];
2
+ export declare function invariantClientId(idName: string, value: string | undefined, providerName: string): asserts value is string;
@@ -0,0 +1,9 @@
1
+ export function applyRequiredScopes(scopes = [], requiredScopes) {
2
+ return [...new Set([...scopes, ...requiredScopes])];
3
+ }
4
+ export function invariantClientId(idName, value, providerName) {
5
+ if (typeof value === 'undefined') {
6
+ throw new Error(`Client Id property \`${idName}\` must be defined to use ${providerName} auth on this platform.`);
7
+ }
8
+ }
9
+ //# sourceMappingURL=provider-utils.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider-utils.js","sourceRoot":"","sources":["../../../src/core/providers/provider-utils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,mBAAmB,CACjC,SAAmB,EAAE,EACrB,cAAwB;IAExB,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAC/B,MAAc,EACd,KAAyB,EACzB,YAAoB;IAEpB,IAAI,OAAO,KAAK,KAAK,WAAW,EAAE,CAAC;QACjC,MAAM,IAAI,KAAK,CACb,wBAAwB,MAAM,6BAA6B,YAAY,yBAAyB,CACjG,CAAC;IACJ,CAAC;AACH,CAAC"}
@@ -0,0 +1,5 @@
1
+ import type { IAuthRequestConfig } from '../auth-request.types';
2
+ export type IProviderAuthRequestConfig = IAuthRequestConfig & {
3
+ /** ISO 639-1 code, optionally `-<ISO 3166-1 alpha-2>` (e.g. `it`, `pt-PT`). */
4
+ language?: string;
5
+ };
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=provider.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"provider.types.js","sourceRoot":"","sources":["../../../src/core/providers/provider.types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,5 @@
1
+ export type IQueryParamsResult = {
2
+ errorCode: string | null;
3
+ params: Record<string, string>;
4
+ };
5
+ export declare function getQueryParams(input: string): IQueryParamsResult;
@@ -0,0 +1,13 @@
1
+ export function getQueryParams(input) {
2
+ const url = new URL(input, 'https://phony.example');
3
+ const errorCode = url.searchParams.get('errorCode');
4
+ url.searchParams.delete('errorCode');
5
+ const params = Object.fromEntries(url.searchParams);
6
+ if (url.hash) {
7
+ new URLSearchParams(url.hash.replace(/^#/, '')).forEach((value, key) => {
8
+ params[key] = value;
9
+ });
10
+ }
11
+ return { errorCode, params };
12
+ }
13
+ //# sourceMappingURL=query-params.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"query-params.js","sourceRoot":"","sources":["../../src/core/query-params.ts"],"names":[],"mappings":"AAKA,MAAM,UAAU,cAAc,CAAC,KAAa;IAC1C,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,KAAK,EAAE,uBAAuB,CAAC,CAAC;IAEpD,MAAM,SAAS,GAAG,GAAG,CAAC,YAAY,CAAC,GAAG,CAAC,WAAW,CAAC,CAAC;IACpD,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,WAAW,CAAC,CAAC;IAErC,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,GAAG,CAAC,YAAY,CAAC,CAAC;IACpD,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC;QACb,IAAI,eAAe,CAAC,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,IAAI,EAAE,EAAE,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE;YACrE,MAAM,CAAC,GAAG,CAAC,GAAG,KAAK,CAAC;QACtB,CAAC,CAAC,CAAC;IACL,CAAC;IAED,OAAO,EAAE,SAAS,EAAE,MAAM,EAAE,CAAC;AAC/B,CAAC"}
@@ -0,0 +1,6 @@
1
+ import type { IAuthSessionResult } from './auth-session.types';
2
+ /** The variant that carries params and authentication */
3
+ export type IAuthSessionParamsResult = Extract<IAuthSessionResult, {
4
+ params: unknown;
5
+ }>;
6
+ export declare function isSuccessResult(result: IAuthSessionResult | null): result is IAuthSessionParamsResult;
@@ -0,0 +1,5 @@
1
+ const SUCCESS_TYPE = 'success';
2
+ export function isSuccessResult(result) {
3
+ return result?.type === SUCCESS_TYPE;
4
+ }
5
+ //# sourceMappingURL=session-result.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"session-result.js","sourceRoot":"","sources":["../../src/core/session-result.ts"],"names":[],"mappings":"AAEA,MAAM,YAAY,GAAG,SAA8C,CAAC;AAQpE,MAAM,UAAU,eAAe,CAC7B,MAAiC;IAEjC,OAAO,MAAM,EAAE,IAAI,KAAK,YAAY,CAAC;AACvC,CAAC"}
@@ -0,0 +1,89 @@
1
+ import type { IDiscoveryDocument } from './discovery';
2
+ import type { IFetchHeaders } from './fetch';
3
+ import type { IAccessTokenRequestConfig, IRefreshTokenRequestConfig, IRevokeTokenRequestConfig, ITokenRequestConfig, ITokenResponseConfig, ITokenType, TokenTypeHint } from './token-request.types';
4
+ import { GrantType } from './token-request.types';
5
+ export declare function getCurrentTimeInSeconds(): number;
6
+ /** https://tools.ietf.org/html/rfc6749#section-5.1 */
7
+ export declare class TokenResponse implements ITokenResponseConfig {
8
+ static isTokenFresh(token: Pick<TokenResponse, 'expiresIn' | 'issuedAt'>,
9
+ /** -10 minutes in seconds. */
10
+ secondsMargin?: number): boolean;
11
+ static fromQueryParams(params: Record<string, string>): TokenResponse;
12
+ accessToken: string;
13
+ tokenType: ITokenType;
14
+ expiresIn?: number;
15
+ refreshToken?: string;
16
+ scope?: string;
17
+ state?: string;
18
+ idToken?: string;
19
+ issuedAt: number;
20
+ /** Unprocessed token response, for fields outside RFC 6749. */
21
+ rawResponse?: unknown;
22
+ constructor(response: ITokenResponseConfig, rawResponse?: unknown);
23
+ private applyResponseConfig;
24
+ getRequestConfig(): ITokenResponseConfig;
25
+ refreshAsync(config: Omit<ITokenRequestConfig, 'grantType' | 'refreshToken'>, discovery: Pick<IDiscoveryDocument, 'tokenEndpoint'>): Promise<TokenResponse>;
26
+ shouldRefresh(): boolean;
27
+ }
28
+ declare abstract class BaseRequest<TConfig, TResult> {
29
+ protected request: TConfig;
30
+ constructor(request: TConfig);
31
+ abstract performAsync(discovery: IDiscoveryDocument): Promise<TResult>;
32
+ abstract getRequestConfig(): TConfig;
33
+ abstract getQueryBody(): Record<string, string>;
34
+ }
35
+ /** A generic token request. */
36
+ export declare class TokenRequest<T extends ITokenRequestConfig> extends BaseRequest<T, TokenResponse> implements ITokenRequestConfig {
37
+ grantType: GrantType;
38
+ readonly clientId: string;
39
+ readonly clientSecret?: string;
40
+ readonly scopes?: string[];
41
+ readonly extraParams?: Record<string, string>;
42
+ readonly extraHeaders?: Record<string, string>;
43
+ constructor(request: T, grantType: GrantType);
44
+ getHeaders(): IFetchHeaders;
45
+ performAsync(discovery: Pick<IDiscoveryDocument, 'tokenEndpoint'>): Promise<TokenResponse>;
46
+ getRequestConfig(): T;
47
+ getQueryBody(): Record<string, string>;
48
+ }
49
+ /** https://tools.ietf.org/html/rfc6749#section-4.1.3 */
50
+ export declare class AccessTokenRequest extends TokenRequest<IAccessTokenRequestConfig> implements IAccessTokenRequestConfig {
51
+ readonly code: string;
52
+ readonly redirectUri: string;
53
+ constructor(options: IAccessTokenRequestConfig);
54
+ getQueryBody(): Record<string, string>;
55
+ getRequestConfig(): IAccessTokenRequestConfig & {
56
+ grantType: GrantType;
57
+ };
58
+ }
59
+ /** https://tools.ietf.org/html/rfc6749#section-6 */
60
+ export declare class RefreshTokenRequest extends TokenRequest<IRefreshTokenRequestConfig> implements IRefreshTokenRequestConfig {
61
+ readonly refreshToken?: string;
62
+ constructor(options: IRefreshTokenRequestConfig);
63
+ getQueryBody(): Record<string, string>;
64
+ getRequestConfig(): IRefreshTokenRequestConfig & {
65
+ grantType: GrantType;
66
+ };
67
+ }
68
+ /** https://tools.ietf.org/html/rfc7009#section-2.1 */
69
+ export declare class RevokeTokenRequest extends BaseRequest<IRevokeTokenRequestConfig, boolean> implements IRevokeTokenRequestConfig {
70
+ readonly clientId?: string;
71
+ readonly clientSecret?: string;
72
+ readonly token: string;
73
+ readonly tokenTypeHint?: TokenTypeHint;
74
+ readonly extraHeaders?: Record<string, string>;
75
+ constructor(request: IRevokeTokenRequestConfig);
76
+ getHeaders(): IFetchHeaders;
77
+ performAsync(discovery: Pick<IDiscoveryDocument, 'revocationEndpoint'>): Promise<boolean>;
78
+ getRequestConfig(): IRevokeTokenRequestConfig;
79
+ getQueryBody(): Record<string, string>;
80
+ }
81
+ /** Exchange an authorization code for an access token. */
82
+ export declare function exchangeCodeAsync(config: IAccessTokenRequestConfig, discovery: Pick<IDiscoveryDocument, 'tokenEndpoint'>): Promise<TokenResponse>;
83
+ /** Refresh an access token. See `TokenResponse.isTokenFresh()`/`shouldRefresh()`. */
84
+ export declare function refreshAsync(config: IRefreshTokenRequestConfig, discovery: Pick<IDiscoveryDocument, 'tokenEndpoint'>): Promise<TokenResponse>;
85
+ /** Revoke a token, effectively requiring the user to sign in again. */
86
+ export declare function revokeAsync(config: IRevokeTokenRequestConfig, discovery: Pick<IDiscoveryDocument, 'revocationEndpoint'>): Promise<boolean>;
87
+ /** Fetch generic user info from the provider's OpenID Connect `userInfoEndpoint`, if supported. */
88
+ export declare function fetchUserInfoAsync(config: Pick<TokenResponse, 'accessToken'>, discovery: Pick<IDiscoveryDocument, 'userInfoEndpoint'>): Promise<Record<string, unknown>>;
89
+ export {};