wallaby-cash 2.3.7 → 2.3.9

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.
@@ -0,0 +1,108 @@
1
+ import { User } from '../../types/common';
2
+ export declare type SignatureMessageResponse = {
3
+ message: string;
4
+ hashedMessage: string;
5
+ signature: string;
6
+ /** @deprecated */
7
+ error?: any;
8
+ };
9
+ export declare type AuthRequest = {
10
+ password: string;
11
+ /**
12
+ * @deprecated
13
+ */
14
+ firstName?: string;
15
+ /**
16
+ * @deprecated
17
+ */
18
+ lastName?: string;
19
+ /**
20
+ * @deprecated
21
+ */
22
+ email?: string;
23
+ };
24
+ export declare type AuthResponse = {
25
+ accessToken: string;
26
+ user: User;
27
+ signatureMessageResponse: SignatureMessageResponse;
28
+ prfValue?: Uint8Array;
29
+ password?: string;
30
+ clientSalt?: string;
31
+ /** @deprecated */
32
+ error?: any;
33
+ };
34
+ export declare type ClientAuthPubKeyRequest = {
35
+ password: string;
36
+ userId: string;
37
+ message: string;
38
+ clientAuthPubKey: string;
39
+ signature: string;
40
+ newClientAuthPubKey: string;
41
+ };
42
+ export declare type ClientAuthPubKeyResponse = {
43
+ user: User;
44
+ /** @deprecated */
45
+ error?: any;
46
+ };
47
+ export declare type RefreshAccessTokenResponse = {
48
+ accessToken: string;
49
+ idToken: string;
50
+ /** @deprecated */
51
+ error?: any;
52
+ };
53
+ export declare type SignatureResponse = {
54
+ signature: string;
55
+ hashedMessage: string;
56
+ message: string;
57
+ };
58
+ export declare type Base64URLString = string;
59
+ export interface PRFExtension {
60
+ prf?: {
61
+ eval?: {
62
+ base64: Base64URLString;
63
+ first: Uint8Array;
64
+ second?: Uint8Array;
65
+ };
66
+ [key: string]: any;
67
+ };
68
+ }
69
+ export type ExtendedAuthenticatorResponse = AuthenticatorResponse & {
70
+ attestationObject: AuthenticatorAssertionResponse;
71
+ signature: ArrayBuffer;
72
+ authenticatorData: ArrayBuffer;
73
+ userHandle: ArrayBuffer;
74
+ };
75
+ export type ExtendedAuthenticationExtensionsClientOutputs = AuthenticationExtensionsClientOutputs & PRFExtension;
76
+ export type ExtendedAuthenticationExtensionsClientInputs = AuthenticationExtensionsClientInputs & PRFExtension;
77
+ export declare enum PublicKeyCredentialAlgorithm {
78
+ RS256 = -257,
79
+ ES256 = -7
80
+ }
81
+ export declare enum TransportEnum {
82
+ Usb = "usb",
83
+ Nfc = "nfc",
84
+ Ble = "ble",
85
+ Internal = "internal",
86
+ Hybrid = "hybrid"
87
+ }
88
+ export declare type SignInRequest = {
89
+ password?: string;
90
+ nickname?: string;
91
+ displayName?: string;
92
+ };
93
+ export declare type AuthenticationRequest = {
94
+ password?: string;
95
+ };
96
+ export declare type AuthenticationResponse = {
97
+ accessToken: string;
98
+ user: User;
99
+ signatureMessageResponse: SignatureMessageResponse;
100
+ nickname?: string;
101
+ displayName?: string;
102
+ password?: string;
103
+ prfValue?: Uint8Array;
104
+ wallabyAuthPublicKey: string;
105
+ clientSalt: string;
106
+ /** @deprecated */
107
+ error?: any;
108
+ };
@@ -1,5 +1,6 @@
1
1
  import { Base } from '../../base';
2
- import { SignatureMessageResponse, WallabyConfig, AuthenticationResponse, AsymmetricKeyPair, GetSignatureOptions, AuthenticationRequest } from '../../types';
2
+ import { SignatureMessageResponse, WallabyConfig, AuthenticationResponse, AsymmetricKeyPair, PasskeyChallengeType } from '../../types';
3
+ import { AuthenticationRequest } from './auth.model';
3
4
  import { GetPasskeyCredentialsData } from '../../generated/api';
