@pymthouse/builder-sdk 0.3.0 → 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.
Files changed (103) hide show
  1. package/README.md +54 -28
  2. package/dist/{client-BHfjDvIe.d.ts → client-CauCfGa7.d.ts} +1 -1
  3. package/dist/{client-CvhJEhjV.d.cts → client-D1Xz-xlx.d.cts} +1 -1
  4. package/dist/config.cjs +0 -21
  5. package/dist/config.cjs.map +1 -1
  6. package/dist/config.d.cts +1 -5
  7. package/dist/config.d.ts +1 -5
  8. package/dist/config.js +1 -20
  9. package/dist/config.js.map +1 -1
  10. package/dist/device-initiate.cjs.map +1 -1
  11. package/dist/device-initiate.js.map +1 -1
  12. package/dist/device.cjs.map +1 -1
  13. package/dist/device.d.cts +1 -1
  14. package/dist/device.d.ts +1 -1
  15. package/dist/device.js.map +1 -1
  16. package/dist/env.cjs +13 -4
  17. package/dist/env.cjs.map +1 -1
  18. package/dist/env.d.cts +2 -2
  19. package/dist/env.d.ts +2 -2
  20. package/dist/env.js +13 -4
  21. package/dist/env.js.map +1 -1
  22. package/dist/index-BTDKEorK.d.ts +64 -0
  23. package/dist/index-BixH4VIG.d.cts +64 -0
  24. package/dist/index.cjs +13 -4
  25. package/dist/index.cjs.map +1 -1
  26. package/dist/index.d.cts +29 -5
  27. package/dist/index.d.ts +29 -5
  28. package/dist/index.js +13 -4
  29. package/dist/index.js.map +1 -1
  30. package/dist/{ingest-DoKJTWU9.d.ts → proxy-JrT6raU_.d.cts} +5 -42
  31. package/dist/{ingest-B3Yi8Tb1.d.cts → proxy-U32DFNuj.d.ts} +5 -42
  32. package/dist/signer/server.cjs +799 -895
  33. package/dist/signer/server.cjs.map +1 -1
  34. package/dist/signer/server.d.cts +9 -13
  35. package/dist/signer/server.d.ts +9 -13
  36. package/dist/signer/server.js +799 -893
  37. package/dist/signer/server.js.map +1 -1
  38. package/dist/signer/webhook/adapters/api-key.cjs +78 -0
  39. package/dist/signer/webhook/adapters/api-key.cjs.map +1 -0
  40. package/dist/signer/webhook/adapters/api-key.d.cts +18 -0
  41. package/dist/signer/webhook/adapters/api-key.d.ts +18 -0
  42. package/dist/signer/webhook/adapters/api-key.js +76 -0
  43. package/dist/signer/webhook/adapters/api-key.js.map +1 -0
  44. package/dist/signer/webhook/adapters/composite.cjs +60 -0
  45. package/dist/signer/webhook/adapters/composite.cjs.map +1 -0
  46. package/dist/signer/webhook/adapters/composite.d.cts +5 -0
  47. package/dist/signer/webhook/adapters/composite.d.ts +5 -0
  48. package/dist/signer/webhook/adapters/composite.js +58 -0
  49. package/dist/signer/webhook/adapters/composite.js.map +1 -0
  50. package/dist/signer/webhook/adapters/oauth1.cjs +18 -0
  51. package/dist/signer/webhook/adapters/oauth1.cjs.map +1 -0
  52. package/dist/signer/webhook/adapters/oauth1.d.cts +19 -0
  53. package/dist/signer/webhook/adapters/oauth1.d.ts +19 -0
  54. package/dist/signer/webhook/adapters/oauth1.js +16 -0
  55. package/dist/signer/webhook/adapters/oauth1.js.map +1 -0
  56. package/dist/signer/webhook/adapters/oidc.cjs +522 -0
  57. package/dist/signer/webhook/adapters/oidc.cjs.map +1 -0
  58. package/dist/signer/webhook/adapters/oidc.d.cts +4 -0
  59. package/dist/signer/webhook/adapters/oidc.d.ts +4 -0
  60. package/dist/signer/webhook/adapters/oidc.js +515 -0
  61. package/dist/signer/webhook/adapters/oidc.js.map +1 -0
  62. package/dist/signer/webhook/adapters/trusted-headers.cjs +103 -0
  63. package/dist/signer/webhook/adapters/trusted-headers.cjs.map +1 -0
  64. package/dist/signer/webhook/adapters/trusted-headers.d.cts +18 -0
  65. package/dist/signer/webhook/adapters/trusted-headers.d.ts +18 -0
  66. package/dist/signer/webhook/adapters/trusted-headers.js +99 -0
  67. package/dist/signer/webhook/adapters/trusted-headers.js.map +1 -0
  68. package/dist/signer/webhook.cjs +747 -0
  69. package/dist/signer/webhook.cjs.map +1 -0
  70. package/dist/signer/webhook.d.cts +26 -0
  71. package/dist/signer/webhook.d.ts +26 -0
  72. package/dist/signer/webhook.js +721 -0
  73. package/dist/signer/webhook.js.map +1 -0
  74. package/dist/tokens.d.cts +1 -1
  75. package/dist/tokens.d.ts +1 -1
  76. package/dist/{types-_R1AwEZp.d.cts → types-BORaHW_x.d.cts} +5 -5
  77. package/dist/{types-_R1AwEZp.d.ts → types-BORaHW_x.d.ts} +5 -5
  78. package/dist/verifier-B-WFDMz6.d.cts +48 -0
  79. package/dist/verifier-B-WFDMz6.d.ts +48 -0
  80. package/dist/verify.cjs.map +1 -1
  81. package/dist/verify.d.cts +1 -1
  82. package/dist/verify.d.ts +1 -1
  83. package/dist/verify.js.map +1 -1
  84. package/package.json +30 -30
  85. package/dist/gateway/client/index.cjs +0 -492
  86. package/dist/gateway/client/index.cjs.map +0 -1
  87. package/dist/gateway/client/index.d.cts +0 -63
  88. package/dist/gateway/client/index.d.ts +0 -63
  89. package/dist/gateway/client/index.js +0 -489
  90. package/dist/gateway/client/index.js.map +0 -1
  91. package/dist/gateway/index.cjs +0 -16
  92. package/dist/gateway/index.cjs.map +0 -1
  93. package/dist/gateway/index.d.cts +0 -52
  94. package/dist/gateway/index.d.ts +0 -52
  95. package/dist/gateway/index.js +0 -10
  96. package/dist/gateway/index.js.map +0 -1
  97. package/dist/gateway/server/index.cjs +0 -1248
  98. package/dist/gateway/server/index.cjs.map +0 -1
  99. package/dist/gateway/server/index.d.cts +0 -31
  100. package/dist/gateway/server/index.d.ts +0 -31
  101. package/dist/gateway/server/index.js +0 -1233
  102. package/dist/gateway/server/index.js.map +0 -1
  103. 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
