expo-auth-session 5.1.0 → 5.2.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/CHANGELOG.md CHANGED
@@ -10,6 +10,20 @@
10
10
 
11
11
  ### 💡 Others
12
12
 
13
+ ## 5.2.0 — 2023-09-04
14
+
15
+ ### 🛠 Breaking changes
16
+
17
+ - Fix for breaking change in expo-constants to only support new manifests. ([#24267](https://github.com/expo/expo/pull/24267) by [@wschurman](https://github.com/wschurman))
18
+
19
+ ## 5.1.2 — 2023-09-04
20
+
21
+ _This version does not introduce any user-facing changes._
22
+
23
+ ## 5.1.1 — 2023-08-02
24
+
25
+ _This version does not introduce any user-facing changes._
26
+
13
27
  ## 5.1.0 — 2023-07-28
14
28
 
15
29
  _This version does not introduce any user-facing changes._
@@ -1 +1 @@
1
- {"version":3,"file":"AuthRequestHooks.js","sourceRoot":"","sources":["../src/AuthRequestHooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAwC,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAE1F,cAAc;AACd;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAAC,iBAAoC;IACnE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAA2B,IAAI,CAAC,CAAC;IAE3E,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,GAAG,IAAI,CAAC;QACrB,qBAAqB,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE;YAC1D,IAAI,SAAS,EAAE;gBACb,YAAY,CAAC,SAAS,CAAC,CAAC;aACzB;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,KAAK,CA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ourcesContent":["import { useCallback, useMemo, useEffect, useState } from 'react';\n\nimport { AuthRequest } from './AuthRequest';\nimport { AuthRequestConfig, AuthRequestPromptOptions } from './AuthRequest.types';\nimport { AuthSessionResult } from './AuthSession.types';\nimport { DiscoveryDocument, IssuerOrDiscovery, resolveDiscoveryAsync } from './Discovery';\n\n// @needsAudit\n/**\n * Given an OpenID Connect issuer URL, this will fetch and return the [`DiscoveryDocument`](#discoverydocument)\n * (a collection of URLs) from the resource provider.\n *\n * @param issuerOrDiscovery URL using the `https` scheme with no query or fragment component that the OP asserts as its Issuer Identifier.\n * @return Returns `null` until the [`DiscoveryDocument`](#discoverydocument) has been fetched from the provided issuer URL.\n *\n * @example\n * ```ts\n * const discovery = useAutoDiscovery('https://example.com/auth');\n * ```\n */\nexport function useAutoDiscovery(issuerOrDiscovery: IssuerOrDiscovery): DiscoveryDocument | null {\n const [discovery, setDiscovery] = useState<DiscoveryDocument | null>(null);\n\n useEffect(() => {\n let isAllowed = true;\n resolveDiscoveryAsync(issuerOrDiscovery).then((discovery) => {\n if (isAllowed) {\n setDiscovery(discovery);\n }\n });\n\n return () => {\n isAllowed = false;\n };\n }, [issuerOrDiscovery]);\n\n return discovery;\n}\n\nexport function useLoadedAuthRequest(\n config: AuthRequestConfig,\n discovery: DiscoveryDocument | null,\n AuthRequestInstance: typeof AuthRequest\n): AuthRequest | null {\n const [request, setRequest] = useState<AuthRequest | null>(null);\n const scopeString = useMemo(() => config.scopes?.join(','), [config.scopes]);\n const extraParamsString = useMemo(\n () => JSON.stringify(config.extraParams || {}),\n [config.extraParams]\n );\n useEffect(() => {\n let isMounted = true;\n\n if (discovery) {\n const request = new AuthRequestInstance(config);\n request.makeAuthUrlAsync(discovery).then(() => {\n if (isMounted) {\n setRequest(request);\n }\n });\n }\n return () => {\n isMounted = false;\n };\n }, [\n discovery?.authorizationEndpoint,\n config.clientId,\n config.redirectUri,\n config.responseType,\n config.prompt,\n config.clientSecret,\n config.codeChallenge,\n config.state,\n config.usePKCE,\n scopeString,\n extraParamsString,\n ]);\n return request;\n}\n\ntype PromptMethod = (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>;\n\nexport function useAuthRequestResult(\n request: AuthRequest | null,\n discovery: DiscoveryDocument | null,\n customOptions: AuthRequestPromptOptions = {}\n): [AuthSessionResult | null, PromptMethod] {\n const [result, setResult] = useState<AuthSessionResult | null>(null);\n\n const promptAsync = useCallback(\n async ({ windowFeatures = {}, ...options }: AuthRequestPromptOptions = {}) => {\n if (!discovery || !request) {\n throw new Error('Cannot prompt to authenticate until the request has finished loading.');\n }\n const inputOptions = {\n ...customOptions,\n ...options,\n windowFeatures: {\n ...(customOptions.windowFeatures ?? {}),\n ...windowFeatures,\n },\n };\n const result = await request?.promptAsync(discovery, inputOptions);\n setResult(result);\n return result;\n },\n [request?.url, discovery?.authorizationEndpoint]\n );\n\n return [result, promptAsync];\n}\n\n// @needsAudit\n/**\n * Load an authorization request for a code. When the prompt method completes then the response will be fulfilled.\n *\n * > In order to close the popup window on web, you need to invoke `WebBrowser.maybeCompleteAuthSession()`.\n * > See the [Identity example](/guides/authentication#identityserver-4) for more info.\n *\n * If an Implicit grant flow was used, you can pass the `response.params` to `TokenResponse.fromQueryParams()`\n * to get a `TokenResponse` instance which you can use to easily refresh the token.\n *\n * @param config A valid [`AuthRequestConfig`](#authrequestconfig) that specifies what provider to use.\n * @param discovery A loaded [`DiscoveryDocument`](#discoverydocument) with endpoints used for authenticating.\n * Only `authorizationEndpoint` is required for requesting an authorization code.\n *\n * @return Returns a loaded request, a response, and a prompt method in a single array in the following order:\n * - `request` - An instance of [`AuthRequest`](#authrequest) that can be used to prompt the user for authorization.\n * This will be `null` until the auth request has finished loading.\n * - `response` - This is `null` until `promptAsync` has been invoked. Once fulfilled it will return information about the authorization.\n * - `promptAsync` - When invoked, a web browser will open up and prompt the user for authentication.\n * Accepts an [`AuthRequestPromptOptions`](#authrequestpromptoptions) object with options about how the prompt will execute.\n *\n * @example\n * ```ts\n * const [request, response, promptAsync] = useAuthRequest({ ... }, { ... });\n * ```\n */\nexport function useAuthRequest(\n config: AuthRequestConfig,\n discovery: DiscoveryDocument | null\n): [\n AuthRequest | null,\n AuthSessionResult | null,\n (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>\n] {\n const request = useLoadedAuthRequest(config, discovery, AuthRequest);\n const [result, promptAsync] = useAuthRequestResult(request, discovery);\n return [request, result, promptAsync];\n}\n"]}
1
+ {"version":3,"file":"AuthRequestHooks.js","sourceRoot":"","sources":["../src/AuthRequestHooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,OAAO,EAAE,SAAS,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAElE,OAAO,EAAE,WAAW,EAAE,MAAM,eAAe,CAAC;AAG5C,OAAO,EAAwC,qBAAqB,EAAE,MAAM,aAAa,CAAC;AAE1F,cAAc;AACd;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,gBAAgB,CAAC,iBAAoC;IACnE,MAAM,CAAC,SAAS,EAAE,YAAY,CAAC,GAAG,QAAQ,CAA2B,IAAI,CAAC,CAAC;IAE3E,SAAS,CAAC,GAAG,EAAE;QACb,IAAI,SAAS,GAAG,IAAI,CAAC;QACrB,qBAAqB,CAAC,iBAAiB,CAAC,CAAC,IAAI,CAAC,CAAC,SAAS,EAAE,EAAE;YAC1D,IAAI,SAAS,EAAE;gBACb,YAAY,CAAC,SAAS,CAAC,CAAC;aACzB;QACH,CAAC,CAAC,CAAC;QAEH,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,KAAK,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE,CAAC,iBAAiB,CAAC,CAAC,CAAC;IAExB,OAAO,SAAS,CAAC;AACnB,CAAC;AAED,MAAM,UAAU,oBAAoB,CAClC,MAAyB,EACzB,SAAmC,EACnC,mBAAuC;IAEvC,MAAM,CAAC,OAAO,EAAE,UAAU,CAAC,GAAG,QAAQ,CAAqB,IAAI,CAAC,CA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AAE,cAAc,GAAG,EAAE,EAAE,GAAG,OAAO,KAA+B,EAAE,EAAE,EAAE;QAC3E,IAAI,CAAC,SAAS,IAAI,CAAC,OAAO,EAAE;YAC1B,MAAM,IAAI,KAAK,CAAC,uEAAuE,CAAC,CAAC;SAC1F;QACD,MAAM,YAAY,GAAG;YACnB,GAAG,aAAa;YAChB,GAAG,OAAO;YACV,cAAc,EAAE;gBACd,GAAG,CAAC,aAAa,CAAC,cAAc,IAAI,EAAE,CAAC;gBACvC,GAAG,cAAc;aAClB;SACF,CAAC;QACF,MAAM,MAAM,GAAG,MAAM,OAAO,EAAE,WAAW,CAAC,SAAS,EAAE,YAAY,CAAC,CAAC;QACnE,SAAS,CAAC,MAAM,CAAC,CAAC;QAClB,OAAO,MAAM,CAAC;IAChB,CAAC,EACD,CAAC,OAAO,EAAE,GAAG,EAAE,SAAS,EAAE,qBAAqB,CAAC,CACjD,CAAC;IAEF,OAAO,CAAC,MAAM,EAAE,WAAW,CAAC,CAAC;AAC/B,CAAC;AAED,cAAc;AACd;;;;;;;;;;;;;;;;;;;;;;;;GAwBG;AACH,MAAM,UAAU,cAAc,CAC5B,MAAyB,EACzB,SAAmC;IAMnC,MAAM,OAAO,GAAG,oBAAoB,CAAC,MAAM,EAAE,SAAS,EAAE,WAAW,CAAC,CAAC;IACrE,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,oBAAoB,CAAC,OAAO,EAAE,SAAS,CAAC,CAAC;IACvE,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import { useCallback, useMemo, useEffect, useState } from 'react';\n\nimport { AuthRequest } from './AuthRequest';\nimport { AuthRequestConfig, AuthRequestPromptOptions } from './AuthRequest.types';\nimport { AuthSessionResult } from './AuthSession.types';\nimport { DiscoveryDocument, IssuerOrDiscovery, resolveDiscoveryAsync } from './Discovery';\n\n// @needsAudit\n/**\n * Given an OpenID Connect issuer URL, this will fetch and return the [`DiscoveryDocument`](#discoverydocument)\n * (a collection of URLs) from the resource provider.\n *\n * @param issuerOrDiscovery URL using the `https` scheme with no query or fragment component that the OP asserts as its Issuer Identifier.\n * @return Returns `null` until the [`DiscoveryDocument`](#discoverydocument) has been fetched from the provided issuer URL.\n *\n * @example\n * ```ts\n * const discovery = useAutoDiscovery('https://example.com/auth');\n * ```\n */\nexport function useAutoDiscovery(issuerOrDiscovery: IssuerOrDiscovery): DiscoveryDocument | null {\n const [discovery, setDiscovery] = useState<DiscoveryDocument | null>(null);\n\n useEffect(() => {\n let isAllowed = true;\n resolveDiscoveryAsync(issuerOrDiscovery).then((discovery) => {\n if (isAllowed) {\n setDiscovery(discovery);\n }\n });\n\n return () => {\n isAllowed = false;\n };\n }, [issuerOrDiscovery]);\n\n return discovery;\n}\n\nexport function useLoadedAuthRequest(\n config: AuthRequestConfig,\n discovery: DiscoveryDocument | null,\n AuthRequestInstance: typeof AuthRequest\n): AuthRequest | null {\n const [request, setRequest] = useState<AuthRequest | null>(null);\n const scopeString = useMemo(() => config.scopes?.join(','), [config.scopes]);\n const extraParamsString = useMemo(\n () => JSON.stringify(config.extraParams || {}),\n [config.extraParams]\n );\n useEffect(() => {\n let isMounted = true;\n\n if (discovery) {\n const request = new AuthRequestInstance(config);\n request.makeAuthUrlAsync(discovery).then(() => {\n if (isMounted) {\n setRequest(request);\n }\n });\n }\n return () => {\n isMounted = false;\n };\n }, [\n discovery?.authorizationEndpoint,\n config.clientId,\n config.redirectUri,\n config.responseType,\n config.prompt,\n config.clientSecret,\n config.codeChallenge,\n config.state,\n config.usePKCE,\n scopeString,\n extraParamsString,\n ]);\n return request;\n}\n\ntype PromptMethod = (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>;\n\nexport function useAuthRequestResult(\n request: AuthRequest | null,\n discovery: DiscoveryDocument | null,\n customOptions: AuthRequestPromptOptions = {}\n): [AuthSessionResult | null, PromptMethod] {\n const [result, setResult] = useState<AuthSessionResult | null>(null);\n\n const promptAsync = useCallback(\n async ({ windowFeatures = {}, ...options }: AuthRequestPromptOptions = {}) => {\n if (!discovery || !request) {\n throw new Error('Cannot prompt to authenticate until the request has finished loading.');\n }\n const inputOptions = {\n ...customOptions,\n ...options,\n windowFeatures: {\n ...(customOptions.windowFeatures ?? {}),\n ...windowFeatures,\n },\n };\n const result = await request?.promptAsync(discovery, inputOptions);\n setResult(result);\n return result;\n },\n [request?.url, discovery?.authorizationEndpoint]\n );\n\n return [result, promptAsync];\n}\n\n// @needsAudit\n/**\n * Load an authorization request for a code. When the prompt method completes then the response will be fulfilled.\n *\n * > In order to close the popup window on web, you need to invoke `WebBrowser.maybeCompleteAuthSession()`.\n * > See the [Identity example](/guides/authentication#identityserver-4) for more info.\n *\n * If an Implicit grant flow was used, you can pass the `response.params` to `TokenResponse.fromQueryParams()`\n * to get a `TokenResponse` instance which you can use to easily refresh the token.\n *\n * @param config A valid [`AuthRequestConfig`](#authrequestconfig) that specifies what provider to use.\n * @param discovery A loaded [`DiscoveryDocument`](#discoverydocument) with endpoints used for authenticating.\n * Only `authorizationEndpoint` is required for requesting an authorization code.\n *\n * @return Returns a loaded request, a response, and a prompt method in a single array in the following order:\n * - `request` - An instance of [`AuthRequest`](#authrequest) that can be used to prompt the user for authorization.\n * This will be `null` until the auth request has finished loading.\n * - `response` - This is `null` until `promptAsync` has been invoked. Once fulfilled it will return information about the authorization.\n * - `promptAsync` - When invoked, a web browser will open up and prompt the user for authentication.\n * Accepts an [`AuthRequestPromptOptions`](#authrequestpromptoptions) object with options about how the prompt will execute.\n *\n * @example\n * ```ts\n * const [request, response, promptAsync] = useAuthRequest({ ... }, { ... });\n * ```\n */\nexport function useAuthRequest(\n config: AuthRequestConfig,\n discovery: DiscoveryDocument | null\n): [\n AuthRequest | null,\n AuthSessionResult | null,\n (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>,\n] {\n const request = useLoadedAuthRequest(config, discovery, AuthRequest);\n const [result, promptAsync] = useAuthRequestResult(request, discovery);\n return [request, result, promptAsync];\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"SessionUrlProvider.d.ts","sourceRoot":"","sources":["../src/SessionUrlProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAIxC,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAA0B;IAC1D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAuB;IAE3D,mBAAmB,CACjB,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,aAAa,CAAC,GACtD,MAAM;IAeT,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM;IAahG,cAAc,CAAC,OAAO,EAAE;QAAE,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;IA8CnF,OAAO,CAAC,MAAM,CAAC,yBAAyB;IA4BxC,OAAO,CAAC,MAAM,CAAC,eAAe;IAQ9B,OAAO,CAAC,MAAM,CAAC,YAAY;IAI3B,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAGlC;;AAED,wBAAwC"}
1
+ {"version":3,"file":"SessionUrlProvider.d.ts","sourceRoot":"","sources":["../src/SessionUrlProvider.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AAIxC,qBAAa,kBAAkB;IAC7B,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,QAAQ,CAA0B;IAC1D,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,YAAY,CAAuB;IAE3D,mBAAmB,CACjB,OAAO,CAAC,EAAE,MAAM,EAChB,OAAO,CAAC,EAAE,IAAI,CAAC,OAAO,CAAC,gBAAgB,EAAE,aAAa,CAAC,GACtD,MAAM;IAeT,WAAW,CAAC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,mBAAmB,EAAE,MAAM,GAAG,SAAS,GAAG,MAAM;IAahG,cAAc,CAAC,OAAO,EAAE;QAAE,mBAAmB,CAAC,EAAE,MAAM,CAAC;QAAC,OAAO,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,MAAM;IA4CnF,OAAO,CAAC,MAAM,CAAC,yBAAyB;IA4BxC,OAAO,CAAC,MAAM,CAAC,eAAe;IAQ9B,OAAO,CAAC,MAAM,CAAC,YAAY;IAI3B,OAAO,CAAC,MAAM,CAAC,kBAAkB;CAGlC;;AAED,wBAAwC"}
@@ -39,9 +39,7 @@ export class SessionUrlProvider {
39
39
  return '';
40
40
  }
41
41
  }
42
- const legacyExpoProjectFullName = options.projectNameForProxy ||
43
- Constants.expoConfig?.originalFullName ||
44
- Constants.__unsafeNoWarnManifest?.originalFullName;
42
+ const legacyExpoProjectFullName = options.projectNameForProxy || Constants.expoConfig?.originalFullName;
45
43
  if (!legacyExpoProjectFullName) {
46
44
  let nextSteps = '';
47
45
  if (__DEV__) {
@@ -1 +1 @@
1
- {"version":3,"file":"SessionUrlProvider.js","sourceRoot":"","sources":["../src/SessionUrlProvider.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAgB,MAAM,IAAI,CAAC;AAElC,MAAM,OAAO,kBAAkB;IACrB,MAAM,CAAU,QAAQ,GAAG,sBAAsB,CAAC;IAClD,MAAM,CAAU,YAAY,GAAG,mBAAmB,CAAC;IAE3D,mBAAmB,CACjB,OAAgB,EAChB,OAAuD;QAEvD,MAAM,WAAW,GAAG,kBAAkB,CAAC,yBAAyB,EAAE,CAAC;QACnE,IAAI,IA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AAO,EAAE;YACZ,OAAO,SAAS,CAAC;SAClB;QAED,MAAM,QAAQ,GAAG,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI;YACF,OAAO,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;SAChC;QAAC,MAAM,GAAE;QAEV,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,GAAG;QACpC,IAAI,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;YAChC,OAAO,CAAC,IAAI,CACV,+HAA+H,GAAG,6TAA6T,CAChc,CAAC;SACH;IACH,CAAC;IAEO,MAAM,CAAC,YAAY,CAAC,GAAW;QACrC,OAAO,GAAG,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;IAClD,CAAC;IAEO,MAAM,CAAC,kBAAkB,CAAC,GAAW;QAC3C,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC;;AAGH,eAAe,IAAI,kBAAkB,EAAE,CAAC","sourcesContent":["import Constants, { ExecutionEnvironment } from 'expo-constants';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'expo-modules-core';\nimport qs, { ParsedQs } from 'qs';\n\nexport class SessionUrlProvider {\n private static readonly BASE_URL = `https://auth.expo.io`;\n private static readonly SESSION_PATH = 'expo-auth-session';\n\n getDefaultReturnUrl(\n urlPath?: string,\n options?: Omit<Linking.CreateURLOptions, 'queryParams'>\n ): string {\n const queryParams = SessionUrlProvider.getHostAddressQueryParams();\n let path = SessionUrlProvider.SESSION_PATH;\n if (urlPath) {\n path = [path, SessionUrlProvider.removeLeadingSlash(urlPath)].filter(Boolean).join('/');\n }\n\n return Linking.createURL(path, {\n // The redirect URL doesn't matter for the proxy as long as it's valid, so silence warnings if needed.\n scheme: options?.scheme ?? Linking.resolveScheme({ isSilent: true }),\n queryParams,\n isTripleSlashed: options?.isTripleSlashed,\n });\n }\n\n getStartUrl(authUrl: string, returnUrl: string, projectNameForProxy: string | undefined): string {\n if (Platform.OS === 'web' && !Platform.isDOMAvailable) {\n // Return nothing in SSR envs\n return '';\n }\n const queryString = qs.stringify({\n authUrl,\n returnUrl,\n });\n\n return `${this.getRedirectUrl({ projectNameForProxy })}/start?${queryString}`;\n }\n\n getRedirectUrl(options: { projectNameForProxy?: string; urlPath?: string }): string {\n if (Platform.OS === 'web') {\n if (Platform.isDOMAvailable) {\n return [window.location.origin, options.urlPath].filter(Boolean).join('/');\n } else {\n // Return nothing in SSR envs\n return '';\n }\n }\n\n const legacyExpoProjectFullName =\n options.projectNameForProxy ||\n Constants.expoConfig?.originalFullName ||\n Constants.__unsafeNoWarnManifest?.originalFullName;\n\n if (!legacyExpoProjectFullName) {\n let nextSteps = '';\n if (__DEV__) {\n if (Constants.executionEnvironment === ExecutionEnvironment.Bare) {\n nextSteps =\n ' Please ensure you have the latest version of expo-constants installed and rebuild your native app. You can verify that originalFullName is defined by running `expo config --type public` and inspecting the output.';\n } else if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {\n nextSteps =\n ' Please report this as a bug with the contents of `expo config --type public`.';\n }\n }\n\n if (Constants.manifest2) {\n nextSteps =\n ' Prefer AuthRequest in combination with an Expo Development Client build of your application.' +\n ' To continue using the AuthSession proxy, specify the project full name (@owner/slug) using the projectNameForProxy option.';\n }\n\n throw new Error(\n 'Cannot use the AuthSession proxy because the project full name is not defined.' + nextSteps\n );\n }\n\n const redirectUrl = `${SessionUrlProvider.BASE_URL}/${legacyExpoProjectFullName}`;\n if (__DEV__) {\n SessionUrlProvider.warnIfAnonymous(legacyExpoProjectFullName, redirectUrl);\n // TODO: Verify with the dev server that the manifest is up to date.\n }\n return redirectUrl;\n }\n\n private static getHostAddressQueryParams(): ParsedQs | undefined {\n let hostUri: string | undefined = Constants.expoConfig?.hostUri;\n if (\n !hostUri &&\n (ExecutionEnvironment.StoreClient === Constants.executionEnvironment ||\n Linking.resolveScheme({}))\n ) {\n if (!Constants.linkingUri) {\n hostUri = '';\n } else {\n // we're probably not using up-to-date xdl, so just fake it for now\n // we have to remove the /--/ on the end since this will be inserted again later\n hostUri = SessionUrlProvider.removeScheme(Constants.linkingUri).replace(/\\/--(\\/.*)?$/, '');\n }\n }\n\n if (!hostUri) {\n return undefined;\n }\n\n const uriParts = hostUri?.split('?');\n try {\n return qs.parse(uriParts?.[1]);\n } catch {}\n\n return undefined;\n }\n\n private static warnIfAnonymous(id, url): void {\n if (id.startsWith('@anonymous/')) {\n console.warn(\n `You are not currently signed in to Expo on your development machine. As a result, the redirect URL for AuthSession will be \"${url}\". If you are using an OAuth provider that requires adding redirect URLs to an allow list, we recommend that you do not add this URL -- instead, you should sign in to Expo to acquire a unique redirect URL. Additionally, if you do decide to publish this app using Expo, you will need to register an account to do it.`\n );\n }\n }\n\n private static removeScheme(url: string) {\n return url.replace(/^[a-zA-Z0-9+.-]+:\\/\\//, '');\n }\n\n private static removeLeadingSlash(url: string) {\n return url.replace(/^\\//, '');\n }\n}\n\nexport default new SessionUrlProvider();\n"]}
1
+ {"version":3,"file":"SessionUrlProvider.js","sourceRoot":"","sources":["../src/SessionUrlProvider.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,EAAE,EAAE,oBAAoB,EAAE,MAAM,gBAAgB,CAAC;AACjE,OAAO,KAAK,OAAO,MAAM,cAAc,CAAC;AACxC,OAAO,EAAE,QAAQ,EAAE,MAAM,mBAAmB,CAAC;AAC7C,OAAO,EAAgB,MAAM,IAAI,CAAC;AAElC,MAAM,OAAO,kBAAkB;IACrB,MAAM,CAAU,QAAQ,GAAG,sBAAsB,CAAC;IAClD,MAAM,CAAU,YAAY,GAAG,mBAAmB,CAAC;IAE3D,mBAAmB,CACjB,OAAgB,EAChB,OAAuD;QAEvD,MAAM,WAAW,GAAG,kBAAkB,CAAC,yBAAyB,EAAE,CAAC;QACnE,IAAI,IAAI,GAAG,kBAA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,GAAG,OAAO,EAAE,KAAK,CAAC,GAAG,CAAC,CAAC;QACrC,IAAI;YACF,OAAO,EAAE,CAAC,KAAK,CAAC,QAAQ,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC;SAChC;QAAC,MAAM,GAAE;QAEV,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,MAAM,CAAC,eAAe,CAAC,EAAE,EAAE,GAAG;QACpC,IAAI,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE;YAChC,OAAO,CAAC,IAAI,CACV,+HAA+H,GAAG,6TAA6T,CAChc,CAAC;SACH;IACH,CAAC;IAEO,MAAM,CAAC,YAAY,CAAC,GAAW;QACrC,OAAO,GAAG,CAAC,OAAO,CAAC,uBAAuB,EAAE,EAAE,CAAC,CAAC;IAClD,CAAC;IAEO,MAAM,CAAC,kBAAkB,CAAC,GAAW;QAC3C,OAAO,GAAG,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAChC,CAAC;;AAGH,eAAe,IAAI,kBAAkB,EAAE,CAAC","sourcesContent":["import Constants, { ExecutionEnvironment } from 'expo-constants';\nimport * as Linking from 'expo-linking';\nimport { Platform } from 'expo-modules-core';\nimport qs, { ParsedQs } from 'qs';\n\nexport class SessionUrlProvider {\n private static readonly BASE_URL = `https://auth.expo.io`;\n private static readonly SESSION_PATH = 'expo-auth-session';\n\n getDefaultReturnUrl(\n urlPath?: string,\n options?: Omit<Linking.CreateURLOptions, 'queryParams'>\n ): string {\n const queryParams = SessionUrlProvider.getHostAddressQueryParams();\n let path = SessionUrlProvider.SESSION_PATH;\n if (urlPath) {\n path = [path, SessionUrlProvider.removeLeadingSlash(urlPath)].filter(Boolean).join('/');\n }\n\n return Linking.createURL(path, {\n // The redirect URL doesn't matter for the proxy as long as it's valid, so silence warnings if needed.\n scheme: options?.scheme ?? Linking.resolveScheme({ isSilent: true }),\n queryParams,\n isTripleSlashed: options?.isTripleSlashed,\n });\n }\n\n getStartUrl(authUrl: string, returnUrl: string, projectNameForProxy: string | undefined): string {\n if (Platform.OS === 'web' && !Platform.isDOMAvailable) {\n // Return nothing in SSR envs\n return '';\n }\n const queryString = qs.stringify({\n authUrl,\n returnUrl,\n });\n\n return `${this.getRedirectUrl({ projectNameForProxy })}/start?${queryString}`;\n }\n\n getRedirectUrl(options: { projectNameForProxy?: string; urlPath?: string }): string {\n if (Platform.OS === 'web') {\n if (Platform.isDOMAvailable) {\n return [window.location.origin, options.urlPath].filter(Boolean).join('/');\n } else {\n // Return nothing in SSR envs\n return '';\n }\n }\n\n const legacyExpoProjectFullName =\n options.projectNameForProxy || Constants.expoConfig?.originalFullName;\n\n if (!legacyExpoProjectFullName) {\n let nextSteps = '';\n if (__DEV__) {\n if (Constants.executionEnvironment === ExecutionEnvironment.Bare) {\n nextSteps =\n ' Please ensure you have the latest version of expo-constants installed and rebuild your native app. You can verify that originalFullName is defined by running `expo config --type public` and inspecting the output.';\n } else if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {\n nextSteps =\n ' Please report this as a bug with the contents of `expo config --type public`.';\n }\n }\n\n if (Constants.manifest2) {\n nextSteps =\n ' Prefer AuthRequest in combination with an Expo Development Client build of your application.' +\n ' To continue using the AuthSession proxy, specify the project full name (@owner/slug) using the projectNameForProxy option.';\n }\n\n throw new Error(\n 'Cannot use the AuthSession proxy because the project full name is not defined.' + nextSteps\n );\n }\n\n const redirectUrl = `${SessionUrlProvider.BASE_URL}/${legacyExpoProjectFullName}`;\n if (__DEV__) {\n SessionUrlProvider.warnIfAnonymous(legacyExpoProjectFullName, redirectUrl);\n // TODO: Verify with the dev server that the manifest is up to date.\n }\n return redirectUrl;\n }\n\n private static getHostAddressQueryParams(): ParsedQs | undefined {\n let hostUri: string | undefined = Constants.expoConfig?.hostUri;\n if (\n !hostUri &&\n (ExecutionEnvironment.StoreClient === Constants.executionEnvironment ||\n Linking.resolveScheme({}))\n ) {\n if (!Constants.linkingUri) {\n hostUri = '';\n } else {\n // we're probably not using up-to-date xdl, so just fake it for now\n // we have to remove the /--/ on the end since this will be inserted again later\n hostUri = SessionUrlProvider.removeScheme(Constants.linkingUri).replace(/\\/--(\\/.*)?$/, '');\n }\n }\n\n if (!hostUri) {\n return undefined;\n }\n\n const uriParts = hostUri?.split('?');\n try {\n return qs.parse(uriParts?.[1]);\n } catch {}\n\n return undefined;\n }\n\n private static warnIfAnonymous(id, url): void {\n if (id.startsWith('@anonymous/')) {\n console.warn(\n `You are not currently signed in to Expo on your development machine. As a result, the redirect URL for AuthSession will be \"${url}\". If you are using an OAuth provider that requires adding redirect URLs to an allow list, we recommend that you do not add this URL -- instead, you should sign in to Expo to acquire a unique redirect URL. Additionally, if you do decide to publish this app using Expo, you will need to register an account to do it.`\n );\n }\n }\n\n private static removeScheme(url: string) {\n return url.replace(/^[a-zA-Z0-9+.-]+:\\/\\//, '');\n }\n\n private static removeLeadingSlash(url: string) {\n return url.replace(/^\\//, '');\n }\n}\n\nexport default new SessionUrlProvider();\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"TokenRequest.d.ts","sourceRoot":"","sources":["../src/TokenRequest.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,aAAa,MAAM,aAAa,CAAC;AAE7C,OAAO,EAAE,OAAO,EAAgB,MAAM,SAAS,CAAC;AAChD,OAAO,EACL,wBAAwB,EACxB,SAAS,EACT,yBAAyB,EACzB,wBAAwB,EAExB,kBAAkB,EAClB,mBAAmB,EACnB,SAAS,EACT,aAAa,EACd,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,wBAAgB,uBAAuB,IAAI,MAAM,CAEhD;AAED;;;;GAIG;AACH,qBAAa,aAAc,YAAW,mBAAmB;IACvD;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CACjB,KAAK,EAAE,IAAI,CAAC,aAAa,EAAE,WAAW,GAAG,UAAU,CAAC;IACpD;;OAEG;IACH,aAAa,GAAE,MAAqB,GACnC,OAAO;IAWV;;;;OAIG;IACH,MAAM,CAAC,eAAe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B,MAAgC,EAChC,SAAiE;IAEjE,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC/C,OAAO,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;AACzC,CAAC;AAED,cAAc;AACd;;;;;;;;;;;GAWG;AACH,MAAM,UAAU,YAAY,CAC1B,MAAiC,EACjC,SAAiE;IAEjE,MAAM,OAAO,GAAG,IAAI,mBAAmB,CAAC,MAAM,CAAC,CAAC;IAChD,OAAO,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;AACzC,CAAC;AAED,cAAc;AACd;;;;;;GAMG;AACH,MAAM,UAAU,WAAW,CACzB,MAAgC,EAChC,SAAsE;IAEtE,MAAM,OAAO,GAAG,IAAI,kBAAkB,CAAC,MAAM,CAAC,CAAC;IAC/C,OAAO,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAA0C,EAC1C,SAAoE;IAEpE,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,4EAA4E,CAAC,CAAC;KAC/F;IACD,OAAO,YAAY,CAAsB,SAAS,CAAC,gBAAgB,EAAE;QACnE,OAAO,EAAE;YACP,cAAc,EAAE,mCAAmC;YACnD,aAAa,EAAE,UAAU,MAAM,CAAC,WAAW,EAAE;SAC9C;QACD,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,KAAK;KACd,CAAC,CAAC;AACL,CAAC","sourcesContent":["import invariant from 'invariant';\nimport { Platform } from 'react-native';\n\nimport * as Base64 from './Base64';\nimport * as ServiceConfig from './Discovery';\nimport { ResponseErrorConfig, TokenError } from './Errors';\nimport { Headers, requestAsync } from './Fetch';\nimport {\n AccessTokenRequestConfig,\n GrantType,\n RefreshTokenRequestConfig,\n RevokeTokenRequestConfig,\n ServerTokenResponseConfig,\n TokenRequestConfig,\n TokenResponseConfig,\n TokenType,\n TokenTypeHint,\n} from './TokenRequest.types';\n\n/**\n * Returns the current time in seconds.\n */\nexport function getCurrentTimeInSeconds(): number {\n return Math.floor(Date.now() / 1000);\n}\n\n/**\n * Token Response.\n *\n * [Section 5.1](https://tools.ietf.org/html/rfc6749#section-5.1)\n */\nexport class TokenResponse implements TokenResponseConfig {\n /**\n * Determines whether a token refresh request must be made to refresh the tokens\n *\n * @param token\n * @param secondsMargin\n */\n static isTokenFresh(\n token: Pick<TokenResponse, 'expiresIn' | 'issuedAt'>,\n /**\n * -10 minutes in seconds\n */\n secondsMargin: number = 60 * 10 * -1\n ): boolean {\n if (!token) {\n return false;\n }\n if (token.expiresIn) {\n const now = getCurrentTimeInSeconds();\n return now < token.issuedAt + token.expiresIn + secondsMargin;\n }\n // if there is no expiration time but we have an access token, it is assumed to never expire\n return true;\n }\n /**\n * Creates a `TokenResponse` from query parameters returned from an `AuthRequest`.\n *\n * @param params\n */\n static fromQueryParams(params: Record<string, any>): TokenResponse {\n return new TokenResponse({\n accessToken: params.access_token,\n refreshToken: params.refresh_token,\n scope: params.scope,\n state: params.state,\n idToken: params.id_token,\n tokenType: params.token_type,\n expiresIn: params.expires_in,\n issuedAt: params.issued_at,\n });\n }\n\n accessToken: string;\n tokenType: TokenType;\n expiresIn?: number;\n refreshToken?: string;\n scope?: string;\n state?: string;\n idToken?: string;\n issuedAt: number;\n\n constructor(response: TokenResponseConfig) {\n this.accessToken = response.accessToken;\n this.tokenType = response.tokenType ?? 'bearer';\n this.expiresIn = response.expiresIn;\n this.refreshToken = response.refreshToken;\n this.scope = response.scope;\n this.state = response.state;\n this.idToken = response.idToken;\n this.issuedAt = response.issuedAt ?? getCurrentTimeInSeconds();\n }\n\n private applyResponseConfig(response: TokenResponseConfig) {\n this.accessToken = response.accessToken ?? this.accessToken;\n this.tokenType = response.tokenType ?? this.tokenType ?? 'bearer';\n this.expiresIn = response.expiresIn ?? this.expiresIn;\n this.refreshToken = response.refreshToken ?? this.refreshToken;\n this.scope = response.scope ?? this.scope;\n this.state = response.state ?? this.state;\n this.idToken = response.idToken ?? this.idToken;\n this.issuedAt = response.issuedAt ?? this.issuedAt ?? getCurrentTimeInSeconds();\n }\n\n getRequestConfig(): TokenResponseConfig {\n return {\n accessToken: this.accessToken,\n idToken: this.idToken,\n refreshToken: this.refreshToken,\n scope: this.scope,\n state: this.state,\n tokenType: this.tokenType,\n issuedAt: this.issuedAt,\n expiresIn: this.expiresIn,\n };\n }\n\n async refreshAsync(\n config: Omit<TokenRequestConfig, 'grantType' | 'refreshToken'>,\n discovery: Pick<ServiceConfig.DiscoveryDocument, 'tokenEndpoint'>\n ): Promise<TokenResponse> {\n const request = new RefreshTokenRequest({\n ...config,\n refreshToken: this.refreshToken,\n });\n const response = await request.performAsync(discovery);\n // Custom: reuse the refresh token if one wasn't returned\n response.refreshToken = response.refreshToken ?? this.refreshToken;\n const json = response.getRequestConfig();\n this.applyResponseConfig(json);\n return this;\n }\n\n shouldRefresh(): boolean {\n // no refresh token available and token has expired\n return !(TokenResponse.isTokenFresh(this) || !this.refreshToken);\n }\n}\n\nclass Request<T, B> {\n constructor(protected request: T) {}\n\n async performAsync(discovery: ServiceConfig.DiscoveryDocument): Promise<B> {\n throw new Error('performAsync must be extended');\n }\n\n getRequestConfig(): T {\n throw new Error('getRequestConfig must be extended');\n }\n\n getQueryBody(): Record<string, string> {\n throw new Error('getQueryBody must be extended');\n }\n}\n\n/**\n * A generic token request.\n */\nclass TokenRequest<T extends TokenRequestConfig> extends Request<T, TokenResponse> {\n readonly clientId: string;\n readonly clientSecret?: string;\n readonly scopes?: string[];\n readonly extraParams?: Record<string, string>;\n\n constructor(request, public grantType: GrantType) {\n super(request);\n this.clientId = request.clientId;\n this.clientSecret = request.clientSecret;\n this.extraParams = request.extraParams;\n this.scopes = request.scopes;\n }\n\n getHeaders(): Headers {\n const headers: Headers = { 'Content-Type': 'application/x-www-form-urlencoded' };\n if (typeof this.clientSecret !== 'undefined') {\n // If client secret exists, it should be converted to base64\n // https://tools.ietf.org/html/rfc6749#section-2.3.1\n const encodedClientId = encodeURIComponent(this.clientId);\n const encodedClientSecret = encodeURIComponent(this.clientSecret);\n const credentials = `${encodedClientId}:${encodedClientSecret}`;\n const basicAuth = Base64.encodeNoWrap(credentials);\n headers.Authorization = `Basic ${basicAuth}`;\n }\n\n return headers;\n }\n\n async performAsync(discovery: Pick<ServiceConfig.DiscoveryDocument, 'tokenEndpoint'>) {\n // redirect URI must not be nil\n invariant(\n discovery.tokenEndpoint,\n `Cannot invoke \\`performAsync()\\` without a valid tokenEndpoint`\n );\n const response = await requestAsync<ServerTokenResponseConfig | ResponseErrorConfig>(\n discovery.tokenEndpoint,\n {\n dataType: 'json',\n method: 'POST',\n headers: this.getHeaders(),\n body: this.getQueryBody(),\n }\n );\n\n if ('error' in response) {\n throw new TokenError(response);\n }\n\n return new TokenResponse({\n accessToken: response.access_token,\n tokenType: response.token_type,\n expiresIn: response.expires_in,\n refreshToken: response.refresh_token,\n scope: response.scope,\n idToken: response.id_token,\n issuedAt: response.issued_at,\n });\n }\n\n getQueryBody() {\n const queryBody: Record<string, string> = {\n grant_type: this.grantType,\n };\n\n if (!this.clientSecret) {\n // Only add the client ID if client secret is not present, otherwise pass the client id with the secret in the request body.\n queryBody.client_id = this.clientId;\n }\n\n if (this.scopes) {\n queryBody.scope = this.scopes.join(' ');\n }\n\n if (this.extraParams) {\n for (const extra in this.extraParams) {\n if (extra in this.extraParams && !(extra in queryBody)) {\n queryBody[extra] = this.extraParams[extra];\n }\n }\n }\n return queryBody;\n }\n}\n\n/**\n * Access token request. Exchange an authorization code for a user access token.\n *\n * [Section 4.1.3](https://tools.ietf.org/html/rfc6749#section-4.1.3)\n */\nexport class AccessTokenRequest\n extends TokenRequest<AccessTokenRequestConfig>\n implements AccessTokenRequestConfig\n{\n readonly code: string;\n readonly redirectUri: string;\n\n constructor(options: AccessTokenRequestConfig) {\n invariant(\n options.redirectUri,\n `\\`AccessTokenRequest\\` requires a valid \\`redirectUri\\` (it must also match the one used in the auth request). Example: ${Platform.select(\n {\n web: 'https://yourwebsite.com/redirect',\n default: 'myapp://redirect',\n }\n )}`\n );\n\n invariant(\n options.code,\n `\\`AccessTokenRequest\\` requires a valid authorization \\`code\\`. This is what's received from the authorization server after an auth request.`\n );\n super(options, GrantType.AuthorizationCode);\n this.code = options.code;\n this.redirectUri = options.redirectUri;\n }\n\n getQueryBody() {\n const queryBody: Record<string, string> = super.getQueryBody();\n\n if (this.redirectUri) {\n queryBody.redirect_uri = this.redirectUri;\n }\n\n if (this.code) {\n queryBody.code = this.code;\n }\n\n return queryBody;\n }\n\n getRequestConfig() {\n return {\n clientId: this.clientId,\n clientSecret: this.clientSecret,\n grantType: this.grantType,\n code: this.code,\n redirectUri: this.redirectUri,\n extraParams: this.extraParams,\n scopes: this.scopes,\n };\n }\n}\n\n/**\n * Refresh request.\n *\n * [Section 6](https://tools.ietf.org/html/rfc6749#section-6)\n */\nexport class RefreshTokenRequest\n extends TokenRequest<RefreshTokenRequestConfig>\n implements RefreshTokenRequestConfig\n{\n readonly refreshToken?: string;\n\n constructor(options: RefreshTokenRequestConfig) {\n invariant(options.refreshToken, `\\`RefreshTokenRequest\\` requires a valid \\`refreshToken\\`.`);\n super(options, GrantType.RefreshToken);\n this.refreshToken = options.refreshToken;\n }\n\n getQueryBody() {\n const queryBody = super.getQueryBody();\n\n if (this.refreshToken) {\n queryBody.refresh_token = this.refreshToken;\n }\n\n return queryBody;\n }\n\n getRequestConfig() {\n return {\n clientId: this.clientId,\n clientSecret: this.clientSecret,\n grantType: this.grantType,\n refreshToken: this.refreshToken,\n extraParams: this.extraParams,\n scopes: this.scopes,\n };\n }\n}\n\n/**\n * Revocation request for a given token.\n *\n * [Section 2.1](https://tools.ietf.org/html/rfc7009#section-2.1)\n */\nexport class RevokeTokenRequest\n extends Request<RevokeTokenRequestConfig, boolean>\n implements RevokeTokenRequestConfig\n{\n readonly clientId?: string;\n readonly clientSecret?: string;\n readonly token: string;\n readonly tokenTypeHint?: TokenTypeHint;\n\n constructor(request: RevokeTokenRequestConfig) {\n super(request);\n invariant(request.token, `\\`RevokeTokenRequest\\` requires a valid \\`token\\` to revoke.`);\n this.clientId = request.clientId;\n this.clientSecret = request.clientSecret;\n this.token = request.token;\n this.tokenTypeHint = request.tokenTypeHint;\n }\n\n getHeaders(): Headers {\n const headers: Headers = { 'Content-Type': 'application/x-www-form-urlencoded' };\n if (typeof this.clientSecret !== 'undefined' && this.clientId) {\n // If client secret exists, it should be converted to base64\n // https://tools.ietf.org/html/rfc6749#section-2.3.1\n const encodedClientId = encodeURIComponent(this.clientId);\n const encodedClientSecret = encodeURIComponent(this.clientSecret);\n const credentials = `${encodedClientId}:${encodedClientSecret}`;\n const basicAuth = Base64.encodeNoWrap(credentials);\n headers.Authorization = `Basic ${basicAuth}`;\n }\n\n return headers;\n }\n\n /**\n * Perform a token revocation request.\n *\n * @param discovery The `revocationEndpoint` for a provider.\n */\n async performAsync(discovery: Pick<ServiceConfig.DiscoveryDocument, 'revocationEndpoint'>) {\n invariant(\n discovery.revocationEndpoint,\n `Cannot invoke \\`performAsync()\\` without a valid revocationEndpoint`\n );\n await requestAsync<boolean>(discovery.revocationEndpoint, {\n method: 'POST',\n headers: this.getHeaders(),\n body: this.getQueryBody(),\n });\n\n return true;\n }\n\n getRequestConfig() {\n return {\n clientId: this.clientId,\n clientSecret: this.clientSecret,\n token: this.token,\n tokenTypeHint: this.tokenTypeHint,\n };\n }\n\n getQueryBody(): Record<string, string> {\n const queryBody: Record<string, string> = { token: this.token };\n if (this.tokenTypeHint) {\n queryBody.token_type_hint = this.tokenTypeHint;\n }\n // Include client creds https://tools.ietf.org/html/rfc6749#section-2.3.1\n if (this.clientId) {\n queryBody.client_id = this.clientId;\n }\n if (this.clientSecret) {\n queryBody.client_secret = this.clientSecret;\n }\n return queryBody;\n }\n}\n\n// @needsAudit\n/**\n * Exchange an authorization code for an access token that can be used to get data from the provider.\n *\n * @param config Configuration used to exchange the code for a token.\n * @param discovery The `tokenEndpoint` for a provider.\n * @return Returns a discovery document with a valid `tokenEndpoint` URL.\n */\nexport function exchangeCodeAsync(\n config: AccessTokenRequestConfig,\n discovery: Pick<ServiceConfig.DiscoveryDocument, 'tokenEndpoint'>\n): Promise<TokenResponse> {\n const request = new AccessTokenRequest(config);\n return request.performAsync(discovery);\n}\n\n// @needsAudit\n/**\n * Refresh an access token.\n * - If the provider didn't return a `refresh_token` then the access token may not be refreshed.\n * - If the provider didn't return a `expires_in` then it's assumed that the token does not expire.\n * - Determine if a token needs to be refreshed via `TokenResponse.isTokenFresh()` or `shouldRefresh()` on an instance of `TokenResponse`.\n *\n * @see [Section 6](https://tools.ietf.org/html/rfc6749#section-6).\n *\n * @param config Configuration used to refresh the given access token.\n * @param discovery The `tokenEndpoint` for a provider.\n * @return Returns a discovery document with a valid `tokenEndpoint` URL.\n */\nexport function refreshAsync(\n config: RefreshTokenRequestConfig,\n discovery: Pick<ServiceConfig.DiscoveryDocument, 'tokenEndpoint'>\n): Promise<TokenResponse> {\n const request = new RefreshTokenRequest(config);\n return request.performAsync(discovery);\n}\n\n// @needsAudit\n/**\n * Revoke a token with a provider. This makes the token unusable, effectively requiring the user to login again.\n *\n * @param config Configuration used to revoke a refresh or access token.\n * @param discovery The `revocationEndpoint` for a provider.\n * @return Returns a discovery document with a valid `revocationEndpoint` URL. Many providers do not support this feature.\n */\nexport function revokeAsync(\n config: RevokeTokenRequestConfig,\n discovery: Pick<ServiceConfig.DiscoveryDocument, 'revocationEndpoint'>\n): Promise<boolean> {\n const request = new RevokeTokenRequest(config);\n return request.performAsync(discovery);\n}\n\n/**\n * Fetch generic user info from the provider's OpenID Connect `userInfoEndpoint` (if supported).\n *\n * @see [UserInfo](https://openid.net/specs/openid-connect-core-1_0.html#UserInfo).\n *\n * @param config The `accessToken` for a user, returned from a code exchange or auth request.\n * @param discovery The `userInfoEndpoint` for a provider.\n */\nexport function fetchUserInfoAsync(\n config: Pick<TokenResponse, 'accessToken'>,\n discovery: Pick<ServiceConfig.DiscoveryDocument, 'userInfoEndpoint'>\n): Promise<Record<string, any>> {\n if (!discovery.userInfoEndpoint) {\n throw new Error('User info endpoint is not defined in the service config discovery document');\n }\n return requestAsync<Record<string, any>>(discovery.userInfoEndpoint, {\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n Authorization: `Bearer ${config.accessToken}`,\n },\n dataType: 'json',\n method: 'GET',\n });\n}\n"]}
1
+ {"version":3,"file":"TokenRequest.js","sourceRoot":"","sources":["../src/TokenRequest.ts"],"names":[],"mappings":"AAAA,OAAO,SAAS,MAAM,WAAW,CAAC;AAClC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,KAAK,MAAM,MAAM,UAAU,CAAC;AAEnC,OAAO,EAAuB,UAAU,EAAE,MAAM,UAAU,CAAC;AAC3D,OAAO,EAAW,YAAY,EAAE,MAAM,SAAS,CAAC;AAChD,OAAO,EAEL,SAAS,GAQV,MAAM,sBAAsB,CAAC;AAE9B;;GAEG;AACH,MAAM,UAAU,uBAAuB;IACrC,OAAO,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;AACvC,CAAC;AAED;;;;GAIG;AACH,MAAM,OAAO,aAAa;IACxB;;;;;OAKG;IACH,MAAM,CAAC,YAAY,CACjB,KAAoD;IACpD;;OAEG;IACH,gBAAwB,EAAE,GAAG,EAAE,GAAG,CAAC,CAAC;QAEpC,IAAI,CAAC,KAAK,EAAE;YACV,OAAO,KAAK,CAAC;SACd;QACD,IAAI,KAAK,CAAC,SAAS,EAAE;YACnB,MAAM,GAAG,GAAG,uBAAuB,EAAE,CAAC;YACtC,OAAO,GAAG,GAAG,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,SAAS,GAAG,aAAa,CAAC;SAC/D;QACD,4FAA4F;QAC5F,OAAO,IAAI,CAAC;IACd,CAAC;IACD;;;;OAIG;IACH,MA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AAO,OAAO,CAAC,YAAY,CAAC,SAAS,CAAC,CAAC;AACzC,CAAC;AAED;;;;;;;GAOG;AACH,MAAM,UAAU,kBAAkB,CAChC,MAA0C,EAC1C,SAAoE;IAEpE,IAAI,CAAC,SAAS,CAAC,gBAAgB,EAAE;QAC/B,MAAM,IAAI,KAAK,CAAC,4EAA4E,CAAC,CAAC;KAC/F;IACD,OAAO,YAAY,CAAsB,SAAS,CAAC,gBAAgB,EAAE;QACnE,OAAO,EAAE;YACP,cAAc,EAAE,mCAAmC;YACnD,aAAa,EAAE,UAAU,MAAM,CAAC,WAAW,EAAE;SAC9C;QACD,QAAQ,EAAE,MAAM;QAChB,MAAM,EAAE,KAAK;KACd,CAAC,CAAC;AACL,CAAC","sourcesContent":["import invariant from 'invariant';\nimport { Platform } from 'react-native';\n\nimport * as Base64 from './Base64';\nimport * as ServiceConfig from './Discovery';\nimport { ResponseErrorConfig, TokenError } from './Errors';\nimport { Headers, requestAsync } from './Fetch';\nimport {\n AccessTokenRequestConfig,\n GrantType,\n RefreshTokenRequestConfig,\n RevokeTokenRequestConfig,\n ServerTokenResponseConfig,\n TokenRequestConfig,\n TokenResponseConfig,\n TokenType,\n TokenTypeHint,\n} from './TokenRequest.types';\n\n/**\n * Returns the current time in seconds.\n */\nexport function getCurrentTimeInSeconds(): number {\n return Math.floor(Date.now() / 1000);\n}\n\n/**\n * Token Response.\n *\n * [Section 5.1](https://tools.ietf.org/html/rfc6749#section-5.1)\n */\nexport class TokenResponse implements TokenResponseConfig {\n /**\n * Determines whether a token refresh request must be made to refresh the tokens\n *\n * @param token\n * @param secondsMargin\n */\n static isTokenFresh(\n token: Pick<TokenResponse, 'expiresIn' | 'issuedAt'>,\n /**\n * -10 minutes in seconds\n */\n secondsMargin: number = 60 * 10 * -1\n ): boolean {\n if (!token) {\n return false;\n }\n if (token.expiresIn) {\n const now = getCurrentTimeInSeconds();\n return now < token.issuedAt + token.expiresIn + secondsMargin;\n }\n // if there is no expiration time but we have an access token, it is assumed to never expire\n return true;\n }\n /**\n * Creates a `TokenResponse` from query parameters returned from an `AuthRequest`.\n *\n * @param params\n */\n static fromQueryParams(params: Record<string, any>): TokenResponse {\n return new TokenResponse({\n accessToken: params.access_token,\n refreshToken: params.refresh_token,\n scope: params.scope,\n state: params.state,\n idToken: params.id_token,\n tokenType: params.token_type,\n expiresIn: params.expires_in,\n issuedAt: params.issued_at,\n });\n }\n\n accessToken: string;\n tokenType: TokenType;\n expiresIn?: number;\n refreshToken?: string;\n scope?: string;\n state?: string;\n idToken?: string;\n issuedAt: number;\n\n constructor(response: TokenResponseConfig) {\n this.accessToken = response.accessToken;\n this.tokenType = response.tokenType ?? 'bearer';\n this.expiresIn = response.expiresIn;\n this.refreshToken = response.refreshToken;\n this.scope = response.scope;\n this.state = response.state;\n this.idToken = response.idToken;\n this.issuedAt = response.issuedAt ?? getCurrentTimeInSeconds();\n }\n\n private applyResponseConfig(response: TokenResponseConfig) {\n this.accessToken = response.accessToken ?? this.accessToken;\n this.tokenType = response.tokenType ?? this.tokenType ?? 'bearer';\n this.expiresIn = response.expiresIn ?? this.expiresIn;\n this.refreshToken = response.refreshToken ?? this.refreshToken;\n this.scope = response.scope ?? this.scope;\n this.state = response.state ?? this.state;\n this.idToken = response.idToken ?? this.idToken;\n this.issuedAt = response.issuedAt ?? this.issuedAt ?? getCurrentTimeInSeconds();\n }\n\n getRequestConfig(): TokenResponseConfig {\n return {\n accessToken: this.accessToken,\n idToken: this.idToken,\n refreshToken: this.refreshToken,\n scope: this.scope,\n state: this.state,\n tokenType: this.tokenType,\n issuedAt: this.issuedAt,\n expiresIn: this.expiresIn,\n };\n }\n\n async refreshAsync(\n config: Omit<TokenRequestConfig, 'grantType' | 'refreshToken'>,\n discovery: Pick<ServiceConfig.DiscoveryDocument, 'tokenEndpoint'>\n ): Promise<TokenResponse> {\n const request = new RefreshTokenRequest({\n ...config,\n refreshToken: this.refreshToken,\n });\n const response = await request.performAsync(discovery);\n // Custom: reuse the refresh token if one wasn't returned\n response.refreshToken = response.refreshToken ?? this.refreshToken;\n const json = response.getRequestConfig();\n this.applyResponseConfig(json);\n return this;\n }\n\n shouldRefresh(): boolean {\n // no refresh token available and token has expired\n return !(TokenResponse.isTokenFresh(this) || !this.refreshToken);\n }\n}\n\nclass Request<T, B> {\n constructor(protected request: T) {}\n\n async performAsync(discovery: ServiceConfig.DiscoveryDocument): Promise<B> {\n throw new Error('performAsync must be extended');\n }\n\n getRequestConfig(): T {\n throw new Error('getRequestConfig must be extended');\n }\n\n getQueryBody(): Record<string, string> {\n throw new Error('getQueryBody must be extended');\n }\n}\n\n/**\n * A generic token request.\n */\nclass TokenRequest<T extends TokenRequestConfig> extends Request<T, TokenResponse> {\n readonly clientId: string;\n readonly clientSecret?: string;\n readonly scopes?: string[];\n readonly extraParams?: Record<string, string>;\n\n constructor(\n request,\n public grantType: GrantType\n ) {\n super(request);\n this.clientId = request.clientId;\n this.clientSecret = request.clientSecret;\n this.extraParams = request.extraParams;\n this.scopes = request.scopes;\n }\n\n getHeaders(): Headers {\n const headers: Headers = { 'Content-Type': 'application/x-www-form-urlencoded' };\n if (typeof this.clientSecret !== 'undefined') {\n // If client secret exists, it should be converted to base64\n // https://tools.ietf.org/html/rfc6749#section-2.3.1\n const encodedClientId = encodeURIComponent(this.clientId);\n const encodedClientSecret = encodeURIComponent(this.clientSecret);\n const credentials = `${encodedClientId}:${encodedClientSecret}`;\n const basicAuth = Base64.encodeNoWrap(credentials);\n headers.Authorization = `Basic ${basicAuth}`;\n }\n\n return headers;\n }\n\n async performAsync(discovery: Pick<ServiceConfig.DiscoveryDocument, 'tokenEndpoint'>) {\n // redirect URI must not be nil\n invariant(\n discovery.tokenEndpoint,\n `Cannot invoke \\`performAsync()\\` without a valid tokenEndpoint`\n );\n const response = await requestAsync<ServerTokenResponseConfig | ResponseErrorConfig>(\n discovery.tokenEndpoint,\n {\n dataType: 'json',\n method: 'POST',\n headers: this.getHeaders(),\n body: this.getQueryBody(),\n }\n );\n\n if ('error' in response) {\n throw new TokenError(response);\n }\n\n return new TokenResponse({\n accessToken: response.access_token,\n tokenType: response.token_type,\n expiresIn: response.expires_in,\n refreshToken: response.refresh_token,\n scope: response.scope,\n idToken: response.id_token,\n issuedAt: response.issued_at,\n });\n }\n\n getQueryBody() {\n const queryBody: Record<string, string> = {\n grant_type: this.grantType,\n };\n\n if (!this.clientSecret) {\n // Only add the client ID if client secret is not present, otherwise pass the client id with the secret in the request body.\n queryBody.client_id = this.clientId;\n }\n\n if (this.scopes) {\n queryBody.scope = this.scopes.join(' ');\n }\n\n if (this.extraParams) {\n for (const extra in this.extraParams) {\n if (extra in this.extraParams && !(extra in queryBody)) {\n queryBody[extra] = this.extraParams[extra];\n }\n }\n }\n return queryBody;\n }\n}\n\n/**\n * Access token request. Exchange an authorization code for a user access token.\n *\n * [Section 4.1.3](https://tools.ietf.org/html/rfc6749#section-4.1.3)\n */\nexport class AccessTokenRequest\n extends TokenRequest<AccessTokenRequestConfig>\n implements AccessTokenRequestConfig\n{\n readonly code: string;\n readonly redirectUri: string;\n\n constructor(options: AccessTokenRequestConfig) {\n invariant(\n options.redirectUri,\n `\\`AccessTokenRequest\\` requires a valid \\`redirectUri\\` (it must also match the one used in the auth request). Example: ${Platform.select(\n {\n web: 'https://yourwebsite.com/redirect',\n default: 'myapp://redirect',\n }\n )}`\n );\n\n invariant(\n options.code,\n `\\`AccessTokenRequest\\` requires a valid authorization \\`code\\`. This is what's received from the authorization server after an auth request.`\n );\n super(options, GrantType.AuthorizationCode);\n this.code = options.code;\n this.redirectUri = options.redirectUri;\n }\n\n getQueryBody() {\n const queryBody: Record<string, string> = super.getQueryBody();\n\n if (this.redirectUri) {\n queryBody.redirect_uri = this.redirectUri;\n }\n\n if (this.code) {\n queryBody.code = this.code;\n }\n\n return queryBody;\n }\n\n getRequestConfig() {\n return {\n clientId: this.clientId,\n clientSecret: this.clientSecret,\n grantType: this.grantType,\n code: this.code,\n redirectUri: this.redirectUri,\n extraParams: this.extraParams,\n scopes: this.scopes,\n };\n }\n}\n\n/**\n * Refresh request.\n *\n * [Section 6](https://tools.ietf.org/html/rfc6749#section-6)\n */\nexport class RefreshTokenRequest\n extends TokenRequest<RefreshTokenRequestConfig>\n implements RefreshTokenRequestConfig\n{\n readonly refreshToken?: string;\n\n constructor(options: RefreshTokenRequestConfig) {\n invariant(options.refreshToken, `\\`RefreshTokenRequest\\` requires a valid \\`refreshToken\\`.`);\n super(options, GrantType.RefreshToken);\n this.refreshToken = options.refreshToken;\n }\n\n getQueryBody() {\n const queryBody = super.getQueryBody();\n\n if (this.refreshToken) {\n queryBody.refresh_token = this.refreshToken;\n }\n\n return queryBody;\n }\n\n getRequestConfig() {\n return {\n clientId: this.clientId,\n clientSecret: this.clientSecret,\n grantType: this.grantType,\n refreshToken: this.refreshToken,\n extraParams: this.extraParams,\n scopes: this.scopes,\n };\n }\n}\n\n/**\n * Revocation request for a given token.\n *\n * [Section 2.1](https://tools.ietf.org/html/rfc7009#section-2.1)\n */\nexport class RevokeTokenRequest\n extends Request<RevokeTokenRequestConfig, boolean>\n implements RevokeTokenRequestConfig\n{\n readonly clientId?: string;\n readonly clientSecret?: string;\n readonly token: string;\n readonly tokenTypeHint?: TokenTypeHint;\n\n constructor(request: RevokeTokenRequestConfig) {\n super(request);\n invariant(request.token, `\\`RevokeTokenRequest\\` requires a valid \\`token\\` to revoke.`);\n this.clientId = request.clientId;\n this.clientSecret = request.clientSecret;\n this.token = request.token;\n this.tokenTypeHint = request.tokenTypeHint;\n }\n\n getHeaders(): Headers {\n const headers: Headers = { 'Content-Type': 'application/x-www-form-urlencoded' };\n if (typeof this.clientSecret !== 'undefined' && this.clientId) {\n // If client secret exists, it should be converted to base64\n // https://tools.ietf.org/html/rfc6749#section-2.3.1\n const encodedClientId = encodeURIComponent(this.clientId);\n const encodedClientSecret = encodeURIComponent(this.clientSecret);\n const credentials = `${encodedClientId}:${encodedClientSecret}`;\n const basicAuth = Base64.encodeNoWrap(credentials);\n headers.Authorization = `Basic ${basicAuth}`;\n }\n\n return headers;\n }\n\n /**\n * Perform a token revocation request.\n *\n * @param discovery The `revocationEndpoint` for a provider.\n */\n async performAsync(discovery: Pick<ServiceConfig.DiscoveryDocument, 'revocationEndpoint'>) {\n invariant(\n discovery.revocationEndpoint,\n `Cannot invoke \\`performAsync()\\` without a valid revocationEndpoint`\n );\n await requestAsync<boolean>(discovery.revocationEndpoint, {\n method: 'POST',\n headers: this.getHeaders(),\n body: this.getQueryBody(),\n });\n\n return true;\n }\n\n getRequestConfig() {\n return {\n clientId: this.clientId,\n clientSecret: this.clientSecret,\n token: this.token,\n tokenTypeHint: this.tokenTypeHint,\n };\n }\n\n getQueryBody(): Record<string, string> {\n const queryBody: Record<string, string> = { token: this.token };\n if (this.tokenTypeHint) {\n queryBody.token_type_hint = this.tokenTypeHint;\n }\n // Include client creds https://tools.ietf.org/html/rfc6749#section-2.3.1\n if (this.clientId) {\n queryBody.client_id = this.clientId;\n }\n if (this.clientSecret) {\n queryBody.client_secret = this.clientSecret;\n }\n return queryBody;\n }\n}\n\n// @needsAudit\n/**\n * Exchange an authorization code for an access token that can be used to get data from the provider.\n *\n * @param config Configuration used to exchange the code for a token.\n * @param discovery The `tokenEndpoint` for a provider.\n * @return Returns a discovery document with a valid `tokenEndpoint` URL.\n */\nexport function exchangeCodeAsync(\n config: AccessTokenRequestConfig,\n discovery: Pick<ServiceConfig.DiscoveryDocument, 'tokenEndpoint'>\n): Promise<TokenResponse> {\n const request = new AccessTokenRequest(config);\n return request.performAsync(discovery);\n}\n\n// @needsAudit\n/**\n * Refresh an access token.\n * - If the provider didn't return a `refresh_token` then the access token may not be refreshed.\n * - If the provider didn't return a `expires_in` then it's assumed that the token does not expire.\n * - Determine if a token needs to be refreshed via `TokenResponse.isTokenFresh()` or `shouldRefresh()` on an instance of `TokenResponse`.\n *\n * @see [Section 6](https://tools.ietf.org/html/rfc6749#section-6).\n *\n * @param config Configuration used to refresh the given access token.\n * @param discovery The `tokenEndpoint` for a provider.\n * @return Returns a discovery document with a valid `tokenEndpoint` URL.\n */\nexport function refreshAsync(\n config: RefreshTokenRequestConfig,\n discovery: Pick<ServiceConfig.DiscoveryDocument, 'tokenEndpoint'>\n): Promise<TokenResponse> {\n const request = new RefreshTokenRequest(config);\n return request.performAsync(discovery);\n}\n\n// @needsAudit\n/**\n * Revoke a token with a provider. This makes the token unusable, effectively requiring the user to login again.\n *\n * @param config Configuration used to revoke a refresh or access token.\n * @param discovery The `revocationEndpoint` for a provider.\n * @return Returns a discovery document with a valid `revocationEndpoint` URL. Many providers do not support this feature.\n */\nexport function revokeAsync(\n config: RevokeTokenRequestConfig,\n discovery: Pick<ServiceConfig.DiscoveryDocument, 'revocationEndpoint'>\n): Promise<boolean> {\n const request = new RevokeTokenRequest(config);\n return request.performAsync(discovery);\n}\n\n/**\n * Fetch generic user info from the provider's OpenID Connect `userInfoEndpoint` (if supported).\n *\n * @see [UserInfo](https://openid.net/specs/openid-connect-core-1_0.html#UserInfo).\n *\n * @param config The `accessToken` for a user, returned from a code exchange or auth request.\n * @param discovery The `userInfoEndpoint` for a provider.\n */\nexport function fetchUserInfoAsync(\n config: Pick<TokenResponse, 'accessToken'>,\n discovery: Pick<ServiceConfig.DiscoveryDocument, 'userInfoEndpoint'>\n): Promise<Record<string, any>> {\n if (!discovery.userInfoEndpoint) {\n throw new Error('User info endpoint is not defined in the service config discovery document');\n }\n return requestAsync<Record<string, any>>(discovery.userInfoEndpoint, {\n headers: {\n 'Content-Type': 'application/x-www-form-urlencoded',\n Authorization: `Bearer ${config.accessToken}`,\n },\n dataType: 'json',\n method: 'GET',\n });\n}\n"]}
@@ -1,6 +1,6 @@
1
+ import { ProviderAuthRequestConfig } from './Provider.types';
1
2
  import { AuthRequestConfig } from '../AuthRequest.types';
2
3
  import { AuthRequest, AuthRequestPromptOptions, AuthSessionRedirectUriOptions, AuthSessionResult, DiscoveryDocument } from '../AuthSession';
3
- import { ProviderAuthRequestConfig } from './Provider.types';
4
4
  export declare const discovery: DiscoveryDocument;
5
5
  /**
6
6
  * @deprecated See [Facebook authentication](/guides/facebook-authentication/).
@@ -1 +1 @@
1
- {"version":3,"file":"Facebook.d.ts","sourceRoot":"","sources":["../../src/providers/Facebook.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EACL,WAAW,EACX,wBAAwB,EACxB,6BAA6B,EAC7B,iBAAiB,EACjB,iBAAiB,EAGlB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAS7D,eAAO,MAAM,SAAS,EAAE,iBAGvB,CAAC;AAGF;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,yBAAyB;IAC1E;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAGD;;GAEG;AACH,cAAM,mBAAoB,SAAQ,WAAW;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;gBAEH,EACV,QAAQ,EAER,WAAgB,EAChB,YAAY,EACZ,GAAG,MAAM,EACV,EAAE,yBAAyB;IA6B5B;;OAEG;IACG,yBAAyB,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAa9D;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,MAAM,GAAE,OAAO,CAAC,yBAAyB,CAAM,EAC/C,kBAAkB,GAAE,OAAO,CAAC,6BAA6B,CAAM,GAC9D;IACD,mBAAmB,GAAG,IAAI;IAC1B,iBAAiB,GAAG,IAAI;IACxB,CAAC,OAAO,CAAC,EAAE,wBAAwB,KAAK,OAAO,CAAC,iBAAiB,CAAC;CACnE,CAqDA"}
1
+ {"version":3,"file":"Facebook.d.ts","sourceRoot":"","sources":["../../src/providers/Facebook.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAE7D,OAAO,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AAEzD,OAAO,EACL,WAAW,EACX,wBAAwB,EACxB,6BAA6B,EAC7B,iBAAiB,EACjB,iBAAiB,EAGlB,MAAM,gBAAgB,CAAC;AASxB,eAAO,MAAM,SAAS,EAAE,iBAGvB,CAAC;AAGF;;GAEG;AACH,MAAM,WAAW,yBAA0B,SAAQ,yBAAyB;IAC1E;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB;;OAEG;IACH,YAAY,CAAC,EAAE,MAAM,CAAC;CACvB;AAGD;;GAEG;AACH,cAAM,mBAAoB,SAAQ,WAAW;IAC3C,KAAK,CAAC,EAAE,MAAM,CAAC;gBAEH,EACV,QAAQ,EAER,WAAgB,EAChB,YAAY,EACZ,GAAG,MAAM,EACV,EAAE,yBAAyB;IA6B5B;;OAEG;IACG,yBAAyB,IAAI,OAAO,CAAC,iBAAiB,CAAC;CAa9D;AAED;;;;;;;;;GASG;AACH,wBAAgB,cAAc,CAC5B,MAAM,GAAE,OAAO,CAAC,yBAAyB,CAAM,EAC/C,kBAAkB,GAAE,OAAO,CAAC,6BAA6B,CAAM,GAC9D;IACD,mBAAmB,GAAG,IAAI;IAC1B,iBAAiB,GAAG,IAAI;IACxB,CAAC,OAAO,CAAC,EAAE,wBAAwB,KAAK,OAAO,CAAC,iBAAiB,CAAC;CACnE,CAqDA"}
@@ -1,9 +1,9 @@
1
1
  import { useMemo } from 'react';
2
2
  import { Platform } from 'react-native';
3
+ import { applyRequiredScopes } from './ProviderUtils';
3
4
  import { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';
4
5
  import { AuthRequest, makeRedirectUri, ResponseType, } from '../AuthSession';
5
6
  import { generateHexStringAsync } from '../PKCE';
6
- import { applyRequiredScopes } from './ProviderUtils';
7
7
  const settings = {
8
8
  windowFeatures: { width: 700, height: 600 },
9
9
  // These are required for Firebase to work properly which is a reasonable default.
@@ -1 +1 @@
1
- {"version":3,"file":"Facebook.js","sourceRoot":"","sources":["../../src/providers/Facebook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EACL,WAAW,EAKX,eAAe,EACf,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,MAAM,QAAQ,GAAG;IACf,cAAc,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;IAC3C,kFAAkF;IAClF,aAAa,EAAE,CAAC,gBAAgB,EAAE,OAAO,CAAC;CAC3C,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAsB;IAC1C,qBAAqB,EAAE,4CAA4C;IACnE,aAAa,EAAE,oDAAoD;CACpE,CAAC;AAyBF,cAAc;AACd;;GAEG;AACH,MAAM,mBAAoB,SAAQ,WAAW;IAC3C,KAAK,CAAU;IAEf,YAAY,EACV,QAAQ;IACR,6DAA6D;IAC7D,WAAW,GAAG,EAAE,EAChB,YAAY,EACZ,GAAG,MAAM,EACiB;QAC1B,MAAM,WAAW,GAA2B;YAC1C,OAAO,EAAE,OAAO;YAChB,GAAG,WAAW;SACf,CAAC;QACF,IAAI,QAAQ,EAAE;YACZ,WAAW,CAAC,MAAM,GAAG,QAAQ,CAAC;SAC/B;QAED,2BAA2B;QAC3B,MAAM,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AAC,CAAC;IAEH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import { useMemo } from 'react';\nimport { Platform } from 'react-native';\n\nimport { AuthRequestConfig } from '../AuthRequest.types';\nimport { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';\nimport {\n AuthRequest,\n AuthRequestPromptOptions,\n AuthSessionRedirectUriOptions,\n AuthSessionResult,\n DiscoveryDocument,\n makeRedirectUri,\n ResponseType,\n} from '../AuthSession';\nimport { generateHexStringAsync } from '../PKCE';\nimport { ProviderAuthRequestConfig } from './Provider.types';\nimport { applyRequiredScopes } from './ProviderUtils';\n\nconst settings = {\n windowFeatures: { width: 700, height: 600 },\n // These are required for Firebase to work properly which is a reasonable default.\n minimumScopes: ['public_profile', 'email'],\n};\n\nexport const discovery: DiscoveryDocument = {\n authorizationEndpoint: 'https://www.facebook.com/v6.0/dialog/oauth',\n tokenEndpoint: 'https://graph.facebook.com/v6.0/oauth/access_token',\n};\n\n// @needsAudit @docsMissing\n/**\n * @deprecated See [Facebook authentication](/guides/facebook-authentication/).\n */\nexport interface FacebookAuthRequestConfig extends ProviderAuthRequestConfig {\n /**\n * Expo web client ID for use in the browser.\n */\n webClientId?: string;\n /**\n * iOS native client ID for use in development builds and bare workflow.\n */\n iosClientId?: string;\n /**\n * Android native client ID for use in development builds and bare workflow.\n */\n androidClientId?: string;\n /**\n * Proxy client ID for use when testing with Expo Go on Android and iOS.\n */\n expoClientId?: string;\n}\n\n// @needsAudit\n/**\n * Extends [`AuthRequest`](#authrequest) and accepts [`FacebookAuthRequest`](#facebookauthrequest) in the constructor.\n */\nclass FacebookAuthRequest extends AuthRequest {\n nonce?: string;\n\n constructor({\n language,\n // Account selection cannot be reliably emulated on Facebook.\n extraParams = {},\n clientSecret,\n ...config\n }: FacebookAuthRequestConfig) {\n const inputParams: Record<string, string> = {\n display: 'popup',\n ...extraParams,\n };\n if (language) {\n inputParams.locale = language;\n }\n\n // Apply the default scopes\n const scopes = applyRequiredScopes(config.scopes, settings.minimumScopes);\n let inputClientSecret: string | undefined;\n // Facebook will throw if you attempt to use the client secret\n if (config.responseType && config.responseType !== ResponseType.Code) {\n // TODO: maybe warn that you shouldn't store the client secret on the client\n inputClientSecret = clientSecret;\n }\n // Default to implicit auth\n if (!config.responseType) {\n config.responseType = ResponseType.Token;\n }\n super({\n ...config,\n clientSecret: inputClientSecret,\n scopes,\n extraParams: inputParams,\n });\n }\n\n /**\n * Load and return a valid auth request based on the input config.\n */\n async getAuthRequestConfigAsync(): Promise<AuthRequestConfig> {\n const { extraParams = {}, ...config } = await super.getAuthRequestConfigAsync();\n if (!extraParams.nonce && !this.nonce) {\n if (!this.nonce) {\n this.nonce = await generateHexStringAsync(16);\n }\n extraParams.auth_nonce = this.nonce;\n }\n return {\n ...config,\n extraParams,\n };\n }\n}\n\n/**\n * Load an authorization request.\n * Returns a loaded request, a response, and a prompt method.\n * When the prompt method completes then the response will be fulfilled.\n *\n * - [Get Started](https://docs.expo.dev/guides/authentication/#facebook)\n *\n * @param config\n * @param redirectUriOptions\n */\nexport function useAuthRequest(\n config: Partial<FacebookAuthRequestConfig> = {},\n redirectUriOptions: Partial<AuthSessionRedirectUriOptions> = {}\n): [\n FacebookAuthRequest | null,\n AuthSessionResult | null,\n (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>\n] {\n const clientId = useMemo((): string => {\n const propertyName = Platform.select({\n ios: 'iosClientId',\n android: 'androidClientId',\n default: 'webClientId',\n });\n return config[propertyName as any] ?? config.clientId;\n }, [\n config.expoClientId,\n config.iosClientId,\n config.androidClientId,\n config.webClientId,\n config.clientId,\n ]);\n\n const redirectUri = useMemo((): string => {\n if (typeof config.redirectUri !== 'undefined') {\n return config.redirectUri;\n }\n\n return makeRedirectUri({\n // The redirect URI should be created using fb + client ID on native.\n native: `fb${clientId}://authorize`,\n ...redirectUriOptions,\n });\n }, [clientId, config.redirectUri, redirectUriOptions]);\n\n const extraParams = useMemo((): FacebookAuthRequestConfig['extraParams'] => {\n const output = config.extraParams ? { ...config.extraParams } : {};\n\n if (config.language) {\n output.locale = config.language;\n }\n return output;\n }, [config.extraParams, config.language]);\n\n const request = useLoadedAuthRequest(\n {\n ...config,\n extraParams,\n clientId,\n redirectUri,\n },\n discovery,\n FacebookAuthRequest\n );\n\n const [result, promptAsync] = useAuthRequestResult(request, discovery, {\n windowFeatures: settings.windowFeatures,\n });\n\n return [request, result, promptAsync];\n}\n"]}
1
+ {"version":3,"file":"Facebook.js","sourceRoot":"","sources":["../../src/providers/Facebook.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAChC,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAE,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;AAEtD,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EACL,WAAW,EAKX,eAAe,EACf,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD,MAAM,QAAQ,GAAG;IACf,cAAc,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;IAC3C,kFAAkF;IAClF,aAAa,EAAE,CAAC,gBAAgB,EAAE,OAAO,CAAC;CAC3C,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAsB;IAC1C,qBAAqB,EAAE,4CAA4C;IACnE,aAAa,EAAE,oDAAoD;CACpE,CAAC;AAyBF,cAAc;AACd;;GAEG;AACH,MAAM,mBAAoB,SAAQ,WAAW;IAC3C,KAAK,CAAU;IAEf,YAAY,EACV,QAAQ;IACR,6DAA6D;IAC7D,WAAW,GAAG,EAAE,EAChB,YAAY,EACZ,GAAG,MAAM,EACiB;QAC1B,MAAM,WAAW,GAA2B;YAC1C,OAAO,EAAE,OAAO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IAEF,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,GAAG,oBAAoB,CAAC,OAAO,EAAE,SAAS,EAAE;QACrE,cAAc,EAAE,QAAQ,CAAC,cAAc;KACxC,CAAC,CAAC;IAEH,OAAO,CAAC,OAAO,EAAE,MAAM,EAAE,WAAW,CAAC,CAAC;AACxC,CAAC","sourcesContent":["import { useMemo } from 'react';\nimport { Platform } from 'react-native';\n\nimport { ProviderAuthRequestConfig } from './Provider.types';\nimport { applyRequiredScopes } from './ProviderUtils';\nimport { AuthRequestConfig } from '../AuthRequest.types';\nimport { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';\nimport {\n AuthRequest,\n AuthRequestPromptOptions,\n AuthSessionRedirectUriOptions,\n AuthSessionResult,\n DiscoveryDocument,\n makeRedirectUri,\n ResponseType,\n} from '../AuthSession';\nimport { generateHexStringAsync } from '../PKCE';\n\nconst settings = {\n windowFeatures: { width: 700, height: 600 },\n // These are required for Firebase to work properly which is a reasonable default.\n minimumScopes: ['public_profile', 'email'],\n};\n\nexport const discovery: DiscoveryDocument = {\n authorizationEndpoint: 'https://www.facebook.com/v6.0/dialog/oauth',\n tokenEndpoint: 'https://graph.facebook.com/v6.0/oauth/access_token',\n};\n\n// @needsAudit @docsMissing\n/**\n * @deprecated See [Facebook authentication](/guides/facebook-authentication/).\n */\nexport interface FacebookAuthRequestConfig extends ProviderAuthRequestConfig {\n /**\n * Expo web client ID for use in the browser.\n */\n webClientId?: string;\n /**\n * iOS native client ID for use in development builds and bare workflow.\n */\n iosClientId?: string;\n /**\n * Android native client ID for use in development builds and bare workflow.\n */\n androidClientId?: string;\n /**\n * Proxy client ID for use when testing with Expo Go on Android and iOS.\n */\n expoClientId?: string;\n}\n\n// @needsAudit\n/**\n * Extends [`AuthRequest`](#authrequest) and accepts [`FacebookAuthRequest`](#facebookauthrequest) in the constructor.\n */\nclass FacebookAuthRequest extends AuthRequest {\n nonce?: string;\n\n constructor({\n language,\n // Account selection cannot be reliably emulated on Facebook.\n extraParams = {},\n clientSecret,\n ...config\n }: FacebookAuthRequestConfig) {\n const inputParams: Record<string, string> = {\n display: 'popup',\n ...extraParams,\n };\n if (language) {\n inputParams.locale = language;\n }\n\n // Apply the default scopes\n const scopes = applyRequiredScopes(config.scopes, settings.minimumScopes);\n let inputClientSecret: string | undefined;\n // Facebook will throw if you attempt to use the client secret\n if (config.responseType && config.responseType !== ResponseType.Code) {\n // TODO: maybe warn that you shouldn't store the client secret on the client\n inputClientSecret = clientSecret;\n }\n // Default to implicit auth\n if (!config.responseType) {\n config.responseType = ResponseType.Token;\n }\n super({\n ...config,\n clientSecret: inputClientSecret,\n scopes,\n extraParams: inputParams,\n });\n }\n\n /**\n * Load and return a valid auth request based on the input config.\n */\n async getAuthRequestConfigAsync(): Promise<AuthRequestConfig> {\n const { extraParams = {}, ...config } = await super.getAuthRequestConfigAsync();\n if (!extraParams.nonce && !this.nonce) {\n if (!this.nonce) {\n this.nonce = await generateHexStringAsync(16);\n }\n extraParams.auth_nonce = this.nonce;\n }\n return {\n ...config,\n extraParams,\n };\n }\n}\n\n/**\n * Load an authorization request.\n * Returns a loaded request, a response, and a prompt method.\n * When the prompt method completes then the response will be fulfilled.\n *\n * - [Get Started](https://docs.expo.dev/guides/authentication/#facebook)\n *\n * @param config\n * @param redirectUriOptions\n */\nexport function useAuthRequest(\n config: Partial<FacebookAuthRequestConfig> = {},\n redirectUriOptions: Partial<AuthSessionRedirectUriOptions> = {}\n): [\n FacebookAuthRequest | null,\n AuthSessionResult | null,\n (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>,\n] {\n const clientId = useMemo((): string => {\n const propertyName = Platform.select({\n ios: 'iosClientId',\n android: 'androidClientId',\n default: 'webClientId',\n });\n return config[propertyName as any] ?? config.clientId;\n }, [\n config.expoClientId,\n config.iosClientId,\n config.androidClientId,\n config.webClientId,\n config.clientId,\n ]);\n\n const redirectUri = useMemo((): string => {\n if (typeof config.redirectUri !== 'undefined') {\n return config.redirectUri;\n }\n\n return makeRedirectUri({\n // The redirect URI should be created using fb + client ID on native.\n native: `fb${clientId}://authorize`,\n ...redirectUriOptions,\n });\n }, [clientId, config.redirectUri, redirectUriOptions]);\n\n const extraParams = useMemo((): FacebookAuthRequestConfig['extraParams'] => {\n const output = config.extraParams ? { ...config.extraParams } : {};\n\n if (config.language) {\n output.locale = config.language;\n }\n return output;\n }, [config.extraParams, config.language]);\n\n const request = useLoadedAuthRequest(\n {\n ...config,\n extraParams,\n clientId,\n redirectUri,\n },\n discovery,\n FacebookAuthRequest\n );\n\n const [result, promptAsync] = useAuthRequestResult(request, discovery, {\n windowFeatures: settings.windowFeatures,\n });\n\n return [request, result, promptAsync];\n}\n"]}
@@ -1,5 +1,5 @@
1
- import { AuthRequest, AuthRequestConfig, AuthRequestPromptOptions, AuthSessionRedirectUriOptions, AuthSessionResult, DiscoveryDocument } from '../AuthSession';
2
1
  import { ProviderAuthRequestConfig } from './Provider.types';
2
+ import { AuthRequest, AuthRequestConfig, AuthRequestPromptOptions, AuthSessionRedirectUriOptions, AuthSessionResult, DiscoveryDocument } from '../AuthSession';
3
3
  export declare const discovery: DiscoveryDocument;
4
4
  /**
5
5
  * @deprecated See [Google authentication](/guides/google-authentication/).
@@ -1 +1 @@
1
- {"version":3,"file":"Google.d.ts","sourceRoot":"","sources":["../../src/providers/Google.ts"],"names":[],"mappings":"AAKA,OAAO,EACL,WAAW,EACX,iBAAiB,EACjB,wBAAwB,EACxB,6BAA6B,EAC7B,iBAAiB,EACjB,iBAAiB,EAKlB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EAAE,yBAAyB,EAAE,MAAM,kBAAkB,CAAC;AAY7D,eAAO,MAAM,SAAS,EAAE,iBAKvB,CAAC;AAGF;;GAEG;AACH,MAAM,WAAW,uBAAwB,SAAQ,yBAAyB;IACxE;;;OAGG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB;;;OAGG;IACH,aAAa,CAAC,EAAE,OAAO,CAAC;IACxB;;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CAAM,EAC7C,kBAAkB,GAAE,OAAO,CAAC,6BAA6B,CAAM,GAC9D;IACD,iBAAiB,GAAG,IAAI;IACxB,iBAAiB,GAAG,IAAI;IACxB,CAAC,OAAO,CAAC,EAAE,wBAAwB,KAAK,OAAO,CAAC,iBAAiB,CAAC;CACnE,CAqIA"}
@@ -1,10 +1,10 @@
1
1
  import * as Application from 'expo-application';
2
2
  import { useEffect, useMemo, useState } from 'react';
3
3
  import { Platform } from 'react-native';
4
+ import { applyRequiredScopes, invariantClientId } from './ProviderUtils';
4
5
  import { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';
5
6
  import { AuthRequest, generateHexStringAsync, makeRedirectUri, Prompt, ResponseType, } from '../AuthSession';
6
7
  import { AccessTokenRequest } from '../TokenRequest';
7
- import { applyRequiredScopes, invariantClientId } from './ProviderUtils';
8
8
  const settings = {
9
9
  windowFeatures: { width: 515, height: 680 },
10
10
  minimumScopes: [
@@ -1 +1 @@
1
- {"version":3,"file":"Google.js","sourceRoot":"","sources":["../../src/providers/Google.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAExC,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EACL,WAAW,EAMX,sBAAsB,EACtB,eAAe,EACf,MAAM,EACN,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AAEzE,MAAM,QAAQ,GAAG;IACf,cAAc,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;IAC3C,aAAa,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 'expo-application';\nimport { useEffect, useMemo, useState } from 'react';\nimport { Platform } from 'react-native';\n\nimport { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';\nimport {\n AuthRequest,\n AuthRequestConfig,\n AuthRequestPromptOptions,\n AuthSessionRedirectUriOptions,\n AuthSessionResult,\n DiscoveryDocument,\n generateHexStringAsync,\n makeRedirectUri,\n Prompt,\n ResponseType,\n} from '../AuthSession';\nimport { AccessTokenRequest } from '../TokenRequest';\nimport { ProviderAuthRequestConfig } from './Provider.types';\nimport { applyRequiredScopes, invariantClientId } from './ProviderUtils';\n\nconst settings = {\n windowFeatures: { width: 515, height: 680 },\n minimumScopes: [\n 'openid',\n 'https://www.googleapis.com/auth/userinfo.profile',\n 'https://www.googleapis.com/auth/userinfo.email',\n ],\n};\n\nexport const discovery: DiscoveryDocument = {\n authorizationEndpoint: 'https://accounts.google.com/o/oauth2/v2/auth',\n tokenEndpoint: 'https://oauth2.googleapis.com/token',\n revocationEndpoint: 'https://oauth2.googleapis.com/revoke',\n userInfoEndpoint: 'https://openidconnect.googleapis.com/v1/userinfo',\n};\n\n// @needsAudit\n/**\n * @deprecated See [Google authentication](/guides/google-authentication/).\n */\nexport interface GoogleAuthRequestConfig extends ProviderAuthRequestConfig {\n /**\n * If the user's email address is known ahead of time, it can be supplied to be the default option.\n * If the user has approved access for this app in the past then auth may return without any further interaction.\n */\n loginHint?: string;\n /**\n * When `true`, the service will allow the user to switch between accounts (if possible).\n * @default false.\n */\n selectAccount?: boolean;\n /**\n * Proxy client ID for use in the Expo client on Android and iOS.\n */\n expoClientId?: string;\n /**\n * Expo web client ID for use in the browser.\n */\n webClientId?: string;\n /**\n * iOS native client ID for use in standalone, bare workflow, and custom clients.\n */\n iosClientId?: string;\n /**\n * Android native client ID for use in standalone, and bare workflow.\n */\n androidClientId?: string;\n /**\n * Should the hook automatically exchange the response code for an authentication token.\n *\n * Defaults to `true` on installed apps (Android, iOS) when `ResponseType.Code` is used (default).\n */\n shouldAutoExchangeCode?: boolean;\n /**\n * Language code ISO 3166-1 alpha-2 region code, such as 'it' or 'pt-PT'.\n */\n language?: string;\n}\n\n// @needsAudit\n/**\n * Extends [`AuthRequest`](#authrequest) and accepts [`GoogleAuthRequestConfig`](#googleauthrequestconfig) in the constructor.\n */\nclass GoogleAuthRequest extends AuthRequest {\n nonce?: string;\n\n constructor({\n language,\n loginHint,\n selectAccount,\n extraParams = {},\n clientSecret,\n ...config\n }: GoogleAuthRequestConfig) {\n const inputParams = {\n ...extraParams,\n };\n if (language) inputParams.hl = language;\n if (loginHint) inputParams.login_hint = loginHint;\n if (selectAccount) inputParams.prompt = Prompt.SelectAccount;\n\n // Apply the default scopes\n const scopes = applyRequiredScopes(config.scopes, settings.minimumScopes);\n const isImplicit =\n config.responseType === ResponseType.Token || config.responseType === ResponseType.IdToken;\n if (isImplicit) {\n // PKCE must be disabled in implicit mode.\n config.usePKCE = false;\n }\n let inputClientSecret: string | undefined;\n // Google will throw if you attempt to use the client secret\n if (config.responseType && config.responseType !== ResponseType.Code) {\n // TODO: maybe warn that you shouldn't store the client secret on the client\n inputClientSecret = clientSecret;\n }\n super({\n ...config,\n clientSecret: inputClientSecret,\n scopes,\n extraParams: inputParams,\n });\n }\n\n /**\n * Load and return a valid auth request based on the input config.\n */\n async getAuthRequestConfigAsync(): Promise<AuthRequestConfig> {\n const { extraParams = {}, ...config } = await super.getAuthRequestConfigAsync();\n if (config.responseType === ResponseType.IdToken && !extraParams.nonce && !this.nonce) {\n if (!this.nonce) {\n this.nonce = await generateHexStringAsync(16);\n }\n extraParams.nonce = this.nonce;\n }\n return {\n ...config,\n extraParams,\n };\n }\n}\n\n/**\n * Load an authorization request with an ID Token for authentication with Firebase.\n *\n * Returns a loaded request, a response, and a prompt method.\n * When the prompt method completes then the response will be fulfilled.\n *\n * The id token can be retrieved with `response.params.id_token`.\n *\n * - [Get Started](https://docs.expo.dev/guides/authentication/#google)\n *\n * @param config\n * @param redirectUriOptions\n */\nexport function useIdTokenAuthRequest(\n config: Partial<GoogleAuthRequestConfig>,\n redirectUriOptions: Partial<AuthSessionRedirectUriOptions> = {}\n): [\n GoogleAuthRequest | null,\n AuthSessionResult | null,\n (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>\n] {\n const isWebAuth = Platform.OS === 'web';\n\n return useAuthRequest(\n {\n ...config,\n responseType:\n // If the client secret is provided then code can be used\n !config.clientSecret &&\n // When web auth is used, we can request the `id_token` directly without exchanging a code.\n isWebAuth\n ? ResponseType.IdToken\n : undefined,\n },\n { ...redirectUriOptions }\n );\n}\n\n/**\n * Load an authorization request.\n * Returns a loaded request, a response, and a prompt method.\n * When the prompt method completes, then the response will be fulfilled.\n *\n * - [Get Started](https://docs.expo.dev/guides/authentication/#google)\n *\n * @param config\n * @param redirectUriOptions\n */\nexport function useAuthRequest(\n config: Partial<GoogleAuthRequestConfig> = {},\n redirectUriOptions: Partial<AuthSessionRedirectUriOptions> = {}\n): [\n GoogleAuthRequest | null,\n AuthSessionResult | null,\n (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>\n] {\n const clientId = useMemo((): string => {\n const propertyName = Platform.select({\n ios: 'iosClientId',\n android: 'androidClientId',\n default: 'webClientId',\n });\n\n const clientId = config[propertyName as any] ?? config.clientId;\n invariantClientId(propertyName, clientId, 'Google');\n return clientId;\n }, [\n config.expoClientId,\n config.iosClientId,\n config.androidClientId,\n config.webClientId,\n config.clientId,\n ]);\n\n const responseType = useMemo(() => {\n // Allow overrides.\n if (typeof config.responseType !== 'undefined') {\n return config.responseType;\n }\n // You can only use `response_token=code` on installed apps (iOS, Android without proxy).\n // Installed apps can auto exchange without a client secret and get the token and id-token (Firebase).\n const isInstalledApp = Platform.OS !== 'web';\n // If the user provided the client secret (they shouldn't!) then use code exchange by default.\n if (config.clientSecret || isInstalledApp) {\n return ResponseType.Code;\n }\n // This seems the most pragmatic option since it can result in a full authentication on web and proxy platforms as expected.\n return ResponseType.Token;\n }, [config.responseType, config.clientSecret]);\n\n const redirectUri = useMemo((): string => {\n if (typeof config.redirectUri !== 'undefined') {\n return config.redirectUri;\n }\n\n return makeRedirectUri({\n native: `${Application.applicationId}:/oauthredirect`,\n ...redirectUriOptions,\n // native: `com.googleusercontent.apps.${guid}:/oauthredirect`,\n });\n }, [config.redirectUri, redirectUriOptions]);\n\n const extraParams = useMemo((): GoogleAuthRequestConfig['extraParams'] => {\n const output = config.extraParams ? { ...config.extraParams } : {};\n\n if (config.language) {\n output.hl = output.language;\n }\n if (config.loginHint) {\n output.login_hint = output.loginHint;\n }\n if (config.selectAccount) {\n output.prompt = Prompt.SelectAccount;\n }\n return output;\n }, [config.extraParams, config.language, config.loginHint, config.selectAccount]);\n\n const request = useLoadedAuthRequest(\n {\n ...config,\n responseType,\n extraParams,\n clientId,\n redirectUri,\n },\n discovery,\n GoogleAuthRequest\n );\n\n const [result, promptAsync] = useAuthRequestResult(request, discovery, {\n windowFeatures: settings.windowFeatures,\n });\n\n const [fullResult, setFullResult] = useState<AuthSessionResult | null>(null);\n\n const shouldAutoExchangeCode = useMemo(() => {\n // allow overrides\n if (typeof config.shouldAutoExchangeCode !== 'undefined') {\n return config.shouldAutoExchangeCode;\n }\n\n // has a code to exchange and doesn't have an authentication yet.\n return result?.type === 'success' && result.params.code && !result.authentication;\n }, [config.shouldAutoExchangeCode, result?.type]);\n\n useEffect(() => {\n let isMounted = true;\n if (shouldAutoExchangeCode && result?.type === 'success') {\n const exchangeRequest = new AccessTokenRequest({\n clientId,\n clientSecret: config.clientSecret,\n redirectUri,\n scopes: config.scopes,\n code: result.params.code,\n extraParams: {\n code_verifier: request?.codeVerifier || '',\n },\n });\n exchangeRequest.performAsync(discovery).then((authentication) => {\n if (isMounted) {\n setFullResult({\n ...result,\n params: {\n id_token: authentication?.idToken || '',\n access_token: authentication.accessToken,\n ...result.params,\n },\n authentication,\n });\n }\n });\n } else {\n setFullResult(result);\n }\n return () => {\n isMounted = false;\n };\n }, [\n clientId,\n redirectUri,\n shouldAutoExchangeCode,\n config.clientSecret,\n config.scopes?.join(','),\n request?.codeVerifier,\n result,\n ]);\n\n return [request, fullResult, promptAsync];\n}\n"]}
1
+ {"version":3,"file":"Google.js","sourceRoot":"","sources":["../../src/providers/Google.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,WAAW,MAAM,kBAAkB,CAAC;AAChD,OAAO,EAAE,SAAS,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AACrD,OAAO,EAAE,QAAQ,EAAE,MAAM,cAAc,CAAC;AAGxC,OAAO,EAAE,mBAAmB,EAAE,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EACL,WAAW,EAMX,sBAAsB,EACtB,eAAe,EACf,MAAM,EACN,YAAY,GACb,MAAM,gBAAgB,CAAC;AACxB,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,QAAQ,GAAG;IACf,cAAc,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;IAC3C,aAAa,EAAE;QACb,QAAQ;QACR,kDAAkD;QAClD,gDAAgD;KACjD;CACF,CAAC;AAEF,MAAM,CAAC,MAAM,SAAS,GAAsB;IAC1C,qBAAqB,EAAE,8CAA8C;IACrE,aAAa,EAAE,qCAAqC;IACpD,kBAAkB,EAAE,sCAAsC;IAC1D,gBAAgB,EAAE,kDAAkD;CACrE,CAAC;AA6CF,cAAc;AACd;;GAEG;AACH,MAAM,iBAAkB,SAAQ,WAAW;IACzC,KAAK,CAAU;IAEf,YAAY,EACV,QAAQ,EACR,SAAS,EACT,aAAa,EACb,WAAW,GAAG,EAAE,EAChB,YAAY,EACZ,GAAG,MAAM,EACe;QACxB,MAAM,WAAW,GAAG;YAClB,GAAG,WAAW;SACf,CAAC;QACF,IAAI,QAAQ;YAAE,WAAW,CAAC,EAAE,GAAG,QAAQ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AAS,CAAC,CAAC,IAAI,CAAC,CAAC,cAAc,EAAE,EAAE;gBAC9D,IAAI,SAAS,EAAE;oBACb,aAAa,CAAC;wBACZ,GAAG,MAAM;wBACT,MAAM,EAAE;4BACN,QAAQ,EAAE,cAAc,EAAE,OAAO,IAAI,EAAE;4BACvC,YAAY,EAAE,cAAc,CAAC,WAAW;4BACxC,GAAG,MAAM,CAAC,MAAM;yBACjB;wBACD,cAAc;qBACf,CAAC,CAAC;iBACJ;YACH,CAAC,CAAC,CAAC;SACJ;aAAM;YACL,aAAa,CAAC,MAAM,CAAC,CAAC;SACvB;QACD,OAAO,GAAG,EAAE;YACV,SAAS,GAAG,KAAK,CAAC;QACpB,CAAC,CAAC;IACJ,CAAC,EAAE;QACD,QAAQ;QACR,WAAW;QACX,sBAAsB;QACtB,MAAM,CAAC,YAAY;QACnB,MAAM,CAAC,MAAM,EAAE,IAAI,CAAC,GAAG,CAAC;QACxB,OAAO,EAAE,YAAY;QACrB,MAAM;KACP,CAAC,CAAC;IAEH,OAAO,CAAC,OAAO,EAAE,UAAU,EAAE,WAAW,CAAC,CAAC;AAC5C,CAAC","sourcesContent":["import * as Application from 'expo-application';\nimport { useEffect, useMemo, useState } from 'react';\nimport { Platform } from 'react-native';\n\nimport { ProviderAuthRequestConfig } from './Provider.types';\nimport { applyRequiredScopes, invariantClientId } from './ProviderUtils';\nimport { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';\nimport {\n AuthRequest,\n AuthRequestConfig,\n AuthRequestPromptOptions,\n AuthSessionRedirectUriOptions,\n AuthSessionResult,\n DiscoveryDocument,\n generateHexStringAsync,\n makeRedirectUri,\n Prompt,\n ResponseType,\n} from '../AuthSession';\nimport { AccessTokenRequest } from '../TokenRequest';\n\nconst settings = {\n windowFeatures: { width: 515, height: 680 },\n minimumScopes: [\n 'openid',\n 'https://www.googleapis.com/auth/userinfo.profile',\n 'https://www.googleapis.com/auth/userinfo.email',\n ],\n};\n\nexport const discovery: DiscoveryDocument = {\n authorizationEndpoint: 'https://accounts.google.com/o/oauth2/v2/auth',\n tokenEndpoint: 'https://oauth2.googleapis.com/token',\n revocationEndpoint: 'https://oauth2.googleapis.com/revoke',\n userInfoEndpoint: 'https://openidconnect.googleapis.com/v1/userinfo',\n};\n\n// @needsAudit\n/**\n * @deprecated See [Google authentication](/guides/google-authentication/).\n */\nexport interface GoogleAuthRequestConfig extends ProviderAuthRequestConfig {\n /**\n * If the user's email address is known ahead of time, it can be supplied to be the default option.\n * If the user has approved access for this app in the past then auth may return without any further interaction.\n */\n loginHint?: string;\n /**\n * When `true`, the service will allow the user to switch between accounts (if possible).\n * @default false.\n */\n selectAccount?: boolean;\n /**\n * Proxy client ID for use in the Expo client on Android and iOS.\n */\n expoClientId?: string;\n /**\n * Expo web client ID for use in the browser.\n */\n webClientId?: string;\n /**\n * iOS native client ID for use in standalone, bare workflow, and custom clients.\n */\n iosClientId?: string;\n /**\n * Android native client ID for use in standalone, and bare workflow.\n */\n androidClientId?: string;\n /**\n * Should the hook automatically exchange the response code for an authentication token.\n *\n * Defaults to `true` on installed apps (Android, iOS) when `ResponseType.Code` is used (default).\n */\n shouldAutoExchangeCode?: boolean;\n /**\n * Language code ISO 3166-1 alpha-2 region code, such as 'it' or 'pt-PT'.\n */\n language?: string;\n}\n\n// @needsAudit\n/**\n * Extends [`AuthRequest`](#authrequest) and accepts [`GoogleAuthRequestConfig`](#googleauthrequestconfig) in the constructor.\n */\nclass GoogleAuthRequest extends AuthRequest {\n nonce?: string;\n\n constructor({\n language,\n loginHint,\n selectAccount,\n extraParams = {},\n clientSecret,\n ...config\n }: GoogleAuthRequestConfig) {\n const inputParams = {\n ...extraParams,\n };\n if (language) inputParams.hl = language;\n if (loginHint) inputParams.login_hint = loginHint;\n if (selectAccount) inputParams.prompt = Prompt.SelectAccount;\n\n // Apply the default scopes\n const scopes = applyRequiredScopes(config.scopes, settings.minimumScopes);\n const isImplicit =\n config.responseType === ResponseType.Token || config.responseType === ResponseType.IdToken;\n if (isImplicit) {\n // PKCE must be disabled in implicit mode.\n config.usePKCE = false;\n }\n let inputClientSecret: string | undefined;\n // Google will throw if you attempt to use the client secret\n if (config.responseType && config.responseType !== ResponseType.Code) {\n // TODO: maybe warn that you shouldn't store the client secret on the client\n inputClientSecret = clientSecret;\n }\n super({\n ...config,\n clientSecret: inputClientSecret,\n scopes,\n extraParams: inputParams,\n });\n }\n\n /**\n * Load and return a valid auth request based on the input config.\n */\n async getAuthRequestConfigAsync(): Promise<AuthRequestConfig> {\n const { extraParams = {}, ...config } = await super.getAuthRequestConfigAsync();\n if (config.responseType === ResponseType.IdToken && !extraParams.nonce && !this.nonce) {\n if (!this.nonce) {\n this.nonce = await generateHexStringAsync(16);\n }\n extraParams.nonce = this.nonce;\n }\n return {\n ...config,\n extraParams,\n };\n }\n}\n\n/**\n * Load an authorization request with an ID Token for authentication with Firebase.\n *\n * Returns a loaded request, a response, and a prompt method.\n * When the prompt method completes then the response will be fulfilled.\n *\n * The id token can be retrieved with `response.params.id_token`.\n *\n * - [Get Started](https://docs.expo.dev/guides/authentication/#google)\n *\n * @param config\n * @param redirectUriOptions\n */\nexport function useIdTokenAuthRequest(\n config: Partial<GoogleAuthRequestConfig>,\n redirectUriOptions: Partial<AuthSessionRedirectUriOptions> = {}\n): [\n GoogleAuthRequest | null,\n AuthSessionResult | null,\n (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>,\n] {\n const isWebAuth = Platform.OS === 'web';\n\n return useAuthRequest(\n {\n ...config,\n responseType:\n // If the client secret is provided then code can be used\n !config.clientSecret &&\n // When web auth is used, we can request the `id_token` directly without exchanging a code.\n isWebAuth\n ? ResponseType.IdToken\n : undefined,\n },\n { ...redirectUriOptions }\n );\n}\n\n/**\n * Load an authorization request.\n * Returns a loaded request, a response, and a prompt method.\n * When the prompt method completes, then the response will be fulfilled.\n *\n * - [Get Started](https://docs.expo.dev/guides/authentication/#google)\n *\n * @param config\n * @param redirectUriOptions\n */\nexport function useAuthRequest(\n config: Partial<GoogleAuthRequestConfig> = {},\n redirectUriOptions: Partial<AuthSessionRedirectUriOptions> = {}\n): [\n GoogleAuthRequest | null,\n AuthSessionResult | null,\n (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>,\n] {\n const clientId = useMemo((): string => {\n const propertyName = Platform.select({\n ios: 'iosClientId',\n android: 'androidClientId',\n default: 'webClientId',\n });\n\n const clientId = config[propertyName as any] ?? config.clientId;\n invariantClientId(propertyName, clientId, 'Google');\n return clientId;\n }, [\n config.expoClientId,\n config.iosClientId,\n config.androidClientId,\n config.webClientId,\n config.clientId,\n ]);\n\n const responseType = useMemo(() => {\n // Allow overrides.\n if (typeof config.responseType !== 'undefined') {\n return config.responseType;\n }\n // You can only use `response_token=code` on installed apps (iOS, Android without proxy).\n // Installed apps can auto exchange without a client secret and get the token and id-token (Firebase).\n const isInstalledApp = Platform.OS !== 'web';\n // If the user provided the client secret (they shouldn't!) then use code exchange by default.\n if (config.clientSecret || isInstalledApp) {\n return ResponseType.Code;\n }\n // This seems the most pragmatic option since it can result in a full authentication on web and proxy platforms as expected.\n return ResponseType.Token;\n }, [config.responseType, config.clientSecret]);\n\n const redirectUri = useMemo((): string => {\n if (typeof config.redirectUri !== 'undefined') {\n return config.redirectUri;\n }\n\n return makeRedirectUri({\n native: `${Application.applicationId}:/oauthredirect`,\n ...redirectUriOptions,\n // native: `com.googleusercontent.apps.${guid}:/oauthredirect`,\n });\n }, [config.redirectUri, redirectUriOptions]);\n\n const extraParams = useMemo((): GoogleAuthRequestConfig['extraParams'] => {\n const output = config.extraParams ? { ...config.extraParams } : {};\n\n if (config.language) {\n output.hl = output.language;\n }\n if (config.loginHint) {\n output.login_hint = output.loginHint;\n }\n if (config.selectAccount) {\n output.prompt = Prompt.SelectAccount;\n }\n return output;\n }, [config.extraParams, config.language, config.loginHint, config.selectAccount]);\n\n const request = useLoadedAuthRequest(\n {\n ...config,\n responseType,\n extraParams,\n clientId,\n redirectUri,\n },\n discovery,\n GoogleAuthRequest\n );\n\n const [result, promptAsync] = useAuthRequestResult(request, discovery, {\n windowFeatures: settings.windowFeatures,\n });\n\n const [fullResult, setFullResult] = useState<AuthSessionResult | null>(null);\n\n const shouldAutoExchangeCode = useMemo(() => {\n // allow overrides\n if (typeof config.shouldAutoExchangeCode !== 'undefined') {\n return config.shouldAutoExchangeCode;\n }\n\n // has a code to exchange and doesn't have an authentication yet.\n return result?.type === 'success' && result.params.code && !result.authentication;\n }, [config.shouldAutoExchangeCode, result?.type]);\n\n useEffect(() => {\n let isMounted = true;\n if (shouldAutoExchangeCode && result?.type === 'success') {\n const exchangeRequest = new AccessTokenRequest({\n clientId,\n clientSecret: config.clientSecret,\n redirectUri,\n scopes: config.scopes,\n code: result.params.code,\n extraParams: {\n code_verifier: request?.codeVerifier || '',\n },\n });\n exchangeRequest.performAsync(discovery).then((authentication) => {\n if (isMounted) {\n setFullResult({\n ...result,\n params: {\n id_token: authentication?.idToken || '',\n access_token: authentication.accessToken,\n ...result.params,\n },\n authentication,\n });\n }\n });\n } else {\n setFullResult(result);\n }\n return () => {\n isMounted = false;\n };\n }, [\n clientId,\n redirectUri,\n shouldAutoExchangeCode,\n config.clientSecret,\n config.scopes?.join(','),\n request?.codeVerifier,\n result,\n ]);\n\n return [request, fullResult, promptAsync];\n}\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "expo-auth-session",
3
- "version": "5.1.0",
3
+ "version": "5.2.0",
4
4
  "description": "Expo module for browser-based authentication",
5
5
  "main": "build/AuthSession.js",
6
6
  "types": "build/AuthSession.d.ts",
@@ -34,10 +34,10 @@
34
34
  "license": "MIT",
35
35
  "homepage": "https://docs.expo.dev/versions/latest/sdk/auth-session",
36
36
  "dependencies": {
37
- "expo-constants": "~14.5.0",
38
- "expo-crypto": "~12.5.0",
39
- "expo-linking": "~5.0.0",
40
- "expo-web-browser": "~12.4.0",
37
+ "expo-constants": "~15.0.0",
38
+ "expo-crypto": "~12.6.0",
39
+ "expo-linking": "~6.0.0",
40
+ "expo-web-browser": "~12.5.0",
41
41
  "invariant": "^2.2.4",
42
42
  "qs": "^6.11.0"
43
43
  },
@@ -48,5 +48,5 @@
48
48
  "jest": {
49
49
  "preset": "expo-module-scripts"
50
50
  },
51
- "gitHead": "663654577a7068c641b5e9474efbc502e3f334ea"
51
+ "gitHead": "4adde0208a611627914ad3d6e701d88c78e709d8"
52
52
  }
@@ -142,7 +142,7 @@ export function useAuthRequest(
142
142
  ): [
143
143
  AuthRequest | null,
144
144
  AuthSessionResult | null,
145
- (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>
145
+ (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>,
146
146
  ] {
147
147
  const request = useLoadedAuthRequest(config, discovery, AuthRequest);
148
148
  const [result, promptAsync] = useAuthRequestResult(request, discovery);
@@ -49,9 +49,7 @@ export class SessionUrlProvider {
49
49
  }
50
50
 
51
51
  const legacyExpoProjectFullName =
52
- options.projectNameForProxy ||
53
- Constants.expoConfig?.originalFullName ||
54
- Constants.__unsafeNoWarnManifest?.originalFullName;
52
+ options.projectNameForProxy || Constants.expoConfig?.originalFullName;
55
53
 
56
54
  if (!legacyExpoProjectFullName) {
57
55
  let nextSteps = '';
@@ -162,7 +162,10 @@ class TokenRequest<T extends TokenRequestConfig> extends Request<T, TokenRespons
162
162
  readonly scopes?: string[];
163
163
  readonly extraParams?: Record<string, string>;
164
164
 
165
- constructor(request, public grantType: GrantType) {
165
+ constructor(
166
+ request,
167
+ public grantType: GrantType
168
+ ) {
166
169
  super(request);
167
170
  this.clientId = request.clientId;
168
171
  this.clientSecret = request.clientSecret;
@@ -1,6 +1,8 @@
1
1
  import { useMemo } from 'react';
2
2
  import { Platform } from 'react-native';
3
3
 
4
+ import { ProviderAuthRequestConfig } from './Provider.types';
5
+ import { applyRequiredScopes } from './ProviderUtils';
4
6
  import { AuthRequestConfig } from '../AuthRequest.types';
5
7
  import { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';
6
8
  import {
@@ -13,8 +15,6 @@ import {
13
15
  ResponseType,
14
16
  } from '../AuthSession';
15
17
  import { generateHexStringAsync } from '../PKCE';
16
- import { ProviderAuthRequestConfig } from './Provider.types';
17
- import { applyRequiredScopes } from './ProviderUtils';
18
18
 
19
19
  const settings = {
20
20
  windowFeatures: { width: 700, height: 600 },
@@ -126,7 +126,7 @@ export function useAuthRequest(
126
126
  ): [
127
127
  FacebookAuthRequest | null,
128
128
  AuthSessionResult | null,
129
- (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>
129
+ (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>,
130
130
  ] {
131
131
  const clientId = useMemo((): string => {
132
132
  const propertyName = Platform.select({
@@ -2,6 +2,8 @@ import * as Application from 'expo-application';
2
2
  import { useEffect, useMemo, useState } from 'react';
3
3
  import { Platform } from 'react-native';
4
4
 
5
+ import { ProviderAuthRequestConfig } from './Provider.types';
6
+ import { applyRequiredScopes, invariantClientId } from './ProviderUtils';
5
7
  import { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';
6
8
  import {
7
9
  AuthRequest,
@@ -16,8 +18,6 @@ import {
16
18
  ResponseType,
17
19
  } from '../AuthSession';
18
20
  import { AccessTokenRequest } from '../TokenRequest';
19
- import { ProviderAuthRequestConfig } from './Provider.types';
20
- import { applyRequiredScopes, invariantClientId } from './ProviderUtils';
21
21
 
22
22
  const settings = {
23
23
  windowFeatures: { width: 515, height: 680 },
@@ -159,7 +159,7 @@ export function useIdTokenAuthRequest(
159
159
  ): [
160
160
  GoogleAuthRequest | null,
161
161
  AuthSessionResult | null,
162
- (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>
162
+ (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>,
163
163
  ] {
164
164
  const isWebAuth = Platform.OS === 'web';
165
165
 
@@ -194,7 +194,7 @@ export function useAuthRequest(
194
194
  ): [
195
195
  GoogleAuthRequest | null,
196
196
  AuthSessionResult | null,
197
- (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>
197
+ (options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>,
198
198
  ] {
199
199
  const clientId = useMemo((): string => {
200
200
  const propertyName = Platform.select({
package/tsconfig.json CHANGED
@@ -5,5 +5,5 @@
5
5
  "outDir": "./build"
6
6
  },
7
7
  "include": ["./src"],
8
- "exclude": ["**/__mocks__/*", "**/__tests__/*", "**/__stories__/*"]
8
+ "exclude": ["**/__mocks__/*", "**/__tests__/*"]
9
9
  }