@openfort/openfort-node 0.9.2 → 0.10.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 (47) hide show
  1. package/CHANGELOG.md +12 -0
  2. package/dist/index.d.mts +559 -582
  3. package/dist/index.d.ts +559 -582
  4. package/dist/index.js +539 -189
  5. package/dist/index.js.map +1 -1
  6. package/dist/index.mjs +538 -182
  7. package/dist/index.mjs.map +1 -1
  8. package/examples/evm/delegation/sendTransaction.ts +34 -0
  9. package/examples/evm/policies/createAccountPolicy.ts +68 -0
  10. package/examples/evm/policies/createProjectPolicy.ts +53 -0
  11. package/examples/evm/policies/deletePolicy.ts +34 -0
  12. package/examples/evm/policies/getPolicyById.ts +34 -0
  13. package/examples/evm/policies/listAccountPolicies.ts +11 -0
  14. package/examples/evm/policies/listPolicies.ts +11 -0
  15. package/examples/evm/policies/listProjectPolicies.ts +11 -0
  16. package/examples/evm/policies/signTypedDataPolicy.ts +35 -0
  17. package/examples/evm/policies/updatePolicy.ts +44 -0
  18. package/examples/evm/policies/validation.ts +45 -0
  19. package/examples/evm/transactions/sendTransaction.ts +44 -0
  20. package/examples/package.json +13 -0
  21. package/examples/pnpm-lock.yaml +933 -0
  22. package/examples/solana/policies/createSolAllowlistPolicy.ts +27 -0
  23. package/examples/solana/policies/createSolMessagePolicy.ts +29 -0
  24. package/examples/solana/policies/createSplTokenLimitsPolicy.ts +33 -0
  25. package/examples/solana/transactions/sendRawTransaction.ts +23 -0
  26. package/examples/solana/transactions/sendTransaction.ts +37 -0
  27. package/examples/solana/transactions/transfer.ts +44 -0
  28. package/knip.json +10 -1
  29. package/openapi.json +28 -637
  30. package/package.json +42 -4
  31. package/tsconfig.json +3 -4
  32. package/examples/policies/createAccountPolicy.ts +0 -71
  33. package/examples/policies/createEvmPolicy.ts +0 -149
  34. package/examples/policies/createSolanaPolicy.ts +0 -176
  35. package/examples/policies/createTypedDataPolicy.ts +0 -159
  36. package/examples/policies/deletePolicy.ts +0 -34
  37. package/examples/policies/getPolicy.ts +0 -41
  38. package/examples/policies/listPolicies.ts +0 -34
  39. package/examples/policies/multiRulePolicy.ts +0 -133
  40. package/examples/policies/updatePolicy.ts +0 -77
  41. package/examples/policies/validatePolicy.ts +0 -176
  42. /package/examples/{contracts → evm/contracts}/createContract.ts +0 -0
  43. /package/examples/{contracts → evm/contracts}/listContracts.ts +0 -0
  44. /package/examples/{transactions → evm/transactionIntents}/createTransactionIntent.ts +0 -0
  45. /package/examples/{transactions → evm/transactionIntents}/estimateGas.ts +0 -0
  46. /package/examples/{transactions → evm/transactionIntents}/getTransactionIntent.ts +0 -0
  47. /package/examples/{transactions → evm/transactionIntents}/listTransactionIntents.ts +0 -0
package/dist/index.mjs CHANGED
@@ -192,6 +192,15 @@ var AccountNotFoundError = class _AccountNotFoundError extends Error {
192
192
  }
193
193
  }
194
194
  };
