@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
|
@@ -1600,7 +1600,8 @@ function _reloadWithoutSaving(user) {
|
|
|
1600
1600
|
tenantId: coreAccount.tenantId || null,
|
|
1601
1601
|
providerData: providerData,
|
|
1602
1602
|
metadata: new UserMetadata(coreAccount.createdAt, coreAccount.lastLoginAt),
|
|
1603
|
-
isAnonymous: isAnonymous
|
|
1603
|
+
isAnonymous: isAnonymous,
|
|
1604
|
+
enrolledPasskeys: coreAccount.passkeyInfo || []
|
|
1604
1605
|
};
|
|
1605
1606
|
Object.assign(user, updates);
|
|
1606
1607
|
return [2 /*return*/];
|
|
@@ -1898,6 +1899,8 @@ var UserImpl = /** @class */ (function () {
|
|
|
1898
1899
|
this.isAnonymous = opt.isAnonymous || false;
|
|
1899
1900
|
this.tenantId = opt.tenantId || null;
|
|
1900
1901
|
this.providerData = opt.providerData ? tslib.__spreadArray([], opt.providerData, true) : [];
|
|
1902
|
+
this.enrolledPasskeys = opt.enrolledPasskeys
|
|
1903
|
+
? tslib.__spreadArray([], opt.enrolledPasskeys, true) : [];
|
|
1901
1904
|
this.metadata = new UserMetadata(opt.createdAt || undefined, opt.lastLoginAt || undefined);
|
|
1902
1905
|
}
|
|
1903
1906
|
UserImpl.prototype.getIdToken = function (forceRefresh) {
|
|
@@ -1940,6 +1943,7 @@ var UserImpl = /** @class */ (function () {
|
|
|
1940
1943
|
this.isAnonymous = user.isAnonymous;
|
|
1941
1944
|
this.tenantId = user.tenantId;
|
|
1942
1945
|
this.providerData = user.providerData.map(function (userInfo) { return (tslib.__assign({}, userInfo)); });
|
|
1946
|
+
this.enrolledPasskeys = user.enrolledPasskeys.map(function (passkeyInfo) { return (tslib.__assign({}, passkeyInfo)); });
|
|
1943
1947
|
this.metadata._copy(user.metadata);
|
|
1944
1948
|
this.stsTokenManager._assign(user.stsTokenManager);
|
|
1945
1949
|
};
|
|
@@ -6712,8 +6716,7 @@ function recachePasswordPolicy(auth) {
|
|
|
6712
6716
|
/**
|
|
6713
6717
|
* Sends a password reset email to the given email address. This method does not throw an error when
|
|
6714
6718
|
* there's no user account with the given email address and
|
|
6715
|
-
*
|
|
6716
|
-
* is enabled.
|
|
6719
|
+
* [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled.
|
|
6717
6720
|
*
|
|
6718
6721
|
* @remarks
|
|
6719
6722
|
* To complete the password reset, call {@link confirmPasswordReset} with the code supplied in
|
|
@@ -6959,10 +6962,9 @@ function createUserWithEmailAndPassword(auth, email, password) {
|
|
|
6959
6962
|
* Asynchronously signs in using an email and password.
|
|
6960
6963
|
*
|
|
6961
6964
|
* @remarks
|
|
6962
|
-
* Fails with an error if the email address and password do not match.
|
|
6963
|
-
*
|
|
6964
|
-
*
|
|
6965
|
-
* email/password.
|
|
6965
|
+
* Fails with an error if the email address and password do not match.
|
|
6966
|
+
* When [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled,
|
|
6967
|
+
* this method fails with "auth/invalid-credential" in case of an invalid email/password.
|
|
6966
6968
|
*
|
|
6967
6969
|
* This method is not supported on {@link Auth} instances created with a
|
|
6968
6970
|
* {@link @firebase/app#FirebaseServerApp}.
|
|
@@ -7186,9 +7188,8 @@ function createAuthUri(auth, request) {
|
|
|
7186
7188
|
*/
|
|
7187
7189
|
/**
|
|
7188
7190
|
* Gets the list of possible sign in methods for the given email address. This method returns an
|
|
7189
|
-
* empty list when
|
|
7190
|
-
*
|
|
7191
|
-
* is enabled, irrespective of the number of authentication methods available for the given email.
|
|
7191
|
+
* empty list when [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled, irrespective of the number of
|
|
7192
|
+
* authentication methods available for the given email.
|
|
7192
7193
|
*
|
|
7193
7194
|
* @remarks
|
|
7194
7195
|
* This is useful to differentiate methods of sign-in for the same provider, eg.
|
|
@@ -7200,8 +7201,7 @@ function createAuthUri(auth, request) {
|
|
|
7200
7201
|
* @param email - The user's email address.
|
|
7201
7202
|
*
|
|
7202
7203
|
* Deprecated. Migrating off of this method is recommended as a security best-practice.
|
|
7203
|
-
* Learn more in the Identity Platform documentation for
|
|
7204
|
-
* {@link https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection | Email Enumeration Protection}.
|
|
7204
|
+
* Learn more in the Identity Platform documentation for [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection).
|
|
7205
7205
|
* @public
|
|
7206
7206
|
*/
|
|
7207
7207
|
function fetchSignInMethodsForEmail(auth, email) {
|
|
@@ -7353,6 +7353,321 @@ function verifyBeforeUpdateEmail(user, newEmail, actionCodeSettings) {
|
|
|
7353
7353
|
});
|
|
7354
7354
|
}
|
|
7355
7355
|
|
|
7356
|
+
/**
|
|
7357
|
+
* @license
|
|
7358
|
+
* Copyright 2023 Google LLC
|
|
7359
|
+
*
|
|
7360
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7361
|
+
* you may not use this file except in compliance with the License.
|
|
7362
|
+
* You may obtain a copy of the License at
|
|
7363
|
+
*
|
|
7364
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7365
|
+
*
|
|
7366
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
7367
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
7368
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
7369
|
+
* See the License for the specific language governing permissions and
|
|
7370
|
+
* limitations under the License.
|
|
7371
|
+
*/
|
|
7372
|
+
function publicKeyCredentialToJSON(pubKeyCred) {
|
|
7373
|
+
// Convert ArrayBuffer to Base64
|
|
7374
|
+
function bufferToBase64(buffer) {
|
|
7375
|
+
var byteArray = Array.from(new Uint8Array(buffer));
|
|
7376
|
+
return btoa(String.fromCharCode.apply(null, byteArray));
|
|
7377
|
+
}
|
|
7378
|
+
var clientDataJSON = bufferToBase64(pubKeyCred.response.clientDataJSON);
|
|
7379
|
+
var result = {};
|
|
7380
|
+
// Handle Attestation Response (Registration)
|
|
7381
|
+
if (pubKeyCred.response instanceof AuthenticatorAttestationResponse) {
|
|
7382
|
+
var attestationObject = bufferToBase64(pubKeyCred.response.attestationObject);
|
|
7383
|
+
result = {
|
|
7384
|
+
id: pubKeyCred.id,
|
|
7385
|
+
type: pubKeyCred.type,
|
|
7386
|
+
rawId: bufferToBase64(pubKeyCred.rawId),
|
|
7387
|
+
response: {
|
|
7388
|
+
clientDataJSON: clientDataJSON,
|
|
7389
|
+
attestationObject: attestationObject
|
|
7390
|
+
}
|
|
7391
|
+
};
|
|
7392
|
+
}
|
|
7393
|
+
// Handle Assertion Response (Authentication)
|
|
7394
|
+
if (pubKeyCred.response instanceof AuthenticatorAssertionResponse) {
|
|
7395
|
+
var authenticatorData = bufferToBase64(pubKeyCred.response.authenticatorData);
|
|
7396
|
+
var signature = bufferToBase64(pubKeyCred.response.signature);
|
|
7397
|
+
var userHandle = pubKeyCred.response.userHandle
|
|
7398
|
+
? bufferToBase64(pubKeyCred.response.userHandle)
|
|
7399
|
+
: undefined;
|
|
7400
|
+
result = {
|
|
7401
|
+
id: pubKeyCred.id,
|
|
7402
|
+
type: pubKeyCred.type,
|
|
7403
|
+
rawId: bufferToBase64(pubKeyCred.rawId),
|
|
7404
|
+
response: {
|
|
7405
|
+
clientDataJSON: clientDataJSON,
|
|
7406
|
+
authenticatorData: authenticatorData,
|
|
7407
|
+
signature: signature,
|
|
7408
|
+
userHandle: userHandle
|
|
7409
|
+
}
|
|
7410
|
+
};
|
|
7411
|
+
}
|
|
7412
|
+
return result;
|
|
7413
|
+
}
|
|
7414
|
+
function startPasskeyEnrollment(auth, request) {
|
|
7415
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
7416
|
+
return tslib.__generator(this, function (_a) {
|
|
7417
|
+
return [2 /*return*/, _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/passkeyEnrollment:start" /* Endpoint.START_PASSKEY_ENROLLMENT */, _addTidIfNecessary(auth, request))];
|
|
7418
|
+
});
|
|
7419
|
+
});
|
|
7420
|
+
}
|
|
7421
|
+
function finalizePasskeyEnrollment(auth, request) {
|
|
7422
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
7423
|
+
return tslib.__generator(this, function (_a) {
|
|
7424
|
+
return [2 /*return*/, _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/passkeyEnrollment:finalize" /* Endpoint.FINALIZE_PASSKEY_ENROLLMENT */, _addTidIfNecessary(auth, request))];
|
|
7425
|
+
});
|
|
7426
|
+
});
|
|
7427
|
+
}
|
|
7428
|
+
function startPasskeySignIn(auth, request) {
|
|
7429
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
7430
|
+
return tslib.__generator(this, function (_a) {
|
|
7431
|
+
return [2 /*return*/, _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/passkeySignIn:start" /* Endpoint.START_PASSKEY_SIGNIN */, _addTidIfNecessary(auth, request))];
|
|
7432
|
+
});
|
|
7433
|
+
});
|
|
7434
|
+
}
|
|
7435
|
+
function finalizePasskeySignIn(auth, request) {
|
|
7436
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
7437
|
+
return tslib.__generator(this, function (_a) {
|
|
7438
|
+
return [2 /*return*/, _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v2/accounts/passkeySignIn:finalize" /* Endpoint.FINALIZE_PASSKEY_SIGNIN */, _addTidIfNecessary(auth, request))];
|
|
7439
|
+
});
|
|
7440
|
+
});
|
|
7441
|
+
}
|
|
7442
|
+
function passkeyUnenroll(auth, request) {
|
|
7443
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
7444
|
+
return tslib.__generator(this, function (_a) {
|
|
7445
|
+
return [2 /*return*/, _performApiRequest(auth, "POST" /* HttpMethod.POST */, "/v1/accounts:update" /* Endpoint.SET_ACCOUNT_INFO */, request)];
|
|
7446
|
+
});
|
|
7447
|
+
});
|
|
7448
|
+
}
|
|
7449
|
+
|
|
7450
|
+
/**
|
|
7451
|
+
* @license
|
|
7452
|
+
* Copyright 2023 Google LLC
|
|
7453
|
+
*
|
|
7454
|
+
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
7455
|
+
* you may not use this file except in compliance with the License.
|
|
7456
|
+
* You may obtain a copy of the License at
|
|
7457
|
+
*
|
|
7458
|
+
* http://www.apache.org/licenses/LICENSE-2.0
|
|
7459
|
+
*
|
|
7460
|
+
* Unless required by applicable law or agreed to in writing, software
|
|
7461
|
+
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
7462
|
+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
7463
|
+
* See the License for the specific language governing permissions and
|
|
7464
|
+
* limitations under the License.
|
|
7465
|
+
*/
|
|
7466
|
+
var DEFAULT_PASSKEY_ACCOUNT_NAME = 'Unnamed account (Web)';
|
|
7467
|
+
var PASSKEY_LOOK_UP_ERROR_MESSAGE = 'The operation either timed out or was not allowed.';
|
|
7468
|
+
/**
|
|
7469
|
+
* Signs in a user with a passkey. Use enrollPasskey to enroll a passkey credential for the current user.
|
|
7470
|
+
* @param auth - The Firebase Auth instance.
|
|
7471
|
+
* @param name - The user's name for passkey.
|
|
7472
|
+
* @param manualSignUp - When false, automatically creates an anonymous user if a passkey credential does not exist. Defaults to false.
|
|
7473
|
+
* @returns A promise that resolves with a `UserCredential` object.
|
|
7474
|
+
*/
|
|
7475
|
+
function signInWithPasskey(auth, name, manualSignUp) {
|
|
7476
|
+
if (manualSignUp === void 0) { manualSignUp = false; }
|
|
7477
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
7478
|
+
var authInternal, startSignInRequest, startSignInResponse, options, credential, finalizeSignInRequest, finalizeSignInResponse, operationType, userCredential, error_1, userCredential, user;
|
|
7479
|
+
return tslib.__generator(this, function (_a) {
|
|
7480
|
+
switch (_a.label) {
|
|
7481
|
+
case 0:
|
|
7482
|
+
authInternal = _castAuth(auth);
|
|
7483
|
+
startSignInRequest = {};
|
|
7484
|
+
return [4 /*yield*/, startPasskeySignIn(authInternal, startSignInRequest)];
|
|
7485
|
+
case 1:
|
|
7486
|
+
startSignInResponse = _a.sent();
|
|
7487
|
+
options = getPasskeyCredentialRequestOptions(startSignInResponse);
|
|
7488
|
+
_a.label = 2;
|
|
7489
|
+
case 2:
|
|
7490
|
+
_a.trys.push([2, 7, , 10]);
|
|
7491
|
+
return [4 /*yield*/, navigator.credentials.get({
|
|
7492
|
+
publicKey: options
|
|
7493
|
+
})];
|
|
7494
|
+
case 3:
|
|
7495
|
+
credential = (_a.sent());
|
|
7496
|
+
finalizeSignInRequest = {
|
|
7497
|
+
authenticatorAuthenticationResponse: publicKeyCredentialToJSON(credential),
|
|
7498
|
+
name: name,
|
|
7499
|
+
displayName: name
|
|
7500
|
+
};
|
|
7501
|
+
return [4 /*yield*/, finalizePasskeySignIn(authInternal, finalizeSignInRequest)];
|
|
7502
|
+
case 4:
|
|
7503
|
+
finalizeSignInResponse = _a.sent();
|
|
7504
|
+
operationType = "signIn" /* OperationType.SIGN_IN */;
|
|
7505
|
+
return [4 /*yield*/, UserCredentialImpl._fromIdTokenResponse(authInternal, operationType, finalizeSignInResponse)];
|
|
7506
|
+
case 5:
|
|
7507
|
+
userCredential = _a.sent();
|
|
7508
|
+
return [4 /*yield*/, auth.updateCurrentUser(userCredential.user)];
|
|
7509
|
+
case 6:
|
|
7510
|
+
_a.sent();
|
|
7511
|
+
return [2 /*return*/, userCredential];
|
|
7512
|
+
case 7:
|
|
7513
|
+
error_1 = _a.sent();
|
|
7514
|
+
if (!(error_1.message.includes(PASSKEY_LOOK_UP_ERROR_MESSAGE) &&
|
|
7515
|
+
!manualSignUp)) return [3 /*break*/, 9];
|
|
7516
|
+
return [4 /*yield*/, signInAnonymously(authInternal)];
|
|
7517
|
+
case 8:
|
|
7518
|
+
userCredential = _a.sent();
|
|
7519
|
+
user = userCredential.user;
|
|
7520
|
+
return [2 /*return*/, enrollPasskey(user, name)];
|
|
7521
|
+
case 9: return [2 /*return*/, Promise.reject(error_1)];
|
|
7522
|
+
case 10: return [2 /*return*/];
|
|
7523
|
+
}
|
|
7524
|
+
});
|
|
7525
|
+
});
|
|
7526
|
+
}
|
|
7527
|
+
/**
|
|
7528
|
+
* Enrolls a passkey for the user account.
|
|
7529
|
+
* @param user - The user to enroll the passkey for.
|
|
7530
|
+
* @param name - The name associated with the passkey.
|
|
7531
|
+
* @returns A promise that resolves with a `UserCredential` object.
|
|
7532
|
+
* @public
|
|
7533
|
+
*/
|
|
7534
|
+
function enrollPasskey(user, name) {
|
|
7535
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
7536
|
+
var userInternal, authInternal, idToken, startEnrollmentRequest, startEnrollmentResponse, options, credential, idToken_1, finalizeEnrollmentRequest, finalizeEnrollmentResponse, operationType, userCredential, err_1;
|
|
7537
|
+
return tslib.__generator(this, function (_a) {
|
|
7538
|
+
switch (_a.label) {
|
|
7539
|
+
case 0:
|
|
7540
|
+
userInternal = util.getModularInstance(user);
|
|
7541
|
+
authInternal = _castAuth(userInternal.auth);
|
|
7542
|
+
if (name === '') {
|
|
7543
|
+
name = DEFAULT_PASSKEY_ACCOUNT_NAME;
|
|
7544
|
+
}
|
|
7545
|
+
return [4 /*yield*/, userInternal.getIdToken()];
|
|
7546
|
+
case 1:
|
|
7547
|
+
idToken = _a.sent();
|
|
7548
|
+
startEnrollmentRequest = {
|
|
7549
|
+
idToken: idToken
|
|
7550
|
+
};
|
|
7551
|
+
return [4 /*yield*/, startPasskeyEnrollment(authInternal, startEnrollmentRequest)];
|
|
7552
|
+
case 2:
|
|
7553
|
+
startEnrollmentResponse = _a.sent();
|
|
7554
|
+
_a.label = 3;
|
|
7555
|
+
case 3:
|
|
7556
|
+
_a.trys.push([3, 8, , 9]);
|
|
7557
|
+
options = getPasskeyCredentialCreationOptions(startEnrollmentResponse, name);
|
|
7558
|
+
return [4 /*yield*/, navigator.credentials.create({
|
|
7559
|
+
publicKey: options
|
|
7560
|
+
})];
|
|
7561
|
+
case 4:
|
|
7562
|
+
credential = (_a.sent());
|
|
7563
|
+
return [4 /*yield*/, userInternal.getIdToken()];
|
|
7564
|
+
case 5:
|
|
7565
|
+
idToken_1 = _a.sent();
|
|
7566
|
+
finalizeEnrollmentRequest = {
|
|
7567
|
+
idToken: idToken_1,
|
|
7568
|
+
authenticatorRegistrationResponse: publicKeyCredentialToJSON(credential),
|
|
7569
|
+
name: name,
|
|
7570
|
+
displayName: name
|
|
7571
|
+
};
|
|
7572
|
+
return [4 /*yield*/, finalizePasskeyEnrollment(authInternal, finalizeEnrollmentRequest)];
|
|
7573
|
+
case 6:
|
|
7574
|
+
finalizeEnrollmentResponse = _a.sent();
|
|
7575
|
+
operationType = "link" /* OperationType.LINK */;
|
|
7576
|
+
return [4 /*yield*/, UserCredentialImpl._fromIdTokenResponse(userInternal.auth, operationType, finalizeEnrollmentResponse)];
|
|
7577
|
+
case 7:
|
|
7578
|
+
userCredential = _a.sent();
|
|
7579
|
+
return [2 /*return*/, userCredential];
|
|
7580
|
+
case 8:
|
|
7581
|
+
err_1 = _a.sent();
|
|
7582
|
+
return [2 /*return*/, Promise.reject(err_1)];
|
|
7583
|
+
case 9: return [2 /*return*/];
|
|
7584
|
+
}
|
|
7585
|
+
});
|
|
7586
|
+
});
|
|
7587
|
+
}
|
|
7588
|
+
/**
|
|
7589
|
+
* Unenrolls the passkey corresponding to the specified credentialId.
|
|
7590
|
+
* @param user - The user to unenroll the passkey for.
|
|
7591
|
+
* @param credentialId - The ID of the passkey to unenroll.
|
|
7592
|
+
* @returns A promise that resolves when the passkey is successfully unenrolled.
|
|
7593
|
+
* @public
|
|
7594
|
+
*/
|
|
7595
|
+
function unenrollPasskey(user, credentialId) {
|
|
7596
|
+
return tslib.__awaiter(this, void 0, void 0, function () {
|
|
7597
|
+
var userInternal, authInternal, idToken, request;
|
|
7598
|
+
return tslib.__generator(this, function (_a) {
|
|
7599
|
+
switch (_a.label) {
|
|
7600
|
+
case 0:
|
|
7601
|
+
userInternal = util.getModularInstance(user);
|
|
7602
|
+
authInternal = _castAuth(userInternal.auth);
|
|
7603
|
+
return [4 /*yield*/, userInternal.getIdToken()];
|
|
7604
|
+
case 1:
|
|
7605
|
+
idToken = _a.sent();
|
|
7606
|
+
request = {
|
|
7607
|
+
idToken: idToken,
|
|
7608
|
+
deletePasskey: [credentialId]
|
|
7609
|
+
};
|
|
7610
|
+
return [4 /*yield*/, passkeyUnenroll(authInternal, request)];
|
|
7611
|
+
case 2:
|
|
7612
|
+
_a.sent();
|
|
7613
|
+
return [2 /*return*/];
|
|
7614
|
+
}
|
|
7615
|
+
});
|
|
7616
|
+
});
|
|
7617
|
+
}
|
|
7618
|
+
// Converts an array of credential IDs of `excludeCredentials` field to an array of `PublicKeyCredentialDescriptor` objects.
|
|
7619
|
+
function convertExcludeCredentials(options) {
|
|
7620
|
+
function base64ToBuffer(base64) {
|
|
7621
|
+
var binaryStr = atob(base64);
|
|
7622
|
+
var len = binaryStr.length;
|
|
7623
|
+
var bytes = new Uint8Array(len);
|
|
7624
|
+
for (var i = 0; i < len; i++) {
|
|
7625
|
+
bytes[i] = binaryStr.charCodeAt(i);
|
|
7626
|
+
}
|
|
7627
|
+
return bytes.buffer;
|
|
7628
|
+
}
|
|
7629
|
+
if ('excludeCredentials' in options && options.excludeCredentials) {
|
|
7630
|
+
for (var _i = 0, _a = options.excludeCredentials; _i < _a.length; _i++) {
|
|
7631
|
+
var cred = _a[_i];
|
|
7632
|
+
if (typeof cred.id === 'string') {
|
|
7633
|
+
// Assuming Base64 encoded strings
|
|
7634
|
+
cred.id = base64ToBuffer(cred.id);
|
|
7635
|
+
}
|
|
7636
|
+
}
|
|
7637
|
+
}
|
|
7638
|
+
}
|
|
7639
|
+
function getPasskeyCredentialCreationOptions(response, name) {
|
|
7640
|
+
if (name === void 0) { name = ''; }
|
|
7641
|
+
var options = response.credentialCreationOptions;
|
|
7642
|
+
if (name === '') {
|
|
7643
|
+
name = 'Unnamed account (Web)';
|
|
7644
|
+
}
|
|
7645
|
+
options.user.name = name;
|
|
7646
|
+
options.user.displayName = name;
|
|
7647
|
+
var userId = options.user.id;
|
|
7648
|
+
options.user.id = Uint8Array.from(atob(userId), function (c) { return c.charCodeAt(0); });
|
|
7649
|
+
var rpId = window.location.hostname;
|
|
7650
|
+
options.rp.id = rpId;
|
|
7651
|
+
options.rp.name = rpId;
|
|
7652
|
+
var challengeBase64 = options.challenge;
|
|
7653
|
+
options.challenge = Uint8Array.from(atob(challengeBase64), function (c) {
|
|
7654
|
+
return c.charCodeAt(0);
|
|
7655
|
+
});
|
|
7656
|
+
convertExcludeCredentials(options);
|
|
7657
|
+
return options;
|
|
7658
|
+
}
|
|
7659
|
+
function getPasskeyCredentialRequestOptions(response, name) {
|
|
7660
|
+
var options = response.credentialRequestOptions;
|
|
7661
|
+
var rpId = window.location.hostname;
|
|
7662
|
+
options.rpId = rpId;
|
|
7663
|
+
var challengeBase64 = options.challenge;
|
|
7664
|
+
options.challenge = Uint8Array.from(atob(challengeBase64), function (c) {
|
|
7665
|
+
return c.charCodeAt(0);
|
|
7666
|
+
});
|
|
7667
|
+
convertExcludeCredentials(options);
|
|
7668
|
+
return options;
|
|
7669
|
+
}
|
|
7670
|
+
|
|
7356
7671
|
/**
|
|
7357
7672
|
* @license
|
|
7358
7673
|
* Copyright 2020 Google LLC
|
|
@@ -7459,9 +7774,7 @@ function updateProfile(user, _a) {
|
|
|
7459
7774
|
* @param user - The user.
|
|
7460
7775
|
* @param newEmail - The new email address.
|
|
7461
7776
|
*
|
|
7462
|
-
* Throws "auth/operation-not-allowed" error when
|
|
7463
|
-
* {@link https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection | Email Enumeration Protection}
|
|
7464
|
-
* is enabled.
|
|
7777
|
+
* Throws "auth/operation-not-allowed" error when [Email Enumeration Protection](https://cloud.google.com/identity-platform/docs/admin/email-enumeration-protection) is enabled.
|
|
7465
7778
|
* Deprecated - Use {@link verifyBeforeUpdateEmail} instead.
|
|
7466
7779
|
*
|
|
7467
7780
|
* @public
|
|
@@ -8188,7 +8501,7 @@ function multiFactor(user) {
|
|
|
8188
8501
|
}
|
|
8189
8502
|
|
|
8190
8503
|
var name = "@firebase/auth";
|
|
8191
|
-
var version = "1.7.1-
|
|
8504
|
+
var version = "1.7.1-passkey-preview.103ead202";
|
|
8192
8505
|
|
|
8193
8506
|
/**
|
|
8194
8507
|
* @license
|
|
@@ -8712,6 +9025,7 @@ exports.createUserWithEmailAndPassword = createUserWithEmailAndPassword;
|
|
|
8712
9025
|
exports.debugAssert = debugAssert;
|
|
8713
9026
|
exports.debugErrorMap = debugErrorMap;
|
|
8714
9027
|
exports.deleteUser = deleteUser;
|
|
9028
|
+
exports.enrollPasskey = enrollPasskey;
|
|
8715
9029
|
exports.fetchSignInMethodsForEmail = fetchSignInMethodsForEmail;
|
|
8716
9030
|
exports.getAdditionalUserInfo = getAdditionalUserInfo;
|
|
8717
9031
|
exports.getAuth = getAuth;
|
|
@@ -8749,10 +9063,12 @@ exports.signInWithCustomToken = signInWithCustomToken;
|
|
|
8749
9063
|
exports.signInWithEmailAndPassword = signInWithEmailAndPassword;
|
|
8750
9064
|
exports.signInWithEmailLink = signInWithEmailLink;
|
|
8751
9065
|
exports.signInWithIdp = signInWithIdp;
|
|
9066
|
+
exports.signInWithPasskey = signInWithPasskey;
|
|
8752
9067
|
exports.signInWithPhoneNumber = signInWithPhoneNumber;
|
|
8753
9068
|
exports.signInWithPopup = signInWithPopup;
|
|
8754
9069
|
exports.signInWithRedirect = signInWithRedirect;
|
|
8755
9070
|
exports.signOut = signOut;
|
|
9071
|
+
exports.unenrollPasskey = unenrollPasskey;
|
|
8756
9072
|
exports.unlink = unlink;
|
|
8757
9073
|
exports.updateCurrentUser = updateCurrentUser;
|
|
8758
9074
|
exports.updateEmail = updateEmail;
|
|
@@ -8763,4 +9079,4 @@ exports.useDeviceLanguage = useDeviceLanguage;
|
|
|
8763
9079
|
exports.validatePassword = validatePassword;
|
|
8764
9080
|
exports.verifyBeforeUpdateEmail = verifyBeforeUpdateEmail;
|
|
8765
9081
|
exports.verifyPasswordResetCode = verifyPasswordResetCode;
|
|
8766
|
-
//# sourceMappingURL=totp-
|
|
9082
|
+
//# sourceMappingURL=totp-e59979fc.js.map
|