@openfort/openfort-node 0.8.3 → 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.3";
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(
@@ -3756,11 +3836,10 @@ var decryptExportedPrivateKey = (encryptedPrivateKeyBase64, privateKeyPem) => {
3756
3836
  // src/wallets/evm/accounts/evmAccount.ts
3757
3837
  import {
3758
3838
  getTypesForEIP712Domain,
3759
- hashMessage,
3760
3839
  hashTypedData,
3761
- keccak256,
3762
3840
  parseSignature,
3763
- serializeTransaction
3841
+ serializeTransaction,
3842
+ toPrefixedMessage
3764
3843
  } from "viem";
3765
3844
 
3766
3845
  // src/wallets/evm/actions/signHash.ts
@@ -3788,19 +3867,13 @@ function toEvmAccount(data) {
3788
3867
  },
3789
3868
  async signMessage(parameters) {
3790
3869
  const { message } = parameters;
3791
- if (typeof message === "string") {
3792
- const hash2 = hashMessage(message);
3793
- const result2 = await sign(id, { data: hash2 });
3794
- return result2.signature;
3795
- }
3796
- const hash = hashMessage(message);
3797
- const result = await sign(id, { data: hash });
3870
+ const preimage = toPrefixedMessage(message);
3871
+ const result = await sign(id, { data: preimage });
3798
3872
  return result.signature;
3799
3873
  },
3800
3874
  async signTransaction(transaction) {
3801
3875
  const serialized = serializeTransaction(transaction);
3802
- const hash = keccak256(serialized);
3803
- const response = await sign(id, { data: hash });
3876
+ const response = await sign(id, { data: serialized });
3804
3877
  const signature2 = parseSignature(response.signature);
3805
3878
  const signedTransaction = serializeTransaction(
3806
3879
  transaction,
@@ -4439,6 +4512,19 @@ var SignEvmHashRuleSchema = z.object({
4439
4512
  action: ActionEnum,
4440
4513
  operation: z.literal("signEvmHash")
4441
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
+ });
4442
4528
 
4443
4529
  // src/policies/solanaSchema.ts
4444
4530
  import { z as z2 } from "zod";
@@ -4556,6 +4642,23 @@ var SignSolMessageRuleSchema = z2.object({
4556
4642
  operation: z2.literal("signSolMessage"),
4557
4643
  criteria: SignSolMessageCriteriaSchema
4558
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
+ });
4559
4662
 
4560
4663
  // src/policies/types.ts
4561
4664
  import { z as z3 } from "zod";
@@ -4566,9 +4669,11 @@ var RuleSchema = z3.discriminatedUnion("operation", [
4566
4669
  SignEvmMessageRuleSchema,
4567
4670
  SignEvmTypedDataRuleSchema,
4568
4671
  SignEvmHashRuleSchema,
4672
+ SponsorEvmTransactionRuleSchema,
4569
4673
  SignSolTransactionRuleSchema,
4570
4674
  SendSolTransactionRuleSchema,
4571
- SignSolMessageRuleSchema
4675
+ SignSolMessageRuleSchema,
4676
+ SponsorSolTransactionRuleSchema
4572
4677
  ]);
4573
4678
  var CreatePolicyBodySchema = z3.object({
4574
4679
  /** The scope of the policy. 'project' applies to all accounts, 'account' applies to a specific account. */
@@ -4596,11 +4701,11 @@ var UpdatePolicyBodySchema = z3.object({
4596
4701
  });
4597
4702
 
4598
4703
  // src/wallets/evm/actions/signMessage.ts
4599
- import { hashMessage as hashMessage2, toHex } from "viem";
4704
+ import { toHex, toPrefixedMessage as toPrefixedMessage2 } from "viem";
4600
4705
 
4601
4706
  // src/wallets/evm/actions/signTransaction.ts
4602
4707
  import {
4603
- keccak256 as keccak2562,
4708
+ keccak256,
4604
4709
  parseSignature as parseSignature2,
4605
4710
  serializeTransaction as serializeTransaction2
4606
4711
  } from "viem";
@@ -4752,8 +4857,8 @@ var Openfort = class {
4752
4857
  // Players API
4753
4858
  // ============================================
4754
4859
  /**
4755
- * Player management endpoints
4756
- * @deprecated
4860
+ * Player management endpoints.
4861
+ * @deprecated Use `openfort.iam.users` for V2 user management.
4757
4862
  */
4758
4863
  get players() {
4759
4864
  return {
@@ -4793,39 +4898,60 @@ var Openfort = class {
4793
4898
  // Policies API
4794
4899
  // ============================================
4795
4900
  /**
4796
- * Policy management endpoints for controlling account operations.
4901
+ * Policy management endpoints for criteria-based access control.
4797
4902
  *
4798
4903
  * Policies define rules that govern what operations accounts can perform,
4799
- * 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).
4800
4919
  *
4801
4920
  * @example
4802
4921
  * ```typescript
4803
- * // List all policies
4804
- * const all = await openfort.policies.list();
4805
- *
4806
- * // Create a policy
4922
+ * // Create a policy that only allows transactions to specific addresses on certain chains
4807
4923
  * const policy = await openfort.policies.create({
4808
4924
  * scope: 'project',
4809
- * 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
+ * }],
4810
4933
  * });
4811
4934
  *
4812
4935
  * // Evaluate whether an operation would be allowed
4813
- * const result = await openfort.policies.evaluate({ operation: 'signEvmTransaction', accountId: 'acc_...' });
4936
+ * const result = await openfort.policies.evaluate({
4937
+ * operation: 'signEvmTransaction',
4938
+ * accountId: 'acc_...',
4939
+ * });
4814
4940
  * ```
4815
4941
  */
4816
4942
  get policies() {
4817
4943
  return {
4818
- /** List policies */
4944
+ /** List policies, optionally filtered by scope, enabled status, or account */
4819
4945
  list: listPolicies,
4820
- /** Create a policy */
4946
+ /** Create a policy with scope, priority, and criteria-based rules */
4821
4947
  create: createPolicyV2,
4822
- /** Get a policy by ID */
4948
+ /** Get a policy by ID (ply_...) */
4823
4949
  get: getPolicyV2,
4824
- /** Update a policy */
4950
+ /** Update a policy's description, priority, enabled status, or rules */
4825
4951
  update: updatePolicyV2,
4826
- /** Delete a policy */
4952
+ /** Soft-delete a policy */
4827
4953
  delete: deletePolicyV2,
4828
- /** Evaluate an operation against policies */
4954
+ /** Pre-flight check: evaluate whether an operation would be allowed without executing it */
4829
4955
  evaluate: evaluatePolicyV2
4830
4956
  };
4831
4957
  }
@@ -4833,56 +4959,83 @@ var Openfort = class {
4833
4959
  // Fee Sponsorship API
4834
4960
  // ============================================
4835
4961
  /**
4836
- * 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
+ * ```
4837
4999
  */
4838
5000
  get feeSponsorship() {
4839
5001
  return {
4840
- /** List fee sponsorship policies */
4841
- list: getPolicies,
4842
- /** Create a fee sponsorship policy */
4843
- create: createPolicy,
4844
- /** Get a fee sponsorship policy by ID */
4845
- get: getPolicy,
4846
- /** Update a fee sponsorship policy */
4847
- update: updatePolicy,
4848
- /** Delete a fee sponsorship policy */
4849
- delete: deletePolicy,
4850
- /** Disable a fee sponsorship policy */
4851
- disable: disablePolicy,
4852
- /** Enable a fee sponsorship policy */
4853
- enable: enablePolicy,
4854
- /** Get fee sponsorship policy total gas usage */
4855
- getTotalGasUsage: getPolicyTotalGasUsage,
4856
- /** Fee sponsorship policy rules */
4857
- rules: {
4858
- /** List policy rules */
4859
- list: getPolicyRules,
4860
- /** Create a policy rule */
4861
- create: createPolicyRule,
4862
- /** Update a policy rule */
4863
- update: updatePolicyRule,
4864
- /** Delete a policy rule */
4865
- delete: deletePolicyRule
4866
- }
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
4867
5016
  };
4868
5017
  }
4869
5018
  // ============================================
4870
5019
  // Transaction Intents API
4871
5020
  // ============================================
4872
5021
  /**
4873
- * 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.
4874
5027
  */
4875
5028
  get transactionIntents() {
4876
5029
  return {
4877
5030
  /** List transaction intents */
4878
5031
  list: getTransactionIntents,
4879
- /** Create a transaction intent */
5032
+ /** Create a transaction intent with contract interactions */
4880
5033
  create: createTransactionIntent,
4881
5034
  /** Get a transaction intent by ID */
4882
5035
  get: getTransactionIntent,
4883
5036
  /** Sign a transaction intent */
4884
5037
  signature,
4885
- /** Estimate cost */
5038
+ /** Estimate gas cost for a transaction before creating it */
4886
5039
  estimateCost: estimateTransactionIntentCost
4887
5040
  };
4888
5041
  }
@@ -4907,27 +5060,6 @@ var Openfort = class {
4907
5060
  };
4908
5061
  }
4909
5062
  // ============================================
4910
- // Settings API
4911
- // ============================================
4912
- /**
4913
- * Settings / Developer account management endpoints
4914
- * @deprecated
4915
- */
4916
- get settings() {
4917
- return {
4918
- /** List developer accounts */
4919
- getDeveloperAccounts,
4920
- /** Create a developer account */
4921
- createDeveloperAccount,
4922
- /** Get a developer account by ID */
4923
- getDeveloperAccount,
4924
- /** Delete a developer account */
4925
- deleteDeveloperAccount,
4926
- /** Get verification payload */
4927
- getVerificationPayload
4928
- };
4929
- }
4930
- // ============================================
4931
5063
  // Subscriptions API
4932
5064
  // ============================================
4933
5065
  /**
@@ -5076,7 +5208,10 @@ var Openfort = class {
5076
5208
  const { recoveryShare: _, ...accountResponse } = response;
5077
5209
  return accountResponse;
5078
5210
  } catch (error) {
5079
- await deleteUser(response.user);
5211
+ try {
5212
+ await deleteUser(response.user);
5213
+ } catch {
5214
+ }
5080
5215
  throw error;
5081
5216
  }
5082
5217
  }
@@ -5107,6 +5242,11 @@ var Openfort = class {
5107
5242
  * @internal
5108
5243
  */
5109
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
+ }
5110
5250
  let externalUserId;
5111
5251
  if (config.shieldAuthProvider === ShieldAuthProvider.OPENFORT) {
5112
5252
  externalUserId = openfortUserId;
@@ -5141,13 +5281,16 @@ var Openfort = class {
5141
5281
  // Paymasters API
5142
5282
  // ============================================
5143
5283
  /**
5144
- * 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.
5145
5288
  */
5146
5289
  get paymasters() {
5147
5290
  return {
5148
5291
  /** Create a paymaster */
5149
5292
  create: createPaymaster,
5150
- /** Get a paymaster by ID */
5293
+ /** Get a paymaster by ID (pay_...) */
5151
5294
  get: getPaymaster,
5152
5295
  /** Update a paymaster */
5153
5296
  update: updatePaymaster,
@@ -5166,10 +5309,16 @@ var Openfort = class {
5166
5309
  */
5167
5310
  async constructWebhookEvent(body, signature2) {
5168
5311
  const signedPayload = await sign2(this._apiKey, body);
5169
- if (signedPayload !== signature2) {
5170
- 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");
5171
5321
  }
5172
- return JSON.parse(body);
5173
5322
  }
5174
5323
  /**
5175
5324
  * Creates an encryption session with Shield.
@@ -5279,6 +5428,7 @@ export {
5279
5428
  EntityTypeDEVICE,
5280
5429
  EntityTypeEMAILSAMPLE,
5281
5430
  EntityTypeEVENT,
5431
+ EntityTypeFEESPONSORSHIP,
5282
5432
  EntityTypeFORWARDERCONTRACT,
5283
5433
  EntityTypeLOG,
5284
5434
  EntityTypePAYMASTER,
@@ -5339,7 +5489,7 @@ export {
5339
5489
  GetAccountsV2AccountType,
5340
5490
  GetAccountsV2ChainType,
5341
5491
  GetAccountsV2Custody,
5342
- GetPolicyRulesExpandItem,
5492
+ GetGasPolicyRulesLegacyExpandItem,
5343
5493
  IMPORT_ENCRYPTION_PUBLIC_KEY,
5344
5494
  ImportPrivateKeyRequestChainType,
5345
5495
  ImportPrivateKeyResponseChainType,
@@ -5351,7 +5501,7 @@ export {
5351
5501
  JsonRpcRequestJsonrpc,
5352
5502
  JsonRpcSuccessResponseAnyJsonrpc,
5353
5503
  ListBackendWalletsChainType,
5354
- ListPoliciesScope,
5504
+ ListPoliciesScopeItem,
5355
5505
  MintAddressCriterionOperator,
5356
5506
  MintAddressCriterionRequestOperator,
5357
5507
  MintAddressCriterionRequestType,
@@ -5387,7 +5537,7 @@ export {
5387
5537
  PolicyRuleTypeCONTRACT,
5388
5538
  PolicyRuleTypeRATELIMIT,
5389
5539
  PolicyV2Action,
5390
- PolicyV2ListQueriesScope,
5540
+ PolicyV2ListQueriesScopeItem,
5391
5541
  PolicyV2Scope,
5392
5542
  PregenerateAccountResponseCustody,
5393
5543
  PregenerateUserRequestV2AccountType,
@@ -5457,10 +5607,12 @@ export {
5457
5607
  SplValueCriterionRequestOperator,
5458
5608
  SplValueCriterionRequestType,
5459
5609
  SplValueCriterionSchema,
5610
+ SponsorEvmTransactionRuleSchema,
5460
5611
  SponsorSchema,
5461
5612
  SponsorSchemaCHARGECUSTOMTOKENS,
5462
5613
  SponsorSchemaFIXEDRATE,
5463
5614
  SponsorSchemaPAYFORUSER,
5615
+ SponsorSolTransactionRuleSchema,
5464
5616
  Status,
5465
5617
  ThirdPartyOAuthProvider,
5466
5618
  ThirdPartyOAuthProviderACCELBYTE,
@@ -5501,15 +5653,16 @@ export {
5501
5653
  createContract,
5502
5654
  createDeveloperAccount,
5503
5655
  createEvent,
5656
+ createFeeSponsorship,
5504
5657
  createForwarderContract,
5658
+ createGasPolicyLegacy,
5659
+ createGasPolicyRuleLegacy,
5660
+ createGasPolicyWithdrawalLegacy,
5505
5661
  createOAuthConfig,
5506
5662
  createOnrampSession,
5507
5663
  createPaymaster,
5508
5664
  createPlayer,
5509
- createPolicy,
5510
- createPolicyRule,
5511
5665
  createPolicyV2,
5512
- createPolicyWithdrawal,
5513
5666
  createSession,
5514
5667
  createSubscription,
5515
5668
  createTransactionIntent,
@@ -5521,20 +5674,23 @@ export {
5521
5674
  deleteContract,
5522
5675
  deleteDeveloperAccount,
5523
5676
  deleteEvent,
5677
+ deleteFeeSponsorship,
5524
5678
  deleteForwarderContract,
5679
+ deleteGasPolicyLegacy,
5680
+ deleteGasPolicyRuleLegacy,
5525
5681
  deleteOAuthConfig,
5526
5682
  deletePaymaster,
5527
5683
  deletePlayer,
5528
- deletePolicy,
5529
- deletePolicyRule,
5530
5684
  deletePolicyV2,
5531
5685
  deleteSubscription,
5532
5686
  deleteTrigger,
5533
5687
  deleteUser,
5534
5688
  deprecatedCallbackOAuth,
5535
5689
  disableAccount,
5536
- disablePolicy,
5537
- enablePolicy,
5690
+ disableFeeSponsorship,
5691
+ disableGasPolicyLegacy,
5692
+ enableFeeSponsorship,
5693
+ enableGasPolicyLegacy,
5538
5694
  encryptForImport,
5539
5695
  estimateTransactionIntentCost,
5540
5696
  evaluatePolicyV2,
@@ -5556,7 +5712,14 @@ export {
5556
5712
  getDeveloperAccounts,
5557
5713
  getEvent,
5558
5714
  getEvents,
5715
+ getFeeSponsorship,
5559
5716
  getForwarderContract,
5717
+ getGasPoliciesLegacy,
5718
+ getGasPolicyBalanceLegacy,
5719
+ getGasPolicyLegacy,
5720
+ getGasPolicyReportTransactionIntentsLegacy,
5721
+ getGasPolicyRulesLegacy,
5722
+ getGasPolicyTotalGasUsageLegacy,
5560
5723
  getJwks,
5561
5724
  getOAuthConfig,
5562
5725
  getOnrampQuote,
@@ -5564,12 +5727,6 @@ export {
5564
5727
  getPlayer,
5565
5728
  getPlayerSessions,
5566
5729
  getPlayers,
5567
- getPolicies,
5568
- getPolicy,
5569
- getPolicyBalance,
5570
- getPolicyReportTransactionIntents,
5571
- getPolicyRules,
5572
- getPolicyTotalGasUsage,
5573
5730
  getPolicyV2,
5574
5731
  getProjectLogs,
5575
5732
  getSession,
@@ -5597,6 +5754,7 @@ export {
5597
5754
  linkThirdParty,
5598
5755
  list,
5599
5756
  listBackendWallets,
5757
+ listFeeSponsorships,
5600
5758
  listForwarderContracts,
5601
5759
  listOAuthConfig,
5602
5760
  listPaymasters,
@@ -5639,11 +5797,12 @@ export {
5639
5797
  unlinkSIWE,
5640
5798
  updateContract,
5641
5799
  updateDeveloperAccount,
5800
+ updateFeeSponsorship,
5642
5801
  updateForwarderContract,
5802
+ updateGasPolicyLegacy,
5803
+ updateGasPolicyRuleLegacy,
5643
5804
  updatePaymaster,
5644
5805
  updatePlayer,
5645
- updatePolicy,
5646
- updatePolicyRule,
5647
5806
  updatePolicyV2,
5648
5807
  verifyAuthToken,
5649
5808
  verifyEmail,