cilantro-sdk 0.0.16 → 0.0.17
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/helpers.cjs +42 -29
- package/dist/helpers.cjs.map +2 -2
- package/dist/helpers.mjs +42 -29
- package/dist/helpers.mjs.map +2 -2
- package/dist/index.cjs +42 -29
- package/dist/index.cjs.map +2 -2
- package/dist/index.mjs +42 -29
- package/dist/index.mjs.map +2 -2
- package/dist/models/createPlatformDto.d.ts +6 -0
- package/dist/models/createPlatformDto.d.ts.map +1 -1
- package/dist/models/updatePlatformDto.d.ts +6 -0
- package/dist/models/updatePlatformDto.d.ts.map +1 -1
- package/dist/signers/deviceIdentityHelpers.d.ts.map +1 -1
- package/dist/signers/deviceKeyHelpers.d.ts.map +1 -1
- package/dist/signers/emailSigner.d.ts.map +1 -1
- package/dist/signers/externalWalletAdapter.d.ts +22 -3
- package/dist/signers/externalWalletAdapter.d.ts.map +1 -1
- package/dist/signers/multiDeviceManager.d.ts +14 -4
- package/dist/signers/multiDeviceManager.d.ts.map +1 -1
- package/dist/signers/passkeyHelpers.d.ts +8 -2
- package/dist/signers/passkeyHelpers.d.ts.map +1 -1
- package/dist/signers/phoneSigner.d.ts.map +1 -1
- package/dist/signers/signerHelpers.d.ts +36 -1
- package/dist/signers/signerHelpers.d.ts.map +1 -1
- package/dist/signers/signerLifecycle.d.ts +3 -2
- package/dist/signers/signerLifecycle.d.ts.map +1 -1
- package/package.json +1 -1
package/dist/helpers.cjs
CHANGED
|
@@ -2489,8 +2489,8 @@ async function signWithSigner(walletId, signerId, signerType, message, options)
|
|
|
2489
2489
|
function parseSignerResponse(response) {
|
|
2490
2490
|
var _a;
|
|
2491
2491
|
return {
|
|
2492
|
-
signerId: response.id || response.signerId,
|
|
2493
|
-
walletId: response.walletId || ((_a = response.wallet) == null ? void 0 : _a.id),
|
|
2492
|
+
signerId: response.id || response.signerId || "",
|
|
2493
|
+
walletId: response.walletId || ((_a = response.wallet) == null ? void 0 : _a.id) || "",
|
|
2494
2494
|
type: response.type || response.signerType || inferSignerType(response),
|
|
2495
2495
|
email: response.email,
|
|
2496
2496
|
phone: response.phone,
|
|
@@ -2571,11 +2571,15 @@ async function derivePasskeyKeypair(walletId, signerId) {
|
|
|
2571
2571
|
);
|
|
2572
2572
|
}
|
|
2573
2573
|
function extractEncryptedData(response) {
|
|
2574
|
-
|
|
2575
|
-
const
|
|
2574
|
+
var _a, _b;
|
|
2575
|
+
const responseData = response;
|
|
2576
|
+
const data = (typeof responseData === "object" && responseData !== null && "data" in responseData ? responseData.data : responseData) || responseData;
|
|
2577
|
+
const dataObj = data;
|
|
2578
|
+
const encryptedSecret = dataObj.encryptedSecret || dataObj.encrypted_secret || ((_a = dataObj.data) == null ? void 0 : _a.encryptedSecret) || ((_b = dataObj.data) == null ? void 0 : _b.encrypted_secret);
|
|
2576
2579
|
if (!encryptedSecret) {
|
|
2580
|
+
const dataKeys = typeof data === "object" && data !== null ? Object.keys(data) : [];
|
|
2577
2581
|
throw new Error(
|
|
2578
|
-
`Missing encryptedSecret in API response. Response structure: ${JSON.stringify(
|
|
2582
|
+
`Missing encryptedSecret in API response. Response structure: ${JSON.stringify(dataKeys)}. Full response: ${JSON.stringify(response).substring(0, 200)}...`
|
|
2579
2583
|
);
|
|
2580
2584
|
}
|
|
2581
2585
|
try {
|
|
@@ -2935,11 +2939,13 @@ var DeviceCompatibilityError = class extends SDKError {
|
|
|
2935
2939
|
// src/signers/deviceKeyHelpers.ts
|
|
2936
2940
|
async function getSignerDeviceKeys(walletId, signerId) {
|
|
2937
2941
|
const signer = await getSignerById(walletId, signerId);
|
|
2938
|
-
const signerData = signer
|
|
2939
|
-
const
|
|
2942
|
+
const signerData = signer;
|
|
2943
|
+
const responseData = signerData.data || signerData;
|
|
2944
|
+
const signerResponse = responseData;
|
|
2945
|
+
const deviceIdentities = signerResponse.deviceIdentities || [];
|
|
2940
2946
|
return deviceIdentities.map((di) => ({
|
|
2941
|
-
deviceId: di.deviceId || di.device_id,
|
|
2942
|
-
devicePublicKey: di.devicePublicKey || di.device_public_key,
|
|
2947
|
+
deviceId: di.deviceId || di.device_id || "",
|
|
2948
|
+
devicePublicKey: di.devicePublicKey || di.device_public_key || "",
|
|
2943
2949
|
lastUsedAt: di.lastUsedAt || di.last_used_at,
|
|
2944
2950
|
createdAt: di.createdAt || di.created_at
|
|
2945
2951
|
}));
|
|
@@ -3043,8 +3049,8 @@ async function createEmailSignerHelper(walletId, config) {
|
|
|
3043
3049
|
devicePublicKey
|
|
3044
3050
|
});
|
|
3045
3051
|
const signers = await listSigners(walletId);
|
|
3046
|
-
const signerResponse = signers
|
|
3047
|
-
const signerList = Array.isArray(signerResponse) ? signerResponse : [];
|
|
3052
|
+
const signerResponse = signers;
|
|
3053
|
+
const signerList = Array.isArray(signerResponse) ? signerResponse : Array.isArray(signerResponse.data) ? signerResponse.data : [];
|
|
3048
3054
|
const signer = signerList.find(
|
|
3049
3055
|
(s) => s.email === config.email || s.type === "email" && s.email === config.email
|
|
3050
3056
|
);
|
|
@@ -3065,8 +3071,9 @@ async function getEmailSignerKeypair(walletId, signerId, options) {
|
|
|
3065
3071
|
let resolvedDeviceId = providedDeviceId;
|
|
3066
3072
|
if (deviceKeyManager) {
|
|
3067
3073
|
const signerResponse = await getSignerById(walletId, signerId);
|
|
3068
|
-
const signerData = signerResponse
|
|
3069
|
-
const
|
|
3074
|
+
const signerData = signerResponse;
|
|
3075
|
+
const responseData = signerData.data || signerData;
|
|
3076
|
+
const deviceIdentities = responseData.deviceIdentities || [];
|
|
3070
3077
|
if (deviceIdentities.length === 0) {
|
|
3071
3078
|
throw new Error(
|
|
3072
3079
|
`No device identities found for signer ${signerId}. Please ensure the signer has been created with a device key.`
|
|
@@ -3142,8 +3149,8 @@ function clearEmailSignerCache(walletId, signerId) {
|
|
|
3142
3149
|
}
|
|
3143
3150
|
async function getEmailSignerByEmail(walletId, email) {
|
|
3144
3151
|
const signers = await listSigners(walletId);
|
|
3145
|
-
const signerResponse = signers
|
|
3146
|
-
const signerList = Array.isArray(signerResponse) ? signerResponse : [];
|
|
3152
|
+
const signerResponse = signers;
|
|
3153
|
+
const signerList = Array.isArray(signerResponse) ? signerResponse : Array.isArray(signerResponse.data) ? signerResponse.data : [];
|
|
3147
3154
|
const signer = signerList.find(
|
|
3148
3155
|
(s) => s.email === email || s.type === "email" && s.email === email
|
|
3149
3156
|
);
|
|
@@ -3158,8 +3165,8 @@ async function createPhoneSignerHelper(walletId, config) {
|
|
|
3158
3165
|
devicePublicKey
|
|
3159
3166
|
});
|
|
3160
3167
|
const signers = await listSigners(walletId);
|
|
3161
|
-
const signerResponse = signers
|
|
3162
|
-
const signerList = Array.isArray(signerResponse) ? signerResponse : [];
|
|
3168
|
+
const signerResponse = signers;
|
|
3169
|
+
const signerList = Array.isArray(signerResponse) ? signerResponse : Array.isArray(signerResponse.data) ? signerResponse.data : [];
|
|
3163
3170
|
const signer = signerList.find(
|
|
3164
3171
|
(s) => s.phone === config.phone || s.type === "phone" && s.phone === config.phone
|
|
3165
3172
|
);
|
|
@@ -3180,8 +3187,9 @@ async function getPhoneSignerKeypair(walletId, signerId, options) {
|
|
|
3180
3187
|
let resolvedDeviceId = providedDeviceId;
|
|
3181
3188
|
if (deviceKeyManager) {
|
|
3182
3189
|
const signerResponse = await getSignerById(walletId, signerId);
|
|
3183
|
-
const signerData = signerResponse
|
|
3184
|
-
const
|
|
3190
|
+
const signerData = signerResponse;
|
|
3191
|
+
const responseData = signerData.data || signerData;
|
|
3192
|
+
const deviceIdentities = responseData.deviceIdentities || [];
|
|
3185
3193
|
if (deviceIdentities.length === 0) {
|
|
3186
3194
|
throw new Error(
|
|
3187
3195
|
`No device identities found for signer ${signerId}. Please ensure the signer has been created with a device key.`
|
|
@@ -3257,8 +3265,8 @@ function clearPhoneSignerCache(walletId, signerId) {
|
|
|
3257
3265
|
}
|
|
3258
3266
|
async function getPhoneSignerByPhone(walletId, phone) {
|
|
3259
3267
|
const signers = await listSigners(walletId);
|
|
3260
|
-
const signerResponse = signers
|
|
3261
|
-
const signerList = Array.isArray(signerResponse) ? signerResponse : [];
|
|
3268
|
+
const signerResponse = signers;
|
|
3269
|
+
const signerList = Array.isArray(signerResponse) ? signerResponse : Array.isArray(signerResponse.data) ? signerResponse.data : [];
|
|
3262
3270
|
const signer = signerList.find(
|
|
3263
3271
|
(s) => s.phone === phone || s.type === "phone" && s.phone === phone
|
|
3264
3272
|
);
|
|
@@ -3281,8 +3289,10 @@ async function addDeviceIdentityToSigner(walletId, signerId, options) {
|
|
|
3281
3289
|
devicePublicKey: newDevicePublicKey
|
|
3282
3290
|
}
|
|
3283
3291
|
);
|
|
3284
|
-
const responseData = encryptedSecretResponse
|
|
3285
|
-
|
|
3292
|
+
const responseData = encryptedSecretResponse;
|
|
3293
|
+
const data = (typeof responseData === "object" && responseData !== null && "data" in responseData ? responseData.data : responseData) || responseData;
|
|
3294
|
+
const dataObj = data;
|
|
3295
|
+
encryptedMasterSecret = dataObj.encryptedSecret || dataObj.encrypted_secret || "";
|
|
3286
3296
|
if (!encryptedMasterSecret) {
|
|
3287
3297
|
throw new Error(
|
|
3288
3298
|
`Failed to get encrypted master secret from API. Response structure: ${JSON.stringify(Object.keys(responseData))}. Please check the API response format.`
|
|
@@ -3741,19 +3751,21 @@ async function createSigner(walletId, type, params) {
|
|
|
3741
3751
|
if (!params.email) {
|
|
3742
3752
|
throw new SDKError("Email is required", "INVALID_PARAMS");
|
|
3743
3753
|
}
|
|
3744
|
-
|
|
3754
|
+
const createDto = {
|
|
3745
3755
|
email: params.email,
|
|
3746
3756
|
devicePublicKey: params.devicePublicKey || ""
|
|
3747
|
-
}
|
|
3757
|
+
};
|
|
3758
|
+
return await createEmailSigner(walletId, createDto);
|
|
3748
3759
|
}
|
|
3749
3760
|
if (type === "phone") {
|
|
3750
3761
|
if (!params.phone) {
|
|
3751
3762
|
throw new SDKError("Phone is required", "INVALID_PARAMS");
|
|
3752
3763
|
}
|
|
3753
|
-
|
|
3764
|
+
const createDto = {
|
|
3754
3765
|
phone: params.phone,
|
|
3755
3766
|
devicePublicKey: params.devicePublicKey || ""
|
|
3756
|
-
}
|
|
3767
|
+
};
|
|
3768
|
+
return await createPhoneSigner(walletId, createDto);
|
|
3757
3769
|
}
|
|
3758
3770
|
throw new SDKError(`Unsupported signer type: ${type}`, "UNSUPPORTED_SIGNER_TYPE");
|
|
3759
3771
|
} catch (error) {
|
|
@@ -3778,7 +3790,7 @@ async function revokeSigner(walletId, signerId) {
|
|
|
3778
3790
|
async function getSigners(walletId) {
|
|
3779
3791
|
try {
|
|
3780
3792
|
const response = await listSigners(walletId);
|
|
3781
|
-
return response
|
|
3793
|
+
return response;
|
|
3782
3794
|
} catch (error) {
|
|
3783
3795
|
throw new SDKError(
|
|
3784
3796
|
`Failed to get signers: ${error instanceof Error ? error.message : String(error)}`,
|
|
@@ -3831,7 +3843,8 @@ async function getDevices(walletId, signerId) {
|
|
|
3831
3843
|
}
|
|
3832
3844
|
async function updateDevice(walletId, signerId, devicePublicKey) {
|
|
3833
3845
|
try {
|
|
3834
|
-
|
|
3846
|
+
const updateDto = { devicePublicKey };
|
|
3847
|
+
return await updateDeviceIdentity(walletId, signerId, updateDto);
|
|
3835
3848
|
} catch (error) {
|
|
3836
3849
|
throw new SDKError(
|
|
3837
3850
|
`Failed to update device: ${error instanceof Error ? error.message : String(error)}`,
|