@openfort/openfort-node 0.8.4 → 0.9.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.
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.0";
378
379
  var PACKAGE = "@openfort/openfort-node";
379
380
 
380
381
  // src/openapi-client/openfortApiClient.ts
@@ -2001,6 +2002,76 @@ var deleteEvent = (id, options) => {
2001
2002
  );
2002
2003
  };
2003
2004
 
2005
+ // src/openapi-client/generated/fee-sponsorship/fee-sponsorship.ts
2006
+ var listFeeSponsorships = (params, options) => {
2007
+ return openfortApiClient(
2008
+ {
2009
+ url: `/v2/fee-sponsorship`,
2010
+ method: "GET",
2011
+ params
2012
+ },
2013
+ options
2014
+ );
2015
+ };
2016
+ var createFeeSponsorship = (createFeeSponsorshipRequest, options) => {
2017
+ return openfortApiClient(
2018
+ {
2019
+ url: `/v2/fee-sponsorship`,
2020
+ method: "POST",
2021
+ headers: { "Content-Type": "application/json" },
2022
+ data: createFeeSponsorshipRequest
2023
+ },
2024
+ options
2025
+ );
2026
+ };
2027
+ var getFeeSponsorship = (feeSponsorshipId, options) => {
2028
+ return openfortApiClient(
2029
+ {
2030
+ url: `/v2/fee-sponsorship/${feeSponsorshipId}`,
2031
+ method: "GET"
2032
+ },
2033
+ options
2034
+ );
2035
+ };
2036
+ var updateFeeSponsorship = (feeSponsorshipId, updateFeeSponsorshipRequest, options) => {
2037
+ return openfortApiClient(
2038
+ {
2039
+ url: `/v2/fee-sponsorship/${feeSponsorshipId}`,
2040
+ method: "PUT",
2041
+ headers: { "Content-Type": "application/json" },
2042
+ data: updateFeeSponsorshipRequest
2043
+ },
2044
+ options
2045
+ );
2046
+ };
2047
+ var deleteFeeSponsorship = (feeSponsorshipId, options) => {
2048
+ return openfortApiClient(
2049
+ {
2050
+ url: `/v2/fee-sponsorship/${feeSponsorshipId}`,
2051
+ method: "DELETE"
2052
+ },
2053
+ options
2054
+ );
2055
+ };
2056
+ var enableFeeSponsorship = (feeSponsorshipId, options) => {
2057
+ return openfortApiClient(
2058
+ {
2059
+ url: `/v2/fee-sponsorship/${feeSponsorshipId}/enable`,
2060
+ method: "PUT"
2061
+ },
2062
+ options
2063
+ );
2064
+ };
2065
+ var disableFeeSponsorship = (feeSponsorshipId, options) => {
2066
+ return openfortApiClient(
2067
+ {
2068
+ url: `/v2/fee-sponsorship/${feeSponsorshipId}/disable`,
2069
+ method: "PUT"
2070
+ },
2071
+ options
2072
+ );
2073
+ };
2074
+
2004
2075
  // src/openapi-client/generated/forwarder-contract/forwarder-contract.ts
