expo-auth-session 6.1.1 → 6.1.2
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 +6 -0
- package/build/Errors.d.ts +1 -1
- package/build/Errors.d.ts.map +1 -1
- package/build/Errors.js.map +1 -1
- package/build/Fetch.d.ts.map +1 -1
- package/build/Fetch.js +6 -4
- package/build/Fetch.js.map +1 -1
- package/build/SessionUrlProvider.js.map +1 -1
- package/build/TokenRequest.d.ts +2 -2
- package/build/TokenRequest.d.ts.map +1 -1
- package/build/TokenRequest.js.map +1 -1
- package/build/providers/Facebook.d.ts.map +1 -1
- package/build/providers/Facebook.js +4 -2
- package/build/providers/Facebook.js.map +1 -1
- package/build/providers/Google.d.ts.map +1 -1
- package/build/providers/Google.js.map +1 -1
- package/build/providers/ProviderUtils.d.ts +1 -1
- package/build/providers/ProviderUtils.d.ts.map +1 -1
- package/build/providers/ProviderUtils.js.map +1 -1
- package/package.json +8 -8
- package/src/Errors.ts +3 -3
- package/src/Fetch.ts +7 -5
- package/src/SessionUrlProvider.ts +1 -1
- package/src/TokenRequest.ts +5 -2
- package/src/providers/Facebook.ts +6 -4
- package/src/providers/Google.ts +3 -4
- package/src/providers/ProviderUtils.ts +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -10,6 +10,12 @@
|
|
|
10
10
|
|
|
11
11
|
### 💡 Others
|
|
12
12
|
|
|
13
|
+
## 6.1.2 — 2025-04-14
|
|
14
|
+
|
|
15
|
+
### 🐛 Bug fixes
|
|
16
|
+
|
|
17
|
+
- Fix `clientId` not being asserted properly if it's `undefined` in `providers/Facebook`, like it is for `providers/Google`
|
|
18
|
+
|
|
13
19
|
## 6.1.1 — 2025-04-09
|
|
14
20
|
|
|
15
21
|
_This version does not introduce any user-facing changes._
|
package/build/Errors.d.ts
CHANGED
|
@@ -41,7 +41,7 @@ export declare class ResponseError extends CodedError {
|
|
|
41
41
|
* Raw results of the error.
|
|
42
42
|
*/
|
|
43
43
|
params: Record<string, string>;
|
|
44
|
-
constructor(params: ResponseErrorConfig, errorCodeType:
|
|
44
|
+
constructor(params: ResponseErrorConfig, errorCodeType: 'auth' | 'token');
|
|
45
45
|
}
|
|
46
46
|
/**
|
|
47
47
|
* Represents an authorization response error: [Section 5.2](https://tools.ietf.org/html/rfc6749#section-5.2).
|
package/build/Errors.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Errors.d.ts","sourceRoot":"","sources":["../src/Errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;IACtD;;OAEG;IACH,KAAK,EAAE,MAAM,CAAC;IACd;;OAEG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B;;OAEG;IACH,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAAC;AAEF,MAAM,MAAM,eAAe,GAAG,mBAAmB,GAAG;IAClD;;OAEG;IACH,KAAK,CAAC,EAAE,MAAM,CAAC;CAChB,CAAC;AA6CF;;GAEG;AACH,qBAAa,aAAc,SAAQ,UAAU;IAC3C;;;OAGG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;;;OAIG;IACH,GAAG,CAAC,EAAE,MAAM,CAAC;IACb;;OAEG;IACH,MAAM,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;gBAEnB,MAAM,EAAE,mBAAmB,EAAE,aAAa,EAAE,MAAM;
|
|
1
|
+
{"version":3,"file":"Errors.d.ts","sourceRoot":"","sources":["../src/Errors.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,mBAAmB,CAAC;AAE/C;;GAEG;AACH,MAAM,MAAM,mBAAmB,GAAG,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAAG;IACt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;IACrB;;;;OAIG;IACH,GAAG,CAAU;IACb;;OAEG;IACH,MAAM,CAAyB;IAE/B,YAAY,MAA2B,EAAE,aAA+B;QACtE,MAAM,EAAE,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,GAAG,MAAM,CAAC;QACvD,MAAM,OAAO,GAAG,iBAAiB,CAAC,aAAa,CAAC,CAAC,KAAK,CAAC,CAAC;QACxD,IAAI,YAAoB,CAAC;QACzB,IAAI,OAAO,EAAE,CAAC;YACZ,YAAY,GAAG,OAAO,GAAG,CAAC,iBAAiB,CAAC,CAAC,CAAC,gBAAgB,iBAAiB,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC;QAC1F,CAAC;aAAM,IAAI,iBAAiB,EAAE,CAAC;YAC7B,YAAY,GAAG,iBAAiB,CAAC;QACnC,CAAC;aAAM,CAAC;YACN,YAAY,GAAG,2BAA2B,CAAC;QAC7C,CAAC;QACD,KAAK,CAAC,KAAK,EAAE,YAAY,CAAC,CAAC;QAC3B,IAAI,CAAC,WAAW,GAAG,iBAAiB,IAAI,OAAO,CAAC;QAChD,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC;QACrB,IAAI,CAAC,MAAM,GAAG,MAAM,CAAC;IACvB,CAAC;CACF;AAED,cAAc;AACd;;;;GAIG;AACH,MAAM,OAAO,SAAU,SAAQ,aAAa;IAC1C;;OAEG;IACH,KAAK,CAAU;IAEf,YAAY,QAAyB;QACnC,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;QACxB,IAAI,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC;IAC9B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,UAAW,SAAQ,aAAa;IAC3C,YAAY,QAA6B;QACvC,KAAK,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAC;IAC3B,CAAC;CACF","sourcesContent":["import { CodedError } from 'expo-modules-core';\n\n/**\n * Server response error.\n */\nexport type ResponseErrorConfig = Record<string, any> & {\n /**\n * Error code\n */\n error: string;\n /**\n * Additional message\n */\n error_description?: string;\n /**\n * URI for more info on the error\n */\n error_uri?: string;\n};\n\nexport type AuthErrorConfig = ResponseErrorConfig & {\n /**\n * Required only if state is used in the initial request\n */\n state?: string;\n};\n\nconst errorCodeMessages = {\n // https://tools.ietf.org/html/rfc6749#section-4.1.2.1\n // https://openid.net/specs/openid-connect-core-1_0.html#AuthError\n auth: {\n // OAuth 2.0\n invalid_request: `The request is missing a required parameter, includes an invalid parameter value, includes a parameter more than once, or is otherwise malformed.`,\n unauthorized_client: `The client is not authorized to request an authorization code using this method.`,\n access_denied: `The resource owner or authorization server denied the request.`,\n unsupported_response_type: `The authorization server does not support obtaining an authorization code using this method.`,\n invalid_scope: 'The requested scope is invalid, unknown, or malformed.',\n server_error:\n 'The authorization server encountered an unexpected condition that prevented it from fulfilling the request. (This error code is needed because a 500 Internal Server Error HTTP status code cannot be returned to the client via an HTTP redirect.)',\n temporarily_unavailable:\n 'The authorization server is currently unable to handle the request due to a temporary overloading or maintenance of the server. (This error code is needed because a 503 Service Unavailable HTTP status code cannot be returned to the client via an HTTP redirect.)',\n // Open ID Connect error codes\n interaction_required:\n 'Auth server requires user interaction of some form to proceed. This error may be returned when the prompt parameter value in the auth request is none, but the auth request cannot be completed without displaying a user interface for user interaction.',\n login_required:\n 'Auth server requires user authentication. This error may be returned when the prompt parameter value in the auth request is none, but the auth request cannot be completed without displaying a user interface for user authentication.',\n account_selection_required:\n 'User is required to select a session at the auth server. The user may be authenticated at the auth server with different associated accounts, but the user did not select a session. This error may be returned when the prompt parameter value in the auth request is `none`, but the auth request cannot be completed without displaying a user interface to prompt for a session to use.',\n consent_required:\n 'Auth server requires user consent. This error may be returned when the prompt parameter value in the auth request is none, but the auth request cannot be completed without displaying a user interface for user consent.',\n invalid_request_uri:\n 'The `request_uri` in the auth request returns an error or contains invalid data.',\n invalid_request_object: 'The request parameter contains an invalid request object.',\n request_not_supported:\n 'The OP does not support use of the `request` parameter defined in Section 6. (https://openid.net/specs/openid-connect-core-1_0.html#JWTRequests)',\n request_uri_not_supported:\n 'The OP does not support use of the `request_uri` parameter defined in Section 6. (https://openid.net/specs/openid-connect-core-1_0.html#JWTRequests)',\n registration_not_supported:\n 'The OP does not support use of the `registration` parameter defined in Section 7.2.1. (https://openid.net/specs/openid-connect-core-1_0.html#RegistrationParameter)',\n } as Record<string, string | undefined>,\n // https://tools.ietf.org/html/rfc6749#section-5.2\n token: {\n invalid_request: `The request is missing a required parameter, includes an unsupported parameter value (other than grant type), repeats a parameter, includes multiple credentials, utilizes more than one mechanism for authenticating the client, or is otherwise malformed.`,\n invalid_client: `Client authentication failed (e.g., unknown client, no client authentication included, or unsupported authentication method). The authorization server MAY return an HTTP 401 (Unauthorized) status code to indicate which HTTP authentication schemes are supported. If the client attempted to authenticate via the \"Authorization\" request header field, the authorization server MUST respond with an HTTP 401 (Unauthorized) status code and include the \"WWW-Authenticate\" response header field matching the authentication scheme used by the client.`,\n invalid_grant: `The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.`,\n unauthorized_client: `The authenticated client is not authorized to use this authorization grant type.`,\n unsupported_grant_type: `The authorization grant type is not supported by the authorization server.`,\n } as Record<string, string | undefined>,\n};\n\n/**\n * [Section 4.1.2.1](https://tools.ietf.org/html/rfc6749#section-4.1.2.1)\n */\nexport class ResponseError extends CodedError {\n /**\n * Used to assist the client developer in\n * understanding the error that occurred.\n */\n description?: string;\n /**\n * A URI identifying a human-readable web page with\n * information about the error, used to provide the client\n * developer with additional information about the error.\n */\n uri?: string;\n /**\n * Raw results of the error.\n */\n params: Record<string, string>;\n\n constructor(params: ResponseErrorConfig, errorCodeType: 'auth' | 'token') {\n const { error, error_description, error_uri } = params;\n const message = errorCodeMessages[errorCodeType][error];\n let errorMessage: string;\n if (message) {\n errorMessage = message + (error_description ? `\\nMore info: ${error_description}` : '');\n } else if (error_description) {\n errorMessage = error_description;\n } else {\n errorMessage = 'An unknown error occurred';\n }\n super(error, errorMessage);\n this.description = error_description ?? message;\n this.uri = error_uri;\n this.params = params;\n }\n}\n\n// @needsAudit\n/**\n * Represents an authorization response error: [Section 5.2](https://tools.ietf.org/html/rfc6749#section-5.2).\n * Often times providers will fail to return the proper error message for a given error code.\n * This error method will add the missing description for more context on what went wrong.\n */\nexport class AuthError extends ResponseError {\n /**\n * Required only if state is used in the initial request\n */\n state?: string;\n\n constructor(response: AuthErrorConfig) {\n super(response, 'auth');\n this.state = response.state;\n }\n}\n\n/**\n * [Section 4.1.2.1](https://tools.ietf.org/html/rfc6749#section-4.1.2.1)\n */\nexport class TokenError extends ResponseError {\n constructor(response: ResponseErrorConfig) {\n super(response, 'token');\n }\n}\n"]}
|
package/build/Fetch.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Fetch.d.ts","sourceRoot":"","sources":["../src/Fetch.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAsB,YAAY,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,
|
|
1
|
+
{"version":3,"file":"Fetch.d.ts","sourceRoot":"","sources":["../src/Fetch.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,OAAO,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,GAAG;IAC7C,cAAc,EAAE,MAAM,CAAC;IACvB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,MAAM,MAAM,YAAY,GAAG;IACzB,OAAO,CAAC,EAAE,OAAO,CAAC;IAClB,IAAI,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB,CAAC;AAEF,wBAAsB,YAAY,CAAC,CAAC,EAAE,UAAU,EAAE,MAAM,EAAE,YAAY,EAAE,YAAY,GAAG,OAAO,CAAC,CAAC,CAAC,CA+ChG"}
|
package/build/Fetch.js
CHANGED
|
@@ -1,15 +1,17 @@
|
|
|
1
1
|
export async function requestAsync(requestUrl, fetchRequest) {
|
|
2
2
|
const url = new URL(requestUrl);
|
|
3
|
+
const headers = {};
|
|
3
4
|
const request = {
|
|
5
|
+
body: undefined,
|
|
4
6
|
method: fetchRequest.method,
|
|
5
7
|
mode: 'cors',
|
|
6
|
-
headers
|
|
8
|
+
headers,
|
|
7
9
|
};
|
|
8
10
|
const isJsonDataType = fetchRequest.dataType?.toLowerCase() === 'json';
|
|
9
11
|
if (fetchRequest.headers) {
|
|
10
12
|
for (const i in fetchRequest.headers) {
|
|
11
13
|
if (i in fetchRequest.headers) {
|
|
12
|
-
|
|
14
|
+
headers[i] = fetchRequest.headers[i];
|
|
13
15
|
}
|
|
14
16
|
}
|
|
15
17
|
}
|
|
@@ -23,9 +25,9 @@ export async function requestAsync(requestUrl, fetchRequest) {
|
|
|
23
25
|
}
|
|
24
26
|
}
|
|
25
27
|
}
|
|
26
|
-
if (isJsonDataType && !
|
|
28
|
+
if (isJsonDataType && !headers.Accept && !headers.accept) {
|
|
27
29
|
// NOTE: Github authentication will return XML if this includes the standard `*/*`
|
|
28
|
-
|
|
30
|
+
headers['Accept'] = 'application/json, text/javascript; q=0.01';
|
|
29
31
|
}
|
|
30
32
|
// Fix a problem with React Native `URL` causing a trailing slash to be added.
|
|
31
33
|
const correctedUrl = url.toString().replace(/\/$/, '');
|
package/build/Fetch.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Fetch.js","sourceRoot":"","sources":["../src/Fetch.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,KAAK,UAAU,YAAY,CAAI,UAAkB,EAAE,YAA0B;IAClF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;IAEhC,MAAM,OAAO,
|
|
1
|
+
{"version":3,"file":"Fetch.js","sourceRoot":"","sources":["../src/Fetch.ts"],"names":[],"mappings":"AAaA,MAAM,CAAC,KAAK,UAAU,YAAY,CAAI,UAAkB,EAAE,YAA0B;IAClF,MAAM,GAAG,GAAG,IAAI,GAAG,CAAC,UAAU,CAAC,CAAC;IAEhC,MAAM,OAAO,GAA2B,EAAE,CAAC;IAC3C,MAAM,OAAO,GAAgB;QAC3B,IAAI,EAAE,SAAS;QACf,MAAM,EAAE,YAAY,CAAC,MAAM;QAC3B,IAAI,EAAE,MAAM;QACZ,OAAO;KACR,CAAC;IAEF,MAAM,cAAc,GAAG,YAAY,CAAC,QAAQ,EAAE,WAAW,EAAE,KAAK,MAAM,CAAC;IAEvE,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;QACzB,KAAK,MAAM,CAAC,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;YACrC,IAAI,CAAC,IAAI,YAAY,CAAC,OAAO,EAAE,CAAC;gBAC9B,OAAO,CAAC,CAAC,CAAC,GAAG,YAAY,CAAC,OAAO,CAAC,CAAC,CAAC,CAAC;YACvC,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,YAAY,CAAC,IAAI,EAAE,CAAC;QACtB,IAAI,YAAY,CAAC,MAAM,EAAE,WAAW,EAAE,KAAK,MAAM,EAAE,CAAC;YAClD,OAAO,CAAC,IAAI,GAAG,IAAI,eAAe,CAAC,YAAY,CAAC,IAAI,CAAC,CAAC,QAAQ,EAAE,CAAC;QACnE,CAAC;aAAM,CAAC;YACN,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,EAAE,CAAC;gBACjD,GAAG,CAAC,YAAY,CAAC,MAAM,CAAC,GAAG,EAAE,YAAY,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,CAAC;YACvD,CAAC;QACH,CAAC;IACH,CAAC;IAED,IAAI,cAAc,IAAI,CAAC,OAAO,CAAC,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;QACzD,kFAAkF;QAClF,OAAO,CAAC,QAAQ,CAAC,GAAG,2CAA2C,CAAC;IAClE,CAAC;IAED,8EAA8E;IAC9E,MAAM,YAAY,GAAG,GAAG,CAAC,QAAQ,EAAE,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;IAEvD,MAAM,QAAQ,GAAG,MAAM,KAAK,CAAC,YAAY,EAAE,OAAO,CAAC,CAAC;IAEpD,MAAM,WAAW,GAAG,QAAQ,CAAC,OAAO,CAAC,GAAG,CAAC,cAAc,CAAC,CAAC;IACzD,IAAI,cAAc,IAAI,WAAW,EAAE,QAAQ,CAAC,kBAAkB,CAAC,EAAE,CAAC;QAChE,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;IACzB,CAAC;IACD,2DAA2D;IAC3D,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAC;AACzB,CAAC","sourcesContent":["export type Headers = Record<string, string> & {\n 'Content-Type': string;\n Authorization?: string;\n Accept?: string;\n};\n\nexport type FetchRequest = {\n headers?: Headers;\n body?: Record<string, string>;\n dataType?: string;\n method?: string;\n};\n\nexport async function requestAsync<T>(requestUrl: string, fetchRequest: FetchRequest): Promise<T> {\n const url = new URL(requestUrl);\n\n const headers: Record<string, string> = {};\n const request: RequestInit = {\n body: undefined,\n method: fetchRequest.method,\n mode: 'cors',\n headers,\n };\n\n const isJsonDataType = fetchRequest.dataType?.toLowerCase() === 'json';\n\n if (fetchRequest.headers) {\n for (const i in fetchRequest.headers) {\n if (i in fetchRequest.headers) {\n headers[i] = fetchRequest.headers[i];\n }\n }\n }\n\n if (fetchRequest.body) {\n if (fetchRequest.method?.toUpperCase() === 'POST') {\n request.body = new URLSearchParams(fetchRequest.body).toString();\n } else {\n for (const key of Object.keys(fetchRequest.body)) {\n url.searchParams.append(key, fetchRequest.body[key]);\n }\n }\n }\n\n if (isJsonDataType && !headers.Accept && !headers.accept) {\n // NOTE: Github authentication will return XML if this includes the standard `*/*`\n headers['Accept'] = 'application/json, text/javascript; q=0.01';\n }\n\n // Fix a problem with React Native `URL` causing a trailing slash to be added.\n const correctedUrl = url.toString().replace(/\\/$/, '');\n\n const response = await fetch(correctedUrl, request);\n\n const contentType = response.headers.get('content-type');\n if (isJsonDataType || contentType?.includes('application/json')) {\n return response.json();\n }\n // @ts-ignore: Type 'string' is not assignable to type 'T'.\n return response.text();\n}\n"]}
|
|
@@ -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,YAAY,GAAG,mBAAmB,CAAC;IAE3D,mBAAmB,CACjB,OAAgB,EAChB,OAAuD;QAEvD,MAAM,WAAW,GAAG,kBAAkB,CAAC,yBAAyB,EAAE,CAAC;QACnE,IAAI,IAAI,GAAG,kBAAkB,CAAC,YAAY,CAAC;QAC3C,I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AAwE;YACxE,IAAI,eAAe,CAAC,QAAQ,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 ' 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(): 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
|
@@ -52,13 +52,13 @@ export declare class Request<T, B> {
|
|
|
52
52
|
/**
|
|
53
53
|
* A generic token request.
|
|
54
54
|
*/
|
|
55
|
-
export declare class TokenRequest<T extends TokenRequestConfig> extends Request<T, TokenResponse> {
|
|
55
|
+
export declare class TokenRequest<T extends TokenRequestConfig> extends Request<T, TokenResponse> implements TokenRequestConfig {
|
|
56
56
|
grantType: GrantType;
|
|
57
57
|
readonly clientId: string;
|
|
58
58
|
readonly clientSecret?: string;
|
|
59
59
|
readonly scopes?: string[];
|
|
60
60
|
readonly extraParams?: Record<string, string>;
|
|
61
|
-
constructor(request:
|
|
61
|
+
constructor(request: T, grantType: GrantType);
|
|
62
62
|
getHeaders(): Headers;
|
|
63
63
|
performAsync(discovery: Pick<ServiceConfig.DiscoveryDocument, 'tokenEndpoint'>): Promise<TokenResponse>;
|
|
64
64
|
getQueryBody(): Record<string, string>;
|
|
@@ -1 +1 @@
|
|
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AAY,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,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> 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
|
+
{"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;YACv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,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 +1 @@
|
|
|
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,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAgB,MAAM,sBAAsB,CAAC;AAGjG,OAAO,EAAE,6BAA6B,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AASjD,eAAO,MAAM,SAAS,EAAE,iBAGvB,CAAC;AAGF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,yBAAyB,GAAG;IAClE;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAGF;;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,
|
|
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,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAAE,iBAAiB,EAAE,wBAAwB,EAAgB,MAAM,sBAAsB,CAAC;AAGjG,OAAO,EAAE,6BAA6B,EAAE,iBAAiB,EAAE,MAAM,sBAAsB,CAAC;AACxF,OAAO,EAAE,iBAAiB,EAAE,MAAM,cAAc,CAAC;AASjD,eAAO,MAAM,SAAS,EAAE,iBAGvB,CAAC;AAGF;;GAEG;AACH,MAAM,MAAM,yBAAyB,GAAG,yBAAyB,GAAG;IAClE;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB;;OAEG;IACH,eAAe,CAAC,EAAE,MAAM,CAAC;CAC1B,CAAC;AAGF;;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,CAiDA"}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { useMemo } from 'react';
|
|
2
2
|
import { Platform } from 'react-native';
|
|
3
|
-
import { applyRequiredScopes } from './ProviderUtils';
|
|
3
|
+
import { applyRequiredScopes, invariantClientId } from './ProviderUtils';
|
|
4
4
|
import { AuthRequest } from '../AuthRequest';
|
|
5
5
|
import { ResponseType } from '../AuthRequest.types';
|
|
6
6
|
import { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';
|
|
@@ -84,7 +84,9 @@ export function useAuthRequest(config = {}, redirectUriOptions = {}) {
|
|
|
84
84
|
android: 'androidClientId',
|
|
85
85
|
default: 'webClientId',
|
|
86
86
|
});
|
|
87
|
-
|
|
87
|
+
const clientId = config[propertyName] ?? config.clientId;
|
|
88
|
+
invariantClientId(propertyName, clientId, 'Facebook');
|
|
89
|
+
return clientId;
|
|
88
90
|
}, [config.iosClientId, config.androidClientId, config.webClientId, config.clientId]);
|
|
89
91
|
const redirectUri = useMemo(() => {
|
|
90
92
|
if (typeof config.redirectUri !== 'undefined') {
|
|
@@ -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,mBAAmB,EAAE,MAAM,iBAAiB,CAAC;
|
|
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,iBAAiB,EAAE,MAAM,iBAAiB,CAAC;AACzE,OAAO,EAAE,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAA+C,YAAY,EAAE,MAAM,sBAAsB,CAAC;AACjG,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AAEjD,MAAM,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Ac;YACnC,GAAG,kBAAkB;SACtB,CAAC,CAAC;IACL,CAAC,EAAE,CAAC,QAAQ,EAAE,MAAM,CAAC,WAAW,EAAE,kBAAkB,CAAC,CAAC,CAAC;IAEvD,MAAM,WAAW,GAAG,OAAO,CAAC,GAA6C,EAAE;QACzE,MAAM,MAAM,GAAG,MAAM,CAAC,WAAW,CAAC,CAAC,CAAC,EAAE,GAAG,MAAM,CAAC,WAAW,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;QAEnE,IAAI,MAAM,CAAC,QAAQ,EAAE,CAAC;YACpB,MAAM,CAAC,MAAM,GAAG,MAAM,CAAC,QAAQ,CAAC;QAClC,CAAC;QACD,OAAO,MAAM,CAAC;IAChB,CAAC,EAAE,CAAC,MAAM,CAAC,WAAW,EAAE,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;IAE1C,MAAM,OAAO,GAAG,oBAAoB,CAClC;QACE,GAAG,MAAM;QACT,WAAW;QACX,QAAQ;QACR,WAAW;KACZ,EACD,SAAS,EACT,mBAAmB,CACpB,CAAC;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, invariantClientId } from './ProviderUtils';\nimport { AuthRequest } from '../AuthRequest';\nimport { AuthRequestConfig, AuthRequestPromptOptions, ResponseType } from '../AuthRequest.types';\nimport { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';\nimport { makeRedirectUri } from '../AuthSession';\nimport { AuthSessionRedirectUriOptions, AuthSessionResult } from '../AuthSession.types';\nimport { DiscoveryDocument } from '../Discovery';\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 type FacebookAuthRequestConfig = 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\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(() => {\n const propertyName = Platform.select({\n ios: 'iosClientId',\n android: 'androidClientId',\n default: 'webClientId',\n } as const);\n const clientId = config[propertyName] ?? config.clientId;\n invariantClientId(propertyName, clientId, 'Facebook');\n return clientId;\n }, [config.iosClientId, config.androidClientId, config.webClientId, config.clientId]);\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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"Google.d.ts","sourceRoot":"","sources":["../../src/providers/Google.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,yBAAyB,EAAE,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C;YACN,aAAa,CAAC,MAAM,CAAC,CAAC;QACxB,CAAC;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 { AuthRequest } from '../AuthRequest';\nimport {\n AuthRequestConfig,\n AuthRequestPromptOptions,\n Prompt,\n ResponseType,\n} from '../AuthRequest.types';\nimport { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';\nimport { makeRedirectUri } from '../AuthSession';\nimport { AuthSessionRedirectUriOptions, AuthSessionResult } from '../AuthSession.types';\nimport { DiscoveryDocument } from '../Discovery';\nimport { generateHexStringAsync } from '../PKCE';\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 type GoogleAuthRequestConfig = 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 * 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 }, [config.iosClientId, config.androidClientId, config.webClientId, config.clientId]);\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,WAAW,EAAE,MAAM,gBAAgB,CAAC;AAC7C,OAAO,EAGL,MAAM,EACN,YAAY,GACb,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,MAAM,qBAAqB,CAAC;AACjF,OAAO,EAAE,eAAe,EAAE,MAAM,gBAAgB,CAAC;AAGjD,OAAO,EAAE,sBAAsB,EAAE,MAAM,SAAS,CAAC;AACjD,OAAO,EAAE,kBAAkB,EAAE,MAAM,iBAAiB,CAAC;AAErD,MAAM,QAAQ,GAAG;IACf,cAAc,EAAE,EAAE,KAAK,EAAE,GAAG,EAAE,MAAM,EAAE,GAAG,EAAE;IAC3C,aA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AAC;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 { AuthRequest } from '../AuthRequest';\nimport {\n AuthRequestConfig,\n AuthRequestPromptOptions,\n Prompt,\n ResponseType,\n} from '../AuthRequest.types';\nimport { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';\nimport { makeRedirectUri } from '../AuthSession';\nimport { AuthSessionRedirectUriOptions, AuthSessionResult } from '../AuthSession.types';\nimport { DiscoveryDocument } from '../Discovery';\nimport { generateHexStringAsync } from '../PKCE';\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 type GoogleAuthRequestConfig = 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 * 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(() => {\n const propertyName = Platform.select({\n ios: 'iosClientId',\n android: 'androidClientId',\n default: 'webClientId',\n } as const);\n const clientId = config[propertyName] ?? config.clientId;\n invariantClientId(propertyName, clientId, 'Google');\n return clientId;\n }, [config.iosClientId, config.androidClientId, config.webClientId, config.clientId]);\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,3 +1,3 @@
|
|
|
1
1
|
export declare function applyRequiredScopes(scopes: string[] | undefined, requiredScopes: string[]): string[];
|
|
2
|
-
export declare function invariantClientId(idName: string, value: any, providerName: string):
|
|
2
|
+
export declare function invariantClientId(idName: string, value: any, providerName: string): asserts value;
|
|
3
3
|
//# sourceMappingURL=ProviderUtils.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProviderUtils.d.ts","sourceRoot":"","sources":["../../src/providers/ProviderUtils.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAK,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAI7F;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,
|
|
1
|
+
{"version":3,"file":"ProviderUtils.d.ts","sourceRoot":"","sources":["../../src/providers/ProviderUtils.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,MAAM,EAAE,YAAK,EAAE,cAAc,EAAE,MAAM,EAAE,GAAG,MAAM,EAAE,CAI7F;AAED,wBAAgB,iBAAiB,CAAC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,GAAG,EAAE,YAAY,EAAE,MAAM,GAAG,OAAO,CAAC,KAAK,CAMjG"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"ProviderUtils.js","sourceRoot":"","sources":["../../src/providers/ProviderUtils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,mBAAmB,CAAC,SAAmB,EAAE,EAAE,cAAwB;IACjF,sDAAsD;IACtD,oBAAoB;IACpB,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAc,EAAE,KAAU,EAAE,YAAoB;IAChF,IAAI,OAAO,KAAK,KAAK,WAAW;QAC9B,8BAA8B;QAC9B,MAAM,IAAI,KAAK,CACb,wBAAwB,MAAM,6BAA6B,YAAY,yBAAyB,CACjG,CAAC;AACN,CAAC","sourcesContent":["export function applyRequiredScopes(scopes: string[] = [], requiredScopes: string[]): string[] {\n // Add the required scopes for returning profile data.\n // Remove duplicates\n return [...new Set([...scopes, ...requiredScopes])];\n}\n\nexport function invariantClientId(idName: string, value: any, providerName: string) {\n if (typeof value === 'undefined')\n // TODO(Bacon): Add learn more\n throw new Error(\n `Client Id property \\`${idName}\\` must be defined to use ${providerName} auth on this platform.`\n );\n}\n"]}
|
|
1
|
+
{"version":3,"file":"ProviderUtils.js","sourceRoot":"","sources":["../../src/providers/ProviderUtils.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,mBAAmB,CAAC,SAAmB,EAAE,EAAE,cAAwB;IACjF,sDAAsD;IACtD,oBAAoB;IACpB,OAAO,CAAC,GAAG,IAAI,GAAG,CAAC,CAAC,GAAG,MAAM,EAAE,GAAG,cAAc,CAAC,CAAC,CAAC,CAAC;AACtD,CAAC;AAED,MAAM,UAAU,iBAAiB,CAAC,MAAc,EAAE,KAAU,EAAE,YAAoB;IAChF,IAAI,OAAO,KAAK,KAAK,WAAW;QAC9B,8BAA8B;QAC9B,MAAM,IAAI,KAAK,CACb,wBAAwB,MAAM,6BAA6B,YAAY,yBAAyB,CACjG,CAAC;AACN,CAAC","sourcesContent":["export function applyRequiredScopes(scopes: string[] = [], requiredScopes: string[]): string[] {\n // Add the required scopes for returning profile data.\n // Remove duplicates\n return [...new Set([...scopes, ...requiredScopes])];\n}\n\nexport function invariantClientId(idName: string, value: any, providerName: string): asserts value {\n if (typeof value === 'undefined')\n // TODO(Bacon): Add learn more\n throw new Error(\n `Client Id property \\`${idName}\\` must be defined to use ${providerName} auth on this platform.`\n );\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "expo-auth-session",
|
|
3
|
-
"version": "6.1.
|
|
3
|
+
"version": "6.1.2",
|
|
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.2",
|
|
38
|
+
"expo-constants": "~17.1.2",
|
|
39
|
+
"expo-crypto": "~14.1.2",
|
|
40
|
+
"expo-linking": "~7.1.2",
|
|
41
|
+
"expo-web-browser": "~14.1.3",
|
|
42
42
|
"invariant": "^2.2.4"
|
|
43
43
|
},
|
|
44
44
|
"devDependencies": {
|
|
45
|
-
"expo-module-scripts": "^4.1.
|
|
45
|
+
"expo-module-scripts": "^4.1.2"
|
|
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": "cb9fdd93f76f28e2ace4f66080b2386d87239553"
|
|
55
55
|
}
|
package/src/Errors.ts
CHANGED
|
@@ -57,7 +57,7 @@ const errorCodeMessages = {
|
|
|
57
57
|
'The OP does not support use of the `request_uri` parameter defined in Section 6. (https://openid.net/specs/openid-connect-core-1_0.html#JWTRequests)',
|
|
58
58
|
registration_not_supported:
|
|
59
59
|
'The OP does not support use of the `registration` parameter defined in Section 7.2.1. (https://openid.net/specs/openid-connect-core-1_0.html#RegistrationParameter)',
|
|
60
|
-
},
|
|
60
|
+
} as Record<string, string | undefined>,
|
|
61
61
|
// https://tools.ietf.org/html/rfc6749#section-5.2
|
|
62
62
|
token: {
|
|
63
63
|
invalid_request: `The request is missing a required parameter, includes an unsupported parameter value (other than grant type), repeats a parameter, includes multiple credentials, utilizes more than one mechanism for authenticating the client, or is otherwise malformed.`,
|
|
@@ -65,7 +65,7 @@ const errorCodeMessages = {
|
|
|
65
65
|
invalid_grant: `The provided authorization grant (e.g., authorization code, resource owner credentials) or refresh token is invalid, expired, revoked, does not match the redirection URI used in the authorization request, or was issued to another client.`,
|
|
66
66
|
unauthorized_client: `The authenticated client is not authorized to use this authorization grant type.`,
|
|
67
67
|
unsupported_grant_type: `The authorization grant type is not supported by the authorization server.`,
|
|
68
|
-
},
|
|
68
|
+
} as Record<string, string | undefined>,
|
|
69
69
|
};
|
|
70
70
|
|
|
71
71
|
/**
|
|
@@ -88,7 +88,7 @@ export class ResponseError extends CodedError {
|
|
|
88
88
|
*/
|
|
89
89
|
params: Record<string, string>;
|
|
90
90
|
|
|
91
|
-
constructor(params: ResponseErrorConfig, errorCodeType:
|
|
91
|
+
constructor(params: ResponseErrorConfig, errorCodeType: 'auth' | 'token') {
|
|
92
92
|
const { error, error_description, error_uri } = params;
|
|
93
93
|
const message = errorCodeMessages[errorCodeType][error];
|
|
94
94
|
let errorMessage: string;
|
package/src/Fetch.ts
CHANGED
|
@@ -14,10 +14,12 @@ export type FetchRequest = {
|
|
|
14
14
|
export async function requestAsync<T>(requestUrl: string, fetchRequest: FetchRequest): Promise<T> {
|
|
15
15
|
const url = new URL(requestUrl);
|
|
16
16
|
|
|
17
|
-
const
|
|
17
|
+
const headers: Record<string, string> = {};
|
|
18
|
+
const request: RequestInit = {
|
|
19
|
+
body: undefined,
|
|
18
20
|
method: fetchRequest.method,
|
|
19
21
|
mode: 'cors',
|
|
20
|
-
headers
|
|
22
|
+
headers,
|
|
21
23
|
};
|
|
22
24
|
|
|
23
25
|
const isJsonDataType = fetchRequest.dataType?.toLowerCase() === 'json';
|
|
@@ -25,7 +27,7 @@ export async function requestAsync<T>(requestUrl: string, fetchRequest: FetchReq
|
|
|
25
27
|
if (fetchRequest.headers) {
|
|
26
28
|
for (const i in fetchRequest.headers) {
|
|
27
29
|
if (i in fetchRequest.headers) {
|
|
28
|
-
|
|
30
|
+
headers[i] = fetchRequest.headers[i];
|
|
29
31
|
}
|
|
30
32
|
}
|
|
31
33
|
}
|
|
@@ -40,9 +42,9 @@ export async function requestAsync<T>(requestUrl: string, fetchRequest: FetchReq
|
|
|
40
42
|
}
|
|
41
43
|
}
|
|
42
44
|
|
|
43
|
-
if (isJsonDataType && !
|
|
45
|
+
if (isJsonDataType && !headers.Accept && !headers.accept) {
|
|
44
46
|
// NOTE: Github authentication will return XML if this includes the standard `*/*`
|
|
45
|
-
|
|
47
|
+
headers['Accept'] = 'application/json, text/javascript; q=0.01';
|
|
46
48
|
}
|
|
47
49
|
|
|
48
50
|
// Fix a problem with React Native `URL` causing a trailing slash to be added.
|
|
@@ -112,7 +112,7 @@ export class SessionUrlProvider {
|
|
|
112
112
|
return undefined;
|
|
113
113
|
}
|
|
114
114
|
|
|
115
|
-
private static warnIfAnonymous(id, url): void {
|
|
115
|
+
private static warnIfAnonymous(id: string, url: string): void {
|
|
116
116
|
if (id.startsWith('@anonymous/')) {
|
|
117
117
|
console.warn(
|
|
118
118
|
`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.`
|
package/src/TokenRequest.ts
CHANGED
|
@@ -156,14 +156,17 @@ export class Request<T, B> {
|
|
|
156
156
|
/**
|
|
157
157
|
* A generic token request.
|
|
158
158
|
*/
|
|
159
|
-
export class TokenRequest<T extends TokenRequestConfig>
|
|
159
|
+
export class TokenRequest<T extends TokenRequestConfig>
|
|
160
|
+
extends Request<T, TokenResponse>
|
|
161
|
+
implements TokenRequestConfig
|
|
162
|
+
{
|
|
160
163
|
readonly clientId: string;
|
|
161
164
|
readonly clientSecret?: string;
|
|
162
165
|
readonly scopes?: string[];
|
|
163
166
|
readonly extraParams?: Record<string, string>;
|
|
164
167
|
|
|
165
168
|
constructor(
|
|
166
|
-
request,
|
|
169
|
+
request: T,
|
|
167
170
|
public grantType: GrantType
|
|
168
171
|
) {
|
|
169
172
|
super(request);
|
|
@@ -2,7 +2,7 @@ import { useMemo } from 'react';
|
|
|
2
2
|
import { Platform } from 'react-native';
|
|
3
3
|
|
|
4
4
|
import { ProviderAuthRequestConfig } from './Provider.types';
|
|
5
|
-
import { applyRequiredScopes } from './ProviderUtils';
|
|
5
|
+
import { applyRequiredScopes, invariantClientId } from './ProviderUtils';
|
|
6
6
|
import { AuthRequest } from '../AuthRequest';
|
|
7
7
|
import { AuthRequestConfig, AuthRequestPromptOptions, ResponseType } from '../AuthRequest.types';
|
|
8
8
|
import { useAuthRequestResult, useLoadedAuthRequest } from '../AuthRequestHooks';
|
|
@@ -119,13 +119,15 @@ export function useAuthRequest(
|
|
|
119
119
|
AuthSessionResult | null,
|
|
120
120
|
(options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>,
|
|
121
121
|
] {
|
|
122
|
-
const clientId = useMemo(()
|
|
122
|
+
const clientId = useMemo(() => {
|
|
123
123
|
const propertyName = Platform.select({
|
|
124
124
|
ios: 'iosClientId',
|
|
125
125
|
android: 'androidClientId',
|
|
126
126
|
default: 'webClientId',
|
|
127
|
-
});
|
|
128
|
-
|
|
127
|
+
} as const);
|
|
128
|
+
const clientId = config[propertyName] ?? config.clientId;
|
|
129
|
+
invariantClientId(propertyName, clientId, 'Facebook');
|
|
130
|
+
return clientId;
|
|
129
131
|
}, [config.iosClientId, config.androidClientId, config.webClientId, config.clientId]);
|
|
130
132
|
|
|
131
133
|
const redirectUri = useMemo((): string => {
|
package/src/providers/Google.ts
CHANGED
|
@@ -191,14 +191,13 @@ export function useAuthRequest(
|
|
|
191
191
|
AuthSessionResult | null,
|
|
192
192
|
(options?: AuthRequestPromptOptions) => Promise<AuthSessionResult>,
|
|
193
193
|
] {
|
|
194
|
-
const clientId = useMemo(()
|
|
194
|
+
const clientId = useMemo(() => {
|
|
195
195
|
const propertyName = Platform.select({
|
|
196
196
|
ios: 'iosClientId',
|
|
197
197
|
android: 'androidClientId',
|
|
198
198
|
default: 'webClientId',
|
|
199
|
-
});
|
|
200
|
-
|
|
201
|
-
const clientId = config[propertyName as any] ?? config.clientId;
|
|
199
|
+
} as const);
|
|
200
|
+
const clientId = config[propertyName] ?? config.clientId;
|
|
202
201
|
invariantClientId(propertyName, clientId, 'Google');
|
|
203
202
|
return clientId;
|
|
204
203
|
}, [config.iosClientId, config.androidClientId, config.webClientId, config.clientId]);
|
|
@@ -4,7 +4,7 @@ export function applyRequiredScopes(scopes: string[] = [], requiredScopes: strin
|
|
|
4
4
|
return [...new Set([...scopes, ...requiredScopes])];
|
|
5
5
|
}
|
|
6
6
|
|
|
7
|
-
export function invariantClientId(idName: string, value: any, providerName: string) {
|
|
7
|
+
export function invariantClientId(idName: string, value: any, providerName: string): asserts value {
|
|
8
8
|
if (typeof value === 'undefined')
|
|
9
9
|
// TODO(Bacon): Add learn more
|
|
10
10
|
throw new Error(
|