@firebase/auth 0.21.5 → 0.21.6-canary.45a55330e
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 +8 -0
- package/README.md +25 -0
- package/dist/auth-public.d.ts +135 -4
- package/dist/auth.d.ts +138 -4
- package/dist/browser-cjs/{index-ff477525.js → index-3e63d976.js} +180 -5
- package/dist/browser-cjs/index-3e63d976.js.map +1 -0
- package/dist/browser-cjs/index.d.ts +2 -1
- package/dist/browser-cjs/index.js +3 -1
- package/dist/browser-cjs/index.js.map +1 -1
- package/dist/browser-cjs/internal.js +3 -1
- package/dist/browser-cjs/internal.js.map +1 -1
- package/dist/browser-cjs/src/api/account_management/mfa.d.ts +38 -4
- package/dist/browser-cjs/src/api/authentication/mfa.d.ts +11 -0
- package/dist/browser-cjs/src/core/errors.d.ts +1 -0
- package/dist/browser-cjs/src/core/index.d.ts +1 -0
- package/dist/browser-cjs/src/mfa/assertions/totp.d.ts +124 -0
- package/dist/browser-cjs/src/mfa/assertions/totp.test.d.ts +17 -0
- package/dist/browser-cjs/src/mfa/mfa_info.d.ts +5 -1
- package/dist/browser-cjs/src/model/enum_maps.d.ts +1 -0
- package/dist/browser-cjs/src/model/public_types.d.ts +18 -1
- package/dist/browser-cjs/test/helpers/integration/helpers.d.ts +3 -0
- package/dist/browser-cjs/test/integration/flows/totp.test.d.ts +17 -0
- package/dist/cordova/index.d.ts +2 -1
- package/dist/cordova/index.js +2 -2
- package/dist/cordova/internal.js +179 -3
- package/dist/cordova/internal.js.map +1 -1
- package/dist/cordova/{popup_redirect-a4d3c436.js → popup_redirect-4dd66477.js} +31 -6
- package/dist/cordova/popup_redirect-4dd66477.js.map +1 -0
- package/dist/cordova/src/api/account_management/mfa.d.ts +38 -4
- package/dist/cordova/src/api/authentication/mfa.d.ts +11 -0
- package/dist/cordova/src/core/errors.d.ts +1 -0
- package/dist/cordova/src/core/index.d.ts +1 -0
- package/dist/cordova/src/mfa/assertions/totp.d.ts +124 -0
- package/dist/cordova/src/mfa/assertions/totp.test.d.ts +17 -0
- package/dist/cordova/src/mfa/mfa_info.d.ts +5 -1
- package/dist/cordova/src/model/enum_maps.d.ts +1 -0
- package/dist/cordova/src/model/public_types.d.ts +18 -1
- package/dist/cordova/test/helpers/integration/helpers.d.ts +3 -0
- package/dist/cordova/test/integration/flows/totp.test.d.ts +17 -0
- package/dist/esm2017/{index-3363a72a.js → index-c8153924.js} +179 -6
- package/dist/esm2017/index-c8153924.js.map +1 -0
- package/dist/esm2017/index.d.ts +2 -1
- package/dist/esm2017/index.js +1 -1
- package/dist/esm2017/internal.js +2 -2
- package/dist/esm2017/src/api/account_management/mfa.d.ts +38 -4
- package/dist/esm2017/src/api/authentication/mfa.d.ts +11 -0
- package/dist/esm2017/src/core/errors.d.ts +1 -0
- package/dist/esm2017/src/core/index.d.ts +1 -0
- package/dist/esm2017/src/mfa/assertions/totp.d.ts +124 -0
- package/dist/esm2017/src/mfa/assertions/totp.test.d.ts +17 -0
- package/dist/esm2017/src/mfa/mfa_info.d.ts +5 -1
- package/dist/esm2017/src/model/enum_maps.d.ts +1 -0
- package/dist/esm2017/src/model/public_types.d.ts +18 -1
- package/dist/esm2017/test/helpers/integration/helpers.d.ts +3 -0
- package/dist/esm2017/test/integration/flows/totp.test.d.ts +17 -0
- package/dist/esm5/{index-3f05dc7b.js → index-f3279380.js} +207 -6
- package/dist/esm5/index-f3279380.js.map +1 -0
- package/dist/esm5/index.d.ts +2 -1
- package/dist/esm5/index.js +1 -1
- package/dist/esm5/internal.js +2 -2
- package/dist/esm5/src/api/account_management/mfa.d.ts +38 -4
- package/dist/esm5/src/api/authentication/mfa.d.ts +11 -0
- package/dist/esm5/src/core/errors.d.ts +1 -0
- package/dist/esm5/src/core/index.d.ts +1 -0
- package/dist/esm5/src/mfa/assertions/totp.d.ts +124 -0
- package/dist/esm5/src/mfa/assertions/totp.test.d.ts +17 -0
- package/dist/esm5/src/mfa/mfa_info.d.ts +5 -1
- package/dist/esm5/src/model/enum_maps.d.ts +1 -0
- package/dist/esm5/src/model/public_types.d.ts +18 -1
- package/dist/esm5/test/helpers/integration/helpers.d.ts +3 -0
- package/dist/esm5/test/integration/flows/totp.test.d.ts +17 -0
- package/dist/index.d.ts +2 -1
- package/dist/index.webworker.esm5.js +23 -4
- package/dist/index.webworker.esm5.js.map +1 -1
- package/dist/node/index.d.ts +2 -1
- package/dist/node/index.js +83 -81
- package/dist/node/index.js.map +1 -1
- package/dist/node/internal.js +144 -142
- package/dist/node/internal.js.map +1 -1
- package/dist/node/src/api/account_management/mfa.d.ts +38 -4
- package/dist/node/src/api/authentication/mfa.d.ts +11 -0
- package/dist/node/src/core/errors.d.ts +1 -0
- package/dist/node/src/core/index.d.ts +1 -0
- package/dist/node/src/mfa/assertions/totp.d.ts +124 -0
- package/dist/node/src/mfa/assertions/totp.test.d.ts +17 -0
- package/dist/node/src/mfa/mfa_info.d.ts +5 -1
- package/dist/node/src/model/enum_maps.d.ts +1 -0
- package/dist/node/src/model/public_types.d.ts +18 -1
- package/dist/node/test/helpers/integration/helpers.d.ts +3 -0
- package/dist/node/test/integration/flows/totp.test.d.ts +17 -0
- package/dist/node/{index-45468d80.js → totp-9c98f1ff.js} +243 -6
- package/dist/node/totp-9c98f1ff.js.map +1 -0
- package/dist/node-esm/index.d.ts +2 -1
- package/dist/node-esm/index.js +2 -2
- package/dist/node-esm/internal.js +3 -3
- package/dist/node-esm/src/api/account_management/mfa.d.ts +38 -4
- package/dist/node-esm/src/api/authentication/mfa.d.ts +11 -0
- package/dist/node-esm/src/core/errors.d.ts +1 -0
- package/dist/node-esm/src/core/index.d.ts +1 -0
- package/dist/node-esm/src/mfa/assertions/totp.d.ts +124 -0
- package/dist/node-esm/src/mfa/assertions/totp.test.d.ts +17 -0
- package/dist/node-esm/src/mfa/mfa_info.d.ts +5 -1
- package/dist/node-esm/src/model/enum_maps.d.ts +1 -0
- package/dist/node-esm/src/model/public_types.d.ts +18 -1
- package/dist/node-esm/test/helpers/integration/helpers.d.ts +3 -0
- package/dist/node-esm/test/integration/flows/totp.test.d.ts +17 -0
- package/dist/node-esm/{index-1f9492de.js → totp-a3bfc07a.js} +213 -7
- package/dist/node-esm/totp-a3bfc07a.js.map +1 -0
- package/dist/rn/index.d.ts +2 -1
- package/dist/rn/index.js +1 -1
- package/dist/rn/internal.js +176 -1
- package/dist/rn/internal.js.map +1 -1
- package/dist/rn/{phone-e7bf48a1.js → phone-588b1f48.js} +37 -5
- package/dist/rn/phone-588b1f48.js.map +1 -0
- package/dist/rn/src/api/account_management/mfa.d.ts +38 -4
- package/dist/rn/src/api/authentication/mfa.d.ts +11 -0
- package/dist/rn/src/core/errors.d.ts +1 -0
- package/dist/rn/src/core/index.d.ts +1 -0
- package/dist/rn/src/mfa/assertions/totp.d.ts +124 -0
- package/dist/rn/src/mfa/assertions/totp.test.d.ts +17 -0
- package/dist/rn/src/mfa/mfa_info.d.ts +5 -1
- package/dist/rn/src/model/enum_maps.d.ts +1 -0
- package/dist/rn/src/model/public_types.d.ts +18 -1
- package/dist/rn/test/helpers/integration/helpers.d.ts +3 -0
- package/dist/rn/test/integration/flows/totp.test.d.ts +17 -0
- package/dist/src/api/account_management/mfa.d.ts +38 -4
- package/dist/src/api/authentication/mfa.d.ts +11 -0
- package/dist/src/core/errors.d.ts +1 -0
- package/dist/src/core/index.d.ts +1 -0
- package/dist/src/mfa/assertions/totp.d.ts +124 -0
- package/dist/src/mfa/assertions/totp.test.d.ts +17 -0
- package/dist/src/mfa/mfa_info.d.ts +5 -1
- package/dist/src/model/enum_maps.d.ts +1 -0
- package/dist/src/model/public_types.d.ts +18 -1
- package/dist/test/helpers/integration/helpers.d.ts +3 -0
- package/dist/test/integration/flows/totp.test.d.ts +17 -0
- package/package.json +10 -8
- package/dist/browser-cjs/index-ff477525.js.map +0 -1
- package/dist/cordova/popup_redirect-a4d3c436.js.map +0 -1
- package/dist/esm2017/index-3363a72a.js.map +0 -1
- package/dist/esm5/index-3f05dc7b.js.map +0 -1
- package/dist/node/index-45468d80.js.map +0 -1
- package/dist/node-esm/index-1f9492de.js.map +0 -1
- package/dist/rn/phone-e7bf48a1.js.map +0 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,13 @@
|
|
|
1
1
|
# @firebase/auth
|
|
2
2
|
|
|
3
|
+
## 0.21.6
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- [`58bae8757`](https://github.com/firebase/firebase-js-sdk/commit/58bae875799ed2ace8232f5d9e7aaaaa7a84d064) [#7146](https://github.com/firebase/firebase-js-sdk/pull/7146) - Support TOTP as a multi-factor option in Firebase Auth/GCIP.
|
|
8
|
+
|
|
9
|
+
- [`00737a1ab`](https://github.com/firebase/firebase-js-sdk/commit/00737a1abd469f3deb041d8ff482165cc16bc34e) [#7125](https://github.com/firebase/firebase-js-sdk/pull/7125) (fixes [#7118](https://github.com/firebase/firebase-js-sdk/issues/7118)) - Modify \_fail to use AuthErrorCode.NETWORK_REQUEST_FAILED
|
|
10
|
+
|
|
3
11
|
## 0.21.5
|
|
4
12
|
|
|
5
13
|
### Patch Changes
|
package/README.md
CHANGED
|
@@ -17,6 +17,7 @@ host of npm scripts to run these tests. The most important commands are:
|
|
|
17
17
|
| `yarn test:<platform>:unit:debug` | Runs \<platform> unit tests, auto-watching for file system changes |
|
|
18
18
|
| `yarn test:<platform>:integration` | Runs only integration tests against the live environment |
|
|
19
19
|
| `yarn test:<platform>:integration:local` | Runs all headless \<platform> integration tests against the emulator (more below) |
|
|
20
|
+
| `yarn test:browser:integration:prodbackend` | Runs TOTP MFA integration tests against the backend (more below) |
|
|
20
21
|
|
|
21
22
|
Where \<platform> is "browser" or "node". There are also cordova tests, but they
|
|
22
23
|
are not broken into such granular details. Check out `package.json` for more.
|
|
@@ -39,6 +40,11 @@ commands also run various tests:
|
|
|
39
40
|
* `yarn test:webdriver` — Executes only the Selenium WebDriver
|
|
40
41
|
integration tests
|
|
41
42
|
|
|
43
|
+
Note - The webdriver tests require the Chrome webdriver to match the version of Chrome running locally.
|
|
44
|
+
In the CI environment, this is ensured using the environment variable [here.](https://github.com/firebase/firebase-js-sdk/blob/6e80a678fe0c31046860554cec0459a2be34d22b/.github/workflows/test-changed-auth.yml#L7)
|
|
45
|
+
When running locally, change the chromedriver version in [package.json](https://github.com/firebase/firebase-js-sdk/blob/6e80a678fe0c31046860554cec0459a2be34d22b/packages/auth/package.json#L124) to match your local Chrome version and run `yarn install`.
|
|
46
|
+
|
|
47
|
+
|
|
42
48
|
For example, to run all integration and WebDriver tests against the emulator,
|
|
43
49
|
you would simply execute the following command:
|
|
44
50
|
|
|
@@ -46,6 +52,25 @@ you would simply execute the following command:
|
|
|
46
52
|
firebase emulators:exec --project foo-bar --only auth "yarn test:integration:local"
|
|
47
53
|
```
|
|
48
54
|
|
|
55
|
+
### Integration testing with the production backend
|
|
56
|
+
|
|
57
|
+
Currently, MFA TOTP tests only run against the production backend (since they are not supported on the emulator yet).
|
|
58
|
+
Running against the backend also makes it a more reliable end-to-end test.
|
|
59
|
+
|
|
60
|
+
The TOTP tests require the following email/password combination to exist in the project, so if you are running this test against your test project, please create this user:
|
|
61
|
+
|
|
62
|
+
'totpuser-donotdelete@test.com', 'password'
|
|
63
|
+
|
|
64
|
+
You also need to verify this email address, in order to use MFA. This can be done with a curl command like this:
|
|
65
|
+
|
|
66
|
+
```
|
|
67
|
+
curl -H "Authorization: Bearer $(gcloud auth print-access-token)" -H "Content-Type: application/json" -H "X-Goog-User-Project: ${PROJECT_ID}" -X POST https://identitytoolkit.googleapis.com/v1/accounts:sendOobCode -d '{
|
|
68
|
+
"email": "totpuser-donotdelete@test.com",
|
|
69
|
+
"requestType": "VERIFY_EMAIL",
|
|
70
|
+
"returnOobLink": true,
|
|
71
|
+
}'
|
|
72
|
+
```
|
|
73
|
+
|
|
49
74
|
### Selenium Webdriver tests
|
|
50
75
|
|
|
51
76
|
These tests assume that you have both Firefox and Chrome installed on your
|
package/dist/auth-public.d.ts
CHANGED
|
@@ -670,7 +670,7 @@ export declare interface AuthSettings {
|
|
|
670
670
|
}
|
|
671
671
|
|
|
672
672
|
/**
|
|
673
|
-
* MFA Info as returned by the API
|
|
673
|
+
* MFA Info as returned by the API.
|
|
674
674
|
*/
|
|
675
675
|
declare interface BaseMfaEnrollment {
|
|
676
676
|
mfaEnrollmentId: string;
|
|
@@ -1154,6 +1154,7 @@ export declare class FacebookAuthProvider extends BaseOAuthProvider {
|
|
|
1154
1154
|
export declare const FactorId: {
|
|
1155
1155
|
/** Phone as second factor */
|
|
1156
1156
|
readonly PHONE: "phone";
|
|
1157
|
+
readonly TOTP: "totp";
|
|
1157
1158
|
};
|
|
1158
1159
|
|
|
1159
1160
|
/**
|
|
@@ -1657,9 +1658,9 @@ export declare function linkWithPopup(user: User, provider: AuthProvider, resolv
|
|
|
1657
1658
|
export declare function linkWithRedirect(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<never>;
|
|
1658
1659
|
|
|
1659
1660
|
/**
|
|
1660
|
-
* MfaEnrollment can be any subtype of BaseMfaEnrollment, currently only PhoneMfaEnrollment
|
|
1661
|
+
* MfaEnrollment can be any subtype of BaseMfaEnrollment, currently only PhoneMfaEnrollment and TotpMfaEnrollment are supported.
|
|
1661
1662
|
*/
|
|
1662
|
-
declare type MfaEnrollment = PhoneMfaEnrollment;
|
|
1663
|
+
declare type MfaEnrollment = PhoneMfaEnrollment | TotpMfaEnrollment;
|
|
1663
1664
|
|
|
1664
1665
|
/**
|
|
1665
1666
|
* The {@link MultiFactorUser} corresponding to the user.
|
|
@@ -2132,6 +2133,7 @@ export declare function onAuthStateChanged(auth: Auth, nextOrObserver: NextOrObs
|
|
|
2132
2133
|
*
|
|
2133
2134
|
* @remarks
|
|
2134
2135
|
* This includes sign-in, sign-out, and token refresh events.
|
|
2136
|
+
* This will not be triggered automatically upon ID token expiration. Use {@link User.getIdToken} to refresh the ID token.
|
|
2135
2137
|
*
|
|
2136
2138
|
* @param auth - The {@link Auth} instance.
|
|
2137
2139
|
* @param nextOrObserver - callback triggered on change.
|
|
@@ -2371,7 +2373,7 @@ export declare class PhoneAuthProvider {
|
|
|
2371
2373
|
export declare type PhoneInfoOptions = PhoneSingleFactorInfoOptions | PhoneMultiFactorEnrollInfoOptions | PhoneMultiFactorSignInInfoOptions;
|
|
2372
2374
|
|
|
2373
2375
|
/**
|
|
2374
|
-
* An MFA provided by SMS verification
|
|
2376
|
+
* An MFA provided by SMS verification.
|
|
2375
2377
|
*/
|
|
2376
2378
|
declare interface PhoneMfaEnrollment extends BaseMfaEnrollment {
|
|
2377
2379
|
phoneInfo: string;
|
|
@@ -3148,10 +3150,139 @@ export declare function signInWithRedirect(auth: Auth, provider: AuthProvider, r
|
|
|
3148
3150
|
*/
|
|
3149
3151
|
export declare function signOut(auth: Auth): Promise<void>;
|
|
3150
3152
|
|
|
3153
|
+
declare interface StartTotpMfaEnrollmentResponse {
|
|
3154
|
+
totpSessionInfo: {
|
|
3155
|
+
sharedSecretKey: string;
|
|
3156
|
+
verificationCodeLength: number;
|
|
3157
|
+
hashingAlgorithm: string;
|
|
3158
|
+
periodSec: number;
|
|
3159
|
+
sessionInfo: string;
|
|
3160
|
+
finalizeEnrollmentTime: number;
|
|
3161
|
+
};
|
|
3162
|
+
}
|
|
3163
|
+
|
|
3151
3164
|
/* Excluded from this release type: StsTokenManager */
|
|
3152
3165
|
|
|
3153
3166
|
/* Excluded from this release type: TaggedWithTokenResponse */
|
|
3154
3167
|
|
|
3168
|
+
/**
|
|
3169
|
+
* An MFA provided by TOTP (Time-based One Time Password).
|
|
3170
|
+
*/
|
|
3171
|
+
declare interface TotpMfaEnrollment extends BaseMfaEnrollment {
|
|
3172
|
+
}
|
|
3173
|
+
|
|
3174
|
+
/**
|
|
3175
|
+
* The class for asserting ownership of a TOTP second factor. Provided by
|
|
3176
|
+
* {@link TotpMultiFactorGenerator.assertionForEnrollment} and
|
|
3177
|
+
* {@link TotpMultiFactorGenerator.assertionForSignIn}.
|
|
3178
|
+
*
|
|
3179
|
+
* @public
|
|
3180
|
+
*/
|
|
3181
|
+
export declare interface TotpMultiFactorAssertion extends MultiFactorAssertion {
|
|
3182
|
+
}
|
|
3183
|
+
|
|
3184
|
+
/**
|
|
3185
|
+
* Provider for generating a {@link TotpMultiFactorAssertion}.
|
|
3186
|
+
*
|
|
3187
|
+
* @public
|
|
3188
|
+
*/
|
|
3189
|
+
export declare class TotpMultiFactorGenerator {
|
|
3190
|
+
/**
|
|
3191
|
+
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of
|
|
3192
|
+
* the TOTP (time-based one-time password) second factor.
|
|
3193
|
+
* This assertion is used to complete enrollment in TOTP second factor.
|
|
3194
|
+
*
|
|
3195
|
+
* @param secret A {@link TotpSecret} containing the shared secret key and other TOTP parameters.
|
|
3196
|
+
* @param oneTimePassword One-time password from TOTP App.
|
|
3197
|
+
* @returns A {@link TotpMultiFactorAssertion} which can be used with
|
|
3198
|
+
* {@link MultiFactorUser.enroll}.
|
|
3199
|
+
*/
|
|
3200
|
+
static assertionForEnrollment(secret: TotpSecret, oneTimePassword: string): TotpMultiFactorAssertion;
|
|
3201
|
+
/**
|
|
3202
|
+
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of the TOTP second factor.
|
|
3203
|
+
* This assertion is used to complete signIn with TOTP as the second factor.
|
|
3204
|
+
*
|
|
3205
|
+
* @param enrollmentId identifies the enrolled TOTP second factor.
|
|
3206
|
+
* @param oneTimePassword One-time password from TOTP App.
|
|
3207
|
+
* @returns A {@link TotpMultiFactorAssertion} which can be used with
|
|
3208
|
+
* {@link MultiFactorResolver.resolveSignIn}.
|
|
3209
|
+
*/
|
|
3210
|
+
static assertionForSignIn(enrollmentId: string, oneTimePassword: string): TotpMultiFactorAssertion;
|
|
3211
|
+
/**
|
|
3212
|
+
* Returns a promise to {@link TotpSecret} which contains the TOTP shared secret key and other parameters.
|
|
3213
|
+
* Creates a TOTP secret as part of enrolling a TOTP second factor.
|
|
3214
|
+
* Used for generating a QR code URL or inputting into a TOTP app.
|
|
3215
|
+
* This method uses the auth instance corresponding to the user in the multiFactorSession.
|
|
3216
|
+
*
|
|
3217
|
+
* @param session The {@link MultiFactorSession} that the user is part of.
|
|
3218
|
+
* @returns A promise to {@link TotpSecret}.
|
|
3219
|
+
*/
|
|
3220
|
+
static generateSecret(session: MultiFactorSession): Promise<TotpSecret>;
|
|
3221
|
+
/**
|
|
3222
|
+
* The identifier of the TOTP second factor: `totp`.
|
|
3223
|
+
*/
|
|
3224
|
+
static FACTOR_ID: 'totp';
|
|
3225
|
+
}
|
|
3226
|
+
|
|
3227
|
+
/**
|
|
3228
|
+
* The subclass of the {@link MultiFactorInfo} interface for TOTP
|
|
3229
|
+
* second factors. The `factorId` of this second factor is {@link FactorId}.TOTP.
|
|
3230
|
+
* @public
|
|
3231
|
+
*/
|
|
3232
|
+
export declare interface TotpMultiFactorInfo extends MultiFactorInfo {
|
|
3233
|
+
}
|
|
3234
|
+
|
|
3235
|
+
/**
|
|
3236
|
+
* Provider for generating a {@link TotpMultiFactorAssertion}.
|
|
3237
|
+
*
|
|
3238
|
+
* Stores the shared secret key and other parameters to generate time-based OTPs.
|
|
3239
|
+
* Implements methods to retrieve the shared secret key and generate a QR code URL.
|
|
3240
|
+
* @public
|
|
3241
|
+
*/
|
|
3242
|
+
export declare class TotpSecret {
|
|
3243
|
+
private readonly sessionInfo;
|
|
3244
|
+
private readonly auth;
|
|
3245
|
+
/**
|
|
3246
|
+
* Shared secret key/seed used for enrolling in TOTP MFA and generating OTPs.
|
|
3247
|
+
*/
|
|
3248
|
+
readonly secretKey: string;
|
|
3249
|
+
/**
|
|
3250
|
+
* Hashing algorithm used.
|
|
3251
|
+
*/
|
|
3252
|
+
readonly hashingAlgorithm: string;
|
|
3253
|
+
/**
|
|
3254
|
+
* Length of the one-time passwords to be generated.
|
|
3255
|
+
*/
|
|
3256
|
+
readonly codeLength: number;
|
|
3257
|
+
/**
|
|
3258
|
+
* The interval (in seconds) when the OTP codes should change.
|
|
3259
|
+
*/
|
|
3260
|
+
readonly codeIntervalSeconds: number;
|
|
3261
|
+
/**
|
|
3262
|
+
* The timestamp (UTC string) by which TOTP enrollment should be completed.
|
|
3263
|
+
*/
|
|
3264
|
+
readonly enrollmentCompletionDeadline: string;
|
|
3265
|
+
private constructor();
|
|
3266
|
+
/* Excluded from this release type: _fromStartTotpMfaEnrollmentResponse */
|
|
3267
|
+
/* Excluded from this release type: _makeTotpVerificationInfo */
|
|
3268
|
+
/**
|
|
3269
|
+
* Returns a QR code URL as described in
|
|
3270
|
+
* https://github.com/google/google-authenticator/wiki/Key-Uri-Format
|
|
3271
|
+
* This can be displayed to the user as a QR code to be scanned into a TOTP app like Google Authenticator.
|
|
3272
|
+
* If the optional parameters are unspecified, an accountName of <userEmail> and issuer of <firebaseAppName> are used.
|
|
3273
|
+
*
|
|
3274
|
+
* @param accountName the name of the account/app along with a user identifier.
|
|
3275
|
+
* @param issuer issuer of the TOTP (likely the app name).
|
|
3276
|
+
* @returns A QR code URL string.
|
|
3277
|
+
*/
|
|
3278
|
+
generateQrCodeUrl(accountName?: string, issuer?: string): string;
|
|
3279
|
+
}
|
|
3280
|
+
|
|
3281
|
+
declare interface TotpVerificationInfo {
|
|
3282
|
+
sessionInfo: string;
|
|
3283
|
+
verificationCode: string;
|
|
3284
|
+
}
|
|
3285
|
+
|
|
3155
3286
|
/**
|
|
3156
3287
|
* Provider for generating an {@link OAuthCredential} for {@link ProviderId}.TWITTER.
|
|
3157
3288
|
*
|
package/dist/auth.d.ts
CHANGED
|
@@ -575,6 +575,7 @@ declare const enum AuthErrorCode {
|
|
|
575
575
|
MISSING_MFA_INFO = "missing-multi-factor-info",
|
|
576
576
|
MISSING_MFA_SESSION = "missing-multi-factor-session",
|
|
577
577
|
MISSING_PHONE_NUMBER = "missing-phone-number",
|
|
578
|
+
MISSING_PASSWORD = "missing-password",
|
|
578
579
|
MISSING_SESSION_INFO = "missing-verification-id",
|
|
579
580
|
MODULE_DESTROYED = "app-deleted",
|
|
580
581
|
NEED_CONFIRMATION = "account-exists-with-different-credential",
|
|
@@ -897,7 +898,7 @@ export declare interface AuthSettings {
|
|
|
897
898
|
}
|
|
898
899
|
|
|
899
900
|
/**
|
|
900
|
-
* MFA Info as returned by the API
|
|
901
|
+
* MFA Info as returned by the API.
|
|
901
902
|
*/
|
|
902
903
|
declare interface BaseMfaEnrollment {
|
|
903
904
|
mfaEnrollmentId: string;
|
|
@@ -1420,6 +1421,7 @@ export declare class FacebookAuthProvider extends BaseOAuthProvider {
|
|
|
1420
1421
|
export declare const FactorId: {
|
|
1421
1422
|
/** Phone as second factor */
|
|
1422
1423
|
readonly PHONE: "phone";
|
|
1424
|
+
readonly TOTP: "totp";
|
|
1423
1425
|
};
|
|
1424
1426
|
|
|
1425
1427
|
/**
|
|
@@ -1978,9 +1980,9 @@ export declare function linkWithPopup(user: User, provider: AuthProvider, resolv
|
|
|
1978
1980
|
export declare function linkWithRedirect(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<never>;
|
|
1979
1981
|
|
|
1980
1982
|
/**
|
|
1981
|
-
* MfaEnrollment can be any subtype of BaseMfaEnrollment, currently only PhoneMfaEnrollment
|
|
1983
|
+
* MfaEnrollment can be any subtype of BaseMfaEnrollment, currently only PhoneMfaEnrollment and TotpMfaEnrollment are supported.
|
|
1982
1984
|
*/
|
|
1983
|
-
declare type MfaEnrollment = PhoneMfaEnrollment;
|
|
1985
|
+
declare type MfaEnrollment = PhoneMfaEnrollment | TotpMfaEnrollment;
|
|
1984
1986
|
|
|
1985
1987
|
/**
|
|
1986
1988
|
* The {@link MultiFactorUser} corresponding to the user.
|
|
@@ -2457,6 +2459,7 @@ export declare function onAuthStateChanged(auth: Auth, nextOrObserver: NextOrObs
|
|
|
2457
2459
|
*
|
|
2458
2460
|
* @remarks
|
|
2459
2461
|
* This includes sign-in, sign-out, and token refresh events.
|
|
2462
|
+
* This will not be triggered automatically upon ID token expiration. Use {@link User.getIdToken} to refresh the ID token.
|
|
2460
2463
|
*
|
|
2461
2464
|
* @param auth - The {@link Auth} instance.
|
|
2462
2465
|
* @param nextOrObserver - callback triggered on change.
|
|
@@ -2702,7 +2705,7 @@ export declare class PhoneAuthProvider {
|
|
|
2702
2705
|
export declare type PhoneInfoOptions = PhoneSingleFactorInfoOptions | PhoneMultiFactorEnrollInfoOptions | PhoneMultiFactorSignInInfoOptions;
|
|
2703
2706
|
|
|
2704
2707
|
/**
|
|
2705
|
-
* An MFA provided by SMS verification
|
|
2708
|
+
* An MFA provided by SMS verification.
|
|
2706
2709
|
*/
|
|
2707
2710
|
declare interface PhoneMfaEnrollment extends BaseMfaEnrollment {
|
|
2708
2711
|
phoneInfo: string;
|
|
@@ -3572,6 +3575,17 @@ export declare function signInWithRedirect(auth: Auth, provider: AuthProvider, r
|
|
|
3572
3575
|
*/
|
|
3573
3576
|
export declare function signOut(auth: Auth): Promise<void>;
|
|
3574
3577
|
|
|
3578
|
+
declare interface StartTotpMfaEnrollmentResponse {
|
|
3579
|
+
totpSessionInfo: {
|
|
3580
|
+
sharedSecretKey: string;
|
|
3581
|
+
verificationCodeLength: number;
|
|
3582
|
+
hashingAlgorithm: string;
|
|
3583
|
+
periodSec: number;
|
|
3584
|
+
sessionInfo: string;
|
|
3585
|
+
finalizeEnrollmentTime: number;
|
|
3586
|
+
};
|
|
3587
|
+
}
|
|
3588
|
+
|
|
3575
3589
|
/**
|
|
3576
3590
|
* We need to mark this class as internal explicitly to exclude it in the public typings, because
|
|
3577
3591
|
* it references AuthInternal which has a circular dependency with UserInternal.
|
|
@@ -3602,6 +3616,126 @@ declare interface TaggedWithTokenResponse {
|
|
|
3602
3616
|
_tokenResponse?: PhoneOrOauthTokenResponse;
|
|
3603
3617
|
}
|
|
3604
3618
|
|
|
3619
|
+
/**
|
|
3620
|
+
* An MFA provided by TOTP (Time-based One Time Password).
|
|
3621
|
+
*/
|
|
3622
|
+
declare interface TotpMfaEnrollment extends BaseMfaEnrollment {
|
|
3623
|
+
}
|
|
3624
|
+
|
|
3625
|
+
/**
|
|
3626
|
+
* The class for asserting ownership of a TOTP second factor. Provided by
|
|
3627
|
+
* {@link TotpMultiFactorGenerator.assertionForEnrollment} and
|
|
3628
|
+
* {@link TotpMultiFactorGenerator.assertionForSignIn}.
|
|
3629
|
+
*
|
|
3630
|
+
* @public
|
|
3631
|
+
*/
|
|
3632
|
+
export declare interface TotpMultiFactorAssertion extends MultiFactorAssertion {
|
|
3633
|
+
}
|
|
3634
|
+
|
|
3635
|
+
/**
|
|
3636
|
+
* Provider for generating a {@link TotpMultiFactorAssertion}.
|
|
3637
|
+
*
|
|
3638
|
+
* @public
|
|
3639
|
+
*/
|
|
3640
|
+
export declare class TotpMultiFactorGenerator {
|
|
3641
|
+
/**
|
|
3642
|
+
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of
|
|
3643
|
+
* the TOTP (time-based one-time password) second factor.
|
|
3644
|
+
* This assertion is used to complete enrollment in TOTP second factor.
|
|
3645
|
+
*
|
|
3646
|
+
* @param secret A {@link TotpSecret} containing the shared secret key and other TOTP parameters.
|
|
3647
|
+
* @param oneTimePassword One-time password from TOTP App.
|
|
3648
|
+
* @returns A {@link TotpMultiFactorAssertion} which can be used with
|
|
3649
|
+
* {@link MultiFactorUser.enroll}.
|
|
3650
|
+
*/
|
|
3651
|
+
static assertionForEnrollment(secret: TotpSecret, oneTimePassword: string): TotpMultiFactorAssertion;
|
|
3652
|
+
/**
|
|
3653
|
+
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of the TOTP second factor.
|
|
3654
|
+
* This assertion is used to complete signIn with TOTP as the second factor.
|
|
3655
|
+
*
|
|
3656
|
+
* @param enrollmentId identifies the enrolled TOTP second factor.
|
|
3657
|
+
* @param oneTimePassword One-time password from TOTP App.
|
|
3658
|
+
* @returns A {@link TotpMultiFactorAssertion} which can be used with
|
|
3659
|
+
* {@link MultiFactorResolver.resolveSignIn}.
|
|
3660
|
+
*/
|
|
3661
|
+
static assertionForSignIn(enrollmentId: string, oneTimePassword: string): TotpMultiFactorAssertion;
|
|
3662
|
+
/**
|
|
3663
|
+
* Returns a promise to {@link TotpSecret} which contains the TOTP shared secret key and other parameters.
|
|
3664
|
+
* Creates a TOTP secret as part of enrolling a TOTP second factor.
|
|
3665
|
+
* Used for generating a QR code URL or inputting into a TOTP app.
|
|
3666
|
+
* This method uses the auth instance corresponding to the user in the multiFactorSession.
|
|
3667
|
+
*
|
|
3668
|
+
* @param session The {@link MultiFactorSession} that the user is part of.
|
|
3669
|
+
* @returns A promise to {@link TotpSecret}.
|
|
3670
|
+
*/
|
|
3671
|
+
static generateSecret(session: MultiFactorSession): Promise<TotpSecret>;
|
|
3672
|
+
/**
|
|
3673
|
+
* The identifier of the TOTP second factor: `totp`.
|
|
3674
|
+
*/
|
|
3675
|
+
static FACTOR_ID: 'totp';
|
|
3676
|
+
}
|
|
3677
|
+
|
|
3678
|
+
/**
|
|
3679
|
+
* The subclass of the {@link MultiFactorInfo} interface for TOTP
|
|
3680
|
+
* second factors. The `factorId` of this second factor is {@link FactorId}.TOTP.
|
|
3681
|
+
* @public
|
|
3682
|
+
*/
|
|
3683
|
+
export declare interface TotpMultiFactorInfo extends MultiFactorInfo {
|
|
3684
|
+
}
|
|
3685
|
+
|
|
3686
|
+
/**
|
|
3687
|
+
* Provider for generating a {@link TotpMultiFactorAssertion}.
|
|
3688
|
+
*
|
|
3689
|
+
* Stores the shared secret key and other parameters to generate time-based OTPs.
|
|
3690
|
+
* Implements methods to retrieve the shared secret key and generate a QR code URL.
|
|
3691
|
+
* @public
|
|
3692
|
+
*/
|
|
3693
|
+
export declare class TotpSecret {
|
|
3694
|
+
private readonly sessionInfo;
|
|
3695
|
+
private readonly auth;
|
|
3696
|
+
/**
|
|
3697
|
+
* Shared secret key/seed used for enrolling in TOTP MFA and generating OTPs.
|
|
3698
|
+
*/
|
|
3699
|
+
readonly secretKey: string;
|
|
3700
|
+
/**
|
|
3701
|
+
* Hashing algorithm used.
|
|
3702
|
+
*/
|
|
3703
|
+
readonly hashingAlgorithm: string;
|
|
3704
|
+
/**
|
|
3705
|
+
* Length of the one-time passwords to be generated.
|
|
3706
|
+
*/
|
|
3707
|
+
readonly codeLength: number;
|
|
3708
|
+
/**
|
|
3709
|
+
* The interval (in seconds) when the OTP codes should change.
|
|
3710
|
+
*/
|
|
3711
|
+
readonly codeIntervalSeconds: number;
|
|
3712
|
+
/**
|
|
3713
|
+
* The timestamp (UTC string) by which TOTP enrollment should be completed.
|
|
3714
|
+
*/
|
|
3715
|
+
readonly enrollmentCompletionDeadline: string;
|
|
3716
|
+
private constructor();
|
|
3717
|
+
/** @internal */
|
|
3718
|
+
static _fromStartTotpMfaEnrollmentResponse(response: StartTotpMfaEnrollmentResponse, auth: AuthInternal): TotpSecret;
|
|
3719
|
+
/** @internal */
|
|
3720
|
+
_makeTotpVerificationInfo(otp: string): TotpVerificationInfo;
|
|
3721
|
+
/**
|
|
3722
|
+
* Returns a QR code URL as described in
|
|
3723
|
+
* https://github.com/google/google-authenticator/wiki/Key-Uri-Format
|
|
3724
|
+
* This can be displayed to the user as a QR code to be scanned into a TOTP app like Google Authenticator.
|
|
3725
|
+
* If the optional parameters are unspecified, an accountName of <userEmail> and issuer of <firebaseAppName> are used.
|
|
3726
|
+
*
|
|
3727
|
+
* @param accountName the name of the account/app along with a user identifier.
|
|
3728
|
+
* @param issuer issuer of the TOTP (likely the app name).
|
|
3729
|
+
* @returns A QR code URL string.
|
|
3730
|
+
*/
|
|
3731
|
+
generateQrCodeUrl(accountName?: string, issuer?: string): string;
|
|
3732
|
+
}
|
|
3733
|
+
|
|
3734
|
+
declare interface TotpVerificationInfo {
|
|
3735
|
+
sessionInfo: string;
|
|
3736
|
+
verificationCode: string;
|
|
3737
|
+
}
|
|
3738
|
+
|
|
3605
3739
|
/**
|
|
3606
3740
|
* Provider for generating an {@link OAuthCredential} for {@link ProviderId}.TWITTER.
|
|
3607
3741
|
*
|