2005
2076
  var createForwarderContract = (createForwarderContractRequest, options) => {
2006
2077
  return openfortApiClient(
@@ -2053,6 +2124,160 @@ var deleteForwarderContract = (id, options) => {
2053
2124
  );
2054
2125
  };
2055
2126
 
2127
+ // src/openapi-client/generated/gas-policies-legacy/gas-policies-legacy.ts
2128
+ var getGasPoliciesLegacy = (params, options) => {
2129
+ return openfortApiClient(
2130
+ {
2131
+ url: `/v1/policies`,
2132
+ method: "GET",
2133
+ params
2134
+ },
2135
+ options
2136
+ );
2137
+ };
2138
+ var createGasPolicyLegacy = (createPolicyRequest, options) => {
2139
+ return openfortApiClient(
2140
+ {
2141
+ url: `/v1/policies`,
2142
+ method: "POST",
2143
+ headers: { "Content-Type": "application/json" },
2144
+ data: createPolicyRequest
2145
+ },
2146
+ options
2147
+ );
2148
+ };
2149
+ var getGasPolicyLegacy = (id, params, options) => {
2150
+ return openfortApiClient(
2151
+ {
2152
+ url: `/v1/policies/${id}`,
2153
+ method: "GET",
2154
+ params
2155
+ },
2156
+ options
2157
+ );
2158
+ };
2159
+ var updateGasPolicyLegacy = (id, updatePolicyRequest, options) => {
2160
+ return openfortApiClient(
2161
+ {
2162
+ url: `/v1/policies/${id}`,
2163
+ method: "POST",
2164
+ headers: { "Content-Type": "application/json" },
2165
+ data: updatePolicyRequest
2166
+ },
2167
+ options
2168
+ );
2169
+ };
2170
+ var deleteGasPolicyLegacy = (id, options) => {
2171
+ return openfortApiClient(
2172
+ {
2173
+ url: `/v1/policies/${id}`,
2174
+ method: "DELETE"
2175
+ },
2176
+ options
2177
+ );
2178
+ };
2179
+ var disableGasPolicyLegacy = (id, options) => {
2180
+ return openfortApiClient(
2181
+ {
2182
+ url: `/v1/policies/${id}/disable`,
2183
+ method: "PUT"
2184
+ },
2185
+ options
2186
+ );
2187
+ };
2188
+ var enableGasPolicyLegacy = (id, options) => {
2189
+ return openfortApiClient(
2190
+ {
2191
+ url: `/v1/policies/${id}/enable`,
2192
+ method: "PUT"
2193
+ },
2194
+ options
2195
+ );
2196
+ };
2197
+ var getGasPolicyTotalGasUsageLegacy = (id, params, options) => {
2198
+ return openfortApiClient(
2199
+ {
2200
+ url: `/v1/policies/${id}/reports`,
2201
+ method: "GET",
2202
+ params
2203
+ },
2204
+ options
2205
+ );
2206
+ };
2207
+ var getGasPolicyReportTransactionIntentsLegacy = (id, params, options) => {
2208
+ return openfortApiClient(
2209
+ {
2210
+ url: `/v1/policies/${id}/reports/transaction_intents`,
2211
+ method: "GET",
2212
+ params
2213
+ },
2214
+ options
2215
+ );
2216
+ };
2217
+ var getGasPolicyBalanceLegacy = (id, options) => {
2218
+ return openfortApiClient(
2219
+ {
2220
+ url: `/v1/policies/${id}/withdraw`,
2221
+ method: "GET"
2222
+ },
2223
+ options
2224
+ );
2225
+ };
2226
+ var createGasPolicyWithdrawalLegacy = (id, withdrawalPolicyRequest, options) => {
2227
+ return openfortApiClient(
2228
+ {
2229
+ url: `/v1/policies/${id}/withdraw`,
2230
+ method: "POST",
2231
+ headers: { "Content-Type": "application/json" },
2232
+ data: withdrawalPolicyRequest
2233
+ },
2234
+ options
2235
+ );
2236
+ };
2237
+
2238
+ // src/openapi-client/generated/gas-policy-rules-legacy/gas-policy-rules-legacy.ts
2239
+ var getGasPolicyRulesLegacy = (params, options) => {
2240
+ return openfortApiClient(
2241
+ {
2242
+ url: `/v1/policy_rules`,
2243
+ method: "GET",
2244
+ params
2245
+ },
2246
+ options
2247
+ );
2248
+ };
2249
+ var createGasPolicyRuleLegacy = (createPolicyRuleRequest, options) => {
2250
+ return openfortApiClient(
2251
+ {
2252
+ url: `/v1/policy_rules`,
2253
+ method: "POST",
2254
+ headers: { "Content-Type": "application/json" },
2255
+ data: createPolicyRuleRequest
2256
+ },
2257
+ options
2258
+ );
2259
+ };
2260
+ var updateGasPolicyRuleLegacy = (id, updatePolicyRuleRequest, options) => {
2261
+ return openfortApiClient(
2262
+ {
2263
+ url: `/v1/policy_rules/${id}`,
2264
+ method: "POST",
2265
+ headers: { "Content-Type": "application/json" },
2266
+ data: updatePolicyRuleRequest
2267
+ },
2268
+ options
2269
+ );
2270
+ };
2271
+ var deleteGasPolicyRuleLegacy = (id, options) => {
2272
+ return openfortApiClient(
2273
+ {
2274
+ url: `/v1/policy_rules/${id}`,
2275
+ method: "DELETE"
2276
+ },
2277
+ options
2278
+ );
2279
+ };
2280
+
2056
2281
  // src/openapi-client/generated/graph-q-l/graph-q-l.ts
2057
2282
  var query = (queryBody, options) => {
2058
2283
  return openfortApiClient(
@@ -2365,7 +2590,8 @@ var PregenerateUserRequestV2ChainType = {
2365
2590
  };
2366
2591
  var PolicyV2Scope = {
2367
2592
  project: "project",
2368
- account: "account"
2593
+ account: "account",
2594
+ transaction: "transaction"
2369
2595
  };
2370
2596
  var PolicyV2Action = {
2371
2597
  accept: "accept",
@@ -2497,9 +2723,10 @@ var EntityTypePOLICYV2RULE = {
2497
2723
  var EntityTypePOLICYV2 = {
2498
2724
  policyV2: "policyV2"
2499
2725
  };
2500
- var PolicyV2ListQueriesScope = {
2726
+ var PolicyV2ListQueriesScopeItem = {
2501
2727
  project: "project",
2502
- account: "account"
2728
+ account: "account",
2729
+ transaction: "transaction"
2503
2730
  };
2504
2731
  var EvmAddressCriterionRequestType = {
2505
2732
  evmAddress: "evmAddress"
@@ -2637,11 +2864,15 @@ var CreatePolicyV2RuleRequestAction = {
2637
2864
  };
2638
2865
  var CreatePolicyV2RequestScope = {
2639
2866
  project: "project",
2640
- account: "account"
2867
+ account: "account",
2868
+ transaction: "transaction"
2641
2869
  };
2642
2870
  var EvaluatePolicyV2ResponseObject = {
2643
2871
  policy_evaluation: "policy_evaluation"
2644
2872
  };
2873
+ var EntityTypeFEESPONSORSHIP = {
2874
+ feeSponsorship: "feeSponsorship"
2875
+ };
2645
2876
  var CreateEmbeddedRequestAccountType = {
2646
2877
  Externally_Owned_Account: "Externally Owned Account",
2647
2878
  Smart_Account: "Smart Account",
@@ -2920,12 +3151,13 @@ var AuthenticationType = {
2920
3151
  basic: "basic",
2921
3152
  third_party: "third_party"
2922
3153
  };
2923
- var GetPolicyRulesExpandItem = {
3154
+ var GetGasPolicyRulesLegacyExpandItem = {
2924
3155
  contract: "contract"
2925
3156
  };
2926
- var ListPoliciesScope = {
3157
+ var ListPoliciesScopeItem = {
2927
3158
  project: "project",
2928
- account: "account"
3159
+ account: "account",
3160
+ transaction: "transaction"
2929
3161
  };
2930
3162
  var ListBackendWalletsChainType = {
2931
3163
  EVM: "EVM",
@@ -3073,115 +3305,6 @@ var cancelTransferAccountOwnership = (id, playerCancelTransferOwnershipRequest,
3073
3305
  };
3074
3306
 
3075
3307
  // 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
3308
  var listPolicies = (params, options) => {
3186
3309
  return openfortApiClient(
3187
3310
  {
@@ -3244,49 +3367,6 @@ var evaluatePolicyV2 = (evaluatePolicyV2Request, options) => {
3244
3367
  );
3245
3368
  };
3246
3369
 
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
3370
  // src/openapi-client/generated/rpc/rpc.ts
3291
3371
  var handleRpcRequest = (jsonRpcRequest, options) => {
3292
3372
  return openfortApiClient(
@@ -4432,6 +4512,19 @@ var SignEvmHashRuleSchema = z.object({
4432
4512
  action: ActionEnum,
4433
4513
  operation: z.literal("signEvmHash")
4434
4514
  });
4515
+ var SponsorEvmTransactionCriteriaSchema = z.array(
4516
+ z.discriminatedUnion("type", [
4517
+ EthValueCriterionSchema,
4518
+ EvmAddressCriterionSchema,
4519
+ EvmNetworkCriterionSchema,
4520
+ EvmDataCriterionSchema
4521
+ ])
4522
+ ).max(10);
4523
+ var SponsorEvmTransactionRuleSchema = z.object({
4524
+ action: ActionEnum,
4525
+ operation: z.literal("sponsorEvmTransaction"),
4526
+ criteria: SponsorEvmTransactionCriteriaSchema
4527
+ });
4435
4528
 
4436
4529
  // src/policies/solanaSchema.ts
4437
4530
  import { z as z2 } from "zod";
@@ -4549,6 +4642,23 @@ var SignSolMessageRuleSchema = z2.object({
4549
4642
  operation: z2.literal("signSolMessage"),
4550
4643
  criteria: SignSolMessageCriteriaSchema
4551
4644
  });
4645
+ var SponsorSolTransactionCriteriaSchema = z2.array(
4646
+ z2.discriminatedUnion("type", [
4647
+ SolAddressCriterionSchema,
4648
+ SolValueCriterionSchema,
4649
+ SplAddressCriterionSchema,
4650
+ SplValueCriterionSchema,
4651
+ MintAddressCriterionSchema,
4652
+ SolDataCriterionSchema,
4653
+ ProgramIdCriterionSchema,
4654
+ SolNetworkCriterionSchema
4655
+ ])
4656
+ ).max(10);
4657
+ var SponsorSolTransactionRuleSchema = z2.object({
4658
+ action: ActionEnum,
4659
+ operation: z2.literal("sponsorSolTransaction"),
4660
+ criteria: SponsorSolTransactionCriteriaSchema
4661
+ });
4552
4662
 
4553
4663
  // src/policies/types.ts
4554
4664
  import { z as z3 } from "zod";
@@ -4559,9 +4669,11 @@ var RuleSchema = z3.discriminatedUnion("operation", [
4559
4669
  SignEvmMessageRuleSchema,
4560
4670
  SignEvmTypedDataRuleSchema,
4561
4671
  SignEvmHashRuleSchema,
4672
+ SponsorEvmTransactionRuleSchema,
4562
4673
  SignSolTransactionRuleSchema,
4563
4674
  SendSolTransactionRuleSchema,
4564
- SignSolMessageRuleSchema
4675
+ SignSolMessageRuleSchema,
4676
+ SponsorSolTransactionRuleSchema
4565
4677
  ]);
4566
4678
  var CreatePolicyBodySchema = z3.object({
4567
4679
  /** The scope of the policy. 'project' applies to all accounts, 'account' applies to a specific account. */
@@ -4745,8 +4857,8 @@ var Openfort = class {
4745
4857
  // Players API
4746
4858
  // ============================================
4747
4859
  /**
4748
- * Player management endpoints
4749
- * @deprecated
4860
+ * Player management endpoints.
4861
+ * @deprecated Use `openfort.iam.users` for V2 user management.
4750
4862
  */
4751
4863
  get players() {
4752
4864
  return {
@@ -4786,39 +4898,60 @@ var Openfort = class {
4786
4898
  // Policies API
4787
4899
  // ============================================
4788
4900
  /**
4789
- * Policy management endpoints for controlling account operations.
4901
+ * Policy management endpoints for criteria-based access control.
4790
4902
  *
4791
4903
  * Policies define rules that govern what operations accounts can perform,
4792
- * including transaction signing, message signing, and more.
4904
+ * including transaction signing, message signing, and gas sponsorship.
4905
+ * Each policy has a scope (project, account, or transaction), a priority,
4906
+ * and an ordered list of rules. Each rule specifies an action (accept/reject),
4907
+ * an operation, and criteria that must all match (AND logic).
4908
+ *
4909
+ * **Supported operations:**
4910
+ * - EVM: `signEvmTransaction`, `sendEvmTransaction`, `signEvmTypedData`, `signEvmMessage`, `signEvmHash`, `sponsorEvmTransaction`
4911
+ * - Solana: `signSolTransaction`, `sendSolTransaction`, `signSolMessage`, `sponsorSolTransaction`
4912
+ *
4913
+ * **Supported criteria types:**
4914
+ * - EVM: `evmAddress`, `ethValue`, `evmNetwork`, `evmData`, `evmMessage`, `evmTypedDataVerifyingContract`, `evmTypedDataField`
4915
+ * - Solana: `solAddress`, `solValue`, `splAddress`, `splValue`, `mintAddress`, `programId`, `solNetwork`, `solMessage`, `solData`
4916
+ *
4917
+ * Policies are evaluated in priority order (highest first). The first matching rule determines the outcome.
4918
+ * If policies exist but no rule matches, the operation is rejected (fail-closed).
4793
4919
  *
4794
4920
  * @example
4795
4921
  * ```typescript
4796
- * // List all policies
4797
- * const all = await openfort.policies.list();
4798
- *
4799
- * // Create a policy
4922
+ * // Create a policy that only allows transactions to specific addresses on certain chains
4800
4923
  * const policy = await openfort.policies.create({
4801
4924
  * scope: 'project',
4802
- * rules: [{ action: 'reject', operation: 'signEvmHash' }],
4925
+ * rules: [{
4926
+ * action: 'accept',
4927
+ * operation: 'sponsorEvmTransaction',
4928
+ * criteria: [
4929
+ * { type: 'evmNetwork', operator: 'in', chainIds: [1, 137] },
4930
+ * { type: 'evmAddress', operator: 'in', addresses: ['0x...'] },
4931
+ * ],
4932
+ * }],
4803
4933
  * });
4804
4934
  *
4805
4935
  * // Evaluate whether an operation would be allowed
4806
- * const result = await openfort.policies.evaluate({ operation: 'signEvmTransaction', accountId: 'acc_...' });
4936
+ * const result = await openfort.policies.evaluate({
4937
+ * operation: 'signEvmTransaction',
4938
+ * accountId: 'acc_...',
4939
+ * });
4807
4940
  * ```
4808
4941
  */
4809
4942
  get policies() {
4810
4943
  return {
4811
- /** List policies */
4944
+ /** List policies, optionally filtered by scope, enabled status, or account */
4812
4945
  list: listPolicies,
4813
- /** Create a policy */
4946
+ /** Create a policy with scope, priority, and criteria-based rules */
4814
4947
  create: createPolicyV2,
4815
- /** Get a policy by ID */
4948
+ /** Get a policy by ID (ply_...) */
4816
4949
  get: getPolicyV2,
4817
- /** Update a policy */
4950
+ /** Update a policy's description, priority, enabled status, or rules */
4818
4951
  update: updatePolicyV2,
4819
- /** Delete a policy */
4952
+ /** Soft-delete a policy */
4820
4953
  delete: deletePolicyV2,
4821
- /** Evaluate an operation against policies */
4954
+ /** Pre-flight check: evaluate whether an operation would be allowed without executing it */
4822
4955
  evaluate: evaluatePolicyV2
4823
4956
  };
4824
4957
  }
@@ -4826,56 +4959,83 @@ var Openfort = class {
4826
4959
  // Fee Sponsorship API
4827
4960
  // ============================================
4828
4961
  /**
4829
- * Fee sponsorship (gas policy) management endpoints
4962
+ * Fee sponsorship endpoints for sponsoring gas costs on behalf of users.
4963
+ *
4964
+ * A fee sponsorship links a strategy (how gas is paid) to a policy (which
4965
+ * transactions qualify). Create a policy first via `openfort.policies.create()`,
4966
+ * then create a fee sponsorship referencing it.
4967
+ *
4968
+ * **Strategies (`sponsorSchema`):**
4969
+ * - `pay_for_user` — Developer fully sponsors gas costs
4970
+ * - `charge_custom_tokens` — User pays in ERC-20 tokens (fixed or dynamic exchange rate)
4971
+ * - `fixed_rate` — User pays a fixed token amount per transaction
4972
+ *
4973
+ * **Workflow:**
4974
+ * 1. Create a policy via `openfort.policies.create()` with criteria rules
4975
+ * 2. Create a fee sponsorship via `openfort.feeSponsorship.create()` linking to that policy
4976
+ *
4977
+ * When a transaction is submitted without an explicit policy, project-scoped fee
4978
+ * sponsorships are auto-discovered and the first matching one is applied.
4979
+ *
4980
+ * @example
4981
+ * ```typescript
4982
+ * // 1. Create a policy to sponsor transactions on Polygon
4983
+ * const policy = await openfort.policies.create({
4984
+ * scope: 'project',
4985
+ * rules: [{
4986
+ * action: 'accept',
4987
+ * operation: 'sponsorEvmTransaction',
4988
+ * criteria: [{ type: 'evmNetwork', operator: 'in', chainIds: [137] }],
4989
+ * }],
4990
+ * });
4991
+ *
4992
+ * // 2. Create a fee sponsorship with pay_for_user strategy
4993
+ * const sponsorship = await openfort.feeSponsorship.create({
4994
+ * name: 'Polygon Gas Sponsorship',
4995
+ * strategy: { sponsorSchema: 'pay_for_user' },
4996
+ * policyId: policy.id,
4997
+ * });
4998
+ * ```
4830
4999
  */
4831
5000
  get feeSponsorship() {
4832
5001
  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
- }
5002
+ /** List fee sponsorships, optionally filtered by name, chainId, or enabled status */
5003
+ list: listFeeSponsorships,
5004
+ /** Create a fee sponsorship linked to a policy (policyId required) */
5005
+ create: createFeeSponsorship,
5006
+ /** Get a fee sponsorship by ID (pol_...) */
5007
+ get: getFeeSponsorship,
5008
+ /** Update a fee sponsorship's name, strategy, or linked policy */
5009
+ update: updateFeeSponsorship,
5010
+ /** Soft-delete a fee sponsorship */
5011
+ delete: deleteFeeSponsorship,
5012
+ /** Disable a fee sponsorship (stops it from being applied to transactions) */
5013
+ disable: disableFeeSponsorship,
5014
+ /** Enable a previously disabled fee sponsorship */
5015
+ enable: enableFeeSponsorship
4860
5016
  };
4861
5017
  }
4862
5018
  // ============================================
4863
5019
  // Transaction Intents API
4864
5020
  // ============================================
4865
5021
  /**
4866
- * Transaction intent management endpoints
5022
+ * Transaction intent endpoints for creating and managing on-chain transactions.
5023
+ *
5024
+ * Transaction intents represent a desired on-chain action (contract calls, transfers).
5025
+ * When a fee sponsorship policy is provided (or auto-discovered from project-scoped policies),
5026
+ * gas costs are sponsored according to the policy's strategy.
4867
5027
  */
4868
5028
  get transactionIntents() {
4869
5029
  return {
4870
5030
  /** List transaction intents */
4871
5031
  list: getTransactionIntents,
4872
- /** Create a transaction intent */
5032
+ /** Create a transaction intent with contract interactions */
4873
5033
  create: createTransactionIntent,
4874
5034
  /** Get a transaction intent by ID */
4875
5035
  get: getTransactionIntent,
4876
5036
  /** Sign a transaction intent */
4877
5037
  signature,
4878
- /** Estimate cost */
5038
+ /** Estimate gas cost for a transaction before creating it */
4879
5039
  estimateCost: estimateTransactionIntentCost
4880
5040
  };
4881
5041
  }
@@ -4900,27 +5060,6 @@ var Openfort = class {
4900
5060
  };
4901
5061
  }
4902
5062
  // ============================================
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
5063
  // Subscriptions API
4925
5064
  // ============================================
4926
5065
  /**
@@ -5069,7 +5208,10 @@ var Openfort = class {
5069
5208
  const { recoveryShare: _, ...accountResponse } = response;
5070
5209
  return accountResponse;
5071
5210
  } catch (error) {
5072
- await deleteUser(response.user);
5211
+ try {
5212
+ await deleteUser(response.user);
5213
+ } catch {
5214
+ }
5073
5215
  throw error;
5074
5216
  }
5075
5217
  }
@@ -5100,6 +5242,11 @@ var Openfort = class {
5100
5242
  * @internal
5101
5243
  */
5102
5244
  async preRegisterWithShield(recoveryShare, openfortUserId, thirdPartyUserId, config) {
5245
+ if (!config.shieldApiKey || !config.shieldApiSecret || !config.encryptionShare) {
5246
+ throw new Error(
5247
+ "Shield configuration requires shieldApiKey, shieldApiSecret, and encryptionShare"
5248
+ );
5249
+ }
5103
5250
  let externalUserId;
5104
5251
  if (config.shieldAuthProvider === ShieldAuthProvider.OPENFORT) {
5105
5252
  externalUserId = openfortUserId;
@@ -5134,13 +5281,16 @@ var Openfort = class {
5134
5281
  // Paymasters API
5135
5282
  // ============================================
5136
5283
  /**
5137
- * Paymaster endpoints
5284
+ * Paymaster endpoints for managing ERC-4337 paymasters.
5285
+ *
5286
+ * Paymasters handle gas payment on-chain for account abstraction (ERC-4337).
5287
+ * Fee sponsorships reference a paymaster to determine how user operations are sponsored.
5138
5288
  */
5139
5289
  get paymasters() {
5140
5290
  return {
5141
5291
  /** Create a paymaster */
5142
5292
  create: createPaymaster,
5143
- /** Get a paymaster by ID */
5293
+ /** Get a paymaster by ID (pay_...) */
5144
5294
  get: getPaymaster,
5145
5295
  /** Update a paymaster */
5146
5296
  update: updatePaymaster,
@@ -5159,10 +5309,16 @@ var Openfort = class {
5159
5309
  */
5160
5310
  async constructWebhookEvent(body, signature2) {
5161
5311
  const signedPayload = await sign2(this._apiKey, body);
5162
- if (signedPayload !== signature2) {
5163
- throw Error("Invalid signature");
5312
+ const expectedBuffer = Buffer.from(signedPayload, "hex");
5313
+ const receivedBuffer = Buffer.from(signature2, "hex");
5314
+ if (expectedBuffer.length !== receivedBuffer.length || !timingSafeEqual(expectedBuffer, receivedBuffer)) {
5315
+ throw new Error("Invalid signature");
5316
+ }
5317
+ try {
5318
+ return JSON.parse(body);
5319
+ } catch {
5320
+ throw new Error("Failed to parse webhook payload");
5164
5321
  }
5165
- return JSON.parse(body);
5166
5322
  }
5167
5323
  /**
5168
5324
  * Creates an encryption session with Shield.
@@ -5272,6 +5428,7 @@ export {
5272
5428
  EntityTypeDEVICE,
5273
5429
  EntityTypeEMAILSAMPLE,
5274
5430
  EntityTypeEVENT,
5431
+ EntityTypeFEESPONSORSHIP,
5275
5432
  EntityTypeFORWARDERCONTRACT,
5276
5433
  EntityTypeLOG,
5277
5434
  EntityTypePAYMASTER,
@@ -5332,7 +5489,7 @@ export {
5332
5489
  GetAccountsV2AccountType,
5333
5490
  GetAccountsV2ChainType,
5334
5491
  GetAccountsV2Custody,
5335
- GetPolicyRulesExpandItem,
5492
+ GetGasPolicyRulesLegacyExpandItem,
5336
5493
  IMPORT_ENCRYPTION_PUBLIC_KEY,
5337
5494
  ImportPrivateKeyRequestChainType,
5338
5495
  ImportPrivateKeyResponseChainType,
@@ -5344,7 +5501,7 @@ export {
5344
5501
  JsonRpcRequestJsonrpc,
5345
5502
  JsonRpcSuccessResponseAnyJsonrpc,
5346
5503
  ListBackendWalletsChainType,
5347
- ListPoliciesScope,
5504
+ ListPoliciesScopeItem,
5348
5505
  MintAddressCriterionOperator,
5349
5506
  MintAddressCriterionRequestOperator,
5350
5507
  MintAddressCriterionRequestType,
@@ -5380,7 +5537,7 @@ export {
5380
5537
  PolicyRuleTypeCONTRACT,
5381
5538
  PolicyRuleTypeRATELIMIT,
5382
5539
  PolicyV2Action,
5383
- PolicyV2ListQueriesScope,
5540
+ PolicyV2ListQueriesScopeItem,
5384
5541
  PolicyV2Scope,
5385
5542
  PregenerateAccountResponseCustody,
5386
5543
  PregenerateUserRequestV2AccountType,
@@ -5450,10 +5607,12 @@ export {
5450
5607
  SplValueCriterionRequestOperator,
5451
5608
  SplValueCriterionRequestType,
5452
5609
  SplValueCriterionSchema,
5610
+ SponsorEvmTransactionRuleSchema,
5453
5611
  SponsorSchema,
5454
5612
  SponsorSchemaCHARGECUSTOMTOKENS,
5455
5613
  SponsorSchemaFIXEDRATE,
5456
5614
  SponsorSchemaPAYFORUSER,
5615
+ SponsorSolTransactionRuleSchema,
5457
5616
  Status,
5458
5617
  ThirdPartyOAuthProvider,
5459
5618
  ThirdPartyOAuthProviderACCELBYTE,
@@ -5494,15 +5653,16 @@ export {
5494
5653
  createContract,
5495
5654
  createDeveloperAccount,
5496
5655
  createEvent,
5656
+ createFeeSponsorship,
5497
5657
  createForwarderContract,
5658
+ createGasPolicyLegacy,
5659
+ createGasPolicyRuleLegacy,
5660
+ createGasPolicyWithdrawalLegacy,
5498
5661
  createOAuthConfig,
5499
5662
  createOnrampSession,
5500
5663
  createPaymaster,
5501
5664
  createPlayer,
5502
- createPolicy,
5503
- createPolicyRule,
5504
5665
  createPolicyV2,
5505
- createPolicyWithdrawal,
5506
5666
  createSession,
5507
5667
  createSubscription,
5508
5668
  createTransactionIntent,
@@ -5514,20 +5674,23 @@ export {
5514
5674
  deleteContract,
5515
5675
  deleteDeveloperAccount,
5516
5676
  deleteEvent,
5677
+ deleteFeeSponsorship,
5517
5678
  deleteForwarderContract,
5679
+ deleteGasPolicyLegacy,
5680
+ deleteGasPolicyRuleLegacy,
5518
5681
  deleteOAuthConfig,
5519
5682
  deletePaymaster,
5520
5683
  deletePlayer,
5521
- deletePolicy,
5522
- deletePolicyRule,
5523
5684
  deletePolicyV2,
5524
5685
  deleteSubscription,
5525
5686
  deleteTrigger,
5526
5687
  deleteUser,
5527
5688
  deprecatedCallbackOAuth,
5528
5689
  disableAccount,
5529
- disablePolicy,
5530
- enablePolicy,
5690
+ disableFeeSponsorship,
5691
+ disableGasPolicyLegacy,
5692
+ enableFeeSponsorship,
5693
+ enableGasPolicyLegacy,
5531
5694
  encryptForImport,
5532
5695
  estimateTransactionIntentCost,
5533
5696
  evaluatePolicyV2,
@@ -5549,7 +5712,14 @@ export {
5549
5712
  getDeveloperAccounts,
5550
5713
  getEvent,
5551
5714
  getEvents,
5715
+ getFeeSponsorship,
5552
5716
  getForwarderContract,
5717
+ getGasPoliciesLegacy,
5718
+ getGasPolicyBalanceLegacy,
5719
+ getGasPolicyLegacy,
5720
+ getGasPolicyReportTransactionIntentsLegacy,
5721
+ getGasPolicyRulesLegacy,
5722
+ getGasPolicyTotalGasUsageLegacy,
5553
5723
  getJwks,
5554
5724
  getOAuthConfig,
5555
5725
  getOnrampQuote,
@@ -5557,12 +5727,6 @@ export {
5557
5727
  getPlayer,
5558
5728
  getPlayerSessions,
5559
5729
  getPlayers,
5560
- getPolicies,
5561
- getPolicy,
5562
- getPolicyBalance,
5563
- getPolicyReportTransactionIntents,
5564
- getPolicyRules,
5565
- getPolicyTotalGasUsage,
5566
5730
  getPolicyV2,
5567
5731
  getProjectLogs,
5568
5732
  getSession,
@@ -5590,6 +5754,7 @@ export {
5590
5754
  linkThirdParty,
5591
5755
  list,
5592
5756
  listBackendWallets,
5757
+ listFeeSponsorships,
5593
5758
  listForwarderContracts,
5594
5759
  listOAuthConfig,
5595
5760
  listPaymasters,
@@ -5632,11 +5797,12 @@ export {
5632
5797
  unlinkSIWE,
5633
5798
  updateContract,
5634
5799
  updateDeveloperAccount,
5800
+ updateFeeSponsorship,
5635
5801
  updateForwarderContract,
5802
+ updateGasPolicyLegacy,
5803
+ updateGasPolicyRuleLegacy,
5636
5804
  updatePaymaster,
5637
5805
  updatePlayer,
5638
- updatePolicy,
5639
- updatePolicyRule,
5640
5806
  updatePolicyV2,
5641
5807
  verifyAuthToken,
5642
5808
  verifyEmail,