wallaby-cash 3.3.0 → 3.4.0

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.
@@ -1,6 +1,6 @@
1
1
  import { Base } from '../../base';
2
2
  import { SignatureMessageResponse, WallabyConfig, AuthenticationResponse, AsymmetricKeyPair, GetSignatureOptions, AuthenticationRequest } from '../../types';
3
- import { GetPasskeyCredentialsData } from '../../generated/api';
3
+ import { GetPasskeyCredentialsData, IssueJWTTokenResponseDto } from '../../generated/api';
4
4
  export declare class AuthService extends Base {
5
5
  private passkeyService;
6
6
  constructor(config: WallabyConfig);
@@ -94,4 +94,11 @@ export declare class AuthService extends Base {
94
94
  valid: boolean;
95
95
  message?: string;
96
96
  }>;
97
+ /**
98
+ * @description Exchanges the client JWT (set at SDK initialisation) for a
99
+ * Wallaby access + refresh token pair. Tokens are persisted to storage so
100
+ * subsequent SDK calls use them automatically.
101
+ * @returns {Promise<IssueJWTTokenResponseDto>} The issued access/refresh tokens and basic user info.
102
+ */
103
+ exchangeClientToken(): Promise<IssueJWTTokenResponseDto>;
97
104
  }
@@ -1,6 +1,5 @@
1
1
  export * from './wallet';
2
2
  export * from './auth';
3
3
  export * from './utils';
4
- export * from './merchants';
5
4
  export * from './api';
6
5
  export * from './swap';
