@domino-sdk/relay 1.74.0 → 1.76.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 (53) hide show
  1. package/CHANGELOG.md +54 -0
  2. package/dist/authoring.d.ts +6 -6
  3. package/dist/authoring.js +4 -4
  4. package/dist/browser.d.ts +3 -3
  5. package/dist/browser.js +8 -8
  6. package/dist/{capability-error-Bn6cCqof.d.ts → capability-error-D56xxE2i.d.ts} +1 -1
  7. package/dist/{chunk-CW7FJ5PX.js → chunk-3KHVIUKK.js} +1 -1
  8. package/dist/{chunk-2LURSPDM.js → chunk-4WODSE6Y.js} +2 -2
  9. package/dist/{chunk-F66GGNKD.js → chunk-4YKOSNYI.js} +1 -1
  10. package/dist/{chunk-ELHMJODS.js → chunk-7B7MDHJ6.js} +1 -1
  11. package/dist/{chunk-6TDHRGBM.js → chunk-7QHROIML.js} +3 -0
  12. package/dist/{chunk-DNOLNMCW.js → chunk-E4ZQCG44.js} +9 -8
  13. package/dist/{chunk-SVZ3QWHT.js → chunk-FBS65R66.js} +2 -2
  14. package/dist/{chunk-KP55TMCC.js → chunk-HEQ7HLXG.js} +1 -1
  15. package/dist/{chunk-TGQNNMCY.js → chunk-IMX45NSW.js} +6 -6
  16. package/dist/{chunk-RALBAKKX.js → chunk-K3PEQXDV.js} +1 -1
  17. package/dist/{chunk-JZT2NLSG.js → chunk-LFFGW7GB.js} +449 -392
  18. package/dist/{chunk-NI6XRGEL.js → chunk-SPLXHFVX.js} +2 -2
  19. package/dist/{chunk-KGZ7SRKJ.js → chunk-TAZ5AEYF.js} +1 -1
  20. package/dist/{chunk-HCOLMJFX.js → chunk-X5REDFGV.js} +4 -3
  21. package/dist/{chunk-T4PTFCSB.js → chunk-XEXB3WZE.js} +1 -1
  22. package/dist/{chunk-724CKAC7.js → chunk-YB5BSKVU.js} +3 -3
  23. package/dist/{chunk-7I7P5UVC.js → chunk-ZXFRHGZC.js} +422 -291
  24. package/dist/{client-B2aVGf38.d.ts → client-336yROej.d.ts} +2 -2
  25. package/dist/{identity-integration-C03rUYc0.d.ts → identity-integration-B1f5oOdc.d.ts} +1169 -3
  26. package/dist/{transport-D77Rbf4D.d.ts → index-BM0DdDYy.d.ts} +614 -1274
  27. package/dist/index.d.ts +3 -3
  28. package/dist/index.js +7 -7
  29. package/dist/internal.d.ts +46 -22
  30. package/dist/internal.js +24 -17
  31. package/dist/{limits-p-Mg0oSi.d.ts → limits-DICxln-i.d.ts} +6 -0
  32. package/dist/portal-proxy.d.ts +8 -1
  33. package/dist/portal-proxy.js +125 -50
  34. package/dist/react/index.d.ts +5 -5
  35. package/dist/react/index.js +8 -8
  36. package/dist/runtime/authoring.js +1 -1
  37. package/dist/runtime/chunks/H6GH644T.js +1 -0
  38. package/dist/runtime/manifest.json +3 -3
  39. package/dist/runtime/schema.js +1 -1
  40. package/dist/schema.d.ts +4 -4
  41. package/dist/schema.js +7 -7
  42. package/dist/server/index.d.ts +4 -4
  43. package/dist/server/index.js +136 -29
  44. package/dist/{sign-in-providers-BG22ZZkl.d.ts → sign-in-providers-BMtk_NWY.d.ts} +1 -1
  45. package/dist/solana.d.ts +3 -3
  46. package/dist/solana.js +8 -8
  47. package/dist/{station-check-in-a1deSjbm.d.ts → station-check-in-vcDKQOet.d.ts} +2 -2
  48. package/dist/{submission-input-DBDLkTF8.d.ts → submission-input-D_NiBR0W.d.ts} +6 -1
  49. package/dist/telegram.d.ts +2 -2
  50. package/dist/testing.d.ts +2 -2
  51. package/dist/testing.js +15 -5
  52. package/package.json +2 -1
  53. package/dist/runtime/chunks/NYEWMPJH.js +0 -1
package/dist/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  export { B as Badge, a as BadgeCatalog, M as ManagedBadge, b as MemberBadge, c as MemberBadges, O as Offer, d as OfferDefinition, e as OfferPrice, R as RedeemOfferInput, f as Redemption } from './offers-CnMyMeQo.js';
2
2
  export { R as RelayAction, c as createRelayAction } from './action-BDFKqGlH.js';
3
- export { A as AuthStartInput, C as ClaimSubmission, E as EmailVerification, K as KnownRelayErrorCode, P as PhotoSubmission, a as ProgressObservation, b as ProgressObserver, Q as QuestActionResult, c as QuestController, d as QuestUpdatedError, e as QuizSubmission, R as RelayClient, f as RelayClientOptions, g as RelayError, h as RelayErrorCode, i as RelayErrorDetails, j as RelayErrorKind, k as RelayRequestOptions, l as RelayResponseOptions, S as SubmissionCallOptions, m as SubmissionDraft, n as SubmissionStatus, o as SubmissionStore, V as ValueSubmission, p as createRelayClient, q as isRelayError } from './client-B2aVGf38.js';
3
+ export { A as AuthStartInput, C as ClaimSubmission, E as EmailVerification, K as KnownRelayErrorCode, P as PhotoSubmission, a as ProgressObservation, b as ProgressObserver, Q as QuestActionResult, c as QuestController, d as QuestUpdatedError, e as QuizSubmission, R as RelayClient, f as RelayClientOptions, g as RelayError, h as RelayErrorCode, i as RelayErrorDetails, j as RelayErrorKind, k as RelayRequestOptions, l as RelayResponseOptions, S as SubmissionCallOptions, m as SubmissionDraft, n as SubmissionStatus, o as SubmissionStore, V as ValueSubmission, p as createRelayClient, q as isRelayError } from './client-336yROej.js';
4
4
  export { R as RequestError, a as RequestErrorDetails, b as RequestErrorKind, c as RequestRecovery, i as isRequestError } from './request-error-C24SY7n9.js';
