@arcenpay/node 0.0.1 → 0.0.2

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.
@@ -0,0 +1,191 @@
1
+ type PlanTier = "starter" | "pro" | "enterprise" | string;
2
+ interface UsageProof {
3
+ a: [bigint, bigint];
4
+ b: [[bigint, bigint], [bigint, bigint]];
5
+ c: [bigint, bigint];
6
+ }
7
+ interface PublicInputs {
8
+ agentAddress: string;
9
+ sessionId: string;
10
+ callCount: bigint;
11
+ windowStart: bigint;
12
+ windowEnd: bigint;
13
+ merkleRoot: string;
14
+ nullifier: string;
15
+ }
16
+ interface BillingSettlement {
17
+ sessionId: string;
18
+ agentAddress: string;
19
+ callCount: bigint;
20
+ settlementAmount: bigint;
21
+ windowStart: bigint;
22
+ windowEnd: bigint;
23
+ transactionHash: string;
24
+ }
25
+ interface X402VerifiedPaymentContext {
26
+ verified: true;
27
+ signer: string;
28
+ planId: string;
29
+ ratePerCall: string;
30
+ amount: string;
31
+ settledAmount: string;
32
+ settlementTxHash: string | null;
33
+ sessionId: string;
34
+ paymentHeader: string;
35
+ timestamp: number;
36
+ rejectionReason: null;
37
+ }
38
+ interface TablelandEntitlement {
39
+ wallet_address: string;
40
+ nft_token_id: number;
41
+ plan_tier: PlanTier;
42
+ feature_flags: Record<string, boolean | string | number>;
43
+ api_rate_limit: number;
44
+ billing_interval: number;
45
+ last_renewed: number;
46
+ expires_at: number;
47
+ chain_id: number;
48
+ }
49
+ /** Keys used to identify a company in API calls */
50
+ interface ArcenCompanyKeys {
51
+ /** Caller's own internal company ID (maps to externalId) */
52
+ id?: string;
53
+ /** Wallet address (checksummed or lowercase) */
54
+ wallet?: string;
55
+ /** Company email address */
56
+ email?: string;
57
+ }
58
+ /** Keys used to identify a user in API calls */
59
+ interface ArcenUserKeys {
60
+ /** Caller's own internal user ID (maps to externalId) */
61
+ id?: string;
62
+ /** Clerk user ID */
63
+ clerkUserId?: string;
64
+ /** Wallet address */
65
+ wallet?: string;
66
+ /** User email address */
67
+ email?: string;
68
+ }
69
+ /** A company entity in the entitlement system */
70
+ interface ArcenCompany {
71
+ id: string;
72
+ teamId: string;
73
+ name: string;
74
+ walletAddress?: string | null;
75
+ email?: string | null;
76
+ externalId?: string | null;
77
+ logoUrl?: string | null;
78
+ traits: Record<string, unknown>;
79
+ activePlanId?: string | null;
80
+ activeAddOnIds: string[];
81
+ createdAt: string;
82
+ lastSeenAt: string;
83
+ }
84
+ /** A user entity linked to a company */
85
+ interface ArcenUser {
86
+ id: string;
87
+ teamId: string;
88
+ companyId: string;
89
+ name?: string | null;
90
+ email?: string | null;
91
+ walletAddress?: string | null;
92
+ clerkUserId?: string | null;
93
+ externalId?: string | null;
94
+ traits: Record<string, unknown>;
95
+ createdAt: string;
96
+ lastSeenAt: string;
97
+ }
98
+ /** Response from the access token creation endpoint */
99
+ interface EmbedAccessTokenResponse {
100
+ token: string;
101
+ expiresAt: string;
102
+ }
103
+ /**
104
+ * Result of checkFlag() — boolean feature gating.
105
+ * Use for "should this feature be visible/enabled?"
106
+ */
107
+ interface FlagResult {
108
+ key: string;
109
+ /** Whether the feature is enabled for this company/user */
110
+ enabled: boolean;
111
+ /** Machine-readable reason: 'override', 'rule:<ruleId>', 'default' */
112
+ reason: string;
113
+ }
114
+ /**
115
+ * Result of checkEntitlement() — quota-aware feature gating.
116
+ * Use for "can this action still be performed under the customer's plan limits?"
117
+ */
118
+ interface EntitlementResult {
119
+ key: string;
120
+ /** Whether the feature/action is currently allowed */
121
+ enabled: boolean;
122
+ /** Machine-readable reason */
123
+ reason: string;
124
+ /** Maximum allowed usage. null = unlimited */
125
+ allocation: number | null;
126
+ /** Current usage count in the active billing period */
127
+ usage: number;
128
+ /** true when usage >= allocation (and allocation is not null) */
129
+ exceeded: boolean;
130
+ }
131
+ /**
132
+ * Result of consumeEntitlement() — quota-aware metered action enforcement.
133
+ * `consumed` is true only when a usage unit was actually recorded.
134
+ */
135
+ interface ConsumeEntitlementResult extends EntitlementResult {
136
+ consumed: boolean;
137
+ }
138
+ /**
139
+ * Result of identify() — creates/updates company+user and returns a session token.
140
+ */
141
+ interface IdentifyResult {
142
+ token: string;
143
+ companyId: string;
144
+ userId?: string;
145
+ expiresAt: string;
146
+ }
147
+
148
+ interface TablelandConfig {
149
+ /** Tableland table name (e.g., meap_feature_flags_84532_123) */
150
+ tableName: string;
151
+ /** Tableland controller wallet private key (required for writes) */
152
+ privateKey?: string;
153
+ /** Chain ID used for metadata and defaults */
154
+ chainId: number;
155
+ /** RPC URL for signer/provider connectivity */
156
+ rpcUrl?: string;
157
+ /** Gateway URL override (used for read HTTP fallback paths) */
158
+ gatewayUrl?: string;
159
+ }
160
+ type TierFlagsMatrix = Record<string, Record<string, boolean | string | number>>;
161
+ declare class TablelandService {
162
+ private config;
163
+ private initialized;
164
+ private dbRead;
165
+ private dbWrite;
166
+ constructor(config: TablelandConfig);
167
+ initialize(): Promise<void>;
168
+ getFeatureFlags(walletAddress: string): Promise<Record<string, boolean | string | number>>;
169
+ setFeatureFlags(walletAddress: string, flags: Record<string, boolean | string | number>, metadata: Partial<TablelandEntitlement>): Promise<boolean>;
170
+ revokeEntitlement(walletAddress: string): Promise<boolean>;
171
+ revokeEntitlementByTokenId(tokenId: number): Promise<boolean>;
172
+ updateEntitlementByTokenId(tokenId: number, updates: Partial<Pick<TablelandEntitlement, "feature_flags" | "plan_tier" | "expires_at" | "last_renewed" | "api_rate_limit" | "billing_interval">>): Promise<boolean>;
173
+ listEntitlements(limit?: number): Promise<TablelandEntitlement[]>;
174
+ syncSubscription(data: {
175
+ walletAddress: string;
176
+ tokenId: number;
177
+ planTier: PlanTier;
178
+ expiresAt: number;
179
+ billingInterval: number;
180
+ features: Record<string, boolean | string | number>;
181
+ }): Promise<void>;
182
+ listTierFeatureFlags(providerAddress: string, tiers?: string[]): Promise<TierFlagsMatrix>;
183
+ setTierFeatureFlags(providerAddress: string, tier: string, flags: Record<string, boolean | string | number>): Promise<boolean>;
184
+ private buildTierMatrixKey;
185
+ private defaultRateLimitForTier;
186
+ private ensureInitialized;
187
+ private ensureWritable;
188
+ private ensureSafeTableName;
189
+ }
190
+
191
+ export { type ArcenCompanyKeys as A, type BillingSettlement as B, type ConsumeEntitlementResult as C, type EntitlementResult as E, type FlagResult as F, type IdentifyResult as I, type PublicInputs as P, type TablelandConfig as T, type UsageProof as U, type X402VerifiedPaymentContext as X, type ArcenUserKeys as a, type ArcenCompany as b, type EmbedAccessTokenResponse as c, type PlanTier as d, type ArcenUser as e, TablelandService as f };
@@ -0,0 +1,191 @@
1
+ type PlanTier = "starter" | "pro" | "enterprise" | string;
2
+ interface UsageProof {
3
+ a: [bigint, bigint];
4
+ b: [[bigint, bigint], [bigint, bigint]];
5
+ c: [bigint, bigint];
6
+ }
7
+ interface PublicInputs {
8
+ agentAddress: string;
9
+ sessionId: string;
10
+ callCount: bigint;
11
+ windowStart: bigint;
12
+ windowEnd: bigint;
13
+ merkleRoot: string;
14
+ nullifier: string;
15
+ }
16
+ interface BillingSettlement {
17
+ sessionId: string;
18
+ agentAddress: string;
19
+ callCount: bigint;
20
+ settlementAmount: bigint;
21
+ windowStart: bigint;
22
+ windowEnd: bigint;
23
+ transactionHash: string;
24
+ }
25
+ interface X402VerifiedPaymentContext {
26
+ verified: true;
27
+ signer: string;
28
+ planId: string;
29
+ ratePerCall: string;
30
+ amount: string;
31
+ settledAmount: string;
32
+ settlementTxHash: string | null;
33
+ sessionId: string;
34
+ paymentHeader: string;
35
+ timestamp: number;
36
+ rejectionReason: null;
37
+ }
38
+ interface TablelandEntitlement {
39
+ wallet_address: string;
40
+ nft_token_id: number;
41
+ plan_tier: PlanTier;
42
+ feature_flags: Record<string, boolean | string | number>;
43
+ api_rate_limit: number;
44
+ billing_interval: number;
45
+ last_renewed: number;
46
+ expires_at: number;
47
+ chain_id: number;
48
+ }
49
+ /** Keys used to identify a company in API calls */
50
+ interface ArcenCompanyKeys {
51
+ /** Caller's own internal company ID (maps to externalId) */
52
+ id?: string;
53
+ /** Wallet address (checksummed or lowercase) */
54
+ wallet?: string;
55
+ /** Company email address */
56
+ email?: string;
57
+ }
58
+ /** Keys used to identify a user in API calls */
59
+ interface ArcenUserKeys {
60
+ /** Caller's own internal user ID (maps to externalId) */
61
+ id?: string;
62
+ /** Clerk user ID */
63
+ clerkUserId?: string;
64
+ /** Wallet address */
65
+ wallet?: string;
66
+ /** User email address */
67
+ email?: string;
68
+ }
69
+ /** A company entity in the entitlement system */
70
+ interface ArcenCompany {
71
+ id: string;
72
+ teamId: string;
73
+ name: string;
74
+ walletAddress?: string | null;
75
+ email?: string | null;
76
+ externalId?: string | null;
77
+ logoUrl?: string | null;
78
+ traits: Record<string, unknown>;
79
+ activePlanId?: string | null;
80
+ activeAddOnIds: string[];
81
+ createdAt: string;
82
+ lastSeenAt: string;
83
+ }
84
+ /** A user entity linked to a company */
85
+ interface ArcenUser {
86
+ id: string;
87
+ teamId: string;
88
+ companyId: string;
89
+ name?: string | null;
90
+ email?: string | null;
91
+ walletAddress?: string | null;
92
+ clerkUserId?: string | null;
93
+ externalId?: string | null;
94
+ traits: Record<string, unknown>;
95
+ createdAt: string;
96
+ lastSeenAt: string;
97
+ }
98
+ /** Response from the access token creation endpoint */
99
+ interface EmbedAccessTokenResponse {
100
+ token: string;
101
+ expiresAt: string;
102
+ }
103
+ /**
104
+ * Result of checkFlag() — boolean feature gating.
105
+ * Use for "should this feature be visible/enabled?"
106
+ */
107
+ interface FlagResult {
108
+ key: string;
109
+ /** Whether the feature is enabled for this company/user */
110
+ enabled: boolean;
111
+ /** Machine-readable reason: 'override', 'rule:<ruleId>', 'default' */
112
+ reason: string;
113
+ }
114
+ /**
115
+ * Result of checkEntitlement() — quota-aware feature gating.
116
+ * Use for "can this action still be performed under the customer's plan limits?"
117
+ */
118
+ interface EntitlementResult {
119
+ key: string;
120
+ /** Whether the feature/action is currently allowed */
121
+ enabled: boolean;
122
+ /** Machine-readable reason */
123
+ reason: string;
124
+ /** Maximum allowed usage. null = unlimited */
125
+ allocation: number | null;
126
+ /** Current usage count in the active billing period */
127
+ usage: number;
128
+ /** true when usage >= allocation (and allocation is not null) */
129
+ exceeded: boolean;
130
+ }
131
+ /**
132
+ * Result of consumeEntitlement() — quota-aware metered action enforcement.
133
+ * `consumed` is true only when a usage unit was actually recorded.
134
+ */
135
+ interface ConsumeEntitlementResult extends EntitlementResult {
136
+ consumed: boolean;
137
+ }
138
+ /**
139
+ * Result of identify() — creates/updates company+user and returns a session token.
140
+ */
141
+ interface IdentifyResult {
142
+ token: string;
143
+ companyId: string;
144
+ userId?: string;
145
+ expiresAt: string;
146
+ }
147
+
148
+ interface TablelandConfig {
149
+ /** Tableland table name (e.g., meap_feature_flags_84532_123) */
150
+ tableName: string;
151
+ /** Tableland controller wallet private key (required for writes) */
152
+ privateKey?: string;
153
+ /** Chain ID used for metadata and defaults */
154
+ chainId: number;
155
+ /** RPC URL for signer/provider connectivity */
156
+ rpcUrl?: string;
157
+ /** Gateway URL override (used for read HTTP fallback paths) */
158
+ gatewayUrl?: string;
159
+ }
160
+ type TierFlagsMatrix = Record<string, Record<string, boolean | string | number>>;
161
+ declare class TablelandService {
162
+ private config;
163
+ private initialized;
164
+ private dbRead;
165
+ private dbWrite;
166
+ constructor(config: TablelandConfig);
167
+ initialize(): Promise<void>;
168
+ getFeatureFlags(walletAddress: string): Promise<Record<string, boolean | string | number>>;
169
+ setFeatureFlags(walletAddress: string, flags: Record<string, boolean | string | number>, metadata: Partial<TablelandEntitlement>): Promise<boolean>;
170
+ revokeEntitlement(walletAddress: string): Promise<boolean>;
171
+ revokeEntitlementByTokenId(tokenId: number): Promise<boolean>;
172
+ updateEntitlementByTokenId(tokenId: number, updates: Partial<Pick<TablelandEntitlement, "feature_flags" | "plan_tier" | "expires_at" | "last_renewed" | "api_rate_limit" | "billing_interval">>): Promise<boolean>;
173
+ listEntitlements(limit?: number): Promise<TablelandEntitlement[]>;
174
+ syncSubscription(data: {
175
+ walletAddress: string;
176
+ tokenId: number;
177
+ planTier: PlanTier;
178
+ expiresAt: number;
179
+ billingInterval: number;
180
+ features: Record<string, boolean | string | number>;
181
+ }): Promise<void>;
182
+ listTierFeatureFlags(providerAddress: string, tiers?: string[]): Promise<TierFlagsMatrix>;
183
+ setTierFeatureFlags(providerAddress: string, tier: string, flags: Record<string, boolean | string | number>): Promise<boolean>;
184
+ private buildTierMatrixKey;
185
+ private defaultRateLimitForTier;
186
+ private ensureInitialized;
187
+ private ensureWritable;
188
+ private ensureSafeTableName;
189
+ }
190
+
191
+ export { type ArcenCompanyKeys as A, type BillingSettlement as B, type ConsumeEntitlementResult as C, type EntitlementResult as E, type FlagResult as F, type IdentifyResult as I, type PublicInputs as P, type TablelandConfig as T, type UsageProof as U, type X402VerifiedPaymentContext as X, type ArcenUserKeys as a, type ArcenCompany as b, type EmbedAccessTokenResponse as c, type PlanTier as d, type ArcenUser as e, TablelandService as f };
@@ -1,46 +1 @@
1
- import { TablelandEntitlement, PlanTier } from '@arcenpay/sdk';
2
-
3
- interface TablelandConfig {
4
- /** Tableland table name (e.g., meap_feature_flags_84532_123) */
5
- tableName: string;
6
- /** Tableland controller wallet private key (required for writes) */
7
- privateKey?: string;
8
- /** Chain ID used for metadata and defaults */
9
- chainId: number;
10
- /** RPC URL for signer/provider connectivity */
11
- rpcUrl?: string;
12
- /** Gateway URL override (used for read HTTP fallback paths) */
13
- gatewayUrl?: string;
14
- }
15
- type TierFlagsMatrix = Record<string, Record<string, boolean | string | number>>;
16
- declare class TablelandService {
17
- private config;
18
- private initialized;
19
- private dbRead;
20
- private dbWrite;
21
- constructor(config: TablelandConfig);
22
- initialize(): Promise<void>;
23
- getFeatureFlags(walletAddress: string): Promise<Record<string, boolean | string | number>>;
24
- setFeatureFlags(walletAddress: string, flags: Record<string, boolean | string | number>, metadata: Partial<TablelandEntitlement>): Promise<boolean>;
25
- revokeEntitlement(walletAddress: string): Promise<boolean>;
26
- revokeEntitlementByTokenId(tokenId: number): Promise<boolean>;
27
- updateEntitlementByTokenId(tokenId: number, updates: Partial<Pick<TablelandEntitlement, 'feature_flags' | 'plan_tier' | 'expires_at' | 'last_renewed' | 'api_rate_limit' | 'billing_interval'>>): Promise<boolean>;
28
- listEntitlements(limit?: number): Promise<TablelandEntitlement[]>;
29
- syncSubscription(data: {
30
- walletAddress: string;
31
- tokenId: number;
32
- planTier: PlanTier;
33
- expiresAt: number;
34
- billingInterval: number;
35
- features: Record<string, boolean | string | number>;
36
- }): Promise<void>;
37
- listTierFeatureFlags(providerAddress: string, tiers?: string[]): Promise<TierFlagsMatrix>;
38
- setTierFeatureFlags(providerAddress: string, tier: string, flags: Record<string, boolean | string | number>): Promise<boolean>;
39
- private buildTierMatrixKey;
40
- private defaultRateLimitForTier;
41
- private ensureInitialized;
42
- private ensureWritable;
43
- private ensureSafeTableName;
44
- }
45
-
46
- export { type TablelandConfig, TablelandService };
1
+ export { T as TablelandConfig, f as TablelandService } from './tableland-gyl7O0n6.mjs';
@@ -1,46 +1 @@
1
- import { TablelandEntitlement, PlanTier } from '@arcenpay/sdk';
2
-
3
- interface TablelandConfig {
4
- /** Tableland table name (e.g., meap_feature_flags_84532_123) */
5
- tableName: string;
6
- /** Tableland controller wallet private key (required for writes) */
7
- privateKey?: string;
8
- /** Chain ID used for metadata and defaults */
9
- chainId: number;
10
- /** RPC URL for signer/provider connectivity */
11
- rpcUrl?: string;
12
- /** Gateway URL override (used for read HTTP fallback paths) */
13
- gatewayUrl?: string;
14
- }
15
- type TierFlagsMatrix = Record<string, Record<string, boolean | string | number>>;
16
- declare class TablelandService {
17
- private config;
18
- private initialized;
19
- private dbRead;
20
- private dbWrite;
21
- constructor(config: TablelandConfig);
22
- initialize(): Promise<void>;
23
- getFeatureFlags(walletAddress: string): Promise<Record<string, boolean | string | number>>;
24
- setFeatureFlags(walletAddress: string, flags: Record<string, boolean | string | number>, metadata: Partial<TablelandEntitlement>): Promise<boolean>;
25
- revokeEntitlement(walletAddress: string): Promise<boolean>;
26
- revokeEntitlementByTokenId(tokenId: number): Promise<boolean>;
27
- updateEntitlementByTokenId(tokenId: number, updates: Partial<Pick<TablelandEntitlement, 'feature_flags' | 'plan_tier' | 'expires_at' | 'last_renewed' | 'api_rate_limit' | 'billing_interval'>>): Promise<boolean>;
28
- listEntitlements(limit?: number): Promise<TablelandEntitlement[]>;
29
- syncSubscription(data: {
30
- walletAddress: string;
31
- tokenId: number;
32
- planTier: PlanTier;
33
- expiresAt: number;
34
- billingInterval: number;
35
- features: Record<string, boolean | string | number>;
36
- }): Promise<void>;
37
- listTierFeatureFlags(providerAddress: string, tiers?: string[]): Promise<TierFlagsMatrix>;
38
- setTierFeatureFlags(providerAddress: string, tier: string, flags: Record<string, boolean | string | number>): Promise<boolean>;
39
- private buildTierMatrixKey;
40
- private defaultRateLimitForTier;
41
- private ensureInitialized;
42
- private ensureWritable;
43
- private ensureSafeTableName;
44
- }
45
-
46
- export { type TablelandConfig, TablelandService };
1
+ export { T as TablelandConfig, f as TablelandService } from './tableland-gyl7O0n6.js';
package/dist/tableland.js CHANGED
@@ -244,7 +244,9 @@ var TablelandService = class {
244
244
  }
