@pymthouse/builder-sdk 0.0.8 → 0.3.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/README.md +106 -2
- package/dist/client-BHfjDvIe.d.ts +129 -0
- package/dist/client-CvhJEhjV.d.cts +129 -0
- package/dist/config.cjs +122 -0
- package/dist/config.cjs.map +1 -0
- package/dist/config.d.cts +29 -0
- package/dist/config.d.ts +29 -0
- package/dist/config.js +111 -0
- package/dist/config.js.map +1 -0
- package/dist/device-initiate.cjs +88 -0
- package/dist/device-initiate.cjs.map +1 -0
- package/dist/device-initiate.d.cts +32 -0
- package/dist/device-initiate.d.ts +32 -0
- package/dist/device-initiate.js +84 -0
- package/dist/device-initiate.js.map +1 -0
- package/dist/device.cjs +1 -1
- package/dist/device.cjs.map +1 -1
- package/dist/device.d.cts +1 -1
- package/dist/device.d.ts +1 -1
- package/dist/device.js +1 -1
- package/dist/device.js.map +1 -1
- package/dist/env.cjs +1071 -28
- package/dist/env.cjs.map +1 -1
- package/dist/env.d.cts +15 -2
- package/dist/env.d.ts +15 -2
- package/dist/env.js +1071 -28
- package/dist/env.js.map +1 -1
- package/dist/gateway/client/index.cjs +492 -0
- package/dist/gateway/client/index.cjs.map +1 -0
- package/dist/gateway/client/index.d.cts +63 -0
- package/dist/gateway/client/index.d.ts +63 -0
- package/dist/gateway/client/index.js +489 -0
- package/dist/gateway/client/index.js.map +1 -0
- package/dist/gateway/index.cjs +16 -0
- package/dist/gateway/index.cjs.map +1 -0
- package/dist/gateway/index.d.cts +52 -0
- package/dist/gateway/index.d.ts +52 -0
- package/dist/gateway/index.js +10 -0
- package/dist/gateway/index.js.map +1 -0
- package/dist/gateway/server/index.cjs +1248 -0
- package/dist/gateway/server/index.cjs.map +1 -0
- package/dist/gateway/server/index.d.cts +31 -0
- package/dist/gateway/server/index.d.ts +31 -0
- package/dist/gateway/server/index.js +1233 -0
- package/dist/gateway/server/index.js.map +1 -0
- package/dist/index.cjs +1401 -137
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +41 -5
- package/dist/index.d.ts +41 -5
- package/dist/index.js +1334 -105
- package/dist/index.js.map +1 -1
- package/dist/ingest-B3Yi8Tb1.d.cts +271 -0
- package/dist/ingest-DoKJTWU9.d.ts +271 -0
- package/dist/plan-pricing.cjs +108 -0
- package/dist/plan-pricing.cjs.map +1 -0
- package/dist/plan-pricing.d.cts +15 -0
- package/dist/plan-pricing.d.ts +15 -0
- package/dist/plan-pricing.js +98 -0
- package/dist/plan-pricing.js.map +1 -0
- package/dist/signer/server.cjs +1366 -0
- package/dist/signer/server.cjs.map +1 -0
- package/dist/signer/server.d.cts +73 -0
- package/dist/signer/server.d.ts +73 -0
- package/dist/signer/server.js +1331 -0
- package/dist/signer/server.js.map +1 -0
- package/dist/tokens.cjs +75 -0
- package/dist/tokens.cjs.map +1 -0
- package/dist/tokens.d.cts +48 -0
- package/dist/tokens.d.ts +48 -0
- package/dist/tokens.js +64 -0
- package/dist/tokens.js.map +1 -0
- package/dist/types-_R1AwEZp.d.cts +343 -0
- package/dist/types-_R1AwEZp.d.ts +343 -0
- package/dist/verify.cjs +1 -1
- package/dist/verify.cjs.map +1 -1
- package/dist/verify.d.cts +1 -1
- package/dist/verify.d.ts +1 -1
- package/dist/verify.js +1 -1
- package/dist/verify.js.map +1 -1
- package/gateway/proto/lp_rpc.proto +542 -0
- package/package.json +57 -1
- package/dist/env-4YmzarGJ.d.ts +0 -68
- package/dist/env-CZczUMzR.d.cts +0 -68
- package/dist/types-W9PJAspR.d.cts +0 -136
- package/dist/types-W9PJAspR.d.ts +0 -136
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
2
|
+
interface OidcDiscoveryDocument {
|
|
3
|
+
issuer: string;
|
|
4
|
+
authorization_endpoint: string;
|
|
5
|
+
token_endpoint: string;
|
|
6
|
+
jwks_uri: string;
|
|
7
|
+
userinfo_endpoint?: string;
|
|
8
|
+
device_authorization_endpoint?: string;
|
|
9
|
+
}
|
|
10
|
+
interface GetDiscoveryOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Bypass the in-memory discovery cache and fetch fresh metadata.
|
|
13
|
+
*/
|
|
14
|
+
force?: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface PmtHouseClientOptions {
|
|
17
|
+
issuerUrl: string;
|
|
18
|
+
publicClientId: string;
|
|
19
|
+
m2mClientId: string;
|
|
20
|
+
m2mClientSecret: string;
|
|
21
|
+
fetch?: FetchLike;
|
|
22
|
+
/**
|
|
23
|
+
* Allow HTTP issuer URLs (e.g. local dev). Passed to oauth4webapi as `allowInsecureRequests`.
|
|
24
|
+
*/
|
|
25
|
+
allowInsecureHttp?: boolean;
|
|
26
|
+
logger?: {
|
|
27
|
+
debug?: (message: string, details?: Record<string, unknown>) => void;
|
|
28
|
+
warn?: (message: string, details?: Record<string, unknown>) => void;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
interface UpsertAppUserInput {
|
|
32
|
+
externalUserId: string;
|
|
33
|
+
email?: string;
|
|
34
|
+
status?: "active" | "inactive";
|
|
35
|
+
}
|
|
36
|
+
interface AppUserRecord {
|
|
37
|
+
id: string;
|
|
38
|
+
clientId: string;
|
|
39
|
+
externalUserId: string;
|
|
40
|
+
email: string | null;
|
|
41
|
+
status: string;
|
|
42
|
+
role: string;
|
|
43
|
+
createdAt: string;
|
|
44
|
+
}
|
|
45
|
+
interface MintUserAccessTokenInput {
|
|
46
|
+
externalUserId: string;
|
|
47
|
+
scope?: string;
|
|
48
|
+
}
|
|
49
|
+
interface MintUserSignerSessionTokenInput extends MintUserAccessTokenInput {
|
|
50
|
+
/**
|
|
51
|
+
* Optional RFC 8707 resource indicator for the signer-session exchange.
|
|
52
|
+
* Defaults to the configured PymtHouse issuer URL.
|
|
53
|
+
*/
|
|
54
|
+
resource?: string;
|
|
55
|
+
}
|
|
56
|
+
interface MintUserAccessTokenResponse {
|
|
57
|
+
access_token: string;
|
|
58
|
+
refresh_token: string;
|
|
59
|
+
token_type: "Bearer";
|
|
60
|
+
expires_in: number;
|
|
61
|
+
scope: string;
|
|
62
|
+
subject_type: "app_user";
|
|
63
|
+
correlation_id?: string;
|
|
64
|
+
}
|
|
65
|
+
interface DeviceApprovalInput {
|
|
66
|
+
userJwt: string;
|
|
67
|
+
userCode: string;
|
|
68
|
+
}
|
|
69
|
+
interface TokenExchangeResponse {
|
|
70
|
+
access_token: string;
|
|
71
|
+
token_type: "Bearer";
|
|
72
|
+
expires_in: number;
|
|
73
|
+
scope: string;
|
|
74
|
+
issued_token_type: string;
|
|
75
|
+
}
|
|
76
|
+
interface UsageQueryInput {
|
|
77
|
+
startDate?: string;
|
|
78
|
+
endDate?: string;
|
|
79
|
+
groupBy?: "none" | "user" | "pipeline_model" | "daily_pipeline";
|
|
80
|
+
userId?: string;
|
|
81
|
+
gatewayRequestId?: string;
|
|
82
|
+
/** When true, sends `include=retail` for estimated end-user billable amounts. */
|
|
83
|
+
includeRetail?: boolean;
|
|
84
|
+
}
|
|
85
|
+
interface UsageTotals {
|
|
86
|
+
requestCount: number;
|
|
87
|
+
totalFeeWei?: string;
|
|
88
|
+
currency?: string;
|
|
89
|
+
networkFeeUsdMicros?: string;
|
|
90
|
+
ownerChargeUsdMicros?: string;
|
|
91
|
+
platformFeeUsdMicros?: string;
|
|
92
|
+
endUserBillableUsdMicros?: string;
|
|
93
|
+
}
|
|
94
|
+
interface UsageByUserRow {
|
|
95
|
+
endUserId: string;
|
|
96
|
+
externalUserId: string | null;
|
|
97
|
+
requestCount: number;
|
|
98
|
+
feeWei?: string;
|
|
99
|
+
currency?: string;
|
|
100
|
+
networkFeeUsdMicros?: string;
|
|
101
|
+
ownerChargeUsdMicros?: string;
|
|
102
|
+
endUserBillableUsdMicros?: string;
|
|
103
|
+
userType?: "system_managed" | "oidc_authorized" | "unknown";
|
|
104
|
+
identifier?: string;
|
|
105
|
+
}
|
|
106
|
+
/** One bucket from Usage API `groupBy=pipeline_model` (validated pipeline + model). */
|
|
107
|
+
interface UsageByPipelineModelRow {
|
|
108
|
+
pipeline: string;
|
|
109
|
+
modelId: string;
|
|
110
|
+
requestCount: number;
|
|
111
|
+
currency?: string;
|
|
112
|
+
networkFeeWei?: string;
|
|
113
|
+
networkFeeEth?: string;
|
|
114
|
+
networkFeeUsdMicros: string;
|
|
115
|
+
ownerChargeUsdMicros?: string;
|
|
116
|
+
endUserBillableUsdMicros?: string;
|
|
117
|
+
retailRateUsd?: string;
|
|
118
|
+
}
|
|
119
|
+
/** One UTC day bucket from Usage API `groupBy=daily_pipeline` (requires `userId`). */
|
|
120
|
+
interface UsageDailyPipelineRow {
|
|
121
|
+
pipeline: string;
|
|
122
|
+
modelId: string;
|
|
123
|
+
date: string;
|
|
124
|
+
requestCount: number;
|
|
125
|
+
currency?: string;
|
|
126
|
+
networkFeeUsdMicros: string;
|
|
127
|
+
ownerChargeUsdMicros?: string;
|
|
128
|
+
endUserBillableUsdMicros?: string;
|
|
129
|
+
}
|
|
130
|
+
interface UsageApiResponse {
|
|
131
|
+
clientId: string;
|
|
132
|
+
source?: "openmeter" | "postgres";
|
|
133
|
+
period: {
|
|
134
|
+
start: string | null;
|
|
135
|
+
end: string | null;
|
|
136
|
+
};
|
|
137
|
+
totals: UsageTotals;
|
|
138
|
+
byUser?: UsageByUserRow[];
|
|
139
|
+
byPipelineModel?: UsageByPipelineModelRow[];
|
|
140
|
+
byDailyPipeline?: UsageDailyPipelineRow[];
|
|
141
|
+
}
|
|
142
|
+
type BillingSyncStatus = "not_applicable" | "pending" | "synced" | "error";
|
|
143
|
+
interface BillingSyncState {
|
|
144
|
+
status: BillingSyncStatus;
|
|
145
|
+
syncedAt: string | null;
|
|
146
|
+
errorCode: string | null;
|
|
147
|
+
errorMessage: string | null;
|
|
148
|
+
openmeterPlanId?: string | null;
|
|
149
|
+
openmeterPlanVersion?: number | null;
|
|
150
|
+
}
|
|
151
|
+
interface CapabilityPriceRule {
|
|
152
|
+
pipeline: string;
|
|
153
|
+
modelId: string;
|
|
154
|
+
retailRateUsd: string | null;
|
|
155
|
+
markupPercent: string | null;
|
|
156
|
+
effectiveRetailRateUsd: string;
|
|
157
|
+
featureKey: string;
|
|
158
|
+
}
|
|
159
|
+
interface AllowancePolicy {
|
|
160
|
+
includedUsdMicros: string | null;
|
|
161
|
+
billingCycle: string;
|
|
162
|
+
}
|
|
163
|
+
interface BillingProduct {
|
|
164
|
+
id: string;
|
|
165
|
+
clientId: string;
|
|
166
|
+
name: string;
|
|
167
|
+
type: string;
|
|
168
|
+
status: string;
|
|
169
|
+
priceAmount: string;
|
|
170
|
+
priceCurrency: string;
|
|
171
|
+
isNetworkDefault: boolean;
|
|
172
|
+
isStarterDefault: boolean;
|
|
173
|
+
allowance: AllowancePolicy;
|
|
174
|
+
defaultRetailRateUsd: string | null;
|
|
175
|
+
capabilities: CapabilityPriceRule[];
|
|
176
|
+
sync: BillingSyncState;
|
|
177
|
+
}
|
|
178
|
+
interface SignedTicketIngestInput {
|
|
179
|
+
requestId: string;
|
|
180
|
+
externalUserId: string;
|
|
181
|
+
networkFeeUsdMicros: string;
|
|
182
|
+
feeWei?: string;
|
|
183
|
+
pixels?: string;
|
|
184
|
+
pipeline?: string;
|
|
185
|
+
modelId?: string;
|
|
186
|
+
gatewayRequestId?: string;
|
|
187
|
+
ethUsdPrice?: string;
|
|
188
|
+
ethUsdRoundId?: string;
|
|
189
|
+
ethUsdObservedAt?: string;
|
|
190
|
+
}
|
|
191
|
+
interface SignedTicketIngestResult {
|
|
192
|
+
ingested: boolean;
|
|
193
|
+
duplicate: boolean;
|
|
194
|
+
source: "openmeter" | "disabled";
|
|
195
|
+
}
|
|
196
|
+
/** OpenMeter entitlement balance from `GET .../usage/balance`. */
|
|
197
|
+
interface UsageBalanceResponse {
|
|
198
|
+
externalUserId: string;
|
|
199
|
+
balanceUsdMicros: string;
|
|
200
|
+
consumedUsdMicros: string;
|
|
201
|
+
lifetimeGrantedUsdMicros: string;
|
|
202
|
+
hasAccess: boolean;
|
|
203
|
+
remainingUsdMicros?: string;
|
|
204
|
+
}
|
|
205
|
+
/** @deprecated Use {@link UsageBalanceResponse}. */
|
|
206
|
+
type UserCreditsResponse = UsageBalanceResponse;
|
|
207
|
+
/** @deprecated Use {@link UserAllowanceGrantInput}. */
|
|
208
|
+
type UserCreditGrantInput = UserAllowanceGrantInput;
|
|
209
|
+
interface SignerRoutingConfig {
|
|
210
|
+
signerApiUrl: string;
|
|
211
|
+
remoteDmzUrl: string | null;
|
|
212
|
+
jwksUri: string;
|
|
213
|
+
identityMode: string;
|
|
214
|
+
meteringMode: "hosted_ingest" | "platform_ingest";
|
|
215
|
+
}
|
|
216
|
+
interface SignerRoutingResponse {
|
|
217
|
+
clientId: string;
|
|
218
|
+
routing: SignerRoutingConfig;
|
|
219
|
+
patterns: {
|
|
220
|
+
hostedFacade: {
|
|
221
|
+
description: string;
|
|
222
|
+
signerApiUrl: string;
|
|
223
|
+
};
|
|
224
|
+
platformDirectDmz: {
|
|
225
|
+
description: string;
|
|
226
|
+
remoteDmzUrl: string | null;
|
|
227
|
+
ingestUrl: string;
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
type GrantSource = "trial" | "manual" | "promo" | "plan_adjustment";
|
|
232
|
+
interface UserAllowanceGrantInput {
|
|
233
|
+
amountUsdMicros: string;
|
|
234
|
+
source?: GrantSource;
|
|
235
|
+
featureKey?: string;
|
|
236
|
+
}
|
|
237
|
+
interface UserAllowancesResponse {
|
|
238
|
+
externalUserId: string;
|
|
239
|
+
allowances: {
|
|
240
|
+
balanceUsdMicros: string;
|
|
241
|
+
consumedUsdMicros?: string;
|
|
242
|
+
lifetimeGrantedUsdMicros?: string;
|
|
243
|
+
hasAccess?: boolean;
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
interface UserSubscriptionResponse {
|
|
247
|
+
externalUserId: string;
|
|
248
|
+
subscription: {
|
|
249
|
+
id: string;
|
|
250
|
+
status: string;
|
|
251
|
+
planId: string;
|
|
252
|
+
planName: string | null;
|
|
253
|
+
planType: string | null;
|
|
254
|
+
currentPeriodStart: string | null;
|
|
255
|
+
currentPeriodEnd: string | null;
|
|
256
|
+
openmeterSubscriptionId: string | null;
|
|
257
|
+
stripeCheckoutSessionId: string | null;
|
|
258
|
+
createdAt: string;
|
|
259
|
+
cancelledAt: string | null;
|
|
260
|
+
} | null;
|
|
261
|
+
}
|
|
262
|
+
interface PlanSyncResult {
|
|
263
|
+
planId: string;
|
|
264
|
+
ok: boolean;
|
|
265
|
+
sync: BillingSyncState;
|
|
266
|
+
openmeterPlanId: string | null;
|
|
267
|
+
}
|
|
268
|
+
interface ListBillingProductsResult {
|
|
269
|
+
apiVersion: number;
|
|
270
|
+
products: BillingProduct[];
|
|
271
|
+
}
|
|
272
|
+
/** Aggregated request count and fee for one provider `externalUserId` across duplicate `byUser` buckets. */
|
|
273
|
+
interface UsageForExternalUser {
|
|
274
|
+
externalUserId: string;
|
|
275
|
+
requestCount: number;
|
|
276
|
+
feeWei: string;
|
|
277
|
+
}
|
|
278
|
+
interface ClientCredentialsTokenResponse {
|
|
279
|
+
access_token: string;
|
|
280
|
+
token_type: "Bearer";
|
|
281
|
+
expires_in?: number;
|
|
282
|
+
scope?: string;
|
|
283
|
+
[key: string]: unknown;
|
|
284
|
+
}
|
|
285
|
+
interface ParsedDeviceApprovalRedirect {
|
|
286
|
+
issuer: string;
|
|
287
|
+
targetLinkUri: string;
|
|
288
|
+
userCode: string;
|
|
289
|
+
clientId: string;
|
|
290
|
+
}
|
|
291
|
+
interface AppManifestCapability {
|
|
292
|
+
pipeline: string;
|
|
293
|
+
modelId: string;
|
|
294
|
+
}
|
|
295
|
+
interface AppManifestResponse {
|
|
296
|
+
/** PymtHouse-local resolved set; informational, not a complete integrator allowlist. */
|
|
297
|
+
capabilities: AppManifestCapability[];
|
|
298
|
+
/** Authoritative exclusions from the Network Price plan. */
|
|
299
|
+
excludedCapabilities?: AppManifestCapability[];
|
|
300
|
+
/** Server-computed revision for cache busting when present. */
|
|
301
|
+
manifestVersion?: string;
|
|
302
|
+
}
|
|
303
|
+
interface GetAppManifestResult {
|
|
304
|
+
manifest: AppManifestResponse | null;
|
|
305
|
+
etag: string | null;
|
|
306
|
+
notModified: boolean;
|
|
307
|
+
}
|
|
308
|
+
interface UsageByPipelineModelFiatRow {
|
|
309
|
+
pipeline: string;
|
|
310
|
+
modelId: string;
|
|
311
|
+
requestCount: number;
|
|
312
|
+
currency: string;
|
|
313
|
+
networkFeeUsdMicros: string;
|
|
314
|
+
ownerChargeUsdMicros: string;
|
|
315
|
+
endUserBillableUsdMicros: string;
|
|
316
|
+
}
|
|
317
|
+
interface MeScopeUsagePayload {
|
|
318
|
+
clientId: string;
|
|
319
|
+
period: UsageApiResponse["period"];
|
|
320
|
+
currentUser: {
|
|
321
|
+
externalUserId: string;
|
|
322
|
+
requestCount: number;
|
|
323
|
+
currency: string;
|
|
324
|
+
networkFeeUsdMicros: string;
|
|
325
|
+
ownerChargeUsdMicros: string;
|
|
326
|
+
endUserBillableUsdMicros: string;
|
|
327
|
+
pipelineModels: UsageByPipelineModelFiatRow[];
|
|
328
|
+
dailyByPipeline?: UsageDailyPipelineRow[];
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
interface MintSignerSessionForExternalUserInput {
|
|
332
|
+
externalUserId: string;
|
|
333
|
+
email?: string;
|
|
334
|
+
scope?: string;
|
|
335
|
+
}
|
|
336
|
+
interface ApproveDeviceLoginInput {
|
|
337
|
+
externalUserId: string;
|
|
338
|
+
userCode: string;
|
|
339
|
+
email?: string;
|
|
340
|
+
publicClientId?: string;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export type { AppUserRecord as A, BillingProduct as B, ClientCredentialsTokenResponse as C, DeviceApprovalInput as D, CapabilityPriceRule as E, FetchLike as F, GetDiscoveryOptions as G, SignerRoutingConfig as H, UsageDailyPipelineRow as I, UsageTotals as J, UserCreditGrantInput as K, ListBillingProductsResult as L, MintUserAccessTokenInput as M, UserCreditsResponse as N, OidcDiscoveryDocument as O, PmtHouseClientOptions as P, SignedTicketIngestInput as S, TokenExchangeResponse as T, UpsertAppUserInput as U, ParsedDeviceApprovalRedirect as a, MintUserAccessTokenResponse as b, MintUserSignerSessionTokenInput as c, UsageQueryInput as d, UsageApiResponse as e, SignedTicketIngestResult as f, SignerRoutingResponse as g, PlanSyncResult as h, UsageBalanceResponse as i, UserAllowancesResponse as j, UserAllowanceGrantInput as k, GrantSource as l, UserSubscriptionResponse as m, MeScopeUsagePayload as n, GetAppManifestResult as o, MintSignerSessionForExternalUserInput as p, ApproveDeviceLoginInput as q, UsageByUserRow as r, UsageForExternalUser as s, UsageByPipelineModelRow as t, UsageByPipelineModelFiatRow as u, AppManifestResponse as v, AllowancePolicy as w, AppManifestCapability as x, BillingSyncState as y, BillingSyncStatus as z };
|
|
@@ -0,0 +1,343 @@
|
|
|
1
|
+
type FetchLike = (input: string | URL | Request, init?: RequestInit) => Promise<Response>;
|
|
2
|
+
interface OidcDiscoveryDocument {
|
|
3
|
+
issuer: string;
|
|
4
|
+
authorization_endpoint: string;
|
|
5
|
+
token_endpoint: string;
|
|
6
|
+
jwks_uri: string;
|
|
7
|
+
userinfo_endpoint?: string;
|
|
8
|
+
device_authorization_endpoint?: string;
|
|
9
|
+
}
|
|
10
|
+
interface GetDiscoveryOptions {
|
|
11
|
+
/**
|
|
12
|
+
* Bypass the in-memory discovery cache and fetch fresh metadata.
|
|
13
|
+
*/
|
|
14
|
+
force?: boolean;
|
|
15
|
+
}
|
|
16
|
+
interface PmtHouseClientOptions {
|
|
17
|
+
issuerUrl: string;
|
|
18
|
+
publicClientId: string;
|
|
19
|
+
m2mClientId: string;
|
|
20
|
+
m2mClientSecret: string;
|
|
21
|
+
fetch?: FetchLike;
|
|
22
|
+
/**
|
|
23
|
+
* Allow HTTP issuer URLs (e.g. local dev). Passed to oauth4webapi as `allowInsecureRequests`.
|
|
24
|
+
*/
|
|
25
|
+
allowInsecureHttp?: boolean;
|
|
26
|
+
logger?: {
|
|
27
|
+
debug?: (message: string, details?: Record<string, unknown>) => void;
|
|
28
|
+
warn?: (message: string, details?: Record<string, unknown>) => void;
|
|
29
|
+
};
|
|
30
|
+
}
|
|
31
|
+
interface UpsertAppUserInput {
|
|
32
|
+
externalUserId: string;
|
|
33
|
+
email?: string;
|
|
34
|
+
status?: "active" | "inactive";
|
|
35
|
+
}
|
|
36
|
+
interface AppUserRecord {
|
|
37
|
+
id: string;
|
|
38
|
+
clientId: string;
|
|
39
|
+
externalUserId: string;
|
|
40
|
+
email: string | null;
|
|
41
|
+
status: string;
|
|
42
|
+
role: string;
|
|
43
|
+
createdAt: string;
|
|
44
|
+
}
|
|
45
|
+
interface MintUserAccessTokenInput {
|
|
46
|
+
externalUserId: string;
|
|
47
|
+
scope?: string;
|
|
48
|
+
}
|
|
49
|
+
interface MintUserSignerSessionTokenInput extends MintUserAccessTokenInput {
|
|
50
|
+
/**
|
|
51
|
+
* Optional RFC 8707 resource indicator for the signer-session exchange.
|
|
52
|
+
* Defaults to the configured PymtHouse issuer URL.
|
|
53
|
+
*/
|
|
54
|
+
resource?: string;
|
|
55
|
+
}
|
|
56
|
+
interface MintUserAccessTokenResponse {
|
|
57
|
+
access_token: string;
|
|
58
|
+
refresh_token: string;
|
|
59
|
+
token_type: "Bearer";
|
|
60
|
+
expires_in: number;
|
|
61
|
+
scope: string;
|
|
62
|
+
subject_type: "app_user";
|
|
63
|
+
correlation_id?: string;
|
|
64
|
+
}
|
|
65
|
+
interface DeviceApprovalInput {
|
|
66
|
+
userJwt: string;
|
|
67
|
+
userCode: string;
|
|
68
|
+
}
|
|
69
|
+
interface TokenExchangeResponse {
|
|
70
|
+
access_token: string;
|
|
71
|
+
token_type: "Bearer";
|
|
72
|
+
expires_in: number;
|
|
73
|
+
scope: string;
|
|
74
|
+
issued_token_type: string;
|
|
75
|
+
}
|
|
76
|
+
interface UsageQueryInput {
|
|
77
|
+
startDate?: string;
|
|
78
|
+
endDate?: string;
|
|
79
|
+
groupBy?: "none" | "user" | "pipeline_model" | "daily_pipeline";
|
|
80
|
+
userId?: string;
|
|
81
|
+
gatewayRequestId?: string;
|
|
82
|
+
/** When true, sends `include=retail` for estimated end-user billable amounts. */
|
|
83
|
+
includeRetail?: boolean;
|
|
84
|
+
}
|
|
85
|
+
interface UsageTotals {
|
|
86
|
+
requestCount: number;
|
|
87
|
+
totalFeeWei?: string;
|
|
88
|
+
currency?: string;
|
|
89
|
+
networkFeeUsdMicros?: string;
|
|
90
|
+
ownerChargeUsdMicros?: string;
|
|
91
|
+
platformFeeUsdMicros?: string;
|
|
92
|
+
endUserBillableUsdMicros?: string;
|
|
93
|
+
}
|
|
94
|
+
interface UsageByUserRow {
|
|
95
|
+
endUserId: string;
|
|
96
|
+
externalUserId: string | null;
|
|
97
|
+
requestCount: number;
|
|
98
|
+
feeWei?: string;
|
|
99
|
+
currency?: string;
|
|
100
|
+
networkFeeUsdMicros?: string;
|
|
101
|
+
ownerChargeUsdMicros?: string;
|
|
102
|
+
endUserBillableUsdMicros?: string;
|
|
103
|
+
userType?: "system_managed" | "oidc_authorized" | "unknown";
|
|
104
|
+
identifier?: string;
|
|
105
|
+
}
|
|
106
|
+
/** One bucket from Usage API `groupBy=pipeline_model` (validated pipeline + model). */
|
|
107
|
+
interface UsageByPipelineModelRow {
|
|
108
|
+
pipeline: string;
|
|
109
|
+
modelId: string;
|
|
110
|
+
requestCount: number;
|
|
111
|
+
currency?: string;
|
|
112
|
+
networkFeeWei?: string;
|
|
113
|
+
networkFeeEth?: string;
|
|
114
|
+
networkFeeUsdMicros: string;
|
|
115
|
+
ownerChargeUsdMicros?: string;
|
|
116
|
+
endUserBillableUsdMicros?: string;
|
|
117
|
+
retailRateUsd?: string;
|
|
118
|
+
}
|
|
119
|
+
/** One UTC day bucket from Usage API `groupBy=daily_pipeline` (requires `userId`). */
|
|
120
|
+
interface UsageDailyPipelineRow {
|
|
121
|
+
pipeline: string;
|
|
122
|
+
modelId: string;
|
|
123
|
+
date: string;
|
|
124
|
+
requestCount: number;
|
|
125
|
+
currency?: string;
|
|
126
|
+
networkFeeUsdMicros: string;
|
|
127
|
+
ownerChargeUsdMicros?: string;
|
|
128
|
+
endUserBillableUsdMicros?: string;
|
|
129
|
+
}
|
|
130
|
+
interface UsageApiResponse {
|
|
131
|
+
clientId: string;
|
|
132
|
+
source?: "openmeter" | "postgres";
|
|
133
|
+
period: {
|
|
134
|
+
start: string | null;
|
|
135
|
+
end: string | null;
|
|
136
|
+
};
|
|
137
|
+
totals: UsageTotals;
|
|
138
|
+
byUser?: UsageByUserRow[];
|
|
139
|
+
byPipelineModel?: UsageByPipelineModelRow[];
|
|
140
|
+
byDailyPipeline?: UsageDailyPipelineRow[];
|
|
141
|
+
}
|
|
142
|
+
type BillingSyncStatus = "not_applicable" | "pending" | "synced" | "error";
|
|
143
|
+
interface BillingSyncState {
|
|
144
|
+
status: BillingSyncStatus;
|
|
145
|
+
syncedAt: string | null;
|
|
146
|
+
errorCode: string | null;
|
|
147
|
+
errorMessage: string | null;
|
|
148
|
+
openmeterPlanId?: string | null;
|
|
149
|
+
openmeterPlanVersion?: number | null;
|
|
150
|
+
}
|
|
151
|
+
interface CapabilityPriceRule {
|
|
152
|
+
pipeline: string;
|
|
153
|
+
modelId: string;
|
|
154
|
+
retailRateUsd: string | null;
|
|
155
|
+
markupPercent: string | null;
|
|
156
|
+
effectiveRetailRateUsd: string;
|
|
157
|
+
featureKey: string;
|
|
158
|
+
}
|
|
159
|
+
interface AllowancePolicy {
|
|
160
|
+
includedUsdMicros: string | null;
|
|
161
|
+
billingCycle: string;
|
|
162
|
+
}
|
|
163
|
+
interface BillingProduct {
|
|
164
|
+
id: string;
|
|
165
|
+
clientId: string;
|
|
166
|
+
name: string;
|
|
167
|
+
type: string;
|
|
168
|
+
status: string;
|
|
169
|
+
priceAmount: string;
|
|
170
|
+
priceCurrency: string;
|
|
171
|
+
isNetworkDefault: boolean;
|
|
172
|
+
isStarterDefault: boolean;
|
|
173
|
+
allowance: AllowancePolicy;
|
|
174
|
+
defaultRetailRateUsd: string | null;
|
|
175
|
+
capabilities: CapabilityPriceRule[];
|
|
176
|
+
sync: BillingSyncState;
|
|
177
|
+
}
|
|
178
|
+
interface SignedTicketIngestInput {
|
|
179
|
+
requestId: string;
|
|
180
|
+
externalUserId: string;
|
|
181
|
+
networkFeeUsdMicros: string;
|
|
182
|
+
feeWei?: string;
|
|
183
|
+
pixels?: string;
|
|
184
|
+
pipeline?: string;
|
|
185
|
+
modelId?: string;
|
|
186
|
+
gatewayRequestId?: string;
|
|
187
|
+
ethUsdPrice?: string;
|
|
188
|
+
ethUsdRoundId?: string;
|
|
189
|
+
ethUsdObservedAt?: string;
|
|
190
|
+
}
|
|
191
|
+
interface SignedTicketIngestResult {
|
|
192
|
+
ingested: boolean;
|
|
193
|
+
duplicate: boolean;
|
|
194
|
+
source: "openmeter" | "disabled";
|
|
195
|
+
}
|
|
196
|
+
/** OpenMeter entitlement balance from `GET .../usage/balance`. */
|
|
197
|
+
interface UsageBalanceResponse {
|
|
198
|
+
externalUserId: string;
|
|
199
|
+
balanceUsdMicros: string;
|
|
200
|
+
consumedUsdMicros: string;
|
|
201
|
+
lifetimeGrantedUsdMicros: string;
|
|
202
|
+
hasAccess: boolean;
|
|
203
|
+
remainingUsdMicros?: string;
|
|
204
|
+
}
|
|
205
|
+
/** @deprecated Use {@link UsageBalanceResponse}. */
|
|
206
|
+
type UserCreditsResponse = UsageBalanceResponse;
|
|
207
|
+
/** @deprecated Use {@link UserAllowanceGrantInput}. */
|
|
208
|
+
type UserCreditGrantInput = UserAllowanceGrantInput;
|
|
209
|
+
interface SignerRoutingConfig {
|
|
210
|
+
signerApiUrl: string;
|
|
211
|
+
remoteDmzUrl: string | null;
|
|
212
|
+
jwksUri: string;
|
|
213
|
+
identityMode: string;
|
|
214
|
+
meteringMode: "hosted_ingest" | "platform_ingest";
|
|
215
|
+
}
|
|
216
|
+
interface SignerRoutingResponse {
|
|
217
|
+
clientId: string;
|
|
218
|
+
routing: SignerRoutingConfig;
|
|
219
|
+
patterns: {
|
|
220
|
+
hostedFacade: {
|
|
221
|
+
description: string;
|
|
222
|
+
signerApiUrl: string;
|
|
223
|
+
};
|
|
224
|
+
platformDirectDmz: {
|
|
225
|
+
description: string;
|
|
226
|
+
remoteDmzUrl: string | null;
|
|
227
|
+
ingestUrl: string;
|
|
228
|
+
};
|
|
229
|
+
};
|
|
230
|
+
}
|
|
231
|
+
type GrantSource = "trial" | "manual" | "promo" | "plan_adjustment";
|
|
232
|
+
interface UserAllowanceGrantInput {
|
|
233
|
+
amountUsdMicros: string;
|
|
234
|
+
source?: GrantSource;
|
|
235
|
+
featureKey?: string;
|
|
236
|
+
}
|
|
237
|
+
interface UserAllowancesResponse {
|
|
238
|
+
externalUserId: string;
|
|
239
|
+
allowances: {
|
|
240
|
+
balanceUsdMicros: string;
|
|
241
|
+
consumedUsdMicros?: string;
|
|
242
|
+
lifetimeGrantedUsdMicros?: string;
|
|
243
|
+
hasAccess?: boolean;
|
|
244
|
+
};
|
|
245
|
+
}
|
|
246
|
+
interface UserSubscriptionResponse {
|
|
247
|
+
externalUserId: string;
|
|
248
|
+
subscription: {
|
|
249
|
+
id: string;
|
|
250
|
+
status: string;
|
|
251
|
+
planId: string;
|
|
252
|
+
planName: string | null;
|
|
253
|
+
planType: string | null;
|
|
254
|
+
currentPeriodStart: string | null;
|
|
255
|
+
currentPeriodEnd: string | null;
|
|
256
|
+
openmeterSubscriptionId: string | null;
|
|
257
|
+
stripeCheckoutSessionId: string | null;
|
|
258
|
+
createdAt: string;
|
|
259
|
+
cancelledAt: string | null;
|
|
260
|
+
} | null;
|
|
261
|
+
}
|
|
262
|
+
interface PlanSyncResult {
|
|
263
|
+
planId: string;
|
|
264
|
+
ok: boolean;
|
|
265
|
+
sync: BillingSyncState;
|
|
266
|
+
openmeterPlanId: string | null;
|
|
267
|
+
}
|
|
268
|
+
interface ListBillingProductsResult {
|
|
269
|
+
apiVersion: number;
|
|
270
|
+
products: BillingProduct[];
|
|
271
|
+
}
|
|
272
|
+
/** Aggregated request count and fee for one provider `externalUserId` across duplicate `byUser` buckets. */
|
|
273
|
+
interface UsageForExternalUser {
|
|
274
|
+
externalUserId: string;
|
|
275
|
+
requestCount: number;
|
|
276
|
+
feeWei: string;
|
|
277
|
+
}
|
|
278
|
+
interface ClientCredentialsTokenResponse {
|
|
279
|
+
access_token: string;
|
|
280
|
+
token_type: "Bearer";
|
|
281
|
+
expires_in?: number;
|
|
282
|
+
scope?: string;
|
|
283
|
+
[key: string]: unknown;
|
|
284
|
+
}
|
|
285
|
+
interface ParsedDeviceApprovalRedirect {
|
|
286
|
+
issuer: string;
|
|
287
|
+
targetLinkUri: string;
|
|
288
|
+
userCode: string;
|
|
289
|
+
clientId: string;
|
|
290
|
+
}
|
|
291
|
+
interface AppManifestCapability {
|
|
292
|
+
pipeline: string;
|
|
293
|
+
modelId: string;
|
|
294
|
+
}
|
|
295
|
+
interface AppManifestResponse {
|
|
296
|
+
/** PymtHouse-local resolved set; informational, not a complete integrator allowlist. */
|
|
297
|
+
capabilities: AppManifestCapability[];
|
|
298
|
+
/** Authoritative exclusions from the Network Price plan. */
|
|
299
|
+
excludedCapabilities?: AppManifestCapability[];
|
|
300
|
+
/** Server-computed revision for cache busting when present. */
|
|
301
|
+
manifestVersion?: string;
|
|
302
|
+
}
|
|
303
|
+
interface GetAppManifestResult {
|
|
304
|
+
manifest: AppManifestResponse | null;
|
|
305
|
+
etag: string | null;
|
|
306
|
+
notModified: boolean;
|
|
307
|
+
}
|
|
308
|
+
interface UsageByPipelineModelFiatRow {
|
|
309
|
+
pipeline: string;
|
|
310
|
+
modelId: string;
|
|
311
|
+
requestCount: number;
|
|
312
|
+
currency: string;
|
|
313
|
+
networkFeeUsdMicros: string;
|
|
314
|
+
ownerChargeUsdMicros: string;
|
|
315
|
+
endUserBillableUsdMicros: string;
|
|
316
|
+
}
|
|
317
|
+
interface MeScopeUsagePayload {
|
|
318
|
+
clientId: string;
|
|
319
|
+
period: UsageApiResponse["period"];
|
|
320
|
+
currentUser: {
|
|
321
|
+
externalUserId: string;
|
|
322
|
+
requestCount: number;
|
|
323
|
+
currency: string;
|
|
324
|
+
networkFeeUsdMicros: string;
|
|
325
|
+
ownerChargeUsdMicros: string;
|
|
326
|
+
endUserBillableUsdMicros: string;
|
|
327
|
+
pipelineModels: UsageByPipelineModelFiatRow[];
|
|
328
|
+
dailyByPipeline?: UsageDailyPipelineRow[];
|
|
329
|
+
};
|
|
330
|
+
}
|
|
331
|
+
interface MintSignerSessionForExternalUserInput {
|
|
332
|
+
externalUserId: string;
|
|
333
|
+
email?: string;
|
|
334
|
+
scope?: string;
|
|
335
|
+
}
|
|
336
|
+
interface ApproveDeviceLoginInput {
|
|
337
|
+
externalUserId: string;
|
|
338
|
+
userCode: string;
|
|
339
|
+
email?: string;
|
|
340
|
+
publicClientId?: string;
|
|
341
|
+
}
|
|
342
|
+
|
|
343
|
+
export type { AppUserRecord as A, BillingProduct as B, ClientCredentialsTokenResponse as C, DeviceApprovalInput as D, CapabilityPriceRule as E, FetchLike as F, GetDiscoveryOptions as G, SignerRoutingConfig as H, UsageDailyPipelineRow as I, UsageTotals as J, UserCreditGrantInput as K, ListBillingProductsResult as L, MintUserAccessTokenInput as M, UserCreditsResponse as N, OidcDiscoveryDocument as O, PmtHouseClientOptions as P, SignedTicketIngestInput as S, TokenExchangeResponse as T, UpsertAppUserInput as U, ParsedDeviceApprovalRedirect as a, MintUserAccessTokenResponse as b, MintUserSignerSessionTokenInput as c, UsageQueryInput as d, UsageApiResponse as e, SignedTicketIngestResult as f, SignerRoutingResponse as g, PlanSyncResult as h, UsageBalanceResponse as i, UserAllowancesResponse as j, UserAllowanceGrantInput as k, GrantSource as l, UserSubscriptionResponse as m, MeScopeUsagePayload as n, GetAppManifestResult as o, MintSignerSessionForExternalUserInput as p, ApproveDeviceLoginInput as q, UsageByUserRow as r, UsageForExternalUser as s, UsageByPipelineModelRow as t, UsageByPipelineModelFiatRow as u, AppManifestResponse as v, AllowancePolicy as w, AppManifestCapability as x, BillingSyncState as y, BillingSyncStatus as z };
|
package/dist/verify.cjs
CHANGED
|
@@ -25,7 +25,7 @@ var PmtHouseError = class extends Error {
|
|
|
25
25
|
// src/string-utils.ts
|
|
26
26
|
function stripTrailingSlashes(value) {
|
|
27
27
|
let end = value.length;
|
|
28
|
-
while (end > 0 && value.
|
|
28
|
+
while (end > 0 && (value.codePointAt(end - 1) ?? 0) === 47) {
|
|
29
29
|
end--;
|
|
30
30
|
}
|
|
31
31
|
return value.slice(0, end);
|