195
+ var DelegationError = class _DelegationError extends Error {
196
+ constructor(message) {
197
+ super(message);
198
+ this.name = "DelegationError";
199
+ if (Error.captureStackTrace) {
200
+ Error.captureStackTrace(this, _DelegationError);
201
+ }
202
+ }
203
+ };
195
204
  var EncryptionError = class _EncryptionError extends Error {
196
205
  /**
197
206
  * Initializes a new EncryptionError instance.
@@ -375,7 +384,7 @@ function requiresWalletAuth(requestMethod, requestPath) {
375
384
  }
376
385
 
377
386
  // src/version.ts
378
- var VERSION = "0.9.2";
387
+ var VERSION = "0.10.0";
379
388
  var PACKAGE = "@openfort/openfort-node";
380
389
 
381
390
  // src/openapi-client/openfortApiClient.ts
@@ -979,17 +988,6 @@ var verifyAuthToken = (params, options) => {
979
988
  options
980
989
  );
981
990
  };
982
- var authorize = (authorizePlayerRequest, options) => {
983
- return openfortApiClient(
984
- {
985
- url: `/iam/v1/authorize`,
986
- method: "POST",
987
- headers: { "Content-Type": "application/json" },
988
- data: authorizePlayerRequest
989
- },
990
- options
991
- );
992
- };
993
991
 
994
992
  // src/openapi-client/generated/auth/auth-v2/auth-v2.ts
995
993
  var auth_v2_exports = {};
@@ -1677,17 +1675,6 @@ var unlinkEmail = (unlinkEmailRequest, options) => {
1677
1675
  options
1678
1676
  );
1679
1677
  };
1680
- var loginOIDC = (loginOIDCRequest, options) => {
1681
- return openfortApiClient(
1682
- {
1683
- url: `/iam/v1/oidc/login`,
1684
- method: "POST",
1685
- headers: { "Content-Type": "application/json" },
1686
- data: loginOIDCRequest
1687
- },
1688
- options
1689
- );
1690
- };
1691
1678
  var initOAuth = (oAuthInitRequest, options) => {
1692
1679
  return openfortApiClient(
1693
1680
  {
@@ -1793,16 +1780,6 @@ var me = (options) => {
1793
1780
  };
1794
1781
 
1795
1782
  // src/openapi-client/generated/backend-wallets/backend-wallets.ts
1796
- var listBackendWallets = (params, options) => {
1797
- return openfortApiClient(
1798
- {
1799
- url: `/v2/accounts/backend`,
1800
- method: "GET",
1801
- params
1802
- },
1803
- options
1804
- );
1805
- };
1806
1783
  var createBackendWallet = (createBackendWalletRequest, options) => {
1807
1784
  return openfortApiClient(
1808
1785
  {
@@ -1814,26 +1791,6 @@ var createBackendWallet = (createBackendWalletRequest, options) => {
1814
1791
  options
1815
1792
  );
1816
1793
  };
1817
- var getBackendWallet = (id, options) => {
1818
- return openfortApiClient(
1819
- {
1820
- url: `/v2/accounts/backend/${id}`,
1821
- method: "GET"
1822
- },
1823
- options
1824
- );
1825
- };
1826
- var updateBackendWallet = (id, updateBackendWalletRequest, options) => {
1827
- return openfortApiClient(
1828
- {
1829
- url: `/v2/accounts/backend/${id}`,
1830
- method: "PUT",
1831
- headers: { "Content-Type": "application/json" },
1832
- data: updateBackendWalletRequest
1833
- },
1834
- options
1835
- );
1836
- };
1837
1794
  var deleteBackendWallet = (id, options) => {
1838
1795
  return openfortApiClient(
1839
1796
  {
@@ -2893,23 +2850,6 @@ var CreateEmbeddedRequestChainType = {
2893
2850
  EVM: "EVM",
2894
2851
  SVM: "SVM"
2895
2852
  };
2896
- var BackendWalletResponseObject = {
2897
- backendWallet: "backendWallet"
2898
- };
2899
- var BackendWalletResponseChainType = {
2900
- EVM: "EVM",
2901
- SVM: "SVM"
2902
- };
2903
- var BackendWalletResponseCustody = {
2904
- Developer: "Developer"
2905
- };
2906
- var BackendWalletListResponseObject = {
2907
- list: "list"
2908
- };
2909
- var BackendWalletListQueriesChainType = {
2910
- EVM: "EVM",
2911
- SVM: "SVM"
2912
- };
2913
2853
  var CreateBackendWalletResponseObject = {
2914
2854
  account: "account"
2915
2855
  };
@@ -2921,27 +2861,6 @@ var CreateBackendWalletRequestChainType = {
2921
2861
  EVM: "EVM",
2922
2862
  SVM: "SVM"
2923
2863
  };
2924
- var UpdateBackendWalletResponseObject = {
2925
- backendWallet: "backendWallet"
2926
- };
2927
- var UpdateBackendWalletResponseChainType = {
2928
- EVM: "EVM",
2929
- SVM: "SVM"
2930
- };
2931
- var UpdateBackendWalletResponseCustody = {
2932
- Developer: "Developer"
2933
- };
2934
- var UpdateBackendWalletResponseDelegatedAccountChainChainType = {
2935
- EVM: "EVM",
2936
- SVM: "SVM"
2937
- };
2938
- var UpdateBackendWalletRequestAccountType = {
2939
- Delegated_Account: "Delegated Account"
2940
- };
2941
- var UpdateBackendWalletRequestChainType = {
2942
- EVM: "EVM",
2943
- SVM: "SVM"
2944
- };
2945
2864
  var DeleteBackendWalletResponseObject = {
2946
2865
  backendWallet: "backendWallet"
2947
2866
  };
@@ -3196,10 +3115,6 @@ var ListPoliciesScopeItem = {
3196
3115
  account: "account",
3197
3116
  transaction: "transaction"
3198
3117
  };
3199
- var ListBackendWalletsChainType = {
3200
- EVM: "EVM",
3201
- SVM: "SVM"
3202
- };
3203
3118
  var GetAccountsV2ChainType = {
3204
3119
  EVM: "EVM",
3205
3120
  SVM: "SVM"
@@ -3870,15 +3785,6 @@ var decryptExportedPrivateKey = (encryptedPrivateKeyBase64, privateKeyPem) => {
3870
3785
  return decrypted.toString("hex");
3871
3786
  };
3872
3787
 
3873
- // src/wallets/evm/accounts/evmAccount.ts
3874
- import {
3875
- getTypesForEIP712Domain,
3876
- hashTypedData,
3877
- parseSignature,
3878
- serializeTransaction,
3879
- toPrefixedMessage
3880
- } from "viem";
3881
-
3882
3788
  // src/wallets/evm/actions/normalizeSignature.ts
3883
3789
  function normalizeSignature(sig) {
3884
3790
  const v = parseInt(sig.slice(-2), 16);
@@ -3900,11 +3806,12 @@ async function signHash(options) {
3900
3806
 
3901
3807
  // src/wallets/evm/accounts/evmAccount.ts
3902
3808
  function toEvmAccount(data) {
3903
- const { id, address } = data;
3809
+ const { id, address, walletId } = data;
3904
3810
  const account = {
3905
3811
  id,
3906
3812
  address,
3907
3813
  custody: "Developer",
3814
+ walletId,
3908
3815
  async sign(parameters) {
3909
3816
  const result = await signHash({
3910
3817
  accountId: id,
@@ -3913,29 +3820,53 @@ function toEvmAccount(data) {
3913
3820
  return result.signature;
3914
3821
  },
3915
3822
  async signMessage(parameters) {
3823
+ let viem;
3824
+ try {
3825
+ viem = await import("viem");
3826
+ } catch {
3827
+ throw new UserInputValidationError(
3828
+ "`viem` is required for signMessage. Install it and try again."
3829
+ );
3830
+ }
3916
3831
  const { message } = parameters;
3917
- const preimage = toPrefixedMessage(message);
3832
+ const preimage = viem.toPrefixedMessage(message);
3918
3833
  const result = await sign(id, { data: preimage });
3919
- return result.signature;
3834
+ return normalizeSignature(result.signature);
3920
3835
  },
3921
3836
  async signTransaction(transaction) {
3922
- const serialized = serializeTransaction(transaction);
3837
+ let viem;
3838
+ try {
3839
+ viem = await import("viem");
3840
+ } catch {
3841
+ throw new UserInputValidationError(
3842
+ "`viem` is required for signTransaction. Install it and try again."
3843
+ );
3844
+ }
3845
+ const serialized = viem.serializeTransaction(transaction);
3923
3846
  const response = await sign(id, { data: serialized });
3924
- const signature2 = parseSignature(response.signature);
3925
- const signedTransaction = serializeTransaction(
3847
+ const signature2 = viem.parseSignature(response.signature);
3848
+ const signedTransaction = viem.serializeTransaction(
3926
3849
  transaction,
3927
3850
  signature2
3928
3851
  );
3929
3852
  return signedTransaction;
3930
3853
  },
3931
3854
  async signTypedData(parameters) {
3855
+ let viem;
3856
+ try {
3857
+ viem = await import("viem");
3858
+ } catch {
3859
+ throw new UserInputValidationError(
3860
+ "`viem` is required for signTypedData. Install it and try again."
3861
+ );
3862
+ }
3932
3863
  const {
3933
3864
  domain = {},
3934
3865
  message,
3935
3866
  primaryType
3936
3867
  } = parameters;
3937
3868
  const types = {
3938
- EIP712Domain: getTypesForEIP712Domain({ domain }),
3869
+ EIP712Domain: viem.getTypesForEIP712Domain({ domain }),
3939
3870
  ...parameters.types
3940
3871
  };
3941
3872
  const openApiMessage = {
@@ -3944,9 +3875,9 @@ function toEvmAccount(data) {
3944
3875
  primaryType,
3945
3876
  message
3946
3877
  };
3947
- const hash = hashTypedData(openApiMessage);
3878
+ const hash = viem.hashTypedData(openApiMessage);
3948
3879
  const result = await sign(id, { data: hash });
3949
- return result.signature;
3880
+ return normalizeSignature(result.signature);
3950
3881
  }
3951
3882
  };
3952
3883
  return account;
@@ -3956,7 +3887,8 @@ function toEvmAccount(data) {
3956
3887
  function toEvmAccountData(response) {
3957
3888
  return {
3958
3889
  id: response.id,
3959
- address: response.address
3890
+ address: response.address,
3891
+ walletId: response.wallet
3960
3892
  };
3961
3893
  }
3962
3894
  var EvmClient = class {
@@ -3996,7 +3928,8 @@ var EvmClient = class {
3996
3928
  });
3997
3929
  return toEvmAccount({
3998
3930
  id: response.id,
3999
- address: response.address
3931
+ address: response.address,
3932
+ walletId: response.walletId
4000
3933
  });
4001
3934
  }
4002
3935
  /**
@@ -4024,13 +3957,17 @@ var EvmClient = class {
4024
3957
  );
4025
3958
  }
4026
3959
  if (options.id) {
4027
- const response = await getBackendWallet(options.id);
3960
+ const response = await getAccountV2(options.id);
3961
+ if (response.custody !== "Developer") {
3962
+ throw new AccountNotFoundError();
3963
+ }
4028
3964
  return toEvmAccount(toEvmAccountData(response));
4029
3965
  }
4030
3966
  if (options.address) {
4031
- const wallets = await listBackendWallets({
3967
+ const wallets = await getAccountsV2({
4032
3968
  address: options.address,
4033
3969
  chainType: "EVM",
3970
+ custody: "Developer",
4034
3971
  limit: 1
4035
3972
  });
4036
3973
  if (wallets.data.length === 0) {
@@ -4040,6 +3977,21 @@ var EvmClient = class {
4040
3977
  }
4041
3978
  throw new AccountNotFoundError();
4042
3979
  }
3980
+ /**
3981
+ * Retrieves delegated accounts linked to an EVM address on a specific chain.
3982
+ *
3983
+ * @param options - Options containing the address and chain ID
3984
+ * @returns List of linked accounts
3985
+ */
3986
+ async getLinkedAccounts(options) {
3987
+ const response = await getAccountsV2({
3988
+ address: options.address,
3989
+ accountType: "Delegated Account",
3990
+ chainType: "EVM",
3991
+ chainId: options.chainId
3992
+ });
3993
+ return response;
3994
+ }
4043
3995
  /**
4044
3996
  * Lists all EVM backend wallets.
4045
3997
  *
@@ -4054,10 +4006,11 @@ var EvmClient = class {
4054
4006
  * ```
4055
4007
  */
4056
4008
  async listAccounts(options = {}) {
4057
- const response = await listBackendWallets({
4009
+ const response = await getAccountsV2({
4058
4010
  limit: options.limit,
4059
4011
  skip: options.skip,
4060
- chainType: "EVM"
4012
+ chainType: "EVM",
4013
+ custody: "Developer"
4061
4014
  });
4062
4015
  const accounts = response.data.map(
4063
4016
  (wallet) => toEvmAccount(toEvmAccountData(wallet))
@@ -4104,7 +4057,8 @@ var EvmClient = class {
4104
4057
  });
4105
4058
  return toEvmAccount({
4106
4059
  id: response.id,
4107
- address: response.address
4060
+ address: response.address,
4061
+ walletId: response.walletId
4108
4062
  });
4109
4063
  } catch (error) {
4110
4064
  if (error instanceof UserInputValidationError) {
@@ -4161,34 +4115,204 @@ var EvmClient = class {
4161
4115
  });
4162
4116
  return response.signature;
4163
4117
  }
4164
- /**
4165
- * Updates an EVM backend wallet.
4166
- *
4167
- * Currently supports upgrading an EVM EOA to a Delegated Account (EIP-7702).
4168
- *
4169
- * @param options - Update options including account ID and delegation parameters
4170
- * @returns The updated backend wallet response
4171
- *
4172
- * @example
4173
- * ```typescript
4174
- * const updated = await openfort.accounts.evm.backend.update({
4175
- * id: 'acc_...',
4176
- * accountType: 'Delegated Account',
4177
- * chain: { chainType: 'EVM', chainId: 8453 },
4178
- * implementationType: 'Calibur',
4179
- * });
4180
- * ```
4181
- */
4182
- async update(options) {
4183
- const { id, ...req } = options;
4184
- return updateBackendWallet(id, req);
4185
- }
4186
4118
  };
4187
4119
  EvmClient.type = "evmWallet";
4188
4120
 
4189
4121
  // src/wallets/solana/solanaClient.ts
4190
4122
  import bs58 from "bs58";
4191
4123
 
4124
+ // src/wallets/solana/actions/constants.ts
4125
+ var USDC_MAINNET_MINT_ADDRESS = "EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v";
4126
+ var USDC_DEVNET_MINT_ADDRESS = "4zMMC9srt5Ri5X14GAgXhaHii3GnPAEERYPJgZJDncDU";
4127
+ var DEFAULT_COMPUTE_UNIT_LIMIT = 2e5;
4128
+ var DEFAULT_COMPUTE_UNIT_PRICE = 50000n;
4129
+
4130
+ // src/wallets/solana/actions/utils.ts
4131
+ function getUsdcMintAddress(cluster) {
4132
+ if (cluster === "mainnet-beta") {
4133
+ return USDC_MAINNET_MINT_ADDRESS;
4134
+ }
4135
+ return USDC_DEVNET_MINT_ADDRESS;
4136
+ }
4137
+ function getRpcEndpoint(cluster) {
4138
+ return cluster === "mainnet-beta" ? "https://api.mainnet-beta.solana.com" : "https://api.devnet.solana.com";
4139
+ }
4140
+ function getWsEndpoint(cluster) {
4141
+ return cluster === "mainnet-beta" ? "wss://api.mainnet-beta.solana.com" : "wss://api.devnet.solana.com";
4142
+ }
4143
+
4144
+ // src/wallets/solana/actions/sendTransaction.ts
4145
+ async function sendTransaction(options) {
4146
+ const {
4147
+ account,
4148
+ cluster,
4149
+ instructions,
4150
+ computeUnitLimit,
4151
+ computeUnitPrice,
4152
+ rpcUrl,
4153
+ wsUrl
4154
+ } = options;
4155
+ let solanaKit;
4156
+ let computeBudget;
4157
+ let transactionConfirmation;
4158
+ let koraModule;
4159
+ try {
4160
+ solanaKit = await import("@solana/kit");
4161
+ } catch {
4162
+ throw new UserInputValidationError(
4163
+ "`@solana/kit` is required for sendTransaction. Install it and try again."
4164
+ );
4165
+ }
4166
+ try {
4167
+ computeBudget = await import("@solana-program/compute-budget");
4168
+ } catch {
4169
+ throw new UserInputValidationError(
4170
+ "`@solana-program/compute-budget` is required for sendTransaction. Install it and try again."
4171
+ );
4172
+ }
4173
+ try {
4174
+ koraModule = await import("@solana/kora");
4175
+ } catch {
4176
+ throw new UserInputValidationError(
4177
+ "`@solana/kora` is required for sendTransaction. Install it and try again."
4178
+ );
4179
+ }
4180
+ try {
4181
+ transactionConfirmation = await import("@solana/transaction-confirmation");
4182
+ } catch {
4183
+ throw new UserInputValidationError(
4184
+ "`@solana/transaction-confirmation` is required for sendTransaction. Install it and try again."
4185
+ );
4186
+ }
4187
+ const userAddress = solanaKit.address(account.address);
4188
+ const clientConfig2 = getConfig();
4189
+ if (!clientConfig2?.publishableKey) {
4190
+ throw new MissingPublishableKeyError("sendTransaction");
4191
+ }
4192
+ const basePath = clientConfig2.basePath || "https://api.openfort.io";
4193
+ const client = new koraModule.KoraClient({
4194
+ rpcUrl: `${basePath}/rpc/solana/${cluster}`,
4195
+ apiKey: `Bearer ${clientConfig2.publishableKey}`
4196
+ });
4197
+ const rpc = solanaKit.createSolanaRpc(rpcUrl ?? getRpcEndpoint(cluster));
4198
+ const rpcSubscriptions = solanaKit.createSolanaRpcSubscriptions(
4199
+ wsUrl ?? getWsEndpoint(cluster)
4200
+ );
4201
+ const confirmTransaction = transactionConfirmation.createRecentSignatureConfirmationPromiseFactory({
4202
+ rpc,
4203
+ rpcSubscriptions
4204
+ });
4205
+ const { signer_address } = await client.getPayerSigner();
4206
+ const blockhashResponse = await client.getBlockhash();
4207
+ let txMsg = solanaKit.pipe(
4208
+ solanaKit.createTransactionMessage({ version: 0 }),
4209
+ (tx) => solanaKit.setTransactionMessageFeePayer(
4210
+ solanaKit.address(signer_address),
4211
+ tx
4212
+ ),
4213
+ // Kora's getBlockhash does not return lastValidBlockHeight, so we use 0n.
4214
+ // Transaction expiry is handled by the confirmTransaction timeout instead.
4215
+ (tx) => solanaKit.setTransactionMessageLifetimeUsingBlockhash(
4216
+ {
4217
+ blockhash: blockhashResponse.blockhash,
4218
+ lastValidBlockHeight: 0n
4219
+ },
4220
+ tx
4221
+ ),
4222
+ (tx) => solanaKit.appendTransactionMessageInstructions(instructions, tx),
4223
+ (tx) => computeBudget.updateOrAppendSetComputeUnitPriceInstruction(
4224
+ computeUnitPrice ?? DEFAULT_COMPUTE_UNIT_PRICE,
4225
+ tx
4226
+ ),
4227
+ (tx) => computeBudget.updateOrAppendSetComputeUnitLimitInstruction(
4228
+ computeUnitLimit ?? DEFAULT_COMPUTE_UNIT_LIMIT,
4229
+ tx
4230
+ )
4231
+ );
4232
+ if (computeUnitLimit === void 0) {
4233
+ const estimateComputeUnitLimit = computeBudget.estimateComputeUnitLimitFactory({ rpc });
4234
+ try {
4235
+ const estimatedLimit = await estimateComputeUnitLimit(txMsg);
4236
+ txMsg = computeBudget.updateOrAppendSetComputeUnitLimitInstruction(
4237
+ estimatedLimit,
4238
+ txMsg
4239
+ );
4240
+ } catch {
4241
+ }
4242
+ }
4243
+ const compiled = solanaKit.compileTransaction(txMsg);
4244
+ const messageBase64 = Buffer.from(
4245
+ compiled.messageBytes
4246
+ ).toString("base64");
4247
+ const signatureHex = await account.signTransaction({
4248
+ transaction: messageBase64
4249
+ });
4250
+ const sigBytes = new Uint8Array(
4251
+ Buffer.from(signatureHex.replace(/^0x/, ""), "hex")
4252
+ );
4253
+ const EMPTY_SIGNATURE = new Uint8Array(64);
4254
+ const signatures = Object.fromEntries(
4255
+ Object.entries(compiled.signatures).map(([addr]) => [
4256
+ addr,
4257
+ addr === userAddress ? sigBytes : EMPTY_SIGNATURE
4258
+ ])
4259
+ );
4260
+ const signed = { ...compiled, signatures };
4261
+ const base64Full = solanaKit.getBase64EncodedWireTransaction(signed);
4262
+ const { signed_transaction } = await client.signTransaction({
4263
+ transaction: base64Full,
4264
+ signer_key: signer_address
4265
+ });
4266
+ const signature2 = await rpc.sendTransaction(
4267
+ signed_transaction,
4268
+ { encoding: "base64" }
4269
+ ).send();
4270
+ await confirmTransaction({
4271
+ commitment: "confirmed",
4272
+ signature: signature2,
4273
+ abortSignal: AbortSignal.timeout(6e4)
4274
+ });
4275
+ return { signature: signature2 };
4276
+ }
4277
+
4278
+ // src/wallets/solana/actions/sendRawTransaction.ts
4279
+ async function sendRawTransaction(options) {
4280
+ const {
4281
+ account,
4282
+ cluster,
4283
+ transaction,
4284
+ computeUnitLimit,
4285
+ computeUnitPrice,
4286
+ rpcUrl,
4287
+ wsUrl
4288
+ } = options;
4289
+ let solanaKit;
4290
+ try {
4291
+ solanaKit = await import("@solana/kit");
4292
+ } catch {
4293
+ throw new UserInputValidationError(
4294
+ "`@solana/kit` is required for sendRawTransaction. Install it and try again."
4295
+ );
4296
+ }
4297
+ const txBytes = new Uint8Array(Buffer.from(transaction, "base64"));
4298
+ const decoded = solanaKit.getTransactionDecoder().decode(txBytes);
4299
+ const compiledMessage = solanaKit.getCompiledTransactionMessageDecoder().decode(decoded.messageBytes);
4300
+ const rpc = solanaKit.createSolanaRpc(rpcUrl ?? getRpcEndpoint(cluster));
4301
+ const decompiled = await solanaKit.decompileTransactionMessageFetchingLookupTables(
4302
+ compiledMessage,
4303
+ rpc
4304
+ );
4305
+ return sendTransaction({
4306
+ account,
4307
+ cluster,
4308
+ instructions: [...decompiled.instructions],
4309
+ computeUnitLimit,
4310
+ computeUnitPrice,
4311
+ rpcUrl,
4312
+ wsUrl
4313
+ });
4314
+ }
4315
+
4192
4316
  // src/wallets/solana/actions/signMessage.ts
4193
4317
  async function signMessage(options) {
4194
4318
  const { accountId, message } = options;
@@ -4211,6 +4335,150 @@ async function signTransaction(options) {
4211
4335
  };
4212
4336
  }
4213
4337
 
4338
+ // src/wallets/solana/actions/rpc.ts
4339
+ async function createRpcClient(cluster, rpcUrl) {
4340
+ let solanaKit;
4341
+ try {
4342
+ solanaKit = await import("@solana/kit");
4343
+ } catch {
4344
+ throw new UserInputValidationError(
4345
+ "`@solana/kit` is required. Install it and try again."
4346
+ );
4347
+ }
4348
+ return solanaKit.createSolanaRpc(rpcUrl ?? getRpcEndpoint(cluster));
4349
+ }
4350
+
4351
+ // src/wallets/solana/actions/transfer.ts
4352
+ async function transfer(options) {
4353
+ const { account, cluster, rpcUrl, ...rest } = options;
4354
+ const rpc = await createRpcClient(cluster, rpcUrl);
4355
+ const instructions = !options.token || options.token.toLowerCase() === "sol" ? await getNativeTransferInstructions({
4356
+ from: account.address,
4357
+ to: options.to,
4358
+ amount: options.amount
4359
+ }) : await getSplTransferInstructions({
4360
+ rpc,
4361
+ from: account.address,
4362
+ to: options.to,
4363
+ mintAddress: options.token.toLowerCase() === "usdc" ? getUsdcMintAddress(cluster) : options.token,
4364
+ amount: options.amount
4365
+ });
4366
+ return sendTransaction({
4367
+ account,
4368
+ cluster,
4369
+ instructions,
4370
+ rpcUrl,
4371
+ computeUnitLimit: rest.computeUnitLimit,
4372
+ computeUnitPrice: rest.computeUnitPrice,
4373
+ wsUrl: rest.wsUrl
4374
+ });
4375
+ }
4376
+ async function getNativeTransferInstructions({
4377
+ from,
4378
+ to,
4379
+ amount
4380
+ }) {
4381
+ let solanaKit;
4382
+ let systemProgram;
4383
+ try {
4384
+ solanaKit = await import("@solana/kit");
4385
+ } catch {
4386
+ throw new UserInputValidationError(
4387
+ "`@solana/kit` is required for transfer. Install it and try again."
4388
+ );
4389
+ }
4390
+ try {
4391
+ systemProgram = await import("@solana-program/system");
4392
+ } catch {
4393
+ throw new UserInputValidationError(
4394
+ "`@solana-program/system` is required for SOL transfers. Install it and try again."
4395
+ );
4396
+ }
4397
+ const fromAddr = solanaKit.address(from);
4398
+ const toAddr = solanaKit.address(to);
4399
+ return [
4400
+ systemProgram.getTransferSolInstruction({
4401
+ source: solanaKit.createNoopSigner(fromAddr),
4402
+ destination: toAddr,
4403
+ amount
4404
+ })
4405
+ ];
4406
+ }
4407
+ async function getSplTransferInstructions({
4408
+ rpc,
4409
+ from,
4410
+ to,
4411
+ mintAddress,
4412
+ amount
4413
+ }) {
4414
+ let solanaKit;
4415
+ let tokenProgram;
4416
+ try {
4417
+ solanaKit = await import("@solana/kit");
4418
+ } catch {
4419
+ throw new UserInputValidationError(
4420
+ "`@solana/kit` is required for transfer. Install it and try again."
4421
+ );
4422
+ }
4423
+ try {
4424
+ tokenProgram = await import("@solana-program/token");
4425
+ } catch {
4426
+ throw new UserInputValidationError(
4427
+ "`@solana-program/token` is required for SPL transfers. Install it and try again."
4428
+ );
4429
+ }
4430
+ const fromAddr = solanaKit.address(from);
4431
+ const toAddr = solanaKit.address(to);
4432
+ const mintAddr = solanaKit.address(mintAddress);
4433
+ const mintInfo = await tokenProgram.fetchMint(rpc, mintAddr).catch(() => {
4434
+ throw new UserInputValidationError(
4435
+ `Failed to fetch mint account for ${mintAddress}. Verify the mint address is correct.`
4436
+ );
4437
+ });
4438
+ const [sourceAta] = await tokenProgram.findAssociatedTokenPda({
4439
+ mint: mintAddr,
4440
+ owner: fromAddr,
4441
+ tokenProgram: tokenProgram.TOKEN_PROGRAM_ADDRESS
4442
+ });
4443
+ const [destAta] = await tokenProgram.findAssociatedTokenPda({
4444
+ mint: mintAddr,
4445
+ owner: toAddr,
4446
+ tokenProgram: tokenProgram.TOKEN_PROGRAM_ADDRESS
4447
+ });
4448
+ const sourceAcct = await tokenProgram.fetchToken(rpc, sourceAta).catch(() => {
4449
+ throw new UserInputValidationError(
4450
+ `Source account has no token account for mint ${mintAddress}`
4451
+ );
4452
+ });
4453
+ if (sourceAcct.data.amount < amount) {
4454
+ throw new UserInputValidationError(
4455
+ `Insufficient token balance: have ${sourceAcct.data.amount}, need ${amount}`
4456
+ );
4457
+ }
4458
+ const instructions = [];
4459
+ const destAccountInfo = await rpc.getAccountInfo(destAta, { encoding: "base64" }).send();
4460
+ if (!destAccountInfo.value) {
4461
+ const createDestIx = await tokenProgram.getCreateAssociatedTokenInstructionAsync({
4462
+ payer: solanaKit.createNoopSigner(fromAddr),
4463
+ owner: toAddr,
4464
+ ata: destAta,
4465
+ mint: mintAddr
4466
+ });
4467
+ instructions.push(createDestIx);
4468
+ }
4469
+ instructions.push(
4470
+ tokenProgram.getTransferCheckedInstruction({
4471
+ source: sourceAta,
4472
+ mint: mintAddr,
4473
+ destination: destAta,
4474
+ authority: solanaKit.createNoopSigner(fromAddr),
4475
+ amount,
4476
+ decimals: mintInfo.data.decimals
4477
+ })
4478
+ );
4479
+ return instructions;
4480
+ }
4481
+
4214
4482
  // src/wallets/solana/accounts/solanaAccount.ts
4215
4483
  function toSolanaAccount(data) {
4216
4484
  const { id, address } = data;
@@ -4231,6 +4499,12 @@ function toSolanaAccount(data) {
4231
4499
  transaction: parameters.transaction
4232
4500
  });
4233
4501
  return result.signedTransaction;
4502
+ },
4503
+ async transfer(options) {
4504
+ return transfer({ ...options, account });
4505
+ },
4506
+ async sendRawTransaction(options) {
4507
+ return sendRawTransaction({ ...options, account });
4234
4508
  }
4235
4509
  };
