@turnkey/core 2.5.0 → 2.7.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.
Files changed (43) hide show
  1. package/dist/__clients__/core.d.ts +36 -3
  2. package/dist/__clients__/core.d.ts.map +1 -1
  3. package/dist/__clients__/core.js +123 -40
  4. package/dist/__clients__/core.js.map +1 -1
  5. package/dist/__clients__/core.mjs +116 -33
  6. package/dist/__clients__/core.mjs.map +1 -1
  7. package/dist/__generated__/sdk-client-base.d.ts +21 -0
  8. package/dist/__generated__/sdk-client-base.d.ts.map +1 -1
  9. package/dist/__generated__/sdk-client-base.js +267 -1
  10. package/dist/__generated__/sdk-client-base.js.map +1 -1
  11. package/dist/__generated__/sdk-client-base.mjs +268 -2
  12. package/dist/__generated__/sdk-client-base.mjs.map +1 -1
  13. package/dist/__generated__/version.d.ts +1 -1
  14. package/dist/__generated__/version.js +1 -1
  15. package/dist/__generated__/version.mjs +1 -1
  16. package/dist/__stampers__/api/base.d.ts +2 -1
  17. package/dist/__stampers__/api/base.d.ts.map +1 -1
  18. package/dist/__stampers__/api/base.js +11 -14
  19. package/dist/__stampers__/api/base.js.map +1 -1
  20. package/dist/__stampers__/api/base.mjs +11 -14
  21. package/dist/__stampers__/api/base.mjs.map +1 -1
  22. package/dist/__stampers__/attested/base.d.ts +22 -0
  23. package/dist/__stampers__/attested/base.d.ts.map +1 -0
  24. package/dist/__stampers__/attested/base.js +50 -0
  25. package/dist/__stampers__/attested/base.js.map +1 -0
  26. package/dist/__stampers__/attested/base.mjs +48 -0
  27. package/dist/__stampers__/attested/base.mjs.map +1 -0
  28. package/dist/__types__/config.d.ts +42 -1
  29. package/dist/__types__/config.d.ts.map +1 -1
  30. package/dist/__types__/enums.d.ts +2 -1
  31. package/dist/__types__/enums.d.ts.map +1 -1
  32. package/dist/__types__/enums.js +1 -0
  33. package/dist/__types__/enums.js.map +1 -1
  34. package/dist/__types__/enums.mjs +1 -0
  35. package/dist/__types__/enums.mjs.map +1 -1
  36. package/dist/__types__/method-types/shared.d.ts +21 -1
  37. package/dist/__types__/method-types/shared.d.ts.map +1 -1
  38. package/dist/utils.d.ts.map +1 -1
  39. package/dist/utils.js +3 -1
  40. package/dist/utils.js.map +1 -1
  41. package/dist/utils.mjs +3 -1
  42. package/dist/utils.mjs.map +1 -1
  43. package/package.json +6 -6
@@ -997,6 +997,36 @@ class TurnkeySDKClientBase {
997
997
  url: fullUrl,
998
998
  };
999
999
  };
