expo-auth-session 6.1.4 → 6.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 +18 -0
- package/build/AuthRequest.types.d.ts +2 -2
- package/build/AuthRequest.types.d.ts.map +1 -1
- package/build/AuthRequest.types.js.map +1 -1
- package/build/SessionUrlProvider.js +2 -2
- package/build/SessionUrlProvider.js.map +1 -1
- package/build/TokenRequest.d.ts +5 -1
- package/build/TokenRequest.d.ts.map +1 -1
- package/build/TokenRequest.js +7 -2
- package/build/TokenRequest.js.map +1 -1
- package/package.json +8 -8
- package/src/AuthRequest.types.ts +2 -2
- package/src/SessionUrlProvider.ts +2 -2
- package/src/TokenRequest.ts +18 -10
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,24 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 6.2.0 — 2025-06-04
|
|
14
|
+
|
|
15
|
+
### 🎉 New features
|
|
16
|
+
|
|
17
|
+
- Added `rawResponse` to `TokenResponse`, allows reading fields that are not part of RFC 6749. ([#20284](https://github.com/expo/expo/pull/20284) by [@stefan-schweiger](https://github.com/stefan-schweiger))
|
|
18
|
+
|
|
19
|
+
### 🐛 Bug fixes
|
|
20
|
+
|
|
21
|
+
- Allow `preferEphemeralSession` in promptAsync method. ([#35489](https://github.com/expo/expo/pull/35489) by [@TJTorola](https://github.com/TJTorola))
|
|
22
|
+
|
|
23
|
+
### 💡 Others
|
|
24
|
+
|
|
25
|
+
- Remove "Please" from warnings and errors ([#36862](https://github.com/expo/expo/pull/36862) by [@brentvatne](https://github.com/brentvatne))
|
|
26
|
+
|
|
27
|
+
## 6.1.5 — 2025-04-30
|
|
28
|
+
|
|
29
|
+
_This version does not introduce any user-facing changes._
|
|
30
|
+
|
|
13
31
|
## 6.1.4 — 2025-04-25
|
|
14
32
|
|
|
15
33
|
_This version does not introduce any user-facing changes._
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AuthSessionOpenOptions, WebBrowserWindowFeatures } from 'expo-web-browser';
|
|
2
2
|
import { DiscoveryDocument } from './Discovery';
|
|
3
3
|
export declare enum CodeChallengeMethod {
|
|
4
4
|
/**
|
|
@@ -66,7 +66,7 @@ export declare enum Prompt {
|
|
|
66
66
|
* Options passed to the `promptAsync()` method of `AuthRequest`s.
|
|
67
67
|
* This can be used to configure how the web browser should look and behave.
|
|
68
68
|
*/
|
|
69
|
-
export type AuthRequestPromptOptions = Omit<
|
|
69
|
+
export type AuthRequestPromptOptions = Omit<AuthSessionOpenOptions, 'windowFeatures'> & {
|
|
70
70
|
/**
|
|
71
71
|
* URL to open when prompting the user. This usually should be defined internally and left `undefined` in most cases.
|
|
72
72
|
*/
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"AuthRequest.types.d.ts","sourceRoot":"","sources":["../src/AuthRequest.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"AuthRequest.types.d.ts","sourceRoot":"","sources":["../src/AuthRequest.types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,sBAAsB,EAAE,wBAAwB,EAAE,MAAM,kBAAkB,CAAC;AAEpF,OAAO,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAGhD,oBAAY,mBAAmB;IAC7B;;;;;OAKG;IACH,IAAI,SAAS;IACb;;OAEG;IACH,KAAK,UAAU;CAChB;AAGD;;;;GAIG;AACH,oBAAY,YAAY;IACtB;;OAEG;IACH,IAAI,SAAS;IACb;;OAEG;IACH,KAAK,UAAU;IACf;;OAEG;IACH,OAAO,aAAa;CACrB;AAGD;;;;;;GAMG;AACH,oBAAY,MAAM;IAChB;;;;OAIG;IACH,IAAI,SAAS;IACb;;;OAGG;IACH,KAAK,UAAU;IACf;;;OAGG;IACH,OAAO,YAAY;IACnB;;;OAGG;IACH,aAAa,mBAAmB;CACjC;AAGD;;;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B,QAY9B;AAED,cAAc;AACd;;;;GAIG;AACH,MAAM,CAAN,IAAY,YAaX;AAbD,WAAY,YAAY;IACtB;;OAEG;IACH,6BAAa,CAAA;IACb;;OAEG;IACH,+BAAe,CAAA;IACf;;OAEG;IACH,oCAAoB,CAAA;AACtB,CAAC,EAbW,YAAY,KAAZ,YAAY,QAavB;AAED,cAAc;AACd;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,MAsBX;AAtBD,WAAY,MAAM;IAChB;;;;OAIG;IACH,uBAAa,CAAA;IACb;;;OAGG;IACH,yBAAe,CAAA;IACf;;;OAGG;IACH,6BAAmB,CAAA;IACnB;;;OAGG;IACH,0CAAgC,CAAA;AAClC,CAAC,EAtBW,MAAM,KAAN,MAAM,QAsBjB","sourcesContent":["import {
|
|
1
|
+
{"version":3,"file":"AuthRequest.types.js","sourceRoot":"","sources":["../src/AuthRequest.types.ts"],"names":[],"mappings":"AAIA,cAAc;AACd,MAAM,CAAN,IAAY,mBAYX;AAZD,WAAY,mBAAmB;IAC7B;;;;;OAKG;IACH,oCAAa,CAAA;IACb;;OAEG;IACH,sCAAe,CAAA;AACjB,CAAC,EAZW,mBAAmB,KAAnB,mBAAmB,QAY9B;AAED,cAAc;AACd;;;;GAIG;AACH,MAAM,CAAN,IAAY,YAaX;AAbD,WAAY,YAAY;IACtB;;OAEG;IACH,6BAAa,CAAA;IACb;;OAEG;IACH,+BAAe,CAAA;IACf;;OAEG;IACH,oCAAoB,CAAA;AACtB,CAAC,EAbW,YAAY,KAAZ,YAAY,QAavB;AAED,cAAc;AACd;;;;;;GAMG;AACH,MAAM,CAAN,IAAY,MAsBX;AAtBD,WAAY,MAAM;IAChB;;;;OAIG;IACH,uBAAa,CAAA;IACb;;;OAGG;IACH,yBAAe,CAAA;IACf;;;OAGG;IACH,6BAAmB,CAAA;IACnB;;;OAGG;IACH,0CAAgC,CAAA;AAClC,CAAC,EAtBW,MAAM,KAAN,MAAM,QAsBjB","sourcesContent":["import { AuthSessionOpenOptions, WebBrowserWindowFeatures } from 'expo-web-browser';\n\nimport { DiscoveryDocument } from './Discovery';\n\n// @needsAudit\nexport enum CodeChallengeMethod {\n /**\n * The default and recommended method for transforming the code verifier.\n * - Convert the code verifier to ASCII.\n * - Create a digest of the string using crypto method SHA256.\n * - Convert the digest to Base64 and URL encode it.\n */\n S256 = 'S256',\n /**\n * This should not be used. When used, the code verifier will be sent to the server as-is.\n */\n Plain = 'plain',\n}\n\n// @needsAudit\n/**\n * The client informs the authorization server of the desired grant type by using the response type.\n *\n * @see [Section 3.1.1](https://tools.ietf.org/html/rfc6749#section-3.1.1).\n */\nexport enum ResponseType {\n /**\n * For requesting an authorization code as described by [Section 4.1.1](https://tools.ietf.org/html/rfc6749#section-4.1.1).\n */\n Code = 'code',\n /**\n * For requesting an access token (implicit grant) as described by [Section 4.2.1](https://tools.ietf.org/html/rfc6749#section-4.2.1).\n */\n Token = 'token',\n /**\n * A custom registered type for getting an `id_token` from Google OAuth.\n */\n IdToken = 'id_token',\n}\n\n// @needsAudit\n/**\n * Informs the server if the user should be prompted to login or consent again.\n * This can be used to present a dialog for switching accounts after the user has already been logged in.\n * You should use this in favor of clearing cookies (which is mostly not possible on iOS).\n *\n * @see [Section 3.1.2.1](https://openid.net/specs/openid-connect-core-1_0.html#AuthorizationRequest).\n */\nexport enum Prompt {\n /**\n * Server must not display any auth or consent UI. Can be used to check for existing auth or consent.\n * An error is returned if a user isn't already authenticated or the client doesn't have pre-configured consent for the requested claims, or does not fulfill other conditions for processing the request.\n * The error code will typically be `login_required`, `interaction_required`, or another code defined in [Section 3.1.2.6](https://openid.net/specs/openid-connect-core-1_0.html#AuthError).\n */\n None = 'none',\n /**\n * The server should prompt the user to reauthenticate.\n * If it cannot reauthenticate the End-User, it must return an error, typically `login_required`.\n */\n Login = 'login',\n /**\n * Server should prompt the user for consent before returning information to the client.\n * If it cannot obtain consent, it must return an error, typically `consent_required`.\n */\n Consent = 'consent',\n /**\n * Server should prompt the user to select an account. Can be used to switch accounts.\n * If it can't obtain an account selection choice made by the user, it must return an error, typically `account_selection_required`.\n */\n SelectAccount = 'select_account',\n}\n\n// @needsAudit\n/**\n * Options passed to the `promptAsync()` method of `AuthRequest`s.\n * This can be used to configure how the web browser should look and behave.\n */\nexport type AuthRequestPromptOptions = Omit<AuthSessionOpenOptions, 'windowFeatures'> & {\n /**\n * URL to open when prompting the user. This usually should be defined internally and left `undefined` in most cases.\n */\n url?: string;\n /**\n * Features to use with `window.open()`.\n * @platform web\n */\n windowFeatures?: WebBrowserWindowFeatures;\n};\n\n// @needsAudit\n/**\n * Represents an OAuth authorization request as JSON.\n */\nexport type AuthRequestConfig = {\n /**\n * Specifies what is returned from the authorization server.\n *\n * [Section 3.1.1](https://tools.ietf.org/html/rfc6749#section-3.1.1)\n *\n * @default ResponseType.Code\n */\n responseType?: ResponseType | string;\n /**\n * A unique string representing the registration information provided by the client.\n * The client identifier is not a secret; it is exposed to the resource owner and shouldn't be used\n * alone for client authentication.\n *\n * The client identifier is unique to the authorization server.\n *\n * [Section 2.2](https://tools.ietf.org/html/rfc6749#section-2.2)\n */\n clientId: string;\n /**\n * After completing an interaction with a resource owner the\n * server will redirect to this URI. Learn more about [linking in Expo](/guides/linking/).\n *\n * [Section 3.1.2](https://tools.ietf.org/html/rfc6749#section-3.1.2)\n */\n redirectUri: string;\n /**\n * List of strings to request access to.\n *\n * [Section 3.3](https://tools.ietf.org/html/rfc6749#section-3.3)\n */\n scopes?: string[];\n /**\n * Client secret supplied by an auth provider.\n * There is no secure way to store this on the client.\n *\n * [Section 2.3.1](https://tools.ietf.org/html/rfc6749#section-2.3.1)\n */\n clientSecret?: string;\n /**\n * Method used to generate the code challenge. You should never use `Plain` as it's not good enough for secure verification.\n * @default CodeChallengeMethod.S256\n */\n codeChallengeMethod?: CodeChallengeMethod;\n /**\n * Derived from the code verifier by using the `CodeChallengeMethod`.\n *\n * [Section 4.2](https://tools.ietf.org/html/rfc7636#section-4.2)\n */\n codeChallenge?: string;\n /**\n * Informs the server if the user should be prompted to login or consent again.\n * This can be used to present a dialog for switching accounts after the user has already been logged in.\n *\n * [Section 3.1.2.1](https://openid.net/specs/openid-connect-core-1_0.html#AuthorizationRequest)\n */\n prompt?: Prompt | Prompt[];\n /**\n * Used for protection against [Cross-Site Request Forgery](https://tools.ietf.org/html/rfc6749#section-10.12).\n */\n state?: string;\n /**\n * Extra query params that'll be added to the query string.\n */\n extraParams?: Record<string, string>;\n /**\n * Should use [Proof Key for Code Exchange](https://oauth.net/2/pkce/).\n * @default true\n */\n usePKCE?: boolean;\n};\n\nexport type AuthDiscoveryDocument = Pick<DiscoveryDocument, 'authorizationEndpoint'>;\n"]}
|
|
@@ -44,11 +44,11 @@ export class SessionUrlProvider {
|
|
|
44
44
|
if (__DEV__) {
|
|
45
45
|
if (Constants.executionEnvironment === ExecutionEnvironment.Bare) {
|
|
46
46
|
nextSteps =
|
|
47
|
-
'
|
|
47
|
+
' Ensure you have the latest version of expo-constants installed and recompile your native app. You can verify that originalFullName is defined by running `npx expo config --type public` and inspecting the output.';
|
|
48
48
|
}
|
|
49
49
|
else if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {
|
|
50
50
|
nextSteps =
|
|
51
|
-
'
|
|
51
|
+
' Report this as a bug with the contents of `expo config --type public`: https://github.com/expo/expo/issues';
|
|
52
52
|
}
|
|
53
53
|
}
|
|
54
54
|
if (Constants.manifest2) {
|
|
@@ -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;AAE7C,MAAM,OAAO,kBAAkB;IACrB,MAAM,CAAU,QAAQ,GAAG,sBAAsB,CAAC;IAClD,MAAM,CAAU,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EAAE,CAAC,CAAC,CAAC,CAAC,CACnC,CAAC;QACJ,CAAC;QAAC,MAAM,CAAC,CAAA,CAAC;QAEV,OAAO,SAAS,CAAC;IACnB,CAAC;IAEO,MAAM,CAAC,eAAe,CAAC,EAAU,EAAE,GAAW;QACpD,IAAI,EAAE,CAAC,UAAU,CAAC,aAAa,CAAC,EAAE,CAAC;YACjC,OAAO,CAAC,IAAI,CACV,+HAA+H,GAAG,6TAA6T,CAChc,CAAC;QACJ,CAAC;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';\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 = new URLSearchParams({\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 ' Ensure you have the latest version of expo-constants installed and recompile your native app. You can verify that originalFullName is defined by running `npx expo config --type public` and inspecting the output.';\n } else if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {\n nextSteps =\n ' Report this as a bug with the contents of `expo config --type public`: https://github.com/expo/expo/issues';\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(): Record<string, string> | 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 Object.fromEntries(\n // @ts-ignore: [Symbol.iterator] is indeed, available on every platform.\n new URLSearchParams(uriParts?.[1])\n );\n } catch {}\n\n return undefined;\n }\n\n private static warnIfAnonymous(id: string, url: string): 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"]}
|
package/build/TokenRequest.d.ts
CHANGED
|
@@ -36,7 +36,11 @@ export declare class TokenResponse implements TokenResponseConfig {
|
|
|
36
36
|
state?: string;
|
|
37
37
|
idToken?: string;
|
|
38
38
|
issuedAt: number;
|
|
39
|
-
|
|
39
|
+
/**
|
|
40
|
+
* Contains the unprocessed token response. Use it to access properties which aren't part of RFC 6749.
|
|
41
|
+
* */
|
|
42
|
+
rawResponse?: unknown;
|
|
43
|
+
constructor(response: TokenResponseConfig, rawResponse?: unknown);
|
|
40
44
|
private applyResponseConfig;
|
|
41
45
|
getRequestConfig(): TokenResponseConfig;
|
|
42
46
|
refreshAsync(config: Omit<TokenRequestConfig, 'grantType' | 'refreshToken'>, discovery: Pick<ServiceConfig.DiscoveryDocument, 'tokenEndpoint'>): Promise<TokenResponse>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"TokenRequest.d.ts","sourceRoot":"","sources":["../src/TokenRequest.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,aAAa,MAA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,CAAC,aAAa,CAAC,EAAE,aAAa,CAAC;gBAE3B,OAAO,EAAE,wBAAwB;IAS7C,UAAU,IAAI,OAAO;IAerB;;;;OAIG;IACG,YAAY,CAAC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,iBAAiB,EAAE,oBAAoB,CAAC;IAczF,gBAAgB;;;;;;IAShB,YAAY,IAAI,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC;CAcvC;AAGD;;;;;;GAMG;AACH,wBAAgB,iBAAiB,CAC/B,MAAM,EAAE,wBAAwB,EAChC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,iBAAiB,EAAE,eAAe,CAAC,GAChE,OAAO,CAAC,aAAa,CAAC,CAGxB;AAGD;;;;;;;;;;;GAWG;AACH,wBAAgB,YAAY,CAC1B,MAAM,EAAE,yBAAyB,EACjC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,iBAAiB,EAAE,eAAe,CAAC,GAChE,OAAO,CAAC,aAAa,CAAC,CAGxB;AAGD;;;;;;GAMG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,wBAAwB,EAChC,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GACrE,OAAO,CAAC,OAAO,CAAC,CAGlB;AAED;;;;;;;GAOG;AACH,wBAAgB,kBAAkB,CAChC,MAAM,EAAE,IAAI,CAAC,aAAa,EAAE,aAAa,CAAC,EAC1C,SAAS,EAAE,IAAI,CAAC,aAAa,CAAC,iBAAiB,EAAE,kBAAkB,CAAC,GACnE,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC,CAY9B"}
|
package/build/TokenRequest.js
CHANGED
|
@@ -62,7 +62,12 @@ export class TokenResponse {
|
|
|
62
62
|
state;
|
|
63
63
|
idToken;
|
|
64
64
|
issuedAt;
|
|
65
|
-
|
|
65
|
+
/**
|
|
66
|
+
* Contains the unprocessed token response. Use it to access properties which aren't part of RFC 6749.
|
|
67
|
+
* */
|
|
68
|
+
rawResponse;
|
|
69
|
+
constructor(response, rawResponse) {
|
|
70
|
+
this.rawResponse = rawResponse;
|
|
66
71
|
this.accessToken = response.accessToken;
|
|
67
72
|
this.tokenType = response.tokenType ?? 'bearer';
|
|
68
73
|
this.expiresIn = response.expiresIn;
|
|
@@ -176,7 +181,7 @@ export class TokenRequest extends Request {
|
|
|
176
181
|
scope: response.scope,
|
|
177
182
|
idToken: response.id_token,
|
|
178
183
|
issuedAt: response.issued_at,
|
|
179
|
-
});
|
|
184
|
+
}, response);
|
|
180
185
|
}
|
|
181
186
|
getQueryBody() {
|
|
182
187
|
const queryBody = {
|
|
@@ -1 +1 @@
|
|
|
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,CAAC;YACX,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YACpB,MAAM,GAAG,GAAG,uBAAuB,EAAE,CAAC;YACt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;;;;;;;;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,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,4EAA4E,CAAC,CAAC;IAChG,CAAC;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\nexport class 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 */\nexport class TokenRequest<T extends TokenRequestConfig>\n extends Request<T, TokenResponse>\n implements TokenRequestConfig\n{\n readonly clientId: string;\n readonly clientSecret?: string;\n readonly scopes?: string[];\n readonly extraParams?: Record<string, string>;\n\n constructor(\n request: T,\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
|
+
{"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,CAAC;YACX,OAAO,KAAK,CAAC;QACf,CAAC;QACD,IAAI,KAAK,CAAC,SAAS,EAAE,CAAC;YACpB,MAAM,GAAG,GAAG,uBAAuB,EAAE,CAAC;YACtC,OAAO,GAAG,GAAG,KAAK,CAAC,QAAQ,GAAG,KAAK,CAAC,SAAS,GAAG,aAAa,CAAC;QAChE,CAAC;QACD,4FAA4F;QAC5F,OAAO,IAAI,CAAC;IACd,CAAC;IACD;;;;OAIG;IACH,MAAM,CAAC,eAAe,CAAC,MAA2B;QAChD,OAAO,IAAI,aAAa,CAAC;YACvB,WAAW,EAAE,MAAM,CAAC,YAAY;YACh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,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,CAAC;QAChC,MAAM,IAAI,KAAK,CAAC,4EAA4E,CAAC,CAAC;IAChG,CAAC;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 * Contains the unprocessed token response. Use it to access properties which aren't part of RFC 6749.\n * */\n rawResponse?: unknown;\n\n constructor(response: TokenResponseConfig, rawResponse?: unknown) {\n this.rawResponse = rawResponse;\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\nexport class 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 */\nexport class TokenRequest<T extends TokenRequestConfig>\n extends Request<T, TokenResponse>\n implements TokenRequestConfig\n{\n readonly clientId: string;\n readonly clientSecret?: string;\n readonly scopes?: string[];\n readonly extraParams?: Record<string, string>;\n\n constructor(\n request: T,\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 {\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 response\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"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-auth-session",
|
|
3
|
-
"version": "6.
|
|
3
|
+
"version": "6.2.0",
|
|
4
4
|
"description": "Expo module for browser-based authentication",
|
|
5
5
|
"main": "build/index.js",
|
|
6
6
|
"types": "build/index.d.ts",
|
|
@@ -34,15 +34,15 @@
|
|
|
34
34
|
"license": "MIT",
|
|
35
35
|
"homepage": "https://docs.expo.dev/versions/latest/sdk/auth-session",
|
|
36
36
|
"dependencies": {
|
|
37
|
-
"expo-application": "~6.1.
|
|
38
|
-
"expo-constants": "~17.1.
|
|
39
|
-
"expo-crypto": "~14.1.
|
|
40
|
-
"expo-linking": "~7.1.
|
|
41
|
-
"expo-web-browser": "~14.1.
|
|
37
|
+
"expo-application": "~6.1.4",
|
|
38
|
+
"expo-constants": "~17.1.6",
|
|
39
|
+
"expo-crypto": "~14.1.4",
|
|
40
|
+
"expo-linking": "~7.1.5",
|
|
41
|
+
"expo-web-browser": "~14.1.6",
|
|
42
42
|
"invariant": "^2.2.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"expo-module-scripts": "^4.1.
|
|
45
|
+
"expo-module-scripts": "^4.1.7"
|
|
46
46
|
},
|
|
47
47
|
"peerDependencies": {
|
|
48
48
|
"react": "*",
|
|
@@ -51,5 +51,5 @@
|
|
|
51
51
|
"jest": {
|
|
52
52
|
"preset": "expo-module-scripts"
|
|
53
53
|
},
|
|
54
|
-
"gitHead": "
|
|
54
|
+
"gitHead": "7638c800b57fe78f57cc7f129022f58e84a523c5"
|
|
55
55
|
}
|
package/src/AuthRequest.types.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AuthSessionOpenOptions, WebBrowserWindowFeatures } from 'expo-web-browser';
|
|
2
2
|
|
|
3
3
|
import { DiscoveryDocument } from './Discovery';
|
|
4
4
|
|
|
@@ -75,7 +75,7 @@ export enum Prompt {
|
|
|
75
75
|
* Options passed to the `promptAsync()` method of `AuthRequest`s.
|
|
76
76
|
* This can be used to configure how the web browser should look and behave.
|
|
77
77
|
*/
|
|
78
|
-
export type AuthRequestPromptOptions = Omit<
|
|
78
|
+
export type AuthRequestPromptOptions = Omit<AuthSessionOpenOptions, 'windowFeatures'> & {
|
|
79
79
|
/**
|
|
80
80
|
* URL to open when prompting the user. This usually should be defined internally and left `undefined` in most cases.
|
|
81
81
|
*/
|
|
@@ -55,10 +55,10 @@ export class SessionUrlProvider {
|
|
|
55
55
|
if (__DEV__) {
|
|
56
56
|
if (Constants.executionEnvironment === ExecutionEnvironment.Bare) {
|
|
57
57
|
nextSteps =
|
|
58
|
-
'
|
|
58
|
+
' Ensure you have the latest version of expo-constants installed and recompile your native app. You can verify that originalFullName is defined by running `npx expo config --type public` and inspecting the output.';
|
|
59
59
|
} else if (Constants.executionEnvironment === ExecutionEnvironment.StoreClient) {
|
|
60
60
|
nextSteps =
|
|
61
|
-
'
|
|
61
|
+
' Report this as a bug with the contents of `expo config --type public`: https://github.com/expo/expo/issues';
|
|
62
62
|
}
|
|
63
63
|
}
|
|
64
64
|
|
package/src/TokenRequest.ts
CHANGED
|
@@ -79,8 +79,13 @@ export class TokenResponse implements TokenResponseConfig {
|
|
|
79
79
|
state?: string;
|
|
80
80
|
idToken?: string;
|
|
81
81
|
issuedAt: number;
|
|
82
|
+
/**
|
|
83
|
+
* Contains the unprocessed token response. Use it to access properties which aren't part of RFC 6749.
|
|
84
|
+
* */
|
|
85
|
+
rawResponse?: unknown;
|
|
82
86
|
|
|
83
|
-
constructor(response: TokenResponseConfig) {
|
|
87
|
+
constructor(response: TokenResponseConfig, rawResponse?: unknown) {
|
|
88
|
+
this.rawResponse = rawResponse;
|
|
84
89
|
this.accessToken = response.accessToken;
|
|
85
90
|
this.tokenType = response.tokenType ?? 'bearer';
|
|
86
91
|
this.expiresIn = response.expiresIn;
|
|
@@ -211,15 +216,18 @@ export class TokenRequest<T extends TokenRequestConfig>
|
|
|
211
216
|
throw new TokenError(response);
|
|
212
217
|
}
|
|
213
218
|
|
|
214
|
-
return new TokenResponse(
|
|
215
|
-
|
|
216
|
-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
219
|
+
return new TokenResponse(
|
|
220
|
+
{
|
|
221
|
+
accessToken: response.access_token,
|
|
222
|
+
tokenType: response.token_type,
|
|
223
|
+
expiresIn: response.expires_in,
|
|
224
|
+
refreshToken: response.refresh_token,
|
|
225
|
+
scope: response.scope,
|
|
226
|
+
idToken: response.id_token,
|
|
227
|
+
issuedAt: response.issued_at,
|
|
228
|
+
},
|
|
229
|
+
response
|
|
230
|
+
);
|
|
223
231
|
}
|
|
224
232
|
|
|
225
233
|
getQueryBody() {
|