wallaby-cash 2.0.1-alpha.21 → 2.0.1-alpha.22

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/index.cjs.js CHANGED
@@ -509,6 +509,8 @@ var isTest = browser$1.env.NODE_ENV === 'test';
509
509
  var PUBLIC_KEY_CREDENTIAL_TIMEOUT = 60000;
510
510
  var DEFAULT_ENTROPY_BYTES$1 = 32;
511
511
  var PBKDF2_ITERATIONS = 131072;
512
+ var DEFAULT_PRIMARY_SHARE_INDEX = 0;
513
+ var DEFAULT_BACKUP_SHARE_INDEX = 1;
512
514
  /**
513
515
  * In the options for a Web Authentication credential registration request, the caller can specify a list of cryptographic algorithm identifiers in the pubKeyCredParams field.
514
516
  If left unspecified, Chrome uses the default values of ES256 (-7) and RS256 (-257).
@@ -5916,7 +5918,7 @@ var AuthService = /** @class */ (function (_super) {
5916
5918
  }
5917
5919
  return [3 /*break*/, 6];
5918
5920
  case 1:
5919
- console.log('SDK::AuthService::signIn::passkey');
5921
+ logger.log('SDK::AuthService::signIn::passkey');
5920
5922
  return [4 /*yield*/, this.handleSignInWithPasskey({
5921
5923
  input: input,
5922
5924
  })];
@@ -6544,7 +6546,7 @@ var AuthService = /** @class */ (function (_super) {
6544
6546
  clientAuthPubKey: deviceAuthKeys.publicKey,
6545
6547
  },
6546
6548
  }).then(function (authResponse) { return __awaiter(_this, void 0, void 0, function () {
6547
- var firstSalt, registrationCredentials, regCred, clientExtensions, authenticationCredentials, authenticationResponse, authenticationExtensions, clientDataJSONDecoded, prfValue, credentialsKeyPair, encryptedDevicePrivKey, passkeyRawId;
6549
+ var firstSalt, registrationCredentials, regCred, clientExtensions, authenticationCredentials, authenticationResponse, authenticationExtensions, clientDataJSONDecoded, prfValue, credentialsKeyPair, encryptedDevicePrivKey;
6548
6550
  var _a, _b, _c, _d, _e;
6549
6551
  return __generator(this, function (_f) {
6550
6552
  switch (_f.label) {
@@ -6607,8 +6609,6 @@ var AuthService = /** @class */ (function (_super) {
6607
6609
  })];
6608
6610
  case 6:
6609
6611
  encryptedDevicePrivKey = _f.sent();
6610
- passkeyRawId = uint8ArrayToBase64(regCred === null || regCred === void 0 ? void 0 : regCred.rawId);
6611
- console.log('SDK::AuthService::handlePasskeyRegistration::passkeyRawId', passkeyRawId);
6612
6612
  console.log('SDK::AuthService::handlePasskeyRegistration::deviceAuthKeys', deviceAuthKeys);
6613
6613
  if (encryptedDevicePrivKey) {
6614
6614
  this.storageService.saveInBulk([
@@ -6638,10 +6638,6 @@ var AuthService = /** @class */ (function (_super) {
6638
6638
  key: exports.LocalStorageItems.PasskeyCredential,
6639
6639
  value: JSON.stringify(regCred),
6640
6640
  },
6641
- {
6642
- key: exports.LocalStorageItems.PasskeyCredentialId,
6643
- value: passkeyRawId,
6644
- },
6645
6641
  ])];
6646
6642
  case 7:
6647
6643
  _f.sent();
@@ -6689,6 +6685,13 @@ var AuthService = /** @class */ (function (_super) {
6689
6685
  var someChallenge = base64url__default.default.encode(randomSignatureMessage);
6690
6686
  var someChallengeBuffer = Uint8Array.from(someChallenge, function (c) { return c.charCodeAt(0); });
6691
6687
  return {
6688
+ // allowCredentials: [
6689
+ // {
6690
+ // id: rawId,
6691
+ // type: 'public-key',
6692
+ // transports: ['internal', 'hybrid'],
6693
+ // },
6694
+ // ],
6692
6695
  challenge: someChallengeBuffer,
6693
6696
  rpId: this.getRelyingPartyId(),
6694
6697
  userVerification: skipVerification ? 'discouraged' : 'required',
@@ -6732,13 +6735,13 @@ var AuthService = /** @class */ (function (_super) {
6732
6735
  pubKeyCredParams: PUBLIC_KEY_CREDENTIAL_PARAM,
6733
6736
  timeout: PUBLIC_KEY_CREDENTIAL_TIMEOUT,
6734
6737
  authenticatorSelection: {
6735
- residentKey: 'required', // Must be a resident key (discoverable credential)
6736
- requireResidentKey: true, // Ensures the credential is stored on the authenticator
6738
+ residentKey: 'preferred', // Must be a resident key (discoverable credential)
6739
+ requireResidentKey: false, // Ensures the credential is stored on the authenticator
6737
6740
  userVerification: 'required', // for stricter security
6738
6741
  // triggering a passkey to save on the same device.
6739
- authenticatorAttachment: 'platform',
6742
+ // authenticatorAttachment: 'platform' as AuthenticatorAttachment,
6740
6743
  // triggering a passkey to save on the browser.
6741
- // authenticatorAttachment: 'cross-platform' as AuthenticatorAttachment,
6744
+ authenticatorAttachment: 'platform',
6742
6745
  },
6743
6746
  attestation: 'none',
6744
6747
  challenge: utf8ToBytes$2(randomSignatureMessage),
@@ -7974,18 +7977,17 @@ var WalletService = /** @class */ (function (_super) {
7974
7977
  * Adds a new device to the wallet by backing up the encrypted share.
7975
7978
  *
7976
7979
  * @param {string} walletId - The Wallaby wallet ID.
7977
- * @param {Encrypted} encryptedShare - The encrypted share to be backed up.
7980
+ * @param {Encrypted[]} encryptedShares - The array of encrypted backup shares to be processed by Wallaby.
7978
7981
  * @param {string} [password] - The password for encrypting the share, if required.
7979
7982
  * @param {Uint8Array} [prfValue] - The PRF value used for encryption, if applicable.
7980
7983
  * @param {EncryptionMechanism} encryptionMechanism - The mechanism used to encrypt the share.
7981
7984
  * @param {AuthenticationResponse} authResponse - The authentication response containing user information.
7982
- * @param {string} [qrCode] - Optional QR code for session persistence.
7983
7985
  *
7984
7986
  * @returns {Promise<{ success: boolean; reference: string }>} A promise that resolves with the backup reference.
7985
7987
  */
7986
7988
  WalletService.prototype.addNewDevice = function (input) {
7987
7989
  return __awaiter(this, void 0, void 0, function () {
7988
- var encryptedDevicePrivateKey, credentialsKeyPair, decryptedDevicePrivateKey, devicePublicKey, signatureMessage, backUpResponse, error_8;
7990
+ var encryptedDevicePrivateKey, credentialsKeyPair, decryptedDevicePrivateKey, devicePublicKey, signatureMessage, backUpResponse, keyShares, error_8;
7989
7991
  var _a;
7990
7992
  return __generator(this, function (_b) {
7991
7993
  switch (_b.label) {
@@ -8030,13 +8032,26 @@ var WalletService = /** @class */ (function (_super) {
8030
8032
  message: signatureMessage.message,
8031
8033
  signature: signatureMessage.signature,
8032
8034
  clientAuthPubKey: devicePublicKey,
8033
- backupShares: input.encryptedShares,
8035
+ share: {
8036
+ encrypted: input.encryptedShares[DEFAULT_BACKUP_SHARE_INDEX], // we only want to send the backup share to be rewrapped
8037
+ wrappingPublicKey: input.authResponse.user.wallabyAuthPubKey,
8038
+ type: exports.KeyTypeName.OwnerBackupDeviceShare,
8039
+ },
8034
8040
  },
8035
8041
  })];
8036
8042
  case 6:
8037
8043
  backUpResponse = _b.sent();
8044
+ keyShares = [
8045
+ backUpResponse.share, // this is the backup share that is now rewrapped with the new device public key.
8046
+ {
8047
+ encrypted: input.encryptedShares[DEFAULT_PRIMARY_SHARE_INDEX],
8048
+ wrappingPublicKey: input.authResponse.user.wallabyAuthPubKey, // this is the primary share still wrapped from the QR code.
8049
+ type: exports.KeyTypeName.OwnerMainDeviceShare,
8050
+ },
8051
+ ];
8038
8052
  return [4 /*yield*/, this.handlers.handleKeySharesFromResponse({
8039
- keyShares: backUpResponse.shares,
8053
+ // we pass in both shares to be stored on device.
8054
+ keyShares: keyShares,
8040
8055
  devicePrivateKey: decryptedDevicePrivateKey,
8041
8056
  credentialsKeyPair: credentialsKeyPair,
8042
8057
  })];