4
5
  export declare class AuthService extends Base {
5
6
  private passkeyService;
@@ -38,7 +39,7 @@ export declare class AuthService extends Base {
38
39
  * @param { PasskeyChallengeType } passkeyChallengeType the type of passkey challenge to request, either for registration or authentication.
39
40
  * @returns the messaged, the hash, and the signature using the passed private key.
40
41
  */
41
- getSignature({ deviceAuthKeys, walletId, passkeyChallengeType, }: GetSignatureOptions): Promise<SignatureMessageResponse>;
42
+ getSignature(deviceAuthKeys: AsymmetricKeyPair, passkeyChallengeType?: PasskeyChallengeType): Promise<SignatureMessageResponse>;
42
43
  /**
43
44
  * Signs up a new user.
44
45
  *
@@ -5,13 +5,13 @@ export declare class Swap extends Base {
5
5
  private walletService;
6
6
  constructor(config: WallabyConfig);
7
7
  /**
8
- * Gets a swap quote between two assets (from/to), including fees, min output, and slippage limits.
8
+ * Gets a swap quote between two assets, including fees, min output, and slippage limits.
9
9
  *
10
10
  * @public
11
11
  * @param {SwapQuoteRequest} request - The swap quote request parameters
12
12
  * @returns {Promise<SwapQuoteResponse>} A promise that resolves with the swap quote
13
13
  */
14
- getQuote({ walletId, fromAsset, toAsset, fromAmount, toAmount }: SwapQuoteRequest): Promise<SwapQuoteResponse>;
14
+ getQuote(request: SwapQuoteRequest): Promise<SwapQuoteResponse>;
15
15
  /**
16
16
  * Executes a swap using a previously generated quote.
17
17
  *
@@ -1,6 +1,7 @@
1
1
  import { Base } from '../../base';
2
- import { WallabyConfig, TokenStandard, FeeEstimatesResponse, Transaction, BlockchainName, GetPendingTransactionsRequest, GetPendingTransactionsResponse, ResolvePendingTransactionRequest, ResolvePendingTransactionResponse, TransactionResponse, FeeEstimateRequest } from '../../types';
2
+ import { WallabyConfig, TokenStandard, FeeEstimatesResponse, Transaction, BlockchainName, GetPendingTransactionsRequest, GetPendingTransactionsResponse, ResolvePendingTransactionRequest, ResolvePendingTransactionResponse, TransactionResponse } from '../../types';
3
3
  import { CreateAllowanceRequest, TransactionStatusResponse, TransferRequest } from '../../types';
4
+ import { FeeEstimateRequest } from './transactions.model';
4
5
  export declare class Transactions extends Base {
5
6
  private authService;
6
7
  private walletService;
@@ -17,7 +18,7 @@ export declare class Transactions extends Base {
17
18
  * @param {BlockchainName} blockchain
18
19
  * @returns {FeeEstimateRequest}
19
20
  */
20
- estimateFee({ originAddress, recipientAddress, amount, transactionType, token, }: FeeEstimateRequest): Promise<FeeEstimatesResponse | undefined>;
21
+ estimateFee({ originAddress, recipientAddress, amount, token, transactionType, }: FeeEstimateRequest): Promise<FeeEstimatesResponse | undefined>;
21
22
  /**
22
23
  *
23
24
  * @public
@@ -0,0 +1,22 @@
1
+ import { AuthenticationResponse } from '../auth/auth.model';
2
+ import { BlockchainName, BlockchainSlip44, TokenStandard, TransactionType } from '../../types';
3
+ export declare type FeeEstimateRequest = Omit<BaseTransactionRequest, keyof AuthenticationResponse>;
4
+ export declare type BaseTransactionRequest = AuthenticationResponse & {
5
+ amount: string;
6
+ originAddress: string;
7
+ recipientAddress: string;
8
+ transactionType: TransactionType;
9
+ token: {
10
+ symbol: string;
11
+ chainName?: BlockchainName;
12
+ tokenStandard?: TokenStandard;
13
+ slip44?: BlockchainSlip44.ETH;
14
+ };
15
+ };
16
+ export type FeeEstimatesResponse = {
17
+ feePaymentSymbol: string;
18
+ fee: string;
19
+ lowestFee: string;
20
+ highestFee: string;
21
+ error?: any;
22
+ };
@@ -37,6 +37,18 @@ export declare class StorageService {
37
37
  checkBackupKeyShareExists(walletId: string): Promise<boolean>;
38
38
  checkSeedPhraseExists(walletId: string): Promise<boolean>;
39
39
  private getSeedPhraseV2KeyName;
40
+ /**
41
+ *
42
+ * Stores Wallaby auth public key to local storage
43
+ * @param wallabyAuthPubKey
44
+ */
45
+ setWallabyAuthPubKey(wallabyAuthPubKey: string): Promise<void>;
46
+ /**
47
+ *
48
+ * Fetches Wallaby auth public key from local storage
49
+ * @returns { string | undefined } Wallaby Auth Public key or undefined.
50
+ */
51
+ getWallabyAuthPubKey(): Promise<string | undefined>;
40
52
  /**
41
53
  * @deprecated This function is only used in tests, and should not be used anywhere else.
42
54
  * Encrypts and stores device auth private key
@@ -35,7 +35,7 @@ export declare class WalletDataService extends Base {
35
35
  * Note: Either chainName or tokenStandard must be provided.
36
36
  * @returns { FetchBalanceData } Returns an array of the requested tokens balances.
37
37
  */
38
- getMultiTokenBalances({ walletId, tokensAndAddressesList, }: {
38
+ getMultiTokenBalances({ walletId, tokensAndAddressesList }: {
39
39
  walletId?: string;
40
40
  tokensAndAddressesList: TokenBalanceRequest[];
41
41
  }): Promise<FetchBalanceData>;
@@ -1,5 +1,5 @@
1
1
  import { Base } from '../../base';
2
- import { ImportWalletRequest, CreateWalletRequest, Encrypted, WallabyConfig, ImportWalletResponse, RecoverWalletResponse } from '../../types';
2
+ import { ImportWalletRequest, CreateWalletRequest, Encrypted, WallabyConfig, AsymmetricKeyPair, ImportWalletResponse, RecoverWalletResponse } from '../../types';
3
3
  import { KeyShareDto } from '../../generated/api';
4
4
  export declare class WalletHandlersService extends Base {
5
5
  private authService;
@@ -58,4 +58,19 @@ export declare class WalletHandlersService extends Base {
58
58
  privateKey: string;
59
59
  };
60
60
  }): Promise<RecoverWalletResponse>;
61
+ /**
62
+ *
63
+ * @param encryptedKeyShares - Encrypted key shares that are encrypted with the wallabyAuthPublicKey.
64
+ * @param walletId - The ID of the wallet for which the seed phrase is being constructed.
65
+ * @param deviceAuthKeys - The device authentication key pair used to sign the request.
66
+ * @description This function constructs the seed phrase from encrypted key shares.
67
+ * It retrieves the seed phrase by sending a request to the Wallaby API with the encrypted key shares.
68
+ * The shares should be encrypted with the wallabyAuthPublicKey before passing them into this function.
69
+ * @returns The function returns the encrypted seed phrase wrapped with client device public key.
70
+ */
71
+ handleConstructingSeedPhraseFromShares({ encryptedKeyShares, walletId, deviceAuthKeys, }: {
72
+ encryptedKeyShares: Encrypted[];
73
+ walletId: string;
74
+ deviceAuthKeys: AsymmetricKeyPair;
75
+ }): Promise<Encrypted>;
61
76
  }
@@ -95,9 +95,6 @@ export declare class WalletService extends Base {
95
95
  *
96
96
  * @param { RecoverWalletRequest } input - The request object containing the necessary parameters.
97
97
  * @returns { Promise<RecoverWalletResponse> } The response containing the recovered wallet details.
98
- *
99
- * @deprecated This function is deprecated and will be removed in the next major release. It only supports seed phrase recovery.
100
- * Use `import` instead with the `RETURN_ONLY_ENCRYPTED_SEED_PHRASE` option to maintain the same behavior.
101
98
  */
102
99
  recover(input: RecoverWalletRequest): Promise<RecoverWalletResponse>;
103
100
  /**
@@ -196,9 +193,7 @@ export declare class WalletService extends Base {
196
193
  }): Promise<{
197
194
  isAccessVerified: boolean;
198
195
  }>;
199
- clearDevice({ walletId }: {
200
- walletId?: string;
201
- }): Promise<void>;
196
+ clearDevice(): Promise<void>;
202
197
  /**
203
198
  * Prepares authentication data and encrypted payload for any request.
204
199
  */
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wallaby-cash",
3
- "version": "2.3.7",
3
+ "version": "2.3.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:WALLABY-WaaS/wallaby-sdk-js.git"
@@ -72,7 +72,6 @@
72
72
  "@size-limit/preset-small-lib": "^11.2.0",
73
73
  "@types/crypto-js": "^4.2.2",
74
74
  "@types/jest": "^29.5.0",
75
- "@types/lodash": "^4.17.16",
76
75
  "@types/node-fetch": "^2.6.13",
77
76
  "@types/qrcode": "^1.5.5",
78
77
  "@types/uuid": "^10.0.0",
@@ -124,12 +123,15 @@
124
123
  }
125
124
  },
126
125
  "overrides": {
126
+ "lodash": "^4.18.0",
127
127
  "@tootallnate/once": "^3.0.1",
128
128
  "markdown-it": "^14.1.1",
129
+ "defu": "^6.1.5",
129
130
  "diff": "^5.2.2",
130
131
  "tar": "^7.5.10",
131
- "lodash": "^4.17.23",
132
- "lodash-es": "^4.17.23",
132
+ "jsdom": {
133
+ "ws": "^8.20.1"
134
+ },
133
135
  "undici": "^7.19.0",
134
136
  "js-yaml": "^4.1.1",
135
137
  "pbkdf2": "^3.1.3",
@@ -1,4 +1,4 @@
1
- import { User, Base64URLString, AsymmetricKeyPair } from './common';
1
+ import { User, Base64URLString } from './common';
2
2
  /**
3
3
  * Local WebAuthn type definitions (duplicated from @simplewebauthn/browser to avoid dependency)
4
4
  * These match the WebAuthn specification and @simplewebauthn/browser types
@@ -158,7 +158,7 @@ export interface AuthenticationExtensionsClientOutputs {
158
158
  export interface RegistrationResponseJSON {
159
159
  id: Base64URLString;
160
160
  rawId: Base64URLString;
161
- response: AuthenticatorAttestationResponseJSON | Record<string, unknown>;
161
+ response: AuthenticatorAttestationResponseJSON;
162
162
  authenticatorAttachment?: AuthenticatorAttachment;
163
163
  clientExtensionResults: AuthenticationExtensionsClientOutputs;
164
164
  type: PublicKeyCredentialType;
@@ -207,7 +207,7 @@ export interface PublicKeyCredentialCreationOptionsJSON {
207
207
  export interface AuthenticationResponseJSON {
208
208
  id: Base64URLString;
209
209
  rawId: Base64URLString;
210
- response: AuthenticatorAssertionResponseJSON | Record<string, unknown>;
210
+ response: AuthenticatorAssertionResponseJSON;
211
211
  authenticatorAttachment?: AuthenticatorAttachment;
212
212
  clientExtensionResults: AuthenticationExtensionsClientOutputs;
213
213
  type: PublicKeyCredentialType;
@@ -232,7 +232,6 @@ export declare type SignatureMessageResponse = {
232
232
  hashedMessage: string;
233
233
  signature: string;
234
234
  challenge: Base64URLString;
235
- wallabyAuthPubKey: string;
236
235
  authenticationOptions?: PublicKeyCredentialRequestOptionsJSON;
237
236
  registrationOptions?: PublicKeyCredentialCreationOptionsJSON;
238
237
  };
@@ -287,11 +286,6 @@ export declare enum PasskeyChallengeType {
287
286
  REGISTRATION = "webauthn.create",
288
287
  AUTHENTICATION = "webauthn.get"
289
288
  }
290
- export type GetSignatureOptions = {
291
- deviceAuthKeys: AsymmetricKeyPair;
292
- walletId?: string;
293
- passkeyChallengeType?: PasskeyChallengeType;
294
- };
295
289
  export interface PRFExtension {
296
290
  prf?: {
297
291
  eval?: {
@@ -341,7 +335,11 @@ export declare type SignInRequest = {
341
335
  displayName?: string;
342
336
  };
343
337
  export declare type AuthenticationRequest = {
338
+ nickname?: string;
339
+ displayName?: string;
344
340
  password?: string;
341
+ prfValue?: Uint8Array;
342
+ clientSalt?: string;
345
343
  };
346
344
  export declare type AuthResponseData = {
347
345
  accessToken: string;
@@ -24,6 +24,7 @@ export declare enum LocalStorageItems {
24
24
  EncryptedAlgorandSeedPhrase = "encrypted-algorand-seedPhrase",
25
25
  EncryptedDevicePrivateKey = "encrypted-private-key",
26
26
  ClientAuthPublicKey = "client-auth-pub-key",
27
+ WallabyAuthPubKey = "wallaby-auth-pub-key",
27
28
  ClientAuthToken = "republic-jwt",
28
29
  PasskeyCredential = "pass-key-credential",
29
30
  Blob = "blob"
@@ -1,14 +1,19 @@
1
1
  import { AuthenticationResponse } from './auth';
2
2
  import { PaginationInterface } from './common';
3
3
  /**
4
- * Request to get a swap quote
4
+ * Request to get a swap quote.
5
+ *
6
+ * Exactly one of `fromAmount` or `toAmount` must be provided.
5
7
  */
6
- export declare type SwapQuoteRequest = {
8
+ export type SwapQuoteRequest = {
7
9
  walletId: string;
8
- fromAsset: string;
9
- toAsset: string;
10
+ /** UUID of the source asset config */
11
+ fromAssetConfigId: string;
12
+ /** UUID of the destination asset config */
13
+ toAssetConfigId: string;
10
14
  fromAmount?: string;
11
15
  toAmount?: string;
16
+ slippage?: number;
12
17
  };
13
18
  /**
14
19
  * Response from swap quote endpoint
@@ -64,16 +64,13 @@ export declare enum MultisigParticipantStatus {
64
64
  Rejected = "rejected"
65
65
  }
66
66
  export declare type FeeEstimateRequest = {
67
- amount: string;
68
67
  originAddress: string;
69
68
  recipientAddress: string;
69
+ amount: number;
70
+ assetSymbol: string;
70
71
  transactionType: TransactionType;
71
- token: {
72
- symbol: string;
73
- chainName?: BlockchainName;
74
- tokenStandard?: TokenStandard;
75
- slip44?: BlockchainSlip44;
76
- };
72
+ tokenStandard?: TokenStandard;
73
+ blockchain?: BlockchainName;
77
74
  };
78
75
  export declare type FeeEstimatesResponse = {
79
76
  feePaymentSymbol: string;
@@ -175,10 +175,8 @@ export declare type CommonWalletRequest = {
175
175
  };
176
176
  export declare type ImportWalletRequest = CommonWalletRequest & {
177
177
  seedPhrase: string;
178
- reference?: string;
179
- wallabyUserId?: string;
180
- /** When set (e.g. re-import while a wallet id is already known), forwarded to `getSignature` so the server can scope the ephemeral key to this wallet. */
181
178
  walletId?: string;
179
+ wallabyUserId?: string;
182
180
  };
183
181
  export declare type ImportWalletResponse = {
184
182
  wallabyAuthPubKey: string;
@@ -194,6 +192,9 @@ export declare type Wallet = {
194
192
  merchantId: string;
195
193
  revisionId: string;
196
194
  revisionName: string;
195
+ evmAddress: string;
196
+ btcAddress: string;
197
+ algoAddress: string;
197
198
  hashedSeedPhrase: string;
198
199
  hashedSeedPhraseSalt: string;
199
200
  recoveryCount: number;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wallaby-cash",
3
- "version": "2.3.7",
3
+ "version": "2.3.9",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git@github.com:WALLABY-WaaS/wallaby-sdk-js.git"
@@ -72,7 +72,6 @@
72
72
  "@size-limit/preset-small-lib": "^11.2.0",
73
73
  "@types/crypto-js": "^4.2.2",
74
74
  "@types/jest": "^29.5.0",
75
- "@types/lodash": "^4.17.16",
76
75
  "@types/node-fetch": "^2.6.13",
77
76
  "@types/qrcode": "^1.5.5",
78
77
  "@types/uuid": "^10.0.0",
@@ -124,12 +123,15 @@
124
123
  }
125
124
  },
126
125
  "overrides": {
126
+ "lodash": "^4.18.0",
127
127
  "@tootallnate/once": "^3.0.1",
128
128
  "markdown-it": "^14.1.1",
129
+ "defu": "^6.1.5",
129
130
  "diff": "^5.2.2",
130
131
  "tar": "^7.5.10",
131
- "lodash": "^4.17.23",
132
- "lodash-es": "^4.17.23",
132
+ "jsdom": {
133
+ "ws": "^8.20.1"
134
+ },
133
135
  "undici": "^7.19.0",
134
136
  "js-yaml": "^4.1.1",
135
137
  "pbkdf2": "^3.1.3",