react-native-oauth-essentials 1.0.11 → 1.1.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +384 -362
- package/android/src/main/java/com/oauthessentials/CredentialError.kt +4 -1
- package/android/src/main/java/com/oauthessentials/CredentialFactory.kt +24 -2
- package/android/src/main/java/com/oauthessentials/CustomTabsActivity.kt +14 -1
- package/android/src/main/java/com/oauthessentials/OauthEssentialsModule.kt +448 -192
- package/app.plugin.js +1 -0
- package/ios/AppleIdRetriever.swift +25 -26
- package/ios/CredentialError.swift +3 -0
- package/ios/CredentialFactory.swift +38 -20
- package/ios/CredentialsType.swift +1 -0
- package/ios/GoogleIdRetriever.swift +132 -56
- package/ios/HybridRetriever.swift +12 -18
- package/ios/OauthEssentials.h +0 -3
- package/ios/OauthEssentials.mm +45 -2
- package/ios/OauthEssentialsModule.swift +266 -57
- package/ios/PasskeyRetriever.swift +31 -49
- package/ios/PasswordRetriever.swift +10 -30
- package/ios/RCTPromiseSettler.swift +125 -0
- package/jest/index.js +149 -0
- package/lib/module/NativeOauthEssentials.js +10 -1
- package/lib/module/NativeOauthEssentials.js.map +1 -1
- package/lib/module/errors.js +38 -0
- package/lib/module/errors.js.map +1 -0
- package/lib/module/index.js +432 -58
- package/lib/module/index.js.map +1 -1
- package/lib/module/oauth.js +97 -0
- package/lib/module/oauth.js.map +1 -0
- package/lib/module/platform.js +108 -0
- package/lib/module/platform.js.map +1 -0
- package/lib/module/types.js +46 -1
- package/lib/module/types.js.map +1 -1
- package/lib/typescript/src/NativeOauthEssentials.d.ts +70 -16
- package/lib/typescript/src/NativeOauthEssentials.d.ts.map +1 -1
- package/lib/typescript/src/errors.d.ts +18 -0
- package/lib/typescript/src/errors.d.ts.map +1 -0
- package/lib/typescript/src/index.d.ts +235 -40
- package/lib/typescript/src/index.d.ts.map +1 -1
- package/lib/typescript/src/oauth.d.ts +32 -0
- package/lib/typescript/src/oauth.d.ts.map +1 -0
- package/lib/typescript/src/platform.d.ts +39 -0
- package/lib/typescript/src/platform.d.ts.map +1 -0
- package/lib/typescript/src/types.d.ts +190 -3
- package/lib/typescript/src/types.d.ts.map +1 -1
- package/package.json +8 -4
- package/plugin/withOauthEssentials.js +291 -0
- package/src/NativeOauthEssentials.ts +91 -17
- package/src/errors.ts +49 -0
- package/src/index.tsx +587 -80
- package/src/oauth.ts +140 -0
- package/src/platform.ts +121 -0
- package/src/types.ts +200 -2
|
@@ -1,78 +1,273 @@
|
|
|
1
|
-
import { type
|
|
1
|
+
import { type EventSubscription } from 'react-native';
|
|
2
|
+
import { type AppleIdCredentialResult, AppleIdCredentialState, type AppleSignInOptions, type CancelledCredentialResult, type CredentialFailureEvent, type CredentialSuccessEvent, type GoogleClientId, type GoogleIdCredentialResult, type GoogleSignInOptions, type HybridSignInOptions, type OAuthCredentialResult, type OAuthSignInOptions, type PassKeyCredentialResult, type PasskeyOptions, type PasswordCredentialResult, type WebAppleIdCredentialResult } from './types';
|
|
2
3
|
export * from './types';
|
|
4
|
+
export { isCredentialError } from './errors';
|
|
3
5
|
/**
|
|
4
|
-
*
|
|
5
|
-
* @param webClientId
|
|
6
|
-
* @param options
|
|
6
|
+
* Shows the Google sign in UI and resolves with the signed in account.
|
|
7
7
|
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
8
|
+
* iOS: configures GoogleSignIn with the iOS client id (+ `serverClientId`, `hostedDomain`) and
|
|
9
|
+
* presents it from the top most view controller, passing `hint`, `scopes` and `nonce`. If the app is
|
|
10
|
+
* not active it waits up to 2 seconds for it to become active. The client id falls back to
|
|
11
|
+
* `GIDClientID` and `serverClientId` to `webClientId`, then to `GIDServerClientID` (Info.plist).
|
|
12
|
+
* Android: shows the Credential Manager bottom sheet (`mode: 'bottomSheet'`, falls back to the
|
|
13
|
+
* "Sign in with Google" flow when there is no credential and `authorizedAccounts` is not set) or
|
|
14
|
+
* the "Sign in with Google" flow (`mode: 'button'`). When `scopes` or `offlineAccess` are set it
|
|
15
|
+
* then asks for authorization, which may show a consent screen.
|
|
16
|
+
*
|
|
17
|
+
* Resolves `GOOGLE_ID`, or `CANCELLED` when the user dismisses the UI (or declines the consent
|
|
18
|
+
* screen on Android).
|
|
19
|
+
* Rejects with `CONFIGURATION_ERROR` (no client id; iOS: the reversed client id URL scheme is not in
|
|
20
|
+
* Info.plist, the message has the exact scheme), `NOT_SUPPORTED_ERROR` (Android, no Play Services),
|
|
21
|
+
* `NO_ACTIVITY_ERROR`,
|
|
22
|
+
* `NO_SIGN_IN_AVAILABLE` (Android), `BROWSER_UNAVAILABLE` (iOS: app not active, its window not in
|
|
23
|
+
* the foreground, Guided Access or Safari could not be opened), `SIMULTANEOUS_CALL_ERROR` (iOS: a Google sign in is pending) or
|
|
24
|
+
* `INVALID_RESULT_ERROR`.
|
|
25
|
+
* Emits `onCredentialSuccess` / `onCredentialFailure`.
|
|
26
|
+
*
|
|
27
|
+
* @param clientId - `{ iosClientId, webClientId }` (see {@link GoogleClientIds}), or one client id
|
|
28
|
+
* string used as is (the iOS client id on iOS, the web client id on Android). Optional: without it
|
|
29
|
+
* the ids are read from the app config (`googleSignIn()` or `googleSignIn(options)`), see
|
|
30
|
+
* {@link GoogleClientIds}.
|
|
31
|
+
* @param options - See {@link GoogleSignInOptions}.
|
|
10
32
|
*/
|
|
11
|
-
export declare function googleSignIn(
|
|
33
|
+
export declare function googleSignIn(options?: GoogleSignInOptions): Promise<GoogleIdCredentialResult | CancelledCredentialResult>;
|
|
34
|
+
export declare function googleSignIn(clientId: GoogleClientId | null | undefined, options?: GoogleSignInOptions): Promise<GoogleIdCredentialResult | CancelledCredentialResult>;
|
|
12
35
|
/**
|
|
13
|
-
*
|
|
14
|
-
*
|
|
36
|
+
* Restores a previous Google sign in.
|
|
37
|
+
*
|
|
38
|
+
* iOS: calls GoogleSignIn `restorePreviousSignIn`, which never shows UI and refreshes the tokens.
|
|
39
|
+
* `hint`, `scopes`, `nonce` and `offlineAccess` are ignored and `serverAuthCode` is always null.
|
|
40
|
+
* Android: shows the Credential Manager bottom sheet filtered to accounts that already signed in to
|
|
41
|
+
* the app with auto select on, so it signs in without UI when there is a single one. `mode` and
|
|
42
|
+
* `hint` are ignored. When `scopes`/`offlineAccess` are set, authorization is only requested without UI:
|
|
43
|
+
* if consent is needed the result has `accessToken: null`.
|
|
15
44
|
*
|
|
16
|
-
*
|
|
17
|
-
*
|
|
45
|
+
* Resolves `GOOGLE_ID`, or `CANCELLED` when the user dismisses the Android sheet.
|
|
46
|
+
* Rejects with `NO_SIGN_IN_AVAILABLE` when there is nothing to restore, plus the same errors as
|
|
47
|
+
* {@link googleSignIn} (it shares the iOS simultaneous call lock with it). Takes the same
|
|
48
|
+
* `clientId` as {@link googleSignIn} (also optional).
|
|
49
|
+
* Emits `onCredentialSuccess` / `onCredentialFailure`.
|
|
18
50
|
*/
|
|
19
|
-
export declare function
|
|
51
|
+
export declare function googleSilentSignIn(options?: GoogleSignInOptions): Promise<GoogleIdCredentialResult | CancelledCredentialResult>;
|
|
52
|
+
export declare function googleSilentSignIn(clientId: GoogleClientId | null | undefined, options?: GoogleSignInOptions): Promise<GoogleIdCredentialResult | CancelledCredentialResult>;
|
|
20
53
|
/**
|
|
21
|
-
*
|
|
22
|
-
* Cannot be a already stored password.
|
|
23
|
-
* @param {string} username
|
|
24
|
-
* @param {string} password
|
|
54
|
+
* Clears the stored sign in state.
|
|
25
55
|
*
|
|
26
|
-
*
|
|
27
|
-
*
|
|
56
|
+
* iOS: calls GoogleSignIn `signOut` (removes the Google session from the keychain, so
|
|
57
|
+
* {@link googleSilentSignIn} rejects afterwards). It does not affect Apple ID or passwords.
|
|
58
|
+
* Android: calls Credential Manager `clearCredentialState`, which turns off auto select for every
|
|
59
|
+
* provider until the user picks an account again.
|
|
60
|
+
*
|
|
61
|
+
* Resolves `true`. Rejects with `INVALID_RESULT_ERROR` (Android only) when clearing fails.
|
|
62
|
+
* Does not emit events.
|
|
63
|
+
*/
|
|
64
|
+
export declare function signOut(): Promise<boolean>;
|
|
65
|
+
/**
|
|
66
|
+
* Shows the saved passwords of the app and resolves with the one the user picks.
|
|
67
|
+
*
|
|
68
|
+
* iOS: `ASAuthorizationPasswordProvider` request (iOS 16+ only offers credentials already saved on
|
|
69
|
+
* the device). Resolves `PASSWORD`, or the `CANCELLED` result when the user dismisses it or there
|
|
70
|
+
* is no saved password. Rejects with `INVALID_RESULT_ERROR` on other errors and
|
|
71
|
+
* `SIMULTANEOUS_CALL_ERROR` while a previous call is pending.
|
|
72
|
+
* Android: Credential Manager `GetPasswordOption`. Resolves `PASSWORD`, or `CANCELLED` when the user
|
|
73
|
+
* dismisses it or there is no saved password. Rejects with `NOT_SUPPORTED_ERROR` without Play
|
|
74
|
+
* Services, `NO_ACTIVITY_ERROR` and `INVALID_RESULT_ERROR` on other errors.
|
|
75
|
+
*
|
|
76
|
+
* Emits `onCredentialSuccess` / `onCredentialFailure`.
|
|
77
|
+
*/
|
|
78
|
+
export declare function getPassword(): Promise<PasswordCredentialResult | CancelledCredentialResult>;
|
|
79
|
+
/**
|
|
80
|
+
* Saves a username and password in the platform password manager. It does not authenticate the
|
|
81
|
+
* user against anything.
|
|
82
|
+
*
|
|
83
|
+
* iOS: does nothing and resolves `false` (iOS has no API to save a password without an associated
|
|
84
|
+
* domain; use the `textContentType` props of your inputs so iOS offers to save it).
|
|
85
|
+
* Android: Credential Manager `createCredential(CreatePasswordRequest)`, which shows the save
|
|
86
|
+
* prompt. Resolves `true` when saved, `false` on any error (including the user declining).
|
|
87
|
+
* Rejects with `NOT_SUPPORTED_ERROR` without Play Services and `NO_ACTIVITY_ERROR`.
|
|
88
|
+
*
|
|
89
|
+
* Does not emit events, except `onCredentialFailure` for the Android rejections.
|
|
28
90
|
*/
|
|
29
91
|
export declare function passwordSignIn(username: string, password: string): Promise<boolean>;
|
|
30
92
|
/**
|
|
31
|
-
*
|
|
32
|
-
*
|
|
33
|
-
*
|
|
34
|
-
*
|
|
35
|
-
*
|
|
93
|
+
* Signs in with Apple.
|
|
94
|
+
*
|
|
95
|
+
* iOS: native Sign in with Apple sheet requesting `fullName` and `email`, with `options.nonce` and
|
|
96
|
+
* `options.state`. Resolves `APPLE_ID`, or `CANCELLED` when the user dismisses it. Rejects with
|
|
97
|
+
* `INVALID_RESULT_ERROR` on other errors and `SIMULTANEOUS_CALL_ERROR` while a previous call is
|
|
98
|
+
* pending. Apple only sends `email`/`fullName` on the first authorization: this function keeps the
|
|
99
|
+
* first result of each `user` in memory (until the app is killed) and fills empty `email`/`fullName`
|
|
100
|
+
* with it.
|
|
101
|
+
* Android: opens `androidWebUrl` in a Custom Tab; `options` is ignored (put the nonce in your url).
|
|
102
|
+
* Your backend must run the Apple web flow and redirect to `<applicationId>://oauth/callback`.
|
|
103
|
+
* Resolves `WEB_APPLE_ID` with the redirect url, or `CANCELLED` when the user closes the tab or
|
|
104
|
+
* another browser session (`appleSignIn`/`oauthSignIn`) starts. Rejects with `INVALID_RESULT_ERROR`
|
|
105
|
+
* (invalid url), `NO_ACTIVITY_ERROR` or `BROWSER_UNAVAILABLE` (no browser installed).
|
|
36
106
|
*
|
|
37
|
-
*
|
|
107
|
+
* Emits `onCredentialSuccess` / `onCredentialFailure`.
|
|
108
|
+
* @see [Sign in with Apple REST API](https://developer.apple.com/documentation/signinwithapplerestapi)
|
|
38
109
|
*
|
|
39
|
-
* @
|
|
110
|
+
* @param androidWebUrl - Web url that starts the Apple flow. Required on Android, ignored on iOS.
|
|
111
|
+
* @param options - See {@link AppleSignInOptions}. iOS only.
|
|
40
112
|
*/
|
|
41
|
-
export declare function appleSignIn(androidWebUrl?: string): Promise<AppleIdCredentialResult | WebAppleIdCredentialResult>;
|
|
113
|
+
export declare function appleSignIn(androidWebUrl?: string, options?: AppleSignInOptions): Promise<AppleIdCredentialResult | WebAppleIdCredentialResult | CancelledCredentialResult>;
|
|
42
114
|
/**
|
|
43
|
-
*
|
|
44
|
-
*
|
|
115
|
+
* Asks Apple whether the user is still signed in to the app with Apple ID, without UI
|
|
116
|
+
* (`ASAuthorizationAppleIDProvider.getCredentialState`).
|
|
117
|
+
* Call it on app start and sign the user out when it is not `AUTHORIZED`.
|
|
118
|
+
*
|
|
119
|
+
* Resolves `AUTHORIZED`, `REVOKED`, `TRANSFERRED` or `NOT_FOUND`. Rejects with
|
|
120
|
+
* `INVALID_RESULT_ERROR` when the check fails, and always with `NOT_SUPPORTED_ERROR` on Android.
|
|
121
|
+
* Does not emit events.
|
|
122
|
+
*
|
|
123
|
+
* @param userId - The `user` field of the AppleIdCredentialResult.
|
|
45
124
|
*/
|
|
46
|
-
export declare function
|
|
125
|
+
export declare function getAppleIdCredentialState(userId: string): Promise<AppleIdCredentialState>;
|
|
47
126
|
/**
|
|
48
|
-
*
|
|
49
|
-
*
|
|
127
|
+
* Shows a single picker with the credentials the user already has, meant for app start.
|
|
128
|
+
*
|
|
129
|
+
* iOS: Apple ID + saved passwords (`clientId` is ignored, Google is not included; only
|
|
130
|
+
* `options.nonce` is used, for Apple ID). On iOS 16+ only credentials already on the device are
|
|
131
|
+
* offered. Resolves `APPLE_ID` or `PASSWORD`, or `CANCELLED` when the user dismisses it or nothing
|
|
132
|
+
* is available. Rejects with `INVALID_RESULT_ERROR` or `SIMULTANEOUS_CALL_ERROR`.
|
|
133
|
+
* Android: Credential Manager with Google ID (bottom sheet option with the web client id,
|
|
134
|
+
* `authorizedAccounts`, `autoSelectEnabled` and `nonce`) + saved passwords. Apple is not included
|
|
135
|
+
* and `mode`, `hint`, `scopes`, `offlineAccess`, `hostedDomain` and `serverClientId` are ignored.
|
|
136
|
+
* Resolves `GOOGLE_ID` or `PASSWORD`, or `CANCELLED`. Rejects with `CONFIGURATION_ERROR` (no web
|
|
137
|
+
* client id), `NOT_SUPPORTED_ERROR` (no Play Services), `NO_ACTIVITY_ERROR`,
|
|
138
|
+
* `NO_SIGN_IN_AVAILABLE` or `INVALID_RESULT_ERROR`.
|
|
139
|
+
*
|
|
140
|
+
* Ignored options produce a warning in development.
|
|
141
|
+
* `clientId` is optional like in {@link googleSignIn}: without it the web client id is read from
|
|
142
|
+
* the app config.
|
|
143
|
+
*
|
|
144
|
+
* Emits `onCredentialSuccess` / `onCredentialFailure`.
|
|
50
145
|
*/
|
|
51
|
-
export declare function
|
|
146
|
+
export declare function hybridSignIn(options?: HybridSignInOptions): Promise<HybridSignInResult>;
|
|
147
|
+
export declare function hybridSignIn(clientId: GoogleClientId | null | undefined, options?: HybridSignInOptions): Promise<HybridSignInResult>;
|
|
148
|
+
/** Result of {@link hybridSignIn}: Apple ID only on iOS, Google ID only on Android. */
|
|
149
|
+
export type HybridSignInResult = AppleIdCredentialResult | GoogleIdCredentialResult | PasswordCredentialResult | CancelledCredentialResult;
|
|
52
150
|
/**
|
|
53
|
-
*
|
|
54
|
-
*
|
|
151
|
+
* Creates a passkey from a WebAuthn `PublicKeyCredentialCreationOptions` JSON (`requestJson`).
|
|
152
|
+
*
|
|
153
|
+
* iOS 16+: platform passkey registration. Reads `challenge`, `rp.id`, `user.id`, `user.name`,
|
|
154
|
+
* `authenticatorSelection.userVerification`, `attestation` and, on iOS 17.4+,
|
|
155
|
+
* `excludeCredentials`; other fields are ignored. `data` is a JSON string with `id`, `rawId`,
|
|
156
|
+
* `type` and `response.clientDataJSON`/`attestationObject` (base64url). Rejects with
|
|
157
|
+
* `NOT_SUPPORTED_ERROR` below iOS 16 and `SIMULTANEOUS_CALL_ERROR` while a passkey call is pending.
|
|
158
|
+
* Android 9+: Credential Manager `CreatePublicKeyCredentialRequest` with the whole JSON and
|
|
159
|
+
* `preferImmediatelyAvailableCredentials`. `data` is the registration response JSON returned by
|
|
160
|
+
* Credential Manager. Rejects with `NOT_SUPPORTED_ERROR` below Android 9 and `NO_ACTIVITY_ERROR`.
|
|
161
|
+
*
|
|
162
|
+
* Resolves `PASSKEY`, or `CANCELLED` when the user dismisses it. Rejects with
|
|
163
|
+
* `INVALID_RESULT_ERROR` for an invalid/missing `requestJson` and other errors.
|
|
164
|
+
* Emits `onCredentialSuccess` / `onCredentialFailure`. Send `data` to your server to verify it.
|
|
165
|
+
*/
|
|
166
|
+
export declare function createPassKey(options: PasskeyOptions): Promise<PassKeyCredentialResult | CancelledCredentialResult>;
|
|
167
|
+
/**
|
|
168
|
+
* Signs in with a passkey from a WebAuthn `PublicKeyCredentialRequestOptions` JSON (`requestJson`).
|
|
169
|
+
*
|
|
170
|
+
* iOS 16+: platform passkey assertion. Reads `challenge`, `rpId`, `allowCredentials` and
|
|
171
|
+
* `userVerification`. With `mediation: 'autofill'` it does not show a sheet: it waits until the user
|
|
172
|
+
* picks a passkey in the QuickType bar of a `textContentType="username"` field, and any other
|
|
173
|
+
* passkey call (or {@link cancelPassKeyAutoFill}) resolves it as `CANCELLED`. Otherwise it shows a
|
|
174
|
+
* sheet that only offers passkeys available on the device (no "other device" QR option), so it
|
|
175
|
+
* resolves `CANCELLED` when there is none. `data` is a JSON string with `id`, `rawId`, `type` and
|
|
176
|
+
* `response.clientDataJSON`/`authenticatorData`/`signature`/`userHandle` (base64url).
|
|
177
|
+
* Rejects with `NOT_SUPPORTED_ERROR` below iOS 16 and `SIMULTANEOUS_CALL_ERROR` while a modal
|
|
178
|
+
* passkey call is pending.
|
|
179
|
+
* Android 9+: Credential Manager `GetPublicKeyCredentialOption` with the whole JSON and
|
|
180
|
+
* `preferImmediatelyAvailableCredentials`; `mediation` is ignored. `data` is the authentication
|
|
181
|
+
* response JSON returned by Credential Manager. Rejects with `NOT_SUPPORTED_ERROR` below Android 9,
|
|
182
|
+
* `NO_ACTIVITY_ERROR` and `NO_SIGN_IN_AVAILABLE` (no passkey).
|
|
183
|
+
*
|
|
184
|
+
* Resolves `PASSKEY`, or `CANCELLED` when the user dismisses it. Rejects with
|
|
185
|
+
* `INVALID_RESULT_ERROR` for an invalid/missing `requestJson` and other errors.
|
|
186
|
+
* Emits `onCredentialSuccess` / `onCredentialFailure`. Send `data` to your server to verify it.
|
|
187
|
+
*/
|
|
188
|
+
export declare function getPassKey(options: PasskeyOptions): Promise<PassKeyCredentialResult | CancelledCredentialResult>;
|
|
189
|
+
/**
|
|
190
|
+
* Cancels a pending `getPassKey({ mediation: 'autofill' })` request, for example when the sign in
|
|
191
|
+
* screen unmounts. The cancelled `getPassKey` resolves `CANCELLED` (and emits it).
|
|
192
|
+
*
|
|
193
|
+
* Resolves `true` when a pending AutoFill request was cancelled, `false` when there was none.
|
|
194
|
+
* Always resolves `false` on Android and below iOS 16.
|
|
195
|
+
*/
|
|
196
|
+
export declare function cancelPassKeyAutoFill(): Promise<boolean>;
|
|
197
|
+
/**
|
|
198
|
+
* Signs in with any OAuth 2.0 / OpenID Connect provider using the authorization code flow.
|
|
199
|
+
*
|
|
200
|
+
* 1. Generates a random `state` and a PKCE S256 verifier/challenge on the native side.
|
|
201
|
+
* 2. Builds `authorizationEndpoint?response_type=code&client_id&redirect_uri&state[&scope]
|
|
202
|
+
* [&code_challenge&code_challenge_method=S256]` + `additionalParameters` (which may override
|
|
203
|
+
* `scope`; the other parameters above are reserved and ignored there, with a dev warning).
|
|
204
|
+
* 3. Opens it in `ASWebAuthenticationSession` (iOS, `prefersEphemeralSession`, waits up to 2 seconds
|
|
205
|
+
* for the app to be active) or a Custom Tab (Android) and waits for the redirect to `redirectUri`.
|
|
206
|
+
* On Android the redirect must reach `CustomTabsActivity`: use `OAUTH_REDIRECT_URI` or add an
|
|
207
|
+
* intent filter for your uri.
|
|
208
|
+
* 4. Checks that the returned `state` matches, then reads `code` (query or fragment).
|
|
209
|
+
* 5. When `tokenEndpoint` is set, POSTs `grant_type=authorization_code`, `code`, `client_id`,
|
|
210
|
+
* `redirect_uri` and `code_verifier` as a form and returns the JSON response in `tokens`
|
|
211
|
+
* (no client secret is sent, the id_token is not validated).
|
|
212
|
+
*
|
|
213
|
+
* Resolves `OAUTH`, or `CANCELLED` when the user closes the browser, the provider returns
|
|
214
|
+
* `error=access_denied` or (Android) another browser session starts.
|
|
215
|
+
* Rejects with `INVALID_RESULT_ERROR` (state mismatch, provider error, no code, token endpoint
|
|
216
|
+
* returned non 2xx or non JSON), `NETWORK_ERROR` (token request failed), `CONFIGURATION_ERROR`
|
|
217
|
+
* (invalid `redirectUri`), `BROWSER_UNAVAILABLE` (iOS: Guided Access, app not active or its window
|
|
218
|
+
* not in the foreground; Android: no browser), `NO_ACTIVITY_ERROR` or `SIMULTANEOUS_CALL_ERROR` (iOS).
|
|
219
|
+
* Does not emit events.
|
|
220
|
+
*/
|
|
221
|
+
export declare function oauthSignIn(options: OAuthSignInOptions): Promise<OAuthCredentialResult | CancelledCredentialResult>;
|
|
222
|
+
/**
|
|
223
|
+
* Called with the same `{ type, data }` the promise resolves with (including `CANCELLED`), for
|
|
224
|
+
* `googleSignIn`, `googleSilentSignIn`, `getPassword`, `appleSignIn`, `hybridSignIn`,
|
|
225
|
+
* `createPassKey` and `getPassKey`. Not called by `signOut`, `passwordSignIn`,
|
|
226
|
+
* `getAppleIdCredentialState`, `cancelPassKeyAutoFill` and `oauthSignIn`.
|
|
227
|
+
*/
|
|
228
|
+
export declare function addCredentialSuccessListener(listener: (event: CredentialSuccessEvent) => void): EventSubscription;
|
|
229
|
+
/**
|
|
230
|
+
* Called with `{ code, message }` when one of the methods listed in
|
|
231
|
+
* {@link addCredentialSuccessListener} rejects. `SIMULTANEOUS_CALL_ERROR`, the iOS
|
|
232
|
+
* `NOT_SUPPORTED_ERROR` below iOS 16 and the iOS missing `requestJson` error are not emitted.
|
|
233
|
+
*/
|
|
234
|
+
export declare function addCredentialFailureListener(listener: (event: CredentialFailureEvent) => void): EventSubscription;
|
|
235
|
+
/**
|
|
236
|
+
* Called when iOS posts `credentialRevokedNotification`, i.e. the user stopped using Apple ID with
|
|
237
|
+
* the app while it is running. Sign the user out when it fires. Never called on Android.
|
|
238
|
+
*/
|
|
239
|
+
export declare function addAppleIdCredentialRevokedListener(listener: () => void): EventSubscription;
|
|
240
|
+
/**
|
|
241
|
+
* Android: Google Play Services are installed and up to date (read once, when the module loads).
|
|
242
|
+
* iOS: always false.
|
|
55
243
|
*/
|
|
56
244
|
export declare const GOOGLE_PLAY_SERVICES_SUPPORTED: boolean;
|
|
57
245
|
/**
|
|
58
|
-
*
|
|
246
|
+
* iOS: always true. Android: same as `GOOGLE_PLAY_SERVICES_SUPPORTED` (`getPassword` and
|
|
247
|
+
* `passwordSignIn` reject with `NOT_SUPPORTED_ERROR` without Play Services).
|
|
59
248
|
*/
|
|
60
249
|
export declare const PASSWORD_SUPPORTED: boolean;
|
|
61
250
|
/**
|
|
62
|
-
*
|
|
63
|
-
* You should mainly rely on this constant to check if you can use google sign in.
|
|
251
|
+
* iOS: always true. Android: same as `GOOGLE_PLAY_SERVICES_SUPPORTED`.
|
|
64
252
|
*/
|
|
65
253
|
export declare const GOOGLE_ID_SUPPORTED: boolean;
|
|
66
254
|
/**
|
|
67
|
-
*
|
|
255
|
+
* Always true (native on iOS, web flow in a Custom Tab on Android).
|
|
68
256
|
*/
|
|
69
257
|
export declare const APPLE_ID_SUPPORTED: boolean;
|
|
70
258
|
/**
|
|
71
|
-
*
|
|
259
|
+
* iOS: always true. Android: same as `GOOGLE_PLAY_SERVICES_SUPPORTED` (`hybridSignIn` rejects with
|
|
260
|
+
* `NOT_SUPPORTED_ERROR` without Play Services).
|
|
72
261
|
*/
|
|
73
262
|
export declare const HYBRID_SUPPORTED: boolean;
|
|
74
263
|
/**
|
|
75
|
-
*
|
|
264
|
+
* iOS 16+ / Android 9+ (API 28).
|
|
76
265
|
*/
|
|
77
266
|
export declare const PASSKEYS_SUPPORTED: boolean;
|
|
267
|
+
/**
|
|
268
|
+
* Default redirect uri of `oauthSignIn`: `<bundle id, lowercased>://oauth/callback` on iOS and
|
|
269
|
+
* `<applicationId>://oauth/callback` on Android (the uri the library's `CustomTabsActivity`
|
|
270
|
+
* intent filter handles).
|
|
271
|
+
*/
|
|
272
|
+
export declare const OAUTH_REDIRECT_URI: string;
|
|
78
273
|
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/index.tsx"],"names":[],"mappings":"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"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
export type PkcePair = {
|
|
2
|
+
codeVerifier: string;
|
|
3
|
+
codeChallenge: string;
|
|
4
|
+
state: string;
|
|
5
|
+
};
|
|
6
|
+
export type AuthorizationUrlParams = {
|
|
7
|
+
authorizationEndpoint: string;
|
|
8
|
+
clientId: string;
|
|
9
|
+
redirectUri: string;
|
|
10
|
+
scopes?: string[];
|
|
11
|
+
additionalParameters?: Record<string, string>;
|
|
12
|
+
state: string;
|
|
13
|
+
codeChallenge?: string;
|
|
14
|
+
};
|
|
15
|
+
/**
|
|
16
|
+
* Set by the library and checked or reused later (state, PKCE, token exchange), so
|
|
17
|
+
* `additionalParameters` cannot override them.
|
|
18
|
+
*/
|
|
19
|
+
export declare const RESERVED_AUTHORIZATION_PARAMS: readonly ["response_type", "client_id", "redirect_uri", "state", "code_challenge", "code_challenge_method"];
|
|
20
|
+
export declare function buildAuthorizationUrl(p: AuthorizationUrlParams): string;
|
|
21
|
+
/**
|
|
22
|
+
* Reads the query and fragment parameters of a redirect url.
|
|
23
|
+
*/
|
|
24
|
+
export declare function parseRedirectParams(url: string): Record<string, string>;
|
|
25
|
+
export declare function getUrlScheme(url: string): string;
|
|
26
|
+
export declare function buildTokenRequestBody(p: {
|
|
27
|
+
code: string;
|
|
28
|
+
clientId: string;
|
|
29
|
+
redirectUri: string;
|
|
30
|
+
codeVerifier: string | null;
|
|
31
|
+
}): string;
|
|
32
|
+
//# sourceMappingURL=oauth.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"oauth.d.ts","sourceRoot":"","sources":["../../../src/oauth.ts"],"names":[],"mappings":"AAIA,MAAM,MAAM,QAAQ,GAAG;IACrB,YAAY,EAAE,MAAM,CAAC;IACrB,aAAa,EAAE,MAAM,CAAC;IACtB,KAAK,EAAE,MAAM,CAAC;CACf,CAAC;AAEF,MAAM,MAAM,sBAAsB,GAAG;IACnC,qBAAqB,EAAE,MAAM,CAAC;IAC9B,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;IAClB,oBAAoB,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC;IAC9C,KAAK,EAAE,MAAM,CAAC;IACd,aAAa,CAAC,EAAE,MAAM,CAAC;CACxB,CAAC;AAuBF;;;GAGG;AACH,eAAO,MAAM,6BAA6B,6GAOhC,CAAC;AAEX,wBAAgB,qBAAqB,CAAC,CAAC,EAAE,sBAAsB,GAAG,MAAM,CA6BvE;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAsBvE;AAED,wBAAgB,YAAY,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAShD;AAED,wBAAgB,qBAAqB,CAAC,CAAC,EAAE;IACvC,IAAI,EAAE,MAAM,CAAC;IACb,QAAQ,EAAE,MAAM,CAAC;IACjB,WAAW,EAAE,MAAM,CAAC;IACpB,YAAY,EAAE,MAAM,GAAG,IAAI,CAAC;CAC7B,GAAG,MAAM,CAWT"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import type { GoogleClientId, GoogleSignInOptions } from './types';
|
|
2
|
+
type OS = 'ios' | 'android' | string;
|
|
3
|
+
/**
|
|
4
|
+
* Picks the client id the native module of `os` expects.
|
|
5
|
+
*
|
|
6
|
+
* A string is passed as is. With `{ iosClientId, webClientId }`, iOS gets `iosClientId` (or '' so
|
|
7
|
+
* the native side reads `GIDClientID` from Info.plist) and `webClientId` as the default
|
|
8
|
+
* `serverClientId`; Android gets `webClientId` (or '', which rejects with `CONFIGURATION_ERROR`).
|
|
9
|
+
*/
|
|
10
|
+
export declare function resolveGoogleClientId<T extends GoogleSignInOptions>(os: OS, clientId: GoogleClientId | null | undefined, options: T): {
|
|
11
|
+
clientId: string;
|
|
12
|
+
options: T;
|
|
13
|
+
};
|
|
14
|
+
/**
|
|
15
|
+
* Splits the `(clientId?, options?)` arguments of the Google methods, which also accept
|
|
16
|
+
* `(options)`: an object with `iosClientId` or `webClientId` is the client id, any other object is
|
|
17
|
+
* the options. Without a client id the native side reads it from the app config (Info.plist,
|
|
18
|
+
* AndroidManifest meta-data or the Firebase files).
|
|
19
|
+
*/
|
|
20
|
+
export declare function splitGoogleArgs<T extends object>(first: GoogleClientId | T | null | undefined, second: T | undefined): {
|
|
21
|
+
clientId: GoogleClientId | undefined;
|
|
22
|
+
options: T | undefined;
|
|
23
|
+
};
|
|
24
|
+
/**
|
|
25
|
+
* Message thrown when the native module is not in the binary: Expo Go (which only ships the Expo
|
|
26
|
+
* SDK native modules) or an app that was not rebuilt after installing the library.
|
|
27
|
+
*/
|
|
28
|
+
export declare function missingNativeModuleMessage(): string;
|
|
29
|
+
/**
|
|
30
|
+
* In development, warns once per method and option that an option set by the app has no effect on
|
|
31
|
+
* the current platform. `options` must be the options as passed by the app (before defaults).
|
|
32
|
+
*/
|
|
33
|
+
export declare function warnIgnored(method: string, platform: string, options: object | null | undefined, keys: readonly string[]): void;
|
|
34
|
+
/**
|
|
35
|
+
* In development, logs `message` once per method and key.
|
|
36
|
+
*/
|
|
37
|
+
export declare function warnOnce(method: string, key: string, message: string): void;
|
|
38
|
+
export {};
|
|
39
|
+
//# sourceMappingURL=platform.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"platform.d.ts","sourceRoot":"","sources":["../../../src/platform.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,mBAAmB,EAAE,MAAM,SAAS,CAAC;AAEnE,KAAK,EAAE,GAAG,KAAK,GAAG,SAAS,GAAG,MAAM,CAAC;AAErC;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,CAAC,SAAS,mBAAmB,EACjE,EAAE,EAAE,EAAE,EACN,QAAQ,EAAE,cAAc,GAAG,IAAI,GAAG,SAAS,EAC3C,OAAO,EAAE,CAAC,GACT;IAAE,QAAQ,EAAE,MAAM,CAAC;IAAC,OAAO,EAAE,CAAC,CAAA;CAAE,CAalC;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,CAAC,SAAS,MAAM,EAC9C,KAAK,EAAE,cAAc,GAAG,CAAC,GAAG,IAAI,GAAG,SAAS,EAC5C,MAAM,EAAE,CAAC,GAAG,SAAS,GACpB;IAAE,QAAQ,EAAE,cAAc,GAAG,SAAS,CAAC;IAAC,OAAO,EAAE,CAAC,GAAG,SAAS,CAAA;CAAE,CAYlE;AAED;;;GAGG;AACH,wBAAgB,0BAA0B,IAAI,MAAM,CAgBnD;AAID;;;GAGG;AACH,wBAAgB,WAAW,CACzB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,EAAE,MAAM,GAAG,IAAI,GAAG,SAAS,EAClC,IAAI,EAAE,SAAS,MAAM,EAAE,GACtB,IAAI,CAaN;AAQD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,MAAM,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAU3E"}
|
|
@@ -1,11 +1,136 @@
|
|
|
1
1
|
export type GoogleSignInOptions = {
|
|
2
|
+
/**
|
|
3
|
+
* Only show accounts that already signed in to the app. [Android only]
|
|
4
|
+
*/
|
|
2
5
|
authorizedAccounts?: boolean;
|
|
6
|
+
/**
|
|
7
|
+
* Automatically sign in when a single authorized account is available. [Android only]
|
|
8
|
+
*/
|
|
3
9
|
autoSelectEnabled?: boolean;
|
|
10
|
+
/**
|
|
11
|
+
* Android UI flow. `bottomSheet` (default) shows the Credential Manager sheet and, unless
|
|
12
|
+
* `authorizedAccounts` is set, falls back to `button` when no credential is available
|
|
13
|
+
* (no account on the device or the sheet is in cooldown after being dismissed).
|
|
14
|
+
* `button` always shows the "Sign in with Google" flow, which is what a sign-in button tap
|
|
15
|
+
* should use. [Android only]
|
|
16
|
+
*/
|
|
17
|
+
mode?: 'bottomSheet' | 'button';
|
|
18
|
+
/**
|
|
19
|
+
* Nonce embedded as-is in the returned idToken, so your backend can prevent replay attacks.
|
|
20
|
+
* Ignored by `googleSilentSignIn` on iOS.
|
|
21
|
+
*/
|
|
22
|
+
nonce?: string;
|
|
23
|
+
/**
|
|
24
|
+
* Email to preselect in the Google page. [iOS only]
|
|
25
|
+
*/
|
|
26
|
+
hint?: string;
|
|
27
|
+
/**
|
|
28
|
+
* Restricts sign in to a Google Workspace domain. On Android it only applies to the
|
|
29
|
+
* "Sign in with Google" (`button`) flow and to the authorization step, not to the bottom sheet.
|
|
30
|
+
*/
|
|
31
|
+
hostedDomain?: string;
|
|
32
|
+
/**
|
|
33
|
+
* Additional OAuth scopes the user must grant.
|
|
34
|
+
* iOS: requested during sign in; `accessToken` and `grantedScopes` are always returned.
|
|
35
|
+
* Android: requested in a second step (Authorization API, may show a consent screen); without
|
|
36
|
+
* `scopes`/`offlineAccess`, `accessToken` and `grantedScopes` are null.
|
|
37
|
+
*/
|
|
38
|
+
scopes?: string[];
|
|
39
|
+
/**
|
|
40
|
+
* Android: requests a `serverAuthCode` (for `serverClientId`, or the main client id) your backend
|
|
41
|
+
* can exchange for refresh tokens. iOS: no effect, `serverAuthCode` is returned whenever
|
|
42
|
+
* `serverClientId` is set.
|
|
43
|
+
*/
|
|
44
|
+
offlineAccess?: boolean;
|
|
45
|
+
/**
|
|
46
|
+
* iOS: web (server) client id. Makes it the idToken audience and returns a `serverAuthCode`.
|
|
47
|
+
* Android: client id the `serverAuthCode` is issued for (defaults to the main client id).
|
|
48
|
+
*/
|
|
49
|
+
serverClientId?: string;
|
|
4
50
|
};
|
|
51
|
+
/**
|
|
52
|
+
* Google OAuth client ids per platform, all from the same Google Cloud project.
|
|
53
|
+
*
|
|
54
|
+
* Both are optional: a missing id is read from the app config, which the Expo plugin writes (from
|
|
55
|
+
* its options or the Firebase files).
|
|
56
|
+
*/
|
|
57
|
+
export type GoogleClientIds = {
|
|
58
|
+
/**
|
|
59
|
+
* iOS client id (created with the iOS bundle id). Used on iOS only. When missing, the `GIDClientID`
|
|
60
|
+
* key of Info.plist is used, then `CLIENT_ID` of GoogleService-Info.plist.
|
|
61
|
+
*/
|
|
62
|
+
iosClientId?: string;
|
|
63
|
+
/**
|
|
64
|
+
* Web client id. Android: the client id passed to Credential Manager; when missing, the
|
|
65
|
+
* `com.oauthessentials.GOOGLE_WEB_CLIENT_ID` meta-data of AndroidManifest is used, then the
|
|
66
|
+
* `default_web_client_id` string generated by the Firebase `google-services` Gradle plugin.
|
|
67
|
+
* iOS: the default `serverClientId` (idToken audience); when missing, the `GIDServerClientID` key
|
|
68
|
+
* of Info.plist is used.
|
|
69
|
+
*/
|
|
70
|
+
webClientId?: string;
|
|
71
|
+
};
|
|
72
|
+
/**
|
|
73
|
+
* A {@link GoogleClientIds} object, or a single client id string, used as is on both platforms
|
|
74
|
+
* (it must be the iOS client id on iOS and the web client id on Android).
|
|
75
|
+
*/
|
|
76
|
+
export type GoogleClientId = string | GoogleClientIds;
|
|
77
|
+
export type AppleSignInOptions = {
|
|
78
|
+
/**
|
|
79
|
+
* Nonce passed as-is to Apple and embedded in the idToken. Firebase and Supabase expect the
|
|
80
|
+
* SHA-256 of the raw nonce here. [iOS only, on Android put it in your `androidWebUrl`]
|
|
81
|
+
*/
|
|
82
|
+
nonce?: string;
|
|
83
|
+
/**
|
|
84
|
+
* Opaque value returned in the credential. [iOS only]
|
|
85
|
+
*/
|
|
86
|
+
state?: string;
|
|
87
|
+
};
|
|
88
|
+
export type HybridSignInOptions = GoogleSignInOptions;
|
|
5
89
|
export type PasskeyOptions = {
|
|
90
|
+
/**
|
|
91
|
+
* WebAuthn options JSON from your server: `PublicKeyCredentialCreationOptions` for
|
|
92
|
+
* `createPassKey`, `PublicKeyCredentialRequestOptions` for `getPassKey`.
|
|
93
|
+
*/
|
|
6
94
|
requestJson: string;
|
|
95
|
+
/**
|
|
96
|
+
* Only offer credentials already available on the device. [Android only, iOS modal requests
|
|
97
|
+
* always behave this way]
|
|
98
|
+
*/
|
|
7
99
|
preferImmediatelyAvailableCredentials?: boolean;
|
|
8
|
-
|
|
100
|
+
/**
|
|
101
|
+
* `autofill` shows passkeys in the QuickType bar of a text field with
|
|
102
|
+
* `textContentType="username"` instead of a modal sheet. [iOS 16+ only]
|
|
103
|
+
*/
|
|
104
|
+
mediation?: 'modal' | 'autofill';
|
|
105
|
+
};
|
|
106
|
+
export type OAuthSignInOptions = {
|
|
107
|
+
authorizationEndpoint: string;
|
|
108
|
+
clientId: string;
|
|
109
|
+
/**
|
|
110
|
+
* Defaults to `OAUTH_REDIRECT_URI` (`<bundle or application id>://oauth/callback`).
|
|
111
|
+
*/
|
|
112
|
+
redirectUri?: string;
|
|
113
|
+
scopes?: string[];
|
|
114
|
+
/**
|
|
115
|
+
* Extra authorization request parameters (e.g. `prompt`, `login_hint`, `nonce`). They may
|
|
116
|
+
* override `scope`, but `response_type`, `client_id`, `redirect_uri`, `state`, `code_challenge`
|
|
117
|
+
* and `code_challenge_method` are set by the library and ignored here (with a warning in
|
|
118
|
+
* development).
|
|
119
|
+
*/
|
|
120
|
+
additionalParameters?: Record<string, string>;
|
|
121
|
+
/**
|
|
122
|
+
* When set, the authorization code is exchanged for tokens on the device.
|
|
123
|
+
* Leave it out to exchange the code on your backend (recommended for confidential clients).
|
|
124
|
+
*/
|
|
125
|
+
tokenEndpoint?: string;
|
|
126
|
+
/**
|
|
127
|
+
* Defaults to true.
|
|
128
|
+
*/
|
|
129
|
+
usePKCE?: boolean;
|
|
130
|
+
/**
|
|
131
|
+
* Do not share cookies with the browser. [iOS only]
|
|
132
|
+
*/
|
|
133
|
+
prefersEphemeralSession?: boolean;
|
|
9
134
|
};
|
|
10
135
|
export type PassKeyCredentialResult = {
|
|
11
136
|
type: CredentialsType.PASSKEY;
|
|
@@ -21,13 +146,20 @@ export type PasswordCredentialResult = {
|
|
|
21
146
|
export type GoogleIdCredentialResult = {
|
|
22
147
|
type: CredentialsType.GOOGLE_ID;
|
|
23
148
|
data: {
|
|
149
|
+
/** iOS: Google user id (the idToken `sub`). Android: the account email. */
|
|
24
150
|
id: string;
|
|
25
151
|
idToken: string;
|
|
26
152
|
displayName: string;
|
|
27
153
|
givenName: string;
|
|
28
154
|
familyName: string;
|
|
155
|
+
email?: string;
|
|
156
|
+
/** iOS: 200px picture url or "". */
|
|
29
157
|
profilePictureUri?: string | null;
|
|
158
|
+
/** Android only. */
|
|
30
159
|
phoneNumber?: string | null;
|
|
160
|
+
accessToken?: string | null;
|
|
161
|
+
serverAuthCode?: string | null;
|
|
162
|
+
grantedScopes?: string[] | null;
|
|
31
163
|
};
|
|
32
164
|
};
|
|
33
165
|
export type CancelledCredentialResult = {
|
|
@@ -43,6 +175,7 @@ export type AppleIdCredentialResult = {
|
|
|
43
175
|
email: string;
|
|
44
176
|
fullName: string;
|
|
45
177
|
likelyReal: boolean;
|
|
178
|
+
state?: string | null;
|
|
46
179
|
};
|
|
47
180
|
};
|
|
48
181
|
export type WebAppleIdCredentialResult = {
|
|
@@ -55,17 +188,71 @@ export type WebAppleIdCredentialResult = {
|
|
|
55
188
|
query: string | null;
|
|
56
189
|
};
|
|
57
190
|
};
|
|
191
|
+
export type OAuthCredentialResult = {
|
|
192
|
+
type: CredentialsType.OAUTH;
|
|
193
|
+
data: {
|
|
194
|
+
code: string;
|
|
195
|
+
state: string;
|
|
196
|
+
redirectUri: string;
|
|
197
|
+
codeVerifier: string | null;
|
|
198
|
+
/** All parameters received in the redirect url. */
|
|
199
|
+
params: Record<string, string>;
|
|
200
|
+
/** Token endpoint response, only when `tokenEndpoint` is set. */
|
|
201
|
+
tokens: Record<string, unknown> | null;
|
|
202
|
+
};
|
|
203
|
+
};
|
|
204
|
+
export type CredentialSuccessEvent = {
|
|
205
|
+
type: string;
|
|
206
|
+
data: Object;
|
|
207
|
+
};
|
|
208
|
+
export type CredentialFailureEvent = {
|
|
209
|
+
code: CredentialErrorCode;
|
|
210
|
+
message: string;
|
|
211
|
+
};
|
|
58
212
|
export declare enum CredentialsType {
|
|
59
213
|
GOOGLE_ID = "GOOGLE_ID",// GoogleId credentials type
|
|
60
214
|
PASSWORD = "PASSWORD",// Password credentials type
|
|
61
215
|
APPLE_ID = "APPLE_ID",// IOS AppleId credentials type
|
|
62
216
|
WEB_APPLE_ID = "WEB_APPLE_ID",// Android AppleId credentials type
|
|
63
217
|
CANCELLED = "CANCELLED",// type when the user cancels it
|
|
64
|
-
PASSKEY = "PASSKEY"
|
|
218
|
+
PASSKEY = "PASSKEY",// Passkey credential type
|
|
219
|
+
OAUTH = "OAUTH"
|
|
220
|
+
}
|
|
221
|
+
export declare enum AppleIdCredentialState {
|
|
222
|
+
AUTHORIZED = "AUTHORIZED",
|
|
223
|
+
REVOKED = "REVOKED",
|
|
224
|
+
NOT_FOUND = "NOT_FOUND",
|
|
225
|
+
TRANSFERRED = "TRANSFERRED"
|
|
65
226
|
}
|
|
66
227
|
export declare enum CredentialError {
|
|
228
|
+
/**
|
|
229
|
+
* @deprecated Never thrown: missing Play Services rejects with `NOT_SUPPORTED_ERROR`.
|
|
230
|
+
*/
|
|
67
231
|
NO_PLAY_SERVICES_ERROR = "NO_PLAY_SERVICES_ERROR",
|
|
232
|
+
/** No Android activity, or no iOS view controller attached to a window, to present the UI. */
|
|
68
233
|
NO_ACTIVITY_ERROR = "NO_ACTIVITY_ERROR",
|
|
69
|
-
|
|
234
|
+
/** The provider failed or returned something unexpected; `message` has the native error. */
|
|
235
|
+
INVALID_RESULT_ERROR = "INVALID_RESULT_ERROR",
|
|
236
|
+
/** There is no credential to return (no account / passkey / previous sign in). */
|
|
237
|
+
NO_SIGN_IN_AVAILABLE = "NO_SIGN_IN_AVAILABLE",
|
|
238
|
+
/** iOS: the same method (or method group) is still waiting for the previous call. */
|
|
239
|
+
SIMULTANEOUS_CALL_ERROR = "SIMULTANEOUS_CALL_ERROR",
|
|
240
|
+
/** The OS version, missing Play Services or the platform does not support the method. */
|
|
241
|
+
NOT_SUPPORTED_ERROR = "NOT_SUPPORTED_ERROR",
|
|
242
|
+
/** The browser session could not be opened (app in background, Guided Access, no browser). */
|
|
243
|
+
BROWSER_UNAVAILABLE = "BROWSER_UNAVAILABLE",
|
|
244
|
+
/**
|
|
245
|
+
* The app is misconfigured: missing Google client id, missing iOS URL scheme (the message has
|
|
246
|
+
* the exact scheme to add) or an invalid `redirectUri`.
|
|
247
|
+
*/
|
|
248
|
+
CONFIGURATION_ERROR = "CONFIGURATION_ERROR",
|
|
249
|
+
/** `oauthSignIn`: the token endpoint request failed (offline, DNS, TLS...). */
|
|
250
|
+
NETWORK_ERROR = "NETWORK_ERROR"
|
|
70
251
|
}
|
|
252
|
+
/** A {@link CredentialError} value, as an enum member or its string. */
|
|
253
|
+
export type CredentialErrorCode = `${CredentialError}`;
|
|
254
|
+
/** Every promise of the library rejects with an `Error` that has one of these codes. */
|
|
255
|
+
export type OauthEssentialsError<C extends CredentialErrorCode = CredentialErrorCode> = Error & {
|
|
256
|
+
code: C;
|
|
257
|
+
};
|
|
71
258
|
//# sourceMappingURL=types.d.ts.map
|