5
5
  export { A as AccountConnection, a as Attempt, b as AttemptStatus, c as AuthProvider, d as AvailabilityWindow, C as CampaignDefinition, e as CampaignEnrollment, f as CampaignEnrollmentInput, g as CampaignView, h as CampaignWithdrawalInput, E as Entitlement, i as EvaluatorProgress, K as KnownAttemptStatus, j as KnownPointEntryKind, k as KnownSignInAccountStatus, l as KnownSignInProvider, L as LeaderboardDefinition, m as LeaderboardHistoryPage, n as LeaderboardHistoryQuery, o as LeaderboardPage, p as LeaderboardPlacement, q as LeaderboardQuery, M as MemberCampaignEnrollmentInput, r as MemberCampaignWithdrawalInput, s as MemberProgress, P as PointBalance, t as PointBalances, u as PointEntry, v as PointEntryKind, w as PointHistoryPage, x as PointHistoryQuery, y as PointLedgerReference, z as ProjectGroup, B as ProjectGroupReference, Q as QuestBudgetView, D as QuestPresentation, F as QuestProfile, G as QuizEvidence, R as ReferralDefinition, H as Reward, S as SignInAccount, I as SignInAccountStatus, J as SignInProvider, N as SignInProviderOption, O as StationCheckIn, T as SubmissionEvidence, U as SubmitInput, V as TieredRewardReference } from './accounts-C9as33l1.js';
6
6
  export { f as formatUnits, p as parseUnits } from './units-CwgsPB_r.js';
7
7
  export { C as ConsentChannel, a as ConsentInput, b as ConsentSource, c as ConsentState, d as CreatorAccount, e as CreatorAccountProvider, f as CreatorAccounts, K as KnownConsentChannel, g as KnownConsentSource, h as KnownConsentState, M as MemberConsent, P as Page, i as PageQuery, Q as QuestClaimInput, j as QuestEnrollment, k as QuestEnrollmentInput, l as QuestOutcome, m as QuestOutcomePage, n as QuestOutcomeQuery, o as QuestOutcomeState, R as ResponseResult, U as UnsupportedResponse, p as paginate } from './reward-deliveries-zWfsgc6m.js';
8
- export { M as MissingPrerequisite, P as Prerequisite, T as TelegramAccountConnection, a as TelegramSignInMethods, b as TextEvidence, c as TextOptions, U as UrlEvidence, d as UrlOptions, V as ValueEvidence } from './submission-input-DBDLkTF8.js';
8
+ export { M as MissingPrerequisite, P as Prerequisite, T as TelegramAccountConnection, a as TelegramSignInMethods, b as TextEvidence, c as TextOptions, U as UrlEvidence, d as UrlOptions, V as ValueEvidence } from './submission-input-D_NiBR0W.js';
9
9
  export { E as ExchangeInput, M as MemberSummary, P as ParticipantActivity, a as ParticipantPrincipal, b as ParticipantSession, R as RelayEvent, S as Session, s as sessionMember } from './participant-activity-BznrcePT.js';
10
10
  export { Q as QuestInteraction, a as QuestRewardView, b as QuestView } from './catalog-9I6t18qP.js';
11
11
  export { A as AutomaticCatchUpPreview, a as AutomaticEvent, b as AutomaticOutcome, C as CollectionPass, c as CounterAchievement, d as CounterPolicy, e as CounterProgress } from './automatic-outcomes-D0yMHSHL.js';
@@ -15,4 +15,4 @@ export { Q as QuizContent, S as StreakProgress } from './streaks-MAqKHbHC.js';
15
15
  export { C as CosmosChain, a as CosmosNetwork, L as LinkedWallet, W as WalletAddressInput, b as WalletChain, c as WalletMessageChallenge, d as WalletProofKind, e as WalletSignInNetwork, f as WalletSignature, g as WalletSigner, h as WalletTransactionChallenge, i as WalletTransactionProof, j as WalletUnlinkInput } from './wallet-CeqgtXNm.js';
16
16
  export { P as ParticipantDelivery } from './participant-rewards-s5Gn23qb.js';
17
17
  import 'zod';
18
- import './sign-in-providers-BG22ZZkl.js';
18
+ import './sign-in-providers-BMtk_NWY.js';
package/dist/index.js CHANGED
@@ -5,25 +5,25 @@ import {
5
5
  import {
6
6
  QuestUpdatedError,
7
7
  createRelayClient
8
- } from "./chunk-DNOLNMCW.js";
8
+ } from "./chunk-E4ZQCG44.js";
9
9
  import {
10
10
  createRelayAction
11
11
  } from "./chunk-E73HZCG2.js";
12
12
  import "./chunk-AL5XMXPO.js";
