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