@openfort/openfort-node 0.9.1 → 0.9.3

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/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.1";
387
+ var VERSION = "0.9.3";
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"
@@ -3900,11 +3815,12 @@ async function signHash(options) {
3900
3815
 
3901
3816
  // src/wallets/evm/accounts/evmAccount.ts
3902
3817
  function toEvmAccount(data) {
3903
- const { id, address } = data;
3818
+ const { id, address, walletId } = data;
3904
3819
  const account = {
3905
3820
  id,
3906
3821
  address,
3907
3822
  custody: "Developer",
3823
+ walletId,
3908
3824
  async sign(parameters) {
3909
3825
  const result = await signHash({
3910
3826
  accountId: id,
@@ -3956,7 +3872,8 @@ function toEvmAccount(data) {
3956
3872
  function toEvmAccountData(response) {
3957
3873
  return {
3958
3874
  id: response.id,
3959
- address: response.address
3875
+ address: response.address,
3876
+ walletId: response.wallet
3960
3877
  };
3961
3878
  }
3962
3879
  var EvmClient = class {
@@ -3996,7 +3913,8 @@ var EvmClient = class {
3996
3913
  });
3997
3914
  return toEvmAccount({
3998
3915
  id: response.id,
3999
- address: response.address
3916
+ address: response.address,
3917
+ walletId: response.walletId
4000
3918
  });
4001
3919
  }
4002
3920
  /**
@@ -4024,13 +3942,17 @@ var EvmClient = class {
4024
3942
  );
4025
3943
  }
4026
3944
  if (options.id) {
4027
- const response = await getBackendWallet(options.id);
3945
+ const response = await getAccountV2(options.id);
3946
+ if (response.custody !== "Developer") {
3947
+ throw new AccountNotFoundError();
3948
+ }
4028
3949
  return toEvmAccount(toEvmAccountData(response));
4029
3950
  }
4030
3951
  if (options.address) {
4031
- const wallets = await listBackendWallets({
3952
+ const wallets = await getAccountsV2({
4032
3953
  address: options.address,
4033
3954
  chainType: "EVM",
3955
+ custody: "Developer",
4034
3956
  limit: 1
4035
3957
  });
4036
3958
  if (wallets.data.length === 0) {
@@ -4040,6 +3962,15 @@ var EvmClient = class {
4040
3962
  }
4041
3963
  throw new AccountNotFoundError();
4042
3964
  }
3965
+ async getLinkedAccounts(options) {
3966
+ const response = await getAccountsV2({
3967
+ address: options.address,
3968
+ accountType: "Delegated Account",
3969
+ chainType: "EVM",
3970
+ chainId: options.chainId
3971
+ });
3972
+ return response;
3973
+ }
4043
3974
  /**
4044
3975
  * Lists all EVM backend wallets.
4045
3976
  *
@@ -4054,10 +3985,11 @@ var EvmClient = class {
4054
3985
  * ```
4055
3986
  */
4056
3987
  async listAccounts(options = {}) {
4057
- const response = await listBackendWallets({
3988
+ const response = await getAccountsV2({
4058
3989
  limit: options.limit,
4059
3990
  skip: options.skip,
4060
- chainType: "EVM"
3991
+ chainType: "EVM",
3992
+ custody: "Developer"
4061
3993
  });
4062
3994
  const accounts = response.data.map(
4063
3995
  (wallet) => toEvmAccount(toEvmAccountData(wallet))
@@ -4104,7 +4036,8 @@ var EvmClient = class {
4104
4036
  });
4105
4037
  return toEvmAccount({
4106
4038
  id: response.id,
4107
- address: response.address
4039
+ address: response.address,
4040
+ walletId: response.walletId
4108
4041
  });
4109
4042
  } catch (error) {
4110
4043
  if (error instanceof UserInputValidationError) {
@@ -4161,28 +4094,6 @@ var EvmClient = class {
4161
4094
  });
4162
4095
  return response.signature;
4163
4096
  }
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
4097
  };
4187
4098
  EvmClient.type = "evmWallet";
4188
4099
 
@@ -4308,13 +4219,14 @@ var SolanaClient = class {
4308
4219
  );
4309
4220
  }
4310
4221
  if (options.id) {
4311
- const response = await getBackendWallet(options.id);
4222
+ const response = await getAccountV2(options.id);
4312
4223
  return toSolanaAccount(toSolanaAccountData(response));
4313
4224
  }
4314
4225
  if (options.address) {
4315
- const wallets = await listBackendWallets({
4226
+ const wallets = await getAccountsV2({
4316
4227
  address: options.address,
4317
4228
  chainType: "SVM",
4229
+ custody: "Developer",
4318
4230
  limit: 1
4319
4231
  });
4320
4232
  if (wallets.data.length === 0) {
@@ -4338,10 +4250,11 @@ var SolanaClient = class {
4338
4250
  * ```
4339
4251
  */
4340
4252
  async listAccounts(options = {}) {
4341
- const response = await listBackendWallets({
4253
+ const response = await getAccountsV2({
4342
4254
  limit: options.limit,
4343
4255
  skip: options.skip,
4344
- chainType: "SVM"
4256
+ chainType: "SVM",
4257
+ custody: "Developer"
4345
4258
  });
4346
4259
  const accounts = response.data.map(
4347
4260
  (wallet) => toSolanaAccount(toSolanaAccountData(wallet))
@@ -4464,6 +4377,96 @@ SolanaClient.type = "solanaWallet";
4464
4377
  // src/index.ts
4465
4378
  import { ShieldAuthProvider as ShieldAuthProvider2 } from "@openfort/shield-js";
4466
4379
 
4380
+ // src/wallets/evm/actions/sendTransaction.ts
4381
+ import { createPublicClient, getAddress, http } from "viem";
4382
+ import * as chains from "viem/chains";
4383
+ import { hashAuthorization } from "viem/utils";
4384
+
4385
+ // src/wallets/evm/actions/updateToDelegated.ts
4386
+ async function update(options) {
4387
+ const { chainId, walletId, implementationType, accountId } = options;
4388
+ return createAccountV2({
4389
+ accountType: "Delegated Account",
4390
+ chainType: "EVM",
4391
+ chainId,
4392
+ user: walletId,
4393
+ implementationType,
4394
+ account: accountId
4395
+ });
4396
+ }
4397
+
4398
+ // src/wallets/evm/actions/sendTransaction.ts
4399
+ async function sendTransaction(options) {
4400
+ const { account, chainId, interactions, policy, rpcUrl } = options;
4401
+ const transport = rpcUrl ? http(rpcUrl) : http();
4402
+ const allChains = Object.values(chains);
4403
+ const chain = allChains.find((c) => c.id === chainId);
4404
+ if (!chain) {
4405
+ throw new DelegationError(
4406
+ `Unknown chain ID ${chainId}. Provide a custom rpcUrl for unsupported chains.`
4407
+ );
4408
+ }
4409
+ let signedAuthorization;
4410
+ let txAccountId;
4411
+ const response = await getAccountsV2({
4412
+ address: getAddress(account.address),
4413
+ accountType: "Delegated Account",
4414
+ chainType: "EVM",
4415
+ chainId
4416
+ });
4417
+ if (response.data.length === 0) {
4418
+ const updated = await update({
4419
+ walletId: account.walletId,
4420
+ chainId,
4421
+ implementationType: "Calibur",
4422
+ accountId: account.id
4423
+ });
4424
+ txAccountId = updated.id;
4425
+ const implementationAddress = "0x000000009b1d0af20d8c6d0a44e162d11f9b8f00";
4426
+ const publicClient = createPublicClient({ chain, transport });
4427
+ const eoaNonce = await publicClient.getTransactionCount({
4428
+ address: account.address
4429
+ });
4430
+ const authHash = hashAuthorization({
4431
+ contractAddress: implementationAddress,
4432
+ chainId,
4433
+ nonce: eoaNonce
4434
+ });
4435
+ signedAuthorization = await account.sign({ hash: authHash });
4436
+ } else {
4437
+ txAccountId = response.data[0].id;
4438
+ }
4439
+ const txIntent = await createTransactionIntent({
4440
+ chainId,
4441
+ account: txAccountId,
4442
+ policy,
4443
+ signedAuthorization,
4444
+ interactions
4445
+ });
4446
+ if (!txIntent.nextAction?.payload?.signableHash) {
4447
+ return txIntent;
4448
+ }
4449
+ const txSignature = await account.sign({
4450
+ hash: txIntent.nextAction.payload.signableHash
4451
+ });
4452
+ return signature(txIntent.id, {
4453
+ signature: txSignature
4454
+ });
4455
+ }
4456
+
4457
+ // src/wallets/evm/actions/signMessage.ts
4458
+ import { toHex, toPrefixedMessage as toPrefixedMessage2 } from "viem";
4459
+
4460
+ // src/wallets/evm/actions/signTransaction.ts
4461
+ import {
4462
+ keccak256,
4463
+ parseSignature as parseSignature2,
4464
+ serializeTransaction as serializeTransaction2
4465
+ } from "viem";
4466
+
4467
+ // src/wallets/evm/actions/signTypedData.ts
4468
+ import { hashTypedData as hashTypedData2 } from "viem";
4469
+
4467
4470
  // src/policies/evmSchema.ts
4468
4471
  import { z } from "zod";
4469
4472
  var EthValueOperatorEnum = z.enum(["<=", ">=", "<", ">"]);
@@ -4769,19 +4772,6 @@ var UpdatePolicyBodySchema = z3.object({
4769
4772
  rules: z3.array(RuleSchema).min(1).max(10).optional()
4770
4773
  });
4771
4774
 
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
4775
  // src/index.ts
4786
4776
  function isValidSecretKey(key) {
4787
4777
  return key.startsWith("sk_test_") || key.startsWith("sk_live_");
@@ -4877,7 +4867,9 @@ var Openfort = class {
4877
4867
  /** Export private key (with E2E encryption) */
4878
4868
  export: evmClient.exportAccount.bind(evmClient),
4879
4869
  /** Update EOA to delegated account */
4880
- update: evmClient.update.bind(evmClient)
4870
+ update,
4871
+ /** Delegate + create + sign + submit a gasless transaction in one call */
4872
+ sendTransaction
4881
4873
  },
4882
4874
  /** Embedded wallet operations (User custody) */
4883
4875
  embedded: {
@@ -5097,10 +5089,14 @@ var Openfort = class {
5097
5089
  * gas costs are sponsored according to the policy's strategy.
5098
5090
  */
5099
5091
  get transactionIntents() {
5092
+ if (!this._evmClient) {
5093
+ this._evmClient = new EvmClient();
5094
+ }
5095
+ const _evmClient = this._evmClient;
5100
5096
  return {
5101
5097
  /** List transaction intents */
5102
5098
  list: getTransactionIntents,
5103
- /** Create a transaction intent with contract interactions */
5099
+ /** Create a transaction intent with contract interactions. */
5104
5100
  create: createTransactionIntent,
5105
5101
  /** Get a transaction intent by ID */
5106
5102
  get: getTransactionIntent,
@@ -5245,9 +5241,7 @@ var Openfort = class {
5245
5241
  /** Verify auth token */
5246
5242
  verifyToken: verifyAuthToken,
5247
5243
  /** Verify OAuth token */
5248
- verifyOAuthToken,
5249
- /** Authorize */
5250
- authorize
5244
+ verifyOAuthToken
5251
5245
  }
5252
5246
  };
5253
5247
  }
@@ -5455,11 +5449,6 @@ export {
5455
5449
  AuthProviderResponseV2,
5456
5450
  AuthenticateOAuthRequestProvider,
5457
5451
  AuthenticationType,
5458
- BackendWalletListQueriesChainType,
5459
- BackendWalletListResponseObject,
5460
- BackendWalletResponseChainType,
5461
- BackendWalletResponseCustody,
5462
- BackendWalletResponseObject,
5463
5452
  BasicAuthProvider,
5464
5453
  BasicAuthProviderEMAIL,
5465
5454
  BasicAuthProviderGUEST,
@@ -5487,6 +5476,7 @@ export {
5487
5476
  CriteriaOperatorNOTIN,
5488
5477
  CriteriaType,
5489
5478
  Currency,
5479
+ DelegationError,
5490
5480
  DeleteBackendWalletResponseObject,
5491
5481
  DeveloperAccountResponseExpandable,
5492
5482
  EmailTypeRequest,
@@ -5571,7 +5561,6 @@ export {
5571
5561
  JsonRpcErrorResponseJsonrpc,
5572
5562
  JsonRpcRequestJsonrpc,
5573
5563
  JsonRpcSuccessResponseAnyJsonrpc,
5574
- ListBackendWalletsChainType,
5575
5564
  ListPoliciesScopeItem,
5576
5565
  MintAddressCriterionOperator,
5577
5566
  MintAddressCriterionRequestOperator,
@@ -5701,12 +5690,6 @@ export {
5701
5690
  TransactionIntentResponseExpandable,
5702
5691
  TransactionStatus,
5703
5692
  UnknownError,
5704
- UpdateBackendWalletRequestAccountType,
5705
- UpdateBackendWalletRequestChainType,
5706
- UpdateBackendWalletResponseChainType,
5707
- UpdateBackendWalletResponseCustody,
5708
- UpdateBackendWalletResponseDelegatedAccountChainChainType,
5709
- UpdateBackendWalletResponseObject,
5710
5693
  UpdatePolicyBodySchema,
5711
5694
  UsageAlertType,
5712
5695
  UserInputValidationError,
@@ -5719,7 +5702,6 @@ export {
5719
5702
  auth_v2_exports as authApi,
5720
5703
  openfortAuth_schemas_exports as authSchemas,
5721
5704
  authenticateSIWE,
5722
- authorize,
5723
5705
  callbackOAuth,
5724
5706
  cancelTransferAccountOwnership,
5725
5707
  configure,
@@ -5782,7 +5764,6 @@ export {
5782
5764
  getAuthPlayers,
5783
5765
  getAuthUser,
5784
5766
  getAuthUsers,
5785
- getBackendWallet,
5786
5767
  getConfig,
5787
5768
  getContract,
5788
5769
  getContracts,
@@ -5831,7 +5812,6 @@ export {
5831
5812
  linkSIWE,
5832
5813
  linkThirdParty,
5833
5814
  list,
5834
- listBackendWallets,
5835
5815
  listFeeSponsorships,
5836
5816
  listForwarderContracts,
5837
5817
  listOAuthConfig,
@@ -5839,7 +5819,6 @@ export {
5839
5819
  listPolicies,
5840
5820
  listSubscriptionLogs,
5841
5821
  loginEmailPassword,
5842
- loginOIDC,
5843
5822
  loginWithIdToken,
5844
5823
  logout,
5845
5824
  me,
@@ -5873,7 +5852,6 @@ export {
5873
5852
  unlinkEmail,
5874
5853
  unlinkOAuth,
5875
5854
  unlinkSIWE,
5876
- updateBackendWallet,
5877
5855
  updateContract,
5878
5856
  updateDeveloperAccount,
5879
5857
  updateFeeSponsorship,