@@ -39,6 +39,9 @@ export declare class System extends Base {
39
39
  * @param {BlockchainName} blockchain - The name of the blockchain.
40
40
  * @param {string} contractAddress - The contract address of the token (optional for non-SUI blockchains).
41
41
  * @param {string} suiObjectId - The SUI object ID of the token (optional for SUI blockchain).
42
+ * @param {string} assetSymbol - The asset symbol; disambiguates new SUI assets. For SUI it is
43
+ * optional: when omitted, it is derived from the `::module::TYPE` suffix of `suiObjectId`
44
+ * (which is otherwise trimmed off before the request is sent).
42
45
  *
43
46
  * @returns {Promise<{ decimals: number; symbol: string; name: string; tokenContractAddress: string }>} A promise that resolves to an object containing token information.
44
47
  *
@@ -47,10 +50,11 @@ export declare class System extends Base {
47
50
  * @throws Will throw an error if `contractAddress` is not provided for non-SUI blockchains.
48
51
  * @throws Will throw an error if the response is invalid or contains an error.
49
52
  */
50
- fetchTokenInfo({ blockchain, contractAddress, suiObjectId, }: {
53
+ fetchTokenInfo({ blockchain, contractAddress, suiObjectId, assetSymbol, }: {
51
54
  blockchain: BlockchainName;
52
55
  contractAddress?: string;
53
56
  suiObjectId?: string;
57
+ assetSymbol?: string;
54
58
  }): Promise<{
55
59
  decimals: number;
56
60
  symbol: string;
@@ -27,6 +27,12 @@ export declare class Cipher {
27
27
  encryptWithMasterKey({ data }: {
28
28
  data: string | object;
29
29
  }): string;
30
+ /**
31
+ * @description Determines deterministically whether a stored value was wrapped by the master key,
32
+ * without inferring from decrypt behavior. Returns true for values carrying the version marker, or
33
+ * legacy crypto-js ciphertext stored before the marker existed. Everything else is treated as raw.
34
+ */
35
+ isWrappedByMasterKey(value: string): boolean;
30
36
  decryptWithMasterKey<T>({ cipherText }: {
31
37
  cipherText: string;
32
38
  }): string | T | undefined;
@@ -0,0 +1,12 @@
1
+ /**
2
+ * Extracts the asset symbol from a fully-qualified Sui coin type.
3
+ *
4
+ * A Sui coin type has the shape `<package>::<module>::<TYPE>`, where the final
5
+ * segment is the coin's struct name and doubles as its symbol.
6
+ *
7
+ * @param objectId - The Sui object id / coin type. Example input:
8
+ * "0xc91acfb75009c5ff2fd57c54f3caaee12ad1fbe997681334adc0b574fc277a07::icorgi::ICORGI"
9
+ * @returns The symbol (e.g. "ICORGI"), or undefined when the id carries no
10
+ * `::module::TYPE` suffix to derive it from.
11
+ */
12
+ export declare const extractSuiAssetSymbol: (objectId?: string) => string | undefined;
@@ -6,6 +6,7 @@ export declare class StorageService {
6
6
  private userId;
7
7
  private cipher;
8
8
  private deviceLocalStorage;
9
+ private _walRecovery?;
9
10
  constructor({ deviceStorage, userId, environment }: {
10
11
  deviceStorage: LocalStorage;
11
12
  userId: string;
@@ -26,6 +27,18 @@ export declare class StorageService {
26
27
  value: any;
27
28
  walletId?: string;
28
29
  }[]): Promise<void>;
30
+ private _computeRawKey;
31
+ private _serializeValue;
32
+ private _applyWAL;
33
+ commitBatch(writes: {
34
+ key: LocalStorageItems | V2KeyNames;
35
+ value: any;
36
+ walletId?: string;
37
+ }[], deletes?: {
38
+ key: LocalStorageItems | V2KeyNames;
39
+ walletId?: string;
40
+ }[]): Promise<void>;
41
+ recoverCommit(): Promise<void>;
29
42
  delete(key: LocalStorageItems | V2KeyNames | V1KeyNames | LegacyKeyNames, options?: {
30
43
  walletId?: string;
31
44
  }): Promise<void>;
@@ -35,7 +35,23 @@ export declare class WalletHandlersService extends Base {
35
35
  walletAddressesInfo: import("../../types").WalletAddressesInfoEntry[];
36
36
  error?: any;
37
37
  }>;
38
- handleKeySharesFromResponse({ walletId, shares, credentialsKeyPair, encryptedBackupShare, }: {
38
+ /**
39
+ * Encrypted share format contract (WAL-1467)
40
+ * --------------------------------------------------------------------------
41
+ * Every flow that ingests shares from the API (import, create, recover,
42
+ * addNewDevice) routes through here, so the contract is asserted in one place.
43
+ *
44
+ * The API returns the main device share as `shares[0]`, an ECIES payload
45
+ * ({ iv, ephemPublicKey, ciphertext, mac }) wrapped to the device public key,
46
+ * so it MUST peel with the device private key. `encryptedBackupShare` is an
47
+ * already-wrapped blob (ECIES or symmetric) that the device cannot decrypt, so
48
+ * it is stored as-is.
49
+ *
50
+ * We shape-assert every share (and the backup share) here, at ingestion, so a
51
+ * server-side wrapping change fails loudly now instead of silently breaking
52
+ * export/recovery later.
53
+ */
54
+ handleKeySharesFromResponse({ walletId, shares, credentialsKeyPair, encryptedBackupShare, devicePrivateKey, }: {
39
55
  walletId: string;
40
56
  shares: KeyShareDto[];
41
57
  credentialsKeyPair: {
@@ -43,6 +59,7 @@ export declare class WalletHandlersService extends Base {
43
59
  privateKey: string;
44
60
  };
45
61
  encryptedBackupShare: Encrypted | SymmetricEncrypted;
62
+ devicePrivateKey: string;
46
63
  }): Promise<Encrypted[]>;
47
64
  handleSeedPhraseFromResponse({ walletId, encryptedSeed, devicePrivateKey, credentialsKeyPair, storeSeedPhrase, }: {
48
65
  walletId: string;
@@ -4,9 +4,18 @@ export declare class WalletService extends Base {
4
4
  private authService;
5
5
  private handlers;
6
6
  private passkeyService;
7
- private passwordResetAttempts;
8
- private migrationAttempts;
7
+ private static readonly RATE_LIMIT_MAX;
8
+ private static readonly RATE_LIMIT_WINDOW_MS;
9
9
  constructor(config: WallabyConfig);
10
+ /**
11
+ * Reads the persisted sliding-window rate-limit state for a counter key.
12
+ * Returns a fresh window ({ count: 0 }) when none is stored or the window has expired.
13
+ */
14
+ private getRateState;
15
+ /** Increments and persists the counter (resetting an expired window). Returns the new count. */
16
+ private recordRateAttempt;
17
+ /** Throws a 429 when the counter is already over the limit, without incrementing it. */
18
+ private assertUnderRateLimit;
10
19
  /**
11
20
  * @public
12
21
  * @returns {boolean} Returns true if the device has a seed phrase.
@@ -155,6 +164,14 @@ export declare class WalletService extends Base {
155
164
  authenticationOptions: AuthenticationResponse;
156
165
  blockchainName?: BlockchainName;
157
166
  }): Promise<GenerateMissingAddressResponseDto>;
167
+ /**
168
+ * Wraps handleUpdateToV2 with the standard user-facing error. All call sites that gate on
169
+ * `AuthType.Password` should go through here so the error message stays consistent.
170
+ */
171
+ migrateToV2Safe({ password, walletId }: {
172
+ password: string;
173
+ walletId: string;
174
+ }): Promise<void>;
158
175
  /**
159
176
  * Detects and migrates legacy/v1 storage items to v2 format.
160
177
  * This function should be called in methods that use password as input when v2 items are missing.
@@ -210,4 +227,5 @@ export declare class WalletService extends Base {
210
227
  authentication: AuthenticationResponse;
211
228
  seedPhrase: string;
212
229
  }>;
230
+ private assertRoundTrip;
213
231
  }
package/dist/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wallaby-cash",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/WALLABY-WaaS/wallaby-sdk-js"
@@ -127,6 +127,7 @@
127
127
  }
128
128
  },
129
129
  "overrides": {
130
+ "sigstore": "^4.1.1",
130
131
  "@babel/core": "^7.29.6",
131
132
  "lodash": "^4.18.0",
132
133
  "@tootallnate/once": "^3.0.1",
@@ -40,4 +40,9 @@ export declare const AuthRoutes: {
40
40
  method: RequestMethod;
41
41
  requiresAccessToken: boolean;
42
42
  };
43
+ issueJwtToken: {
44
+ fullPath: string;
45
+ method: RequestMethod;
46
+ requiresAccessToken: boolean;
47
+ };
43
48
  };
@@ -58,5 +58,9 @@ export declare enum V2KeyNames {
58
58
  PrimaryDeviceKeyShare = "primary-device-key-share",
59
59
  WallabyAuthPubKey = "wallaby-auth-pub-key",
60
60
  MigrationVersion = "wsdk_migrated_with_version",
61
- LastMigratedAt = "wsdk_last_migrated_at"
61
+ LastMigratedAt = "wsdk_last_migrated_at",
62
+ PasswordResetAttempts = "wsdk_password_reset_attempts",
63
+ MigrationAttempts = "wsdk_migration_attempts",
64
+ CredentialConversionInProgress = "credential-conversion-in-progress",
65
+ PendingCommit = "pending-commit"
62
66
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "wallaby-cash",
3
- "version": "3.3.0",
3
+ "version": "3.4.0",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "https://github.com/WALLABY-WaaS/wallaby-sdk-js"
@@ -127,6 +127,7 @@
127
127
  }
128
128
  },
129
129
  "overrides": {
130
+ "sigstore": "^4.1.1",
130
131
  "@babel/core": "^7.29.6",
131
132
  "lodash": "^4.18.0",
132
133
  "@tootallnate/once": "^3.0.1",
@@ -1,59 +0,0 @@
1
- import { Base } from '../../base';
2
- import { WallabyConfig } from '../../types';
3
- import { ListMerchantsResponse, Merchant, MerchantAsset, MerchantStatus } from '../../types/merchants';
4
- export declare class Merchants extends Base {
5
- constructor(config: WallabyConfig);
6
- /**
7
- * @description
8
- * Retrieves the merchant ID from access token `aud` claim.
9
- * Even though merchantId is possibly undefined. If an access token is not stored on device, the request will most likely
10
- * not have it in headers and will fail with 401 regardless.
11
- *
12
- * @returns { string | undefined } Merchant ID
13
- */
14
- private _getMerchantId;
15
- /**
16
- *
17
- * @public
18
- * List of all merchants in the system
19
- * @returns { ListMerchantsResponse } Array of all merchants
20
- */
21
- list(): Promise<ListMerchantsResponse>;
22
- /**
23
- *
24
- * @public
25
- * Allows to create a new merchant
26
- * @returns { Merchant } Merchant data
27
- */
28
- create({ name }: {
29
- name: string;
30
- }): Promise<Merchant>;
31
- /**
32
- *
33
- * @public
34
- * Allows to update merchant data
35
- * @returns { Merchant } Merchant data
36
- */
37
- update({ name, status }: {
38
- name?: string;
39
- status?: MerchantStatus;
40
- }): Promise<Merchant>;
41
- /**
42
- *
43
- * @public
44
- * @returns { Merchant } Merchant data
45
- */
46
- getMerchantData(): Promise<Merchant>;
47
- /**
48
- *
49
- * @public
50
- * @returns { MerchantAsset[] } List of merchant assets
51
- */
52
- getAssets(): Promise<MerchantAsset[]>;
53
- addAsset({ configId }: {
54
- configId: string;
55
- }): Promise<unknown>;
56
- deleteAsset({ configId }: {
57
- configId: string;
58
- }): Promise<unknown>;
59
- }
@@ -1,48 +0,0 @@
1
- import { RequestMethod } from '../types';
2
- export declare const MerchantsRoutes: {
3
- create: {
4
- fullPath: string;
5
- method: RequestMethod;
6
- requiresAccessToken: boolean;
7
- };
8
- update: {
9
- fullPath: ({ merchantId }: {
10
- merchantId: string;
11
- }) => string;
12
- method: RequestMethod;
13
- requiresAccessToken: boolean;
14
- };
15
- getMerchantData: {
16
- fullPath: ({ merchantId }: {
17
- merchantId: string;
18
- }) => string;
19
- method: RequestMethod;
20
- requiresAccessToken: boolean;
21
- };
22
- list: {
23
- fullPath: string;
24
- method: RequestMethod;
25
- requiresAccessToken: boolean;
26
- };
27
- getAssets: {
28
- fullPath: () => string;
29
- method: RequestMethod;
30
- requiresAccessToken: boolean;
31
- };
32
- addAsset: {
33
- fullPath: ({ merchantId, configId }: {
34
- merchantId: string;
35
- configId: string;
36
- }) => string;
37
- method: RequestMethod;
38
- requiresAccessToken: boolean;
39
- };
40
- deleteAsset: {
41
- fullPath: ({ merchantId, configId }: {
42
- merchantId: string;
43
- configId: string;
44
- }) => string;
45
- method: RequestMethod;
46
- requiresAccessToken: boolean;
47
- };
48
- };