4236
4510
  return account;
@@ -4308,13 +4582,14 @@ var SolanaClient = class {
4308
4582
  );
4309
4583
  }
4310
4584
  if (options.id) {
4311
- const response = await getBackendWallet(options.id);
4585
+ const response = await getAccountV2(options.id);
4312
4586
  return toSolanaAccount(toSolanaAccountData(response));
4313
4587
  }
4314
4588
  if (options.address) {
4315
- const wallets = await listBackendWallets({
4589
+ const wallets = await getAccountsV2({
4316
4590
  address: options.address,
4317
4591
  chainType: "SVM",
4592
+ custody: "Developer",
4318
4593
  limit: 1
4319
4594
  });
4320
4595
  if (wallets.data.length === 0) {
@@ -4338,10 +4613,11 @@ var SolanaClient = class {
4338
4613
  * ```
4339
4614
  */
4340
4615
  async listAccounts(options = {}) {
4341
- const response = await listBackendWallets({
4616
+ const response = await getAccountsV2({
4342
4617
  limit: options.limit,
4343
4618
  skip: options.skip,
4344
- chainType: "SVM"
4619
+ chainType: "SVM",
4620
+ custody: "Developer"
4345
4621
  });
4346
4622
  const accounts = response.data.map(
4347
4623
  (wallet) => toSolanaAccount(toSolanaAccountData(wallet))
@@ -4459,11 +4735,110 @@ var SolanaClient = class {
4459
4735
  return response.signature;
4460
4736
  }
4461
4737
  };
4738
+ /** Wallet type identifier used for client registration */
4462
4739
  SolanaClient.type = "solanaWallet";
4463
4740
 
4464
4741
  // src/index.ts
4465
4742
  import { ShieldAuthProvider as ShieldAuthProvider2 } from "@openfort/shield-js";
4466
4743
 
4744
+ // src/wallets/evm/actions/updateToDelegated.ts
4745
+ async function update(options) {
4746
+ const { chainId, walletId, implementationType, accountId } = options;
4747
+ return createAccountV2({
4748
+ accountType: "Delegated Account",
4749
+ chainType: "EVM",
4750
+ chainId,
4751
+ user: walletId,
4752
+ implementationType,
4753
+ account: accountId
4754
+ });
4755
+ }
4756
+
4757
+ // src/wallets/evm/actions/sendTransaction.ts
4758
+ async function sendTransaction2(options) {
4759
+ let viem;
4760
+ let viemChains;
4761
+ let viemUtils;
4762
+ try {
4763
+ viem = await import("viem");
4764
+ } catch {
4765
+ throw new UserInputValidationError(
4766
+ "`viem` is required for sendTransaction. Install it and try again."
4767
+ );
4768
+ }
4769
+ try {
4770
+ viemChains = await import("viem/chains");
4771
+ } catch {
4772
+ throw new UserInputValidationError(
4773
+ "`viem` is required for sendTransaction. Install it and try again."
4774
+ );
4775
+ }
4776
+ try {
4777
+ viemUtils = await import("viem/utils");
4778
+ } catch {
4779
+ throw new UserInputValidationError(
4780
+ "`viem` is required for sendTransaction. Install it and try again."
4781
+ );
4782
+ }
4783
+ const { account, chainId, interactions, policy, rpcUrl } = options;
4784
+ const transport = rpcUrl ? viem.http(rpcUrl) : viem.http();
4785
+ const allChains = Object.values(viemChains);
4786
+ const chain = allChains.find(
4787
+ (c) => typeof c === "object" && c !== null && "id" in c && c.id === chainId
4788
+ );
4789
+ if (!chain) {
4790
+ throw new DelegationError(
4791
+ `Unknown chain ID ${chainId}. Provide a custom rpcUrl for unsupported chains.`
4792
+ );
4793
+ }
4794
+ let signedAuthorization;
4795
+ let txAccountId;
4796
+ const response = await getAccountsV2({
4797
+ address: viem.getAddress(account.address),
4798
+ accountType: "Delegated Account",
4799
+ chainType: "EVM",
4800
+ chainId
4801
+ });
4802
+ if (response.data.length === 0) {
4803
+ const updated = await update({
4804
+ walletId: account.walletId,
4805
+ chainId,
4806
+ implementationType: "Calibur",
4807
+ accountId: account.id
4808
+ });
4809
+ txAccountId = updated.id;
4810
+ const implementationAddress = "0x000000009b1d0af20d8c6d0a44e162d11f9b8f00";
4811
+ const publicClient = viem.createPublicClient({ chain, transport });
4812
+ const eoaNonce = await publicClient.getTransactionCount({
4813
+ address: account.address
4814
+ });
4815
+ const authHash = viemUtils.hashAuthorization({
4816
+ contractAddress: implementationAddress,
4817
+ chainId,
4818
+ nonce: eoaNonce
4819
+ });
4820
+ signedAuthorization = await account.sign({ hash: authHash });
4821
+ } else {
4822
+ txAccountId = response.data[0].id;
4823
+ }
4824
+ const txIntent = await createTransactionIntent({
4825
+ chainId,
4826
+ account: txAccountId,
4827
+ policy,
4828
+ signedAuthorization,
4829
+ interactions
4830
+ });
4831
+ if (!txIntent.nextAction?.payload?.signableHash) {
4832
+ return txIntent;
4833
+ }
4834
+ const txSignature = await account.sign({
4835
+ hash: txIntent.nextAction.payload.signableHash
4836
+ });
4837
+ return signature(txIntent.id, {
4838
+ signature: txSignature
4839
+ });
4840
+ }
4841
+
4467
4842
  // src/policies/evmSchema.ts
4468
4843
  import { z } from "zod";
4469
4844
  var EthValueOperatorEnum = z.enum(["<=", ">=", "<", ">"]);
@@ -4769,19 +5144,6 @@ var UpdatePolicyBodySchema = z3.object({
4769
5144
  rules: z3.array(RuleSchema).min(1).max(10).optional()
4770
5145
  });
4771
5146
 
4772
- // src/wallets/evm/actions/signMessage.ts
4773
- import { toHex, toPrefixedMessage as toPrefixedMessage2 } from "viem";
4774
-
4775
- // src/wallets/evm/actions/signTransaction.ts
4776
- import {
4777
- keccak256,
4778
- parseSignature as parseSignature2,
4779
- serializeTransaction as serializeTransaction2
4780
- } from "viem";
4781
-
4782
- // src/wallets/evm/actions/signTypedData.ts
4783
- import { hashTypedData as hashTypedData2 } from "viem";
4784
-
4785
5147
  // src/index.ts
4786
5148
  function isValidSecretKey(key) {
4787
5149
  return key.startsWith("sk_test_") || key.startsWith("sk_live_");
@@ -4877,7 +5239,9 @@ var Openfort = class {
4877
5239
  /** Export private key (with E2E encryption) */
4878
5240
  export: evmClient.exportAccount.bind(evmClient),
4879
5241
  /** Update EOA to delegated account */
4880
- update: evmClient.update.bind(evmClient)
5242
+ update,
5243
+ /** Delegate + create + sign + submit a gasless transaction in one call */
5244
+ sendTransaction: sendTransaction2
4881
5245
  },
4882
5246
  /** Embedded wallet operations (User custody) */
4883
5247
  embedded: {
@@ -4906,7 +5270,13 @@ var Openfort = class {
4906
5270
  /** Import private key (with E2E encryption) */
4907
5271
  import: solanaClient.importAccount.bind(solanaClient),
4908
5272
  /** Export private key (with E2E encryption) */
4909
- export: solanaClient.exportAccount.bind(solanaClient)
5273
+ export: solanaClient.exportAccount.bind(solanaClient),
5274
+ /** Send a gasless transaction via Kora */
5275
+ sendTransaction,
5276
+ /** Send a pre-built base64 transaction via Kora gasless flow */
5277
+ sendRawTransaction,
5278
+ /** Transfer SOL or SPL tokens (high-level) */
5279
+ transfer
4910
5280
  },
4911
5281
  /** Embedded wallet operations (User custody) */
4912
5282
  embedded: {
@@ -5097,10 +5467,14 @@ var Openfort = class {
5097
5467
  * gas costs are sponsored according to the policy's strategy.
5098
5468
  */
5099
5469
  get transactionIntents() {
5470
+ if (!this._evmClient) {
5471
+ this._evmClient = new EvmClient();
5472
+ }
5473
+ const _evmClient = this._evmClient;
5100
5474
  return {
5101
5475
  /** List transaction intents */
5102
5476
  list: getTransactionIntents,
5103
- /** Create a transaction intent with contract interactions */
5477
+ /** Create a transaction intent with contract interactions. */
5104
5478
  create: createTransactionIntent,
5105
5479
  /** Get a transaction intent by ID */
5106
5480
  get: getTransactionIntent,
@@ -5245,9 +5619,7 @@ var Openfort = class {
5245
5619
  /** Verify auth token */
5246
5620
  verifyToken: verifyAuthToken,
5247
5621
  /** Verify OAuth token */
5248
- verifyOAuthToken,
5249
- /** Authorize */
5250
- authorize
5622
+ verifyOAuthToken
5251
5623
  }
5252
5624
  };
5253
5625
  }
@@ -5455,11 +5827,6 @@ export {
5455
5827
  AuthProviderResponseV2,
5456
5828
  AuthenticateOAuthRequestProvider,
5457
5829
  AuthenticationType,
5458
- BackendWalletListQueriesChainType,
5459
- BackendWalletListResponseObject,
5460
- BackendWalletResponseChainType,
5461
- BackendWalletResponseCustody,
5462
- BackendWalletResponseObject,
5463
5830
  BasicAuthProvider,
5464
5831
  BasicAuthProviderEMAIL,
5465
5832
  BasicAuthProviderGUEST,
@@ -5487,6 +5854,7 @@ export {
5487
5854
  CriteriaOperatorNOTIN,
5488
5855
  CriteriaType,
5489
5856
  Currency,
5857
+ DelegationError,
5490
5858
  DeleteBackendWalletResponseObject,
5491
5859
  DeveloperAccountResponseExpandable,
5492
5860
  EmailTypeRequest,
@@ -5571,7 +5939,6 @@ export {
5571
5939
  JsonRpcErrorResponseJsonrpc,
5572
5940
  JsonRpcRequestJsonrpc,
5573
5941
  JsonRpcSuccessResponseAnyJsonrpc,
5574
- ListBackendWalletsChainType,
5575
5942
  ListPoliciesScopeItem,
5576
5943
  MintAddressCriterionOperator,
5577
5944
  MintAddressCriterionRequestOperator,
@@ -5701,12 +6068,6 @@ export {
5701
6068
  TransactionIntentResponseExpandable,
5702
6069
  TransactionStatus,
5703
6070
  UnknownError,
5704
- UpdateBackendWalletRequestAccountType,
5705
- UpdateBackendWalletRequestChainType,
5706
- UpdateBackendWalletResponseChainType,
5707
- UpdateBackendWalletResponseCustody,
5708
- UpdateBackendWalletResponseDelegatedAccountChainChainType,
5709
- UpdateBackendWalletResponseObject,
5710
6071
  UpdatePolicyBodySchema,
5711
6072
  UsageAlertType,
5712
6073
  UserInputValidationError,
@@ -5719,7 +6080,6 @@ export {
5719
6080
  auth_v2_exports as authApi,
5720
6081
  openfortAuth_schemas_exports as authSchemas,
5721
6082
  authenticateSIWE,
5722
- authorize,
5723
6083
  callbackOAuth,
5724
6084
  cancelTransferAccountOwnership,
5725
6085
  configure,
@@ -5782,7 +6142,6 @@ export {
5782
6142
  getAuthPlayers,
5783
6143
  getAuthUser,
5784
6144
  getAuthUsers,
5785
- getBackendWallet,
5786
6145
  getConfig,
5787
6146
  getContract,
5788
6147
  getContracts,
@@ -5831,7 +6190,6 @@ export {
5831
6190
  linkSIWE,
5832
6191
  linkThirdParty,
5833
6192
  list,
5834
- listBackendWallets,
5835
6193
  listFeeSponsorships,
5836
6194
  listForwarderContracts,
5837
6195
  listOAuthConfig,
@@ -5839,7 +6197,6 @@ export {
5839
6197
  listPolicies,
5840
6198
  listSubscriptionLogs,
5841
6199
  loginEmailPassword,
5842
- loginOIDC,
5843
6200
  loginWithIdToken,
5844
6201
  logout,
5845
6202
  me,
@@ -5873,7 +6230,6 @@ export {
5873
6230
  unlinkEmail,
5874
6231
  unlinkOAuth,
5875
6232
  unlinkSIWE,
5876
- updateBackendWallet,
5877
6233
  updateContract,
5878
6234
  updateDeveloperAccount,
5879
6235
  updateFeeSponsorship,