13
- import "./chunk-F66GGNKD.js";
14
- import "./chunk-HCOLMJFX.js";
13
+ import "./chunk-4YKOSNYI.js";
14
+ import "./chunk-X5REDFGV.js";
15
15
  import {
16
16
  QuestOutcomeState
17
- } from "./chunk-KP55TMCC.js";
17
+ } from "./chunk-HEQ7HLXG.js";
18
18
  import {
19
19
  sessionMember
20
- } from "./chunk-CW7FJ5PX.js";
21
- import "./chunk-KGZ7SRKJ.js";
20
+ } from "./chunk-3KHVIUKK.js";
21
+ import "./chunk-TAZ5AEYF.js";
22
22
  import {
23
23
  AttemptStatus,
24
24
  PointEntryKind,
25
25
  paginate
26
- } from "./chunk-6TDHRGBM.js";
26
+ } from "./chunk-7QHROIML.js";
27
27
  import {
28
28
  RelayError,
29
29
  RelayErrorCode,
@@ -1,14 +1,16 @@
1
- import { a as ManagementEndpoint } from './transport-D77Rbf4D.js';
2
- import { managedAttemptPageSchema, managedAttemptSchema, evidenceRedactionResultSchema, evidenceRetentionResultSchema, evidenceRetentionSettingSchema, BillingPlan, memberCompletionPageSchema, completionRevocationSchema, completionRestorationSchema, completionReceiptSchema, completionReceiptListSchema, ConnectionStatus, ConnectionReconnectReason, ConnectionSyncKind, ConnectionSyncStatus, PluginSlot, ProjectRole, managedEntitlementPageSchema, managedEntitlementSchema, inventoryItemPageSchema, inventoryItemStateSchema, stockAdditionSchema, leaderboardSettlementReviewPageSchema, leaderboardSettlementReviewSchema, leaderboardSettlementExportSchema, solanaPayoutPageSchema, solanaPayoutSchema, solanaPayoutConfirmationResultSchema, RevokedEntitlementOutcome, RevokedDeliveryOutcome, RevokedReferralOutcome, IdentitySource, MemberBanRunStatus, ManagedAccountStatus, offerLifecycleResultSchema, tieredRewardLifecycleResultSchema, operationSchema, ProjectPermission, StationProof, StationStatus, TestMemberDecisionKind } from './server/index.js';
3
- export { O as EndpointMethod, Q as EndpointPermission, U as EndpointResult, V as HOSTING_NAME_PATTERN, X as ID_PATTERN, Y as ManagementTransportOptions, Z as OrganizationRule, _ as ParameterPattern, $ as ParticipantRoute, a0 as PathParameters, a1 as QuestShapeError, a2 as REFERRAL_INTEGRATION_REWARD_ERROR, a3 as SEGMENT_PATTERN, a4 as UUID_PATTERN, a5 as containsReferralIntegrationReward, a6 as endpointRoute, a7 as isIntegrationParticipantPath, a8 as isParticipantRoute, a9 as managementEndpoint, aa as managementTransport, ab as nextScheduleRun, ac as ok, ad as parseImageExtraction, ae as parseImageResult, af as participantRoutePattern, ag as participantRoutes, ah as questConfiguration, ai as sequenceCursorSchema, aj as sourceDataSchema, ak as sourceRoles, al as validateQuestShape } from './transport-D77Rbf4D.js';
4
- import { MemberImportState, MemberImportRefusalCode } from './server/index.js';
5
- export { A as AccountVouchedBy, d as IdentityIntegration, e as IdentityIntegrationAccountVouchingInput, f as IdentityIntegrationAppSecret, I as IdentityIntegrationKey, g as IdentityKindClaim, K as KnownIdentityIntegrationEnvironment, P as ParticipantExchangeAccountResult, h as ParticipantExchangeInput, a as ParticipantExchangeResult, i as accountVouchedBySchema, j as appLoginOriginSchema, k as httpsOriginSchema, l as identityIntegrationAccountVouchingInputSchema, m as identityIntegrationAppSecretSchema, n as identityIntegrationInputSchema, o as identityIntegrationKeySchema, p as identityIntegrationSchema, q as identityIntegrationSecretSchema, r as identityKindClaimSchema, s as participantExchangeAccountResultSchema, t as participantExchangeAccountsSchema, u as participantExchangeResultSchema, v as participantExchangeSchema } from './identity-integration-C03rUYc0.js';
6
- import { E as Extracted } from './limits-p-Mg0oSi.js';
1
+ import { a as ManagementEndpoint } from './index-BM0DdDYy.js';
2
+ import { managedAttemptPageSchema, managedAttemptSchema, evidenceRedactionResultSchema, evidenceRetentionResultSchema, evidenceRetentionSettingSchema, BillingPlan, memberCompletionPageSchema, completionRevocationSchema, completionRestorationSchema, completionReceiptSchema, completionReceiptListSchema, ConnectionStatus, ConnectionReconnectReason, ConnectionSyncKind, ConnectionSyncStatus, PluginSlot, managedEntitlementPageSchema, managedEntitlementSchema, inventoryItemPageSchema, inventoryItemStateSchema, stockAdditionSchema, leaderboardMemberStandingSchema, leaderboardSettlementReviewPageSchema, leaderboardSettlementReviewSchema, leaderboardSettlementExportSchema, solanaPayoutPageSchema, solanaPayoutSchema, solanaPayoutConfirmationResultSchema, RevokedEntitlementOutcome, RevokedDeliveryOutcome, RevokedReferralOutcome, IdentitySource, MemberBanRunStatus, ManagedAccountStatus, offerLifecycleResultSchema, tieredRewardLifecycleResultSchema, operationSchema, StationProof, StationStatus, managedReferralHistorySchema, TestMemberDecisionKind } from './server/index.js';
3
+ export { O as EndpointMethod, Q as EndpointPermission, U as EndpointResult, V as HOSTING_NAME_PATTERN, X as ID_PATTERN, Y as ManagementTransportOptions, Z as OrganizationRule, _ as ParameterPattern, $ as ParticipantRoute, a0 as PathParameters, a1 as QuestShapeError, a2 as REFERRAL_INTEGRATION_REWARD_ERROR, a3 as SEGMENT_PATTERN, a4 as UUID_PATTERN, a5 as containsReferralIntegrationReward, a6 as endpointRoute, a7 as isIntegrationParticipantPath, a8 as isParticipantRoute, a9 as managementEndpoint, aa as managementTransport, ab as nextScheduleRun, ac as ok, ad as parseImageExtraction, ae as parseImageResult, af as participantRoutePattern, ag as participantRoutes, ah as questConfiguration, ai as sequenceCursorSchema, aj as sourceDataSchema, ak as sourceRoles, al as validateQuestShape } from './index-BM0DdDYy.js';
4
+ import { ProjectRole, AppSecretCredential, MemberImportState, MemberImportRefusalCode, ProjectPermission } from './server/index.js';
5
+ export { f as AccountVouchedBy, g as IdentityIntegration, h as IdentityIntegrationAccountVouchingInput, i as IdentityIntegrationAppSecret, I as IdentityIntegrationKey, j as IdentityKindClaim, K as KnownIdentityIntegrationEnvironment, P as ParticipantExchangeAccountResult, k as ParticipantExchangeInput, a as ParticipantExchangeResult, l as accountVouchedBySchema, m as appLoginOriginSchema, n as httpsOriginSchema, o as identityIntegrationAccountVouchingInputSchema, p as identityIntegrationAppSecretSchema, q as identityIntegrationInputSchema, r as identityIntegrationKeySchema, s as identityIntegrationSchema, t as identityIntegrationSecretSchema, u as identityKindClaimSchema, v as participantExchangeAccountResultSchema, w as participantExchangeAccountsSchema, x as participantExchangeResultSchema, y as participantExchangeSchema } from './identity-integration-B1f5oOdc.js';
6
+ import { E as Extracted } from './limits-DICxln-i.js';
7
7
  import { ImageReference, ImageFields } from './schema.js';
8
8
  import { IntegrationModuleProvider, GalleryKind } from './authoring.js';
9
9
  import { AttemptStatus, SignInProvider } from './index.js';
10
- import { AttemptCodeSource, attemptSchema, RewardType, contentPerformancePageSchema, engagementPageSchema, engagementBoundaryPageSchema, engagementVersionPageSchema, engagementRuleVersionPageSchema, engagementRuleSchema, engagementChangePreviewSchema, entitlementSchema, stockItemSchema, pickupCatalogSchema, pickupAvailabilitySchema, leaderboardPageSchema, leaderboardExclusionGroupSchema, leaderboardSettlementSchema, CompletionSourceKind, KnownAttemptActionKind, QuestSubmissionStatus, referralManagementSchema } from './schema.js';
10
+ import { AttemptCodeSource, attemptSchema, RewardType, contentPerformancePageSchema, engagementPageSchema, engagementBoundaryPageSchema, engagementVersionPageSchema, engagementRuleVersionPageSchema, engagementRuleSchema, engagementChangePreviewSchema, entitlementSchema, stockItemSchema, pickupCatalogSchema, pickupAvailabilitySchema, leaderboardPageSchema, leaderboardHistoryPageSchema, leaderboardExclusionGroupSchema, leaderboardSettlementSchema, CompletionSourceKind, KnownAttemptActionKind, QuestSubmissionStatus, referralManagementSchema } from './schema.js';
11
11
  export { ew as stationRefusal } from './accounts-C9as33l1.js';
12
+ import { TelegramChatMemberStatus } from './authoring.js';
13
+ export { S as photoEvidenceByteLimit } from './submission-input-D_NiBR0W.js';
12
14
  import { StandardWallet, StandardWalletAccount } from './browser.js';
13
15
  import { SolanaSeed, NftCollection, WalletBalanceQuery, WalletNftsQuery, WalletCallQuery, WalletDelegationsQuery, WalletEventsQuery, WalletTransactionsQuery, WalletProgramAccountQuery, WalletStakeQuery } from './authoring.js';
14
16
  import { WalletProofKind } from './index.js';
@@ -20,9 +22,8 @@ import { SkipEnrollment } from './index.js';
20
22
  import { OpenIdentityKind, trackerStatusSchema, trackerPageSchema, trackerContentSchema, trackerSummarySchema, trackerOutcomePageSchema, trackerTriggerOutcomePageSchema, trackerIngestResultSchema, trackerOutcomeSchema, trackerPreviewSchema } from './schema.js';
21
23
  export { bL as TrackerDataBudget, bM as schemaCheckedReader, E as sourceContent, bN as trackerDataBatchSteps, bO as trackerDataIssue, bP as trackerDataIssues, bQ as trackerDataPathTypes, bR as trackerDataRecordSteps, bS as walletProgramAccounts, bT as whereSchemaIssue, F as whereSettings } from './tracker-data-Dwq9dWEm.js';
22
24
  export { H as HostEnvironment, h as hostEnvironmentPath, a as hostEnvironmentSchema } from './host-environment-DUw5-Cvj.js';
23
- export { k as compatibleSettingKinds, l as dashboardIssue, m as isBoundSetting, n as normalizeDashboard } from './capability-error-Bn6cCqof.js';
25
+ export { k as compatibleSettingKinds, l as dashboardIssue, m as isBoundSetting, n as normalizeDashboard } from './capability-error-D56xxE2i.js';
24
26
  import * as z from 'zod';
25
- import { TelegramChatMemberStatus } from './authoring.js';
26
27
  import { EvaluationContext, MemberCompletionQuery } from './authoring.js';
27
28
  export { m as walletBalances, n as walletNfts, o as walletProgramActivity, p as walletStake } from './stake-BSVjB3BJ.js';
28
29
  import * as zod_v4_core from 'zod/v4/core';
@@ -32,8 +33,8 @@ import { contentQualificationPageSchema, MemberConsentHistory, rewardDeliveriesS
32
33
  import { deploymentPreviewSchema, deploymentHistoryPageSchema, deploymentRecordSchema, deploymentResultSchema } from './schema.js';
33
34
  import { collectionPreviewSchema } from './schema.js';
34
35
  import { offerSchema, redemptionPageSchema, redemptionSchema } from './schema.js';
35
- import './action-BDFKqGlH.js';
36
36
  import './profiles-CLDKZVFx.js';
37
+ import './action-BDFKqGlH.js';
37
38
  import './catalog-9I6t18qP.js';
38
39
  import './streaks-MAqKHbHC.js';
39
40
  import './units-CwgsPB_r.js';
@@ -15002,6 +15003,7 @@ declare const secretEndpoints: {
15002
15003
  name: z.ZodString;
15003
15004
  updatedAt: z.ZodNumber;
15004
15005
  updatedBy: z.ZodString;
15006
+ credential: z.ZodOptional<z.ZodType<AppSecretCredential, unknown, z.core.$ZodTypeInternals<AppSecretCredential, unknown>>>;
15005
15007
  }, z.core.$strip>>;
15006
15008
  declared: z.ZodDefault<z.ZodArray<z.ZodObject<{
15007
15009
  description: z.ZodString;
@@ -15015,6 +15017,7 @@ declare const secretEndpoints: {
15015
15017
  name: z.ZodString;
15016
15018
  updatedAt: z.ZodNumber;
15017
15019
  updatedBy: z.ZodString;
15020
+ credential: z.ZodOptional<z.ZodType<AppSecretCredential, unknown, z.core.$ZodTypeInternals<AppSecretCredential, unknown>>>;
15018
15021
  }, z.core.$strip>, "PUT"> & {
15019
15022
  readonly ledger: null;
15020
15023
  };
@@ -15054,6 +15057,8 @@ declare const storageEndpoints: {
15054
15057
  offset: z.ZodNumber;
15055
15058
  total: z.ZodNumber;
15056
15059
  nextCursor: z.ZodDefault<z.ZodNullable<z.ZodString>>;
15060
+ keyColumns: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodString>>>;
15061
+ rowKeys: z.ZodOptional<z.ZodNullable<z.ZodArray<z.ZodNullable<z.ZodString>>>>;
15057
15062
  }, z.core.$strip>, "GET"> & {
15058
15063
  readonly ledger: null;
15059
15064
  };
@@ -15072,6 +15077,7 @@ declare const storageEndpoints: {
15072
15077
  offset: z.ZodNumber;
15073
15078
  text: z.ZodNullable<z.ZodString>;
15074
15079
  nextCursor: z.ZodDefault<z.ZodNullable<z.ZodString>>;
15080
+ revision: z.ZodOptional<z.ZodNullable<z.ZodString>>;
15075
15081
  }, z.core.$strip>, "GET"> & {
15076
15082
  readonly ledger: null;
15077
15083
  };
@@ -15093,6 +15099,16 @@ declare const storageEndpoints: {
15093
15099
  }, z.core.$strip>, "GET"> & {
15094
15100
  readonly ledger: null;
15095
15101
  };
15102
+ bytes: ManagementEndpoint<"/storage/kv/{name}/bytes", () => z.ZodObject<{
15103
+ key: z.ZodString;
15104
+ size: z.ZodNumber;
15105
+ offset: z.ZodNumber;
15106
+ base64: z.ZodString;
15107
+ revision: z.ZodString;
15108
+ nextCursor: z.ZodDefault<z.ZodNullable<z.ZodString>>;
15109
+ }, z.core.$strip>, "GET"> & {
15110
+ readonly ledger: null;
15111
+ };
15096
15112
  clear: ManagementEndpoint<"/storage/{kind}/{name}/clear", () => z.ZodDiscriminatedUnion<[z.ZodObject<{
15097
15113
  environment: z.ZodString;
15098
15114
  kind: z.ZodLiteral<"sql">;
@@ -15213,6 +15229,7 @@ declare const scheduleEndpoints: {
15213
15229
  }, z.core.$strip>>>;
15214
15230
  }, z.core.$strip>>>;
15215
15231
  }, z.core.$strip>>;
15232
+ nextCursor: z.ZodOptional<z.ZodNullable<z.ZodString>>;
15216
15233
  }, z.core.$strip>, "GET"> & {
15217
15234
  readonly ledger: null;
15218
15235
  };
@@ -15425,6 +15442,12 @@ declare const buildEndpoints: {
15425
15442
  readonly ledger: null;
15426
15443
  };
15427
15444
  };
15445
+ /** @experimental */
15446
+ declare const runtimeLogEndpoints: {
15447
+ list: ManagementEndpoint<"/runtime-logs", () => z.ZodUnknown, "GET"> & {
15448
+ readonly ledger: null;
15449
+ };
15450
+ };
15428
15451
  declare const stagingEndpoints: {
15429
15452
  access: ManagementEndpoint<"/staging/access", () => z.ZodUnknown, "GET"> & {
15430
15453
  readonly ledger: null;
@@ -15986,6 +16009,16 @@ declare const leaderboardEndpoints: {
15986
16009
  } & {
15987
16010
  readonly bodyLimit?: undefined;
15988
16011
  };
16012
+ memberStanding: ManagementEndpoint<"/leaderboards/{leaderboard}/members/{member}", () => typeof leaderboardMemberStandingSchema, "GET"> & {
16013
+ readonly ledger: "leaderboards.memberStanding";
16014
+ } & {
16015
+ readonly bodyLimit?: undefined;
16016
+ };
16017
+ memberEntries: ManagementEndpoint<"/leaderboards/{leaderboard}/members/{member}/entries", () => typeof leaderboardHistoryPageSchema, "GET"> & {
16018
+ readonly ledger: "leaderboards.memberEntries";
16019
+ } & {
16020
+ readonly bodyLimit?: undefined;
16021
+ };
15989
16022
  history: ManagementEndpoint<"/leaderboards/{leaderboard}/history", () => z.ZodArray<z.ZodObject<{
15990
16023
  archivedAt: z.ZodOptional<z.ZodNullable<z.ZodNumber>>;
15991
16024
  version: z.ZodString;
@@ -28582,6 +28615,7 @@ declare const projectEndpoints: {
28582
28615
  live: "live";
28583
28616
  }>>;
28584
28617
  }, z.core.$strip>>;
28618
+ expiresAt: z.ZodOptional<z.ZodNumber>;
28585
28619
  credential: z.ZodOptional<z.ZodObject<{
28586
28620
  kind: z.ZodString;
28587
28621
  id: z.ZodString;
@@ -31915,17 +31949,7 @@ declare const referralEndpoints: {
31915
31949
  } & {
31916
31950
  readonly bodyLimit?: undefined;
31917
31951
  };
31918
- history: ManagementEndpoint<"/referrals/history/{member}", () => z.ZodObject<{
31919
- items: z.ZodArray<z.ZodObject<{
31920
- id: z.ZodNumber;
31921
- program: z.ZodString;
31922
- balance: z.ZodString;
31923
- amount: z.ZodNumber;
31924
- at: z.ZodNumber;
31925
- reason: z.ZodString;
31926
- }, z.core.$strip>>;
31927
- nextCursor: z.ZodNullable<z.ZodString>;
31928
- }, z.core.$strip>, "GET"> & {
31952
+ history: ManagementEndpoint<"/referrals/history/{member}", () => typeof managedReferralHistorySchema, "GET"> & {
31929
31953
  readonly ledger: "referrals.memberHistory";
31930
31954
  } & {
31931
31955
  readonly bodyLimit?: undefined;
@@ -36426,5 +36450,5 @@ declare function routeNames(route: {
36426
36450
  */
36427
36451
  declare const declaredManagementEndpoints: () => ManagementEndpoint[];
36428
36452
 
36429
- export { Extracted, MANAGEMENT_TIMEOUT, ManagementEndpoint, WRITTEN_PARAMETER, analyticsEndpoints, anchorIdlAccountBytes, anchorIdlAddress, attemptEndpoints, auditEndpoints, automationKeyEndpoints, badgeEndpoints, bareOrigin, base58, billingEndpoints, buildEndpoints, calendarEndpoints, campaignEndpoints, canonicalWalletAddress, capabilityRequestSchemas, catalogEndpoints, checkedInteger, completionEndpoints, confirmedSignature, connectSolanaAccount, connectionEndpoints, contentEndpoints, csvLines, dashboardEndpoints, declaredManagementEndpoints, deploymentEndpoints, developmentEndpoints, domainEndpoints, engagementEndpoints, entitlementEndpoints, evaluatorReaderFactories, galleryEndpoints, grantEndpoints, groupEndpoints, identityIntegrationEndpoints, idlTooLarge, imageEndpoints, inWindow, integrationEndpoints, inventoryEndpoints, leaderboardEndpoints, lifetime, littleEndianBytes, liveAppEndpoints, loopbackHosts, maxAnchorIdlBytes, memberEndpoints, memberImportEndpoints, metricsEndpoints, offerEndpoints, operationEndpoints, pageEndpoints, parseSolanaSeeds, parseStationCodeLink, participantEndpoints, playgroundEndpoints, pluginEndpoints, pointEndpoints, pointLedgerEndpoints, profileEndpoints, programMetadataIdlAddress, programMetadataIdlBytes, programMetadataProgram, projectEndpoints, promotionEndpoints, providerEndpoints, questEndpoints, referralEndpoints, registeredWallets, releaseEndpoints, repositoryEndpoints, resourceArchiveEndpoints, resourceEndpoints, retryAfter, retrying, rewardDeliveryEndpoints, routeNames, routePath, scheduleEndpoints, secretEndpoints, secureOrLoopbackOrigin, serviceKeyEndpoints, sessionEndpoints, simulationEndpoints, solanaAddressBytes, solanaProgramAddress, solanaPublicEndpoints, solanaRpc, solanaSeedBytes, stagingEndpoints, stationCodeLink, stationPayLink, stationQrSvg, storageEndpoints, storedIdlJson, teamEndpoints, testMemberEndpoints, tieredRewardEndpoints, tokenEndpoints, trackerEndpoints, usageEndpoints, walletSignatureValid, webhookEndpoints, withoutPatterns, zeroCopyAccount };
36453
+ export { Extracted, MANAGEMENT_TIMEOUT, ManagementEndpoint, WRITTEN_PARAMETER, analyticsEndpoints, anchorIdlAccountBytes, anchorIdlAddress, attemptEndpoints, auditEndpoints, automationKeyEndpoints, badgeEndpoints, bareOrigin, base58, billingEndpoints, buildEndpoints, calendarEndpoints, campaignEndpoints, canonicalWalletAddress, capabilityRequestSchemas, catalogEndpoints, checkedInteger, completionEndpoints, confirmedSignature, connectSolanaAccount, connectionEndpoints, contentEndpoints, csvLines, dashboardEndpoints, declaredManagementEndpoints, deploymentEndpoints, developmentEndpoints, domainEndpoints, engagementEndpoints, entitlementEndpoints, evaluatorReaderFactories, galleryEndpoints, grantEndpoints, groupEndpoints, identityIntegrationEndpoints, idlTooLarge, imageEndpoints, inWindow, integrationEndpoints, inventoryEndpoints, leaderboardEndpoints, lifetime, littleEndianBytes, liveAppEndpoints, loopbackHosts, maxAnchorIdlBytes, memberEndpoints, memberImportEndpoints, metricsEndpoints, offerEndpoints, operationEndpoints, pageEndpoints, parseSolanaSeeds, parseStationCodeLink, participantEndpoints, playgroundEndpoints, pluginEndpoints, pointEndpoints, pointLedgerEndpoints, profileEndpoints, programMetadataIdlAddress, programMetadataIdlBytes, programMetadataProgram, projectEndpoints, promotionEndpoints, providerEndpoints, questEndpoints, referralEndpoints, registeredWallets, releaseEndpoints, repositoryEndpoints, resourceArchiveEndpoints, resourceEndpoints, retryAfter, retrying, rewardDeliveryEndpoints, routeNames, routePath, runtimeLogEndpoints, scheduleEndpoints, secretEndpoints, secureOrLoopbackOrigin, serviceKeyEndpoints, sessionEndpoints, simulationEndpoints, solanaAddressBytes, solanaProgramAddress, solanaPublicEndpoints, solanaRpc, solanaSeedBytes, stagingEndpoints, stationCodeLink, stationPayLink, stationQrSvg, storageEndpoints, storedIdlJson, teamEndpoints, testMemberEndpoints, tieredRewardEndpoints, tokenEndpoints, trackerEndpoints, usageEndpoints, walletSignatureValid, webhookEndpoints, withoutPatterns, zeroCopyAccount };
36430
36454
  export type { AttemptFailure, IdlCompression, IdlDecompressors, Lifetime, ReaderCall, StationCodeCheckIn, WrittenRoute };
package/dist/internal.js CHANGED
@@ -61,6 +61,7 @@ import {
61
61
  resourceArchiveEndpoints,
62
62
  resourceEndpoints,
63
63
  rewardDeliveryEndpoints,
64
+ runtimeLogEndpoints,
64
65
  scheduleEndpoints,
65
66
  secretEndpoints,
66
67
  sequenceCursorSchema,
@@ -77,22 +78,22 @@ import {
77
78
  usageEndpoints,
78
79
  walletSignatureValid,
79
80
  webhookEndpoints
80
- } from "./chunk-JZT2NLSG.js";
81
+ } from "./chunk-LFFGW7GB.js";
81
82
  import {
82
83
  capabilityRequestSchemas,
83
84
  evaluatorReaderFactories
84
- } from "./chunk-NI6XRGEL.js";
85
+ } from "./chunk-SPLXHFVX.js";
85
86
  import {
86
87
  parseImageExtraction,
87
88
  parseImageResult
88
- } from "./chunk-SVZ3QWHT.js";
89
- import "./chunk-2LURSPDM.js";
89
+ } from "./chunk-FBS65R66.js";
90
+ import "./chunk-4WODSE6Y.js";
90
91
  import {
91
92
  QuestShapeError,
92
93
  sourceDataSchema,
93
94
  sourceRoles,
94
95
  validateQuestShape
95
- } from "./chunk-ELHMJODS.js";
96
+ } from "./chunk-7B7MDHJ6.js";
96
97
  import {
97
98
  accountVouchedBySchema,
98
99
  appLoginOriginSchema,
@@ -112,21 +113,21 @@ import {
112
113
  participantExchangeResultSchema,
113
114
  participantExchangeSchema,
114
115
  secureOrLoopbackOrigin
115
- } from "./chunk-7I7P5UVC.js";
116
+ } from "./chunk-ZXFRHGZC.js";
116
117
  import {
117
118
  isIntegrationParticipantPath,
118
119
  isParticipantRoute,
119
120
  participantRoutePattern,
120
121
  participantRoutes
121
122
  } from "./chunk-PYZSCFMJ.js";
122
- import "./chunk-TGQNNMCY.js";
123
+ import "./chunk-IMX45NSW.js";
123
124
  import {
124
125
  imageUploadsSchema
125
- } from "./chunk-RALBAKKX.js";
126
+ } from "./chunk-K3PEQXDV.js";
126
127
  import {
127
128
  dashboardIssue,
128
129
  normalizeDashboard
129
- } from "./chunk-T4PTFCSB.js";
130
+ } from "./chunk-XEXB3WZE.js";
130
131
  import "./chunk-MWMCQLCG.js";
131
132
  import {
132
133
  connectSolanaAccount,
@@ -138,16 +139,16 @@ import {
138
139
  stationPayLink,
139
140
  stationQrSvg
140
141
  } from "./chunk-MDSSIOBC.js";
141
- import "./chunk-F66GGNKD.js";
142
+ import "./chunk-4YKOSNYI.js";
142
143
  import {
143
144
  MANAGEMENT_TIMEOUT,
144
145
  lifetime,
145
146
  retryAfter,
146
147
  retrying
147
- } from "./chunk-HCOLMJFX.js";
148
- import "./chunk-KP55TMCC.js";
149
- import "./chunk-CW7FJ5PX.js";
150
- import "./chunk-KGZ7SRKJ.js";
148
+ } from "./chunk-X5REDFGV.js";
149
+ import "./chunk-HEQ7HLXG.js";
150
+ import "./chunk-3KHVIUKK.js";
151
+ import "./chunk-TAZ5AEYF.js";
151
152
  import {
152
153
  base58,
153
154
  base58Bytes,
@@ -156,6 +157,7 @@ import {
156
157
  inWindow,
157
158
  isBoundSetting,
158
159
  limits,
160
+ photoEvidenceByteLimit,
159
161
  schemaCheckedReader,
160
162
  sourceContent,
161
163
  stationRefusal,
@@ -171,7 +173,7 @@ import {
171
173
  walletStake,
172
174
  whereSchemaIssue,
173
175
  whereSettings
174
- } from "./chunk-6TDHRGBM.js";
176
+ } from "./chunk-7QHROIML.js";
175
177
  import "./chunk-2M5FM7FW.js";
176
178
 
177
179
  // src/solana-idl-accounts.ts
@@ -326,8 +328,10 @@ function anchorIdlAccountBytes(data) {
326
328
  return length === 0 || 44 + length > data.length ? null : data.subarray(44, 44 + length);
327
329
  }
328
330
  var programMetadataProgram = "ProgM6JCCvbYkfKqJYHePx4xxSUSqJp7rh8Lyv7nk7S";
329
- var idlSeed = /* @__PURE__ */ (() => new Uint8Array(16))();
330
- idlSeed.set(encoder.encode("idl"));
331
+ var idlSeed = /* @__PURE__ */ (() => Uint8Array.from(
332
+ { length: 16 },
333
+ (_, index) => index < 3 ? "idl".charCodeAt(index) : 0
334
+ ))();
331
335
  var metadataHeaderLength = 96;
332
336
  var metadataDiscriminator = 2;
333
337
  var metadataCompressions = ["none", "gzip", "zlib"];
@@ -678,6 +682,7 @@ var declaredManagementEndpoints = () => [
678
682
  ...Object.values(repositoryEndpoints),
679
683
  ...Object.values(resourceEndpoints),
680
684
  ...Object.values(rewardDeliveryEndpoints),
685
+ ...Object.values(runtimeLogEndpoints),
681
686
  ...Object.values(scheduleEndpoints),
682
687
  ...Object.values(secretEndpoints),
683
688
  ...Object.values(serviceKeyEndpoints),
@@ -790,6 +795,7 @@ export {
790
795
  participantExchangeSchema,
791
796
  participantRoutePattern,
792
797
  participantRoutes,
798
+ photoEvidenceByteLimit,
793
799
  playgroundEndpoints,
794
800
  pluginEndpoints,
795
801
  pointEndpoints,
@@ -814,6 +820,7 @@ export {
814
820
  rewardDeliveryEndpoints,
815
821
  routeNames,
816
822
  routePath,
823
+ runtimeLogEndpoints,
817
824
  scheduleEndpoints,
818
825
  schemaCheckedReader,
819
826
  secretEndpoints,
@@ -893,6 +893,12 @@ type Limits = {
893
893
  readonly storagePreviewCharacters: number;
894
894
  /** Characters a full SQL value read returns per page. */
895
895
  readonly storageCellCharacters: number;
896
+ /**
897
+ * Bytes a full KV value read returns per page. Cloudflare's KV API reads a value only whole, so
898
+ * each page reads all of it (up to 25 MiB): 4 MiB pages take a value in at most 7 reads, and
899
+ * keep each answer (base64, about 5.6 MB) well inside what the builder and backend relay.
900
+ */
901
+ readonly storageValueBytes: number;
896
902
  /**
897
903
  * KV keys one test storage clear deletes before answering `complete: false`: one Cloudflare
898
904
  * bulk delete, which takes at most 10,000 keys.
@@ -1,8 +1,8 @@
1
1
  import { ParticipantExchangeAccountResult, ParticipantExchangeResult, IdentityIntegrationKey } from './internal.js';
2
2
  import { MemberImportVouchedAccount } from './server/index.js';
3
3
  import { RequestError } from './index.js';
4
- import './tracker-data-Dwq9dWEm.js';
5
4
  import 'zod';
5
+ import './tracker-data-Dwq9dWEm.js';
6
6
  import './wallet-CeqgtXNm.js';
7
7
 
8
8
  /**
@@ -86,6 +86,13 @@ declare function inspectIntegrationKey(options: {
86
86
  * `onExchangeError` receives each refused exchange as Domino answered it (status, code, message and
87
87
  * `retryAfter`) before the browser gets its answer, so the server can log why sign-in failed. The
88
88
  * browser's answer does not change, and a callback that throws does not change it either.
89
+ * `authenticate` runs on every request. The exchange does not: a request reuses the session this
90
+ * backend exchanged for the same user when the browser presents that session's cookie, the session
91
+ * has more than 5 minutes left, and `authenticate` returned no `accounts`. Any other request
92
+ * exchanges, so a request that vouches accounts always does, and `onAccounts` and `onExchangeError`
93
+ * run for it. Logging out forgets the session; when Relay refuses a reused session, a GET or HEAD
94
+ * exchanges once and is sent again, and other methods get Relay's 401. The reused sessions live in
95
+ * this backend's memory, up to 10,000 of them, least recently used dropped first.
89
96
  * The browser does not see the app's own sign-in or logout: under `RelayProvider`, call
90
97
  * `useSession().refresh()` after each.
91
98
  */
@@ -3,25 +3,25 @@ import {
3
3
  participantExchangeAccountsSchema,
4
4
  participantExchangeResultSchema,
5
5
  secureOrLoopbackOrigin
6
- } from "./chunk-7I7P5UVC.js";
6
+ } from "./chunk-ZXFRHGZC.js";
7
7
  import {
8
8
  isParticipantRoute
9
9
  } from "./chunk-PYZSCFMJ.js";
10
- import "./chunk-TGQNNMCY.js";
11
- import "./chunk-RALBAKKX.js";
12
- import "./chunk-T4PTFCSB.js";
10
+ import "./chunk-IMX45NSW.js";
11
+ import "./chunk-K3PEQXDV.js";
12
+ import "./chunk-XEXB3WZE.js";
13
13
  import "./chunk-MWMCQLCG.js";
14
14
  import {
15
15
  clientIdentity,
16
16
  retryAfter
17
- } from "./chunk-HCOLMJFX.js";
18
- import "./chunk-KP55TMCC.js";
17
+ } from "./chunk-X5REDFGV.js";
18
+ import "./chunk-HEQ7HLXG.js";
19
19
  import {
20
20
  participantPrincipalSchema,
21
21
  sessionMember
22
- } from "./chunk-CW7FJ5PX.js";
23
- import "./chunk-KGZ7SRKJ.js";
24
- import "./chunk-6TDHRGBM.js";
22
+ } from "./chunk-3KHVIUKK.js";
23
+ import "./chunk-TAZ5AEYF.js";
24
+ import "./chunk-7QHROIML.js";
25
25
  import {
26
26
  RequestError,
27
27
  isRequestError
@@ -97,6 +97,8 @@ async function proxyParticipant(request, upstream) {
97
97
  });
98
98
  const resultHeaders = new Headers(response.headers);
99
99
  resultHeaders.set("Cache-Control", "no-store");
100
+ resultHeaders.delete("Content-Encoding");
101
+ resultHeaders.delete("Content-Length");
100
102
  return new Response(response.body, {
101
103
  status: response.status,
102
104
  headers: resultHeaders
@@ -209,6 +211,7 @@ function createParticipantBackend(options) {
209
211
  // WebKit drops a Secure cookie on http://localhost, so a loopback origin sets it without.
210
212
  `domino_app_session=${token}; Path=/relay; HttpOnly;${loopback ? "" : " Secure;"} SameSite=Lax; Max-Age=${token ? 28800 : 0}`
211
213
  );
214
+ const sessions = exchangedSessions();
212
215
  return async (request) => {
213
216
  const url = new URL(request.url);
214
217
  const reject = (error, status, code) => Response.json(
@@ -235,68 +238,140 @@ function createParticipantBackend(options) {
235
238
  );
236
239
  }
237
240
  const previousToken = onlyCookie(request.headers.get("Cookie"), "domino_app_session") ?? void 0;
238
- const exchanged = await requestExchange(options, {
239
- subject: identity.subject,
240
- previousToken,
241
- accounts: identity.accounts
242
- });
243
- if (!exchanged.ok) {
244
- const body = await exchanged.json().catch(() => null);
245
- const failure = refusalError(exchanged, body, "Domino identity exchange");
246
- const { code } = failure;
247
- const wait = exchanged.headers.get("Retry-After");
248
- if (options.onExchangeError) {
249
- try {
250
- await options.onExchangeError(failure, request);
251
- } catch {
252
- }
253
- }
254
- return Response.json(
255
- {
256
- error: (exchanged.status === 409 || code === "ACCOUNT_VOUCHING_OFF") && typeof body?.error === "string" ? body.error : exchanged.status === 409 ? "Domino refused this account. Ask an organizer." : "Domino identity exchange failed. Check the server integration key and its expiry in Console Settings.",
257
- code
258
- },
259
- {
260
- status: exchanged.status,
261
- headers: {
262
- "Set-Cookie": cookie(""),
263
- "Cache-Control": "no-store",
264
- ...wait ? { "Retry-After": wait } : {}
241
+ const cached = identity.accounts?.length ? null : sessions.reuse(identity.subject, previousToken);
242
+ const exchange = async () => {
243
+ const exchanged = await requestExchange(options, {
244
+ subject: identity.subject,
245
+ previousToken,
246
+ accounts: identity.accounts
247
+ });
248
+ if (!exchanged.ok) {
249
+ const body = await exchanged.json().catch(() => null);
250
+ const failure = refusalError(
251
+ exchanged,
252
+ body,
253
+ "Domino identity exchange"
254
+ );
255
+ const { code } = failure;
256
+ const wait = exchanged.headers.get("Retry-After");
257
+ if (options.onExchangeError) {
258
+ try {
259
+ await options.onExchangeError(failure, request);
260
+ } catch {
265
261
  }
266
262
  }
263
+ return Response.json(
264
+ {
265
+ error: (exchanged.status === 409 || code === "ACCOUNT_VOUCHING_OFF") && typeof body?.error === "string" ? body.error : exchanged.status === 409 ? "Domino refused this account. Ask an organizer." : "Domino identity exchange failed. Check the server integration key and its expiry in Console Settings.",
266
+ code
267
+ },
268
+ {
269
+ status: exchanged.status,
270
+ headers: {
271
+ "Set-Cookie": cookie(""),
272
+ "Cache-Control": "no-store",
273
+ ...wait ? { "Retry-After": wait } : {}
274
+ }
275
+ }
276
+ );
277
+ }
278
+ const { token: token2, session, accounts } = participantExchangeResultSchema.parse(await exchanged.json());
279
+ sessions.remember(
280
+ identity.subject,
281
+ previousToken,
282
+ token2,
283
+ session.expiresAt
267
284
  );
268
- }
269
- const { token, accounts } = participantExchangeResultSchema.parse(
270
- await exchanged.json()
271
- );
272
- if (accounts?.length && options.onAccounts) {
273
- await options.onAccounts(accounts, request);
274
- }
275
- const response = await proxyParticipant(request, {
285
+ if (accounts?.length && options.onAccounts) {
286
+ await options.onAccounts(accounts, request);
287
+ }
288
+ return token2;
289
+ };
290
+ const forward = (token2) => proxyParticipant(request, {
276
291
  baseUrl: options.baseUrl,
277
292
  // The integration key selects the scope; an app origin would ask for the staging pass.
278
293
  hosted: false,
279
294
  fetch: async (target, init) => {
280
295
  const headers2 = new Headers(init?.headers);
281
296
  headers2.delete("Cookie");
282
- const returnBinding = oauthReturnBinding(request.headers.get("Cookie"));
297
+ const returnBinding = oauthReturnBinding(
298
+ request.headers.get("Cookie")
299
+ );
283
300
  if (returnBinding) {
284
301
  headers2.set("Cookie", returnBinding);
285
302
  }
286
- headers2.set("Authorization", "Bearer " + token);
303
+ headers2.set("Authorization", "Bearer " + token2);
287
304
  headers2.set("X-Relay-Integration-Key", options.integrationKey);
288
305
  headers2.set("Origin", options.origin);
289
306
  return send(target, { ...init, headers: headers2, redirect: "manual" });
290
307
  }
291
308
  });
309
+ let token = cached ?? await exchange();
310
+ if (typeof token !== "string") {
311
+ return token;
312
+ }
313
+ let response = await forward(token);
314
+ if (cached !== null && response.status === 401) {
315
+ sessions.forget(identity.subject, cached);
316
+ if (request.method === "GET" || request.method === "HEAD") {
317
+ await response.body?.cancel();
318
+ token = await exchange();
319
+ if (typeof token !== "string") {
320
+ return token;
321
+ }
322
+ response = await forward(token);
323
+ }
324
+ }
325
+ const loggedOut = url.pathname === "/relay/v1/auth/logout";
326
+ if (loggedOut) {
327
+ sessions.forget(identity.subject, token);
328
+ }
292
329
  const headers = new Headers(response.headers);
293
- headers.append(
294
- "Set-Cookie",
295
- cookie(url.pathname === "/relay/v1/auth/logout" ? "" : token)
296
- );
330
+ headers.append("Set-Cookie", cookie(loggedOut ? "" : token));
297
331
  return new Response(response.body, { status: response.status, headers });
298
332
  };
299
333
  }
334
+ var reuseMarginMs = 5 * 6e4;
335
+ var reusedSessionLimit = 1e4;
336
+ function exchangedSessions() {
337
+ const entries = /* @__PURE__ */ new Map();
338
+ const key = (subject, token) => JSON.stringify([subject, token]);
339
+ return {
340
+ /** The browser's token, when this proxy exchanged it for `subject` and it is not near expiry. */
341
+ reuse(subject, token) {
342
+ if (!token) {
343
+ return null;
344
+ }
345
+ const found = key(subject, token);
346
+ const expiresAt = entries.get(found);
347
+ if (expiresAt === void 0) {
348
+ return null;
349
+ }
350
+ entries.delete(found);
351
+ if (expiresAt - Date.now() <= reuseMarginMs) {
352
+ return null;
353
+ }
354
+ entries.set(found, expiresAt);
355
+ return token;
356
+ },
357
+ remember(subject, previousToken, token, expiresAt) {
358
+ if (previousToken && previousToken !== token) {
359
+ entries.delete(key(subject, previousToken));
360
+ }
361
+ entries.delete(key(subject, token));
362
+ entries.set(key(subject, token), expiresAt);
363
+ for (const oldest of entries.keys()) {
364
+ if (entries.size <= reusedSessionLimit) {
365
+ break;
366
+ }
367
+ entries.delete(oldest);
368
+ }
369
+ },
370
+ forget(subject, token) {
371
+ entries.delete(key(subject, token));
372
+ }
373
+ };
374
+ }
300
375
  function onlyCookie(header, name) {
301
376
  const values = (header ?? "").split(";").map((value) => value.trim()).filter((value) => value.startsWith(name + "="));
302
377
  return values.length === 1 ? values[0].slice(name.length + 1) : null;