- export { i as ingestSignedTicket, a as ingestSignedTicketsBatch, s as signerSnapshotToIngestPayload } from './ingest-B3Yi8Tb1.cjs';
3
- import { r as UsageByUserRow, s as UsageForExternalUser, e as UsageApiResponse, n as MeScopeUsagePayload, t as UsageByPipelineModelRow, u as UsageByPipelineModelFiatRow, O as OidcDiscoveryDocument, F as FetchLike, v as AppManifestResponse } from './types-_R1AwEZp.cjs';
4
- 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, S as SignedTicketIngestInput, f as SignedTicketIngestResult, 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-_R1AwEZp.cjs';
5
- export { P as PmtHouseClient, b as buildDeviceCodeResource, n as normalizeUserCode } from './client-CvhJEhjV.cjs';
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
- export { i as ingestSignedTicket, a as ingestSignedTicketsBatch, s as signerSnapshotToIngestPayload } from './ingest-DoKJTWU9.js';
3
- import { r as UsageByUserRow, s as UsageForExternalUser, e as UsageApiResponse, n as MeScopeUsagePayload, t as UsageByPipelineModelRow, u as UsageByPipelineModelFiatRow, O as OidcDiscoveryDocument, F as FetchLike, v as AppManifestResponse } from './types-_R1AwEZp.js';
4
- 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, S as SignedTicketIngestInput, f as SignedTicketIngestResult, 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-_R1AwEZp.js';
5
- export { P as PmtHouseClient, b as buildDeviceCodeResource, n as normalizeUserCode } from './client-BHfjDvIe.js';
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 signerHandlerErrorResponse(error) {
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 LIVEPEER_REMOTE_SIGNER_AUDIENCE, DEFAULT_TTL_REFRESH_RATIO, TOKEN_RESPONSE_ERROR;
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() || LIVEPEER_REMOTE_SIGNER_AUDIENCE;
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,