@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
|
@@ -1469,7 +1469,8 @@ async function _reloadWithoutSaving(user) {
|
|
|
1469
1469
|
tenantId: coreAccount.tenantId || null,
|
|
1470
1470
|
providerData,
|
|
1471
1471
|
metadata: new UserMetadata(coreAccount.createdAt, coreAccount.lastLoginAt),
|
|
1472
|
-
isAnonymous
|
|
1472
|
+
isAnonymous,
|
|
1473
|
+
enrolledPasskeys: coreAccount.passkeyInfo || []
|
|
1473
1474
|
};
|
|
1474
1475
|
Object.assign(user, updates);
|
|
1475
1476
|
}
|
|
@@ -1701,6 +1702,9 @@ class UserImpl {
|
|
|
1701
1702
|
this.isAnonymous = opt.isAnonymous || false;
|
|
1702
1703
|
this.tenantId = opt.tenantId || null;
|
|
1703
1704
|
this.providerData = opt.providerData ? [...opt.providerData] : [];
|
|
1705
|
+
this.enrolledPasskeys = opt.enrolledPasskeys
|
|
1706
|
+
? [...opt.enrolledPasskeys]
|
|
1707
|
+
: [];
|
|
1704
1708
|
this.metadata = new UserMetadata(opt.createdAt || undefined, opt.lastLoginAt || undefined);
|
|
1705
1709
|
}
|
|
1706
1710
|
async getIdToken(forceRefresh) {
|
|
@@ -1732,6 +1736,7 @@ class UserImpl {
|
|
|
1732
1736
|
this.isAnonymous = user.isAnonymous;
|
|
1733
1737
|
this.tenantId = user.tenantId;
|
|
1734
1738
|
this.providerData = user.providerData.map(userInfo => (Object.assign({}, userInfo)));
|
|
1739
|
+
this.enrolledPasskeys = user.enrolledPasskeys.map(passkeyInfo => (Object.assign({}, passkeyInfo)));
|
|
1735
1740
|
this.metadata._copy(user.metadata);
|
|
1736
1741
|
this.stsTokenManager._assign(user.stsTokenManager);
|
|
1737
1742
|
}
|
|
@@ -5739,8 +5744,7 @@ async function recachePasswordPolicy(auth) {
|
|
|
5739
5744
|
/**
|
|
5740
5745
|
* Sends a password reset email to the given email address. This method does not throw an error when
|
|
5741
5746
|
* there's no user account with the given email address and
|
|
5742
|
-
*
|
|
5743
|
-
* is enabled.
|
|
5747
|
+
* [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled.
|
|
5744
5748
|
*
|
|
5745
5749
|
* @remarks
|
|
5746
5750
|
* To complete the password reset, call {@link confirmPasswordReset} with the code supplied in
|
|
@@ -5929,10 +5933,9 @@ async function createUserWithEmailAndPassword(auth, email, password) {
|
|
|
5929
5933
|
* Asynchronously signs in using an email and password.
|
|
5930
5934
|
*
|
|
5931
5935
|
* @remarks
|
|
5932
|
-
* Fails with an error if the email address and password do not match.
|
|
5933
|
-
*
|
|
5934
|
-
*
|
|
5935
|
-
* email/password.
|
|
5936
|
+
* Fails with an error if the email address and password do not match.
|
|
5937
|
+
* When [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled,
|
|
5938
|
+
* this method fails with "auth/invalid-credential" in case of an invalid email/password.
|
|
5936
5939
|
*
|
|
5937
5940
|
* This method is not supported on {@link Auth} instances created with a
|
|
5938
5941
|
* {@link @firebase/app#FirebaseServerApp}.
|
|
@@ -6133,9 +6136,8 @@ async function createAuthUri(auth, request) {
|
|
|
6133
6136
|
*/
|
|
6134
6137
|
/**
|
|
6135
6138
|
* Gets the list of possible sign in methods for the given email address. This method returns an
|
|
6136
|
-
* empty list when
|
|
6137
|
-
*
|
|
6138
|
-
* is enabled, irrespective of the number of authentication methods available for the given email.
|
|
6139
|
+
* empty list when [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled, irrespective of the number of
|
|
6140
|
+
* authentication methods available for the given email.
|
|
6139
6141
|
*
|
|
6140
6142
|
* @remarks
|
|
6141
6143
|
* This is useful to differentiate methods of sign-in for the same provider, eg.
|
|
@@ -6147,8 +6149,7 @@ async function createAuthUri(auth, request) {
|
|
|
6147
6149
|
* @param email - The user's email address.
|
|
6148
6150
|
*
|
|
6149
6151
|
* Deprecated. Migrating off of this method is recommended as a security best-practice.
|
|
6150
|
-
* Learn more in the Identity Platform documentation for
|
|
6151
|
-
* {@link https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection | Email Enumeration Protection}.
|
|
6152
|
+
* Learn more in the Identity Platform documentation for [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection).
|
|
6152
6153
|
* @public
|
|
6153
6154
|
*/
|
|
6154
6155
|
async function fetchSignInMethodsForEmail(auth, email) {
|
|
@@ -6261,6 +6262,248 @@ async function verifyBeforeUpdateEmail(user, newEmail, actionCodeSettings) {
|
|
|
6261
6262
|
}
|
|
6262
6263
|
}
|
|
6263
6264
|
|
|
6265
|
+
/**
|
|
6266
|
+
* @license
|
|
6267
|
+
* Copyright 2023 Google LLC
|
|
6268
|
+
*
|
|
6269
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6270
|
+
* you may not use this file except in compliance with the License.
|
|
6271
|
+
* You may obtain a copy of the License at
|
|
6272
|
+
*
|
|
6273
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
6274
|
+
*
|
|
6275
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
6276
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
6277
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6278
|
+
* See the License for the specific language governing permissions and
|
|
6279
|
+
* limitations under the License.
|
|
6280
|
+
*/
|
|
6281
|
+
function publicKeyCredentialToJSON(pubKeyCred) {
|
|
6282
|
+
// Convert ArrayBuffer to Base64
|
|
6283
|
+
function bufferToBase64(buffer) {
|
|
6284
|
+
const byteArray = Array.from(new Uint8Array(buffer));
|
|
6285
|
+
return btoa(String.fromCharCode.apply(null, byteArray));
|
|
6286
|
+
}
|
|
6287
|
+
const clientDataJSON = bufferToBase64(pubKeyCred.response.clientDataJSON);
|
|
6288
|
+
let result = {};
|
|
6289
|
+
// Handle Attestation Response (Registration)
|
|
6290
|
+
if (pubKeyCred.response instanceof AuthenticatorAttestationResponse) {
|
|
6291
|
+
const attestationObject = bufferToBase64(pubKeyCred.response.attestationObject);
|
|
6292
|
+
result = {
|
|
6293
|
+
id: pubKeyCred.id,
|
|
6294
|
+
type: pubKeyCred.type,
|
|
6295
|
+
rawId: bufferToBase64(pubKeyCred.rawId),
|
|
6296
|
+
response: {
|
|
6297
|
+
clientDataJSON,
|
|
6298
|
+
attestationObject
|
|
6299
|
+
}
|
|
6300
|
+
};
|
|
6301
|
+
}
|
|
6302
|
+
// Handle Assertion Response (Authentication)
|
|
6303
|
+
if (pubKeyCred.response instanceof AuthenticatorAssertionResponse) {
|
|
6304
|
+
const authenticatorData = bufferToBase64(pubKeyCred.response.authenticatorData);
|
|
6305
|
+
const signature = bufferToBase64(pubKeyCred.response.signature);
|
|
6306
|
+
const userHandle = pubKeyCred.response.userHandle
|
|
6307
|
+
? bufferToBase64(pubKeyCred.response.userHandle)
|
|
6308
|
+
: undefined;
|
|
6309
|
+
result = {
|
|
6310
|
+
id: pubKeyCred.id,
|
|
6311
|
+
type: pubKeyCred.type,
|
|
6312
|
+
rawId: bufferToBase64(pubKeyCred.rawId),
|
|
6313
|
+
response: {
|
|
6314
|
+
clientDataJSON,
|
|
6315
|
+
authenticatorData,
|
|
6316
|
+
signature,
|
|
6317
|
+
userHandle
|
|
6318
|
+
}
|
|
6319
|
+
};
|
|
6320
|
+
}
|
|
6321
|
+
return result;
|
|
6322
|
+
}
|
|
6323
|
+
async function startPasskeyEnrollment(auth, request) {
|
|
6324
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/passkeyEnrollment:start" /* Endpoint.START_PASSKEY_ENROLLMENT */, _addTidIfNecessary(auth, request));
|
|
6325
|
+
}
|
|
6326
|
+
async function finalizePasskeyEnrollment(auth, request) {
|
|
6327
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/passkeyEnrollment:finalize" /* Endpoint.FINALIZE_PASSKEY_ENROLLMENT */, _addTidIfNecessary(auth, request));
|
|
6328
|
+
}
|
|
6329
|
+
async function startPasskeySignIn(auth, request) {
|
|
6330
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/passkeySignIn:start" /* Endpoint.START_PASSKEY_SIGNIN */, _addTidIfNecessary(auth, request));
|
|
6331
|
+
}
|
|
6332
|
+
async function finalizePasskeySignIn(auth, request) {
|
|
6333
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/passkeySignIn:finalize" /* Endpoint.FINALIZE_PASSKEY_SIGNIN */, _addTidIfNecessary(auth, request));
|
|
6334
|
+
}
|
|
6335
|
+
async function passkeyUnenroll(auth, request) {
|
|
6336
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v1/accounts:update" /* Endpoint.SET_ACCOUNT_INFO */, request);
|
|
6337
|
+
}
|
|
6338
|
+
|
|
6339
|
+
/**
|
|
6340
|
+
* @license
|
|
6341
|
+
* Copyright 2023 Google LLC
|
|
6342
|
+
*
|
|
6343
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6344
|
+
* you may not use this file except in compliance with the License.
|
|
6345
|
+
* You may obtain a copy of the License at
|
|
6346
|
+
*
|
|
6347
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
6348
|
+
*
|
|
6349
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
6350
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
6351
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6352
|
+
* See the License for the specific language governing permissions and
|
|
6353
|
+
* limitations under the License.
|
|
6354
|
+
*/
|
|
6355
|
+
const DEFAULT_PASSKEY_ACCOUNT_NAME = 'Unnamed account (Web)';
|
|
6356
|
+
const PASSKEY_LOOK_UP_ERROR_MESSAGE = 'The operation either timed out or was not allowed.';
|
|
6357
|
+
/**
|
|
6358
|
+
* Signs in a user with a passkey. Use enrollPasskey to enroll a passkey credential for the current user.
|
|
6359
|
+
* @param auth - The Firebase Auth instance.
|
|
6360
|
+
* @param name - The user's name for passkey.
|
|
6361
|
+
* @param manualSignUp - When false, automatically creates an anonymous user if a passkey credential does not exist. Defaults to false.
|
|
6362
|
+
* @returns A promise that resolves with a `UserCredential` object.
|
|
6363
|
+
*/
|
|
6364
|
+
async function signInWithPasskey(auth, name, manualSignUp = false) {
|
|
6365
|
+
const authInternal = _castAuth(auth);
|
|
6366
|
+
// Start Passkey Sign in
|
|
6367
|
+
const startSignInRequest = {};
|
|
6368
|
+
const startSignInResponse = await startPasskeySignIn(authInternal, startSignInRequest);
|
|
6369
|
+
const options = getPasskeyCredentialRequestOptions(startSignInResponse, name);
|
|
6370
|
+
// Get the credential
|
|
6371
|
+
let credential;
|
|
6372
|
+
try {
|
|
6373
|
+
credential = (await navigator.credentials.get({
|
|
6374
|
+
publicKey: options
|
|
6375
|
+
}));
|
|
6376
|
+
const finalizeSignInRequest = {
|
|
6377
|
+
authenticatorAuthenticationResponse: publicKeyCredentialToJSON(credential),
|
|
6378
|
+
name,
|
|
6379
|
+
displayName: name
|
|
6380
|
+
};
|
|
6381
|
+
const finalizeSignInResponse = await finalizePasskeySignIn(authInternal, finalizeSignInRequest);
|
|
6382
|
+
const operationType = "signIn" /* OperationType.SIGN_IN */;
|
|
6383
|
+
const userCredential = await UserCredentialImpl._fromIdTokenResponse(authInternal, operationType, finalizeSignInResponse);
|
|
6384
|
+
await auth.updateCurrentUser(userCredential.user);
|
|
6385
|
+
return userCredential;
|
|
6386
|
+
}
|
|
6387
|
+
catch (error) {
|
|
6388
|
+
if (error.message.includes(PASSKEY_LOOK_UP_ERROR_MESSAGE) &&
|
|
6389
|
+
!manualSignUp) {
|
|
6390
|
+
// If the user is not signed up, sign them up anonymously
|
|
6391
|
+
const userCredential = await signInAnonymously(authInternal);
|
|
6392
|
+
const user = userCredential.user;
|
|
6393
|
+
return enrollPasskey(user, name);
|
|
6394
|
+
}
|
|
6395
|
+
return Promise.reject(error);
|
|
6396
|
+
}
|
|
6397
|
+
}
|
|
6398
|
+
/**
|
|
6399
|
+
* Enrolls a passkey for the user account.
|
|
6400
|
+
* @param user - The user to enroll the passkey for.
|
|
6401
|
+
* @param name - The name associated with the passkey.
|
|
6402
|
+
* @returns A promise that resolves with a `UserCredential` object.
|
|
6403
|
+
* @public
|
|
6404
|
+
*/
|
|
6405
|
+
async function enrollPasskey(user, name) {
|
|
6406
|
+
const userInternal = getModularInstance(user);
|
|
6407
|
+
const authInternal = _castAuth(userInternal.auth);
|
|
6408
|
+
if (name === '') {
|
|
6409
|
+
name = DEFAULT_PASSKEY_ACCOUNT_NAME;
|
|
6410
|
+
}
|
|
6411
|
+
// Start Passkey Enrollment
|
|
6412
|
+
const idToken = await userInternal.getIdToken();
|
|
6413
|
+
const startEnrollmentRequest = {
|
|
6414
|
+
idToken
|
|
6415
|
+
};
|
|
6416
|
+
const startEnrollmentResponse = await startPasskeyEnrollment(authInternal, startEnrollmentRequest);
|
|
6417
|
+
// Create the crendential
|
|
6418
|
+
try {
|
|
6419
|
+
const options = getPasskeyCredentialCreationOptions(startEnrollmentResponse, name);
|
|
6420
|
+
const credential = (await navigator.credentials.create({
|
|
6421
|
+
publicKey: options
|
|
6422
|
+
}));
|
|
6423
|
+
const idToken = await userInternal.getIdToken();
|
|
6424
|
+
const finalizeEnrollmentRequest = {
|
|
6425
|
+
idToken,
|
|
6426
|
+
authenticatorRegistrationResponse: publicKeyCredentialToJSON(credential),
|
|
6427
|
+
name,
|
|
6428
|
+
displayName: name
|
|
6429
|
+
};
|
|
6430
|
+
const finalizeEnrollmentResponse = await finalizePasskeyEnrollment(authInternal, finalizeEnrollmentRequest);
|
|
6431
|
+
// The passkey provider is linked with the user's current providers.
|
|
6432
|
+
const operationType = "link" /* OperationType.LINK */;
|
|
6433
|
+
const userCredential = await UserCredentialImpl._fromIdTokenResponse(userInternal.auth, operationType, finalizeEnrollmentResponse);
|
|
6434
|
+
return userCredential;
|
|
6435
|
+
}
|
|
6436
|
+
catch (err) {
|
|
6437
|
+
return Promise.reject(err);
|
|
6438
|
+
}
|
|
6439
|
+
}
|
|
6440
|
+
/**
|
|
6441
|
+
* Unenrolls the passkey corresponding to the specified credentialId.
|
|
6442
|
+
* @param user - The user to unenroll the passkey for.
|
|
6443
|
+
* @param credentialId - The ID of the passkey to unenroll.
|
|
6444
|
+
* @returns A promise that resolves when the passkey is successfully unenrolled.
|
|
6445
|
+
* @public
|
|
6446
|
+
*/
|
|
6447
|
+
async function unenrollPasskey(user, credentialId) {
|
|
6448
|
+
const userInternal = getModularInstance(user);
|
|
6449
|
+
const authInternal = _castAuth(userInternal.auth);
|
|
6450
|
+
const idToken = await userInternal.getIdToken();
|
|
6451
|
+
const request = {
|
|
6452
|
+
idToken,
|
|
6453
|
+
deletePasskey: [credentialId]
|
|
6454
|
+
};
|
|
6455
|
+
await passkeyUnenroll(authInternal, request);
|
|
6456
|
+
}
|
|
6457
|
+
// Converts an array of credential IDs of `excludeCredentials` field to an array of `PublicKeyCredentialDescriptor` objects.
|
|
6458
|
+
function convertExcludeCredentials(options) {
|
|
6459
|
+
function base64ToBuffer(base64) {
|
|
6460
|
+
const binaryStr = atob(base64);
|
|
6461
|
+
const len = binaryStr.length;
|
|
6462
|
+
const bytes = new Uint8Array(len);
|
|
6463
|
+
for (let i = 0; i < len; i++) {
|
|
6464
|
+
bytes[i] = binaryStr.charCodeAt(i);
|
|
6465
|
+
}
|
|
6466
|
+
return bytes.buffer;
|
|
6467
|
+
}
|
|
6468
|
+
if ('excludeCredentials' in options && options.excludeCredentials) {
|
|
6469
|
+
for (const cred of options.excludeCredentials) {
|
|
6470
|
+
if (typeof cred.id === 'string') {
|
|
6471
|
+
// Assuming Base64 encoded strings
|
|
6472
|
+
cred.id = base64ToBuffer(cred.id);
|
|
6473
|
+
}
|
|
6474
|
+
}
|
|
6475
|
+
}
|
|
6476
|
+
}
|
|
6477
|
+
function getPasskeyCredentialCreationOptions(response, name = '') {
|
|
6478
|
+
const options = response.credentialCreationOptions;
|
|
6479
|
+
if (name === '') {
|
|
6480
|
+
name = 'Unnamed account (Web)';
|
|
6481
|
+
}
|
|
6482
|
+
options.user.name = name;
|
|
6483
|
+
options.user.displayName = name;
|
|
6484
|
+
const userId = options.user.id;
|
|
6485
|
+
options.user.id = Uint8Array.from(atob(userId), c => c.charCodeAt(0));
|
|
6486
|
+
const rpId = window.location.hostname;
|
|
6487
|
+
options.rp.id = rpId;
|
|
6488
|
+
options.rp.name = rpId;
|
|
6489
|
+
const challengeBase64 = options.challenge;
|
|
6490
|
+
options.challenge = Uint8Array.from(atob(challengeBase64), c => c.charCodeAt(0));
|
|
6491
|
+
convertExcludeCredentials(options);
|
|
6492
|
+
return options;
|
|
6493
|
+
}
|
|
6494
|
+
function getPasskeyCredentialRequestOptions(response, name = '') {
|
|
6495
|
+
const options = response.credentialRequestOptions;
|
|
6496
|
+
if (name === '') {
|
|
6497
|
+
name = 'Unnamed account (Web)';
|
|
6498
|
+
}
|
|
6499
|
+
const rpId = window.location.hostname;
|
|
6500
|
+
options.rpId = rpId;
|
|
6501
|
+
const challengeBase64 = options.challenge;
|
|
6502
|
+
options.challenge = Uint8Array.from(atob(challengeBase64), c => c.charCodeAt(0));
|
|
6503
|
+
convertExcludeCredentials(options);
|
|
6504
|
+
return options;
|
|
6505
|
+
}
|
|
6506
|
+
|
|
6264
6507
|
/**
|
|
6265
6508
|
* @license
|
|
6266
6509
|
* Copyright 2020 Google LLC
|
|
@@ -6345,9 +6588,7 @@ async function updateProfile(user, { displayName, photoURL: photoUrl }) {
|
|
|
6345
6588
|
* @param user - The user.
|
|
6346
6589
|
* @param newEmail - The new email address.
|
|
6347
6590
|
*
|
|
6348
|
-
* Throws "auth/operation-not-allowed" error when
|
|
6349
|
-
* {@link https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection | Email Enumeration Protection}
|
|
6350
|
-
* is enabled.
|
|
6591
|
+
* Throws "auth/operation-not-allowed" error when [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled.
|
|
6351
6592
|
* Deprecated - Use {@link verifyBeforeUpdateEmail} instead.
|
|
6352
6593
|
*
|
|
6353
6594
|
* @public
|
|
@@ -10468,7 +10709,7 @@ function _isEmptyString(input) {
|
|
|
10468
10709
|
}
|
|
10469
10710
|
|
|
10470
10711
|
var name = "@firebase/auth";
|
|
10471
|
-
var version = "1.7.1-
|
|
10712
|
+
var version = "1.7.1-passkey-preview.103ead202";
|
|
10472
10713
|
|
|
10473
10714
|
/**
|
|
10474
10715
|
* @license
|
|
@@ -10722,5 +10963,5 @@ _setExternalJSProvider({
|
|
|
10722
10963
|
});
|
|
10723
10964
|
registerAuth("Browser" /* ClientPlatform.BROWSER */);
|
|
10724
10965
|
|
|
10725
|
-
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,
|
|
10726
|
-
//# sourceMappingURL=index-
|
|
10966
|
+
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, _fail as aA, _getRedirectUrl as aB, _getProjectConfig as aC, _isIOS7Or8 as aD, _createError as aE, _assert as aF, AuthEventManager as aG, _getInstance as aH, _persistenceKeyName as aI, _getRedirectResult as aJ, _overrideRedirectResult as aK, _clearRedirectOutcomes as aL, _castAuth as aM, UserImpl as aN, AuthImpl as aO, _getClientVersion as aP, _generateEventId as aQ, AuthPopup as aR, FetchProvider as aS, SAMLAuthCredential as aT, 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, debugAssert as ax, _isIOS as ay, _isAndroid 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 };
|
|
10967
|
+
//# sourceMappingURL=index-e517538d.js.map
|