245
245
  ensureInitialized() {
246
246
  if (!this.initialized || !this.dbRead) {
247
- throw new Error("[Tableland] Service not initialized. Call initialize() first.");
247
+ throw new Error(
248
+ "[Tableland] Service not initialized. Call initialize() first."
249
+ );
248
250
  }
249
251
  }
250
252
  ensureWritable() {
@@ -1,6 +1,7 @@
1
1
  import {
2
2
  TablelandService
3
- } from "./chunk-SKFD6TSD.mjs";
3
+ } from "./chunk-5CPGRELK.mjs";
4
+ import "./chunk-E2J5KZ6E.mjs";
4
5
  export {
5
6
  TablelandService
6
7
  };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@arcenpay/node",
3
- "version": "0.0.1",
3
+ "version": "0.0.2",
4
4
  "description": "ArcenPay SDK — Node.js middleware and billing services",
5
5
  "license": "UNLICENSED",
6
6
  "homepage": "https://app.arcenpay.com",
@@ -37,6 +37,11 @@
37
37
  "access": "public"
38
38
  },
39
39
  "scripts": {
40
+ "sync:core": "node ../../scripts/sync-sdk-core.mjs sdk-node",
41
+ "prebuild": "npm run sync:core",
42
+ "predev": "npm run sync:core",
43
+ "pretest": "npm run sync:core",
44
+ "pretypecheck": "npm run sync:core",
40
45
  "build": "tsup src/index.ts src/tableland.ts --clean --format cjs,esm --dts --dts-resolve",
41
46
  "dev": "tsup src/index.ts src/tableland.ts --clean --format cjs,esm --dts --watch",
42
47
  "test": "vitest run",
@@ -48,7 +53,6 @@
48
53
  "@lit-protocol/constants": "^7.4.0",
49
54
  "@lit-protocol/encryption": "^7.4.0",
50
55
  "@lit-protocol/lit-node-client": "^7.4.0",
51
- "@arcenpay/sdk": "0.0.1",
52
56
  "@tableland/sdk": "^7.2.1",
53
57
  "ethers": "^6.13.5",
54
58
  "redis": "^4.7.1",