@pymthouse/builder-sdk 0.3.1 → 0.4.1-rc.1
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 +54 -28
- package/dist/{client-BHfjDvIe.d.ts → client-CauCfGa7.d.ts} +1 -1
- package/dist/{client-CvhJEhjV.d.cts → client-D1Xz-xlx.d.cts} +1 -1
- package/dist/config.cjs +0 -21
- package/dist/config.cjs.map +1 -1
- package/dist/config.d.cts +1 -5
- package/dist/config.d.ts +1 -5
- package/dist/config.js +1 -20
- package/dist/config.js.map +1 -1
- package/dist/device-initiate.cjs.map +1 -1
- package/dist/device-initiate.js.map +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.map +1 -1
- package/dist/env.cjs +13 -4
- package/dist/env.cjs.map +1 -1
- package/dist/env.d.cts +2 -2
- package/dist/env.d.ts +2 -2
- package/dist/env.js +13 -4
- package/dist/env.js.map +1 -1
- package/dist/index-BTDKEorK.d.ts +64 -0
- package/dist/index-BixH4VIG.d.cts +64 -0
- package/dist/index.cjs +13 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +29 -5
- package/dist/index.d.ts +29 -5
- package/dist/index.js +13 -4
- package/dist/index.js.map +1 -1
- package/dist/{ingest-DoKJTWU9.d.ts → proxy-JrT6raU_.d.cts} +5 -42
- package/dist/{ingest-B3Yi8Tb1.d.cts → proxy-U32DFNuj.d.ts} +5 -42
- package/dist/signer/server.cjs +799 -895
- package/dist/signer/server.cjs.map +1 -1
- package/dist/signer/server.d.cts +9 -13
- package/dist/signer/server.d.ts +9 -13
- package/dist/signer/server.js +799 -893
- package/dist/signer/server.js.map +1 -1
- package/dist/signer/webhook/adapters/api-key.cjs +78 -0
- package/dist/signer/webhook/adapters/api-key.cjs.map +1 -0
- package/dist/signer/webhook/adapters/api-key.d.cts +18 -0
- package/dist/signer/webhook/adapters/api-key.d.ts +18 -0
- package/dist/signer/webhook/adapters/api-key.js +76 -0
- package/dist/signer/webhook/adapters/api-key.js.map +1 -0
- package/dist/signer/webhook/adapters/composite.cjs +60 -0
- package/dist/signer/webhook/adapters/composite.cjs.map +1 -0
- package/dist/signer/webhook/adapters/composite.d.cts +5 -0
- package/dist/signer/webhook/adapters/composite.d.ts +5 -0
- package/dist/signer/webhook/adapters/composite.js +58 -0
- package/dist/signer/webhook/adapters/composite.js.map +1 -0
- package/dist/signer/webhook/adapters/oauth1.cjs +18 -0
- package/dist/signer/webhook/adapters/oauth1.cjs.map +1 -0
- package/dist/signer/webhook/adapters/oauth1.d.cts +19 -0
- package/dist/signer/webhook/adapters/oauth1.d.ts +19 -0
- package/dist/signer/webhook/adapters/oauth1.js +16 -0
- package/dist/signer/webhook/adapters/oauth1.js.map +1 -0
- package/dist/signer/webhook/adapters/oidc.cjs +522 -0
- package/dist/signer/webhook/adapters/oidc.cjs.map +1 -0
- package/dist/signer/webhook/adapters/oidc.d.cts +4 -0
- package/dist/signer/webhook/adapters/oidc.d.ts +4 -0
- package/dist/signer/webhook/adapters/oidc.js +515 -0
- package/dist/signer/webhook/adapters/oidc.js.map +1 -0
- package/dist/signer/webhook/adapters/trusted-headers.cjs +103 -0
- package/dist/signer/webhook/adapters/trusted-headers.cjs.map +1 -0
- package/dist/signer/webhook/adapters/trusted-headers.d.cts +18 -0
- package/dist/signer/webhook/adapters/trusted-headers.d.ts +18 -0
- package/dist/signer/webhook/adapters/trusted-headers.js +99 -0
- package/dist/signer/webhook/adapters/trusted-headers.js.map +1 -0
- package/dist/signer/webhook.cjs +747 -0
- package/dist/signer/webhook.cjs.map +1 -0
- package/dist/signer/webhook.d.cts +26 -0
- package/dist/signer/webhook.d.ts +26 -0
- package/dist/signer/webhook.js +721 -0
- package/dist/signer/webhook.js.map +1 -0
- package/dist/tokens.d.cts +1 -1
- package/dist/tokens.d.ts +1 -1
- package/dist/{types-_R1AwEZp.d.cts → types-BORaHW_x.d.cts} +5 -5
- package/dist/{types-_R1AwEZp.d.ts → types-BORaHW_x.d.ts} +5 -5
- package/dist/verifier-B-WFDMz6.d.cts +48 -0
- package/dist/verifier-B-WFDMz6.d.ts +48 -0
- 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.map +1 -1
- package/package.json +30 -30
- package/dist/gateway/client/index.cjs +0 -492
- package/dist/gateway/client/index.cjs.map +0 -1
- package/dist/gateway/client/index.d.cts +0 -63
- package/dist/gateway/client/index.d.ts +0 -63
- package/dist/gateway/client/index.js +0 -489
- package/dist/gateway/client/index.js.map +0 -1
- package/dist/gateway/index.cjs +0 -16
- package/dist/gateway/index.cjs.map +0 -1
- package/dist/gateway/index.d.cts +0 -52
- package/dist/gateway/index.d.ts +0 -52
- package/dist/gateway/index.js +0 -10
- package/dist/gateway/index.js.map +0 -1
- package/dist/gateway/server/index.cjs +0 -1248
- package/dist/gateway/server/index.cjs.map +0 -1
- package/dist/gateway/server/index.d.cts +0 -31
- package/dist/gateway/server/index.d.ts +0 -31
- package/dist/gateway/server/index.js +0 -1233
- package/dist/gateway/server/index.js.map +0 -1
- package/gateway/proto/lp_rpc.proto +0 -542
package/dist/index.d.cts
CHANGED
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
export { NETWORK_USD_PER_MICRO, applyRetailRateToNetworkMicros, defaultRetailRateUsd, markupPercentToRetailRateUsd, parseMarkupPercentInput, parseRetailRateUsd, retailRateUsdPerMillion, retailRateUsdToMarkupPercent } from './plan-pricing.cjs';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export { P as PmtHouseClient, b as buildDeviceCodeResource, n as normalizeUserCode } from './client-
|
|
2
|
+
import { S as SignedTicketIngestInput, F as FetchLike, f as SignedTicketIngestResult, r as UsageByUserRow, s as UsageForExternalUser, e as UsageApiResponse, n as MeScopeUsagePayload, t as UsageByPipelineModelRow, u as UsageByPipelineModelFiatRow, O as OidcDiscoveryDocument, v as AppManifestResponse } from './types-BORaHW_x.cjs';
|
|
3
|
+
export { w as AllowancePolicy, x as AppManifestCapability, A as AppUserRecord, q as ApproveDeviceLoginInput, B as BillingProduct, y as BillingSyncState, z as BillingSyncStatus, E as CapabilityPriceRule, C as ClientCredentialsTokenResponse, D as DeviceApprovalInput, o as GetAppManifestResult, G as GetDiscoveryOptions, l as GrantSource, L as ListBillingProductsResult, p as MintSignerSessionForExternalUserInput, M as MintUserAccessTokenInput, b as MintUserAccessTokenResponse, c as MintUserSignerSessionTokenInput, a as ParsedDeviceApprovalRedirect, h as PlanSyncResult, P as PmtHouseClientOptions, H as SignerRoutingConfig, g as SignerRoutingResponse, T as TokenExchangeResponse, U as UpsertAppUserInput, i as UsageBalanceResponse, I as UsageDailyPipelineRow, d as UsageQueryInput, J as UsageTotals, k as UserAllowanceGrantInput, j as UserAllowancesResponse, K as UserCreditGrantInput, N as UserCreditsResponse, m as UserSubscriptionResponse } from './types-BORaHW_x.cjs';
|
|
4
|
+
import { S as SignerUsageSnapshot } from './proxy-JrT6raU_.cjs';
|
|
5
|
+
export { P as PmtHouseClient, b as buildDeviceCodeResource, n as normalizeUserCode } from './client-D1Xz-xlx.cjs';
|
|
6
6
|
export { PYMTHOUSE_NOT_CONFIGURED_MESSAGE, getBuilderApiV1BaseFromIssuerUrl, getPymthouseIssuerOrigin, getPymthouseIssuerUrlFromEnv, getPymthousePublicClientIdFromEnv, isPymthouseConfigured, readPymthouseEnv } from './config.cjs';
|
|
7
7
|
import { AuthorizationServer } from 'oauth4webapi';
|
|
8
8
|
export { PYMTHOUSE_SIGNER_SESSION_TTL_MS, SIGNER_SESSION_EXPIRES_IN_SEC, SIGNER_SESSION_TTL_MS, SIGN_JOB_SCOPE, SignerSessionToken, computePymthouseExpiry, computeSignerSessionExpiry, decodeJwtExp, isLikelyOidcJwt, isOpaqueSignerSessionToken, parseSignerSessionExchange } from './tokens.cjs';
|
|
9
9
|
|
|
10
|
+
type IngestSignedTicketOptions = {
|
|
11
|
+
issuerUrl: string;
|
|
12
|
+
publicClientId: string;
|
|
13
|
+
m2mClientId: string;
|
|
14
|
+
m2mClientSecret: string;
|
|
15
|
+
ticket: SignedTicketIngestInput;
|
|
16
|
+
fetch?: FetchLike;
|
|
17
|
+
};
|
|
18
|
+
type IngestSignedTicketsBatchOptions = Omit<IngestSignedTicketOptions, "ticket"> & {
|
|
19
|
+
tickets: SignedTicketIngestInput[];
|
|
20
|
+
};
|
|
21
|
+
declare function signerSnapshotToIngestPayload(input: {
|
|
22
|
+
snapshot: SignerUsageSnapshot;
|
|
23
|
+
externalUserId: string;
|
|
24
|
+
gatewayRequestId?: string;
|
|
25
|
+
}): SignedTicketIngestInput;
|
|
26
|
+
declare function ingestSignedTicket(options: IngestSignedTicketOptions): Promise<SignedTicketIngestResult>;
|
|
27
|
+
declare function ingestSignedTicketsBatch(options: IngestSignedTicketsBatchOptions): Promise<{
|
|
28
|
+
results: Array<SignedTicketIngestResult & {
|
|
29
|
+
requestId?: string;
|
|
30
|
+
ok?: boolean;
|
|
31
|
+
}>;
|
|
32
|
+
}>;
|
|
33
|
+
|
|
10
34
|
/** ISO bounds for the current calendar month in UTC (billing-friendly window). */
|
|
11
35
|
declare function getUtcCalendarMonthIsoBounds(now?: Date): {
|
|
12
36
|
startDate: string;
|
|
@@ -80,4 +104,4 @@ declare function clearDiscoveryCache(issuerUrl?: string): void;
|
|
|
80
104
|
declare function parseAppManifestResponse(json: unknown): AppManifestResponse;
|
|
81
105
|
declare function computeManifestRevision(data: Pick<AppManifestResponse, "capabilities" | "excludedCapabilities" | "manifestVersion"> | null): string;
|
|
82
106
|
|
|
83
|
-
export { AppManifestResponse, DEFAULT_MAX_END_USER_IDS, FetchLike, type LoadAuthorizationServerOptions, MeScopeUsagePayload, OidcDiscoveryDocument, PmtHouseError, UsageApiResponse, UsageByPipelineModelFiatRow, UsageByPipelineModelRow, UsageByUserRow, UsageForExternalUser, aggregateUsageByExternalUserId, authorizationServerToOidcDocument, buildMeScopeUsagePayload, clearDiscoveryCache, computeManifestRevision, fetchDiscoveryDocument, getEndUserIdsForExternalUser, getUsageRecordUserIdsForExternalUser, getUtcCalendarMonthIsoBounds, listUsageByPipelineModel, loadAuthorizationServer, mergeUsageByPipelineModel, parseAppManifestResponse, parseUsageDateParam, summarizeUsageFiatForExternalUser, summarizeUsageForExternalUser, toPmtHouseError };
|
|
107
|
+
export { AppManifestResponse, DEFAULT_MAX_END_USER_IDS, FetchLike, type LoadAuthorizationServerOptions, MeScopeUsagePayload, OidcDiscoveryDocument, PmtHouseError, SignedTicketIngestInput, SignedTicketIngestResult, UsageApiResponse, UsageByPipelineModelFiatRow, UsageByPipelineModelRow, UsageByUserRow, UsageForExternalUser, aggregateUsageByExternalUserId, authorizationServerToOidcDocument, buildMeScopeUsagePayload, clearDiscoveryCache, computeManifestRevision, fetchDiscoveryDocument, getEndUserIdsForExternalUser, getUsageRecordUserIdsForExternalUser, getUtcCalendarMonthIsoBounds, ingestSignedTicket, ingestSignedTicketsBatch, listUsageByPipelineModel, loadAuthorizationServer, mergeUsageByPipelineModel, parseAppManifestResponse, parseUsageDateParam, signerSnapshotToIngestPayload, summarizeUsageFiatForExternalUser, summarizeUsageForExternalUser, toPmtHouseError };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,12 +1,36 @@
|
|
|
1
1
|
export { NETWORK_USD_PER_MICRO, applyRetailRateToNetworkMicros, defaultRetailRateUsd, markupPercentToRetailRateUsd, parseMarkupPercentInput, parseRetailRateUsd, retailRateUsdPerMillion, retailRateUsdToMarkupPercent } from './plan-pricing.js';
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
export { P as PmtHouseClient, b as buildDeviceCodeResource, n as normalizeUserCode } from './client-
|
|
2
|
+
import { S as SignedTicketIngestInput, F as FetchLike, f as SignedTicketIngestResult, r as UsageByUserRow, s as UsageForExternalUser, e as UsageApiResponse, n as MeScopeUsagePayload, t as UsageByPipelineModelRow, u as UsageByPipelineModelFiatRow, O as OidcDiscoveryDocument, v as AppManifestResponse } from './types-BORaHW_x.js';
|
|
3
|
+
export { w as AllowancePolicy, x as AppManifestCapability, A as AppUserRecord, q as ApproveDeviceLoginInput, B as BillingProduct, y as BillingSyncState, z as BillingSyncStatus, E as CapabilityPriceRule, C as ClientCredentialsTokenResponse, D as DeviceApprovalInput, o as GetAppManifestResult, G as GetDiscoveryOptions, l as GrantSource, L as ListBillingProductsResult, p as MintSignerSessionForExternalUserInput, M as MintUserAccessTokenInput, b as MintUserAccessTokenResponse, c as MintUserSignerSessionTokenInput, a as ParsedDeviceApprovalRedirect, h as PlanSyncResult, P as PmtHouseClientOptions, H as SignerRoutingConfig, g as SignerRoutingResponse, T as TokenExchangeResponse, U as UpsertAppUserInput, i as UsageBalanceResponse, I as UsageDailyPipelineRow, d as UsageQueryInput, J as UsageTotals, k as UserAllowanceGrantInput, j as UserAllowancesResponse, K as UserCreditGrantInput, N as UserCreditsResponse, m as UserSubscriptionResponse } from './types-BORaHW_x.js';
|
|
4
|
+
import { S as SignerUsageSnapshot } from './proxy-U32DFNuj.js';
|
|
5
|
+
export { P as PmtHouseClient, b as buildDeviceCodeResource, n as normalizeUserCode } from './client-CauCfGa7.js';
|
|
6
6
|
export { PYMTHOUSE_NOT_CONFIGURED_MESSAGE, getBuilderApiV1BaseFromIssuerUrl, getPymthouseIssuerOrigin, getPymthouseIssuerUrlFromEnv, getPymthousePublicClientIdFromEnv, isPymthouseConfigured, readPymthouseEnv } from './config.js';
|
|
7
7
|
import { AuthorizationServer } from 'oauth4webapi';
|
|
8
8
|
export { PYMTHOUSE_SIGNER_SESSION_TTL_MS, SIGNER_SESSION_EXPIRES_IN_SEC, SIGNER_SESSION_TTL_MS, SIGN_JOB_SCOPE, SignerSessionToken, computePymthouseExpiry, computeSignerSessionExpiry, decodeJwtExp, isLikelyOidcJwt, isOpaqueSignerSessionToken, parseSignerSessionExchange } from './tokens.js';
|
|
9
9
|
|
|
10
|
+
type IngestSignedTicketOptions = {
|
|
11
|
+
issuerUrl: string;
|
|
12
|
+
publicClientId: string;
|
|
13
|
+
m2mClientId: string;
|
|
14
|
+
m2mClientSecret: string;
|
|
15
|
+
ticket: SignedTicketIngestInput;
|
|
16
|
+
fetch?: FetchLike;
|
|
17
|
+
};
|
|
18
|
+
type IngestSignedTicketsBatchOptions = Omit<IngestSignedTicketOptions, "ticket"> & {
|
|
19
|
+
tickets: SignedTicketIngestInput[];
|
|
20
|
+
};
|
|
21
|
+
declare function signerSnapshotToIngestPayload(input: {
|
|
22
|
+
snapshot: SignerUsageSnapshot;
|
|
23
|
+
externalUserId: string;
|
|
24
|
+
gatewayRequestId?: string;
|
|
25
|
+
}): SignedTicketIngestInput;
|
|
26
|
+
declare function ingestSignedTicket(options: IngestSignedTicketOptions): Promise<SignedTicketIngestResult>;
|
|
27
|
+
declare function ingestSignedTicketsBatch(options: IngestSignedTicketsBatchOptions): Promise<{
|
|
28
|
+
results: Array<SignedTicketIngestResult & {
|
|
29
|
+
requestId?: string;
|
|
30
|
+
ok?: boolean;
|
|
31
|
+
}>;
|
|
32
|
+
}>;
|
|
33
|
+
|
|
10
34
|
/** ISO bounds for the current calendar month in UTC (billing-friendly window). */
|
|
11
35
|
declare function getUtcCalendarMonthIsoBounds(now?: Date): {
|
|
12
36
|
startDate: string;
|
|
@@ -80,4 +104,4 @@ declare function clearDiscoveryCache(issuerUrl?: string): void;
|
|
|
80
104
|
declare function parseAppManifestResponse(json: unknown): AppManifestResponse;
|
|
81
105
|
declare function computeManifestRevision(data: Pick<AppManifestResponse, "capabilities" | "excludedCapabilities" | "manifestVersion"> | null): string;
|
|
82
106
|
|
|
83
|
-
export { AppManifestResponse, DEFAULT_MAX_END_USER_IDS, FetchLike, type LoadAuthorizationServerOptions, MeScopeUsagePayload, OidcDiscoveryDocument, PmtHouseError, UsageApiResponse, UsageByPipelineModelFiatRow, UsageByPipelineModelRow, UsageByUserRow, UsageForExternalUser, aggregateUsageByExternalUserId, authorizationServerToOidcDocument, buildMeScopeUsagePayload, clearDiscoveryCache, computeManifestRevision, fetchDiscoveryDocument, getEndUserIdsForExternalUser, getUsageRecordUserIdsForExternalUser, getUtcCalendarMonthIsoBounds, listUsageByPipelineModel, loadAuthorizationServer, mergeUsageByPipelineModel, parseAppManifestResponse, parseUsageDateParam, summarizeUsageFiatForExternalUser, summarizeUsageForExternalUser, toPmtHouseError };
|
|
107
|
+
export { AppManifestResponse, DEFAULT_MAX_END_USER_IDS, FetchLike, type LoadAuthorizationServerOptions, MeScopeUsagePayload, OidcDiscoveryDocument, PmtHouseError, SignedTicketIngestInput, SignedTicketIngestResult, UsageApiResponse, UsageByPipelineModelFiatRow, UsageByPipelineModelRow, UsageByUserRow, UsageForExternalUser, aggregateUsageByExternalUserId, authorizationServerToOidcDocument, buildMeScopeUsagePayload, clearDiscoveryCache, computeManifestRevision, fetchDiscoveryDocument, getEndUserIdsForExternalUser, getUsageRecordUserIdsForExternalUser, getUtcCalendarMonthIsoBounds, ingestSignedTicket, ingestSignedTicketsBatch, listUsageByPipelineModel, loadAuthorizationServer, mergeUsageByPipelineModel, parseAppManifestResponse, parseUsageDateParam, signerSnapshotToIngestPayload, summarizeUsageFiatForExternalUser, summarizeUsageForExternalUser, toPmtHouseError };
|
package/dist/index.js
CHANGED
|
@@ -242,8 +242,14 @@ var init_fetch_json = __esm({
|
|
|
242
242
|
});
|
|
243
243
|
|
|
244
244
|
// src/signer/handler-errors.ts
|
|
245
|
-
function
|
|
245
|
+
function isPmtHouseError(error) {
|
|
246
246
|
if (error instanceof PmtHouseError) {
|
|
247
|
+
return true;
|
|
248
|
+
}
|
|
249
|
+
return error instanceof Error && typeof error.status === "number" && typeof error.code === "string";
|
|
250
|
+
}
|
|
251
|
+
function signerHandlerErrorResponse(error) {
|
|
252
|
+
if (isPmtHouseError(error)) {
|
|
247
253
|
return new Response(
|
|
248
254
|
JSON.stringify({
|
|
249
255
|
error: error.code,
|
|
@@ -296,6 +302,9 @@ var init_json_fields = __esm({
|
|
|
296
302
|
});
|
|
297
303
|
|
|
298
304
|
// src/signer/mint-token.ts
|
|
305
|
+
function signerJwtAudience(issuerUrl) {
|
|
306
|
+
return stripTrailingSlashes(issuerUrl);
|
|
307
|
+
}
|
|
299
308
|
function parseMintUserSignerTokenResponse(body, ttlRefreshRatio = DEFAULT_TTL_REFRESH_RATIO) {
|
|
300
309
|
const accessToken = readStringField(body, "access_token", TOKEN_RESPONSE_ERROR, "Token response");
|
|
301
310
|
const expiresIn = readExpiresIn(body, TOKEN_RESPONSE_ERROR);
|
|
@@ -322,11 +331,11 @@ function parseMintUserSignerTokenResponse(body, ttlRefreshRatio = DEFAULT_TTL_RE
|
|
|
322
331
|
lifetimeGrantedUsdMicros
|
|
323
332
|
};
|
|
324
333
|
}
|
|
325
|
-
var
|
|
334
|
+
var DEFAULT_TTL_REFRESH_RATIO, TOKEN_RESPONSE_ERROR;
|
|
326
335
|
var init_mint_token = __esm({
|
|
327
336
|
"src/signer/mint-token.ts"() {
|
|
337
|
+
init_string_utils();
|
|
328
338
|
init_json_fields();
|
|
329
|
-
LIVEPEER_REMOTE_SIGNER_AUDIENCE = "livepeer-remote-signer";
|
|
330
339
|
DEFAULT_TTL_REFRESH_RATIO = 0.8;
|
|
331
340
|
TOKEN_RESPONSE_ERROR = "invalid_token_response";
|
|
332
341
|
}
|
|
@@ -393,7 +402,7 @@ async function mintSignerTokenFromDeviceToken(options) {
|
|
|
393
402
|
code: "oidc_discovery_invalid"
|
|
394
403
|
});
|
|
395
404
|
}
|
|
396
|
-
const audience = options.audience?.trim() ||
|
|
405
|
+
const audience = options.audience?.trim() || signerJwtAudience(issuerUrl);
|
|
397
406
|
const params = new URLSearchParams({
|
|
398
407
|
grant_type: TOKEN_EXCHANGE_GRANT,
|
|
399
408
|
subject_token: options.deviceToken,
|