@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.
Files changed (85) hide show
  1. package/README.md +106 -2
  2. package/dist/client-BHfjDvIe.d.ts +129 -0
  3. package/dist/client-CvhJEhjV.d.cts +129 -0
  4. package/dist/config.cjs +122 -0
  5. package/dist/config.cjs.map +1 -0
  6. package/dist/config.d.cts +29 -0
  7. package/dist/config.d.ts +29 -0
  8. package/dist/config.js +111 -0
  9. package/dist/config.js.map +1 -0
  10. package/dist/device-initiate.cjs +88 -0
  11. package/dist/device-initiate.cjs.map +1 -0
  12. package/dist/device-initiate.d.cts +32 -0
  13. package/dist/device-initiate.d.ts +32 -0
  14. package/dist/device-initiate.js +84 -0
  15. package/dist/device-initiate.js.map +1 -0
  16. package/dist/device.cjs +1 -1
  17. package/dist/device.cjs.map +1 -1
  18. package/dist/device.d.cts +1 -1
  19. package/dist/device.d.ts +1 -1
  20. package/dist/device.js +1 -1
  21. package/dist/device.js.map +1 -1
  22. package/dist/env.cjs +1071 -28
  23. package/dist/env.cjs.map +1 -1
  24. package/dist/env.d.cts +15 -2
  25. package/dist/env.d.ts +15 -2
  26. package/dist/env.js +1071 -28
  27. package/dist/env.js.map +1 -1
  28. package/dist/gateway/client/index.cjs +492 -0
  29. package/dist/gateway/client/index.cjs.map +1 -0
  30. package/dist/gateway/client/index.d.cts +63 -0
  31. package/dist/gateway/client/index.d.ts +63 -0
  32. package/dist/gateway/client/index.js +489 -0
  33. package/dist/gateway/client/index.js.map +1 -0
  34. package/dist/gateway/index.cjs +16 -0
  35. package/dist/gateway/index.cjs.map +1 -0
  36. package/dist/gateway/index.d.cts +52 -0
  37. package/dist/gateway/index.d.ts +52 -0
  38. package/dist/gateway/index.js +10 -0
  39. package/dist/gateway/index.js.map +1 -0
  40. package/dist/gateway/server/index.cjs +1248 -0
  41. package/dist/gateway/server/index.cjs.map +1 -0
  42. package/dist/gateway/server/index.d.cts +31 -0
  43. package/dist/gateway/server/index.d.ts +31 -0
  44. package/dist/gateway/server/index.js +1233 -0
  45. package/dist/gateway/server/index.js.map +1 -0
  46. package/dist/index.cjs +1401 -137
  47. package/dist/index.cjs.map +1 -1
  48. package/dist/index.d.cts +41 -5
  49. package/dist/index.d.ts +41 -5
  50. package/dist/index.js +1334 -105
  51. package/dist/index.js.map +1 -1
  52. package/dist/ingest-B3Yi8Tb1.d.cts +271 -0
  53. package/dist/ingest-DoKJTWU9.d.ts +271 -0
  54. package/dist/plan-pricing.cjs +108 -0
  55. package/dist/plan-pricing.cjs.map +1 -0
  56. package/dist/plan-pricing.d.cts +15 -0
  57. package/dist/plan-pricing.d.ts +15 -0
  58. package/dist/plan-pricing.js +98 -0
  59. package/dist/plan-pricing.js.map +1 -0
  60. package/dist/signer/server.cjs +1366 -0
  61. package/dist/signer/server.cjs.map +1 -0
  62. package/dist/signer/server.d.cts +73 -0
  63. package/dist/signer/server.d.ts +73 -0
  64. package/dist/signer/server.js +1331 -0
  65. package/dist/signer/server.js.map +1 -0
  66. package/dist/tokens.cjs +75 -0
  67. package/dist/tokens.cjs.map +1 -0
  68. package/dist/tokens.d.cts +48 -0
  69. package/dist/tokens.d.ts +48 -0
  70. package/dist/tokens.js +64 -0
  71. package/dist/tokens.js.map +1 -0
  72. package/dist/types-_R1AwEZp.d.cts +343 -0
  73. package/dist/types-_R1AwEZp.d.ts +343 -0
  74. package/dist/verify.cjs +1 -1
  75. package/dist/verify.cjs.map +1 -1
  76. package/dist/verify.d.cts +1 -1
  77. package/dist/verify.d.ts +1 -1
  78. package/dist/verify.js +1 -1
  79. package/dist/verify.js.map +1 -1
  80. package/gateway/proto/lp_rpc.proto +542 -0
  81. package/package.json +57 -1
  82. package/dist/env-4YmzarGJ.d.ts +0 -68
  83. package/dist/env-CZczUMzR.d.cts +0 -68
  84. package/dist/types-W9PJAspR.d.cts +0 -136
  85. package/dist/types-W9PJAspR.d.ts +0 -136
