@symbiote-native/auth-session 0.0.0-stage → 0.1.1

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,44 @@
1
+ import type { IEventValueSource } from '@symbiote-native/engine';
2
+ import type { IAuthDiscoveryDocument, IAuthRequestConfig, IAuthRequestPromptOptions } from './auth-request.types';
3
+ import type { IAuthSessionResult } from './auth-session.types';
4
+ import type { IDiscoveryDocument, IIssuerOrDiscovery } from './discovery';
5
+ export declare const AUTH_CELL_CHANGE = "change";
6
+ export type IAuthCell<T> = IEventValueSource<T, typeof AUTH_CELL_CHANGE> & {
7
+ getSnapshot: () => T;
8
+ };
9
+ type IWritableAuthCell<T> = IAuthCell<T> & {
10
+ set: (value: T) => void;
11
+ };
12
+ export declare function createAuthCell<T>(initial: T): IWritableAuthCell<T>;
13
+ /** What a request has to offer for a hook to load it and prompt with it */
14
+ export type ILoadableRequest = {
15
+ url: string | null;
16
+ codeVerifier?: string;
17
+ makeAuthUrlAsync: (discovery: IAuthDiscoveryDocument) => Promise<string>;
18
+ promptAsync: (discovery: IAuthDiscoveryDocument, options?: IAuthRequestPromptOptions) => Promise<IAuthSessionResult>;
19
+ };
20
+ export type IAuthRequestClass<TRequest extends ILoadableRequest> = new (config: IAuthRequestConfig) => TRequest;
21
+ type ICellResourceController<TArgs extends unknown[], TValue> = {
22
+ resolve: (...args: TArgs) => IAuthCell<TValue>;
23
+ flushDispose: () => void;
24
+ dispose: () => void;
25
+ };
26
+ export declare function createAutoDiscoveryController(): ICellResourceController<[
27
+ IIssuerOrDiscovery
28
+ ], IDiscoveryDocument | null>;
29
+ export declare function createLoadedRequestController<TRequest extends ILoadableRequest = ILoadableRequest>(): {
30
+ resolve: (config: IAuthRequestConfig, discovery: IDiscoveryDocument | null, RequestClass: IAuthRequestClass<TRequest>) => IAuthCell<TRequest | null>;
31
+ flushDispose: () => void;
32
+ dispose: () => void;
33
+ };
34
+ export type IPromptMethod = (options?: IAuthRequestPromptOptions) => Promise<IAuthSessionResult>;
35
+ export type IRequestResultHolder = {
36
+ result: IAuthCell<IAuthSessionResult | null>;
37
+ promptAsync: IPromptMethod;
38
+ };
39
+ export declare function createRequestResultController(): {
40
+ resolve: (request: ILoadableRequest | null, discovery: IDiscoveryDocument | null, customOptions?: IAuthRequestPromptOptions) => IRequestResultHolder;
41
+ flushDispose: () => void;
42
+ dispose: () => void;
43
+ };
44
+ export {};
@@ -0,0 +1,123 @@
1
+ // Framework-agnostic halves of `useAutoDiscovery`, `useLoadedAuthRequest` and
2
+ // `useAuthRequestResult`. Each controller binds to an adapter's `createResourceHook`, and the value
3
+ // it hands back is a cell the adapter follows with its `createEventValueHook`
4
+ import { createResourceController } from '@symbiote-native/engine';
5
+ import { resolveDiscoveryAsync } from './discovery';
6
+ import { createPromptString } from './prompt-string';
7
+ export const AUTH_CELL_CHANGE = 'change';
8
+ export function createAuthCell(initial) {
9
+ let value = initial;
10
+ const listeners = new Set();
11
+ return {
12
+ getSnapshot: () => value,
13
+ set(next) {
14
+ value = next;
15
+ for (const listener of [...listeners])
16
+ listener(next);
17
+ },
18
+ addListener(_event, listener) {
19
+ listeners.add(listener);
20
+ return { remove: () => void listeners.delete(listener) };
21
+ },
22
+ };
23
+ }
24
+ export function createAutoDiscoveryController() {
25
+ const controller = createResourceController(issuerOrDiscovery => {
26
+ const cell = createAuthCell(null);
27
+ let isAllowed = true;
28
+ void resolveDiscoveryAsync(issuerOrDiscovery).then(discovery => {
29
+ if (isAllowed)
30
+ cell.set(discovery);
31
+ });
32
+ return {
33
+ cell,
34
+ stop: () => {
35
+ isAllowed = false;
36
+ },
37
+ };
38
+ }, resource => resource.stop());
39
+ return {
40
+ resolve: issuerOrDiscovery => controller.resolve(issuerOrDiscovery).cell,
41
+ flushDispose: controller.flushDispose,
42
+ dispose: controller.dispose,
43
+ };
44
+ }
45
+ // Everything upstream lists as the effect's dependencies, folded to primitives
46
+ function loadedRequestKey(config, discovery) {
47
+ return JSON.stringify([
48
+ discovery?.authorizationEndpoint,
49
+ config.clientId,
50
+ config.redirectUri,
51
+ config.responseType,
52
+ config.clientSecret,
53
+ config.codeChallenge,
54
+ config.state,
55
+ config.usePKCE,
56
+ config.scopes?.join(' '),
57
+ createPromptString(config.prompt),
58
+ JSON.stringify(config.extraParams ?? {}),
59
+ ]);
60
+ }
61
+ export function createLoadedRequestController() {
62
+ // The request that finished loading last, shown while a changed config reloads
63
+ let lastLoaded = null;
64
+ let RequestClassInUse = null;
65
+ const controller = createResourceController(({ config, discovery }) => {
66
+ const cell = createAuthCell(lastLoaded);
67
+ let isMounted = true;
68
+ if (discovery && RequestClassInUse) {
69
+ const request = new RequestClassInUse(config);
70
+ void request.makeAuthUrlAsync(discovery).then(() => {
71
+ if (!isMounted)
72
+ return;
73
+ lastLoaded = request;
74
+ cell.set(request);
75
+ });
76
+ }
77
+ return {
78
+ cell,
79
+ stop: () => {
80
+ isMounted = false;
81
+ },
82
+ };
83
+ }, resource => resource.stop(), (a, b) => a.key === b.key);
84
+ return {
85
+ resolve(config, discovery, RequestClass) {
86
+ RequestClassInUse = RequestClass;
87
+ return controller.resolve({
88
+ key: loadedRequestKey(config, discovery),
89
+ config,
90
+ discovery,
91
+ }).cell;
92
+ },
93
+ flushDispose: controller.flushDispose,
94
+ dispose: controller.dispose,
95
+ };
96
+ }
97
+ export function createRequestResultController() {
98
+ const result = createAuthCell(null);
99
+ let latest = { request: null, discovery: null, customOptions: {} };
100
+ // Reads the latest inputs when called, so one stable function serves every render
101
+ const promptAsync = async (options = {}) => {
102
+ const { request, discovery, customOptions } = latest;
103
+ if (!discovery || !request) {
104
+ throw new Error('Cannot prompt to authenticate until the request has finished loading.');
105
+ }
106
+ const prompted = await request.promptAsync(discovery, {
107
+ ...customOptions,
108
+ ...options,
109
+ });
110
+ result.set(prompted);
111
+ return prompted;
112
+ };
113
+ const holder = { result, promptAsync };
114
+ return {
115
+ resolve(request, discovery, customOptions = {}) {
116
+ latest = { request, discovery, customOptions };
117
+ return holder;
118
+ },
119
+ flushDispose: () => undefined,
120
+ dispose: () => undefined,
121
+ };
122
+ }
123
+ //# sourceMappingURL=auth-request-controllers.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-request-controllers.js","sourceRoot":"","sources":["../../src/core/auth-request-controllers.ts"],"names":[],"mappings":"AAAA,8EAA8E;AAC9E,oGAAoG;AACpG,8EAA8E;AAG9E,OAAO,EAAE,wBAAwB,EAAE,MAAM,yBAAyB,CAAC;AAQnE,OAAO,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACpD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,CAAC,MAAM,gBAAgB,GAAG,QAAQ,CAAC;AAQzC,MAAM,UAAU,cAAc,CAAI,OAAU;IAC1C,IAAI,KAAK,GAAG,OAAO,CAAC;IACpB,MAAM,SAAS,GAAG,IAAI,GAAG,EAAqB,CAAC;IAC/C,OAAO;QACL,WAAW,EAAE,GAAG,EAAE,CAAC,KAAK;QACxB,GAAG,CAAC,IAAI;YACN,KAAK,GAAG,IAAI,CAAC;YACb,KAAK,MAAM,QAAQ,IAAI,CAAC,GAAG,SAA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AAY,EAAE,GAAG,EAAE,CAAC,SAAS;QAC7B,OAAO,EAAE,GAAG,EAAE,CAAC,SAAS;KACzB,CAAC;AACJ,CAAC"}
@@ -0,0 +1,67 @@
1
+ import { AuthRequest } from './auth-request';
2
+ import type { IAuthCell, IAuthRequestClass, IPromptMethod } from './auth-request-controllers';
3
+ import { AUTH_CELL_CHANGE } from './auth-request-controllers';
4
+ import type { IAuthRequestConfig, IAuthRequestPromptOptions } from './auth-request.types';
5
+ import type { IAuthSessionRedirectUriOptions, IAuthSessionResult } from './auth-session.types';
6
+ import type { IDiscoveryDocument, IIssuerOrDiscovery } from './discovery';
7
+ import type { FacebookAuthRequest, IFacebookAuthRequestConfig } from './providers/facebook';
8
+ import type { GoogleAuthRequest, IGoogleAuthRequestConfig } from './providers/google';
9
+ /** A type-level function, how an adapter says "its box of `T`" */
10
+ export interface IHkt {
11
+ readonly input: unknown;
12
+ readonly output: unknown;
13
+ }
14
+ export type IApply<F extends IHkt, T> = (F & {
15
+ readonly input: T;
16
+ })['output'];
17
+ /** A plain getter, the argument shape of Solid, Svelte and Angular */
18
+ export interface IGetterKind extends IHkt {
19
+ readonly output: () => this['input'];
20
+ }
21
+ type IBoxed<T> = {
22
+ readonly current: T;
23
+ };
24
+ /** A `{ current }` box, Svelte's result shape */
25
+ export interface IBoxedKind extends IHkt {
26
+ readonly output: IBoxed<this['input']>;
27
+ }
28
+ /** The argument half of a kit for adapters whose arguments are plain getters */
29
+ export declare const GETTER_ARGS: {
30
+ toGetter: <T>(arg: () => T) => (() => T);
31
+ constant: <T>(value: T) => (() => T);
32
+ };
33
+ type IDiscoveryValue = IDiscoveryDocument | null;
34
+ type IResultValue = IAuthSessionResult | null;
35
+ export type IAuthResourceController<TArgs extends unknown[], TResource> = {
36
+ resolve: (...args: TArgs) => TResource;
37
+ flushDispose: () => void;
38
+ dispose: () => void;
39
+ };
40
+ /** The adapter's own primitives the hooks are built from */
41
+ export type IAuthHooksKit<FResource extends IHkt, FValue extends IHkt, FArg extends IHkt> = {
42
+ createResourceHook: <TArgs extends unknown[], TResource>(createController: () => IAuthResourceController<TArgs, TResource>) => (getArgs: () => TArgs) => IApply<FResource, TResource>;
43
+ readResource: <T>(box: IApply<FResource, T>) => T;
44
+ createEventValueHook: <TValue>(event: typeof AUTH_CELL_CHANGE, getValue: (source: IAuthCell<TValue>) => TValue) => (getSource: () => IAuthCell<TValue>) => IApply<FValue, TValue>;
45
+ readValue: <T>(box: IApply<FValue, T>) => T;
46
+ /** Turns whatever the adapter accepts as an argument into a getter */
47
+ toGetter: <T>(arg: IApply<FArg, T>) => () => T;
48
+ /** Wraps a fixed value in the adapter's argument shape */
49
+ constant: <T>(value: T) => IApply<FArg, T>;
50
+ };
51
+ type IUseAuthRequestBoxes<FValue extends IHkt, TRequest extends AuthRequest> = readonly [
52
+ IApply<FValue, TRequest | null>,
53
+ IApply<FValue, IResultValue>,
54
+ IPromptMethod
55
+ ];
56
+ type IAnyKit = IAuthHooksKit<IHkt, IHkt, IHkt>;
57
+ export type IAuthRequestHooks<FValue extends IHkt, FArg extends IHkt> = {
58
+ useAutoDiscovery: (issuerOrDiscovery: IApply<FArg, IIssuerOrDiscovery>) => IApply<FValue, IDiscoveryValue>;
59
+ useLoadedAuthRequest: (config: IApply<FArg, IAuthRequestConfig>, discovery: IApply<FArg, IDiscoveryValue>, RequestClass: IAuthRequestClass<AuthRequest>) => IApply<FValue, AuthRequest | null>;
60
+ useAuthRequestResult: (request: IApply<FArg, AuthRequest | null>, discovery: IApply<FArg, IDiscoveryValue>, customOptions?: IApply<FArg, IAuthRequestPromptOptions>) => readonly [IApply<FValue, IResultValue>, IPromptMethod];
61
+ useAuthRequest: (config: IApply<FArg, IAuthRequestConfig>, discovery: IApply<FArg, IDiscoveryValue>) => IUseAuthRequestBoxes<FValue, AuthRequest>;
62
+ useGoogleAuthRequest: (config?: IApply<FArg, Partial<IGoogleAuthRequestConfig>>, redirectUriOptions?: IApply<FArg, Partial<IAuthSessionRedirectUriOptions>>) => IUseAuthRequestBoxes<FValue, GoogleAuthRequest>;
63
+ useGoogleIdTokenAuthRequest: (config: IApply<FArg, Partial<IGoogleAuthRequestConfig>>, redirectUriOptions?: IApply<FArg, Partial<IAuthSessionRedirectUriOptions>>) => IUseAuthRequestBoxes<FValue, GoogleAuthRequest>;
64
+ useFacebookAuthRequest: (config?: IApply<FArg, Partial<IFacebookAuthRequestConfig>>, redirectUriOptions?: IApply<FArg, Partial<IAuthSessionRedirectUriOptions>>) => IUseAuthRequestBoxes<FValue, FacebookAuthRequest>;
65
+ };
66
+ export declare function createAuthRequestHooks<FResource extends IHkt, FValue extends IHkt, FArg extends IHkt>(kit: IAuthHooksKit<FResource, FValue, FArg>): IAuthRequestHooks<FValue, FArg>;
67
+ export type { IAnyKit as IAuthHooksAnyKit };
@@ -0,0 +1,76 @@
1
+ // The auth request hooks written once for every adapter whose hooks take getters (Vue, Solid,
2
+ // Svelte, Angular), React keeps its own wiring. An adapter's boxes (`ShallowRef`, `Accessor`,
3
+ // `{ current }`, `Signal`) are type-level functions here, since one hook returns several box types
4
+ import { AuthRequest } from './auth-request';
5
+ import { AUTH_CELL_CHANGE, createAutoDiscoveryController, createLoadedRequestController, createRequestResultController, } from './auth-request-controllers';
6
+ import { discovery as facebookDiscovery, FacebookAuthRequest as FacebookRequest, } from './providers/facebook';
7
+ import { createGoogleExchangeController } from './providers/google-exchange-controller';
8
+ import { discovery as googleDiscovery, GoogleAuthRequest as GoogleRequest, } from './providers/google';
9
+ import { resolveFacebookRequestSetup, resolveGoogleRequestSetup, toGoogleIdTokenConfig, } from './providers/provider-hook-setup';
10
+ /** The argument half of a kit for adapters whose arguments are plain getters */
11
+ export const GETTER_ARGS = {
12
+ toGetter: (arg) => arg,
13
+ constant: (value) => () => value,
14
+ };
15
+ function readAuthCell(cell) {
16
+ return cell.getSnapshot();
17
+ }
18
+ function valueHook(kit) {
19
+ return kit.createEventValueHook(AUTH_CELL_CHANGE, readAuthCell);
20
+ }
21
+ function discoveryOf(kit, getIssuer) {
22
+ const cell = kit.createResourceHook(createAutoDiscoveryController)(() => [
23
+ getIssuer(),
24
+ ]);
25
+ return valueHook(kit)(() => kit.readResource(cell));
26
+ }
27
+ function loadedRequestOf(kit, getConfig, getDiscovery, RequestClass) {
28
+ const useCell = kit.createResourceHook(() => createLoadedRequestController());
29
+ const cell = useCell(() => [getConfig(), getDiscovery(), RequestClass]);
30
+ return valueHook(kit)(() => kit.readResource(cell));
31
+ }
32
+ function resultOf(kit, getRequest, getDiscovery, getOptions) {
33
+ const useHolder = kit.createResourceHook(createRequestResultController);
34
+ const holder = useHolder(() => [getRequest(), getDiscovery(), getOptions()]);
35
+ const result = valueHook(kit)(() => kit.readResource(holder).result);
36
+ return [result, options => kit.readResource(holder).promptAsync(options)];
37
+ }
38
+ function baseRequestOf(kit, getConfig, getDiscovery) {
39
+ const request = loadedRequestOf(kit, getConfig, getDiscovery, AuthRequest);
40
+ const [result, promptAsync] = resultOf(kit, () => kit.readValue(request), getDiscovery, () => ({}));
41
+ return [request, result, promptAsync];
42
+ }
43
+ function googleRequestOf(kit, getConfig, getRedirectUriOptions) {
44
+ const getSetup = () => resolveGoogleRequestSetup(getConfig(), getRedirectUriOptions());
45
+ const request = loadedRequestOf(kit, () => getSetup().requestConfig, () => googleDiscovery, GoogleRequest);
46
+ const [result, promptAsync] = resultOf(kit, () => kit.readValue(request), () => googleDiscovery, () => ({}));
47
+ const useExchange = kit.createResourceHook(createGoogleExchangeController);
48
+ const exchanged = useExchange(() => [
49
+ kit.readValue(result),
50
+ kit.readValue(request),
51
+ getSetup().exchange,
52
+ ]);
53
+ const fullResult = valueHook(kit)(() => kit.readResource(exchanged));
54
+ return [request, fullResult, promptAsync];
55
+ }
56
+ function facebookRequestOf(kit, getConfig, getRedirectUriOptions) {
57
+ const request = loadedRequestOf(kit, () => resolveFacebookRequestSetup(getConfig(), getRedirectUriOptions()), () => facebookDiscovery, FacebookRequest);
58
+ const [result, promptAsync] = resultOf(kit, () => kit.readValue(request), () => facebookDiscovery, () => ({}));
59
+ return [request, result, promptAsync];
60
+ }
61
+ export function createAuthRequestHooks(kit) {
62
+ const noOptions = kit.constant({});
63
+ return {
64
+ useAutoDiscovery: issuer => discoveryOf(kit, kit.toGetter(issuer)),
65
+ useLoadedAuthRequest: (config, discovery, RequestClass) => loadedRequestOf(kit, kit.toGetter(config), kit.toGetter(discovery), RequestClass),
66
+ useAuthRequestResult: (request, discovery, customOptions = kit.constant({})) => resultOf(kit, kit.toGetter(request), kit.toGetter(discovery), kit.toGetter(customOptions)),
67
+ useAuthRequest: (config, discovery) => baseRequestOf(kit, kit.toGetter(config), kit.toGetter(discovery)),
68
+ useGoogleAuthRequest: (config = kit.constant({}), redirect = noOptions) => googleRequestOf(kit, kit.toGetter(config), kit.toGetter(redirect)),
69
+ useGoogleIdTokenAuthRequest: (config, redirect = noOptions) => {
70
+ const getConfig = kit.toGetter(config);
71
+ return googleRequestOf(kit, () => toGoogleIdTokenConfig(getConfig()), kit.toGetter(redirect));
72
+ },
73
+ useFacebookAuthRequest: (config = kit.constant({}), redirect = noOptions) => facebookRequestOf(kit, kit.toGetter(config), kit.toGetter(redirect)),
74
+ };
75
+ }
76
+ //# sourceMappingURL=auth-request-hooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-request-hooks.js","sourceRoot":"","sources":["../../src/core/auth-request-hooks.ts"],"names":[],"mappings":"AAAA,8FAA8F;AAC9F,8FAA8F;AAC9F,mGAAmG;AAEnG,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAM7C,OAAO,EACL,gBAAgB,EAChB,6BAA6B,EAC7B,6BAA6B,EAC7B,6BAA6B,GAC9B,MAAM,4BAA4B,CAAC;AAcpC,OAAO,EACL,SAAS,IAAI,iBAAiB,EAC9B,mBAAmB,IAAI,eAAe,GACvC,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,8BAA8B,EAAE,MAAM,wCAAwC,CAAC;AAKxF,OAAO,EACL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,CAAC,MAAM,CAAC,CAAC;YACvC,OAAO,eAAe,CACpB,GAAG,EACH,GAAG,EAAE,CAAC,qBAAqB,CAAC,SAAS,EAAE,CAAC,EACxC,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CACvB,CAAC;QACJ,CAAC;QACD,sBAAsB,EAAE,CAAC,MAAM,GAAG,GAAG,CAAC,QAAQ,CAAC,EAAE,CAAC,EAAE,QAAQ,GAAG,SAAS,EAAE,EAAE,CAC1E,iBAAiB,CAAC,GAAG,EAAE,GAAG,CAAC,QAAQ,CAAC,MAAM,CAAC,EAAE,GAAG,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;KACvE,CAAC;AACJ,CAAC"}
@@ -0,0 +1,29 @@
1
+ import type { IAuthDiscoveryDocument, IAuthRequestConfig, IAuthRequestPromptOptions, Prompt } from './auth-request.types';
2
+ import { CodeChallengeMethod, ResponseType } from './auth-request.types';
3
+ import type { IAuthSessionResult } from './auth-session.types';
4
+ /** Manages an authorization request, https://tools.ietf.org/html/rfc6749#section-4.1.1 */
5
+ export declare class AuthRequest implements Omit<IAuthRequestConfig, 'state'> {
6
+ /** Protection against Cross-Site Request Forgery. */
7
+ state: string;
8
+ url: string | null;
9
+ codeVerifier?: string;
10
+ codeChallenge?: string;
11
+ readonly responseType: ResponseType | string;
12
+ readonly clientId: string;
13
+ readonly extraParams: Record<string, string>;
14
+ readonly usePKCE?: boolean;
15
+ readonly codeChallengeMethod: CodeChallengeMethod;
16
+ readonly redirectUri: string;
17
+ readonly scopes?: string[];
18
+ readonly clientSecret?: string;
19
+ readonly prompt?: Prompt | Prompt[];
20
+ constructor(request: IAuthRequestConfig);
21
+ /** Loads and returns a valid auth request config, generating PKCE fields if needed. */
22
+ getAuthRequestConfigAsync(): Promise<IAuthRequestConfig>;
23
+ /** Prompts the user to authorize, opening a browser session for the auth URL. */
24
+ promptAsync(discovery: IAuthDiscoveryDocument, { url, ...options }?: IAuthRequestPromptOptions): Promise<IAuthSessionResult>;
25
+ parseReturnUrl(url: string): IAuthSessionResult;
26
+ /** Builds and caches the authorization URL. */
27
+ makeAuthUrlAsync(discovery: IAuthDiscoveryDocument): Promise<string>;
28
+ private ensureCodeIsSetupAsync;
29
+ }
@@ -0,0 +1,162 @@
1
+ import { Platform } from 'react-native';
2
+ import invariant from 'invariant';
3
+ import { openAuthSessionAsync } from '@symbiote-native/web-browser';
4
+ import { CodeChallengeMethod, ResponseType } from './auth-request.types';
5
+ import { AuthError } from './errors';
6
+ import { createPromptString } from './prompt-string';
7
+ import { getQueryParams } from './query-params';
8
+ import { buildCodeAsync, generateRandom } from './pkce';
9
+ import { TokenResponse } from './token-request';
10
+ let authLock = false;
11
+ /** Manages an authorization request, https://tools.ietf.org/html/rfc6749#section-4.1.1 */
12
+ export class AuthRequest {
13
+ /** Protection against Cross-Site Request Forgery. */
14
+ state;
15
+ url = null;
16
+ codeVerifier;
17
+ codeChallenge;
18
+ responseType;
19
+ clientId;
20
+ extraParams;
21
+ usePKCE;
22
+ codeChallengeMethod;
23
+ redirectUri;
24
+ scopes;
25
+ clientSecret;
26
+ prompt;
27
+ constructor(request) {
28
+ this.responseType = request.responseType ?? ResponseType.Code;
29
+ this.clientId = request.clientId;
30
+ this.redirectUri = request.redirectUri;
31
+ this.scopes = request.scopes;
32
+ this.clientSecret = request.clientSecret;
33
+ this.prompt = request.prompt;
34
+ this.state = request.state ?? generateRandom(10);
35
+ this.extraParams = request.extraParams ?? {};
36
+ this.codeChallengeMethod =
37
+ request.codeChallengeMethod ?? CodeChallengeMethod.S256;
38
+ this.usePKCE = request.usePKCE ?? true;
39
+ invariant(this.codeChallengeMethod !== CodeChallengeMethod.Plain, '`AuthRequest` does not support `CodeChallengeMethod.Plain` as it is not secure.');
40
+ invariant(this.redirectUri, `\`AuthRequest\` requires a valid \`redirectUri\`. Ex: ${Platform.OS === 'web'
41
+ ? 'https://yourwebsite.com/'
42
+ : 'com.your.app:/oauthredirect'}`);
43
+ }
44
+ /** Loads and returns a valid auth request config, generating PKCE fields if needed. */
45
+ async getAuthRequestConfigAsync() {
46
+ if (this.usePKCE) {
47
+ await this.ensureCodeIsSetupAsync();
48
+ }
49
+ return {
50
+ responseType: this.responseType,
51
+ clientId: this.clientId,
52
+ redirectUri: this.redirectUri,
53
+ scopes: this.scopes,
54
+ clientSecret: this.clientSecret,
55
+ codeChallenge: this.codeChallenge,
56
+ codeChallengeMethod: this.codeChallengeMethod,
57
+ prompt: this.prompt,
58
+ state: this.state,
59
+ extraParams: this.extraParams,
60
+ usePKCE: this.usePKCE,
61
+ };
62
+ }
63
+ /** Prompts the user to authorize, opening a browser session for the auth URL. */
64
+ async promptAsync(discovery, { url, ...options } = {}) {
65
+ if (!url) {
66
+ if (!this.url) {
67
+ return this.promptAsync(discovery, {
68
+ ...options,
69
+ url: await this.makeAuthUrlAsync(discovery),
70
+ });
71
+ }
72
+ url = this.url;
73
+ }
74
+ invariant(url, 'No authUrl provided - it points to the page where the user signs in.');
75
+ if (authLock) {
76
+ return { type: 'locked' };
77
+ }
78
+ authLock = true;
79
+ let result;
80
+ try {
81
+ result = await openAuthSessionAsync(url, this.redirectUri, options);
82
+ }
83
+ finally {
84
+ authLock = false;
85
+ }
86
+ if (result.type === 'opened') {
87
+ throw new Error('An unexpected error occurred');
88
+ }
89
+ if (result.type !== 'success') {
90
+ return { type: result.type };
91
+ }
92
+ return this.parseReturnUrl(result.url);
93
+ }
94
+ parseReturnUrl(url) {
95
+ const { params, errorCode } = getQueryParams(url);
96
+ const { state, error = errorCode ?? undefined } = params;
97
+ let parsedError = null;
98
+ let authentication = null;
99
+ if (state !== this.state) {
100
+ parsedError = new AuthError({
101
+ error: 'state_mismatch',
102
+ error_description: 'Cross-Site request verification failed. Cached state and returned state do not match.',
103
+ });
104
+ }
105
+ else if (error) {
106
+ parsedError = new AuthError({ error, ...params });
107
+ }
108
+ if (params.access_token) {
109
+ authentication = TokenResponse.fromQueryParams(params);
110
+ }
111
+ return {
112
+ type: parsedError ? 'error' : 'success',
113
+ error: parsedError,
114
+ url,
115
+ params,
116
+ authentication,
117
+ errorCode,
118
+ };
119
+ }
120
+ /** Builds and caches the authorization URL. */
121
+ async makeAuthUrlAsync(discovery) {
122
+ const request = await this.getAuthRequestConfigAsync();
123
+ if (!request.state)
124
+ throw new Error('Cannot make request URL without a valid `state` loaded');
125
+ const params = {};
126
+ if (request.codeChallenge) {
127
+ params.code_challenge = request.codeChallenge;
128
+ }
129
+ for (const extra in request.extraParams) {
130
+ const param = request.extraParams[extra];
131
+ if (param != null) {
132
+ params[extra] = param;
133
+ }
134
+ }
135
+ if (request.usePKCE && request.codeChallengeMethod) {
136
+ params.code_challenge_method = request.codeChallengeMethod;
137
+ }
138
+ if (request.clientSecret) {
139
+ params.client_secret = request.clientSecret;
140
+ }
141
+ if (request.prompt) {
142
+ params.prompt = createPromptString(request.prompt) ?? '';
143
+ }
144
+ params.redirect_uri = request.redirectUri;
145
+ params.client_id = request.clientId;
146
+ params.response_type = request.responseType ?? ResponseType.Code;
147
+ params.state = request.state;
148
+ if (request.scopes?.length) {
149
+ params.scope = request.scopes.join(' ');
150
+ }
151
+ this.url = `${discovery.authorizationEndpoint}?${new URLSearchParams(params)}`;
152
+ return this.url;
153
+ }
154
+ async ensureCodeIsSetupAsync() {
155
+ if (this.codeVerifier)
156
+ return;
157
+ const { codeVerifier, codeChallenge } = await buildCodeAsync();
158
+ this.codeVerifier = codeVerifier;
159
+ this.codeChallenge = codeChallenge;
160
+ }
161
+ }
162
+ //# sourceMappingURL=auth-request.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-request.js","sourceRoot":"","sources":["../../src/core/auth-request.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AACxC,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,oBAAoB,EAAE,MAAM,8BAA8B,CAAC;AAQpE,OAAO,EAAE,mBAAmB,EAAE,YAAY,EAAE,MAAM,sBA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AAI,OAAO,CAAC,MAAM,EAAE,CAAC;YACnB,MAAM,CAAC,MAAM,GAAG,kBAAkB,CAAC,OAAO,CAAC,MAAM,CAAC,IAAI,EAAE,CAAC;QAC3D,CAAC;QACD,MAAM,CAAC,YAAY,GAAG,OAAO,CAAC,WAAW,CAAC;QAC1C,MAAM,CAAC,SAAS,GAAG,OAAO,CAAC,QAAQ,CAAC;QACpC,MAAM,CAAC,aAAa,GAAG,OAAO,CAAC,YAAY,IAAI,YAAY,CAAC,IAAI,CAAC;QACjE,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC7B,IAAI,OAAO,CAAC,MAAM,EAAE,MAAM,EAAE,CAAC;YAC3B,MAAM,CAAC,KAAK,GAAG,OAAO,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;QAC1C,CAAC;QAED,IAAI,CAAC,GAAG,GAAG,GAAG,SAAS,CAAC,qBAAqB,IAAI,IAAI,eAAe,CAAC,MAAM,CAAC,EAAE,CAAC;QAC/E,OAAO,IAAI,CAAC,GAAG,CAAC;IAClB,CAAC;IAEO,KAAK,CAAC,sBAAsB;QAClC,IAAI,IAAI,CAAC,YAAY;YAAE,OAAO;QAC9B,MAAM,EAAE,YAAY,EAAE,aAAa,EAAE,GAAG,MAAM,cAAc,EAAE,CAAC;QAC/D,IAAI,CAAC,YAAY,GAAG,YAAY,CAAC;QACjC,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;IACrC,CAAC;CACF"}
@@ -0,0 +1,46 @@
1
+ import type { IAuthSessionOpenOptions } from '@symbiote-native/web-browser';
2
+ import type { IDiscoveryDocument } from './discovery';
3
+ export declare enum CodeChallengeMethod {
4
+ /** The default and recommended method for transforming the code verifier. */
5
+ S256 = "S256",
6
+ /** Not secure - the code verifier would be sent to the server as-is. */
7
+ Plain = "plain"
8
+ }
9
+ export type ICodeChallengeMethod = CodeChallengeMethod;
10
+ /** https://tools.ietf.org/html/rfc6749#section-3.1.1 */
11
+ export declare enum ResponseType {
12
+ Code = "code",
13
+ Token = "token",
14
+ /** A custom registered type for getting an `id_token` from Google OAuth. */
15
+ IdToken = "id_token"
16
+ }
17
+ /** https://openid.net/specs/openid-connect-core-1_0.html#AuthorizationRequest */
18
+ export declare enum Prompt {
19
+ None = "none",
20
+ Login = "login",
21
+ Consent = "consent",
22
+ SelectAccount = "select_account"
23
+ }
24
+ export type IAuthRequestPromptOptions = IAuthSessionOpenOptions & {
25
+ /** URL to open when prompting the user; usually left undefined and generated internally. */
26
+ url?: string;
27
+ };
28
+ /** Represents an OAuth authorization request as JSON. */
29
+ export type IAuthRequestConfig = {
30
+ /** @default ResponseType.Code */
31
+ responseType?: ResponseType | string;
32
+ clientId: string;
33
+ redirectUri: string;
34
+ scopes?: string[];
35
+ clientSecret?: string;
36
+ /** @default CodeChallengeMethod.S256 */
37
+ codeChallengeMethod?: CodeChallengeMethod;
38
+ codeChallenge?: string;
39
+ prompt?: Prompt | Prompt[];
40
+ /** Protection against Cross-Site Request Forgery. */
41
+ state?: string;
42
+ extraParams?: Record<string, string>;
43
+ /** @default true */
44
+ usePKCE?: boolean;
45
+ };
46
+ export type IAuthDiscoveryDocument = Pick<IDiscoveryDocument, 'authorizationEndpoint'>;
@@ -0,0 +1,24 @@
1
+ export var CodeChallengeMethod;
2
+ (function (CodeChallengeMethod) {
3
+ /** The default and recommended method for transforming the code verifier. */
4
+ CodeChallengeMethod["S256"] = "S256";
5
+ /** Not secure - the code verifier would be sent to the server as-is. */
6
+ CodeChallengeMethod["Plain"] = "plain";
7
+ })(CodeChallengeMethod || (CodeChallengeMethod = {}));
8
+ /** https://tools.ietf.org/html/rfc6749#section-3.1.1 */
9
+ export var ResponseType;
10
+ (function (ResponseType) {
11
+ ResponseType["Code"] = "code";
12
+ ResponseType["Token"] = "token";
13
+ /** A custom registered type for getting an `id_token` from Google OAuth. */
14
+ ResponseType["IdToken"] = "id_token";
15
+ })(ResponseType || (ResponseType = {}));
16
+ /** https://openid.net/specs/openid-connect-core-1_0.html#AuthorizationRequest */
17
+ export var Prompt;
18
+ (function (Prompt) {
19
+ Prompt["None"] = "none";
20
+ Prompt["Login"] = "login";
21
+ Prompt["Consent"] = "consent";
22
+ Prompt["SelectAccount"] = "select_account";
23
+ })(Prompt || (Prompt = {}));
24
+ //# sourceMappingURL=auth-request.types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-request.types.js","sourceRoot":"","sources":["../../src/core/auth-request.types.ts"],"names":[],"mappings":"AAGA,MAAM,CAAN,IAAY,mBAKX;AALD,WAAY,mBAAmB;IAC7B,6EAA6E;IAC7E,oCAAa,CAAA;IACb,wEAAwE;IACxE,sCAAe,CAAA;AACjB,CAAC,EALW,mBAAmB,KAAnB,mBAAmB,QAK9B;AAGD,wDAAwD;AACxD,MAAM,CAAN,IAAY,YAKX;AALD,WAAY,YAAY;IACtB,6BAAa,CAAA;IACb,+BAAe,CAAA;IACf,4EAA4E;IAC5E,oCAAoB,CAAA;AACtB,CAAC,EALW,YAAY,KAAZ,YAAY,QAKvB;AAED,iFAAiF;AACjF,MAAM,CAAN,IAAY,MAKX;AALD,WAAY,MAAM;IAChB,uBAAa,CAAA;IACb,yBAAe,CAAA;IACf,6BAAmB,CAAA;IACnB,0CAAgC,CAAA;AAClC,CAAC,EALW,MAAM,KAAN,MAAM,QAKjB"}
@@ -0,0 +1,10 @@
1
+ import { AuthRequest } from './auth-request';
2
+ import type { IAuthRequestConfig } from './auth-request.types';
3
+ import type { IAuthSessionRedirectUriOptions } from './auth-session.types';
4
+ import type { IIssuerOrDiscovery } from './discovery';
5
+ /** Cancels an active `AuthSession`, if there is one. */
6
+ export declare function dismiss(): void;
7
+ /** Unlike upstream, never reads an app manifest - pass `native` or `scheme` explicitly. */
8
+ export declare function makeRedirectUri({ native, scheme, isTripleSlashed, queryParams, path, preferLocalhost, }?: IAuthSessionRedirectUriOptions): string;
9
+ /** Builds an `AuthRequest` and loads its authorization URL before returning it. */
10
+ export declare function loadAsync(config: IAuthRequestConfig, issuerOrDiscovery: IIssuerOrDiscovery): Promise<AuthRequest>;