@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
|
@@ -1370,7 +1370,8 @@ async function _reloadWithoutSaving(user) {
|
|
|
1370
1370
|
tenantId: coreAccount.tenantId || null,
|
|
1371
1371
|
providerData,
|
|
1372
1372
|
metadata: new UserMetadata(coreAccount.createdAt, coreAccount.lastLoginAt),
|
|
1373
|
-
isAnonymous
|
|
1373
|
+
isAnonymous,
|
|
1374
|
+
enrolledPasskeys: coreAccount.passkeyInfo || []
|
|
1374
1375
|
};
|
|
1375
1376
|
Object.assign(user, updates);
|
|
1376
1377
|
}
|
|
@@ -1602,6 +1603,9 @@ class UserImpl {
|
|
|
1602
1603
|
this.isAnonymous = opt.isAnonymous || false;
|
|
1603
1604
|
this.tenantId = opt.tenantId || null;
|
|
1604
1605
|
this.providerData = opt.providerData ? [...opt.providerData] : [];
|
|
1606
|
+
this.enrolledPasskeys = opt.enrolledPasskeys
|
|
1607
|
+
? [...opt.enrolledPasskeys]
|
|
1608
|
+
: [];
|
|
1605
1609
|
this.metadata = new UserMetadata(opt.createdAt || undefined, opt.lastLoginAt || undefined);
|
|
1606
1610
|
}
|
|
1607
1611
|
async getIdToken(forceRefresh) {
|
|
@@ -1633,6 +1637,7 @@ class UserImpl {
|
|
|
1633
1637
|
this.isAnonymous = user.isAnonymous;
|
|
1634
1638
|
this.tenantId = user.tenantId;
|
|
1635
1639
|
this.providerData = user.providerData.map(userInfo => (Object.assign({}, userInfo)));
|
|
1640
|
+
this.enrolledPasskeys = user.enrolledPasskeys.map(passkeyInfo => (Object.assign({}, passkeyInfo)));
|
|
1636
1641
|
this.metadata._copy(user.metadata);
|
|
1637
1642
|
this.stsTokenManager._assign(user.stsTokenManager);
|
|
1638
1643
|
}
|
|
@@ -5640,8 +5645,7 @@ async function recachePasswordPolicy(auth) {
|
|
|
5640
5645
|
/**
|
|
5641
5646
|
* Sends a password reset email to the given email address. This method does not throw an error when
|
|
5642
5647
|
* there's no user account with the given email address and
|
|
5643
|
-
*
|
|
5644
|
-
* is enabled.
|
|
5648
|
+
* [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled.
|
|
5645
5649
|
*
|
|
5646
5650
|
* @remarks
|
|
5647
5651
|
* To complete the password reset, call {@link confirmPasswordReset} with the code supplied in
|
|
@@ -5830,10 +5834,9 @@ async function createUserWithEmailAndPassword(auth, email, password) {
|
|
|
5830
5834
|
* Asynchronously signs in using an email and password.
|
|
5831
5835
|
*
|
|
5832
5836
|
* @remarks
|
|
5833
|
-
* Fails with an error if the email address and password do not match.
|
|
5834
|
-
*
|
|
5835
|
-
*
|
|
5836
|
-
* email/password.
|
|
5837
|
+
* Fails with an error if the email address and password do not match.
|
|
5838
|
+
* When [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled,
|
|
5839
|
+
* this method fails with "auth/invalid-credential" in case of an invalid email/password.
|
|
5837
5840
|
*
|
|
5838
5841
|
* This method is not supported on {@link Auth} instances created with a
|
|
5839
5842
|
* {@link @firebase/app#FirebaseServerApp}.
|
|
@@ -6034,9 +6037,8 @@ async function createAuthUri(auth, request) {
|
|
|
6034
6037
|
*/
|
|
6035
6038
|
/**
|
|
6036
6039
|
* Gets the list of possible sign in methods for the given email address. This method returns an
|
|
6037
|
-
* empty list when
|
|
6038
|
-
*
|
|
6039
|
-
* is enabled, irrespective of the number of authentication methods available for the given email.
|
|
6040
|
+
* empty list when [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled, irrespective of the number of
|
|
6041
|
+
* authentication methods available for the given email.
|
|
6040
6042
|
*
|
|
6041
6043
|
* @remarks
|
|
6042
6044
|
* This is useful to differentiate methods of sign-in for the same provider, eg.
|
|
@@ -6048,8 +6050,7 @@ async function createAuthUri(auth, request) {
|
|
|
6048
6050
|
* @param email - The user's email address.
|
|
6049
6051
|
*
|
|
6050
6052
|
* Deprecated. Migrating off of this method is recommended as a security best-practice.
|
|
6051
|
-
* Learn more in the Identity Platform documentation for
|
|
6052
|
-
* {@link https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection | Email Enumeration Protection}.
|
|
6053
|
+
* Learn more in the Identity Platform documentation for [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection).
|
|
6053
6054
|
* @public
|
|
6054
6055
|
*/
|
|
6055
6056
|
async function fetchSignInMethodsForEmail(auth, email) {
|
|
@@ -6162,6 +6163,248 @@ async function verifyBeforeUpdateEmail(user, newEmail, actionCodeSettings) {
|
|
|
6162
6163
|
}
|
|
6163
6164
|
}
|
|
6164
6165
|
|
|
6166
|
+
/**
|
|
6167
|
+
* @license
|
|
6168
|
+
* Copyright 2023 Google LLC
|
|
6169
|
+
*
|
|
6170
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6171
|
+
* you may not use this file except in compliance with the License.
|
|
6172
|
+
* You may obtain a copy of the License at
|
|
6173
|
+
*
|
|
6174
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
6175
|
+
*
|
|
6176
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
6177
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
6178
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6179
|
+
* See the License for the specific language governing permissions and
|
|
6180
|
+
* limitations under the License.
|
|
6181
|
+
*/
|
|
6182
|
+
function publicKeyCredentialToJSON(pubKeyCred) {
|
|
6183
|
+
// Convert ArrayBuffer to Base64
|
|
6184
|
+
function bufferToBase64(buffer) {
|
|
6185
|
+
const byteArray = Array.from(new Uint8Array(buffer));
|
|
6186
|
+
return btoa(String.fromCharCode.apply(null, byteArray));
|
|
6187
|
+
}
|
|
6188
|
+
const clientDataJSON = bufferToBase64(pubKeyCred.response.clientDataJSON);
|
|
6189
|
+
let result = {};
|
|
6190
|
+
// Handle Attestation Response (Registration)
|
|
6191
|
+
if (pubKeyCred.response instanceof AuthenticatorAttestationResponse) {
|
|
6192
|
+
const attestationObject = bufferToBase64(pubKeyCred.response.attestationObject);
|
|
6193
|
+
result = {
|
|
6194
|
+
id: pubKeyCred.id,
|
|
6195
|
+
type: pubKeyCred.type,
|
|
6196
|
+
rawId: bufferToBase64(pubKeyCred.rawId),
|
|
6197
|
+
response: {
|
|
6198
|
+
clientDataJSON,
|
|
6199
|
+
attestationObject
|
|
6200
|
+
}
|
|
6201
|
+
};
|
|
6202
|
+
}
|
|
6203
|
+
// Handle Assertion Response (Authentication)
|
|
6204
|
+
if (pubKeyCred.response instanceof AuthenticatorAssertionResponse) {
|
|
6205
|
+
const authenticatorData = bufferToBase64(pubKeyCred.response.authenticatorData);
|
|
6206
|
+
const signature = bufferToBase64(pubKeyCred.response.signature);
|
|
6207
|
+
const userHandle = pubKeyCred.response.userHandle
|
|
6208
|
+
? bufferToBase64(pubKeyCred.response.userHandle)
|
|
6209
|
+
: undefined;
|
|
6210
|
+
result = {
|
|
6211
|
+
id: pubKeyCred.id,
|
|
6212
|
+
type: pubKeyCred.type,
|
|
6213
|
+
rawId: bufferToBase64(pubKeyCred.rawId),
|
|
6214
|
+
response: {
|
|
6215
|
+
clientDataJSON,
|
|
6216
|
+
authenticatorData,
|
|
6217
|
+
signature,
|
|
6218
|
+
userHandle
|
|
6219
|
+
}
|
|
6220
|
+
};
|
|
6221
|
+
}
|
|
6222
|
+
return result;
|
|
6223
|
+
}
|
|
6224
|
+
async function startPasskeyEnrollment(auth, request) {
|
|
6225
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/passkeyEnrollment:start" /* Endpoint.START_PASSKEY_ENROLLMENT */, _addTidIfNecessary(auth, request));
|
|
6226
|
+
}
|
|
6227
|
+
async function finalizePasskeyEnrollment(auth, request) {
|
|
6228
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/passkeyEnrollment:finalize" /* Endpoint.FINALIZE_PASSKEY_ENROLLMENT */, _addTidIfNecessary(auth, request));
|
|
6229
|
+
}
|
|
6230
|
+
async function startPasskeySignIn(auth, request) {
|
|
6231
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/passkeySignIn:start" /* Endpoint.START_PASSKEY_SIGNIN */, _addTidIfNecessary(auth, request));
|
|
6232
|
+
}
|
|
6233
|
+
async function finalizePasskeySignIn(auth, request) {
|
|
6234
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/passkeySignIn:finalize" /* Endpoint.FINALIZE_PASSKEY_SIGNIN */, _addTidIfNecessary(auth, request));
|
|
6235
|
+
}
|
|
6236
|
+
async function passkeyUnenroll(auth, request) {
|
|
6237
|
+
return _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v1/accounts:update" /* Endpoint.SET_ACCOUNT_INFO */, request);
|
|
6238
|
+
}
|
|
6239
|
+
|
|
6240
|
+
/**
|
|
6241
|
+
* @license
|
|
6242
|
+
* Copyright 2023 Google LLC
|
|
6243
|
+
*
|
|
6244
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
6245
|
+
* you may not use this file except in compliance with the License.
|
|
6246
|
+
* You may obtain a copy of the License at
|
|
6247
|
+
*
|
|
6248
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
6249
|
+
*
|
|
6250
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
6251
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
6252
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
6253
|
+
* See the License for the specific language governing permissions and
|
|
6254
|
+
* limitations under the License.
|
|
6255
|
+
*/
|
|
6256
|
+
const DEFAULT_PASSKEY_ACCOUNT_NAME = 'Unnamed account (Web)';
|
|
6257
|
+
const PASSKEY_LOOK_UP_ERROR_MESSAGE = 'The operation either timed out or was not allowed.';
|
|
6258
|
+
/**
|
|
6259
|
+
* Signs in a user with a passkey. Use enrollPasskey to enroll a passkey credential for the current user.
|
|
6260
|
+
* @param auth - The Firebase Auth instance.
|
|
6261
|
+
* @param name - The user's name for passkey.
|
|
6262
|
+
* @param manualSignUp - When false, automatically creates an anonymous user if a passkey credential does not exist. Defaults to false.
|
|
6263
|
+
* @returns A promise that resolves with a `UserCredential` object.
|
|
6264
|
+
*/
|
|
6265
|
+
async function signInWithPasskey(auth, name, manualSignUp = false) {
|
|
6266
|
+
const authInternal = _castAuth(auth);
|
|
6267
|
+
// Start Passkey Sign in
|
|
6268
|
+
const startSignInRequest = {};
|
|
6269
|
+
const startSignInResponse = await startPasskeySignIn(authInternal, startSignInRequest);
|
|
6270
|
+
const options = getPasskeyCredentialRequestOptions(startSignInResponse, name);
|
|
6271
|
+
// Get the credential
|
|
6272
|
+
let credential;
|
|
6273
|
+
try {
|
|
6274
|
+
credential = (await navigator.credentials.get({
|
|
6275
|
+
publicKey: options
|
|
6276
|
+
}));
|
|
6277
|
+
const finalizeSignInRequest = {
|
|
6278
|
+
authenticatorAuthenticationResponse: publicKeyCredentialToJSON(credential),
|
|
6279
|
+
name,
|
|
6280
|
+
displayName: name
|
|
6281
|
+
};
|
|
6282
|
+
const finalizeSignInResponse = await finalizePasskeySignIn(authInternal, finalizeSignInRequest);
|
|
6283
|
+
const operationType = "signIn" /* OperationType.SIGN_IN */;
|
|
6284
|
+
const userCredential = await UserCredentialImpl._fromIdTokenResponse(authInternal, operationType, finalizeSignInResponse);
|
|
6285
|
+
await auth.updateCurrentUser(userCredential.user);
|
|
6286
|
+
return userCredential;
|
|
6287
|
+
}
|
|
6288
|
+
catch (error) {
|
|
6289
|
+
if (error.message.includes(PASSKEY_LOOK_UP_ERROR_MESSAGE) &&
|
|
6290
|
+
!manualSignUp) {
|
|
6291
|
+
// If the user is not signed up, sign them up anonymously
|
|
6292
|
+
const userCredential = await signInAnonymously(authInternal);
|
|
6293
|
+
const user = userCredential.user;
|
|
6294
|
+
return enrollPasskey(user, name);
|
|
6295
|
+
}
|
|
6296
|
+
return Promise.reject(error);
|
|
6297
|
+
}
|
|
6298
|
+
}
|
|
6299
|
+
/**
|
|
6300
|
+
* Enrolls a passkey for the user account.
|
|
6301
|
+
* @param user - The user to enroll the passkey for.
|
|
6302
|
+
* @param name - The name associated with the passkey.
|
|
6303
|
+
* @returns A promise that resolves with a `UserCredential` object.
|
|
6304
|
+
* @public
|
|
6305
|
+
*/
|
|
6306
|
+
async function enrollPasskey(user, name) {
|
|
6307
|
+
const userInternal = getModularInstance(user);
|
|
6308
|
+
const authInternal = _castAuth(userInternal.auth);
|
|
6309
|
+
if (name === '') {
|
|
6310
|
+
name = DEFAULT_PASSKEY_ACCOUNT_NAME;
|
|
6311
|
+
}
|
|
6312
|
+
// Start Passkey Enrollment
|
|
6313
|
+
const idToken = await userInternal.getIdToken();
|
|
6314
|
+
const startEnrollmentRequest = {
|
|
6315
|
+
idToken
|
|
6316
|
+
};
|
|
6317
|
+
const startEnrollmentResponse = await startPasskeyEnrollment(authInternal, startEnrollmentRequest);
|
|
6318
|
+
// Create the crendential
|
|
6319
|
+
try {
|
|
6320
|
+
const options = getPasskeyCredentialCreationOptions(startEnrollmentResponse, name);
|
|
6321
|
+
const credential = (await navigator.credentials.create({
|
|
6322
|
+
publicKey: options
|
|
6323
|
+
}));
|
|
6324
|
+
const idToken = await userInternal.getIdToken();
|
|
6325
|
+
const finalizeEnrollmentRequest = {
|
|
6326
|
+
idToken,
|
|
6327
|
+
authenticatorRegistrationResponse: publicKeyCredentialToJSON(credential),
|
|
6328
|
+
name,
|
|
6329
|
+
displayName: name
|
|
6330
|
+
};
|
|
6331
|
+
const finalizeEnrollmentResponse = await finalizePasskeyEnrollment(authInternal, finalizeEnrollmentRequest);
|
|
6332
|
+
// The passkey provider is linked with the user's current providers.
|
|
6333
|
+
const operationType = "link" /* OperationType.LINK */;
|
|
6334
|
+
const userCredential = await UserCredentialImpl._fromIdTokenResponse(userInternal.auth, operationType, finalizeEnrollmentResponse);
|
|
6335
|
+
return userCredential;
|
|
6336
|
+
}
|
|
6337
|
+
catch (err) {
|
|
6338
|
+
return Promise.reject(err);
|
|
6339
|
+
}
|
|
6340
|
+
}
|
|
6341
|
+
/**
|
|
6342
|
+
* Unenrolls the passkey corresponding to the specified credentialId.
|
|
6343
|
+
* @param user - The user to unenroll the passkey for.
|
|
6344
|
+
* @param credentialId - The ID of the passkey to unenroll.
|
|
6345
|
+
* @returns A promise that resolves when the passkey is successfully unenrolled.
|
|
6346
|
+
* @public
|
|
6347
|
+
*/
|
|
6348
|
+
async function unenrollPasskey(user, credentialId) {
|
|
6349
|
+
const userInternal = getModularInstance(user);
|
|
6350
|
+
const authInternal = _castAuth(userInternal.auth);
|
|
6351
|
+
const idToken = await userInternal.getIdToken();
|
|
6352
|
+
const request = {
|
|
6353
|
+
idToken,
|
|
6354
|
+
deletePasskey: [credentialId]
|
|
6355
|
+
};
|
|
6356
|
+
await passkeyUnenroll(authInternal, request);
|
|
6357
|
+
}
|
|
6358
|
+
// Converts an array of credential IDs of `excludeCredentials` field to an array of `PublicKeyCredentialDescriptor` objects.
|
|
6359
|
+
function convertExcludeCredentials(options) {
|
|
6360
|
+
function base64ToBuffer(base64) {
|
|
6361
|
+
const binaryStr = atob(base64);
|
|
6362
|
+
const len = binaryStr.length;
|
|
6363
|
+
const bytes = new Uint8Array(len);
|
|
6364
|
+
for (let i = 0; i < len; i++) {
|
|
6365
|
+
bytes[i] = binaryStr.charCodeAt(i);
|
|
6366
|
+
}
|
|
6367
|
+
return bytes.buffer;
|
|
6368
|
+
}
|
|
6369
|
+
if ('excludeCredentials' in options && options.excludeCredentials) {
|
|
6370
|
+
for (const cred of options.excludeCredentials) {
|
|
6371
|
+
if (typeof cred.id === 'string') {
|
|
6372
|
+
// Assuming Base64 encoded strings
|
|
6373
|
+
cred.id = base64ToBuffer(cred.id);
|
|
6374
|
+
}
|
|
6375
|
+
}
|
|
6376
|
+
}
|
|
6377
|
+
}
|
|
6378
|
+
function getPasskeyCredentialCreationOptions(response, name = '') {
|
|
6379
|
+
const options = response.credentialCreationOptions;
|
|
6380
|
+
if (name === '') {
|
|
6381
|
+
name = 'Unnamed account (Web)';
|
|
6382
|
+
}
|
|
6383
|
+
options.user.name = name;
|
|
6384
|
+
options.user.displayName = name;
|
|
6385
|
+
const userId = options.user.id;
|
|
6386
|
+
options.user.id = Uint8Array.from(atob(userId), c => c.charCodeAt(0));
|
|
6387
|
+
const rpId = window.location.hostname;
|
|
6388
|
+
options.rp.id = rpId;
|
|
6389
|
+
options.rp.name = rpId;
|
|
6390
|
+
const challengeBase64 = options.challenge;
|
|
6391
|
+
options.challenge = Uint8Array.from(atob(challengeBase64), c => c.charCodeAt(0));
|
|
6392
|
+
convertExcludeCredentials(options);
|
|
6393
|
+
return options;
|
|
6394
|
+
}
|
|
6395
|
+
function getPasskeyCredentialRequestOptions(response, name = '') {
|
|
6396
|
+
const options = response.credentialRequestOptions;
|
|
6397
|
+
if (name === '') {
|
|
6398
|
+
name = 'Unnamed account (Web)';
|
|
6399
|
+
}
|
|
6400
|
+
const rpId = window.location.hostname;
|
|
6401
|
+
options.rpId = rpId;
|
|
6402
|
+
const challengeBase64 = options.challenge;
|
|
6403
|
+
options.challenge = Uint8Array.from(atob(challengeBase64), c => c.charCodeAt(0));
|
|
6404
|
+
convertExcludeCredentials(options);
|
|
6405
|
+
return options;
|
|
6406
|
+
}
|
|
6407
|
+
|
|
6165
6408
|
/**
|
|
6166
6409
|
* @license
|
|
6167
6410
|
* Copyright 2020 Google LLC
|
|
@@ -6246,9 +6489,7 @@ async function updateProfile(user, { displayName, photoURL: photoUrl }) {
|
|
|
6246
6489
|
* @param user - The user.
|
|
6247
6490
|
* @param newEmail - The new email address.
|
|
6248
6491
|
*
|
|
6249
|
-
* Throws "auth/operation-not-allowed" error when
|
|
6250
|
-
* {@link https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection | Email Enumeration Protection}
|
|
6251
|
-
* is enabled.
|
|
6492
|
+
* Throws "auth/operation-not-allowed" error when [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled.
|
|
6252
6493
|
* Deprecated - Use {@link verifyBeforeUpdateEmail} instead.
|
|
6253
6494
|
*
|
|
6254
6495
|
* @public
|
|
@@ -7755,7 +7996,7 @@ function _isEmptyString(input) {
|
|
|
7755
7996
|
}
|
|
7756
7997
|
|
|
7757
7998
|
var name = "@firebase/auth";
|
|
7758
|
-
var version = "1.7.1-
|
|
7999
|
+
var version = "1.7.1-passkey-preview.103ead202";
|
|
7759
8000
|
|
|
7760
8001
|
/**
|
|
7761
8002
|
* @license
|
|
@@ -7901,5 +8142,5 @@ function registerAuth(clientPlatform) {
|
|
|
7901
8142
|
registerVersion(name, version, 'esm2017');
|
|
7902
8143
|
}
|
|
7903
8144
|
|
|
7904
|
-
export {
|
|
7905
|
-
//# sourceMappingURL=register-
|
|
8145
|
+
export { ActionCodeURL as $, AUTH_ERROR_CODES_MAP_DO_NOT_USE_INTERNALLY as A, linkWithCredential as B, reauthenticateWithCredential as C, signInWithCustomToken as D, EmailAuthCredential as E, FacebookAuthProvider as F, GoogleAuthProvider as G, sendPasswordResetEmail as H, confirmPasswordReset as I, applyActionCode as J, checkActionCode as K, verifyPasswordResetCode as L, createUserWithEmailAndPassword as M, signInWithEmailAndPassword as N, OAuthCredential as O, PhoneAuthCredential as P, sendSignInLinkToEmail as Q, isSignInWithEmailLink as R, SAMLAuthProvider as S, TotpMultiFactorGenerator as T, signInWithEmailLink as U, fetchSignInMethodsForEmail as V, sendEmailVerification as W, verifyBeforeUpdateEmail as X, signInWithPasskey as Y, enrollPasskey as Z, unenrollPasskey as _, indexedDBLocalPersistence as a, FetchProvider as a$, parseActionCodeURL as a0, updateProfile as a1, updateEmail as a2, updatePassword as a3, getIdToken as a4, getIdTokenResult as a5, unlink as a6, getAdditionalUserInfo as a7, reload as a8, getMultiFactorResolver as a9, _signInWithCredential as aA, _reauthenticate as aB, signInWithIdp as aC, _fail as aD, debugAssert as aE, _assertInstanceOf as aF, _generateEventId as aG, FederatedAuthProvider as aH, _persistenceKeyName as aI, _performApiRequest as aJ, _getCurrentUrl as aK, _gapiScriptUrl as aL, _emulatorUrl as aM, _isChromeIOS as aN, _isFirefox as aO, _isIOSStandalone as aP, BaseOAuthProvider as aQ, _setWindowLocation as aR, MultiFactorAssertionImpl as aS, finalizeEnrollPhoneMfa as aT, finalizeSignInPhoneMfa as aU, _setExternalJSProvider as aV, _isAndroid as aW, _isIOS7Or8 as aX, UserImpl as aY, AuthImpl as aZ, _getClientVersion as a_, multiFactor as aa, STORAGE_AVAILABLE_KEY as ab, _isIframe as ac, _isMobileBrowser as ad, _isIE10 as ae, _isSafari as af, _isIOS as ag, _assert as ah, Delay as ai, _window as aj, isV2 as ak, _createError as al, _recaptchaV2ScriptUrl as am, _loadJS as an, _generateCallbackName as ao, _castAuth as ap, _isHttpOrHttps as aq, _isWorker as ar, getRecaptchaParams as as, _serverAppCurrentUserOperationNotSupportedError as at, _assertLinkedStatus as au, startEnrollPhoneMfa as av, startSignInPhoneMfa as aw, sendPhoneVerificationCode as ax, _link as ay, _getInstance as az, TotpSecret as b, SAMLAuthCredential as b0, connectAuthEmulator as c, initializeRecaptchaConfig as d, beforeAuthStateChanged as e, onAuthStateChanged as f, updateCurrentUser as g, signOut as h, initializeAuth as i, revokeAccessToken as j, deleteUser as k, debugErrorMap as l, AuthCredential as m, inMemoryPersistence as n, onIdTokenChanged as o, prodErrorMap as p, EmailAuthProvider as q, registerAuth as r, setPersistence as s, GithubAuthProvider as t, useDeviceLanguage as u, validatePassword as v, OAuthProvider as w, TwitterAuthProvider as x, signInAnonymously as y, signInWithCredential as z };
|
|
8146
|
+
//# sourceMappingURL=register-49f5fb7d.js.map
|