@@ -1,68 +0,0 @@
1
- import { f as PmtHouseClientOptions, G as GetDiscoveryOptions, O as OidcDiscoveryDocument, P as ParsedDeviceApprovalRedirect, A as AppUserRecord, g as UpsertAppUserInput, M as MintUserAccessTokenInput, d as MintUserAccessTokenResponse, D as DeviceApprovalInput, T as TokenExchangeResponse, C as ClientCredentialsTokenResponse, e as MintUserSignerSessionTokenInput, h as UsageQueryInput, b as UsageApiResponse } from './types-W9PJAspR.cjs';
2
-
3
- /**
4
- * Normalize RFC 8628 user codes for comparison and resource URIs (uppercase, strip separators).
5
- */
6
- declare function normalizeUserCode(value: string): string;
7
- /**
8
- * RFC 8707 resource indicator for NaaP Option B device approval (`urn:pmth:device_code:<normalized>`).
9
- */
10
- declare function buildDeviceCodeResource(userCode: string): string;
11
- declare class PmtHouseClient {
12
- private readonly issuerUrl;
13
- private readonly publicClientId;
14
- private readonly m2mClientId;
15
- private readonly m2mClientSecret;
16
- private readonly fetchImpl;
17
- private readonly logger?;
18
- private readonly allowInsecureHttp;
19
- constructor(options: PmtHouseClientOptions);
20
- getDiscovery(options?: GetDiscoveryOptions): Promise<OidcDiscoveryDocument>;
21
- verifyIssuer(iss: string): boolean;
22
- parseDeviceApprovalRedirect(searchParams: URLSearchParams): ParsedDeviceApprovalRedirect;
23
- listAppUsers(): Promise<{
24
- users: AppUserRecord[];
25
- }>;
26
- upsertAppUser(input: UpsertAppUserInput): Promise<AppUserRecord>;
27
- deleteAppUser(params: {
28
- externalUserId: string;
29
- }): Promise<{
30
- success: boolean;
31
- }>;
32
- mintUserAccessToken(input: MintUserAccessTokenInput): Promise<MintUserAccessTokenResponse>;
33
- completeDeviceApproval(input: DeviceApprovalInput): Promise<TokenExchangeResponse>;
34
- issueMachineAccessToken(scope?: string): Promise<ClientCredentialsTokenResponse>;
35
- exchangeForSignerSession(input: {
36
- userJwt: string;
37
- resource?: string;
38
- }): Promise<TokenExchangeResponse>;
39
- /**
40
- * Mint a short-lived per-user JWT with the Builder API, then exchange it for
41
- * a long-lived opaque signer session token at the PymtHouse OIDC token endpoint.
42
- */
43
- mintUserSignerSessionToken(input: MintUserSignerSessionTokenInput): Promise<TokenExchangeResponse>;
44
- createSignerSessionToken(params: {
45
- userJwt?: string;
46
- }): Promise<TokenExchangeResponse>;
47
- getUsage(input?: UsageQueryInput): Promise<UsageApiResponse>;
48
- private tokenEndpointFetchOptions;
49
- private getAppsBaseUrl;
50
- private getIssuerOrigin;
51
- private builderHeaders;
52
- private m2mClientAuth;
53
- private requestJson;
54
- private safeParseJson;
55
- private asError;
56
- }
57
-
58
- /**
59
- * Site origin for the PymtHouse deployment (e.g. https://pymthouse.com), derived
60
- * from `PYMTHOUSE_ISSUER_URL`.
61
- */
62
- declare function getPymthouseBaseUrl(): string;
63
- /**
64
- * Singleton `PmtHouseClient` from `PYMTHOUSE_*` environment variables (server-side).
65
- */
66
- declare function createPmtHouseClientFromEnv(): PmtHouseClient;
67
-
68
- export { PmtHouseClient as P, buildDeviceCodeResource as b, createPmtHouseClientFromEnv as c, getPymthouseBaseUrl as g, normalizeUserCode as n };
@@ -1,136 +0,0 @@
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";
80
- userId?: string;
81
- gatewayRequestId?: string;
82
- }
83
- interface UsageTotals {
84
- requestCount: number;
85
- totalFeeWei: string;
86
- }
87
- interface UsageByUserRow {
88
- endUserId: string;
89
- externalUserId: string | null;
90
- requestCount: number;
91
- feeWei: string;
92
- userType?: "system_managed" | "oidc_authorized" | "unknown";
93
- identifier?: string;
94
- }
95
- /** One bucket from Usage API `groupBy=pipeline_model` (validated pipeline + model). */
96
- interface UsageByPipelineModelRow {
97
- pipeline: string;
98
- modelId: string;
99
- requestCount: number;
100
- networkFeeWei: string;
101
- networkFeeEth?: string;
102
- networkFeeUsdMicros: string;
103
- ownerChargeUsdMicros: string;
104
- endUserBillableUsdMicros: string;
105
- }
106
- interface UsageApiResponse {
107
- clientId: string;
108
- period: {
109
- start: string | null;
110
- end: string | null;
111
- };
112
- totals: UsageTotals;
113
- byUser?: UsageByUserRow[];
114
- byPipelineModel?: UsageByPipelineModelRow[];
115
- }
116
- /** Aggregated request count and fee for one provider `externalUserId` across duplicate `byUser` buckets. */
117
- interface UsageForExternalUser {
118
- externalUserId: string;
119
- requestCount: number;
120
- feeWei: string;
121
- }
122
- interface ClientCredentialsTokenResponse {
123
- access_token: string;
124
- token_type: "Bearer";
125
- expires_in?: number;
126
- scope?: string;
127
- [key: string]: unknown;
128
- }
129
- interface ParsedDeviceApprovalRedirect {
130
- issuer: string;
131
- targetLinkUri: string;
132
- userCode: string;
133
- clientId: string;
134
- }
135
-
136
- export type { AppUserRecord as A, ClientCredentialsTokenResponse as C, DeviceApprovalInput as D, FetchLike as F, GetDiscoveryOptions as G, MintUserAccessTokenInput as M, OidcDiscoveryDocument as O, ParsedDeviceApprovalRedirect as P, TokenExchangeResponse as T, UsageByUserRow as U, UsageForExternalUser as a, UsageApiResponse as b, UsageByPipelineModelRow as c, MintUserAccessTokenResponse as d, MintUserSignerSessionTokenInput as e, PmtHouseClientOptions as f, UpsertAppUserInput as g, UsageQueryInput as h, UsageTotals as i };
@@ -1,136 +0,0 @@
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";
80
- userId?: string;
81
- gatewayRequestId?: string;
82
- }
83
- interface UsageTotals {
84
- requestCount: number;
85
- totalFeeWei: string;
86
- }
87
- interface UsageByUserRow {
88
- endUserId: string;
89
- externalUserId: string | null;
90
- requestCount: number;
91
- feeWei: string;
92
- userType?: "system_managed" | "oidc_authorized" | "unknown";
93
- identifier?: string;
94
- }
95
- /** One bucket from Usage API `groupBy=pipeline_model` (validated pipeline + model). */
96
- interface UsageByPipelineModelRow {
97
- pipeline: string;
98
- modelId: string;
99
- requestCount: number;
100
- networkFeeWei: string;
101
- networkFeeEth?: string;
102
- networkFeeUsdMicros: string;
103
- ownerChargeUsdMicros: string;
104
- endUserBillableUsdMicros: string;
105
- }
106
- interface UsageApiResponse {
107
- clientId: string;
108
- period: {
109
- start: string | null;
110
- end: string | null;
111
- };
112
- totals: UsageTotals;
113
- byUser?: UsageByUserRow[];
114
- byPipelineModel?: UsageByPipelineModelRow[];
115
- }
116
- /** Aggregated request count and fee for one provider `externalUserId` across duplicate `byUser` buckets. */
117
- interface UsageForExternalUser {
118
- externalUserId: string;
119
- requestCount: number;
120
- feeWei: string;
121
- }
122
- interface ClientCredentialsTokenResponse {
123
- access_token: string;
124
- token_type: "Bearer";
125
- expires_in?: number;
126
- scope?: string;
127
- [key: string]: unknown;
128
- }
129
- interface ParsedDeviceApprovalRedirect {
130
- issuer: string;
131
- targetLinkUri: string;
132
- userCode: string;
133
- clientId: string;
134
- }
135
-
136
- export type { AppUserRecord as A, ClientCredentialsTokenResponse as C, DeviceApprovalInput as D, FetchLike as F, GetDiscoveryOptions as G, MintUserAccessTokenInput as M, OidcDiscoveryDocument as O, ParsedDeviceApprovalRedirect as P, TokenExchangeResponse as T, UsageByUserRow as U, UsageForExternalUser as a, UsageApiResponse as b, UsageByPipelineModelRow as c, MintUserAccessTokenResponse as d, MintUserSignerSessionTokenInput as e, PmtHouseClientOptions as f, UpsertAppUserInput as g, UsageQueryInput as h, UsageTotals as i };