@firebase/auth 1.7.1-canary.e1a7764cf → 1.7.1-passkey-preview.103ead202
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/dist/auth-public.d.ts +60 -15
- package/dist/auth.d.ts +64 -16
- package/dist/browser-cjs/{index-b554a82d.js → index-763ce1de.js} +261 -17
- package/dist/browser-cjs/index-763ce1de.js.map +1 -0
- package/dist/browser-cjs/index.js +4 -1
- package/dist/browser-cjs/index.js.map +1 -1
- package/dist/browser-cjs/internal.js +4 -1
- package/dist/browser-cjs/internal.js.map +1 -1
- package/dist/browser-cjs/src/api/account_management/account.d.ts +2 -0
- package/dist/browser-cjs/src/api/account_management/passkey.d.ts +83 -0
- package/dist/browser-cjs/src/api/account_management/passkey.test.d.ts +17 -0
- package/dist/browser-cjs/src/api/index.d.ts +5 -1
- package/dist/browser-cjs/src/core/index.d.ts +1 -0
- package/dist/browser-cjs/src/core/strategies/email.d.ts +3 -5
- package/dist/browser-cjs/src/core/strategies/email_and_password.d.ts +4 -6
- package/dist/browser-cjs/src/core/strategies/passkey.d.ts +41 -0
- package/dist/browser-cjs/src/core/strategies/passkey.test.d.ts +17 -0
- package/dist/browser-cjs/src/core/user/account_info.d.ts +1 -3
- package/dist/browser-cjs/src/core/user/user_impl.d.ts +2 -1
- package/dist/browser-cjs/src/model/enums.d.ts +6 -2
- package/dist/browser-cjs/src/model/public_types.d.ts +18 -1
- package/dist/browser-cjs/src/model/user.d.ts +3 -0
- package/dist/cordova/index.js +2 -2
- package/dist/cordova/internal.js +2 -2
- package/dist/cordova/{popup_redirect-89a4178c.js → popup_redirect-619ee864.js} +331 -18
- package/dist/cordova/popup_redirect-619ee864.js.map +1 -0
- package/dist/cordova/src/api/account_management/account.d.ts +2 -0
- package/dist/cordova/src/api/account_management/passkey.d.ts +83 -0
- package/dist/cordova/src/api/account_management/passkey.test.d.ts +17 -0
- package/dist/cordova/src/api/index.d.ts +5 -1
- package/dist/cordova/src/core/index.d.ts +1 -0
- package/dist/cordova/src/core/strategies/email.d.ts +3 -5
- package/dist/cordova/src/core/strategies/email_and_password.d.ts +4 -6
- package/dist/cordova/src/core/strategies/passkey.d.ts +41 -0
- package/dist/cordova/src/core/strategies/passkey.test.d.ts +17 -0
- package/dist/cordova/src/core/user/account_info.d.ts +1 -3
- package/dist/cordova/src/core/user/user_impl.d.ts +2 -1
- package/dist/cordova/src/model/enums.d.ts +6 -2
- package/dist/cordova/src/model/public_types.d.ts +18 -1
- package/dist/cordova/src/model/user.d.ts +3 -0
- package/dist/esm2017/{index-456eaf5d.js → index-e517538d.js} +259 -18
- package/dist/esm2017/index-e517538d.js.map +1 -0
- package/dist/esm2017/index.js +1 -1
- package/dist/esm2017/internal.js +2 -2
- package/dist/esm2017/src/api/account_management/account.d.ts +2 -0
- package/dist/esm2017/src/api/account_management/passkey.d.ts +83 -0
- package/dist/esm2017/src/api/account_management/passkey.test.d.ts +17 -0
- package/dist/esm2017/src/api/index.d.ts +5 -1
- package/dist/esm2017/src/core/index.d.ts +1 -0
- package/dist/esm2017/src/core/strategies/email.d.ts +3 -5
- package/dist/esm2017/src/core/strategies/email_and_password.d.ts +4 -6
- package/dist/esm2017/src/core/strategies/passkey.d.ts +41 -0
- package/dist/esm2017/src/core/strategies/passkey.test.d.ts +17 -0
- package/dist/esm2017/src/core/user/account_info.d.ts +1 -3
- package/dist/esm2017/src/core/user/user_impl.d.ts +2 -1
- package/dist/esm2017/src/model/enums.d.ts +6 -2
- package/dist/esm2017/src/model/public_types.d.ts +18 -1
- package/dist/esm2017/src/model/user.d.ts +3 -0
- package/dist/esm5/{index-7c43a070.js → index-5377e4d7.js} +331 -18
- package/dist/esm5/index-5377e4d7.js.map +1 -0
- package/dist/esm5/index.js +1 -1
- package/dist/esm5/internal.js +2 -2
- package/dist/esm5/src/api/account_management/account.d.ts +2 -0
- package/dist/esm5/src/api/account_management/passkey.d.ts +83 -0
- package/dist/esm5/src/api/account_management/passkey.test.d.ts +17 -0
- package/dist/esm5/src/api/index.d.ts +5 -1
- package/dist/esm5/src/core/index.d.ts +1 -0
- package/dist/esm5/src/core/strategies/email.d.ts +3 -5
- package/dist/esm5/src/core/strategies/email_and_password.d.ts +4 -6
- package/dist/esm5/src/core/strategies/passkey.d.ts +41 -0
- package/dist/esm5/src/core/strategies/passkey.test.d.ts +17 -0
- package/dist/esm5/src/core/user/account_info.d.ts +1 -3
- package/dist/esm5/src/core/user/user_impl.d.ts +2 -1
- package/dist/esm5/src/model/enums.d.ts +6 -2
- package/dist/esm5/src/model/public_types.d.ts +18 -1
- package/dist/esm5/src/model/user.d.ts +3 -0
- package/dist/index.webworker.esm5.js +330 -17
- package/dist/index.webworker.esm5.js.map +1 -1
- package/dist/node/index.js +4 -1
- package/dist/node/index.js.map +1 -1
- package/dist/node/internal.js +4 -1
- package/dist/node/internal.js.map +1 -1
- package/dist/node/src/api/account_management/account.d.ts +2 -0
- package/dist/node/src/api/account_management/passkey.d.ts +83 -0
- package/dist/node/src/api/account_management/passkey.test.d.ts +17 -0
- package/dist/node/src/api/index.d.ts +5 -1
- package/dist/node/src/core/index.d.ts +1 -0
- package/dist/node/src/core/strategies/email.d.ts +3 -5
- package/dist/node/src/core/strategies/email_and_password.d.ts +4 -6
- package/dist/node/src/core/strategies/passkey.d.ts +41 -0
- package/dist/node/src/core/strategies/passkey.test.d.ts +17 -0
- package/dist/node/src/core/user/account_info.d.ts +1 -3
- package/dist/node/src/core/user/user_impl.d.ts +2 -1
- package/dist/node/src/model/enums.d.ts +6 -2
- package/dist/node/src/model/public_types.d.ts +18 -1
- package/dist/node/src/model/user.d.ts +3 -0
- package/dist/node/{totp-38aba8fd.js → totp-e59979fc.js} +333 -17
- package/dist/node/totp-e59979fc.js.map +1 -0
- package/dist/node-esm/index.js +1 -1
- package/dist/node-esm/internal.js +2 -2
- package/dist/node-esm/src/api/account_management/account.d.ts +2 -0
- package/dist/node-esm/src/api/account_management/passkey.d.ts +83 -0
- package/dist/node-esm/src/api/account_management/passkey.test.d.ts +17 -0
- package/dist/node-esm/src/api/index.d.ts +5 -1
- package/dist/node-esm/src/core/index.d.ts +1 -0
- package/dist/node-esm/src/core/strategies/email.d.ts +3 -5
- package/dist/node-esm/src/core/strategies/email_and_password.d.ts +4 -6
- package/dist/node-esm/src/core/strategies/passkey.d.ts +41 -0
- package/dist/node-esm/src/core/strategies/passkey.test.d.ts +17 -0
- package/dist/node-esm/src/core/user/account_info.d.ts +1 -3
- package/dist/node-esm/src/core/user/user_impl.d.ts +2 -1
- package/dist/node-esm/src/model/enums.d.ts +6 -2
- package/dist/node-esm/src/model/public_types.d.ts +18 -1
- package/dist/node-esm/src/model/user.d.ts +3 -0
- package/dist/node-esm/{totp-e448e7fe.js → totp-86acc588.js} +259 -18
- package/dist/node-esm/totp-86acc588.js.map +1 -0
- package/dist/rn/{index-985afdb4.js → index-551e6aca.js} +333 -17
- package/dist/rn/index-551e6aca.js.map +1 -0
- package/dist/rn/index.js +4 -1
- package/dist/rn/index.js.map +1 -1
- package/dist/rn/internal.js +4 -1
- package/dist/rn/internal.js.map +1 -1
- package/dist/rn/src/api/account_management/account.d.ts +2 -0
- package/dist/rn/src/api/account_management/passkey.d.ts +83 -0
- package/dist/rn/src/api/account_management/passkey.test.d.ts +17 -0
- package/dist/rn/src/api/index.d.ts +5 -1
- package/dist/rn/src/core/index.d.ts +1 -0
- package/dist/rn/src/core/strategies/email.d.ts +3 -5
- package/dist/rn/src/core/strategies/email_and_password.d.ts +4 -6
- package/dist/rn/src/core/strategies/passkey.d.ts +41 -0
- package/dist/rn/src/core/strategies/passkey.test.d.ts +17 -0
- package/dist/rn/src/core/user/account_info.d.ts +1 -3
- package/dist/rn/src/core/user/user_impl.d.ts +2 -1
- package/dist/rn/src/model/enums.d.ts +6 -2
- package/dist/rn/src/model/public_types.d.ts +18 -1
- package/dist/rn/src/model/user.d.ts +3 -0
- package/dist/src/api/account_management/account.d.ts +2 -0
- package/dist/src/api/account_management/passkey.d.ts +83 -0
- package/dist/src/api/account_management/passkey.test.d.ts +17 -0
- package/dist/src/api/index.d.ts +5 -1
- package/dist/src/core/index.d.ts +1 -0
- package/dist/src/core/strategies/email.d.ts +3 -5
- package/dist/src/core/strategies/email_and_password.d.ts +4 -6
- package/dist/src/core/strategies/passkey.d.ts +41 -0
- package/dist/src/core/strategies/passkey.test.d.ts +17 -0
- package/dist/src/core/user/account_info.d.ts +1 -3
- package/dist/src/core/user/user_impl.d.ts +2 -1
- package/dist/src/model/enums.d.ts +6 -2
- package/dist/src/model/public_types.d.ts +18 -1
- package/dist/src/model/user.d.ts +3 -0
- package/dist/web-extension-cjs/index.js +4 -1
- package/dist/web-extension-cjs/index.js.map +1 -1
- package/dist/web-extension-cjs/internal.js +4 -1
- package/dist/web-extension-cjs/internal.js.map +1 -1
- package/dist/web-extension-cjs/{register-e3ac7adf.js → register-84d046a5.js} +261 -17
- package/dist/web-extension-cjs/register-84d046a5.js.map +1 -0
- package/dist/web-extension-cjs/src/api/account_management/account.d.ts +2 -0
- package/dist/web-extension-cjs/src/api/account_management/passkey.d.ts +83 -0
- package/dist/web-extension-cjs/src/api/account_management/passkey.test.d.ts +17 -0
- package/dist/web-extension-cjs/src/api/index.d.ts +5 -1
- package/dist/web-extension-cjs/src/core/index.d.ts +1 -0
- package/dist/web-extension-cjs/src/core/strategies/email.d.ts +3 -5
- package/dist/web-extension-cjs/src/core/strategies/email_and_password.d.ts +4 -6
- package/dist/web-extension-cjs/src/core/strategies/passkey.d.ts +41 -0
- package/dist/web-extension-cjs/src/core/strategies/passkey.test.d.ts +17 -0
- package/dist/web-extension-cjs/src/core/user/account_info.d.ts +1 -3
- package/dist/web-extension-cjs/src/core/user/user_impl.d.ts +2 -1
- package/dist/web-extension-cjs/src/model/enums.d.ts +6 -2
- package/dist/web-extension-cjs/src/model/public_types.d.ts +18 -1
- package/dist/web-extension-cjs/src/model/user.d.ts +3 -0
- package/dist/web-extension-esm2017/index.js +2 -2
- package/dist/web-extension-esm2017/internal.js +2 -2
- package/dist/web-extension-esm2017/{register-ffa8f4d2.js → register-49f5fb7d.js} +259 -18
- package/dist/web-extension-esm2017/register-49f5fb7d.js.map +1 -0
- package/dist/web-extension-esm2017/src/api/account_management/account.d.ts +2 -0
- package/dist/web-extension-esm2017/src/api/account_management/passkey.d.ts +83 -0
- package/dist/web-extension-esm2017/src/api/account_management/passkey.test.d.ts +17 -0
- package/dist/web-extension-esm2017/src/api/index.d.ts +5 -1
- package/dist/web-extension-esm2017/src/core/index.d.ts +1 -0
- package/dist/web-extension-esm2017/src/core/strategies/email.d.ts +3 -5
- package/dist/web-extension-esm2017/src/core/strategies/email_and_password.d.ts +4 -6
- package/dist/web-extension-esm2017/src/core/strategies/passkey.d.ts +41 -0
- package/dist/web-extension-esm2017/src/core/strategies/passkey.test.d.ts +17 -0
- package/dist/web-extension-esm2017/src/core/user/account_info.d.ts +1 -3
- package/dist/web-extension-esm2017/src/core/user/user_impl.d.ts +2 -1
- package/dist/web-extension-esm2017/src/model/enums.d.ts +6 -2
- package/dist/web-extension-esm2017/src/model/public_types.d.ts +18 -1
- package/dist/web-extension-esm2017/src/model/user.d.ts +3 -0
- package/package.json +6 -6
- package/dist/browser-cjs/index-b554a82d.js.map +0 -1
- package/dist/cordova/popup_redirect-89a4178c.js.map +0 -1
- package/dist/esm2017/index-456eaf5d.js.map +0 -1
- package/dist/esm5/index-7c43a070.js.map +0 -1
- package/dist/node/totp-38aba8fd.js.map +0 -1
- package/dist/node-esm/totp-e448e7fe.js.map +0 -1
- package/dist/rn/index-985afdb4.js.map +0 -1
- package/dist/web-extension-cjs/register-e3ac7adf.js.map +0 -1
- package/dist/web-extension-esm2017/package.json +0 -1
- package/dist/web-extension-esm2017/register-ffa8f4d2.js.map +0 -1
|
@@ -1453,7 +1453,8 @@ async function _reloadWithoutSaving(user) {
|
|
|
1453
1453
|
tenantId: coreAccount.tenantId || null,
|
|
1454
1454
|
providerData,
|
|
1455
1455
|
metadata: new UserMetadata(coreAccount.createdAt, coreAccount.lastLoginAt),
|
|
1456
|
-
isAnonymous
|
|
1456
|
+
isAnonymous,
|
|
1457
|
+
enrolledPasskeys: coreAccount.passkeyInfo || []
|
|
1457
1458
|
};
|
|
1458
1459
|
Object.assign(user, updates);
|
|
1459
1460
|
}
|
|
@@ -1685,6 +1686,9 @@ class UserImpl {
|
|
|
1685
1686
|
this.isAnonymous = opt.isAnonymous || false;
|
|
1686
1687
|
this.tenantId = opt.tenantId || null;
|
|
1687
1688
|
this.providerData = opt.providerData ? [...opt.providerData] : [];
|
|
1689
|
+
this.enrolledPasskeys = opt.enrolledPasskeys
|
|
1690
|
+
? [...opt.enrolledPasskeys]
|
|
1691
|
+
: [];
|
|
1688
1692
|
this.metadata = new UserMetadata(opt.createdAt || undefined, opt.lastLoginAt || undefined);
|
|
1689
1693
|
}
|
|
1690
1694
|
async getIdToken(forceRefresh) {
|
|
@@ -1716,6 +1720,7 @@ class UserImpl {
|
|
|
1716
1720
|
this.isAnonymous = user.isAnonymous;
|
|
1717
1721
|
this.tenantId = user.tenantId;
|
|
1718
1722
|
this.providerData = user.providerData.map(userInfo => (Object.assign({}, userInfo)));
|
|
1723
|
+
this.enrolledPasskeys = user.enrolledPasskeys.map(passkeyInfo => (Object.assign({}, passkeyInfo)));
|
|
1719
1724
|
this.metadata._copy(user.metadata);
|
|
1720
1725
|
this.stsTokenManager._assign(user.stsTokenManager);
|
|
1721
1726
|
}
|
|
@@ -5704,8 +5709,7 @@ async function recachePasswordPolicy(auth) {
|
|
|
5704
5709
|
/**
|
|
5705
5710
|
* Sends a password reset email to the given email address. This method does not throw an error when
|
|
5706
5711
|
* there's no user account with the given email address and
|
|
5707
|
-
*
|
|
5708
|
-
* is enabled.
|
|
5712
|
+
* [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled.
|
|
5709
5713
|
*
|
|
5710
5714
|
* @remarks
|
|
5711
5715
|
* To complete the password reset, call {@link confirmPasswordReset} with the code supplied in
|
|
@@ -5894,10 +5898,9 @@ async function createUserWithEmailAndPassword(auth, email, password) {
|
|
|
5894
5898
|
* Asynchronously signs in using an email and password.
|
|
5895
5899
|
*
|
|
5896
5900
|
* @remarks
|
|
5897
|
-
* Fails with an error if the email address and password do not match.
|
|
5898
|
-
*
|
|
5899
|
-
*
|
|
5900
|
-
* email/password.
|
|
5901
|
+
* Fails with an error if the email address and password do not match.
|
|
5902
|
+
* When [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled,
|
|
5903
|
+
* this method fails with "auth/invalid-credential" in case of an invalid email/password.
|
|
5901
5904
|
*
|
|
5902
5905
|
* This method is not supported on {@link Auth} instances created with a
|
|
5903
5906
|
* {@link @firebase/app#FirebaseServerApp}.
|
|
@@ -6098,9 +6101,8 @@ async function createAuthUri(auth, request) {
|
|
|
6098
6101
|
*/
|
|
6099
6102
|
/**
|
|
6100
6103
|
* Gets the list of possible sign in methods for the given email address. This method returns an
|
|
6101
|
-
* empty list when
|
|
6102
|
-
*
|
|
6103
|
-
* is enabled, irrespective of the number of authentication methods available for the given email.
|
|
6104
|
+
* empty list when [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled, irrespective of the number of
|
|
6105
|
+
* authentication methods available for the given email.
|
|
6104
6106
|
*
|
|
6105
6107
|
* @remarks
|
|
6106
6108
|
* This is useful to differentiate methods of sign-in for the same provider, eg.
|
|
@@ -6112,8 +6114,7 @@ async function createAuthUri(auth, request) {
|
|
|
6112
6114
|
* @param email - The user's email address.
|
|
6113
6115
|
*
|
|
6114
6116
|
* Deprecated. Migrating off of this method is recommended as a security best-practice.
|
|
6115
|
-
* Learn more in the Identity Platform documentation for
|
|
6116
|
-
* {@link https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection | Email Enumeration Protection}.
|
|
6117
|
+
* Learn more in the Identity Platform documentation for [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection).
|
|
6117
6118
|
* @public
|
|
6118
6119
|
*/
|
|
6119
6120
|
async function fetchSignInMethodsForEmail(auth, email) {
|
|
@@ -6226,6 +6227,248 @@ async function verifyBeforeUpdateEmail(user, newEmail, actionCodeSettings) {
|
|
|
6226
6227
|
}
|
|
6227
6228
|
}
|
|
6228
6229
|
|
|
6230
|
+
/**
|
|
6231
|
+
* @license
|
|
6232
|
+
* Copyright 2023 Google LLC
|
|
6233
|
+
*
|
|
6234
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6235
|
+
* you may not use this file except in compliance with the License.
|
|
6236
|
+
* You may obtain a copy of the License at
|
|
6237
|
+
*
|
|
6238
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
6239
|
+
*
|
|
6240
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
6241
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
6242
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6243
|
+
* See the License for the specific language governing permissions and
|
|
6244
|
+
* limitations under the License.
|
|
6245
|
+
*/
|
|
6246
|
+
function publicKeyCredentialToJSON(pubKeyCred) {
|
|
6247
|
+
// Convert ArrayBuffer to Base64
|
|
6248
|
+
function bufferToBase64(buffer) {
|
|
6249
|
+
const byteArray = Array.from(new Uint8Array(buffer));
|
|
6250
|
+
return btoa(String.fromCharCode.apply(null, byteArray));
|
|
6251
|
+
}
|
|
6252
|
+
const clientDataJSON = bufferToBase64(pubKeyCred.response.clientDataJSON);
|
|
6253
|
+
let result = {};
|
|
6254
|
+
// Handle Attestation Response (Registration)
|
|
6255
|
+
if (pubKeyCred.response instanceof AuthenticatorAttestationResponse) {
|
|
6256
|
+
const attestationObject = bufferToBase64(pubKeyCred.response.attestationObject);
|
|
6257
|
+
result = {
|
|
6258
|
+
id: pubKeyCred.id,
|
|
6259
|
+
type: pubKeyCred.type,
|
|
6260
|
+
rawId: bufferToBase64(pubKeyCred.rawId),
|
|
6261
|
+
response: {
|
|
6262
|
+
clientDataJSON,
|
|
6263
|
+
attestationObject
|
|
6264
|
+
}
|
|
6265
|
+
};
|
|
6266
|
+
}
|
|
6267
|
+
// Handle Assertion Response (Authentication)
|
|
6268
|
+
if (pubKeyCred.response instanceof AuthenticatorAssertionResponse) {
|
|
6269
|
+
const authenticatorData = bufferToBase64(pubKeyCred.response.authenticatorData);
|
|
6270
|
+
const signature = bufferToBase64(pubKeyCred.response.signature);
|
|
6271
|
+
const userHandle = pubKeyCred.response.userHandle
|
|
6272
|
+
? bufferToBase64(pubKeyCred.response.userHandle)
|
|
6273
|
+
: undefined;
|
|
6274
|
+
result = {
|
|
6275
|
+
id: pubKeyCred.id,
|
|
6276
|
+
type: pubKeyCred.type,
|
|
6277
|
+
rawId: bufferToBase64(pubKeyCred.rawId),
|
|
6278
|
+
response: {
|
|
6279
|
+
clientDataJSON,
|
|
6280
|
+
authenticatorData,
|
|
6281
|
+
signature,
|
|
6282
|
+
userHandle
|
|
6283
|
+
}
|
|
6284
|
+
};
|
|
6285
|
+
}
|
|
6286
|
+
return result;
|
|
6287
|
+
}
|
|
6288
|
+
async function startPasskeyEnrollment(auth, request) {
|
|
6289
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/passkeyEnrollment:start" /* Endpoint.START_PASSKEY_ENROLLMENT */, _addTidIfNecessary(auth, request));
|
|
6290
|
+
}
|
|
6291
|
+
async function finalizePasskeyEnrollment(auth, request) {
|
|
6292
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/passkeyEnrollment:finalize" /* Endpoint.FINALIZE_PASSKEY_ENROLLMENT */, _addTidIfNecessary(auth, request));
|
|
6293
|
+
}
|
|
6294
|
+
async function startPasskeySignIn(auth, request) {
|
|
6295
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/passkeySignIn:start" /* Endpoint.START_PASSKEY_SIGNIN */, _addTidIfNecessary(auth, request));
|
|
6296
|
+
}
|
|
6297
|
+
async function finalizePasskeySignIn(auth, request) {
|
|
6298
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/passkeySignIn:finalize" /* Endpoint.FINALIZE_PASSKEY_SIGNIN */, _addTidIfNecessary(auth, request));
|
|
6299
|
+
}
|
|
6300
|
+
async function passkeyUnenroll(auth, request) {
|
|
6301
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v1/accounts:update" /* Endpoint.SET_ACCOUNT_INFO */, request);
|
|
6302
|
+
}
|
|
6303
|
+
|
|
6304
|
+
/**
|
|
6305
|
+
* @license
|
|
6306
|
+
* Copyright 2023 Google LLC
|
|
6307
|
+
*
|
|
6308
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6309
|
+
* you may not use this file except in compliance with the License.
|
|
6310
|
+
* You may obtain a copy of the License at
|
|
6311
|
+
*
|
|
6312
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
6313
|
+
*
|
|
6314
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
6315
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
6316
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6317
|
+
* See the License for the specific language governing permissions and
|
|
6318
|
+
* limitations under the License.
|
|
6319
|
+
*/
|
|
6320
|
+
const DEFAULT_PASSKEY_ACCOUNT_NAME = 'Unnamed account (Web)';
|
|
6321
|
+
const PASSKEY_LOOK_UP_ERROR_MESSAGE = 'The operation either timed out or was not allowed.';
|
|
6322
|
+
/**
|
|
6323
|
+
* Signs in a user with a passkey. Use enrollPasskey to enroll a passkey credential for the current user.
|
|
6324
|
+
* @param auth - The Firebase Auth instance.
|
|
6325
|
+
* @param name - The user's name for passkey.
|
|
6326
|
+
* @param manualSignUp - When false, automatically creates an anonymous user if a passkey credential does not exist. Defaults to false.
|
|
6327
|
+
* @returns A promise that resolves with a `UserCredential` object.
|
|
6328
|
+
*/
|
|
6329
|
+
async function signInWithPasskey(auth, name, manualSignUp = false) {
|
|
6330
|
+
const authInternal = _castAuth(auth);
|
|
6331
|
+
// Start Passkey Sign in
|
|
6332
|
+
const startSignInRequest = {};
|
|
6333
|
+
const startSignInResponse = await startPasskeySignIn(authInternal, startSignInRequest);
|
|
6334
|
+
const options = getPasskeyCredentialRequestOptions(startSignInResponse, name);
|
|
6335
|
+
// Get the credential
|
|
6336
|
+
let credential;
|
|
6337
|
+
try {
|
|
6338
|
+
credential = (await navigator.credentials.get({
|
|
6339
|
+
publicKey: options
|
|
6340
|
+
}));
|
|
6341
|
+
const finalizeSignInRequest = {
|
|
6342
|
+
authenticatorAuthenticationResponse: publicKeyCredentialToJSON(credential),
|
|
6343
|
+
name,
|
|
6344
|
+
displayName: name
|
|
6345
|
+
};
|
|
6346
|
+
const finalizeSignInResponse = await finalizePasskeySignIn(authInternal, finalizeSignInRequest);
|
|
6347
|
+
const operationType = "signIn" /* OperationType.SIGN_IN */;
|
|
6348
|
+
const userCredential = await UserCredentialImpl._fromIdTokenResponse(authInternal, operationType, finalizeSignInResponse);
|
|
6349
|
+
await auth.updateCurrentUser(userCredential.user);
|
|
6350
|
+
return userCredential;
|
|
6351
|
+
}
|
|
6352
|
+
catch (error) {
|
|
6353
|
+
if (error.message.includes(PASSKEY_LOOK_UP_ERROR_MESSAGE) &&
|
|
6354
|
+
!manualSignUp) {
|
|
6355
|
+
// If the user is not signed up, sign them up anonymously
|
|
6356
|
+
const userCredential = await signInAnonymously(authInternal);
|
|
6357
|
+
const user = userCredential.user;
|
|
6358
|
+
return enrollPasskey(user, name);
|
|
6359
|
+
}
|
|
6360
|
+
return Promise.reject(error);
|
|
6361
|
+
}
|
|
6362
|
+
}
|
|
6363
|
+
/**
|
|
6364
|
+
* Enrolls a passkey for the user account.
|
|
6365
|
+
* @param user - The user to enroll the passkey for.
|
|
6366
|
+
* @param name - The name associated with the passkey.
|
|
6367
|
+
* @returns A promise that resolves with a `UserCredential` object.
|
|
6368
|
+
* @public
|
|
6369
|
+
*/
|
|
6370
|
+
async function enrollPasskey(user, name) {
|
|
6371
|
+
const userInternal = getModularInstance(user);
|
|
6372
|
+
const authInternal = _castAuth(userInternal.auth);
|
|
6373
|
+
if (name === '') {
|
|
6374
|
+
name = DEFAULT_PASSKEY_ACCOUNT_NAME;
|
|
6375
|
+
}
|
|
6376
|
+
// Start Passkey Enrollment
|
|
6377
|
+
const idToken = await userInternal.getIdToken();
|
|
6378
|
+
const startEnrollmentRequest = {
|
|
6379
|
+
idToken
|
|
6380
|
+
};
|
|
6381
|
+
const startEnrollmentResponse = await startPasskeyEnrollment(authInternal, startEnrollmentRequest);
|
|
6382
|
+
// Create the crendential
|
|
6383
|
+
try {
|
|
6384
|
+
const options = getPasskeyCredentialCreationOptions(startEnrollmentResponse, name);
|
|
6385
|
+
const credential = (await navigator.credentials.create({
|
|
6386
|
+
publicKey: options
|
|
6387
|
+
}));
|
|
6388
|
+
const idToken = await userInternal.getIdToken();
|
|
6389
|
+
const finalizeEnrollmentRequest = {
|
|
6390
|
+
idToken,
|
|
6391
|
+
authenticatorRegistrationResponse: publicKeyCredentialToJSON(credential),
|
|
6392
|
+
name,
|
|
6393
|
+
displayName: name
|
|
6394
|
+
};
|
|
6395
|
+
const finalizeEnrollmentResponse = await finalizePasskeyEnrollment(authInternal, finalizeEnrollmentRequest);
|
|
6396
|
+
// The passkey provider is linked with the user's current providers.
|
|
6397
|
+
const operationType = "link" /* OperationType.LINK */;
|
|
6398
|
+
const userCredential = await UserCredentialImpl._fromIdTokenResponse(userInternal.auth, operationType, finalizeEnrollmentResponse);
|
|
6399
|
+
return userCredential;
|
|
6400
|
+
}
|
|
6401
|
+
catch (err) {
|
|
6402
|
+
return Promise.reject(err);
|
|
6403
|
+
}
|
|
6404
|
+
}
|
|
6405
|
+
/**
|
|
6406
|
+
* Unenrolls the passkey corresponding to the specified credentialId.
|
|
6407
|
+
* @param user - The user to unenroll the passkey for.
|
|
6408
|
+
* @param credentialId - The ID of the passkey to unenroll.
|
|
6409
|
+
* @returns A promise that resolves when the passkey is successfully unenrolled.
|
|
6410
|
+
* @public
|
|
6411
|
+
*/
|
|
6412
|
+
async function unenrollPasskey(user, credentialId) {
|
|
6413
|
+
const userInternal = getModularInstance(user);
|
|
6414
|
+
const authInternal = _castAuth(userInternal.auth);
|
|
6415
|
+
const idToken = await userInternal.getIdToken();
|
|
6416
|
+
const request = {
|
|
6417
|
+
idToken,
|
|
6418
|
+
deletePasskey: [credentialId]
|
|
6419
|
+
};
|
|
6420
|
+
await passkeyUnenroll(authInternal, request);
|
|
6421
|
+
}
|
|
6422
|
+
// Converts an array of credential IDs of `excludeCredentials` field to an array of `PublicKeyCredentialDescriptor` objects.
|
|
6423
|
+
function convertExcludeCredentials(options) {
|
|
6424
|
+
function base64ToBuffer(base64) {
|
|
6425
|
+
const binaryStr = atob(base64);
|
|
6426
|
+
const len = binaryStr.length;
|
|
6427
|
+
const bytes = new Uint8Array(len);
|
|
6428
|
+
for (let i = 0; i < len; i++) {
|
|
6429
|
+
bytes[i] = binaryStr.charCodeAt(i);
|
|
6430
|
+
}
|
|
6431
|
+
return bytes.buffer;
|
|
6432
|
+
}
|
|
6433
|
+
if ('excludeCredentials' in options && options.excludeCredentials) {
|
|
6434
|
+
for (const cred of options.excludeCredentials) {
|
|
6435
|
+
if (typeof cred.id === 'string') {
|
|
6436
|
+
// Assuming Base64 encoded strings
|
|
6437
|
+
cred.id = base64ToBuffer(cred.id);
|
|
6438
|
+
}
|
|
6439
|
+
}
|
|
6440
|
+
}
|
|
6441
|
+
}
|
|
6442
|
+
function getPasskeyCredentialCreationOptions(response, name = '') {
|
|
6443
|
+
const options = response.credentialCreationOptions;
|
|
6444
|
+
if (name === '') {
|
|
6445
|
+
name = 'Unnamed account (Web)';
|
|
6446
|
+
}
|
|
6447
|
+
options.user.name = name;
|
|
6448
|
+
options.user.displayName = name;
|
|
6449
|
+
const userId = options.user.id;
|
|
6450
|
+
options.user.id = Uint8Array.from(atob(userId), c => c.charCodeAt(0));
|
|
6451
|
+
const rpId = window.location.hostname;
|
|
6452
|
+
options.rp.id = rpId;
|
|
6453
|
+
options.rp.name = rpId;
|
|
6454
|
+
const challengeBase64 = options.challenge;
|
|
6455
|
+
options.challenge = Uint8Array.from(atob(challengeBase64), c => c.charCodeAt(0));
|
|
6456
|
+
convertExcludeCredentials(options);
|
|
6457
|
+
return options;
|
|
6458
|
+
}
|
|
6459
|
+
function getPasskeyCredentialRequestOptions(response, name = '') {
|
|
6460
|
+
const options = response.credentialRequestOptions;
|
|
6461
|
+
if (name === '') {
|
|
6462
|
+
name = 'Unnamed account (Web)';
|
|
6463
|
+
}
|
|
6464
|
+
const rpId = window.location.hostname;
|
|
6465
|
+
options.rpId = rpId;
|
|
6466
|
+
const challengeBase64 = options.challenge;
|
|
6467
|
+
options.challenge = Uint8Array.from(atob(challengeBase64), c => c.charCodeAt(0));
|
|
6468
|
+
convertExcludeCredentials(options);
|
|
6469
|
+
return options;
|
|
6470
|
+
}
|
|
6471
|
+
|
|
6229
6472
|
/**
|
|
6230
6473
|
* @license
|
|
6231
6474
|
* Copyright 2020 Google LLC
|
|
@@ -6310,9 +6553,7 @@ async function updateProfile(user, { displayName, photoURL: photoUrl }) {
|
|
|
6310
6553
|
* @param user - The user.
|
|
6311
6554
|
* @param newEmail - The new email address.
|
|
6312
6555
|
*
|
|
6313
|
-
* Throws "auth/operation-not-allowed" error when
|
|
6314
|
-
* {@link https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection | Email Enumeration Protection}
|
|
6315
|
-
* is enabled.
|
|
6556
|
+
* Throws "auth/operation-not-allowed" error when [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled.
|
|
6316
6557
|
* Deprecated - Use {@link verifyBeforeUpdateEmail} instead.
|
|
6317
6558
|
*
|
|
6318
6559
|
* @public
|
|
@@ -6921,7 +7162,7 @@ function multiFactor(user) {
|
|
|
6921
7162
|
}
|
|
6922
7163
|
|
|
6923
7164
|
var name = "@firebase/auth";
|
|
6924
|
-
var version = "1.7.1-
|
|
7165
|
+
var version = "1.7.1-passkey-preview.103ead202";
|
|
6925
7166
|
|
|
6926
7167
|
/**
|
|
6927
7168
|
* @license
|
|
@@ -7332,5 +7573,5 @@ function _isEmptyString(input) {
|
|
|
7332
7573
|
return typeof input === 'undefined' || (input === null || input === void 0 ? void 0 : input.length) === 0;
|
|
7333
7574
|
}
|
|
7334
7575
|
|
|
7335
|
-
export { TwitterAuthProvider as $, ActionCodeOperation as A, updateCurrentUser as B, signOut as C, revokeAccessToken as D, deleteUser as E, FactorId as F, debugErrorMap as G, prodErrorMap as H, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as I, initializeAuth as J, connectAuthEmulator as K, AuthCredential as L, EmailAuthCredential as M, OAuthCredential as N, OperationType as O, PhoneAuthProvider as P, PhoneAuthCredential as Q, RecaptchaVerifier as R, SignInMethod as S, TotpMultiFactorGenerator as T, inMemoryPersistence as U, EmailAuthProvider as V, FacebookAuthProvider as W, GoogleAuthProvider as X, GithubAuthProvider as Y, OAuthProvider as Z, SAMLAuthProvider as _, browserSessionPersistence as a, signInAnonymously as a0, signInWithCredential as a1, linkWithCredential as a2, reauthenticateWithCredential as a3, signInWithCustomToken as a4, sendPasswordResetEmail as a5, confirmPasswordReset as a6, applyActionCode as a7, checkActionCode as a8, verifyPasswordResetCode as a9,
|
|
7336
|
-
//# sourceMappingURL=totp-
|
|
7576
|
+
export { TwitterAuthProvider as $, ActionCodeOperation as A, updateCurrentUser as B, signOut as C, revokeAccessToken as D, deleteUser as E, FactorId as F, debugErrorMap as G, prodErrorMap as H, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as I, initializeAuth as J, connectAuthEmulator as K, AuthCredential as L, EmailAuthCredential as M, OAuthCredential as N, OperationType as O, PhoneAuthProvider as P, PhoneAuthCredential as Q, RecaptchaVerifier as R, SignInMethod as S, TotpMultiFactorGenerator as T, inMemoryPersistence as U, EmailAuthProvider as V, FacebookAuthProvider as W, GoogleAuthProvider as X, GithubAuthProvider as Y, OAuthProvider as Z, SAMLAuthProvider as _, browserSessionPersistence as a, signInAnonymously as a0, signInWithCredential as a1, linkWithCredential as a2, reauthenticateWithCredential as a3, signInWithCustomToken as a4, sendPasswordResetEmail as a5, confirmPasswordReset as a6, applyActionCode as a7, checkActionCode as a8, verifyPasswordResetCode as a9, _reauthenticate as aA, _link as aB, signInWithIdp as aC, _fail as aD, debugAssert as aE, _persistenceKeyName as aF, _serverAppCurrentUserOperationNotSupportedError as aG, _castAuth as aH, FederatedAuthProvider as aI, BaseOAuthProvider as aJ, _emulatorUrl as aK, _performApiRequest as aL, _isIOS as aM, _isAndroid as aN, _isIOS7Or8 as aO, _createError as aP, _isIframe as aQ, _isMobileBrowser as aR, _isIE10 as aS, _isSafari as aT, UserImpl as aU, AuthImpl as aV, _getClientVersion as aW, FetchProvider as aX, SAMLAuthCredential as aY, createUserWithEmailAndPassword as aa, signInWithEmailAndPassword as ab, sendSignInLinkToEmail as ac, isSignInWithEmailLink as ad, signInWithEmailLink as ae, fetchSignInMethodsForEmail as af, sendEmailVerification as ag, verifyBeforeUpdateEmail as ah, signInWithPasskey as ai, enrollPasskey as aj, unenrollPasskey as ak, ActionCodeURL as al, parseActionCodeURL as am, updateProfile as an, updateEmail as ao, updatePassword as ap, getIdToken as aq, getIdTokenResult as ar, unlink as as, getAdditionalUserInfo as at, reload as au, getMultiFactorResolver as av, multiFactor as aw, _getInstance as ax, _assert as ay, _signInWithCredential as az, browserLocalPersistence as b, signInWithPopup as c, linkWithPopup as d, reauthenticateWithPopup as e, signInWithRedirect as f, linkWithRedirect as g, reauthenticateWithRedirect as h, indexedDBLocalPersistence as i, getRedirectResult as j, browserPopupRedirectResolver as k, linkWithPhoneNumber as l, PhoneMultiFactorGenerator as m, TotpSecret as n, getAuth as o, ProviderId as p, setPersistence as q, reauthenticateWithPhoneNumber as r, signInWithPhoneNumber as s, initializeRecaptchaConfig as t, updatePhoneNumber as u, validatePassword as v, onIdTokenChanged as w, beforeAuthStateChanged as x, onAuthStateChanged as y, useDeviceLanguage as z };
|
|
7577
|
+
//# sourceMappingURL=totp-86acc588.js.map
|