@firebase/auth 0.21.5-canary.6e80a678f → 0.21.5-canary.81cb20a2f
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 +25 -0
- package/dist/auth-public.d.ts +137 -4
- package/dist/auth.d.ts +148 -4
- package/dist/browser-cjs/{index-0e4450da.js → index-243a5398.js} +174 -3
- package/dist/browser-cjs/index-243a5398.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/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-a2c6887b.js → popup_redirect-69eb3f6e.js} +25 -4
- package/dist/cordova/popup_redirect-69eb3f6e.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/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-5aecf935.js → index-29f286f5.js} +173 -4
- package/dist/esm2017/index-29f286f5.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/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-b9ec9062.js → index-40066eaa.js} +201 -4
- package/dist/esm5/index-40066eaa.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/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 +17 -2
- 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/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-f1263830.js → totp-71bc3d0d.js} +237 -4
- package/dist/node/totp-71bc3d0d.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/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-590d6912.js → totp-1dc5987e.js} +207 -5
- package/dist/node-esm/totp-1dc5987e.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-628fcf7d.js → phone-151d0f85.js} +31 -3
- package/dist/rn/phone-151d0f85.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/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/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-0e4450da.js.map +0 -1
- package/dist/cordova/popup_redirect-a2c6887b.js.map +0 -1
- package/dist/esm2017/index-5aecf935.js.map +0 -1
- package/dist/esm5/index-b9ec9062.js.map +0 -1
- package/dist/node/index-f1263830.js.map +0 -1
- package/dist/node-esm/index-590d6912.js.map +0 -1
- package/dist/rn/phone-628fcf7d.js.map +0 -1
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,8 +1154,11 @@ 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
|
|
|
1160
|
+
/* Excluded from this release type: FactorId_2 */
|
|
1161
|
+
|
|
1159
1162
|
/**
|
|
1160
1163
|
* The base class for all Federated providers (OAuth (including OIDC), SAML).
|
|
1161
1164
|
*
|
|
@@ -1657,9 +1660,9 @@ export declare function linkWithPopup(user: User, provider: AuthProvider, resolv
|
|
|
1657
1660
|
export declare function linkWithRedirect(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<never>;
|
|
1658
1661
|
|
|
1659
1662
|
/**
|
|
1660
|
-
* MfaEnrollment can be any subtype of BaseMfaEnrollment, currently only PhoneMfaEnrollment
|
|
1663
|
+
* MfaEnrollment can be any subtype of BaseMfaEnrollment, currently only PhoneMfaEnrollment and TotpMfaEnrollment are supported.
|
|
1661
1664
|
*/
|
|
1662
|
-
declare type MfaEnrollment = PhoneMfaEnrollment;
|
|
1665
|
+
declare type MfaEnrollment = PhoneMfaEnrollment | TotpMfaEnrollment;
|
|
1663
1666
|
|
|
1664
1667
|
/**
|
|
1665
1668
|
* The {@link MultiFactorUser} corresponding to the user.
|
|
@@ -2132,6 +2135,7 @@ export declare function onAuthStateChanged(auth: Auth, nextOrObserver: NextOrObs
|
|
|
2132
2135
|
*
|
|
2133
2136
|
* @remarks
|
|
2134
2137
|
* This includes sign-in, sign-out, and token refresh events.
|
|
2138
|
+
* This will not be triggered automatically upon ID token expiration. Use {@link User.getIdToken} to refresh the ID token.
|
|
2135
2139
|
*
|
|
2136
2140
|
* @param auth - The {@link Auth} instance.
|
|
2137
2141
|
* @param nextOrObserver - callback triggered on change.
|
|
@@ -2371,7 +2375,7 @@ export declare class PhoneAuthProvider {
|
|
|
2371
2375
|
export declare type PhoneInfoOptions = PhoneSingleFactorInfoOptions | PhoneMultiFactorEnrollInfoOptions | PhoneMultiFactorSignInInfoOptions;
|
|
2372
2376
|
|
|
2373
2377
|
/**
|
|
2374
|
-
* An MFA provided by SMS verification
|
|
2378
|
+
* An MFA provided by SMS verification.
|
|
2375
2379
|
*/
|
|
2376
2380
|
declare interface PhoneMfaEnrollment extends BaseMfaEnrollment {
|
|
2377
2381
|
phoneInfo: string;
|
|
@@ -3148,10 +3152,139 @@ export declare function signInWithRedirect(auth: Auth, provider: AuthProvider, r
|
|
|
3148
3152
|
*/
|
|
3149
3153
|
export declare function signOut(auth: Auth): Promise<void>;
|
|
3150
3154
|
|
|
3155
|
+
declare interface StartTotpMfaEnrollmentResponse {
|
|
3156
|
+
totpSessionInfo: {
|
|
3157
|
+
sharedSecretKey: string;
|
|
3158
|
+
verificationCodeLength: number;
|
|
3159
|
+
hashingAlgorithm: string;
|
|
3160
|
+
periodSec: number;
|
|
3161
|
+
sessionInfo: string;
|
|
3162
|
+
finalizeEnrollmentTime: number;
|
|
3163
|
+
};
|
|
3164
|
+
}
|
|
3165
|
+
|
|
3151
3166
|
/* Excluded from this release type: StsTokenManager */
|
|
3152
3167
|
|
|
3153
3168
|
/* Excluded from this release type: TaggedWithTokenResponse */
|
|
3154
3169
|
|
|
3170
|
+
/**
|
|
3171
|
+
* An MFA provided by TOTP (Time-based One Time Password).
|
|
3172
|
+
*/
|
|
3173
|
+
declare interface TotpMfaEnrollment extends BaseMfaEnrollment {
|
|
3174
|
+
}
|
|
3175
|
+
|
|
3176
|
+
/**
|
|
3177
|
+
* The class for asserting ownership of a TOTP second factor. Provided by
|
|
3178
|
+
* {@link TotpMultiFactorGenerator.assertionForEnrollment} and
|
|
3179
|
+
* {@link TotpMultiFactorGenerator.assertionForSignIn}.
|
|
3180
|
+
*
|
|
3181
|
+
* @public
|
|
3182
|
+
*/
|
|
3183
|
+
export declare interface TotpMultiFactorAssertion extends MultiFactorAssertion {
|
|
3184
|
+
}
|
|
3185
|
+
|
|
3186
|
+
/**
|
|
3187
|
+
* Provider for generating a {@link TotpMultiFactorAssertion}.
|
|
3188
|
+
*
|
|
3189
|
+
* @public
|
|
3190
|
+
*/
|
|
3191
|
+
export declare class TotpMultiFactorGenerator {
|
|
3192
|
+
/**
|
|
3193
|
+
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of
|
|
3194
|
+
* the TOTP (time-based one-time password) second factor.
|
|
3195
|
+
* This assertion is used to complete enrollment in TOTP second factor.
|
|
3196
|
+
*
|
|
3197
|
+
* @param secret A {@link TotpSecret} containing the shared secret key and other TOTP parameters.
|
|
3198
|
+
* @param oneTimePassword One-time password from TOTP App.
|
|
3199
|
+
* @returns A {@link TotpMultiFactorAssertion} which can be used with
|
|
3200
|
+
* {@link MultiFactorUser.enroll}.
|
|
3201
|
+
*/
|
|
3202
|
+
static assertionForEnrollment(secret: TotpSecret, oneTimePassword: string): TotpMultiFactorAssertion;
|
|
3203
|
+
/**
|
|
3204
|
+
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of the TOTP second factor.
|
|
3205
|
+
* This assertion is used to complete signIn with TOTP as the second factor.
|
|
3206
|
+
*
|
|
3207
|
+
* @param enrollmentId identifies the enrolled TOTP second factor.
|
|
3208
|
+
* @param oneTimePassword One-time password from TOTP App.
|
|
3209
|
+
* @returns A {@link TotpMultiFactorAssertion} which can be used with
|
|
3210
|
+
* {@link MultiFactorResolver.resolveSignIn}.
|
|
3211
|
+
*/
|
|
3212
|
+
static assertionForSignIn(enrollmentId: string, oneTimePassword: string): TotpMultiFactorAssertion;
|
|
3213
|
+
/**
|
|
3214
|
+
* Returns a promise to {@link TotpSecret} which contains the TOTP shared secret key and other parameters.
|
|
3215
|
+
* Creates a TOTP secret as part of enrolling a TOTP second factor.
|
|
3216
|
+
* Used for generating a QR code URL or inputting into a TOTP app.
|
|
3217
|
+
* This method uses the auth instance corresponding to the user in the multiFactorSession.
|
|
3218
|
+
*
|
|
3219
|
+
* @param session The {@link MultiFactorSession} that the user is part of.
|
|
3220
|
+
* @returns A promise to {@link TotpSecret}.
|
|
3221
|
+
*/
|
|
3222
|
+
static generateSecret(session: MultiFactorSession): Promise<TotpSecret>;
|
|
3223
|
+
/**
|
|
3224
|
+
* The identifier of the TOTP second factor: `totp`.
|
|
3225
|
+
*/
|
|
3226
|
+
static FACTOR_ID: FactorId_2;
|
|
3227
|
+
}
|
|
3228
|
+
|
|
3229
|
+
/**
|
|
3230
|
+
* The subclass of the {@link MultiFactorInfo} interface for TOTP
|
|
3231
|
+
* second factors. The `factorId` of this second factor is {@link FactorId}.TOTP.
|
|
3232
|
+
* @public
|
|
3233
|
+
*/
|
|
3234
|
+
export declare interface TotpMultiFactorInfo extends MultiFactorInfo {
|
|
3235
|
+
}
|
|
3236
|
+
|
|
3237
|
+
/**
|
|
3238
|
+
* Provider for generating a {@link TotpMultiFactorAssertion}.
|
|
3239
|
+
*
|
|
3240
|
+
* Stores the shared secret key and other parameters to generate time-based OTPs.
|
|
3241
|
+
* Implements methods to retrieve the shared secret key and generate a QR code URL.
|
|
3242
|
+
* @public
|
|
3243
|
+
*/
|
|
3244
|
+
export declare class TotpSecret {
|
|
3245
|
+
private readonly sessionInfo;
|
|
3246
|
+
private readonly auth;
|
|
3247
|
+
/**
|
|
3248
|
+
* Shared secret key/seed used for enrolling in TOTP MFA and generating OTPs.
|
|
3249
|
+
*/
|
|
3250
|
+
readonly secretKey: string;
|
|
3251
|
+
/**
|
|
3252
|
+
* Hashing algorithm used.
|
|
3253
|
+
*/
|
|
3254
|
+
readonly hashingAlgorithm: string;
|
|
3255
|
+
/**
|
|
3256
|
+
* Length of the one-time passwords to be generated.
|
|
3257
|
+
*/
|
|
3258
|
+
readonly codeLength: number;
|
|
3259
|
+
/**
|
|
3260
|
+
* The interval (in seconds) when the OTP codes should change.
|
|
3261
|
+
*/
|
|
3262
|
+
readonly codeIntervalSeconds: number;
|
|
3263
|
+
/**
|
|
3264
|
+
* The timestamp (UTC string) by which TOTP enrollment should be completed.
|
|
3265
|
+
*/
|
|
3266
|
+
readonly enrollmentCompletionDeadline: string;
|
|
3267
|
+
private constructor();
|
|
3268
|
+
/* Excluded from this release type: _fromStartTotpMfaEnrollmentResponse */
|
|
3269
|
+
/* Excluded from this release type: _makeTotpVerificationInfo */
|
|
3270
|
+
/**
|
|
3271
|
+
* Returns a QR code URL as described in
|
|
3272
|
+
* https://github.com/google/google-authenticator/wiki/Key-Uri-Format
|
|
3273
|
+
* This can be displayed to the user as a QR code to be scanned into a TOTP app like Google Authenticator.
|
|
3274
|
+
* If the optional parameters are unspecified, an accountName of <userEmail> and issuer of <firebaseAppName> are used.
|
|
3275
|
+
*
|
|
3276
|
+
* @param accountName the name of the account/app along with a user identifier.
|
|
3277
|
+
* @param issuer issuer of the TOTP (likely the app name).
|
|
3278
|
+
* @returns A QR code URL string.
|
|
3279
|
+
*/
|
|
3280
|
+
generateQrCodeUrl(accountName?: string, issuer?: string): string;
|
|
3281
|
+
}
|
|
3282
|
+
|
|
3283
|
+
declare interface TotpVerificationInfo {
|
|
3284
|
+
sessionInfo: string;
|
|
3285
|
+
verificationCode: string;
|
|
3286
|
+
}
|
|
3287
|
+
|
|
3155
3288
|
/**
|
|
3156
3289
|
* Provider for generating an {@link OAuthCredential} for {@link ProviderId}.TWITTER.
|
|
3157
3290
|
*
|
package/dist/auth.d.ts
CHANGED
|
@@ -897,7 +897,7 @@ export declare interface AuthSettings {
|
|
|
897
897
|
}
|
|
898
898
|
|
|
899
899
|
/**
|
|
900
|
-
* MFA Info as returned by the API
|
|
900
|
+
* MFA Info as returned by the API.
|
|
901
901
|
*/
|
|
902
902
|
declare interface BaseMfaEnrollment {
|
|
903
903
|
mfaEnrollmentId: string;
|
|
@@ -1420,8 +1420,20 @@ export declare class FacebookAuthProvider extends BaseOAuthProvider {
|
|
|
1420
1420
|
export declare const FactorId: {
|
|
1421
1421
|
/** Phone as second factor */
|
|
1422
1422
|
readonly PHONE: "phone";
|
|
1423
|
+
readonly TOTP: "totp";
|
|
1423
1424
|
};
|
|
1424
1425
|
|
|
1426
|
+
/**
|
|
1427
|
+
* An enum of factors that may be used for multifactor authentication.
|
|
1428
|
+
*
|
|
1429
|
+
* @internal
|
|
1430
|
+
*/
|
|
1431
|
+
declare const enum FactorId_2 {
|
|
1432
|
+
/** Phone as second factor */
|
|
1433
|
+
PHONE = "phone",
|
|
1434
|
+
TOTP = "totp"
|
|
1435
|
+
}
|
|
1436
|
+
|
|
1425
1437
|
/**
|
|
1426
1438
|
* The base class for all Federated providers (OAuth (including OIDC), SAML).
|
|
1427
1439
|
*
|
|
@@ -1978,9 +1990,9 @@ export declare function linkWithPopup(user: User, provider: AuthProvider, resolv
|
|
|
1978
1990
|
export declare function linkWithRedirect(user: User, provider: AuthProvider, resolver?: PopupRedirectResolver): Promise<never>;
|
|
1979
1991
|
|
|
1980
1992
|
/**
|
|
1981
|
-
* MfaEnrollment can be any subtype of BaseMfaEnrollment, currently only PhoneMfaEnrollment
|
|
1993
|
+
* MfaEnrollment can be any subtype of BaseMfaEnrollment, currently only PhoneMfaEnrollment and TotpMfaEnrollment are supported.
|
|
1982
1994
|
*/
|
|
1983
|
-
declare type MfaEnrollment = PhoneMfaEnrollment;
|
|
1995
|
+
declare type MfaEnrollment = PhoneMfaEnrollment | TotpMfaEnrollment;
|
|
1984
1996
|
|
|
1985
1997
|
/**
|
|
1986
1998
|
* The {@link MultiFactorUser} corresponding to the user.
|
|
@@ -2457,6 +2469,7 @@ export declare function onAuthStateChanged(auth: Auth, nextOrObserver: NextOrObs
|
|
|
2457
2469
|
*
|
|
2458
2470
|
* @remarks
|
|
2459
2471
|
* This includes sign-in, sign-out, and token refresh events.
|
|
2472
|
+
* This will not be triggered automatically upon ID token expiration. Use {@link User.getIdToken} to refresh the ID token.
|
|
2460
2473
|
*
|
|
2461
2474
|
* @param auth - The {@link Auth} instance.
|
|
2462
2475
|
* @param nextOrObserver - callback triggered on change.
|
|
@@ -2702,7 +2715,7 @@ export declare class PhoneAuthProvider {
|
|
|
2702
2715
|
export declare type PhoneInfoOptions = PhoneSingleFactorInfoOptions | PhoneMultiFactorEnrollInfoOptions | PhoneMultiFactorSignInInfoOptions;
|
|
2703
2716
|
|
|
2704
2717
|
/**
|
|
2705
|
-
* An MFA provided by SMS verification
|
|
2718
|
+
* An MFA provided by SMS verification.
|
|
2706
2719
|
*/
|
|
2707
2720
|
declare interface PhoneMfaEnrollment extends BaseMfaEnrollment {
|
|
2708
2721
|
phoneInfo: string;
|
|
@@ -3572,6 +3585,17 @@ export declare function signInWithRedirect(auth: Auth, provider: AuthProvider, r
|
|
|
3572
3585
|
*/
|
|
3573
3586
|
export declare function signOut(auth: Auth): Promise<void>;
|
|
3574
3587
|
|
|
3588
|
+
declare interface StartTotpMfaEnrollmentResponse {
|
|
3589
|
+
totpSessionInfo: {
|
|
3590
|
+
sharedSecretKey: string;
|
|
3591
|
+
verificationCodeLength: number;
|
|
3592
|
+
hashingAlgorithm: string;
|
|
3593
|
+
periodSec: number;
|
|
3594
|
+
sessionInfo: string;
|
|
3595
|
+
finalizeEnrollmentTime: number;
|
|
3596
|
+
};
|
|
3597
|
+
}
|
|
3598
|
+
|
|
3575
3599
|
/**
|
|
3576
3600
|
* We need to mark this class as internal explicitly to exclude it in the public typings, because
|
|
3577
3601
|
* it references AuthInternal which has a circular dependency with UserInternal.
|
|
@@ -3602,6 +3626,126 @@ declare interface TaggedWithTokenResponse {
|
|
|
3602
3626
|
_tokenResponse?: PhoneOrOauthTokenResponse;
|
|
3603
3627
|
}
|
|
3604
3628
|
|
|
3629
|
+
/**
|
|
3630
|
+
* An MFA provided by TOTP (Time-based One Time Password).
|
|
3631
|
+
*/
|
|
3632
|
+
declare interface TotpMfaEnrollment extends BaseMfaEnrollment {
|
|
3633
|
+
}
|
|
3634
|
+
|
|
3635
|
+
/**
|
|
3636
|
+
* The class for asserting ownership of a TOTP second factor. Provided by
|
|
3637
|
+
* {@link TotpMultiFactorGenerator.assertionForEnrollment} and
|
|
3638
|
+
* {@link TotpMultiFactorGenerator.assertionForSignIn}.
|
|
3639
|
+
*
|
|
3640
|
+
* @public
|
|
3641
|
+
*/
|
|
3642
|
+
export declare interface TotpMultiFactorAssertion extends MultiFactorAssertion {
|
|
3643
|
+
}
|
|
3644
|
+
|
|
3645
|
+
/**
|
|
3646
|
+
* Provider for generating a {@link TotpMultiFactorAssertion}.
|
|
3647
|
+
*
|
|
3648
|
+
* @public
|
|
3649
|
+
*/
|
|
3650
|
+
export declare class TotpMultiFactorGenerator {
|
|
3651
|
+
/**
|
|
3652
|
+
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of
|
|
3653
|
+
* the TOTP (time-based one-time password) second factor.
|
|
3654
|
+
* This assertion is used to complete enrollment in TOTP second factor.
|
|
3655
|
+
*
|
|
3656
|
+
* @param secret A {@link TotpSecret} containing the shared secret key and other TOTP parameters.
|
|
3657
|
+
* @param oneTimePassword One-time password from TOTP App.
|
|
3658
|
+
* @returns A {@link TotpMultiFactorAssertion} which can be used with
|
|
3659
|
+
* {@link MultiFactorUser.enroll}.
|
|
3660
|
+
*/
|
|
3661
|
+
static assertionForEnrollment(secret: TotpSecret, oneTimePassword: string): TotpMultiFactorAssertion;
|
|
3662
|
+
/**
|
|
3663
|
+
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of the TOTP second factor.
|
|
3664
|
+
* This assertion is used to complete signIn with TOTP as the second factor.
|
|
3665
|
+
*
|
|
3666
|
+
* @param enrollmentId identifies the enrolled TOTP second factor.
|
|
3667
|
+
* @param oneTimePassword One-time password from TOTP App.
|
|
3668
|
+
* @returns A {@link TotpMultiFactorAssertion} which can be used with
|
|
3669
|
+
* {@link MultiFactorResolver.resolveSignIn}.
|
|
3670
|
+
*/
|
|
3671
|
+
static assertionForSignIn(enrollmentId: string, oneTimePassword: string): TotpMultiFactorAssertion;
|
|
3672
|
+
/**
|
|
3673
|
+
* Returns a promise to {@link TotpSecret} which contains the TOTP shared secret key and other parameters.
|
|
3674
|
+
* Creates a TOTP secret as part of enrolling a TOTP second factor.
|
|
3675
|
+
* Used for generating a QR code URL or inputting into a TOTP app.
|
|
3676
|
+
* This method uses the auth instance corresponding to the user in the multiFactorSession.
|
|
3677
|
+
*
|
|
3678
|
+
* @param session The {@link MultiFactorSession} that the user is part of.
|
|
3679
|
+
* @returns A promise to {@link TotpSecret}.
|
|
3680
|
+
*/
|
|
3681
|
+
static generateSecret(session: MultiFactorSession): Promise<TotpSecret>;
|
|
3682
|
+
/**
|
|
3683
|
+
* The identifier of the TOTP second factor: `totp`.
|
|
3684
|
+
*/
|
|
3685
|
+
static FACTOR_ID: FactorId_2;
|
|
3686
|
+
}
|
|
3687
|
+
|
|
3688
|
+
/**
|
|
3689
|
+
* The subclass of the {@link MultiFactorInfo} interface for TOTP
|
|
3690
|
+
* second factors. The `factorId` of this second factor is {@link FactorId}.TOTP.
|
|
3691
|
+
* @public
|
|
3692
|
+
*/
|
|
3693
|
+
export declare interface TotpMultiFactorInfo extends MultiFactorInfo {
|
|
3694
|
+
}
|
|
3695
|
+
|
|
3696
|
+
/**
|
|
3697
|
+
* Provider for generating a {@link TotpMultiFactorAssertion}.
|
|
3698
|
+
*
|
|
3699
|
+
* Stores the shared secret key and other parameters to generate time-based OTPs.
|
|
3700
|
+
* Implements methods to retrieve the shared secret key and generate a QR code URL.
|
|
3701
|
+
* @public
|
|
3702
|
+
*/
|
|
3703
|
+
export declare class TotpSecret {
|
|
3704
|
+
private readonly sessionInfo;
|
|
3705
|
+
private readonly auth;
|
|
3706
|
+
/**
|
|
3707
|
+
* Shared secret key/seed used for enrolling in TOTP MFA and generating OTPs.
|
|
3708
|
+
*/
|
|
3709
|
+
readonly secretKey: string;
|
|
3710
|
+
/**
|
|
3711
|
+
* Hashing algorithm used.
|
|
3712
|
+
*/
|
|
3713
|
+
readonly hashingAlgorithm: string;
|
|
3714
|
+
/**
|
|
3715
|
+
* Length of the one-time passwords to be generated.
|
|
3716
|
+
*/
|
|
3717
|
+
readonly codeLength: number;
|
|
3718
|
+
/**
|
|
3719
|
+
* The interval (in seconds) when the OTP codes should change.
|
|
3720
|
+
*/
|
|
3721
|
+
readonly codeIntervalSeconds: number;
|
|
3722
|
+
/**
|
|
3723
|
+
* The timestamp (UTC string) by which TOTP enrollment should be completed.
|
|
3724
|
+
*/
|
|
3725
|
+
readonly enrollmentCompletionDeadline: string;
|
|
3726
|
+
private constructor();
|
|
3727
|
+
/** @internal */
|
|
3728
|
+
static _fromStartTotpMfaEnrollmentResponse(response: StartTotpMfaEnrollmentResponse, auth: AuthInternal): TotpSecret;
|
|
3729
|
+
/** @internal */
|
|
3730
|
+
_makeTotpVerificationInfo(otp: string): TotpVerificationInfo;
|
|
3731
|
+
/**
|
|
3732
|
+
* Returns a QR code URL as described in
|
|
3733
|
+
* https://github.com/google/google-authenticator/wiki/Key-Uri-Format
|
|
3734
|
+
* This can be displayed to the user as a QR code to be scanned into a TOTP app like Google Authenticator.
|
|
3735
|
+
* If the optional parameters are unspecified, an accountName of <userEmail> and issuer of <firebaseAppName> are used.
|
|
3736
|
+
*
|
|
3737
|
+
* @param accountName the name of the account/app along with a user identifier.
|
|
3738
|
+
* @param issuer issuer of the TOTP (likely the app name).
|
|
3739
|
+
* @returns A QR code URL string.
|
|
3740
|
+
*/
|
|
3741
|
+
generateQrCodeUrl(accountName?: string, issuer?: string): string;
|
|
3742
|
+
}
|
|
3743
|
+
|
|
3744
|
+
declare interface TotpVerificationInfo {
|
|
3745
|
+
sessionInfo: string;
|
|
3746
|
+
verificationCode: string;
|
|
3747
|
+
}
|
|
3748
|
+
|
|
3605
3749
|
/**
|
|
3606
3750
|
* Provider for generating an {@link OAuthCredential} for {@link ProviderId}.TWITTER.
|
|
3607
3751
|
*
|
|
@@ -29,7 +29,8 @@ var component = require('@firebase/component');
|
|
|
29
29
|
*/
|
|
30
30
|
const FactorId = {
|
|
31
31
|
/** Phone as second factor */
|
|
32
|
-
PHONE: 'phone'
|
|
32
|
+
PHONE: 'phone',
|
|
33
|
+
TOTP: 'totp'
|
|
33
34
|
};
|
|
34
35
|
/**
|
|
35
36
|
* Enumeration of supported providers.
|
|
@@ -4864,6 +4865,9 @@ class MultiFactorInfoImpl {
|
|
|
4864
4865
|
if ('phoneInfo' in enrollment) {
|
|
4865
4866
|
return PhoneMultiFactorInfoImpl._fromServerResponse(auth, enrollment);
|
|
4866
4867
|
}
|
|
4868
|
+
else if ('totpInfo' in enrollment) {
|
|
4869
|
+
return TotpMultiFactorInfoImpl._fromServerResponse(auth, enrollment);
|
|
4870
|
+
}
|
|
4867
4871
|
return _fail(auth, "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
4868
4872
|
}
|
|
4869
4873
|
}
|
|
@@ -4875,6 +4879,14 @@ class PhoneMultiFactorInfoImpl extends MultiFactorInfoImpl {
|
|
|
4875
4879
|
static _fromServerResponse(_auth, enrollment) {
|
|
4876
4880
|
return new PhoneMultiFactorInfoImpl(enrollment);
|
|
4877
4881
|
}
|
|
4882
|
+
}
|
|
4883
|
+
class TotpMultiFactorInfoImpl extends MultiFactorInfoImpl {
|
|
4884
|
+
constructor(response) {
|
|
4885
|
+
super("totp" /* FactorId.TOTP */, response);
|
|
4886
|
+
}
|
|
4887
|
+
static _fromServerResponse(_auth, enrollment) {
|
|
4888
|
+
return new TotpMultiFactorInfoImpl(enrollment);
|
|
4889
|
+
}
|
|
4878
4890
|
}
|
|
4879
4891
|
|
|
4880
4892
|
/**
|
|
@@ -5678,6 +5690,7 @@ function setPersistence(auth, persistence) {
|
|
|
5678
5690
|
*
|
|
5679
5691
|
* @remarks
|
|
5680
5692
|
* This includes sign-in, sign-out, and token refresh events.
|
|
5693
|
+
* This will not be triggered automatically upon ID token expiration. Use {@link User.getIdToken} to refresh the ID token.
|
|
5681
5694
|
*
|
|
5682
5695
|
* @param auth - The {@link Auth} instance.
|
|
5683
5696
|
* @param nextOrObserver - callback triggered on change.
|
|
@@ -5911,6 +5924,12 @@ function startEnrollPhoneMfa(auth, request) {
|
|
|
5911
5924
|
function finalizeEnrollPhoneMfa(auth, request) {
|
|
5912
5925
|
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaEnrollment:finalize" /* Endpoint.FINALIZE_MFA_ENROLLMENT */, _addTidIfNecessary(auth, request));
|
|
5913
5926
|
}
|
|
5927
|
+
function startEnrollTotpMfa(auth, request) {
|
|
5928
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaEnrollment:start" /* Endpoint.START_MFA_ENROLLMENT */, _addTidIfNecessary(auth, request));
|
|
5929
|
+
}
|
|
5930
|
+
function finalizeEnrollTotpMfa(auth, request) {
|
|
5931
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaEnrollment:finalize" /* Endpoint.FINALIZE_MFA_ENROLLMENT */, _addTidIfNecessary(auth, request));
|
|
5932
|
+
}
|
|
5914
5933
|
function withdrawMfa(auth, request) {
|
|
5915
5934
|
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaEnrollment:withdraw" /* Endpoint.WITHDRAW_MFA */, _addTidIfNecessary(auth, request));
|
|
5916
5935
|
}
|
|
@@ -7006,6 +7025,9 @@ function startSignInPhoneMfa(auth, request) {
|
|
|
7006
7025
|
}
|
|
7007
7026
|
function finalizeSignInPhoneMfa(auth, request) {
|
|
7008
7027
|
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaSignIn:finalize" /* Endpoint.FINALIZE_MFA_SIGN_IN */, _addTidIfNecessary(auth, request));
|
|
7028
|
+
}
|
|
7029
|
+
function finalizeSignInTotpMfa(auth, request) {
|
|
7030
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/mfaSignIn:finalize" /* Endpoint.FINALIZE_MFA_SIGN_IN */, _addTidIfNecessary(auth, request));
|
|
7009
7031
|
}
|
|
7010
7032
|
|
|
7011
7033
|
/**
|
|
@@ -9316,8 +9338,155 @@ class PhoneMultiFactorGenerator {
|
|
|
9316
9338
|
*/
|
|
9317
9339
|
PhoneMultiFactorGenerator.FACTOR_ID = 'phone';
|
|
9318
9340
|
|
|
9341
|
+
/**
|
|
9342
|
+
* Provider for generating a {@link TotpMultiFactorAssertion}.
|
|
9343
|
+
*
|
|
9344
|
+
* @public
|
|
9345
|
+
*/
|
|
9346
|
+
class TotpMultiFactorGenerator {
|
|
9347
|
+
/**
|
|
9348
|
+
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of
|
|
9349
|
+
* the TOTP (time-based one-time password) second factor.
|
|
9350
|
+
* This assertion is used to complete enrollment in TOTP second factor.
|
|
9351
|
+
*
|
|
9352
|
+
* @param secret A {@link TotpSecret} containing the shared secret key and other TOTP parameters.
|
|
9353
|
+
* @param oneTimePassword One-time password from TOTP App.
|
|
9354
|
+
* @returns A {@link TotpMultiFactorAssertion} which can be used with
|
|
9355
|
+
* {@link MultiFactorUser.enroll}.
|
|
9356
|
+
*/
|
|
9357
|
+
static assertionForEnrollment(secret, oneTimePassword) {
|
|
9358
|
+
return TotpMultiFactorAssertionImpl._fromSecret(secret, oneTimePassword);
|
|
9359
|
+
}
|
|
9360
|
+
/**
|
|
9361
|
+
* Provides a {@link TotpMultiFactorAssertion} to confirm ownership of the TOTP second factor.
|
|
9362
|
+
* This assertion is used to complete signIn with TOTP as the second factor.
|
|
9363
|
+
*
|
|
9364
|
+
* @param enrollmentId identifies the enrolled TOTP second factor.
|
|
9365
|
+
* @param oneTimePassword One-time password from TOTP App.
|
|
9366
|
+
* @returns A {@link TotpMultiFactorAssertion} which can be used with
|
|
9367
|
+
* {@link MultiFactorResolver.resolveSignIn}.
|
|
9368
|
+
*/
|
|
9369
|
+
static assertionForSignIn(enrollmentId, oneTimePassword) {
|
|
9370
|
+
return TotpMultiFactorAssertionImpl._fromEnrollmentId(enrollmentId, oneTimePassword);
|
|
9371
|
+
}
|
|
9372
|
+
/**
|
|
9373
|
+
* Returns a promise to {@link TotpSecret} which contains the TOTP shared secret key and other parameters.
|
|
9374
|
+
* Creates a TOTP secret as part of enrolling a TOTP second factor.
|
|
9375
|
+
* Used for generating a QR code URL or inputting into a TOTP app.
|
|
9376
|
+
* This method uses the auth instance corresponding to the user in the multiFactorSession.
|
|
9377
|
+
*
|
|
9378
|
+
* @param session The {@link MultiFactorSession} that the user is part of.
|
|
9379
|
+
* @returns A promise to {@link TotpSecret}.
|
|
9380
|
+
*/
|
|
9381
|
+
static async generateSecret(session) {
|
|
9382
|
+
const mfaSession = session;
|
|
9383
|
+
_assert(typeof mfaSession.auth !== 'undefined', "internal-error" /* AuthErrorCode.INTERNAL_ERROR */);
|
|
9384
|
+
const response = await startEnrollTotpMfa(mfaSession.auth, {
|
|
9385
|
+
idToken: mfaSession.credential,
|
|
9386
|
+
totpEnrollmentInfo: {}
|
|
9387
|
+
});
|
|
9388
|
+
return TotpSecret._fromStartTotpMfaEnrollmentResponse(response, mfaSession.auth);
|
|
9389
|
+
}
|
|
9390
|
+
}
|
|
9391
|
+
/**
|
|
9392
|
+
* The identifier of the TOTP second factor: `totp`.
|
|
9393
|
+
*/
|
|
9394
|
+
TotpMultiFactorGenerator.FACTOR_ID = "totp" /* FactorId.TOTP */;
|
|
9395
|
+
class TotpMultiFactorAssertionImpl extends MultiFactorAssertionImpl {
|
|
9396
|
+
constructor(otp, enrollmentId, secret) {
|
|
9397
|
+
super("totp" /* FactorId.TOTP */);
|
|
9398
|
+
this.otp = otp;
|
|
9399
|
+
this.enrollmentId = enrollmentId;
|
|
9400
|
+
this.secret = secret;
|
|
9401
|
+
}
|
|
9402
|
+
/** @internal */
|
|
9403
|
+
static _fromSecret(secret, otp) {
|
|
9404
|
+
return new TotpMultiFactorAssertionImpl(otp, undefined, secret);
|
|
9405
|
+
}
|
|
9406
|
+
/** @internal */
|
|
9407
|
+
static _fromEnrollmentId(enrollmentId, otp) {
|
|
9408
|
+
return new TotpMultiFactorAssertionImpl(otp, enrollmentId);
|
|
9409
|
+
}
|
|
9410
|
+
/** @internal */
|
|
9411
|
+
async _finalizeEnroll(auth, idToken, displayName) {
|
|
9412
|
+
_assert(typeof this.secret !== 'undefined', auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
|
|
9413
|
+
return finalizeEnrollTotpMfa(auth, {
|
|
9414
|
+
idToken,
|
|
9415
|
+
displayName,
|
|
9416
|
+
totpVerificationInfo: this.secret._makeTotpVerificationInfo(this.otp)
|
|
9417
|
+
});
|
|
9418
|
+
}
|
|
9419
|
+
/** @internal */
|
|
9420
|
+
async _finalizeSignIn(auth, mfaPendingCredential) {
|
|
9421
|
+
_assert(this.enrollmentId !== undefined && this.otp !== undefined, auth, "argument-error" /* AuthErrorCode.ARGUMENT_ERROR */);
|
|
9422
|
+
const totpVerificationInfo = { verificationCode: this.otp };
|
|
9423
|
+
return finalizeSignInTotpMfa(auth, {
|
|
9424
|
+
mfaPendingCredential,
|
|
9425
|
+
mfaEnrollmentId: this.enrollmentId,
|
|
9426
|
+
totpVerificationInfo
|
|
9427
|
+
});
|
|
9428
|
+
}
|
|
9429
|
+
}
|
|
9430
|
+
/**
|
|
9431
|
+
* Provider for generating a {@link TotpMultiFactorAssertion}.
|
|
9432
|
+
*
|
|
9433
|
+
* Stores the shared secret key and other parameters to generate time-based OTPs.
|
|
9434
|
+
* Implements methods to retrieve the shared secret key and generate a QR code URL.
|
|
9435
|
+
* @public
|
|
9436
|
+
*/
|
|
9437
|
+
class TotpSecret {
|
|
9438
|
+
// The public members are declared outside the constructor so the docs can be generated.
|
|
9439
|
+
constructor(secretKey, hashingAlgorithm, codeLength, codeIntervalSeconds, enrollmentCompletionDeadline, sessionInfo, auth) {
|
|
9440
|
+
this.sessionInfo = sessionInfo;
|
|
9441
|
+
this.auth = auth;
|
|
9442
|
+
this.secretKey = secretKey;
|
|
9443
|
+
this.hashingAlgorithm = hashingAlgorithm;
|
|
9444
|
+
this.codeLength = codeLength;
|
|
9445
|
+
this.codeIntervalSeconds = codeIntervalSeconds;
|
|
9446
|
+
this.enrollmentCompletionDeadline = enrollmentCompletionDeadline;
|
|
9447
|
+
}
|
|
9448
|
+
/** @internal */
|
|
9449
|
+
static _fromStartTotpMfaEnrollmentResponse(response, auth) {
|
|
9450
|
+
return new TotpSecret(response.totpSessionInfo.sharedSecretKey, response.totpSessionInfo.hashingAlgorithm, response.totpSessionInfo.verificationCodeLength, response.totpSessionInfo.periodSec, new Date(response.totpSessionInfo.finalizeEnrollmentTime).toUTCString(), response.totpSessionInfo.sessionInfo, auth);
|
|
9451
|
+
}
|
|
9452
|
+
/** @internal */
|
|
9453
|
+
_makeTotpVerificationInfo(otp) {
|
|
9454
|
+
return { sessionInfo: this.sessionInfo, verificationCode: otp };
|
|
9455
|
+
}
|
|
9456
|
+
/**
|
|
9457
|
+
* Returns a QR code URL as described in
|
|
9458
|
+
* https://github.com/google/google-authenticator/wiki/Key-Uri-Format
|
|
9459
|
+
* This can be displayed to the user as a QR code to be scanned into a TOTP app like Google Authenticator.
|
|
9460
|
+
* If the optional parameters are unspecified, an accountName of <userEmail> and issuer of <firebaseAppName> are used.
|
|
9461
|
+
*
|
|
9462
|
+
* @param accountName the name of the account/app along with a user identifier.
|
|
9463
|
+
* @param issuer issuer of the TOTP (likely the app name).
|
|
9464
|
+
* @returns A QR code URL string.
|
|
9465
|
+
*/
|
|
9466
|
+
generateQrCodeUrl(accountName, issuer) {
|
|
9467
|
+
var _a;
|
|
9468
|
+
let useDefaults = false;
|
|
9469
|
+
if (_isEmptyString(accountName) || _isEmptyString(issuer)) {
|
|
9470
|
+
useDefaults = true;
|
|
9471
|
+
}
|
|
9472
|
+
if (useDefaults) {
|
|
9473
|
+
if (_isEmptyString(accountName)) {
|
|
9474
|
+
accountName = ((_a = this.auth.currentUser) === null || _a === void 0 ? void 0 : _a.email) || 'unknownuser';
|
|
9475
|
+
}
|
|
9476
|
+
if (_isEmptyString(issuer)) {
|
|
9477
|
+
issuer = this.auth.name;
|
|
9478
|
+
}
|
|
9479
|
+
}
|
|
9480
|
+
return `otpauth://totp/${issuer}:${accountName}?secret=${this.secretKey}&issuer=${issuer}&algorithm=${this.hashingAlgorithm}&digits=${this.codeLength}`;
|
|
9481
|
+
}
|
|
9482
|
+
}
|
|
9483
|
+
/** @internal */
|
|
9484
|
+
function _isEmptyString(input) {
|
|
9485
|
+
return typeof input === 'undefined' || (input === null || input === void 0 ? void 0 : input.length) === 0;
|
|
9486
|
+
}
|
|
9487
|
+
|
|
9319
9488
|
var name = "@firebase/auth";
|
|
9320
|
-
var version = "0.21.5-canary.
|
|
9489
|
+
var version = "0.21.5-canary.81cb20a2f";
|
|
9321
9490
|
|
|
9322
9491
|
/**
|
|
9323
9492
|
* @license
|
|
@@ -9567,6 +9736,8 @@ exports.RecaptchaVerifier = RecaptchaVerifier;
|
|
|
9567
9736
|
exports.SAMLAuthCredential = SAMLAuthCredential;
|
|
9568
9737
|
exports.SAMLAuthProvider = SAMLAuthProvider;
|
|
9569
9738
|
exports.SignInMethod = SignInMethod;
|
|
9739
|
+
exports.TotpMultiFactorGenerator = TotpMultiFactorGenerator;
|
|
9740
|
+
exports.TotpSecret = TotpSecret;
|
|
9570
9741
|
exports.TwitterAuthProvider = TwitterAuthProvider;
|
|
9571
9742
|
exports.UserImpl = UserImpl;
|
|
9572
9743
|
exports._assert = _assert;
|
|
@@ -9644,4 +9815,4 @@ exports.updateProfile = updateProfile;
|
|
|
9644
9815
|
exports.useDeviceLanguage = useDeviceLanguage;
|
|
9645
9816
|
exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
|
|
9646
9817
|
exports.verifyPasswordResetCode = verifyPasswordResetCode;
|
|
9647
|
-
//# sourceMappingURL=index-
|
|
9818
|
+
//# sourceMappingURL=index-243a5398.js.map
|