1000
+ this.getTvcQosVersions = async (input, stampWith) => {
1001
+ const session = await this.storageManager?.getActiveSession();
1002
+ return this.request("/public/v1/query/get_tvc_qos_versions", {
1003
+ ...input,
1004
+ organizationId: input.organizationId ??
1005
+ session?.organizationId ??
1006
+ this.config.organizationId,
1007
+ }, stampWith);
1008
+ };
1009
+ this.stampGetTvcQosVersions = async (input, stampWith) => {
1010
+ const activeStamper = this.getStamper(stampWith);
1011
+ if (!activeStamper) {
1012
+ return undefined;
1013
+ }
1014
+ const session = await this.storageManager?.getActiveSession();
1015
+ const fullUrl = this.config.apiBaseUrl + "/public/v1/query/get_tvc_qos_versions";
1016
+ const body = {
1017
+ ...input,
1018
+ organizationId: input.organizationId ??
1019
+ session?.organizationId ??
1020
+ this.config.organizationId,
1021
+ };
1022
+ const stringifiedBody = JSON.stringify(body);
1023
+ const stamp = await activeStamper.stamp(stringifiedBody);
1024
+ return {
1025
+ body: stringifiedBody,
1026
+ stamp: stamp,
1027
+ url: fullUrl,
1028
+ };
1029
+ };
1000
1030
  this.getUser = async (input, stampWith) => {
1001
1031
  const session = await this.storageManager?.getActiveSession();
1002
1032
  return this.request("/public/v1/query/get_user", {
@@ -1477,6 +1507,36 @@ class TurnkeySDKClientBase {
1477
1507
  url: fullUrl,
1478
1508
  };
1479
1509
  };
1510
+ this.listSecrets = async (input, stampWith) => {
1511
+ const session = await this.storageManager?.getActiveSession();
1512
+ return this.request("/public/v1/query/list_secrets", {
1513
+ ...input,
1514
+ organizationId: input.organizationId ??
1515
+ session?.organizationId ??
1516
+ this.config.organizationId,
1517
+ }, stampWith);
1518
+ };
1519
+ this.stampListSecrets = async (input, stampWith) => {
1520
+ const activeStamper = this.getStamper(stampWith);
1521
+ if (!activeStamper) {
1522
+ return undefined;
1523
+ }
1524
+ const session = await this.storageManager?.getActiveSession();
1525
+ const fullUrl = this.config.apiBaseUrl + "/public/v1/query/list_secrets";
1526
+ const body = {
1527
+ ...input,
1528
+ organizationId: input.organizationId ??
1529
+ session?.organizationId ??
1530
+ this.config.organizationId,
1531
+ };
1532
+ const stringifiedBody = JSON.stringify(body);
1533
+ const stamp = await activeStamper.stamp(stringifiedBody);
1534
+ return {
1535
+ body: stringifiedBody,
1536
+ stamp: stamp,
1537
+ url: fullUrl,
1538
+ };
1539
+ };
1480
1540
  this.getSmartContractInterfaces = async (input, stampWith) => {
1481
1541
  const session = await this.storageManager?.getActiveSession();
1482
1542
  return this.request("/public/v1/query/list_smart_contract_interfaces", {
@@ -2602,6 +2662,43 @@ class TurnkeySDKClientBase {
2602
2662
  url: fullUrl,
2603
2663
  };
2604
2664
  };
2665
+ this.createSwapQuote = async (input, stampWith) => {
2666
+ const { organizationId, timestampMs, ...rest } = input;
2667
+ //@ts-ignore - generateAppProofs does not exist on all request types, so we ignore the type error here for those that are missing it
2668
+ const generateAppProofs = input?.generateAppProofs ?? false;
2669
+ const session = await this.storageManager?.getActiveSession();
2670
+ return this.activity("/public/v1/submit/create_swap_quote", {
2671
+ parameters: rest,
2672
+ organizationId: organizationId ??
2673
+ session?.organizationId ??
2674
+ this.config.organizationId,
2675
+ timestampMs: timestampMs ?? String(Date.now()),
2676
+ generateAppProofs: generateAppProofs ?? false,
2677
+ type: "ACTIVITY_TYPE_CREATE_SWAP_QUOTE",
2678
+ }, "createSwapQuoteResult", stampWith);
2679
+ };
2680
+ this.stampCreateSwapQuote = async (input, stampWith) => {
2681
+ const activeStamper = this.getStamper(stampWith);
2682
+ if (!activeStamper) {
2683
+ return undefined;
2684
+ }
2685
+ const { organizationId, timestampMs, ...parameters } = input;
2686
+ const session = await this.storageManager?.getActiveSession();
2687
+ const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/create_swap_quote";
2688
+ const bodyWithType = {
2689
+ parameters,
2690
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
2691
+ timestampMs: timestampMs ?? String(Date.now()),
2692
+ type: "ACTIVITY_TYPE_CREATE_SWAP_QUOTE",
2693
+ };
2694
+ const stringifiedBody = JSON.stringify(bodyWithType);
2695
+ const stamp = await activeStamper.stamp(stringifiedBody);
2696
+ return {
2697
+ body: stringifiedBody,
2698
+ stamp: stamp,
2699
+ url: fullUrl,
2700
+ };
2701
+ };
2605
2702
  this.createTvcApp = async (input, stampWith) => {
2606
2703
  const { organizationId, timestampMs, ...rest } = input;
2607
2704
  //@ts-ignore - generateAppProofs does not exist on all request types, so we ignore the type error here for those that are missing it
@@ -3864,6 +3961,43 @@ class TurnkeySDKClientBase {
3864
3961
  url: fullUrl,
3865
3962
  };
3866
3963
  };
3964
+ this.executeSwap = async (input, stampWith) => {
3965
+ const { organizationId, timestampMs, ...rest } = input;
3966
+ //@ts-ignore - generateAppProofs does not exist on all request types, so we ignore the type error here for those that are missing it
3967
+ const generateAppProofs = input?.generateAppProofs ?? false;
3968
+ const session = await this.storageManager?.getActiveSession();
3969
+ return this.activity("/public/v1/submit/execute_swap", {
3970
+ parameters: rest,
3971
+ organizationId: organizationId ??
3972
+ session?.organizationId ??
3973
+ this.config.organizationId,
3974
+ timestampMs: timestampMs ?? String(Date.now()),
3975
+ generateAppProofs: generateAppProofs ?? false,
3976
+ type: "ACTIVITY_TYPE_EXECUTE_SWAP_V2",
3977
+ }, "executeSwapResult", stampWith);
3978
+ };
3979
+ this.stampExecuteSwap = async (input, stampWith) => {
3980
+ const activeStamper = this.getStamper(stampWith);
3981
+ if (!activeStamper) {
3982
+ return undefined;
3983
+ }
3984
+ const { organizationId, timestampMs, ...parameters } = input;
3985
+ const session = await this.storageManager?.getActiveSession();
3986
+ const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/execute_swap";
3987
+ const bodyWithType = {
3988
+ parameters,
3989
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
3990
+ timestampMs: timestampMs ?? String(Date.now()),
3991
+ type: "ACTIVITY_TYPE_EXECUTE_SWAP_V2",
3992
+ };
3993
+ const stringifiedBody = JSON.stringify(bodyWithType);
3994
+ const stamp = await activeStamper.stamp(stringifiedBody);
3995
+ return {
3996
+ body: stringifiedBody,
3997
+ stamp: stamp,
3998
+ url: fullUrl,
3999
+ };
4000
+ };
3867
4001
  this.exportPrivateKey = async (input, stampWith) => {
3868
4002
  const { organizationId, timestampMs, ...rest } = input;
3869
4003
  //@ts-ignore - generateAppProofs does not exist on all request types, so we ignore the type error here for those that are missing it
@@ -3901,6 +4035,43 @@ class TurnkeySDKClientBase {
3901
4035
  url: fullUrl,
3902
4036
  };
3903
4037
  };
4038
+ this.exportSecrets = async (input, stampWith) => {
4039
+ const { organizationId, timestampMs, ...rest } = input;
4040
+ //@ts-ignore - generateAppProofs does not exist on all request types, so we ignore the type error here for those that are missing it
4041
+ const generateAppProofs = input?.generateAppProofs ?? false;
4042
+ const session = await this.storageManager?.getActiveSession();
4043
+ return this.activity("/public/v1/submit/export_secrets", {
4044
+ parameters: rest,
4045
+ organizationId: organizationId ??
4046
+ session?.organizationId ??
4047
+ this.config.organizationId,
4048
+ timestampMs: timestampMs ?? String(Date.now()),
4049
+ generateAppProofs: generateAppProofs ?? false,
4050
+ type: "ACTIVITY_TYPE_EXPORT_SECRETS",
4051
+ }, "exportSecretsResult", stampWith);
4052
+ };
4053
+ this.stampExportSecrets = async (input, stampWith) => {
4054
+ const activeStamper = this.getStamper(stampWith);
4055
+ if (!activeStamper) {
4056
+ return undefined;
4057
+ }
4058
+ const { organizationId, timestampMs, ...parameters } = input;
4059
+ const session = await this.storageManager?.getActiveSession();
4060
+ const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/export_secrets";
4061
+ const bodyWithType = {
4062
+ parameters,
4063
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
4064
+ timestampMs: timestampMs ?? String(Date.now()),
4065
+ type: "ACTIVITY_TYPE_EXPORT_SECRETS",
4066
+ };
4067
+ const stringifiedBody = JSON.stringify(bodyWithType);
4068
+ const stamp = await activeStamper.stamp(stringifiedBody);
4069
+ return {
4070
+ body: stringifiedBody,
4071
+ stamp: stamp,
4072
+ url: fullUrl,
4073
+ };
4074
+ };
3904
4075
  this.exportWallet = async (input, stampWith) => {
3905
4076
  const { organizationId, timestampMs, ...rest } = input;
3906
4077
  //@ts-ignore - generateAppProofs does not exist on all request types, so we ignore the type error here for those that are missing it
@@ -4012,6 +4183,43 @@ class TurnkeySDKClientBase {
4012
4183
  url: fullUrl,
4013
4184
  };
4014
4185
  };
4186
+ this.importSecrets = async (input, stampWith) => {
4187
+ const { organizationId, timestampMs, ...rest } = input;
4188
+ //@ts-ignore - generateAppProofs does not exist on all request types, so we ignore the type error here for those that are missing it
4189
+ const generateAppProofs = input?.generateAppProofs ?? false;
4190
+ const session = await this.storageManager?.getActiveSession();
4191
+ return this.activity("/public/v1/submit/import_secrets", {
4192
+ parameters: rest,
4193
+ organizationId: organizationId ??
4194
+ session?.organizationId ??
4195
+ this.config.organizationId,
4196
+ timestampMs: timestampMs ?? String(Date.now()),
4197
+ generateAppProofs: generateAppProofs ?? false,
4198
+ type: "ACTIVITY_TYPE_IMPORT_SECRETS",
4199
+ }, "importSecretsResult", stampWith);
4200
+ };
4201
+ this.stampImportSecrets = async (input, stampWith) => {
4202
+ const activeStamper = this.getStamper(stampWith);
4203
+ if (!activeStamper) {
4204
+ return undefined;
4205
+ }
4206
+ const { organizationId, timestampMs, ...parameters } = input;
4207
+ const session = await this.storageManager?.getActiveSession();
4208
+ const fullUrl = this.config.apiBaseUrl + "/public/v1/submit/import_secrets";
4209
+ const bodyWithType = {
4210
+ parameters,
4211
+ organizationId: organizationId ?? session?.organizationId ?? this.config.organizationId,
4212
+ timestampMs: timestampMs ?? String(Date.now()),
4213
+ type: "ACTIVITY_TYPE_IMPORT_SECRETS",
4214
+ };
4215
+ const stringifiedBody = JSON.stringify(bodyWithType);
4216
+ const stamp = await activeStamper.stamp(stringifiedBody);
4217
+ return {
4218
+ body: stringifiedBody,
4219
+ stamp: stamp,
4220
+ url: fullUrl,
4221
+ };
4222
+ };
4015
4223
  this.importWallet = async (input, stampWith) => {
4016
4224
  const { organizationId, timestampMs, ...rest } = input;
4017
4225
  //@ts-ignore - generateAppProofs does not exist on all request types, so we ignore the type error here for those that are missing it
@@ -5838,6 +6046,9 @@ class TurnkeySDKClientBase {
5838
6046
  if (config.walletStamper) {
5839
6047
  this.walletStamper = config.walletStamper;
5840
6048
  }
6049
+ if (config.attestedStamper) {
6050
+ this.attestedStamper = config.attestedStamper;
6051
+ }
5841
6052
  if (config.storageManager) {
5842
6053
  this.storageManager = config.storageManager;
5843
6054
  }
@@ -5855,6 +6066,9 @@ class TurnkeySDKClientBase {
5855
6066
  else if (this.walletStamper) {
5856
6067
  this.defaultStamperType = enums.StamperType.Wallet;
5857
6068
  }
6069
+ else if (this.attestedStamper) {
6070
+ this.defaultStamperType = enums.StamperType.Attested;
6071
+ }
5858
6072
  else {
5859
6073
  this.defaultStamperType = undefined;
5860
6074
  }
@@ -5872,6 +6086,8 @@ class TurnkeySDKClientBase {
5872
6086
  return this.passkeyStamper;
5873
6087
  case enums.StamperType.Wallet:
5874
6088
  return this.walletStamper;
6089
+ case enums.StamperType.Attested:
6090
+ return this.attestedStamper;
5875
6091
  default:
5876
6092
  return this.apiKeyStamper;
5877
6093
  }
@@ -5902,7 +6118,7 @@ class TurnkeySDKClientBase {
5902
6118
  */
5903
6119
  handleActivityResponse(activityData, resultKey) {
5904
6120
  const { result, status } = activityData.activity;
5905
- if (status === "ACTIVITY_STATUS_COMPLETED" && result) {
6121
+ if (status === sdkTypes.ActivityStatus.COMPLETED && result) {
5906
6122
  // If a specific resultKey was provided, use it
5907
6123
  if (resultKey && result[resultKey]) {
5908
6124
  return {
@@ -5922,6 +6138,52 @@ class TurnkeySDKClientBase {
5922
6138
  }
5923
6139
  return activityData;
5924
6140
  }
6141
+ /**
6142
+ * If the activity requires MFA (AUTHENTICATORS_NEEDED) or consensus
6143
+ * (CONSENSUS_NEEDED) and an onMfaRequired callback is configured, fetch the
6144
+ * MFA statuses for the activity, invoke the callback, and then poll for
6145
+ * completion. Returns the (possibly updated) activity data.
6146
+ * @internal
6147
+ */
6148
+ async handleMfaIfNeeded(activityData, stampWith) {
6149
+ const AUTHENTICATORS_NEEDED = sdkTypes.ActivityStatus.AUTHENTICATORS_NEEDED;
6150
+ // We need to check for CONSENSUS_NEEDED as well, since that can also involve MFA (user is NOT the proposer but has MFA).
6151
+ const CONSENSUS_NEEDED = sdkTypes.ActivityStatus.CONSENSUS_NEEDED;
6152
+ const activityStatus = activityData.activity.status;
6153
+ // Only AUTHENTICATORS_NEEDED and CONSENSUS_NEEDED can involve MFA.
6154
+ // Anything else is returned as-is.
6155
+ if (activityStatus !== AUTHENTICATORS_NEEDED &&
6156
+ activityStatus !== CONSENSUS_NEEDED) {
6157
+ return activityData;
6158
+ }
6159
+ if (!this.config.onMfaRequired) {
6160
+ return activityData;
6161
+ }
6162
+ // Fetch the MFA statuses for this activity.
6163
+ const { mfaStatuses } = await this.getMfaStatus({
6164
+ activityId: activityData.activity.id,
6165
+ organizationId: activityData.activity.organizationId,
6166
+ }, stampWith);
6167
+ // For CONSENSUS_NEEDED there may be no MFA statuses.
6168
+ // In that case, return the activity as-is.
6169
+ if (activityStatus === CONSENSUS_NEEDED &&
6170
+ (!mfaStatuses || mfaStatuses.length === 0)) {
6171
+ return activityData;
6172
+ }
6173
+ const mfaContext = {
6174
+ activityId: activityData.activity.id,
6175
+ fingerprint: activityData.activity.fingerprint,
6176
+ organizationId: activityData.activity.organizationId,
6177
+ activityType: activityData.activity.type,
6178
+ activityStatus,
6179
+ mfaStatuses,
6180
+ };
6181
+ // Await the callback — it should resolve when MFA approval is complete
6182
+ await this.config.onMfaRequired(mfaContext);
6183
+ // After callback resolves, poll for the updated activity status
6184
+ activityData = await this.pollForCompletion(activityData.activity.id, stampWith);
6185
+ return activityData;
6186
+ }
5925
6187
  async request(url, body, stampWith) {
5926
6188
  const fullUrl = this.config.apiBaseUrl + url;
5927
6189
  const stringifiedBody = JSON.stringify(body);
@@ -5961,6 +6223,8 @@ class TurnkeySDKClientBase {
5961
6223
  if (!sdkTypes.TERMINAL_ACTIVITY_STATUSES.includes(activityData.activity.status)) {
5962
6224
  activityData = await this.pollForCompletion(activityData.activity.id, stampWith);
5963
6225
  }
6226
+ // Handle MFA if needed (callback gate + re-poll)
6227
+ activityData = await this.handleMfaIfNeeded(activityData, stampWith);
5964
6228
  return this.handleActivityResponse(activityData, resultKey);
5965
6229
  }
5966
6230
  async activityDecision(url, body, stampWith) {
@@ -6046,6 +6310,8 @@ class TurnkeySDKClientBase {
6046
6310
  if (!sdkTypes.TERMINAL_ACTIVITY_STATUSES.includes(activityData.activity.status)) {
6047
6311
  activityData = await this.pollForCompletion(activityData.activity.id);
6048
6312
  }
6313
+ // Handle MFA if needed (callback gate + re-poll)
6314
+ activityData = await this.handleMfaIfNeeded(activityData);
6049
6315
  return this.handleActivityResponse(activityData, options?.resultKey);
6050
6316
  }
6051
6317
  return data;