cilantro-sdk 0.0.9 → 0.0.11
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/README.md +73 -1
- package/dist/api/wallets/wallets.d.ts +3 -1
- package/dist/api/wallets/wallets.d.ts.map +1 -1
- package/dist/helpers.cjs +271 -81
- package/dist/helpers.cjs.map +4 -4
- package/dist/helpers.d.ts +1 -0
- package/dist/helpers.d.ts.map +1 -1
- package/dist/helpers.mjs +267 -81
- package/dist/helpers.mjs.map +4 -4
- package/dist/index.cjs +271 -81
- package/dist/index.cjs.map +4 -4
- package/dist/index.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.mjs +270 -81
- package/dist/index.mjs.map +4 -4
- package/dist/models/index.d.ts +1 -0
- package/dist/models/index.d.ts.map +1 -1
- package/dist/models/updateDeviceIdentityDto.d.ts +18 -0
- package/dist/models/updateDeviceIdentityDto.d.ts.map +1 -0
- package/dist/signers/deviceIdentityHelpers.d.ts +108 -0
- package/dist/signers/deviceIdentityHelpers.d.ts.map +1 -0
- package/dist/signers/index.d.ts +1 -0
- package/dist/signers/index.d.ts.map +1 -1
- package/dist/utils/storage/adapters.d.ts.map +1 -1
- package/dist/wallet.cjs +16 -1
- package/dist/wallet.cjs.map +3 -3
- package/dist/wallet.d.ts +3 -2
- package/dist/wallet.d.ts.map +1 -1
- package/dist/wallet.mjs +15 -1
- package/dist/wallet.mjs.map +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -85,7 +85,48 @@ const result = await sendSOL('wallet-id', { ... });
|
|
|
85
85
|
|
|
86
86
|
## Helpers Module (Device Keys & Signer Management)
|
|
87
87
|
|
|
88
|
-
The SDK includes a comprehensive helpers module for device key management and signer operations with automatic caching, validation, and
|
|
88
|
+
The SDK includes a comprehensive helpers module for device key management and signer operations with automatic caching, validation, key resolution, and multi-device support. This simplifies working with email/phone signers and eliminates manual key management.
|
|
89
|
+
|
|
90
|
+
### What Happens When a User Changes Devices?
|
|
91
|
+
|
|
92
|
+
**Scenario:** User creates an email signer on Device A, then switches to Device B.
|
|
93
|
+
|
|
94
|
+
**On Device A (Initial Setup):**
|
|
95
|
+
1. User creates email signer → Device A generates device key pair
|
|
96
|
+
2. Public key sent to API → stored in `deviceIdentities[0]`
|
|
97
|
+
3. Private key stored locally on Device A
|
|
98
|
+
4. ✅ **Device A can sign**
|
|
99
|
+
|
|
100
|
+
**On Device B (New Device - Before Adding Device Identity):**
|
|
101
|
+
1. User tries to sign → `getEmailSignerKeypair()` is called
|
|
102
|
+
2. SDK searches Device B's storage for device key
|
|
103
|
+
3. **Not found** → Throws `DeviceKeyNotFoundError`
|
|
104
|
+
4. ❌ **Cannot sign** - Device B doesn't have Device A's private key
|
|
105
|
+
|
|
106
|
+
**Solution: Add Device B as a New Device Identity**
|
|
107
|
+
```typescript
|
|
108
|
+
// On Device B - add new device identity
|
|
109
|
+
const newDevice = await addNewDeviceToSigner(
|
|
110
|
+
'wallet-id',
|
|
111
|
+
'signer-id',
|
|
112
|
+
{ deviceKeyManager: storage }
|
|
113
|
+
);
|
|
114
|
+
|
|
115
|
+
// Now Device B can sign
|
|
116
|
+
const keypair = await getEmailSignerKeypair(
|
|
117
|
+
'wallet-id',
|
|
118
|
+
'signer-id',
|
|
119
|
+
{
|
|
120
|
+
devicePublicKey: newDevice.devicePublicKey,
|
|
121
|
+
deviceKeyManager: storage
|
|
122
|
+
}
|
|
123
|
+
);
|
|
124
|
+
```
|
|
125
|
+
|
|
126
|
+
**Result:**
|
|
127
|
+
- ✅ User can sign from both Device A and Device B (multi-device support)
|
|
128
|
+
- ✅ Each device has its own device identity
|
|
129
|
+
- ✅ No need to transfer private keys between devices
|
|
89
130
|
|
|
90
131
|
### Quick Example
|
|
91
132
|
|
|
@@ -146,6 +187,12 @@ const keypair = await getEmailSignerKeypair(
|
|
|
146
187
|
- `getBestDeviceIdentity()` - Get best device to use (most recent)
|
|
147
188
|
- `findAndValidateDeviceKey()` - Find and validate device key in one call
|
|
148
189
|
|
|
190
|
+
**Device Identity Management (NEW in v0.0.9):**
|
|
191
|
+
- `addDeviceIdentityToSigner()` - Add new device identity to existing signer
|
|
192
|
+
- `replaceDeviceIdentity()` - Replace existing device identity
|
|
193
|
+
- `addNewDeviceToSigner()` - Convenience function for device changes
|
|
194
|
+
- `canAddDeviceToSigner()` - Check if device can be added
|
|
195
|
+
|
|
149
196
|
**Email Signer Helpers:**
|
|
150
197
|
- `createEmailSignerHelper()` - Create email signer with auto key management
|
|
151
198
|
- `getEmailSignerKeypair()` - Get keypair with automatic resolution and validation
|
|
@@ -259,6 +306,31 @@ const apiDeviceKeys = await getSignerDeviceKeys('wallet-id', 'signer-id');
|
|
|
259
306
|
const storedKeys = await listAllDeviceKeys(storage);
|
|
260
307
|
```
|
|
261
308
|
|
|
309
|
+
**Example 4: Add New Device (Device Change)**
|
|
310
|
+
```typescript
|
|
311
|
+
import { addNewDeviceToSigner, getEmailSignerKeypair } from 'cilantro-sdk/helpers';
|
|
312
|
+
|
|
313
|
+
// On new device - add device identity
|
|
314
|
+
const newDevice = await addNewDeviceToSigner(
|
|
315
|
+
'wallet-id',
|
|
316
|
+
'signer-id',
|
|
317
|
+
{
|
|
318
|
+
deviceKeyManager: storage,
|
|
319
|
+
deviceFingerprint: 'New Device'
|
|
320
|
+
}
|
|
321
|
+
);
|
|
322
|
+
|
|
323
|
+
// Now can sign from new device
|
|
324
|
+
const keypair = await getEmailSignerKeypair(
|
|
325
|
+
'wallet-id',
|
|
326
|
+
'signer-id',
|
|
327
|
+
{
|
|
328
|
+
devicePublicKey: newDevice.devicePublicKey,
|
|
329
|
+
deviceKeyManager: storage
|
|
330
|
+
}
|
|
331
|
+
);
|
|
332
|
+
```
|
|
333
|
+
|
|
262
334
|
For complete documentation, see [DEVICE_KEY_MANAGEMENT.md](./DEVICE_KEY_MANAGEMENT.md).
|
|
263
335
|
|
|
264
336
|
## Configuration
|
|
@@ -5,7 +5,7 @@
|
|
|
5
5
|
* API documentation for GUAC Smart API v2 - A Solana wallet management system
|
|
6
6
|
* OpenAPI spec version: 2.0
|
|
7
7
|
*/
|
|
8
|
-
import type { AddSignerDto, BatchCreateWalletDto, BatchSendSolDto, BatchSendSplDto, CreateApiKeySignerDto, CreateEmailSignerDto, CreateExternalWalletSignerDto, CreatePhoneSignerDto, CreateWalletDto, MintNftDto, MintNftSimpleDto, MintTokenDto, PasskeyAuthenticationDto, PasskeyRegistrationDto, SendSolDto, SendSplDto, SendTransactionDto, SimulateTransactionDto, UpdateAdminSignerDto, UpdateSignerDto, UpdateSignerPermissionsDto, UpdateWalletDto, WalletAssetResponseDto, WalletControllerFindAllParams, WalletControllerGetDeviceEncryptedSecretParams, WalletControllerGetWalletAssetsParams, WalletControllerMintNFT200, WalletControllerMintNFTSimple200, WalletControllerMintToken200, WalletControllerSendSOL200, WalletControllerSendSPL200, WalletControllerSendTransaction200 } from '../../models';
|
|
8
|
+
import type { AddSignerDto, BatchCreateWalletDto, BatchSendSolDto, BatchSendSplDto, CreateApiKeySignerDto, CreateEmailSignerDto, CreateExternalWalletSignerDto, CreatePhoneSignerDto, CreateWalletDto, MintNftDto, MintNftSimpleDto, MintTokenDto, PasskeyAuthenticationDto, PasskeyRegistrationDto, SendSolDto, SendSplDto, SendTransactionDto, SimulateTransactionDto, UpdateAdminSignerDto, UpdateDeviceIdentityDto, UpdateSignerDto, UpdateSignerPermissionsDto, UpdateWalletDto, WalletAssetResponseDto, WalletControllerFindAllParams, WalletControllerGetDeviceEncryptedSecretParams, WalletControllerGetWalletAssetsParams, WalletControllerMintNFT200, WalletControllerMintNFTSimple200, WalletControllerMintToken200, WalletControllerSendSOL200, WalletControllerSendSPL200, WalletControllerSendTransaction200 } from '../../models';
|
|
9
9
|
import { customInstance } from '../../api-client';
|
|
10
10
|
type SecondParameter<T extends (...args: never) => unknown> = Parameters<T>[1];
|
|
11
11
|
export declare const getWallets: () => {
|
|
@@ -43,6 +43,7 @@ export declare const getWallets: () => {
|
|
|
43
43
|
walletControllerUpdateSigner: (id: string, signerId: string, updateSignerDto: UpdateSignerDto, options?: SecondParameter<typeof customInstance<void>>) => Promise<void>;
|
|
44
44
|
walletControllerDeleteSigner: (id: string, signerId: string, options?: SecondParameter<typeof customInstance<void>>) => Promise<void>;
|
|
45
45
|
walletControllerGetDeviceEncryptedSecret: (id: string, signerId: string, params: WalletControllerGetDeviceEncryptedSecretParams, options?: SecondParameter<typeof customInstance<void>>) => Promise<void>;
|
|
46
|
+
walletControllerUpdateDeviceIdentity: (id: string, signerId: string, updateDeviceIdentityDto: UpdateDeviceIdentityDto, options?: SecondParameter<typeof customInstance<void>>) => Promise<void>;
|
|
46
47
|
walletControllerAddSigner: (id: string, addSignerDto: AddSignerDto, options?: SecondParameter<typeof customInstance<void>>) => Promise<void>;
|
|
47
48
|
walletControllerListSigners: (id: string, options?: SecondParameter<typeof customInstance<void>>) => Promise<void>;
|
|
48
49
|
walletControllerRemoveSigner: (id: string, pubkey: string, options?: SecondParameter<typeof customInstance<void>>) => Promise<void>;
|
|
@@ -83,6 +84,7 @@ export type WalletControllerGetSignerByIdResult = NonNullable<Awaited<ReturnType
|
|
|
83
84
|
export type WalletControllerUpdateSignerResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getWallets>['walletControllerUpdateSigner']>>>;
|
|
84
85
|
export type WalletControllerDeleteSignerResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getWallets>['walletControllerDeleteSigner']>>>;
|
|
85
86
|
export type WalletControllerGetDeviceEncryptedSecretResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getWallets>['walletControllerGetDeviceEncryptedSecret']>>>;
|
|
87
|
+
export type WalletControllerUpdateDeviceIdentityResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getWallets>['walletControllerUpdateDeviceIdentity']>>>;
|
|
86
88
|
export type WalletControllerAddSignerResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getWallets>['walletControllerAddSigner']>>>;
|
|
87
89
|
export type WalletControllerListSignersResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getWallets>['walletControllerListSigners']>>>;
|
|
88
90
|
export type WalletControllerRemoveSignerResult = NonNullable<Awaited<ReturnType<ReturnType<typeof getWallets>['walletControllerRemoveSigner']>>>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"wallets.d.ts","sourceRoot":"","sources":["../../../src/api/wallets/wallets.ts"],"names":[],"mappings":"AAAA;;;;;;GAMG;AACH,OAAO,KAAK,EACV,YAAY,EACZ,oBAAoB,EACpB,eAAe,EACf,eAAe,EACf,qBAAqB,EACrB,oBAAoB,EACpB,6BAA6B,EAC7B,oBAAoB,EACpB,eAAe,EACf,UAAU,EACV,gBAAgB,EAChB,YAAY,EACZ,wBAAwB,EACxB,sBAAsB,EACtB,UAAU,EACV,UAAU,EACV,kBAAkB,EAClB,sBAAsB,EACtB,oBAAoB,EACpB,eAAe,EACf,0BAA0B,EAC1B,eAAe,EACf,sBAAsB,EACtB,6BAA6B,EAC7B,8CAA8C,EAC9C,qCAAqC,EACrC,0BAA0B,EAC1B,gCAAgC,EAChC,4BAA4B,EAC5B,0BAA0B,EAC1B,0BAA0B,EAC1B,kCAAkC,EACnC,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,cAAc,EAAE,MAAM,kBAAkB,CAAC;AAGlD,KAAK,eAAe,CAAC,CAAC,SAAS,CAAC,GAAG,IAAI,EAAE,KAAK,KAAK,OAAO,IAAI,UAAU,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC;AAG7E,eAAO,MAAM,UAAU;8CAKJ,eAAe,YACzB,eAAe,CAAC,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;uCAY1C,6BAA6B,YAC/B,eAAe,CAAC,OAAO,cAAc,CAAC,IAAI,CAAC,CAAC;gDAY5C,eAAe,CAAC,OAAO,cAAc,CAAC,MAAM,CAAC,CAAC;kCAUjD,MAAM,YACH,eAAe,CAAC,OAAO,cAAc,CAAC,IAAI,CAAC,CA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,CAAA;AAChJ,MAAM,MAAM,8CAA8C,GAAG,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,0CAA0C,CAAC,CAAC,CAAC,CAAC,CAAA;AACxK,MAAM,MAAM,0CAA0C,GAAG,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,sCAAsC,CAAC,CAAC,CAAC,CAAC,CAAA;AAChK,MAAM,MAAM,+BAA+B,GAAG,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,2BAA2B,CAAC,CAAC,CAAC,CAAC,CAAA;AAC1I,MAAM,MAAM,iCAAiC,GAAG,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,6BAA6B,CAAC,CAAC,CAAC,CAAC,CAAA;AAC9I,MAAM,MAAM,kCAAkC,GAAG,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAAC,CAAA;AAChJ,MAAM,MAAM,6CAA6C,GAAG,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,yCAAyC,CAAC,CAAC,CAAC,CAAC,CAAA;AACtK,MAAM,MAAM,uCAAuC,GAAG,WAAW,CAAC,OAAO,CAAC,UAAU,CAAC,UAAU,CAAC,OAAO,UAAU,CAAC,CAAC,mCAAmC,CAAC,CAAC,CAAC,CAAC,CAAA"}
|
package/dist/helpers.cjs
CHANGED
|
@@ -634,6 +634,17 @@ var init_wallets = __esm({
|
|
|
634
634
|
options
|
|
635
635
|
);
|
|
636
636
|
};
|
|
637
|
+
const walletControllerUpdateDeviceIdentity2 = (id, signerId, updateDeviceIdentityDto, options) => {
|
|
638
|
+
return customInstance(
|
|
639
|
+
{
|
|
640
|
+
url: `/wallets/${id}/signers/${signerId}/device-identity`,
|
|
641
|
+
method: "PATCH",
|
|
642
|
+
headers: { "Content-Type": "application/json" },
|
|
643
|
+
data: updateDeviceIdentityDto
|
|
644
|
+
},
|
|
645
|
+
options
|
|
646
|
+
);
|
|
647
|
+
};
|
|
637
648
|
const walletControllerAddSigner2 = (id, addSignerDto, options) => {
|
|
638
649
|
return customInstance(
|
|
639
650
|
{
|
|
@@ -685,13 +696,13 @@ var init_wallets = __esm({
|
|
|
685
696
|
options
|
|
686
697
|
);
|
|
687
698
|
};
|
|
688
|
-
return { walletControllerCreate: walletControllerCreate2, walletControllerFindAll: walletControllerFindAll2, walletControllerGetTotalBalance: walletControllerGetTotalBalance2, walletControllerFindOne: walletControllerFindOne2, walletControllerUpdate: walletControllerUpdate2, walletControllerRemove: walletControllerRemove2, walletControllerFindByAddress: walletControllerFindByAddress2, walletControllerSendSOL: walletControllerSendSOL2, walletControllerSendSPL: walletControllerSendSPL2, walletControllerMintNFT: walletControllerMintNFT2, walletControllerMintNFTSimple: walletControllerMintNFTSimple2, walletControllerMintToken: walletControllerMintToken2, walletControllerSendTransaction: walletControllerSendTransaction2, walletControllerGetWalletAssets: walletControllerGetWalletAssets2, walletControllerSyncWalletAssets: walletControllerSyncWalletAssets2, walletControllerDeactivateWallet: walletControllerDeactivateWallet2, walletControllerActivateWallet: walletControllerActivateWallet2, walletControllerBatchCreateWallets: walletControllerBatchCreateWallets2, walletControllerBatchSendSOL: walletControllerBatchSendSOL2, walletControllerBatchSendSPL: walletControllerBatchSendSPL2, walletControllerSimulateTransaction: walletControllerSimulateTransaction2, walletControllerGetWalletCustodyInfo: walletControllerGetWalletCustodyInfo2, walletControllerCreateEmailSigner: walletControllerCreateEmailSigner2, walletControllerCreatePhoneSigner: walletControllerCreatePhoneSigner2, walletControllerStartPasskeyRegistration: walletControllerStartPasskeyRegistration2, walletControllerVerifyPasskeyRegistration: walletControllerVerifyPasskeyRegistration2, walletControllerStartPasskeyAuthentication: walletControllerStartPasskeyAuthentication2, walletControllerVerifyPasskeyAuthentication: walletControllerVerifyPasskeyAuthentication2, walletControllerCreateExternalWalletSigner: walletControllerCreateExternalWalletSigner2, walletControllerCreateApiKeySigner: walletControllerCreateApiKeySigner2, walletControllerGetSignerById: walletControllerGetSignerById2, walletControllerUpdateSigner: walletControllerUpdateSigner2, walletControllerDeleteSigner: walletControllerDeleteSigner2, walletControllerGetDeviceEncryptedSecret: walletControllerGetDeviceEncryptedSecret2, walletControllerAddSigner: walletControllerAddSigner2, walletControllerListSigners: walletControllerListSigners2, walletControllerRemoveSigner: walletControllerRemoveSigner2, walletControllerUpdateSignerPermissions: walletControllerUpdateSignerPermissions2, walletControllerUpdateAdminSigner: walletControllerUpdateAdminSigner2 };
|
|
699
|
+
return { walletControllerCreate: walletControllerCreate2, walletControllerFindAll: walletControllerFindAll2, walletControllerGetTotalBalance: walletControllerGetTotalBalance2, walletControllerFindOne: walletControllerFindOne2, walletControllerUpdate: walletControllerUpdate2, walletControllerRemove: walletControllerRemove2, walletControllerFindByAddress: walletControllerFindByAddress2, walletControllerSendSOL: walletControllerSendSOL2, walletControllerSendSPL: walletControllerSendSPL2, walletControllerMintNFT: walletControllerMintNFT2, walletControllerMintNFTSimple: walletControllerMintNFTSimple2, walletControllerMintToken: walletControllerMintToken2, walletControllerSendTransaction: walletControllerSendTransaction2, walletControllerGetWalletAssets: walletControllerGetWalletAssets2, walletControllerSyncWalletAssets: walletControllerSyncWalletAssets2, walletControllerDeactivateWallet: walletControllerDeactivateWallet2, walletControllerActivateWallet: walletControllerActivateWallet2, walletControllerBatchCreateWallets: walletControllerBatchCreateWallets2, walletControllerBatchSendSOL: walletControllerBatchSendSOL2, walletControllerBatchSendSPL: walletControllerBatchSendSPL2, walletControllerSimulateTransaction: walletControllerSimulateTransaction2, walletControllerGetWalletCustodyInfo: walletControllerGetWalletCustodyInfo2, walletControllerCreateEmailSigner: walletControllerCreateEmailSigner2, walletControllerCreatePhoneSigner: walletControllerCreatePhoneSigner2, walletControllerStartPasskeyRegistration: walletControllerStartPasskeyRegistration2, walletControllerVerifyPasskeyRegistration: walletControllerVerifyPasskeyRegistration2, walletControllerStartPasskeyAuthentication: walletControllerStartPasskeyAuthentication2, walletControllerVerifyPasskeyAuthentication: walletControllerVerifyPasskeyAuthentication2, walletControllerCreateExternalWalletSigner: walletControllerCreateExternalWalletSigner2, walletControllerCreateApiKeySigner: walletControllerCreateApiKeySigner2, walletControllerGetSignerById: walletControllerGetSignerById2, walletControllerUpdateSigner: walletControllerUpdateSigner2, walletControllerDeleteSigner: walletControllerDeleteSigner2, walletControllerGetDeviceEncryptedSecret: walletControllerGetDeviceEncryptedSecret2, walletControllerUpdateDeviceIdentity: walletControllerUpdateDeviceIdentity2, walletControllerAddSigner: walletControllerAddSigner2, walletControllerListSigners: walletControllerListSigners2, walletControllerRemoveSigner: walletControllerRemoveSigner2, walletControllerUpdateSignerPermissions: walletControllerUpdateSignerPermissions2, walletControllerUpdateAdminSigner: walletControllerUpdateAdminSigner2 };
|
|
689
700
|
};
|
|
690
701
|
}
|
|
691
702
|
});
|
|
692
703
|
|
|
693
704
|
// src/wallet.ts
|
|
694
|
-
var walletControllerCreate, walletControllerFindAll, walletControllerGetTotalBalance, walletControllerFindOne, walletControllerUpdate, walletControllerRemove, walletControllerFindByAddress, walletControllerSendSOL, walletControllerSendSPL, walletControllerMintNFT, walletControllerMintNFTSimple, walletControllerMintToken, walletControllerSendTransaction, walletControllerGetWalletAssets, walletControllerSyncWalletAssets, walletControllerDeactivateWallet, walletControllerActivateWallet, walletControllerBatchCreateWallets, walletControllerBatchSendSOL, walletControllerBatchSendSPL, walletControllerSimulateTransaction, walletControllerGetWalletCustodyInfo, walletControllerCreateEmailSigner, walletControllerCreatePhoneSigner, walletControllerStartPasskeyRegistration, walletControllerVerifyPasskeyRegistration, walletControllerStartPasskeyAuthentication, walletControllerVerifyPasskeyAuthentication, walletControllerCreateExternalWalletSigner, walletControllerCreateApiKeySigner, walletControllerGetSignerById, walletControllerUpdateSigner, walletControllerDeleteSigner, walletControllerGetDeviceEncryptedSecret, walletControllerAddSigner, walletControllerListSigners, walletControllerRemoveSigner, walletControllerUpdateSignerPermissions, walletControllerUpdateAdminSigner, createEmailSigner, createPhoneSigner, getSignerById, getDeviceEncryptedSecret, listSigners;
|
|
705
|
+
var walletControllerCreate, walletControllerFindAll, walletControllerGetTotalBalance, walletControllerFindOne, walletControllerUpdate, walletControllerRemove, walletControllerFindByAddress, walletControllerSendSOL, walletControllerSendSPL, walletControllerMintNFT, walletControllerMintNFTSimple, walletControllerMintToken, walletControllerSendTransaction, walletControllerGetWalletAssets, walletControllerSyncWalletAssets, walletControllerDeactivateWallet, walletControllerActivateWallet, walletControllerBatchCreateWallets, walletControllerBatchSendSOL, walletControllerBatchSendSPL, walletControllerSimulateTransaction, walletControllerGetWalletCustodyInfo, walletControllerCreateEmailSigner, walletControllerCreatePhoneSigner, walletControllerStartPasskeyRegistration, walletControllerVerifyPasskeyRegistration, walletControllerStartPasskeyAuthentication, walletControllerVerifyPasskeyAuthentication, walletControllerCreateExternalWalletSigner, walletControllerCreateApiKeySigner, walletControllerGetSignerById, walletControllerUpdateSigner, walletControllerDeleteSigner, walletControllerGetDeviceEncryptedSecret, walletControllerUpdateDeviceIdentity, walletControllerAddSigner, walletControllerListSigners, walletControllerRemoveSigner, walletControllerUpdateSignerPermissions, walletControllerUpdateAdminSigner, createEmailSigner, createPhoneSigner, getSignerById, getDeviceEncryptedSecret, updateDeviceIdentity, listSigners;
|
|
695
706
|
var init_wallet = __esm({
|
|
696
707
|
"src/wallet.ts"() {
|
|
697
708
|
"use strict";
|
|
@@ -731,6 +742,7 @@ var init_wallet = __esm({
|
|
|
731
742
|
walletControllerUpdateSigner,
|
|
732
743
|
walletControllerDeleteSigner,
|
|
733
744
|
walletControllerGetDeviceEncryptedSecret,
|
|
745
|
+
walletControllerUpdateDeviceIdentity,
|
|
734
746
|
walletControllerAddSigner,
|
|
735
747
|
walletControllerListSigners,
|
|
736
748
|
walletControllerRemoveSigner,
|
|
@@ -741,6 +753,7 @@ var init_wallet = __esm({
|
|
|
741
753
|
createPhoneSigner = walletControllerCreatePhoneSigner;
|
|
742
754
|
getSignerById = walletControllerGetSignerById;
|
|
743
755
|
getDeviceEncryptedSecret = walletControllerGetDeviceEncryptedSecret;
|
|
756
|
+
updateDeviceIdentity = walletControllerUpdateDeviceIdentity;
|
|
744
757
|
listSigners = walletControllerListSigners;
|
|
745
758
|
}
|
|
746
759
|
});
|
|
@@ -951,9 +964,12 @@ __export(helpers_exports, {
|
|
|
951
964
|
MultipleDeviceIdentitiesError: () => MultipleDeviceIdentitiesError,
|
|
952
965
|
NoDeviceIdentitiesError: () => NoDeviceIdentitiesError,
|
|
953
966
|
SDKError: () => SDKError,
|
|
967
|
+
addDeviceIdentityToSigner: () => addDeviceIdentityToSigner,
|
|
968
|
+
addNewDeviceToSigner: () => addNewDeviceToSigner,
|
|
954
969
|
arrayBufferToBase64: () => arrayBufferToBase642,
|
|
955
970
|
base64ToArrayBuffer: () => base64ToArrayBuffer,
|
|
956
971
|
base64ToPEM: () => base64ToPEM,
|
|
972
|
+
canAddDeviceToSigner: () => canAddDeviceToSigner,
|
|
957
973
|
clearDeviceKeyCache: () => clearDeviceKeyCache,
|
|
958
974
|
clearEmailSignerCache: () => clearEmailSignerCache,
|
|
959
975
|
clearPhoneSignerCache: () => clearPhoneSignerCache,
|
|
@@ -987,6 +1003,7 @@ __export(helpers_exports, {
|
|
|
987
1003
|
normalizeSPKI: () => normalizeSPKI,
|
|
988
1004
|
parseSignerResponse: () => parseSignerResponse,
|
|
989
1005
|
pemToBase64: () => pemToBase64,
|
|
1006
|
+
replaceDeviceIdentity: () => replaceDeviceIdentity,
|
|
990
1007
|
resolveDeviceKey: () => resolveDeviceKey,
|
|
991
1008
|
rotateDeviceKey: () => rotateDeviceKey,
|
|
992
1009
|
signWithEmailSigner: () => signWithEmailSigner,
|
|
@@ -997,6 +1014,75 @@ __export(helpers_exports, {
|
|
|
997
1014
|
module.exports = __toCommonJS(helpers_exports);
|
|
998
1015
|
init_deviceKeyManager();
|
|
999
1016
|
|
|
1017
|
+
// src/utils/keyFormats.ts
|
|
1018
|
+
function normalizeSPKI(spkiKey) {
|
|
1019
|
+
return spkiKey.replace(/-----BEGIN PUBLIC KEY-----/g, "").replace(/-----END PUBLIC KEY-----/g, "").replace(/-----BEGIN PRIVATE KEY-----/g, "").replace(/-----END PRIVATE KEY-----/g, "").replace(/\n/g, "").replace(/\r/g, "").replace(/\s/g, "").trim();
|
|
1020
|
+
}
|
|
1021
|
+
function base64ToPEM(base64Key, keyType = "public") {
|
|
1022
|
+
var _a;
|
|
1023
|
+
const normalized = normalizeSPKI(base64Key);
|
|
1024
|
+
const header = keyType === "public" ? "PUBLIC KEY" : "PRIVATE KEY";
|
|
1025
|
+
const formatted = ((_a = normalized.match(/.{1,64}/g)) == null ? void 0 : _a.join("\n")) || normalized;
|
|
1026
|
+
return `-----BEGIN ${header}-----
|
|
1027
|
+
${formatted}
|
|
1028
|
+
-----END ${header}-----`;
|
|
1029
|
+
}
|
|
1030
|
+
function pemToBase64(pemKey) {
|
|
1031
|
+
return normalizeSPKI(pemKey);
|
|
1032
|
+
}
|
|
1033
|
+
function base64ToArrayBuffer(base64) {
|
|
1034
|
+
const normalized = normalizeSPKI(base64);
|
|
1035
|
+
if (typeof Buffer !== "undefined") {
|
|
1036
|
+
return Buffer.from(normalized, "base64").buffer;
|
|
1037
|
+
}
|
|
1038
|
+
const binaryString = atob(normalized);
|
|
1039
|
+
const bytes = new Uint8Array(binaryString.length);
|
|
1040
|
+
for (let i = 0; i < binaryString.length; i++) {
|
|
1041
|
+
bytes[i] = binaryString.charCodeAt(i);
|
|
1042
|
+
}
|
|
1043
|
+
return bytes.buffer;
|
|
1044
|
+
}
|
|
1045
|
+
function arrayBufferToBase642(buffer) {
|
|
1046
|
+
if (typeof Buffer !== "undefined") {
|
|
1047
|
+
return Buffer.from(buffer).toString("base64");
|
|
1048
|
+
}
|
|
1049
|
+
const bytes = new Uint8Array(buffer);
|
|
1050
|
+
let binary = "";
|
|
1051
|
+
for (let i = 0; i < bytes.byteLength; i++) {
|
|
1052
|
+
binary += String.fromCharCode(bytes[i]);
|
|
1053
|
+
}
|
|
1054
|
+
return btoa(binary);
|
|
1055
|
+
}
|
|
1056
|
+
async function importSPKIPublicKey(spkiBase64) {
|
|
1057
|
+
if (typeof globalThis.crypto === "undefined" || !globalThis.crypto.subtle) {
|
|
1058
|
+
throw new Error("Web Crypto API not available");
|
|
1059
|
+
}
|
|
1060
|
+
const normalized = normalizeSPKI(spkiBase64);
|
|
1061
|
+
const keyBuffer = base64ToArrayBuffer(normalized);
|
|
1062
|
+
return globalThis.crypto.subtle.importKey(
|
|
1063
|
+
"spki",
|
|
1064
|
+
keyBuffer,
|
|
1065
|
+
{
|
|
1066
|
+
name: "ECDH",
|
|
1067
|
+
namedCurve: "P-256"
|
|
1068
|
+
},
|
|
1069
|
+
true,
|
|
1070
|
+
[]
|
|
1071
|
+
);
|
|
1072
|
+
}
|
|
1073
|
+
async function exportToSPKI(key) {
|
|
1074
|
+
if (typeof globalThis.crypto === "undefined" || !globalThis.crypto.subtle) {
|
|
1075
|
+
throw new Error("Web Crypto API not available");
|
|
1076
|
+
}
|
|
1077
|
+
const exported = await globalThis.crypto.subtle.exportKey("spki", key);
|
|
1078
|
+
return arrayBufferToBase642(exported);
|
|
1079
|
+
}
|
|
1080
|
+
function isValidBase64(str) {
|
|
1081
|
+
const normalized = normalizeSPKI(str);
|
|
1082
|
+
const base64Regex = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
1083
|
+
return base64Regex.test(normalized);
|
|
1084
|
+
}
|
|
1085
|
+
|
|
1000
1086
|
// src/utils/storage/adapters.ts
|
|
1001
1087
|
function createMemoryAdapter() {
|
|
1002
1088
|
const storage = /* @__PURE__ */ new Map();
|
|
@@ -1081,9 +1167,6 @@ function createLocalStorageAdapter() {
|
|
|
1081
1167
|
publicKey: keyPair.publicKey,
|
|
1082
1168
|
keyId: keyPair.keyId,
|
|
1083
1169
|
createdAt: keyPair.createdAt.toISOString(),
|
|
1084
|
-
// Note: Browser CryptoKeys cannot be serialized to localStorage
|
|
1085
|
-
// This is a security feature. Consider using IndexedDB for full support.
|
|
1086
|
-
privateKeyType: typeof keyPair.privateKey === "string" ? "pem" : "cryptokey",
|
|
1087
1170
|
// Metadata for searchability
|
|
1088
1171
|
deviceId: keyPair.deviceId,
|
|
1089
1172
|
signerId: keyPair.signerId,
|
|
@@ -1096,6 +1179,22 @@ function createLocalStorageAdapter() {
|
|
|
1096
1179
|
};
|
|
1097
1180
|
if (typeof keyPair.privateKey === "string") {
|
|
1098
1181
|
data.privateKey = keyPair.privateKey;
|
|
1182
|
+
data.privateKeyType = "raw";
|
|
1183
|
+
} else {
|
|
1184
|
+
try {
|
|
1185
|
+
const crypto = globalThis.crypto;
|
|
1186
|
+
if (!crypto || !crypto.subtle) {
|
|
1187
|
+
throw new Error("Web Crypto API not available");
|
|
1188
|
+
}
|
|
1189
|
+
const pkcs8Key = await crypto.subtle.exportKey("pkcs8", keyPair.privateKey);
|
|
1190
|
+
const pkcs8Base64 = arrayBufferToBase642(pkcs8Key);
|
|
1191
|
+
data.privateKey = pkcs8Base64;
|
|
1192
|
+
data.privateKeyType = "cryptokey-pkcs8";
|
|
1193
|
+
} catch (error) {
|
|
1194
|
+
throw new Error(
|
|
1195
|
+
`Failed to export CryptoKey for storage: ${error}. The private key may not be extractable. Consider using IndexedDB adapter.`
|
|
1196
|
+
);
|
|
1197
|
+
}
|
|
1099
1198
|
}
|
|
1100
1199
|
localStorage.setItem(prefix + keyId, JSON.stringify(data));
|
|
1101
1200
|
},
|
|
@@ -1104,12 +1203,54 @@ function createLocalStorageAdapter() {
|
|
|
1104
1203
|
if (!stored)
|
|
1105
1204
|
return null;
|
|
1106
1205
|
const data = JSON.parse(stored);
|
|
1107
|
-
|
|
1108
|
-
|
|
1206
|
+
let privateKey;
|
|
1207
|
+
if (data.privateKeyType === "raw" || !data.privateKeyType) {
|
|
1208
|
+
if (!data.privateKey) {
|
|
1209
|
+
throw new Error(
|
|
1210
|
+
`Private key is missing from storage for keyId: ${keyId}. The stored key may be corrupted. Consider regenerating the device key.`
|
|
1211
|
+
);
|
|
1212
|
+
}
|
|
1213
|
+
privateKey = data.privateKey;
|
|
1214
|
+
} else if (data.privateKeyType === "cryptokey-pkcs8") {
|
|
1215
|
+
if (!data.privateKey) {
|
|
1216
|
+
throw new Error(
|
|
1217
|
+
`Private key is missing from storage for keyId: ${keyId}. The stored key may be corrupted. Consider regenerating the device key.`
|
|
1218
|
+
);
|
|
1219
|
+
}
|
|
1220
|
+
try {
|
|
1221
|
+
const crypto = globalThis.crypto;
|
|
1222
|
+
if (!crypto || !crypto.subtle) {
|
|
1223
|
+
throw new Error("Web Crypto API not available");
|
|
1224
|
+
}
|
|
1225
|
+
const pkcs8Buffer = base64ToArrayBuffer(data.privateKey);
|
|
1226
|
+
privateKey = await crypto.subtle.importKey(
|
|
1227
|
+
"pkcs8",
|
|
1228
|
+
pkcs8Buffer,
|
|
1229
|
+
{
|
|
1230
|
+
name: "ECDH",
|
|
1231
|
+
namedCurve: "P-256"
|
|
1232
|
+
},
|
|
1233
|
+
true,
|
|
1234
|
+
// extractable
|
|
1235
|
+
["deriveKey", "deriveBits"]
|
|
1236
|
+
);
|
|
1237
|
+
} catch (error) {
|
|
1238
|
+
throw new Error(
|
|
1239
|
+
`Failed to import CryptoKey from storage: ${error}. The stored key may be corrupted. Consider regenerating the device key.`
|
|
1240
|
+
);
|
|
1241
|
+
}
|
|
1242
|
+
} else if (data.privateKeyType === "cryptokey-raw") {
|
|
1243
|
+
throw new Error(
|
|
1244
|
+
"Legacy CryptoKey format detected. Please regenerate your device key. The old format is no longer supported."
|
|
1245
|
+
);
|
|
1246
|
+
} else {
|
|
1247
|
+
throw new Error(
|
|
1248
|
+
`Unknown private key type: ${data.privateKeyType}. Cannot load device key. Consider regenerating.`
|
|
1249
|
+
);
|
|
1109
1250
|
}
|
|
1110
1251
|
return {
|
|
1111
1252
|
publicKey: data.publicKey,
|
|
1112
|
-
privateKey
|
|
1253
|
+
privateKey,
|
|
1113
1254
|
keyId: data.keyId,
|
|
1114
1255
|
createdAt: new Date(data.createdAt),
|
|
1115
1256
|
deviceId: data.deviceId,
|
|
@@ -1274,75 +1415,6 @@ function getDefaultStorageAdapter() {
|
|
|
1274
1415
|
return createMemoryAdapter();
|
|
1275
1416
|
}
|
|
1276
1417
|
|
|
1277
|
-
// src/utils/keyFormats.ts
|
|
1278
|
-
function normalizeSPKI(spkiKey) {
|
|
1279
|
-
return spkiKey.replace(/-----BEGIN PUBLIC KEY-----/g, "").replace(/-----END PUBLIC KEY-----/g, "").replace(/-----BEGIN PRIVATE KEY-----/g, "").replace(/-----END PRIVATE KEY-----/g, "").replace(/\n/g, "").replace(/\r/g, "").replace(/\s/g, "").trim();
|
|
1280
|
-
}
|
|
1281
|
-
function base64ToPEM(base64Key, keyType = "public") {
|
|
1282
|
-
var _a;
|
|
1283
|
-
const normalized = normalizeSPKI(base64Key);
|
|
1284
|
-
const header = keyType === "public" ? "PUBLIC KEY" : "PRIVATE KEY";
|
|
1285
|
-
const formatted = ((_a = normalized.match(/.{1,64}/g)) == null ? void 0 : _a.join("\n")) || normalized;
|
|
1286
|
-
return `-----BEGIN ${header}-----
|
|
1287
|
-
${formatted}
|
|
1288
|
-
-----END ${header}-----`;
|
|
1289
|
-
}
|
|
1290
|
-
function pemToBase64(pemKey) {
|
|
1291
|
-
return normalizeSPKI(pemKey);
|
|
1292
|
-
}
|
|
1293
|
-
function base64ToArrayBuffer(base64) {
|
|
1294
|
-
const normalized = normalizeSPKI(base64);
|
|
1295
|
-
if (typeof Buffer !== "undefined") {
|
|
1296
|
-
return Buffer.from(normalized, "base64").buffer;
|
|
1297
|
-
}
|
|
1298
|
-
const binaryString = atob(normalized);
|
|
1299
|
-
const bytes = new Uint8Array(binaryString.length);
|
|
1300
|
-
for (let i = 0; i < binaryString.length; i++) {
|
|
1301
|
-
bytes[i] = binaryString.charCodeAt(i);
|
|
1302
|
-
}
|
|
1303
|
-
return bytes.buffer;
|
|
1304
|
-
}
|
|
1305
|
-
function arrayBufferToBase642(buffer) {
|
|
1306
|
-
if (typeof Buffer !== "undefined") {
|
|
1307
|
-
return Buffer.from(buffer).toString("base64");
|
|
1308
|
-
}
|
|
1309
|
-
const bytes = new Uint8Array(buffer);
|
|
1310
|
-
let binary = "";
|
|
1311
|
-
for (let i = 0; i < bytes.byteLength; i++) {
|
|
1312
|
-
binary += String.fromCharCode(bytes[i]);
|
|
1313
|
-
}
|
|
1314
|
-
return btoa(binary);
|
|
1315
|
-
}
|
|
1316
|
-
async function importSPKIPublicKey(spkiBase64) {
|
|
1317
|
-
if (typeof globalThis.crypto === "undefined" || !globalThis.crypto.subtle) {
|
|
1318
|
-
throw new Error("Web Crypto API not available");
|
|
1319
|
-
}
|
|
1320
|
-
const normalized = normalizeSPKI(spkiBase64);
|
|
1321
|
-
const keyBuffer = base64ToArrayBuffer(normalized);
|
|
1322
|
-
return globalThis.crypto.subtle.importKey(
|
|
1323
|
-
"spki",
|
|
1324
|
-
keyBuffer,
|
|
1325
|
-
{
|
|
1326
|
-
name: "ECDH",
|
|
1327
|
-
namedCurve: "P-256"
|
|
1328
|
-
},
|
|
1329
|
-
true,
|
|
1330
|
-
[]
|
|
1331
|
-
);
|
|
1332
|
-
}
|
|
1333
|
-
async function exportToSPKI(key) {
|
|
1334
|
-
if (typeof globalThis.crypto === "undefined" || !globalThis.crypto.subtle) {
|
|
1335
|
-
throw new Error("Web Crypto API not available");
|
|
1336
|
-
}
|
|
1337
|
-
const exported = await globalThis.crypto.subtle.exportKey("spki", key);
|
|
1338
|
-
return arrayBufferToBase642(exported);
|
|
1339
|
-
}
|
|
1340
|
-
function isValidBase64(str) {
|
|
1341
|
-
const normalized = normalizeSPKI(str);
|
|
1342
|
-
const base64Regex = /^[A-Za-z0-9+/]*={0,2}$/;
|
|
1343
|
-
return base64Regex.test(normalized);
|
|
1344
|
-
}
|
|
1345
|
-
|
|
1346
1418
|
// src/signers/signerHelpers.ts
|
|
1347
1419
|
init_deviceKeyManager();
|
|
1348
1420
|
init_wallet();
|
|
@@ -1460,6 +1532,11 @@ async function deriveEmailPhoneKeypair(walletId, signerId, storage, specifiedDev
|
|
|
1460
1532
|
devicePublicKey
|
|
1461
1533
|
});
|
|
1462
1534
|
const encryptedData = extractEncryptedData(response);
|
|
1535
|
+
if (!devicePrivateKey) {
|
|
1536
|
+
throw new Error(
|
|
1537
|
+
`Device private key is missing. This may happen if the device key was not properly stored or loaded. Please ensure the device key exists in storage for devicePublicKey: ${devicePublicKey.substring(0, 20)}...`
|
|
1538
|
+
);
|
|
1539
|
+
}
|
|
1463
1540
|
const masterSecret = await decryptSecret(
|
|
1464
1541
|
encryptedData,
|
|
1465
1542
|
devicePrivateKey,
|
|
@@ -1496,6 +1573,31 @@ async function decryptSecret(encryptedData, devicePrivateKey, devicePublicKey) {
|
|
|
1496
1573
|
}
|
|
1497
1574
|
async function decryptSecretBrowser(encryptedData, devicePrivateKey) {
|
|
1498
1575
|
const crypto = globalThis.crypto;
|
|
1576
|
+
if (!encryptedData.ephemeralPublicKey) {
|
|
1577
|
+
throw new Error(
|
|
1578
|
+
`Missing ephemeralPublicKey in encrypted data. Received: ${JSON.stringify(Object.keys(encryptedData))}. The API response may be in an unexpected format.`
|
|
1579
|
+
);
|
|
1580
|
+
}
|
|
1581
|
+
if (!encryptedData.encryptedSecret) {
|
|
1582
|
+
throw new Error(
|
|
1583
|
+
`Missing encryptedSecret in encrypted data. The API response may be in an unexpected format.`
|
|
1584
|
+
);
|
|
1585
|
+
}
|
|
1586
|
+
if (!encryptedData.iv) {
|
|
1587
|
+
throw new Error(
|
|
1588
|
+
`Missing iv (initialization vector) in encrypted data. The API response may be in an unexpected format.`
|
|
1589
|
+
);
|
|
1590
|
+
}
|
|
1591
|
+
if (!encryptedData.tag) {
|
|
1592
|
+
throw new Error(
|
|
1593
|
+
`Missing tag (authentication tag) in encrypted data. The API response may be in an unexpected format.`
|
|
1594
|
+
);
|
|
1595
|
+
}
|
|
1596
|
+
if (!devicePrivateKey) {
|
|
1597
|
+
throw new Error(
|
|
1598
|
+
`Device private key is undefined. This may happen if the device key was not properly loaded from storage.`
|
|
1599
|
+
);
|
|
1600
|
+
}
|
|
1499
1601
|
const ephemeralPublicKeyBuffer = base64ToArrayBuffer2(encryptedData.ephemeralPublicKey);
|
|
1500
1602
|
const ephemeralPublicKey = await crypto.subtle.importKey(
|
|
1501
1603
|
"raw",
|
|
@@ -1629,8 +1731,8 @@ async function getEmailSignerKeypair(walletId, signerId, options) {
|
|
|
1629
1731
|
if (resolvedDevicePublicKey && deviceKeyManager) {
|
|
1630
1732
|
const foundKey = await findDeviceKeyByPublicKey(resolvedDevicePublicKey, deviceKeyManager);
|
|
1631
1733
|
if (!foundKey) {
|
|
1632
|
-
const { DeviceKeyNotFoundError:
|
|
1633
|
-
throw new
|
|
1734
|
+
const { DeviceKeyNotFoundError: DeviceKeyNotFoundError3 } = (init_errors(), __toCommonJS(errors_exports));
|
|
1735
|
+
throw new DeviceKeyNotFoundError3(resolvedDevicePublicKey, signerId);
|
|
1634
1736
|
}
|
|
1635
1737
|
if (validateDeviceKey2) {
|
|
1636
1738
|
const validation = await validateDeviceKeyFn(
|
|
@@ -1734,8 +1836,8 @@ async function getPhoneSignerKeypair(walletId, signerId, options) {
|
|
|
1734
1836
|
if (resolvedDevicePublicKey && deviceKeyManager) {
|
|
1735
1837
|
const foundKey = await findDeviceKeyByPublicKey(resolvedDevicePublicKey, deviceKeyManager);
|
|
1736
1838
|
if (!foundKey) {
|
|
1737
|
-
const { DeviceKeyNotFoundError:
|
|
1738
|
-
throw new
|
|
1839
|
+
const { DeviceKeyNotFoundError: DeviceKeyNotFoundError3 } = (init_errors(), __toCommonJS(errors_exports));
|
|
1840
|
+
throw new DeviceKeyNotFoundError3(resolvedDevicePublicKey, signerId);
|
|
1739
1841
|
}
|
|
1740
1842
|
if (validateDeviceKey2) {
|
|
1741
1843
|
const validation = await validateDeviceKeyFn(
|
|
@@ -1796,6 +1898,90 @@ async function getPhoneSignerByPhone(walletId, phone) {
|
|
|
1796
1898
|
|
|
1797
1899
|
// src/helpers.ts
|
|
1798
1900
|
init_deviceKeyHelpers();
|
|
1901
|
+
|
|
1902
|
+
// src/signers/deviceIdentityHelpers.ts
|
|
1903
|
+
init_wallet();
|
|
1904
|
+
init_deviceKeyManager();
|
|
1905
|
+
init_deviceKeyHelpers();
|
|
1906
|
+
init_errors();
|
|
1907
|
+
async function addDeviceIdentityToSigner(walletId, signerId, options) {
|
|
1908
|
+
const deviceKeyPair = await generateDeviceKeyPair();
|
|
1909
|
+
const newDevicePublicKey = deviceKeyPair.publicKey;
|
|
1910
|
+
if (options == null ? void 0 : options.deviceKeyManager) {
|
|
1911
|
+
await options.deviceKeyManager.save(deviceKeyPair.keyId, deviceKeyPair);
|
|
1912
|
+
}
|
|
1913
|
+
let encryptedMasterSecret;
|
|
1914
|
+
try {
|
|
1915
|
+
const encryptedSecretResponse = await getDeviceEncryptedSecret(
|
|
1916
|
+
walletId,
|
|
1917
|
+
signerId,
|
|
1918
|
+
{
|
|
1919
|
+
devicePublicKey: newDevicePublicKey
|
|
1920
|
+
}
|
|
1921
|
+
);
|
|
1922
|
+
const responseData = encryptedSecretResponse.data || encryptedSecretResponse;
|
|
1923
|
+
encryptedMasterSecret = responseData.encryptedSecret || responseData.encrypted_secret;
|
|
1924
|
+
if (!encryptedMasterSecret) {
|
|
1925
|
+
throw new Error("Failed to get encrypted master secret from API");
|
|
1926
|
+
}
|
|
1927
|
+
} catch (error) {
|
|
1928
|
+
throw new Error(
|
|
1929
|
+
`Failed to get encrypted master secret for new device: ${error}. Make sure the signer exists and you have proper authentication.`
|
|
1930
|
+
);
|
|
1931
|
+
}
|
|
1932
|
+
await updateDeviceIdentity(
|
|
1933
|
+
walletId,
|
|
1934
|
+
signerId,
|
|
1935
|
+
{
|
|
1936
|
+
oldDevicePublicKey: options == null ? void 0 : options.oldDevicePublicKey,
|
|
1937
|
+
// Optional: replace specific device
|
|
1938
|
+
devicePublicKey: newDevicePublicKey,
|
|
1939
|
+
encryptedMasterSecret,
|
|
1940
|
+
deviceFingerprint: options == null ? void 0 : options.deviceFingerprint
|
|
1941
|
+
}
|
|
1942
|
+
);
|
|
1943
|
+
const deviceIdentities = await getSignerDeviceKeys(walletId, signerId);
|
|
1944
|
+
const newDevice = deviceIdentities.find(
|
|
1945
|
+
(d) => d.devicePublicKey === newDevicePublicKey
|
|
1946
|
+
);
|
|
1947
|
+
if (!newDevice) {
|
|
1948
|
+
throw new Error("Failed to retrieve new device identity after creation");
|
|
1949
|
+
}
|
|
1950
|
+
return {
|
|
1951
|
+
deviceId: newDevice.deviceId,
|
|
1952
|
+
devicePublicKey: newDevice.devicePublicKey,
|
|
1953
|
+
createdAt: newDevice.createdAt || (/* @__PURE__ */ new Date()).toISOString()
|
|
1954
|
+
};
|
|
1955
|
+
}
|
|
1956
|
+
async function replaceDeviceIdentity(walletId, signerId, options) {
|
|
1957
|
+
return addDeviceIdentityToSigner(walletId, signerId, {
|
|
1958
|
+
oldDevicePublicKey: options.oldDevicePublicKey,
|
|
1959
|
+
deviceKeyManager: options.deviceKeyManager,
|
|
1960
|
+
deviceFingerprint: options.deviceFingerprint
|
|
1961
|
+
});
|
|
1962
|
+
}
|
|
1963
|
+
async function addNewDeviceToSigner(walletId, signerId, options) {
|
|
1964
|
+
const existingDevices = await getSignerDeviceKeys(walletId, signerId);
|
|
1965
|
+
if (existingDevices.length === 0) {
|
|
1966
|
+
throw new NoDeviceIdentitiesError(signerId, walletId);
|
|
1967
|
+
}
|
|
1968
|
+
const oldDevicePublicKey = existingDevices.length === 1 ? existingDevices[0].devicePublicKey : void 0;
|
|
1969
|
+
return addDeviceIdentityToSigner(walletId, signerId, {
|
|
1970
|
+
oldDevicePublicKey,
|
|
1971
|
+
deviceKeyManager: options == null ? void 0 : options.deviceKeyManager,
|
|
1972
|
+
deviceFingerprint: options == null ? void 0 : options.deviceFingerprint
|
|
1973
|
+
});
|
|
1974
|
+
}
|
|
1975
|
+
async function canAddDeviceToSigner(walletId, signerId) {
|
|
1976
|
+
try {
|
|
1977
|
+
const deviceIdentities = await getSignerDeviceKeys(walletId, signerId);
|
|
1978
|
+
return deviceIdentities.length > 0;
|
|
1979
|
+
} catch (error) {
|
|
1980
|
+
return false;
|
|
1981
|
+
}
|
|
1982
|
+
}
|
|
1983
|
+
|
|
1984
|
+
// src/helpers.ts
|
|
1799
1985
|
init_errors();
|
|
1800
1986
|
// Annotate the CommonJS export names for ESM import in node:
|
|
1801
1987
|
0 && (module.exports = {
|
|
@@ -1804,9 +1990,12 @@ init_errors();
|
|
|
1804
1990
|
MultipleDeviceIdentitiesError,
|
|
1805
1991
|
NoDeviceIdentitiesError,
|
|
1806
1992
|
SDKError,
|
|
1993
|
+
addDeviceIdentityToSigner,
|
|
1994
|
+
addNewDeviceToSigner,
|
|
1807
1995
|
arrayBufferToBase64,
|
|
1808
1996
|
base64ToArrayBuffer,
|
|
1809
1997
|
base64ToPEM,
|
|
1998
|
+
canAddDeviceToSigner,
|
|
1810
1999
|
clearDeviceKeyCache,
|
|
1811
2000
|
clearEmailSignerCache,
|
|
1812
2001
|
clearPhoneSignerCache,
|
|
@@ -1840,6 +2029,7 @@ init_errors();
|
|
|
1840
2029
|
normalizeSPKI,
|
|
1841
2030
|
parseSignerResponse,
|
|
1842
2031
|
pemToBase64,
|
|
2032
|
+
replaceDeviceIdentity,
|
|
1843
2033
|
resolveDeviceKey,
|
|
1844
2034
|
rotateDeviceKey,
|
|
1845
2035
|
signWithEmailSigner,
|