@openfort/openfort-node 0.8.4 → 0.9.1

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
@@ -5,6 +5,7 @@ var __export = (target, all) => {
5
5
  };
6
6
 
7
7
  // src/index.ts
8
+ import { timingSafeEqual } from "crypto";
8
9
  import {
9
10
  entropy,
10
11
  ShieldAuthProvider,
@@ -374,7 +375,7 @@ function requiresWalletAuth(requestMethod, requestPath) {
374
375
  }
375
376
 
376
377
  // src/version.ts
377
- var VERSION = "0.8.4";
378
+ var VERSION = "0.9.1";
378
379
  var PACKAGE = "@openfort/openfort-node";
379
380
 
380
381
  // src/openapi-client/openfortApiClient.ts
@@ -1822,6 +1823,17 @@ var getBackendWallet = (id, options) => {
1822
1823
  options
1823
1824
  );
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
+ };
1825
1837
  var deleteBackendWallet = (id, options) => {
1826
1838
  return openfortApiClient(
1827
1839
  {
@@ -2001,6 +2013,76 @@ var deleteEvent = (id, options) => {
2001
2013
  );
2002
2014
  };
2003
2015
 
2016
+ // src/openapi-client/generated/fee-sponsorship/fee-sponsorship.ts
2017
+ var listFeeSponsorships = (params, options) => {
2018
+ return openfortApiClient(
2019
+ {
2020
+ url: `/v2/fee-sponsorship`,
2021
+ method: "GET",
2022
+ params
2023
+ },
2024
+ options
2025
+ );
2026
+ };
2027
+ var createFeeSponsorship = (createFeeSponsorshipRequest, options) => {
2028
+ return openfortApiClient(
2029
+ {
2030
+ url: `/v2/fee-sponsorship`,
2031
+ method: "POST",
2032
+ headers: { "Content-Type": "application/json" },
2033
+ data: createFeeSponsorshipRequest
2034
+ },
2035
+ options
2036
+ );
2037
+ };
2038
+ var getFeeSponsorship = (feeSponsorshipId, options) => {
2039
+ return openfortApiClient(
2040
+ {
2041
+ url: `/v2/fee-sponsorship/${feeSponsorshipId}`,
2042
+ method: "GET"
2043
+ },
2044
+ options
2045
+ );
2046
+ };
2047
+ var updateFeeSponsorship = (feeSponsorshipId, updateFeeSponsorshipRequest, options) => {
2048
+ return openfortApiClient(
2049
+ {
2050
+ url: `/v2/fee-sponsorship/${feeSponsorshipId}`,
2051
+ method: "PUT",
2052
+ headers: { "Content-Type": "application/json" },
2053
+ data: updateFeeSponsorshipRequest
2054
+ },
2055
+ options
2056
+ );
2057
+ };
2058
+ var deleteFeeSponsorship = (feeSponsorshipId, options) => {
2059
+ return openfortApiClient(
2060
+ {
2061
+ url: `/v2/fee-sponsorship/${feeSponsorshipId}`,
2062
+ method: "DELETE"
2063
+ },
2064
+ options
2065
+ );
2066
+ };
2067
+ var enableFeeSponsorship = (feeSponsorshipId, options) => {
2068
+ return openfortApiClient(
2069
+ {
2070
+ url: `/v2/fee-sponsorship/${feeSponsorshipId}/enable`,
2071
+ method: "PUT"
2072
+ },
2073
+ options
2074
+ );
2075
+ };
2076
+ var disableFeeSponsorship = (feeSponsorshipId, options) => {
2077
+ return openfortApiClient(
2078
+ {
2079
+ url: `/v2/fee-sponsorship/${feeSponsorshipId}/disable`,
2080
+ method: "PUT"
2081
+ },
2082
+ options
2083
+ );
2084
+ };
2085
+
2004
2086
  // src/openapi-client/generated/forwarder-contract/forwarder-contract.ts
2005
2087
  var createForwarderContract = (createForwarderContractRequest, options) => {
2006
2088
  return openfortApiClient(
@@ -2053,6 +2135,160 @@ var deleteForwarderContract = (id, options) => {
2053
2135
  );
2054
2136
  };
2055
2137
 
2138
+ // src/openapi-client/generated/gas-policies-legacy/gas-policies-legacy.ts
2139
+ var getGasPoliciesLegacy = (params, options) => {
2140
+ return openfortApiClient(
2141
+ {
2142
+ url: `/v1/policies`,
2143
+ method: "GET",
2144
+ params
2145
+ },
2146
+ options
2147
+ );
2148
+ };
2149
+ var createGasPolicyLegacy = (createPolicyRequest, options) => {
2150
+ return openfortApiClient(
2151
+ {
2152
+ url: `/v1/policies`,
2153
+ method: "POST",
2154
+ headers: { "Content-Type": "application/json" },
2155
+ data: createPolicyRequest
2156
+ },
2157
+ options
2158
+ );
2159
+ };
2160
+ var getGasPolicyLegacy = (id, params, options) => {
2161
+ return openfortApiClient(
2162
+ {
2163
+ url: `/v1/policies/${id}`,
2164
+ method: "GET",
2165
+ params
2166
+ },
2167
+ options
2168
+ );
2169
+ };
2170
+ var updateGasPolicyLegacy = (id, updatePolicyRequest, options) => {
2171
+ return openfortApiClient(
2172
+ {
2173
+ url: `/v1/policies/${id}`,
2174
+ method: "POST",
2175
+ headers: { "Content-Type": "application/json" },
2176
+ data: updatePolicyRequest
2177
+ },
2178
+ options
2179
+ );
2180
+ };
2181
+ var deleteGasPolicyLegacy = (id, options) => {
2182
+ return openfortApiClient(
2183
+ {
2184
+ url: `/v1/policies/${id}`,
2185
+ method: "DELETE"
2186
+ },
2187
+ options
2188
+ );
2189
+ };
2190
+ var disableGasPolicyLegacy = (id, options) => {
2191
+ return openfortApiClient(
2192
+ {
2193
+ url: `/v1/policies/${id}/disable`,
2194
+ method: "PUT"
2195
+ },
2196
+ options
2197
+ );
2198
+ };
2199
+ var enableGasPolicyLegacy = (id, options) => {
2200
+ return openfortApiClient(
2201
+ {
2202
+ url: `/v1/policies/${id}/enable`,
2203
+ method: "PUT"
2204
+ },
2205
+ options
2206
+ );
2207
+ };
2208
+ var getGasPolicyTotalGasUsageLegacy = (id, params, options) => {
2209
+ return openfortApiClient(
2210
+ {
2211
+ url: `/v1/policies/${id}/reports`,
2212
+ method: "GET",
2213
+ params
2214
+ },
2215
+ options
2216
+ );
2217
+ };
2218
+ var getGasPolicyReportTransactionIntentsLegacy = (id, params, options) => {
2219
+ return openfortApiClient(
2220
+ {
2221
+ url: `/v1/policies/${id}/reports/transaction_intents`,
2222
+ method: "GET",
2223
+ params
2224
+ },
2225
+ options
2226
+ );
2227
+ };
2228
+ var getGasPolicyBalanceLegacy = (id, options) => {
2229
+ return openfortApiClient(
2230
+ {
2231
+ url: `/v1/policies/${id}/withdraw`,
2232
+ method: "GET"
2233
+ },
2234
+ options
2235
+ );
2236
+ };
2237
+ var createGasPolicyWithdrawalLegacy = (id, withdrawalPolicyRequest, options) => {
2238
+ return openfortApiClient(
2239
+ {
2240
+ url: `/v1/policies/${id}/withdraw`,
2241
+ method: "POST",
2242
+ headers: { "Content-Type": "application/json" },
2243
+ data: withdrawalPolicyRequest
2244
+ },
2245
+ options
2246
+ );
2247
+ };
2248
+
2249
+ // src/openapi-client/generated/gas-policy-rules-legacy/gas-policy-rules-legacy.ts
2250
+ var getGasPolicyRulesLegacy = (params, options) => {
2251
+ return openfortApiClient(
2252
+ {
2253
+ url: `/v1/policy_rules`,
2254
+ method: "GET",
2255
+ params
2256
+ },
2257
+ options
2258
+ );
2259
+ };
2260
+ var createGasPolicyRuleLegacy = (createPolicyRuleRequest, options) => {
2261
+ return openfortApiClient(
2262
+ {
2263
+ url: `/v1/policy_rules`,
2264
+ method: "POST",
2265
+ headers: { "Content-Type": "application/json" },
2266
+ data: createPolicyRuleRequest
2267
+ },
2268
+ options
2269
+ );
2270
+ };
2271
+ var updateGasPolicyRuleLegacy = (id, updatePolicyRuleRequest, options) => {
2272
+ return openfortApiClient(
2273
+ {
2274
+ url: `/v1/policy_rules/${id}`,
2275
+ method: "POST",
2276
+ headers: { "Content-Type": "application/json" },
2277
+ data: updatePolicyRuleRequest
2278
+ },
2279
+ options
2280
+ );
2281
+ };
2282
+ var deleteGasPolicyRuleLegacy = (id, options) => {
2283
+ return openfortApiClient(
2284
+ {
2285
+ url: `/v1/policy_rules/${id}`,
2286
+ method: "DELETE"
2287
+ },
2288
+ options
2289
+ );
2290
+ };
2291
+
2056
2292
  // src/openapi-client/generated/graph-q-l/graph-q-l.ts
2057
2293
  var query = (queryBody, options) => {
2058
2294
  return openfortApiClient(
@@ -2365,7 +2601,8 @@ var PregenerateUserRequestV2ChainType = {
2365
2601
  };
2366
2602
  var PolicyV2Scope = {
2367
2603
  project: "project",
2368
- account: "account"
2604
+ account: "account",
2605
+ transaction: "transaction"
2369
2606
  };
2370
2607
  var PolicyV2Action = {
2371
2608
  accept: "accept",
@@ -2497,9 +2734,10 @@ var EntityTypePOLICYV2RULE = {
2497
2734
  var EntityTypePOLICYV2 = {
2498
2735
  policyV2: "policyV2"
2499
2736
  };
2500
- var PolicyV2ListQueriesScope = {
2737
+ var PolicyV2ListQueriesScopeItem = {
2501
2738
  project: "project",
2502
- account: "account"
2739
+ account: "account",
2740
+ transaction: "transaction"
2503
2741
  };
2504
2742
  var EvmAddressCriterionRequestType = {
2505
2743
  evmAddress: "evmAddress"
@@ -2637,11 +2875,15 @@ var CreatePolicyV2RuleRequestAction = {
2637
2875
  };
2638
2876
  var CreatePolicyV2RequestScope = {
2639
2877
  project: "project",
2640
- account: "account"
2878
+ account: "account",
2879
+ transaction: "transaction"
2641
2880
  };
2642
2881
  var EvaluatePolicyV2ResponseObject = {
2643
2882
  policy_evaluation: "policy_evaluation"
2644
2883
  };
2884
+ var EntityTypeFEESPONSORSHIP = {
2885
+ feeSponsorship: "feeSponsorship"
2886
+ };
2645
2887
  var CreateEmbeddedRequestAccountType = {
2646
2888
  Externally_Owned_Account: "Externally Owned Account",
2647
2889
  Smart_Account: "Smart Account",
@@ -2679,6 +2921,27 @@ var CreateBackendWalletRequestChainType = {
2679
2921
  EVM: "EVM",
2680
2922
  SVM: "SVM"
2681
2923
  };
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
+ };
2682
2945
  var DeleteBackendWalletResponseObject = {
2683
2946
  backendWallet: "backendWallet"
2684
2947
  };
@@ -2750,6 +3013,11 @@ var UserProjectRoleMEMBER = {
2750
3013
  };
2751
3014
  var UserProjectCreateRequestRole = { ...UserProjectRoleADMIN, ...UserProjectRoleMEMBER };
2752
3015
  var UserProjectUpdateRequestRole = { ...UserProjectRoleMEMBER, ...UserProjectRoleADMIN };
3016
+ var UsageAlertType = {
3017
+ warning: "warning",
3018
+ critical: "critical",
3019
+ info: "info"
3020
+ };
2753
3021
  var EntityTypePROJECT = {
2754
3022
  project: "project"
2755
3023
  };
@@ -2920,12 +3188,13 @@ var AuthenticationType = {
2920
3188
  basic: "basic",
2921
3189
  third_party: "third_party"
2922
3190
  };
2923
- var GetPolicyRulesExpandItem = {
3191
+ var GetGasPolicyRulesLegacyExpandItem = {
2924
3192
  contract: "contract"
2925
3193
  };
2926
- var ListPoliciesScope = {
3194
+ var ListPoliciesScopeItem = {
2927
3195
  project: "project",
2928
- account: "account"
3196
+ account: "account",
3197
+ transaction: "transaction"
2929
3198
  };
2930
3199
  var ListBackendWalletsChainType = {
2931
3200
  EVM: "EVM",
@@ -3073,115 +3342,6 @@ var cancelTransferAccountOwnership = (id, playerCancelTransferOwnershipRequest,
3073
3342
  };
3074
3343
 
3075
3344
  // src/openapi-client/generated/policies/policies.ts
3076
- var getPolicies = (params, options) => {
3077
- return openfortApiClient(
3078
- {
3079
- url: `/v1/policies`,
3080
- method: "GET",
3081
- params
3082
- },
3083
- options
3084
- );
3085
- };
3086
- var createPolicy = (createPolicyRequest, options) => {
3087
- return openfortApiClient(
3088
- {
3089
- url: `/v1/policies`,
3090
- method: "POST",
3091
- headers: { "Content-Type": "application/json" },
3092
- data: createPolicyRequest
3093
- },
3094
- options
3095
- );
3096
- };
3097
- var getPolicy = (id, params, options) => {
3098
- return openfortApiClient(
3099
- {
3100
- url: `/v1/policies/${id}`,
3101
- method: "GET",
3102
- params
3103
- },
3104
- options
3105
- );
3106
- };
3107
- var updatePolicy = (id, updatePolicyRequest, options) => {
3108
- return openfortApiClient(
3109
- {
3110
- url: `/v1/policies/${id}`,
3111
- method: "POST",
3112
- headers: { "Content-Type": "application/json" },
3113
- data: updatePolicyRequest
3114
- },
3115
- options
3116
- );
3117
- };
3118
- var deletePolicy = (id, options) => {
3119
- return openfortApiClient(
3120
- {
3121
- url: `/v1/policies/${id}`,
3122
- method: "DELETE"
3123
- },
3124
- options
3125
- );
3126
- };
3127
- var disablePolicy = (id, options) => {
3128
- return openfortApiClient(
3129
- {
3130
- url: `/v1/policies/${id}/disable`,
3131
- method: "PUT"
3132
- },
3133
- options
3134
- );
3135
- };
3136
- var enablePolicy = (id, options) => {
3137
- return openfortApiClient(
3138
- {
3139
- url: `/v1/policies/${id}/enable`,
3140
- method: "PUT"
3141
- },
3142
- options
3143
- );
3144
- };
3145
- var getPolicyTotalGasUsage = (id, params, options) => {
3146
- return openfortApiClient(
3147
- {
3148
- url: `/v1/policies/${id}/reports`,
3149
- method: "GET",
3150
- params
3151
- },
3152
- options
3153
- );
3154
- };
3155
- var getPolicyReportTransactionIntents = (id, params, options) => {
3156
- return openfortApiClient(
3157
- {
3158
- url: `/v1/policies/${id}/reports/transaction_intents`,
3159
- method: "GET",
3160
- params
3161
- },
3162
- options
3163
- );
3164
- };
3165
- var getPolicyBalance = (id, options) => {
3166
- return openfortApiClient(
3167
- {
3168
- url: `/v1/policies/${id}/withdraw`,
3169
- method: "GET"
3170
- },
3171
- options
3172
- );
3173
- };
3174
- var createPolicyWithdrawal = (id, withdrawalPolicyRequest, options) => {
3175
- return openfortApiClient(
3176
- {
3177
- url: `/v1/policies/${id}/withdraw`,
3178
- method: "POST",
3179
- headers: { "Content-Type": "application/json" },
3180
- data: withdrawalPolicyRequest
3181
- },
3182
- options
3183
- );
3184
- };
3185
3345
  var listPolicies = (params, options) => {
3186
3346
  return openfortApiClient(
3187
3347
  {
@@ -3244,49 +3404,6 @@ var evaluatePolicyV2 = (evaluatePolicyV2Request, options) => {
3244
3404
  );
3245
3405
  };
3246
3406
 
3247
- // src/openapi-client/generated/policy-rules/policy-rules.ts
3248
- var getPolicyRules = (params, options) => {
3249
- return openfortApiClient(
3250
- {
3251
- url: `/v1/policy_rules`,
3252
- method: "GET",
3253
- params
3254
- },
3255
- options
3256
- );
3257
- };
3258
- var createPolicyRule = (createPolicyRuleRequest, options) => {
3259
- return openfortApiClient(
3260
- {
3261
- url: `/v1/policy_rules`,
3262
- method: "POST",
3263
- headers: { "Content-Type": "application/json" },
3264
- data: createPolicyRuleRequest
3265
- },
3266
- options
3267
- );
3268
- };
3269
- var updatePolicyRule = (id, updatePolicyRuleRequest, options) => {
3270
- return openfortApiClient(
3271
- {
3272
- url: `/v1/policy_rules/${id}`,
3273
- method: "POST",
3274
- headers: { "Content-Type": "application/json" },
3275
- data: updatePolicyRuleRequest
3276
- },
3277
- options
3278
- );
3279
- };
3280
- var deletePolicyRule = (id, options) => {
3281
- return openfortApiClient(
3282
- {
3283
- url: `/v1/policy_rules/${id}`,
3284
- method: "DELETE"
3285
- },
3286
- options
3287
- );
3288
- };
3289
-
3290
3407
  // src/openapi-client/generated/rpc/rpc.ts
3291
3408
  var handleRpcRequest = (jsonRpcRequest, options) => {
3292
3409
  return openfortApiClient(
@@ -3762,12 +3879,22 @@ import {
3762
3879
  toPrefixedMessage
3763
3880
  } from "viem";
3764
3881
 
3882
+ // src/wallets/evm/actions/normalizeSignature.ts
3883
+ function normalizeSignature(sig) {
3884
+ const v = parseInt(sig.slice(-2), 16);
3885
+ if (v < 27) {
3886
+ return sig.slice(0, -2) + (v + 27).toString(16);
3887
+ }
3888
+ return sig;
3889
+ }
3890
+
3765
3891
  // src/wallets/evm/actions/signHash.ts
3766
3892
  async function signHash(options) {
3767
3893
  const { accountId, hash } = options;
3768
3894
  const response = await sign(accountId, { data: hash });
3895
+ const signature2 = normalizeSignature(response.signature);
3769
3896
  return {
3770
- signature: response.signature
3897
+ signature: signature2
3771
3898
  };
3772
3899
  }
3773
3900
 
@@ -4034,6 +4161,28 @@ var EvmClient = class {
4034
4161
  });
4035
4162
  return response.signature;
4036
4163
  }
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
+ }
4037
4186
  };
4038
4187
  EvmClient.type = "evmWallet";
4039
4188
 
@@ -4432,6 +4581,19 @@ var SignEvmHashRuleSchema = z.object({
4432
4581
  action: ActionEnum,
4433
4582
  operation: z.literal("signEvmHash")
4434
4583
  });
4584
+ var SponsorEvmTransactionCriteriaSchema = z.array(
4585
+ z.discriminatedUnion("type", [
4586
+ EthValueCriterionSchema,
4587
+ EvmAddressCriterionSchema,
4588
+ EvmNetworkCriterionSchema,
4589
+ EvmDataCriterionSchema
4590
+ ])
4591
+ ).max(10);
4592
+ var SponsorEvmTransactionRuleSchema = z.object({
4593
+ action: ActionEnum,
4594
+ operation: z.literal("sponsorEvmTransaction"),
4595
+ criteria: SponsorEvmTransactionCriteriaSchema
4596
+ });
4435
4597
 
4436
4598
  // src/policies/solanaSchema.ts
4437
4599
  import { z as z2 } from "zod";
@@ -4549,6 +4711,23 @@ var SignSolMessageRuleSchema = z2.object({
4549
4711
  operation: z2.literal("signSolMessage"),
4550
4712
  criteria: SignSolMessageCriteriaSchema
4551
4713
  });
4714
+ var SponsorSolTransactionCriteriaSchema = z2.array(
4715
+ z2.discriminatedUnion("type", [
4716
+ SolAddressCriterionSchema,
4717
+ SolValueCriterionSchema,
4718
+ SplAddressCriterionSchema,
4719
+ SplValueCriterionSchema,
4720
+ MintAddressCriterionSchema,
4721
+ SolDataCriterionSchema,
4722
+ ProgramIdCriterionSchema,
4723
+ SolNetworkCriterionSchema
4724
+ ])
4725
+ ).max(10);
4726
+ var SponsorSolTransactionRuleSchema = z2.object({
4727
+ action: ActionEnum,
4728
+ operation: z2.literal("sponsorSolTransaction"),
4729
+ criteria: SponsorSolTransactionCriteriaSchema
4730
+ });
4552
4731
 
4553
4732
  // src/policies/types.ts
4554
4733
  import { z as z3 } from "zod";
@@ -4559,9 +4738,11 @@ var RuleSchema = z3.discriminatedUnion("operation", [
4559
4738
  SignEvmMessageRuleSchema,
4560
4739
  SignEvmTypedDataRuleSchema,
4561
4740
  SignEvmHashRuleSchema,
4741
+ SponsorEvmTransactionRuleSchema,
4562
4742
  SignSolTransactionRuleSchema,
4563
4743
  SendSolTransactionRuleSchema,
4564
- SignSolMessageRuleSchema
4744
+ SignSolMessageRuleSchema,
4745
+ SponsorSolTransactionRuleSchema
4565
4746
  ]);
4566
4747
  var CreatePolicyBodySchema = z3.object({
4567
4748
  /** The scope of the policy. 'project' applies to all accounts, 'account' applies to a specific account. */
@@ -4694,7 +4875,9 @@ var Openfort = class {
4694
4875
  /** Import private key (with E2E encryption) */
4695
4876
  import: evmClient.importAccount.bind(evmClient),
4696
4877
  /** Export private key (with E2E encryption) */
4697
- export: evmClient.exportAccount.bind(evmClient)
4878
+ export: evmClient.exportAccount.bind(evmClient),
4879
+ /** Update EOA to delegated account */
4880
+ update: evmClient.update.bind(evmClient)
4698
4881
  },
4699
4882
  /** Embedded wallet operations (User custody) */
4700
4883
  embedded: {
@@ -4745,8 +4928,8 @@ var Openfort = class {
4745
4928
  // Players API
4746
4929
  // ============================================
4747
4930
  /**
4748
- * Player management endpoints
4749
- * @deprecated
4931
+ * Player management endpoints.
4932
+ * @deprecated Use `openfort.iam.users` for V2 user management.
4750
4933
  */
4751
4934
  get players() {
4752
4935
  return {
@@ -4786,39 +4969,60 @@ var Openfort = class {
4786
4969
  // Policies API
4787
4970
  // ============================================
4788
4971
  /**
4789
- * Policy management endpoints for controlling account operations.
4972
+ * Policy management endpoints for criteria-based access control.
4790
4973
  *
4791
4974
  * Policies define rules that govern what operations accounts can perform,
4792
- * including transaction signing, message signing, and more.
4975
+ * including transaction signing, message signing, and gas sponsorship.
4976
+ * Each policy has a scope (project, account, or transaction), a priority,
4977
+ * and an ordered list of rules. Each rule specifies an action (accept/reject),
4978
+ * an operation, and criteria that must all match (AND logic).
4979
+ *
4980
+ * **Supported operations:**
4981
+ * - EVM: `signEvmTransaction`, `sendEvmTransaction`, `signEvmTypedData`, `signEvmMessage`, `signEvmHash`, `sponsorEvmTransaction`
4982
+ * - Solana: `signSolTransaction`, `sendSolTransaction`, `signSolMessage`, `sponsorSolTransaction`
4983
+ *
4984
+ * **Supported criteria types:**
4985
+ * - EVM: `evmAddress`, `ethValue`, `evmNetwork`, `evmData`, `evmMessage`, `evmTypedDataVerifyingContract`, `evmTypedDataField`
4986
+ * - Solana: `solAddress`, `solValue`, `splAddress`, `splValue`, `mintAddress`, `programId`, `solNetwork`, `solMessage`, `solData`
4987
+ *
4988
+ * Policies are evaluated in priority order (highest first). The first matching rule determines the outcome.
4989
+ * If policies exist but no rule matches, the operation is rejected (fail-closed).
4793
4990
  *
4794
4991
  * @example
4795
4992
  * ```typescript
4796
- * // List all policies
4797
- * const all = await openfort.policies.list();
4798
- *
4799
- * // Create a policy
4993
+ * // Create a policy that only allows transactions to specific addresses on certain chains
4800
4994
  * const policy = await openfort.policies.create({
4801
4995
  * scope: 'project',
4802
- * rules: [{ action: 'reject', operation: 'signEvmHash' }],
4996
+ * rules: [{
4997
+ * action: 'accept',
4998
+ * operation: 'sponsorEvmTransaction',
4999
+ * criteria: [
5000
+ * { type: 'evmNetwork', operator: 'in', chainIds: [1, 137] },
5001
+ * { type: 'evmAddress', operator: 'in', addresses: ['0x...'] },
5002
+ * ],
5003
+ * }],
4803
5004
  * });
4804
5005
  *
4805
5006
  * // Evaluate whether an operation would be allowed
4806
- * const result = await openfort.policies.evaluate({ operation: 'signEvmTransaction', accountId: 'acc_...' });
5007
+ * const result = await openfort.policies.evaluate({
5008
+ * operation: 'signEvmTransaction',
5009
+ * accountId: 'acc_...',
5010
+ * });
4807
5011
  * ```
4808
5012
  */
4809
5013
  get policies() {
4810
5014
  return {
4811
- /** List policies */
5015
+ /** List policies, optionally filtered by scope, enabled status, or account */
4812
5016
  list: listPolicies,
4813
- /** Create a policy */
5017
+ /** Create a policy with scope, priority, and criteria-based rules */
4814
5018
  create: createPolicyV2,
4815
- /** Get a policy by ID */
5019
+ /** Get a policy by ID (ply_...) */
4816
5020
  get: getPolicyV2,
4817
- /** Update a policy */
5021
+ /** Update a policy's description, priority, enabled status, or rules */
4818
5022
  update: updatePolicyV2,
4819
- /** Delete a policy */
5023
+ /** Soft-delete a policy */
4820
5024
  delete: deletePolicyV2,
4821
- /** Evaluate an operation against policies */
5025
+ /** Pre-flight check: evaluate whether an operation would be allowed without executing it */
4822
5026
  evaluate: evaluatePolicyV2
4823
5027
  };
4824
5028
  }
@@ -4826,56 +5030,83 @@ var Openfort = class {
4826
5030
  // Fee Sponsorship API
4827
5031
  // ============================================
4828
5032
  /**
4829
- * Fee sponsorship (gas policy) management endpoints
5033
+ * Fee sponsorship endpoints for sponsoring gas costs on behalf of users.
5034
+ *
5035
+ * A fee sponsorship links a strategy (how gas is paid) to a policy (which
5036
+ * transactions qualify). Create a policy first via `openfort.policies.create()`,
5037
+ * then create a fee sponsorship referencing it.
5038
+ *
5039
+ * **Strategies (`sponsorSchema`):**
5040
+ * - `pay_for_user` — Developer fully sponsors gas costs
5041
+ * - `charge_custom_tokens` — User pays in ERC-20 tokens (fixed or dynamic exchange rate)
5042
+ * - `fixed_rate` — User pays a fixed token amount per transaction
5043
+ *
5044
+ * **Workflow:**
5045
+ * 1. Create a policy via `openfort.policies.create()` with criteria rules
5046
+ * 2. Create a fee sponsorship via `openfort.feeSponsorship.create()` linking to that policy
5047
+ *
5048
+ * When a transaction is submitted without an explicit policy, project-scoped fee
5049
+ * sponsorships are auto-discovered and the first matching one is applied.
5050
+ *
5051
+ * @example
5052
+ * ```typescript
5053
+ * // 1. Create a policy to sponsor transactions on Polygon
5054
+ * const policy = await openfort.policies.create({
5055
+ * scope: 'project',
5056
+ * rules: [{
5057
+ * action: 'accept',
5058
+ * operation: 'sponsorEvmTransaction',
5059
+ * criteria: [{ type: 'evmNetwork', operator: 'in', chainIds: [137] }],
5060
+ * }],
5061
+ * });
5062
+ *
5063
+ * // 2. Create a fee sponsorship with pay_for_user strategy
5064
+ * const sponsorship = await openfort.feeSponsorship.create({
5065
+ * name: 'Polygon Gas Sponsorship',
5066
+ * strategy: { sponsorSchema: 'pay_for_user' },
5067
+ * policyId: policy.id,
5068
+ * });
5069
+ * ```
4830
5070
  */
4831
5071
  get feeSponsorship() {
4832
5072
  return {
4833
- /** List fee sponsorship policies */
4834
- list: getPolicies,
4835
- /** Create a fee sponsorship policy */
4836
- create: createPolicy,
4837
- /** Get a fee sponsorship policy by ID */
4838
- get: getPolicy,
4839
- /** Update a fee sponsorship policy */
4840
- update: updatePolicy,
4841
- /** Delete a fee sponsorship policy */
4842
- delete: deletePolicy,
4843
- /** Disable a fee sponsorship policy */
4844
- disable: disablePolicy,
4845
- /** Enable a fee sponsorship policy */
4846
- enable: enablePolicy,
4847
- /** Get fee sponsorship policy total gas usage */
4848
- getTotalGasUsage: getPolicyTotalGasUsage,
4849
- /** Fee sponsorship policy rules */
4850
- rules: {
4851
- /** List policy rules */
4852
- list: getPolicyRules,
4853
- /** Create a policy rule */
4854
- create: createPolicyRule,
4855
- /** Update a policy rule */
4856
- update: updatePolicyRule,
4857
- /** Delete a policy rule */
4858
- delete: deletePolicyRule
4859
- }
5073
+ /** List fee sponsorships, optionally filtered by name, chainId, or enabled status */
5074
+ list: listFeeSponsorships,
5075
+ /** Create a fee sponsorship linked to a policy (policyId required) */
5076
+ create: createFeeSponsorship,
5077
+ /** Get a fee sponsorship by ID (pol_...) */
5078
+ get: getFeeSponsorship,
5079
+ /** Update a fee sponsorship's name, strategy, or linked policy */
5080
+ update: updateFeeSponsorship,
5081
+ /** Soft-delete a fee sponsorship */
5082
+ delete: deleteFeeSponsorship,
5083
+ /** Disable a fee sponsorship (stops it from being applied to transactions) */
5084
+ disable: disableFeeSponsorship,
5085
+ /** Enable a previously disabled fee sponsorship */
5086
+ enable: enableFeeSponsorship
4860
5087
  };
4861
5088
  }
4862
5089
  // ============================================
4863
5090
  // Transaction Intents API
4864
5091
  // ============================================
4865
5092
  /**
4866
- * Transaction intent management endpoints
5093
+ * Transaction intent endpoints for creating and managing on-chain transactions.
5094
+ *
5095
+ * Transaction intents represent a desired on-chain action (contract calls, transfers).
5096
+ * When a fee sponsorship policy is provided (or auto-discovered from project-scoped policies),
5097
+ * gas costs are sponsored according to the policy's strategy.
4867
5098
  */
4868
5099
  get transactionIntents() {
4869
5100
  return {
4870
5101
  /** List transaction intents */
4871
5102
  list: getTransactionIntents,
4872
- /** Create a transaction intent */
5103
+ /** Create a transaction intent with contract interactions */
4873
5104
  create: createTransactionIntent,
4874
5105
  /** Get a transaction intent by ID */
4875
5106
  get: getTransactionIntent,
4876
5107
  /** Sign a transaction intent */
4877
5108
  signature,
4878
- /** Estimate cost */
5109
+ /** Estimate gas cost for a transaction before creating it */
4879
5110
  estimateCost: estimateTransactionIntentCost
4880
5111
  };
4881
5112
  }
@@ -4900,27 +5131,6 @@ var Openfort = class {
4900
5131
  };
4901
5132
  }
4902
5133
  // ============================================
4903
- // Settings API
4904
- // ============================================
4905
- /**
4906
- * Settings / Developer account management endpoints
4907
- * @deprecated
4908
- */
4909
- get settings() {
4910
- return {
4911
- /** List developer accounts */
4912
- getDeveloperAccounts,
4913
- /** Create a developer account */
4914
- createDeveloperAccount,
4915
- /** Get a developer account by ID */
4916
- getDeveloperAccount,
4917
- /** Delete a developer account */
4918
- deleteDeveloperAccount,
4919
- /** Get verification payload */
4920
- getVerificationPayload
4921
- };
4922
- }
4923
- // ============================================
4924
5134
  // Subscriptions API
4925
5135
  // ============================================
4926
5136
  /**
@@ -5069,7 +5279,10 @@ var Openfort = class {
5069
5279
  const { recoveryShare: _, ...accountResponse } = response;
5070
5280
  return accountResponse;
5071
5281
  } catch (error) {
5072
- await deleteUser(response.user);
5282
+ try {
5283
+ await deleteUser(response.user);
5284
+ } catch {
5285
+ }
5073
5286
  throw error;
5074
5287
  }
5075
5288
  }
@@ -5100,6 +5313,11 @@ var Openfort = class {
5100
5313
  * @internal
5101
5314
  */
5102
5315
  async preRegisterWithShield(recoveryShare, openfortUserId, thirdPartyUserId, config) {
5316
+ if (!config.shieldApiKey || !config.shieldApiSecret || !config.encryptionShare) {
5317
+ throw new Error(
5318
+ "Shield configuration requires shieldApiKey, shieldApiSecret, and encryptionShare"
5319
+ );
5320
+ }
5103
5321
  let externalUserId;
5104
5322
  if (config.shieldAuthProvider === ShieldAuthProvider.OPENFORT) {
5105
5323
  externalUserId = openfortUserId;
@@ -5134,13 +5352,16 @@ var Openfort = class {
5134
5352
  // Paymasters API
5135
5353
  // ============================================
5136
5354
  /**
5137
- * Paymaster endpoints
5355
+ * Paymaster endpoints for managing ERC-4337 paymasters.
5356
+ *
5357
+ * Paymasters handle gas payment on-chain for account abstraction (ERC-4337).
5358
+ * Fee sponsorships reference a paymaster to determine how user operations are sponsored.
5138
5359
  */
5139
5360
  get paymasters() {
5140
5361
  return {
5141
5362
  /** Create a paymaster */
5142
5363
  create: createPaymaster,
5143
- /** Get a paymaster by ID */
5364
+ /** Get a paymaster by ID (pay_...) */
5144
5365
  get: getPaymaster,
5145
5366
  /** Update a paymaster */
5146
5367
  update: updatePaymaster,
@@ -5159,10 +5380,16 @@ var Openfort = class {
5159
5380
  */
5160
5381
  async constructWebhookEvent(body, signature2) {
5161
5382
  const signedPayload = await sign2(this._apiKey, body);
5162
- if (signedPayload !== signature2) {
5163
- throw Error("Invalid signature");
5383
+ const expectedBuffer = Buffer.from(signedPayload, "hex");
5384
+ const receivedBuffer = Buffer.from(signature2, "hex");
5385
+ if (expectedBuffer.length !== receivedBuffer.length || !timingSafeEqual(expectedBuffer, receivedBuffer)) {
5386
+ throw new Error("Invalid signature");
5387
+ }
5388
+ try {
5389
+ return JSON.parse(body);
5390
+ } catch {
5391
+ throw new Error("Failed to parse webhook payload");
5164
5392
  }
5165
- return JSON.parse(body);
5166
5393
  }
5167
5394
  /**
5168
5395
  * Creates an encryption session with Shield.
@@ -5272,6 +5499,7 @@ export {
5272
5499
  EntityTypeDEVICE,
5273
5500
  EntityTypeEMAILSAMPLE,
5274
5501
  EntityTypeEVENT,
5502
+ EntityTypeFEESPONSORSHIP,
5275
5503
  EntityTypeFORWARDERCONTRACT,
5276
5504
  EntityTypeLOG,
5277
5505
  EntityTypePAYMASTER,
@@ -5332,7 +5560,7 @@ export {
5332
5560
  GetAccountsV2AccountType,
5333
5561
  GetAccountsV2ChainType,
5334
5562
  GetAccountsV2Custody,
5335
- GetPolicyRulesExpandItem,
5563
+ GetGasPolicyRulesLegacyExpandItem,
5336
5564
  IMPORT_ENCRYPTION_PUBLIC_KEY,
5337
5565
  ImportPrivateKeyRequestChainType,
5338
5566
  ImportPrivateKeyResponseChainType,
@@ -5344,7 +5572,7 @@ export {
5344
5572
  JsonRpcRequestJsonrpc,
5345
5573
  JsonRpcSuccessResponseAnyJsonrpc,
5346
5574
  ListBackendWalletsChainType,
5347
- ListPoliciesScope,
5575
+ ListPoliciesScopeItem,
5348
5576
  MintAddressCriterionOperator,
5349
5577
  MintAddressCriterionRequestOperator,
5350
5578
  MintAddressCriterionRequestType,
@@ -5380,7 +5608,7 @@ export {
5380
5608
  PolicyRuleTypeCONTRACT,
5381
5609
  PolicyRuleTypeRATELIMIT,
5382
5610
  PolicyV2Action,
5383
- PolicyV2ListQueriesScope,
5611
+ PolicyV2ListQueriesScopeItem,
5384
5612
  PolicyV2Scope,
5385
5613
  PregenerateAccountResponseCustody,
5386
5614
  PregenerateUserRequestV2AccountType,
@@ -5450,10 +5678,12 @@ export {
5450
5678
  SplValueCriterionRequestOperator,
5451
5679
  SplValueCriterionRequestType,
5452
5680
  SplValueCriterionSchema,
5681
+ SponsorEvmTransactionRuleSchema,
5453
5682
  SponsorSchema,
5454
5683
  SponsorSchemaCHARGECUSTOMTOKENS,
5455
5684
  SponsorSchemaFIXEDRATE,
5456
5685
  SponsorSchemaPAYFORUSER,
5686
+ SponsorSolTransactionRuleSchema,
5457
5687
  Status,
5458
5688
  ThirdPartyOAuthProvider,
5459
5689
  ThirdPartyOAuthProviderACCELBYTE,
@@ -5471,7 +5701,14 @@ export {
5471
5701
  TransactionIntentResponseExpandable,
5472
5702
  TransactionStatus,
5473
5703
  UnknownError,
5704
+ UpdateBackendWalletRequestAccountType,
5705
+ UpdateBackendWalletRequestChainType,
5706
+ UpdateBackendWalletResponseChainType,
5707
+ UpdateBackendWalletResponseCustody,
5708
+ UpdateBackendWalletResponseDelegatedAccountChainChainType,
5709
+ UpdateBackendWalletResponseObject,
5474
5710
  UpdatePolicyBodySchema,
5711
+ UsageAlertType,
5475
5712
  UserInputValidationError,
5476
5713
  UserProjectCreateRequestRole,
5477
5714
  UserProjectRole,
@@ -5494,15 +5731,16 @@ export {
5494
5731
  createContract,
5495
5732
  createDeveloperAccount,
5496
5733
  createEvent,
5734
+ createFeeSponsorship,
5497
5735
  createForwarderContract,
5736
+ createGasPolicyLegacy,
5737
+ createGasPolicyRuleLegacy,
5738
+ createGasPolicyWithdrawalLegacy,
5498
5739
  createOAuthConfig,
5499
5740
  createOnrampSession,
5500
5741
  createPaymaster,
5501
5742
  createPlayer,
5502
- createPolicy,
5503
- createPolicyRule,
5504
5743
  createPolicyV2,
5505
- createPolicyWithdrawal,
5506
5744
  createSession,
5507
5745
  createSubscription,
5508
5746
  createTransactionIntent,
@@ -5514,20 +5752,23 @@ export {
5514
5752
  deleteContract,
5515
5753
  deleteDeveloperAccount,
5516
5754
  deleteEvent,
5755
+ deleteFeeSponsorship,
5517
5756
  deleteForwarderContract,
5757
+ deleteGasPolicyLegacy,
5758
+ deleteGasPolicyRuleLegacy,
5518
5759
  deleteOAuthConfig,
5519
5760
  deletePaymaster,
5520
5761
  deletePlayer,
5521
- deletePolicy,
5522
- deletePolicyRule,
5523
5762
  deletePolicyV2,
5524
5763
  deleteSubscription,
5525
5764
  deleteTrigger,
5526
5765
  deleteUser,
5527
5766
  deprecatedCallbackOAuth,
5528
5767
  disableAccount,
5529
- disablePolicy,
5530
- enablePolicy,
5768
+ disableFeeSponsorship,
5769
+ disableGasPolicyLegacy,
5770
+ enableFeeSponsorship,
5771
+ enableGasPolicyLegacy,
5531
5772
  encryptForImport,
5532
5773
  estimateTransactionIntentCost,
5533
5774
  evaluatePolicyV2,
@@ -5549,7 +5790,14 @@ export {
5549
5790
  getDeveloperAccounts,
5550
5791
  getEvent,
5551
5792
  getEvents,
5793
+ getFeeSponsorship,
5552
5794
  getForwarderContract,
5795
+ getGasPoliciesLegacy,
5796
+ getGasPolicyBalanceLegacy,
5797
+ getGasPolicyLegacy,
5798
+ getGasPolicyReportTransactionIntentsLegacy,
5799
+ getGasPolicyRulesLegacy,
5800
+ getGasPolicyTotalGasUsageLegacy,
5553
5801
  getJwks,
5554
5802
  getOAuthConfig,
5555
5803
  getOnrampQuote,
@@ -5557,12 +5805,6 @@ export {
5557
5805
  getPlayer,
5558
5806
  getPlayerSessions,
5559
5807
  getPlayers,
5560
- getPolicies,
5561
- getPolicy,
5562
- getPolicyBalance,
5563
- getPolicyReportTransactionIntents,
5564
- getPolicyRules,
5565
- getPolicyTotalGasUsage,
5566
5808
  getPolicyV2,
5567
5809
  getProjectLogs,
5568
5810
  getSession,
@@ -5590,6 +5832,7 @@ export {
5590
5832
  linkThirdParty,
5591
5833
  list,
5592
5834
  listBackendWallets,
5835
+ listFeeSponsorships,
5593
5836
  listForwarderContracts,
5594
5837
  listOAuthConfig,
5595
5838
  listPaymasters,
@@ -5630,13 +5873,15 @@ export {
5630
5873
  unlinkEmail,
5631
5874
  unlinkOAuth,
5632
5875
  unlinkSIWE,
5876
+ updateBackendWallet,
5633
5877
  updateContract,
5634
5878
  updateDeveloperAccount,
5879
+ updateFeeSponsorship,
5635
5880
  updateForwarderContract,
5881
+ updateGasPolicyLegacy,
5882
+ updateGasPolicyRuleLegacy,
5636
5883
  updatePaymaster,
5637
5884
  updatePlayer,
5638
- updatePolicy,
5639
- updatePolicyRule,
5640
5885
  updatePolicyV2,
5641
5886
  verifyAuthToken,
5642
5887
  verifyEmail,