glitch-javascript-sdk 4.0.0 → 4.0.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.
@@ -140,6 +140,17 @@ export interface MicrotransactionProduct extends Omit<MicrotransactionProductInp
140
140
  created_at: string;
141
141
  updated_at: string;
142
142
  }
143
+ /** Read-only collection facts, not tax exemption or a determination of tax owed. */
144
+ export interface MicrotransactionTaxCollection {
145
+ /** Configured intent stays automatic during a known pending-setup fallback. */
146
+ requested_mode: 'automatic' | 'disabled';
147
+ /** Pending setup may disable collection for a NEW order; unknown facts are null and block new automatic checkout. */
148
+ effective_mode: 'automatic' | 'disabled' | null;
149
+ status: string;
150
+ missing_fields: string[];
151
+ fallback_reason: 'stripe_tax_setup_incomplete' | null;
152
+ warnings: string[];
153
+ }
143
154
  export interface MicrotransactionProvider {
144
155
  provider: MicrotransactionProviderName;
145
156
  environment: MicrotransactionEnvironment;
@@ -160,6 +171,7 @@ export interface MicrotransactionProvider {
160
171
  charges_enabled: boolean;
161
172
  payouts_enabled: boolean;
162
173
  requirements_due: string[];
174
+ merchant_name?: string | null;
163
175
  } | null;
164
176
  /** The game's payout target. Do not substitute the platform processing account's payouts_enabled. */
165
177
  payout_account: {
@@ -176,6 +188,10 @@ export interface MicrotransactionProvider {
176
188
  status: string;
177
189
  missing_fields: string[];
178
190
  };
191
+ /** Current route facts only. Never use these to reinterpret an existing order's frozen decision. */
192
+ tax_collection?: MicrotransactionTaxCollection | null;
193
+ /** Non-blocking collection warnings, separate from reasons and payout_account availability. */
194
+ warnings?: string[];
179
195
  reasons: string[];
180
196
  checked_at: string | null;
181
197
  revision?: number;
@@ -187,6 +203,7 @@ export interface MicrotransactionProviderSku {
187
203
  amount_minor: number;
188
204
  }
189
205
  export interface MicrotransactionProviderConfiguration {
206
+ /** Requested configuration. Explicit disabled is sandbox-only; pending-setup fallback does not change live configuration to disabled. */
190
207
  tax_mode: 'automatic' | 'disabled';
191
208
  /** Stripe tax code txcd_ followed by exactly eight digits. */
192
209
  tax_code: string | null;
@@ -287,7 +304,12 @@ export interface MicrotransactionRefundInput extends MicrotransactionLegacyConfi
287
304
  }
288
305
  export interface MicrotransactionReadiness {
289
306
  status: 'disabled' | 'draft' | 'sandbox' | 'ready' | 'live' | 'degraded' | 'suspended';
307
+ /** Configuration readiness only; not proof of payment, delivery, claim or browser 3DS. */
290
308
  ready: boolean;
309
+ /** Optional on older backends; retains the same configuration meaning as ready. */
310
+ configuration_ready?: boolean;
311
+ /** Stored sandbox paid + fulfilled + claimed evidence. Absent means unknown; not browser/3DS certification. */
312
+ integration_verified?: boolean;
291
313
  blockers: string[];
292
314
  providers: MicrotransactionProvider[];
293
315
  commission_basis_points: 1200;
@@ -388,6 +410,8 @@ export interface MicrotransactionOrder {
388
410
  paid_at: string | null;
389
411
  refunded_minor: number;
390
412
  items: MicrotransactionGrant[];
413
+ /** Frozen decision, also returned inside checkout/session.order. Null/absent for legacy orders; never infer from current provider facts. Warnings do not imply zero tax owed. */
414
+ tax_collection?: MicrotransactionTaxCollection | null;
391
415
  entitlements?: MicrotransactionEntitlement[];
392
416
  }
393
417
  export interface MicrotransactionOrderDetail extends MicrotransactionOrder {
@@ -593,8 +617,9 @@ export interface MicrotransactionCapabilities {
593
617
  [key: string]: unknown;
594
618
  }
595
619
  /**
596
- * Provider-neutral, title-scoped commerce. Configure with user JWT; purchases
597
- * use a recoverable user account and limited checkout capability. Install/title
620
+ * Provider-neutral, title-scoped commerce. Guest games configure only the API
621
+ * base URL, never global account/admin auth. Hosted account pages use their own
622
+ * user JWT and limited checkout capability; playerToken overrides auth per request. Install/title
598
623
  * tokens cannot authorize money, ownership, refunds, or catalog changes.
599
624
  *
600
625
  * Each result preserves payment versus fulfillment versus settlement. Redirects
@@ -686,13 +711,13 @@ declare class Microtransactions {
686
711
  static refundOrder(title_id: string, order_id: string, data: MicrotransactionRefundInput, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionRefund>>;
687
712
  /** Replay the same immutable event. Receiver must deduplicate event_id. This cannot mint goods. */
688
713
  static replayDelivery(title_id: string, delivery_id: string, data?: MicrotransactionLegacyConfirmation, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionDeliveryResult>>;
689
- /** Public eligible catalog. Sandbox is restricted by backend environment/admin policy. */
714
+ /** Guest catalog on the exact approved game Origin. Sandbox requires enabled sandbox settings; the backend enforces environment policy. */
690
715
  static catalog(title_id: string, params?: MicrotransactionCatalogFilter, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionCatalog>>;
691
716
  /** User-authenticated quote. Clients select product/quantity, never monetary values or seller accounts. */
692
717
  static createQuote(title_id: string, data: MicrotransactionPurchaseInput, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionQuote>>;
693
- /** Anonymous-safe opening step only. The hosted UI creates/logs into an account before payment. */
718
+ /** Guest opening only: browser Origin must equal approved return_origin. Inherits configured global auth; use an isolated credential-free game context. Hosted UI authenticates before payment. */
694
719
  static createCheckoutSession(title_id: string, data: MicrotransactionCheckoutSessionInput, options?: MicrotransactionRequestOptions): AxiosPromise<MicrotransactionResponse<MicrotransactionCreatedCheckoutSession>>;
695
- /** Anonymous-safe inventory recovery. Opens an in-game hosted sign-in overlay, never creates a charge or requires the game's account JWT. */
720
+ /** Guest entry to hosted recovery, not inventory access. Exact approved Origin/return_origin required. Owning-account bind remains mandatory, including when commerce is off. Never install an account JWT in the game. */
696
721
  static createRestoreSession(title_id: string, data: {
697
722
  return_origin: string;
698
723
  nonce: string;
package/dist/esm/index.js CHANGED
@@ -21752,8 +21752,9 @@ MicrotransactionsRoute.routes = {
21752
21752
  };
21753
21753
 
21754
21754
  /**
21755
- * Provider-neutral, title-scoped commerce. Configure with user JWT; purchases
21756
- * use a recoverable user account and limited checkout capability. Install/title
21755
+ * Provider-neutral, title-scoped commerce. Guest games configure only the API
21756
+ * base URL, never global account/admin auth. Hosted account pages use their own
21757
+ * user JWT and limited checkout capability; playerToken overrides auth per request. Install/title
21757
21758
  * tokens cannot authorize money, ownership, refunds, or catalog changes.
21758
21759
  *
21759
21760
  * Each result preserves payment versus fulfillment versus settlement. Redirects
@@ -21833,13 +21834,13 @@ class Microtransactions {
21833
21834
  }
21834
21835
  /** Replay the same immutable event. Receiver must deduplicate event_id. This cannot mint goods. */
21835
21836
  static replayDelivery(title_id, delivery_id, data = {}, options) { return this.call('replayDelivery', title_id, data, { delivery_id }, undefined, options); }
21836
- /** Public eligible catalog. Sandbox is restricted by backend environment/admin policy. */
21837
+ /** Guest catalog on the exact approved game Origin. Sandbox requires enabled sandbox settings; the backend enforces environment policy. */
21837
21838
  static catalog(title_id, params, options) { return this.call('catalog', title_id, undefined, {}, params, options); }
21838
21839
  /** User-authenticated quote. Clients select product/quantity, never monetary values or seller accounts. */
21839
21840
  static createQuote(title_id, data, options) { return this.call('createQuote', title_id, data, {}, undefined, options); }
21840
- /** Anonymous-safe opening step only. The hosted UI creates/logs into an account before payment. */
21841
+ /** Guest opening only: browser Origin must equal approved return_origin. Inherits configured global auth; use an isolated credential-free game context. Hosted UI authenticates before payment. */
21841
21842
  static createCheckoutSession(title_id, data, options) { return this.call('createCheckoutSession', title_id, data, {}, undefined, options); }
21842
- /** Anonymous-safe inventory recovery. Opens an in-game hosted sign-in overlay, never creates a charge or requires the game's account JWT. */
21843
+ /** Guest entry to hosted recovery, not inventory access. Exact approved Origin/return_origin required. Owning-account bind remains mandatory, including when commerce is off. Never install an account JWT in the game. */
21843
21844
  static createRestoreSession(title_id, data, options) { return this.call('createRestoreSession', title_id, data, {}, undefined, options); }
21844
21845
  /** Read the session using its limited capability. Cannot mutate user identity or declare payment. */
21845
21846
  static getCheckoutSession(title_id, session_id, options) { return this.call('checkoutSession', title_id, undefined, { session_id }, undefined, options); }
@@ -22072,6 +22073,8 @@ function openMicrotransactionOverlay(options) {
22072
22073
  if (activeOverlays.has(doc))
22073
22074
  throw new Error('A checkout is already open. Resume or close that same purchase first.');
22074
22075
  const session = options.session;
22076
+ // Older purchase-session creation responses need not include an intent.
22077
+ const restoring = session.intent === 'restore';
22075
22078
  const parsed = new URL(session.hosted_url);
22076
22079
  const path = `/games/${encodeURIComponent(options.titleId)}/checkout/${encodeURIComponent(session.id)}`;
22077
22080
  if (parsed.origin !== options.checkoutOrigin || parsed.pathname !== path || parsed.search || parsed.username || parsed.password ||
@@ -22090,41 +22093,55 @@ function openMicrotransactionOverlay(options) {
22090
22093
  dialog.setAttribute('aria-modal', 'true');
22091
22094
  dialog.setAttribute('aria-labelledby', `${id}-title`);
22092
22095
  dialog.setAttribute('role', 'dialog');
22093
- dialog.style.cssText = 'position:fixed;inset:16px;margin:auto;padding:0;border:1px solid #cbd5e1;border-radius:16px;width:min(1100px,calc(100vw - 32px));height:min(850px,calc(100dvh - 32px));max-width:none;max-height:none;background:#fff;color:#172033;box-shadow:0 24px 90px #0008;z-index:2147483647;overflow:hidden;';
22096
+ dialog.style.cssText = 'position:fixed;inset:0;margin:auto;padding:0;border:1px solid #cbd5e1;border-radius:16px;box-sizing:border-box;display:flex;flex-direction:column;width:min(1100px,calc(100vw - 32px));height:min(850px,calc(100vh - 32px));min-width:0;min-height:0;max-width:none;max-height:none;background:#fff;color:#172033;box-shadow:0 24px 90px #0008;z-index:2147483647;overflow:hidden;';
22094
22097
  const style = doc.createElement('style');
22095
- style.textContent = `#${id}::backdrop{background:rgba(8,16,32,.72)}#${id} button:focus-visible{outline:3px solid #4263eb;outline-offset:3px}@media(max-width:600px){#${id}{inset:0!important;width:100vw!important;height:100dvh!important;border-radius:0!important}}`;
22098
+ style.textContent = `
22099
+ #${id}::backdrop{background:rgba(8,16,32,.72)}
22100
+ #${id} button:focus-visible{outline:3px solid #4263eb;outline-offset:3px}
22101
+ @supports(height:100dvh){#${id}{height:min(850px,calc(100dvh - 32px))!important}}
22102
+ @media(max-width:600px),(max-height:500px){
22103
+ #${id}{width:100%!important;height:100vh!important;border:0!important;border-radius:0!important;padding:env(safe-area-inset-top,0px) env(safe-area-inset-right,0px) env(safe-area-inset-bottom,0px) env(safe-area-inset-left,0px)!important}
22104
+ @supports(height:100dvh){#${id}{height:100dvh!important}}
22105
+ }`;
22106
+ // Natural-height chrome can wrap/scroll without consuming the entire frame.
22107
+ // No fixed header/status subtraction; the iframe owns all remaining space.
22108
+ const chrome = doc.createElement('div');
22109
+ chrome.style.cssText = 'flex:0 1 auto;min-width:0;min-height:0;max-height:50%;overflow:auto;overscroll-behavior:contain;';
22096
22110
  const header = doc.createElement('div');
22097
- header.style.cssText = 'display:flex;align-items:center;justify-content:space-between;gap:16px;padding:12px 16px;border-bottom:1px solid #e2e8f0;height:56px;box-sizing:border-box;';
22111
+ header.style.cssText = 'display:flex;flex-wrap:wrap;align-items:center;justify-content:space-between;gap:8px 16px;padding:12px 16px;border-bottom:1px solid #e2e8f0;box-sizing:border-box;min-width:0;';
22098
22112
  const heading = doc.createElement('h2');
22099
22113
  heading.id = `${id}-title`;
22100
- heading.textContent = options.label || (session.intent === 'restore' ? 'Restore game purchases' : 'Secure game checkout');
22101
- heading.style.cssText = 'margin:0;font:600 17px/1.3 system-ui,sans-serif;color:#172033;';
22114
+ heading.textContent = options.label || (restoring ? 'Restore game purchases' : 'Secure game checkout');
22115
+ heading.style.cssText = 'flex:1 1 10rem;min-width:0;margin:0;font:600 17px/1.3 system-ui,sans-serif;color:#172033;white-space:normal;overflow-wrap:anywhere;';
22102
22116
  const closeButton = doc.createElement('button');
22103
22117
  closeButton.type = 'button';
22104
22118
  closeButton.textContent = 'Close';
22105
- closeButton.setAttribute('aria-label', 'Close checkout and return to game');
22106
- closeButton.style.cssText = 'border:1px solid #cbd5e1;border-radius:8px;padding:7px 14px;background:#fff;color:#172033;font:600 14px system-ui,sans-serif;cursor:pointer;';
22119
+ closeButton.setAttribute('aria-label', restoring ? 'Close restore and return to game' : 'Close checkout and return to game');
22120
+ closeButton.style.cssText = 'box-sizing:border-box;flex:1 1 auto;min-width:44px;min-height:44px;max-width:100%;height:auto;margin:0;border:1px solid #cbd5e1;border-radius:8px;padding:10px 14px;background:#fff;color:#172033;font:600 14px/1.4 system-ui,sans-serif;white-space:normal;overflow-wrap:anywhere;cursor:pointer;';
22107
22121
  const retryButton = doc.createElement('button');
22108
22122
  retryButton.type = 'button';
22109
22123
  retryButton.textContent = 'Retry';
22110
- retryButton.setAttribute('aria-label', 'Reload this same checkout without starting another purchase');
22124
+ retryButton.setAttribute('aria-label', restoring ? 'Reload this same restore session' : 'Reload this same checkout without starting another purchase');
22111
22125
  retryButton.style.cssText = closeButton.style.cssText;
22126
+ closeButton.style.background = '#172033';
22127
+ closeButton.style.color = '#fff';
22112
22128
  const controls = doc.createElement('div');
22113
- controls.style.cssText = 'display:flex;gap:8px;';
22129
+ controls.style.cssText = 'display:flex;flex-wrap:wrap;gap:8px;min-width:0;max-width:100%;margin-left:auto;';
22114
22130
  controls.append(retryButton, closeButton);
22115
22131
  header.append(heading, controls);
22116
22132
  const status = doc.createElement('div');
22117
22133
  status.setAttribute('role', 'status');
22118
- status.style.cssText = 'padding:6px 16px;font:12px/1.4 system-ui,sans-serif;background:#f1f5f9;color:#172033;min-height:28px;box-sizing:border-box;';
22119
- status.textContent = 'Your game stays open. Loading secure checkout…';
22134
+ status.style.cssText = 'padding:6px 16px;font:12px/1.4 system-ui,sans-serif;background:#f1f5f9;color:#172033;box-sizing:border-box;white-space:normal;overflow-wrap:anywhere;';
22135
+ status.textContent = restoring ? 'Your game stays open. Loading secure restore…' : 'Your game stays open. Loading secure checkout…';
22120
22136
  const iframe = doc.createElement('iframe');
22121
22137
  iframe.title = heading.textContent;
22122
22138
  iframe.setAttribute('allow', 'payment');
22123
22139
  iframe.setAttribute('sandbox', 'allow-scripts allow-forms allow-same-origin allow-popups allow-popups-to-escape-sandbox');
22124
22140
  iframe.referrerPolicy = 'no-referrer';
22125
- iframe.style.cssText = 'display:block;width:100%;height:calc(100% - 84px);border:0;background:#fff;';
22141
+ iframe.style.cssText = 'display:block;flex:1 1 0%;min-width:0;min-height:0;width:100%;height:100%;margin:0;padding:0;border:0;background:#fff;';
22126
22142
  iframe.src = session.hosted_url;
22127
- dialog.append(style, header, status, iframe);
22143
+ chrome.append(header, status);
22144
+ dialog.append(style, chrome, iframe);
22128
22145
  doc.body.append(dialog);
22129
22146
  const frameWindow = iframe.contentWindow;
22130
22147
  if (!frameWindow) {
@@ -22138,6 +22155,19 @@ function openMicrotransactionOverlay(options) {
22138
22155
  let frameLoadTimer;
22139
22156
  let appReadyTimer;
22140
22157
  let applicationReady = false;
22158
+ let retryPhase = 'idle';
22159
+ let retryReady = false;
22160
+ const isBlankDocument = () => {
22161
+ var _a;
22162
+ // about:blank inherits our origin. A src attribute alone says nothing about
22163
+ // which document emitted load; an old checkout load can still be queued.
22164
+ try {
22165
+ return ((_a = iframe.contentDocument) === null || _a === void 0 ? void 0 : _a.URL) === 'about:blank' && iframe.contentDocument.readyState === 'complete';
22166
+ }
22167
+ catch (_b) {
22168
+ return false;
22169
+ }
22170
+ };
22141
22171
  const blocked = [];
22142
22172
  const report = (error) => { var _a; try {
22143
22173
  (_a = options.onError) === null || _a === void 0 ? void 0 : _a.call(options, error);
@@ -22155,21 +22185,32 @@ function openMicrotransactionOverlay(options) {
22155
22185
  if (closed)
22156
22186
  return;
22157
22187
  clearWatchdogs();
22188
+ if (retryPhase !== 'idle') {
22189
+ retryPhase = 'failed';
22190
+ retryReady = false;
22191
+ }
22158
22192
  status.setAttribute('role', 'alert');
22193
+ const flow = restoring ? 'Restore' : 'Checkout';
22159
22194
  status.textContent = reason === 'ready'
22160
- ? 'Checkout did not become ready. Retry this same checkout or Close; your game remains open.'
22161
- : 'Checkout could not load here. Retry this same checkout or Close; your game remains open.';
22162
- report(new Error(reason === 'ready'
22163
- ? 'Embedded checkout readiness timed out; no navigation or new payment was attempted.'
22164
- : 'Embedded checkout loading unavailable; no navigation or new payment was attempted.'));
22195
+ ? `${flow} did not become ready. Retry this same session or Close; your game remains open.`
22196
+ : `${flow} could not load here. Retry this same session or Close; your game remains open.`;
22197
+ report(new Error(restoring
22198
+ ? `Embedded restore ${reason === 'ready' ? 'readiness timed out' : 'loading unavailable'}; no navigation was attempted.`
22199
+ : reason === 'ready'
22200
+ ? 'Embedded checkout readiness timed out; no navigation or new payment was attempted.'
22201
+ : 'Embedded checkout loading unavailable; no navigation or new payment was attempted.'));
22165
22202
  };
22166
22203
  const markApplicationReady = () => {
22167
22204
  if (closed)
22168
22205
  return;
22206
+ // A verified claim from the previous document may finish while Retry is
22207
+ // navigating. Keep that claim, but it cannot certify the new document UI.
22208
+ if (retryPhase !== 'idle')
22209
+ return;
22169
22210
  applicationReady = true;
22170
22211
  clearWatchdogs();
22171
22212
  status.setAttribute('role', 'status');
22172
- status.textContent = 'Checkout is ready. Your game remains open underneath.';
22213
+ status.textContent = restoring ? 'Restore is ready. Your game remains open underneath.' : 'Checkout is ready. Your game remains open underneath.';
22173
22214
  };
22174
22215
  const armLoadWatchdog = () => {
22175
22216
  clearWatchdogs();
@@ -22223,7 +22264,8 @@ function openMicrotransactionOverlay(options) {
22223
22264
  event.preventDefault();
22224
22265
  void overlay.close();
22225
22266
  }
22226
- if (event.key === 'Tab' && !closed) {
22267
+ // Keep the trap while close waits for an in-flight claim/inventory callback.
22268
+ if (event.key === 'Tab' && dialog.isConnected) {
22227
22269
  if (event.shiftKey && doc.activeElement === retryButton) {
22228
22270
  event.preventDefault();
22229
22271
  iframe.focus();
@@ -22235,6 +22277,8 @@ function openMicrotransactionOverlay(options) {
22235
22277
  }
22236
22278
  };
22237
22279
  const onCancel = (event) => { event.preventDefault(); void overlay.close(); };
22280
+ // Keyboard events inside the cross-origin document do not reach onKey.
22281
+ // The hosted UI forwards Escape via this existing, strictly bound close message.
22238
22282
  const onCloseMessage = (event) => {
22239
22283
  if (closed || event.origin !== options.checkoutOrigin || event.source !== frameWindow || !event.data || typeof event.data !== 'object')
22240
22284
  return;
@@ -22243,24 +22287,53 @@ function openMicrotransactionOverlay(options) {
22243
22287
  message.checkout_session_id !== session.id || message.nonce !== session.nonce)
22244
22288
  return;
22245
22289
  if (message.type === 'glitch.microtransaction.ready') {
22246
- markApplicationReady();
22290
+ if (retryPhase === 'checkout' && !isBlankDocument())
22291
+ retryReady = true;
22292
+ else if (retryPhase === 'idle')
22293
+ markApplicationReady();
22247
22294
  return;
22248
22295
  }
22249
22296
  if (message.type !== 'glitch.microtransaction.close')
22250
22297
  return;
22251
22298
  void overlay.close(verified ? 'completed' : 'dismissed');
22252
22299
  };
22253
- const onFrameError = () => { unavailable('error'); };
22300
+ const onFrameError = () => {
22301
+ // Events from the document being left cannot fail the blank navigation.
22302
+ // Its watchdog still bounds a missing/failed intermediate load.
22303
+ if (retryPhase === 'blank' || (retryPhase === 'checkout' && isBlankDocument()))
22304
+ return;
22305
+ unavailable('error');
22306
+ };
22254
22307
  const onFrameLoad = () => {
22255
22308
  if (closed)
22256
22309
  return;
22310
+ if (retryPhase === 'failed')
22311
+ return;
22312
+ if (retryPhase === 'blank') {
22313
+ if (!isBlankDocument())
22314
+ return;
22315
+ retryPhase = 'checkout';
22316
+ armLoadWatchdog();
22317
+ iframe.src = session.hosted_url;
22318
+ return;
22319
+ }
22320
+ if (retryPhase === 'checkout') {
22321
+ if (isBlankDocument())
22322
+ return;
22323
+ retryPhase = 'idle';
22324
+ if (retryReady) {
22325
+ retryReady = false;
22326
+ markApplicationReady();
22327
+ return;
22328
+ }
22329
+ }
22257
22330
  if (frameLoadTimer !== undefined)
22258
22331
  win.clearTimeout(frameLoadTimer);
22259
22332
  frameLoadTimer = undefined;
22260
22333
  if (applicationReady)
22261
22334
  return;
22262
22335
  status.setAttribute('role', 'status');
22263
- status.textContent = 'Checkout document loaded. Waiting for the secure checkout interface…';
22336
+ status.textContent = restoring ? 'Restore document loaded. Waiting for the secure restore interface…' : 'Checkout document loaded. Waiting for the secure checkout interface…';
22264
22337
  // A document load is not proof the app rendered. Repeated loads cannot
22265
22338
  // indefinitely extend this bounded wait; only explicit Retry resets it.
22266
22339
  if (appReadyTimer === undefined)
@@ -22269,12 +22342,18 @@ function openMicrotransactionOverlay(options) {
22269
22342
  const overlay = {
22270
22343
  element: dialog, iframe, refresh,
22271
22344
  retry: () => {
22272
- if (closed)
22345
+ if (closed || retryPhase === 'blank' || retryPhase === 'checkout')
22273
22346
  return;
22274
- status.textContent = 'Retrying the same secure checkout. Your game stays open.';
22347
+ status.textContent = restoring ? 'Retrying the same secure restore session. Your game stays open.' : 'Retrying the same secure checkout. Your game stays open.';
22275
22348
  status.setAttribute('role', 'status');
22349
+ retryPhase = 'blank';
22350
+ retryReady = false;
22276
22351
  armLoadWatchdog();
22277
- iframe.src = session.hosted_url;
22352
+ // Bootstrap removes #token with replaceState. Reassigning the original
22353
+ // URL then only changes the fragment; it does not reload checkout/API.
22354
+ // Commit a harmless blank document first, then navigate this SAME iframe
22355
+ // to the exact original capability URL. Its WindowProxy/bridge stay pinned.
22356
+ iframe.src = 'about:blank';
22278
22357
  },
22279
22358
  close: (reason = 'dismissed') => {
22280
22359
  if (closing)
@@ -22283,7 +22362,10 @@ function openMicrotransactionOverlay(options) {
22283
22362
  return Promise.resolve();
22284
22363
  closed = true;
22285
22364
  clearWatchdogs();
22286
- status.textContent = 'Finishing secure purchase verification. Your game stays open.';
22365
+ retryPhase = 'failed';
22366
+ retryReady = false;
22367
+ status.setAttribute('role', 'status');
22368
+ status.textContent = restoring ? 'Finishing secure restore verification. Your game stays open.' : 'Finishing secure purchase verification. Your game stays open.';
22287
22369
  closing = (() => __awaiter(this, void 0, void 0, function* () {
22288
22370
  var _a;
22289
22371
  try {