@copart/ops-tool-kit 1.13.0-beta.31 → 1.13.0-beta.32
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/bin/cli.js +0 -0
- package/dist/ops-tool-kit.js +431 -87
- package/dist/ops-tool-kit.js.map +1 -1
- package/package.json +1 -1
package/dist/ops-tool-kit.js
CHANGED
|
@@ -49,7 +49,7 @@ var ReactDOM__default = /*#__PURE__*/_interopDefaultLegacy(ReactDOM);
|
|
|
49
49
|
var ReactRouterDOM__namespace = /*#__PURE__*/_interopNamespace(ReactRouterDOM);
|
|
50
50
|
|
|
51
51
|
const name$1 = "@copart/ops-tool-kit";
|
|
52
|
-
const version$3 = "1.13.0-beta.
|
|
52
|
+
const version$3 = "1.13.0-beta.32";
|
|
53
53
|
const main$1 = "dist/ops-tool-kit.js";
|
|
54
54
|
const style = "dist/ops-tool-kit.css";
|
|
55
55
|
const files = [
|
|
@@ -69088,6 +69088,7 @@ function isAllowedOrigin(origin) {
|
|
|
69088
69088
|
var _excluded$1 = ["signal"];
|
|
69089
69089
|
var pending = new Map();
|
|
69090
69090
|
var STORAGE_REQUEST_TIMEOUT_MS = 5000;
|
|
69091
|
+
var LOG_PREFIX = '[iframe-bridge]';
|
|
69091
69092
|
function requestId() {
|
|
69092
69093
|
if (typeof crypto !== 'undefined' && typeof crypto.randomUUID === 'function') {
|
|
69093
69094
|
return crypto.randomUUID();
|
|
@@ -69107,47 +69108,365 @@ function requestId() {
|
|
|
69107
69108
|
return v.toString(16);
|
|
69108
69109
|
});
|
|
69109
69110
|
}
|
|
69111
|
+
function isEmbeddedFrame() {
|
|
69112
|
+
return typeof window !== 'undefined' && window.self !== window.top;
|
|
69113
|
+
}
|
|
69110
69114
|
|
|
69111
|
-
// The exact origin of the shell that framed us. Learned from
|
|
69112
|
-
//
|
|
69115
|
+
// The exact origin of the shell that framed us. Learned from SHELL_ORIGIN,
|
|
69116
|
+
// optional browser hints, or the first inbound message that passes validation,
|
|
69113
69117
|
// then pinned. Used as the targetOrigin for every outbound post() so app→shell
|
|
69114
69118
|
// messages (incl. FETCH_REQUEST bodies) are never broadcast to '*'.
|
|
69115
69119
|
//
|
|
69116
69120
|
// If SHELL_ORIGIN is provided at build time we lock to it up front — there is
|
|
69117
69121
|
// only one shell, so this is the tightest option and closes the "any
|
|
69118
69122
|
// *.copart.com subdomain" residual entirely. Otherwise we capture-and-lock.
|
|
69119
|
-
|
|
69123
|
+
//
|
|
69124
|
+
// CRITICAL: handshake MUST NOT depend on ancestorOrigins/referrer. Those are
|
|
69125
|
+
// Chromium-only / often empty. Cross-origin GET_INIT_DATA uses targetOrigin '*'
|
|
69126
|
+
// until the parent is pinned by an inbound LOAD_URI or INIT_DATA (all browsers).
|
|
69127
|
+
var configuredShellOrigin = typeof process !== 'undefined' && process.env && process.env.SHELL_ORIGIN || null;
|
|
69128
|
+
var trustedParentOrigin = configuredShellOrigin || null;
|
|
69129
|
+
var parentOriginWaiters = new Set();
|
|
69130
|
+
function notifyParentOriginWaiters() {
|
|
69131
|
+
if (!trustedParentOrigin || parentOriginWaiters.size === 0) return;
|
|
69132
|
+
var waiters = Array.from(parentOriginWaiters);
|
|
69133
|
+
parentOriginWaiters.clear();
|
|
69134
|
+
waiters.forEach(function (resolve) {
|
|
69135
|
+
return resolve(trustedParentOrigin);
|
|
69136
|
+
});
|
|
69137
|
+
}
|
|
69138
|
+
|
|
69139
|
+
/**
|
|
69140
|
+
* Optional fast-path only. Never required for correctness.
|
|
69141
|
+
* Chromium: ancestorOrigins. Others: document.referrer (often empty).
|
|
69142
|
+
*/
|
|
69143
|
+
function tryInferParentOrigin() {
|
|
69144
|
+
if (typeof window === 'undefined') return null;
|
|
69145
|
+
try {
|
|
69146
|
+
var ancestors = window.location && window.location.ancestorOrigins;
|
|
69147
|
+
if (ancestors && ancestors.length > 0) {
|
|
69148
|
+
var origin = ancestors[0];
|
|
69149
|
+
if (isAllowedOrigin(origin)) return origin;
|
|
69150
|
+
}
|
|
69151
|
+
} catch (_) {/* ignore */}
|
|
69152
|
+
try {
|
|
69153
|
+
if (document.referrer) {
|
|
69154
|
+
var _origin = new URL(document.referrer).origin;
|
|
69155
|
+
if (isAllowedOrigin(_origin)) return _origin;
|
|
69156
|
+
}
|
|
69157
|
+
} catch (_) {/* ignore */}
|
|
69158
|
+
return null;
|
|
69159
|
+
}
|
|
69160
|
+
if (!trustedParentOrigin) {
|
|
69161
|
+
var inferred = tryInferParentOrigin();
|
|
69162
|
+
if (inferred) trustedParentOrigin = inferred;
|
|
69163
|
+
}
|
|
69164
|
+
|
|
69165
|
+
/** Snapshot for support logs — no tokens/secrets. */
|
|
69166
|
+
function getHandshakeDiagnostics() {
|
|
69167
|
+
var ancestorOrigin = null;
|
|
69168
|
+
var referrerOrigin = null;
|
|
69169
|
+
try {
|
|
69170
|
+
var ancestors = typeof window !== 'undefined' && window.location && window.location.ancestorOrigins;
|
|
69171
|
+
if (ancestors && ancestors.length > 0) ancestorOrigin = ancestors[0];
|
|
69172
|
+
} catch (_) {/* ignore */}
|
|
69173
|
+
try {
|
|
69174
|
+
if (typeof document !== 'undefined' && document.referrer) {
|
|
69175
|
+
referrerOrigin = new URL(document.referrer).origin;
|
|
69176
|
+
}
|
|
69177
|
+
} catch (_) {/* ignore */}
|
|
69178
|
+
return {
|
|
69179
|
+
inIframe: isEmbeddedFrame(),
|
|
69180
|
+
appOrigin: typeof window !== 'undefined' ? window.location.origin : null,
|
|
69181
|
+
configuredShellOrigin: configuredShellOrigin,
|
|
69182
|
+
pinnedShellOrigin: trustedParentOrigin,
|
|
69183
|
+
inferredAncestorOrigin: ancestorOrigin,
|
|
69184
|
+
inferredReferrerOrigin: referrerOrigin,
|
|
69185
|
+
earlyLoadUri: typeof window !== 'undefined' ? window.__IFRAME_EARLY_LOAD_URI : null,
|
|
69186
|
+
pendingRequestCount: pending.size
|
|
69187
|
+
};
|
|
69188
|
+
}
|
|
69189
|
+
|
|
69190
|
+
/**
|
|
69191
|
+
* Pin the shell origin after validating it is an allowed Copart origin.
|
|
69192
|
+
* Used by early LOAD_URI and by the first trusted inbound message.
|
|
69193
|
+
* Once pinned, a conflicting origin is rejected.
|
|
69194
|
+
*/
|
|
69195
|
+
function pinTrustedParentOrigin(origin) {
|
|
69196
|
+
var source = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : 'unknown';
|
|
69197
|
+
if (!origin || typeof origin !== 'string') return false;
|
|
69198
|
+
if (configuredShellOrigin) {
|
|
69199
|
+
var ok = origin === configuredShellOrigin;
|
|
69200
|
+
if (!ok) {
|
|
69201
|
+
console.warn("".concat(LOG_PREFIX, " refused pin \u2014 conflicts with SHELL_ORIGIN"), {
|
|
69202
|
+
source: source,
|
|
69203
|
+
attempted: origin,
|
|
69204
|
+
configuredShellOrigin: configuredShellOrigin
|
|
69205
|
+
});
|
|
69206
|
+
}
|
|
69207
|
+
return ok;
|
|
69208
|
+
}
|
|
69209
|
+
if (trustedParentOrigin) {
|
|
69210
|
+
var _ok = origin === trustedParentOrigin;
|
|
69211
|
+
if (!_ok) {
|
|
69212
|
+
console.warn("".concat(LOG_PREFIX, " refused pin \u2014 already pinned to different origin"), {
|
|
69213
|
+
source: source,
|
|
69214
|
+
attempted: origin,
|
|
69215
|
+
pinned: trustedParentOrigin
|
|
69216
|
+
});
|
|
69217
|
+
}
|
|
69218
|
+
return _ok;
|
|
69219
|
+
}
|
|
69220
|
+
if (!isAllowedOrigin(origin)) {
|
|
69221
|
+
console.warn("".concat(LOG_PREFIX, " refused pin \u2014 origin not in allowlist"), {
|
|
69222
|
+
source: source,
|
|
69223
|
+
attempted: origin
|
|
69224
|
+
});
|
|
69225
|
+
return false;
|
|
69226
|
+
}
|
|
69227
|
+
trustedParentOrigin = origin;
|
|
69228
|
+
console.info("".concat(LOG_PREFIX, " pinned shell origin"), {
|
|
69229
|
+
source: source,
|
|
69230
|
+
shellOrigin: origin
|
|
69231
|
+
});
|
|
69232
|
+
notifyParentOriginWaiters();
|
|
69233
|
+
return true;
|
|
69234
|
+
}
|
|
69235
|
+
|
|
69236
|
+
/**
|
|
69237
|
+
* Resolve (and optionally wait for) the pinned shell origin before outbound posts.
|
|
69238
|
+
*/
|
|
69239
|
+
function waitForTrustedParentOrigin() {
|
|
69240
|
+
var timeoutMs = arguments.length > 0 && arguments[0] !== undefined ? arguments[0] : 4000;
|
|
69241
|
+
if (trustedParentOrigin) return Promise.resolve(trustedParentOrigin);
|
|
69242
|
+
var inferred = tryInferParentOrigin();
|
|
69243
|
+
if (inferred) {
|
|
69244
|
+
pinTrustedParentOrigin(inferred, 'infer');
|
|
69245
|
+
return Promise.resolve(trustedParentOrigin);
|
|
69246
|
+
}
|
|
69247
|
+
return new Promise(function (resolve) {
|
|
69248
|
+
var settled = false;
|
|
69249
|
+
var _waiter = function waiter(origin) {
|
|
69250
|
+
if (settled) return;
|
|
69251
|
+
settled = true;
|
|
69252
|
+
clearTimeout(timer);
|
|
69253
|
+
parentOriginWaiters.delete(_waiter);
|
|
69254
|
+
resolve(origin || null);
|
|
69255
|
+
};
|
|
69256
|
+
parentOriginWaiters.add(_waiter);
|
|
69257
|
+
var timer = setTimeout(function () {
|
|
69258
|
+
parentOriginWaiters.delete(_waiter);
|
|
69259
|
+
if (!settled) {
|
|
69260
|
+
settled = true;
|
|
69261
|
+
resolve(trustedParentOrigin || null);
|
|
69262
|
+
}
|
|
69263
|
+
}, timeoutMs);
|
|
69264
|
+
});
|
|
69265
|
+
}
|
|
69120
69266
|
|
|
69121
69267
|
/**
|
|
69122
69268
|
* Gate every inbound message. event.origin is set by the browser and cannot be
|
|
69123
|
-
* forged by the sender
|
|
69124
|
-
* rejected here before it can lock the origin or be processed.
|
|
69125
|
-
* - must come from our direct parent window (single framer),
|
|
69126
|
-
* - must be a copart origin (or the pinned SHELL_ORIGIN if configured),
|
|
69127
|
-
* - once an origin is pinned, only that exact origin is accepted thereafter.
|
|
69269
|
+
* forged by the sender.
|
|
69128
69270
|
*/
|
|
69129
69271
|
function isTrustedMessage(event) {
|
|
69130
|
-
if (typeof window !== 'undefined' && event.source !== window.parent)
|
|
69272
|
+
if (typeof window !== 'undefined' && event.source !== window.parent) {
|
|
69273
|
+
return false;
|
|
69274
|
+
}
|
|
69131
69275
|
if (trustedParentOrigin) {
|
|
69132
|
-
|
|
69133
|
-
|
|
69276
|
+
if (event.origin !== trustedParentOrigin) {
|
|
69277
|
+
console.warn("".concat(LOG_PREFIX, " ignored message \u2014 origin mismatch vs pinned shell"), {
|
|
69278
|
+
eventType: event.data && event.data.eventType,
|
|
69279
|
+
from: event.origin,
|
|
69280
|
+
pinned: trustedParentOrigin
|
|
69281
|
+
});
|
|
69282
|
+
return false;
|
|
69283
|
+
}
|
|
69284
|
+
return true;
|
|
69134
69285
|
}
|
|
69135
|
-
if (!isAllowedOrigin(event.origin))
|
|
69136
|
-
|
|
69137
|
-
|
|
69286
|
+
if (!isAllowedOrigin(event.origin)) {
|
|
69287
|
+
console.warn("".concat(LOG_PREFIX, " ignored message \u2014 origin not allowlisted"), {
|
|
69288
|
+
eventType: event.data && event.data.eventType,
|
|
69289
|
+
from: event.origin
|
|
69290
|
+
});
|
|
69291
|
+
return false;
|
|
69292
|
+
}
|
|
69293
|
+
// First valid message from a copart parent — pin it (works on all browsers).
|
|
69294
|
+
pinTrustedParentOrigin(event.origin, "inbound:".concat(event.data && event.data.eventType || 'message'));
|
|
69138
69295
|
return true;
|
|
69139
69296
|
}
|
|
69297
|
+
|
|
69298
|
+
/**
|
|
69299
|
+
* @param {string} eventType
|
|
69300
|
+
* @param {object} [eventProps]
|
|
69301
|
+
* @param {{ allowWildcardHandshake?: boolean }} [options]
|
|
69302
|
+
* @returns {boolean} whether the browser postMessage was invoked
|
|
69303
|
+
*/
|
|
69140
69304
|
function post(eventType, eventProps) {
|
|
69141
|
-
|
|
69142
|
-
|
|
69143
|
-
|
|
69144
|
-
|
|
69145
|
-
|
|
69146
|
-
|
|
69305
|
+
var options = arguments.length > 2 && arguments[2] !== undefined ? arguments[2] : {};
|
|
69306
|
+
if (typeof window === 'undefined' || !window.parent) return false;
|
|
69307
|
+
var targetOrigin = trustedParentOrigin;
|
|
69308
|
+
if (!targetOrigin) {
|
|
69309
|
+
if (options.allowWildcardHandshake) {
|
|
69310
|
+
// Handshake probe only — no secrets in the payload. Required for
|
|
69311
|
+
// cross-origin embeds on Safari/Firefox where parent origin is unknown
|
|
69312
|
+
// until the first inbound shell message arrives.
|
|
69313
|
+
targetOrigin = '*';
|
|
69314
|
+
} else if (isEmbeddedFrame()) {
|
|
69315
|
+
// NEVER use '/' while framed: it silently drops on subdomain (cross-origin).
|
|
69316
|
+
console.error("".concat(LOG_PREFIX, " blocked post \u2014 shell origin not pinned yet"), {
|
|
69317
|
+
eventType: eventType,
|
|
69318
|
+
diagnostics: getHandshakeDiagnostics()
|
|
69319
|
+
});
|
|
69320
|
+
return false;
|
|
69321
|
+
} else {
|
|
69322
|
+
targetOrigin = '/';
|
|
69323
|
+
}
|
|
69324
|
+
}
|
|
69147
69325
|
window.parent.postMessage({
|
|
69148
69326
|
eventType: eventType,
|
|
69149
69327
|
eventProps: eventProps || {}
|
|
69150
69328
|
}, targetOrigin);
|
|
69329
|
+
return true;
|
|
69330
|
+
}
|
|
69331
|
+
function delay(ms) {
|
|
69332
|
+
return new Promise(function (resolve) {
|
|
69333
|
+
return setTimeout(resolve, ms);
|
|
69334
|
+
});
|
|
69335
|
+
}
|
|
69336
|
+
function requestInitDataOnce(timeoutMs, allowWildcardHandshake) {
|
|
69337
|
+
return new Promise(function (_resolve) {
|
|
69338
|
+
var id = requestId();
|
|
69339
|
+
var timer = setTimeout(function () {
|
|
69340
|
+
if (pending.has(id)) {
|
|
69341
|
+
pending.delete(id);
|
|
69342
|
+
console.warn("".concat(LOG_PREFIX, " GET_INIT_DATA attempt timed out"), {
|
|
69343
|
+
requestId: id,
|
|
69344
|
+
timeoutMs: timeoutMs,
|
|
69345
|
+
usedWildcard: allowWildcardHandshake,
|
|
69346
|
+
shellOrigin: trustedParentOrigin
|
|
69347
|
+
});
|
|
69348
|
+
_resolve(null);
|
|
69349
|
+
}
|
|
69350
|
+
}, timeoutMs);
|
|
69351
|
+
pending.set(id, {
|
|
69352
|
+
resolve: function resolve(result) {
|
|
69353
|
+
clearTimeout(timer);
|
|
69354
|
+
_resolve(result);
|
|
69355
|
+
},
|
|
69356
|
+
reject: function reject() {
|
|
69357
|
+
clearTimeout(timer);
|
|
69358
|
+
_resolve(null);
|
|
69359
|
+
}
|
|
69360
|
+
});
|
|
69361
|
+
var sent = post(IFRAME_EVENTS.GET_INIT_DATA, {
|
|
69362
|
+
requestId: id
|
|
69363
|
+
}, {
|
|
69364
|
+
allowWildcardHandshake: allowWildcardHandshake
|
|
69365
|
+
});
|
|
69366
|
+
console.info("".concat(LOG_PREFIX, " GET_INIT_DATA sent"), {
|
|
69367
|
+
requestId: id,
|
|
69368
|
+
usedWildcard: allowWildcardHandshake,
|
|
69369
|
+
shellOrigin: trustedParentOrigin,
|
|
69370
|
+
sent: sent
|
|
69371
|
+
});
|
|
69372
|
+
if (!sent) {
|
|
69373
|
+
clearTimeout(timer);
|
|
69374
|
+
pending.delete(id);
|
|
69375
|
+
_resolve(null);
|
|
69376
|
+
}
|
|
69377
|
+
});
|
|
69378
|
+
}
|
|
69379
|
+
|
|
69380
|
+
/**
|
|
69381
|
+
* Fetch bootstrap init data from the shell.
|
|
69382
|
+
* All-browser / cross-origin safe:
|
|
69383
|
+
* - does NOT require ancestorOrigins or referrer
|
|
69384
|
+
* - sends GET_INIT_DATA with '*' until parent origin is pinned
|
|
69385
|
+
* - retries so a request that arrives before the shell listener is attached
|
|
69386
|
+
* is not a permanent failure
|
|
69387
|
+
* - first trusted INIT_DATA / LOAD_URI pins the parent for later secret posts
|
|
69388
|
+
*/
|
|
69389
|
+
function getInitData() {
|
|
69390
|
+
return _getInitData.apply(this, arguments);
|
|
69391
|
+
}
|
|
69392
|
+
function _getInitData() {
|
|
69393
|
+
_getInitData = _asyncToGenerator$1(/*#__PURE__*/_regenerator().m(function _callee() {
|
|
69394
|
+
var timeoutMs,
|
|
69395
|
+
_inferred,
|
|
69396
|
+
attempts,
|
|
69397
|
+
perAttemptTimeout,
|
|
69398
|
+
attempt,
|
|
69399
|
+
allowWildcardHandshake,
|
|
69400
|
+
result,
|
|
69401
|
+
_args = arguments;
|
|
69402
|
+
return _regenerator().w(function (_context) {
|
|
69403
|
+
while (1) switch (_context.n) {
|
|
69404
|
+
case 0:
|
|
69405
|
+
timeoutMs = _args.length > 0 && _args[0] !== undefined ? _args[0] : 5000;
|
|
69406
|
+
// Optional fast-path only — never block the handshake on browser-specific APIs.
|
|
69407
|
+
if (!trustedParentOrigin) {
|
|
69408
|
+
_inferred = tryInferParentOrigin();
|
|
69409
|
+
if (_inferred) pinTrustedParentOrigin(_inferred, 'infer-before-handshake');
|
|
69410
|
+
}
|
|
69411
|
+
console.info("".concat(LOG_PREFIX, " handshake start"), getHandshakeDiagnostics());
|
|
69412
|
+
attempts = 3; // Full window per attempt — shell may await permission fetches on cold load.
|
|
69413
|
+
perAttemptTimeout = Math.max(timeoutMs, 5000);
|
|
69414
|
+
attempt = 1;
|
|
69415
|
+
case 1:
|
|
69416
|
+
if (!(attempt <= attempts)) {
|
|
69417
|
+
_context.n = 5;
|
|
69418
|
+
break;
|
|
69419
|
+
}
|
|
69420
|
+
allowWildcardHandshake = !trustedParentOrigin;
|
|
69421
|
+
console.info("".concat(LOG_PREFIX, " GET_INIT_DATA attempt"), {
|
|
69422
|
+
attempt: attempt,
|
|
69423
|
+
attempts: attempts,
|
|
69424
|
+
allowWildcardHandshake: allowWildcardHandshake,
|
|
69425
|
+
shellOrigin: trustedParentOrigin
|
|
69426
|
+
});
|
|
69427
|
+
_context.n = 2;
|
|
69428
|
+
return requestInitDataOnce(perAttemptTimeout, allowWildcardHandshake);
|
|
69429
|
+
case 2:
|
|
69430
|
+
result = _context.v;
|
|
69431
|
+
if (!result) {
|
|
69432
|
+
_context.n = 3;
|
|
69433
|
+
break;
|
|
69434
|
+
}
|
|
69435
|
+
console.info("".concat(LOG_PREFIX, " handshake success"), {
|
|
69436
|
+
attempt: attempt,
|
|
69437
|
+
shellOrigin: trustedParentOrigin,
|
|
69438
|
+
hasLogin: !!(result && result.login),
|
|
69439
|
+
hasAccessToken: !!(result && result.accessToken)
|
|
69440
|
+
});
|
|
69441
|
+
return _context.a(2, result);
|
|
69442
|
+
case 3:
|
|
69443
|
+
if (!(attempt < attempts)) {
|
|
69444
|
+
_context.n = 4;
|
|
69445
|
+
break;
|
|
69446
|
+
}
|
|
69447
|
+
console.warn("".concat(LOG_PREFIX, " GET_INIT_DATA attempt failed; retrying"), {
|
|
69448
|
+
attempt: attempt,
|
|
69449
|
+
attempts: attempts,
|
|
69450
|
+
shellOrigin: trustedParentOrigin,
|
|
69451
|
+
diagnostics: getHandshakeDiagnostics()
|
|
69452
|
+
});
|
|
69453
|
+
_context.n = 4;
|
|
69454
|
+
return delay(200);
|
|
69455
|
+
case 4:
|
|
69456
|
+
attempt += 1;
|
|
69457
|
+
_context.n = 1;
|
|
69458
|
+
break;
|
|
69459
|
+
case 5:
|
|
69460
|
+
console.error("".concat(LOG_PREFIX, " handshake FAILED \u2014 no INIT_DATA from shell"), {
|
|
69461
|
+
attempts: attempts,
|
|
69462
|
+
perAttemptTimeout: perAttemptTimeout,
|
|
69463
|
+
diagnostics: getHandshakeDiagnostics()
|
|
69464
|
+
});
|
|
69465
|
+
return _context.a(2, null);
|
|
69466
|
+
}
|
|
69467
|
+
}, _callee);
|
|
69468
|
+
}));
|
|
69469
|
+
return _getInitData.apply(this, arguments);
|
|
69151
69470
|
}
|
|
69152
69471
|
function handleMessage(event) {
|
|
69153
69472
|
if (!isTrustedMessage(event)) return;
|
|
@@ -69156,7 +69475,18 @@ function handleMessage(event) {
|
|
|
69156
69475
|
var _data$eventProps = data.eventProps,
|
|
69157
69476
|
eventProps = _data$eventProps === void 0 ? {} : _data$eventProps;
|
|
69158
69477
|
var id = eventProps.requestId;
|
|
69159
|
-
if (!id || !pending.has(id))
|
|
69478
|
+
if (!id || !pending.has(id)) {
|
|
69479
|
+
// LOAD_URI / STORAGE_CHANGED etc. are handled by other listeners; only log
|
|
69480
|
+
// orphaned RPC responses which indicate a timeout/retry race.
|
|
69481
|
+
if (data.eventType === IFRAME_EVENTS.INIT_DATA || data.eventType === IFRAME_EVENTS.FETCH_RESPONSE || data.eventType === IFRAME_EVENTS.STORAGE_RESPONSE || data.eventType === IFRAME_EVENTS.ACCESS_RESPONSE) {
|
|
69482
|
+
console.warn("".concat(LOG_PREFIX, " ignored RPC response \u2014 no matching pending request"), {
|
|
69483
|
+
eventType: data.eventType,
|
|
69484
|
+
requestId: id,
|
|
69485
|
+
pendingCount: pending.size
|
|
69486
|
+
});
|
|
69487
|
+
}
|
|
69488
|
+
return;
|
|
69489
|
+
}
|
|
69160
69490
|
var _pending$get = pending.get(id),
|
|
69161
69491
|
resolve = _pending$get.resolve,
|
|
69162
69492
|
reject = _pending$get.reject,
|
|
@@ -69177,11 +69507,8 @@ function handleMessage(event) {
|
|
|
69177
69507
|
var _eventProps$result;
|
|
69178
69508
|
var resultData = (_eventProps$result = eventProps.result) === null || _eventProps$result === void 0 ? void 0 : _eventProps$result.data;
|
|
69179
69509
|
if (pendingResponseType === 'arraybuffer') {
|
|
69180
|
-
if (resultData instanceof ArrayBuffer)
|
|
69181
|
-
|
|
69182
|
-
// This means Step 2 (shell) has not been deployed yet, or the shell
|
|
69183
|
-
// is not forwarding responseType to its own axios call.
|
|
69184
|
-
console.warn('[iframe-bridge/transport] FETCH_RESPONSE expected ArrayBuffer but got non-binary — shell may not support responseType yet', {
|
|
69510
|
+
if (!(resultData instanceof ArrayBuffer)) {
|
|
69511
|
+
console.warn("".concat(LOG_PREFIX, " FETCH_RESPONSE expected ArrayBuffer but got non-binary"), {
|
|
69185
69512
|
requestId: id,
|
|
69186
69513
|
actualType: _typeof$1(resultData),
|
|
69187
69514
|
isNull: resultData == null
|
|
@@ -69209,25 +69536,20 @@ function sendFetchRequest(payload) {
|
|
|
69209
69536
|
var signal = payload.signal,
|
|
69210
69537
|
restPayload = _objectWithoutProperties(payload, _excluded$1);
|
|
69211
69538
|
return new Promise(function (resolve, reject) {
|
|
69212
|
-
// Reject immediately if the signal is already aborted before we even send
|
|
69213
69539
|
if (signal !== null && signal !== void 0 && signal.aborted) {
|
|
69214
69540
|
reject(new DOMException('Request aborted', 'AbortError'));
|
|
69215
69541
|
return;
|
|
69216
69542
|
}
|
|
69217
69543
|
var id = requestId();
|
|
69218
|
-
// store responseType so the response handler can detect a binary/non-binary mismatch
|
|
69219
69544
|
pending.set(id, {
|
|
69220
69545
|
resolve: resolve,
|
|
69221
69546
|
reject: reject,
|
|
69222
69547
|
responseType: payload.responseType
|
|
69223
69548
|
});
|
|
69224
|
-
|
|
69225
|
-
// signal cannot be transferred through postMessage — handle abort locally
|
|
69226
69549
|
if (signal) {
|
|
69227
69550
|
var onAbort = function onAbort() {
|
|
69228
69551
|
if (pending.has(id)) {
|
|
69229
69552
|
pending.delete(id);
|
|
69230
|
-
// Notify the shell so it can cancel its own request if wired up
|
|
69231
69553
|
post(IFRAME_EVENTS.CANCEL_REQUEST, {
|
|
69232
69554
|
requestId: id
|
|
69233
69555
|
});
|
|
@@ -69238,103 +69560,87 @@ function sendFetchRequest(payload) {
|
|
|
69238
69560
|
once: true
|
|
69239
69561
|
});
|
|
69240
69562
|
}
|
|
69241
|
-
|
|
69242
|
-
// signal is intentionally excluded from the message — it's a non-serialisable DOM object
|
|
69243
|
-
post(IFRAME_EVENTS.FETCH_REQUEST, _objectSpread2(_objectSpread2({}, restPayload), {}, {
|
|
69563
|
+
var sent = post(IFRAME_EVENTS.FETCH_REQUEST, _objectSpread2(_objectSpread2({}, restPayload), {}, {
|
|
69244
69564
|
requestId: id
|
|
69245
69565
|
}));
|
|
69566
|
+
if (!sent) {
|
|
69567
|
+
pending.delete(id);
|
|
69568
|
+
reject(new Error('iframe-bridge: FETCH_REQUEST blocked — shell origin not pinned'));
|
|
69569
|
+
}
|
|
69246
69570
|
});
|
|
69247
69571
|
}
|
|
69248
69572
|
function sendStorageGet(payload) {
|
|
69249
69573
|
var timeoutMs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : STORAGE_REQUEST_TIMEOUT_MS;
|
|
69250
|
-
return new Promise(function (
|
|
69574
|
+
return new Promise(function (_resolve2) {
|
|
69251
69575
|
var id = requestId();
|
|
69252
69576
|
var timer = setTimeout(function () {
|
|
69253
69577
|
if (pending.has(id)) {
|
|
69254
69578
|
pending.delete(id);
|
|
69255
|
-
console.warn(
|
|
69579
|
+
console.warn("".concat(LOG_PREFIX, " STORAGE_GET timed out"), {
|
|
69256
69580
|
op: payload === null || payload === void 0 ? void 0 : payload.op,
|
|
69257
69581
|
key: payload === null || payload === void 0 ? void 0 : payload.key,
|
|
69258
|
-
timeoutMs: timeoutMs
|
|
69582
|
+
timeoutMs: timeoutMs,
|
|
69583
|
+
shellOrigin: trustedParentOrigin
|
|
69259
69584
|
});
|
|
69260
|
-
|
|
69585
|
+
_resolve2(undefined);
|
|
69261
69586
|
}
|
|
69262
69587
|
}, timeoutMs);
|
|
69263
69588
|
pending.set(id, {
|
|
69264
69589
|
resolve: function resolve(result) {
|
|
69265
69590
|
clearTimeout(timer);
|
|
69266
|
-
|
|
69591
|
+
_resolve2(result);
|
|
69267
69592
|
},
|
|
69268
69593
|
reject: function reject() {
|
|
69269
69594
|
clearTimeout(timer);
|
|
69270
|
-
|
|
69595
|
+
_resolve2(undefined);
|
|
69271
69596
|
}
|
|
69272
69597
|
});
|
|
69273
|
-
post(IFRAME_EVENTS.STORAGE_GET, _objectSpread2(_objectSpread2({}, payload), {}, {
|
|
69598
|
+
var sent = post(IFRAME_EVENTS.STORAGE_GET, _objectSpread2(_objectSpread2({}, payload), {}, {
|
|
69274
69599
|
requestId: id
|
|
69275
69600
|
}));
|
|
69601
|
+
if (!sent) {
|
|
69602
|
+
clearTimeout(timer);
|
|
69603
|
+
pending.delete(id);
|
|
69604
|
+
_resolve2(undefined);
|
|
69605
|
+
}
|
|
69276
69606
|
});
|
|
69277
69607
|
}
|
|
69278
69608
|
function sendStorageSet(payload) {
|
|
69279
69609
|
var timeoutMs = arguments.length > 1 && arguments[1] !== undefined ? arguments[1] : STORAGE_REQUEST_TIMEOUT_MS;
|
|
69280
|
-
return new Promise(function (
|
|
69610
|
+
return new Promise(function (_resolve3) {
|
|
69281
69611
|
var id = requestId();
|
|
69282
69612
|
var timer = setTimeout(function () {
|
|
69283
69613
|
if (pending.has(id)) {
|
|
69284
69614
|
pending.delete(id);
|
|
69285
|
-
console.warn(
|
|
69615
|
+
console.warn("".concat(LOG_PREFIX, " STORAGE_SET timed out"), {
|
|
69286
69616
|
op: payload === null || payload === void 0 ? void 0 : payload.op,
|
|
69287
69617
|
key: payload === null || payload === void 0 ? void 0 : payload.key,
|
|
69288
|
-
timeoutMs: timeoutMs
|
|
69618
|
+
timeoutMs: timeoutMs,
|
|
69619
|
+
shellOrigin: trustedParentOrigin
|
|
69289
69620
|
});
|
|
69290
|
-
|
|
69621
|
+
_resolve3(undefined);
|
|
69291
69622
|
}
|
|
69292
69623
|
}, timeoutMs);
|
|
69293
69624
|
pending.set(id, {
|
|
69294
69625
|
resolve: function resolve(result) {
|
|
69295
69626
|
clearTimeout(timer);
|
|
69296
|
-
|
|
69627
|
+
_resolve3(result);
|
|
69297
69628
|
},
|
|
69298
69629
|
reject: function reject() {
|
|
69299
69630
|
clearTimeout(timer);
|
|
69300
|
-
|
|
69631
|
+
_resolve3(undefined);
|
|
69301
69632
|
}
|
|
69302
69633
|
});
|
|
69303
|
-
post(IFRAME_EVENTS.STORAGE_SET, _objectSpread2(_objectSpread2({}, payload), {}, {
|
|
69634
|
+
var sent = post(IFRAME_EVENTS.STORAGE_SET, _objectSpread2(_objectSpread2({}, payload), {}, {
|
|
69304
69635
|
requestId: id
|
|
69305
69636
|
}));
|
|
69637
|
+
if (!sent) {
|
|
69638
|
+
clearTimeout(timer);
|
|
69639
|
+
pending.delete(id);
|
|
69640
|
+
_resolve3(undefined);
|
|
69641
|
+
}
|
|
69306
69642
|
});
|
|
69307
69643
|
}
|
|
69308
|
-
function getInitData() {
|
|
69309
|
-
return new Promise(function (_resolve4) {
|
|
69310
|
-
var id = requestId();
|
|
69311
|
-
var timer = setTimeout(function () {
|
|
69312
|
-
if (pending.has(id)) {
|
|
69313
|
-
pending.delete(id);
|
|
69314
|
-
_resolve4(null);
|
|
69315
|
-
}
|
|
69316
|
-
}, 5000);
|
|
69317
|
-
pending.set(id, {
|
|
69318
|
-
resolve: function resolve(result) {
|
|
69319
|
-
clearTimeout(timer);
|
|
69320
|
-
_resolve4(result);
|
|
69321
|
-
},
|
|
69322
|
-
reject: function reject() {
|
|
69323
|
-
clearTimeout(timer);
|
|
69324
|
-
_resolve4(null);
|
|
69325
|
-
}
|
|
69326
|
-
});
|
|
69327
|
-
post(IFRAME_EVENTS.GET_INIT_DATA, {
|
|
69328
|
-
requestId: id
|
|
69329
|
-
});
|
|
69330
|
-
});
|
|
69331
|
-
}
|
|
69332
|
-
|
|
69333
|
-
/**
|
|
69334
|
-
* The shell origin we are pinned to (learned from the handshake or SHELL_ORIGIN).
|
|
69335
|
-
* Null until the first valid inbound message arrives. Used to build absolute
|
|
69336
|
-
* shell URLs (e.g. AppLink opening a shell route in a new tab).
|
|
69337
|
-
*/
|
|
69338
69644
|
function getShellOrigin() {
|
|
69339
69645
|
return trustedParentOrigin;
|
|
69340
69646
|
}
|
|
@@ -69367,11 +69673,6 @@ function postCountsAvailable() {
|
|
|
69367
69673
|
/**
|
|
69368
69674
|
* Push nav badge counts to the shell.
|
|
69369
69675
|
* @param {Record<string, Record<string, import('../utilities/navCountStatus').NavCountEntry>>} countsByMenu
|
|
69370
|
-
* Top-level menu route → sub-route counts. Each value may be:
|
|
69371
|
-
* - a plain number (count only, no badge color), or
|
|
69372
|
-
* - `{ count, status }` where status is pre-resolved in the iframe (1|2|3).
|
|
69373
|
-
* Example:
|
|
69374
|
-
* { tasks: { 'open-tasks': { count: 750, status: 2 } }, admin: { 'staged-users': 12 } }
|
|
69375
69676
|
*/
|
|
69376
69677
|
function postNavCounts(countsByMenu) {
|
|
69377
69678
|
if (!countsByMenu || _typeof$1(countsByMenu) !== 'object') return;
|
|
@@ -69427,6 +69728,9 @@ function extractUriFromFullPath(fullPath) {
|
|
|
69427
69728
|
function getInitialUri() {
|
|
69428
69729
|
if (typeof window !== 'undefined' && window.__IFRAME_EARLY_LOAD_URI != null) {
|
|
69429
69730
|
var uri = window.__IFRAME_EARLY_LOAD_URI;
|
|
69731
|
+
console.info("".concat(LOG_PREFIX, " getInitialUri from early LOAD_URI"), {
|
|
69732
|
+
uri: uri
|
|
69733
|
+
});
|
|
69430
69734
|
return Promise.resolve(uri === '' ? '/' : uri);
|
|
69431
69735
|
}
|
|
69432
69736
|
return new Promise(function (resolve) {
|
|
@@ -69439,6 +69743,9 @@ function getInitialUri() {
|
|
|
69439
69743
|
if (_uri == null && event.data.eventProps.fullPath) {
|
|
69440
69744
|
_uri = extractUriFromFullPath(event.data.eventProps.fullPath);
|
|
69441
69745
|
}
|
|
69746
|
+
console.info("".concat(LOG_PREFIX, " getInitialUri from LOAD_URI"), {
|
|
69747
|
+
uri: _uri
|
|
69748
|
+
});
|
|
69442
69749
|
resolve(_uri == null || _uri === '' ? '/' : _uri);
|
|
69443
69750
|
}
|
|
69444
69751
|
}
|
|
@@ -69446,6 +69753,10 @@ function getInitialUri() {
|
|
|
69446
69753
|
var timer = setTimeout(function () {
|
|
69447
69754
|
window.removeEventListener('message', onMessage);
|
|
69448
69755
|
var early = typeof window !== 'undefined' && window.__IFRAME_EARLY_LOAD_URI;
|
|
69756
|
+
console.warn("".concat(LOG_PREFIX, " getInitialUri timed out \u2014 defaulting"), {
|
|
69757
|
+
uri: early || '/',
|
|
69758
|
+
diagnostics: getHandshakeDiagnostics()
|
|
69759
|
+
});
|
|
69449
69760
|
resolve(early || '/');
|
|
69450
69761
|
}, 3000);
|
|
69451
69762
|
});
|
|
@@ -70710,6 +71021,12 @@ function Crumb(_ref) {
|
|
|
70710
71021
|
* catch-all for raw <a>/window.open/forms) use this so they agree on what is
|
|
70711
71022
|
* "internal" (a shell route), "external" (a foreign site), or something we
|
|
70712
71023
|
* should leave to the browser.
|
|
71024
|
+
*
|
|
71025
|
+
* Cross-origin note: after handshake, getShellOrigin() is the portal origin
|
|
71026
|
+
* (e.g. https://g2-qa4.copart.com), which may differ from window.location.origin
|
|
71027
|
+
* (the app subdomain). Relative hrefs are resolved against the shell origin so
|
|
71028
|
+
* they route through the portal, not the app host. This does not depend on
|
|
71029
|
+
* ancestorOrigins/referrer — only on the pinned shell origin from handshake.
|
|
70713
71030
|
*/
|
|
70714
71031
|
|
|
70715
71032
|
// Schemes that are not frame navigations we manage — let the browser handle.
|
|
@@ -70734,6 +71051,7 @@ function classifyHref(href) {
|
|
|
70734
71051
|
};
|
|
70735
71052
|
var shellOrigin = getShellOrigin();
|
|
70736
71053
|
var appOrigin = typeof window !== 'undefined' ? window.location.origin : undefined;
|
|
71054
|
+
// Prefer pinned shell origin so relative links are portal routes, not app-subdomain URLs.
|
|
70737
71055
|
var base = shellOrigin || appOrigin;
|
|
70738
71056
|
var parsed;
|
|
70739
71057
|
try {
|
|
@@ -71011,6 +71329,9 @@ var iframeFacade = {
|
|
|
71011
71329
|
getInitDataForBootstrap: getInitDataForBootstrap,
|
|
71012
71330
|
sendStorageGet: sendStorageGet,
|
|
71013
71331
|
getShellOrigin: getShellOrigin,
|
|
71332
|
+
pinTrustedParentOrigin: pinTrustedParentOrigin,
|
|
71333
|
+
waitForTrustedParentOrigin: waitForTrustedParentOrigin,
|
|
71334
|
+
getHandshakeDiagnostics: getHandshakeDiagnostics,
|
|
71014
71335
|
IFRAME_EVENTS: IFRAME_EVENTS
|
|
71015
71336
|
}
|
|
71016
71337
|
};
|
|
@@ -71018,6 +71339,8 @@ var iframeFacade = {
|
|
|
71018
71339
|
/**
|
|
71019
71340
|
* Register a synchronous LOAD_URI listener before async bootstrap loads.
|
|
71020
71341
|
* Call this from the app entry (index.js) before dynamic-importing bootstrap.
|
|
71342
|
+
* Also pins the shell origin so later secret-carrying posts can target the real
|
|
71343
|
+
* parent (all browsers — does not require ancestorOrigins/referrer).
|
|
71021
71344
|
*/
|
|
71022
71345
|
function registerEarlyLoadUriListener() {
|
|
71023
71346
|
if (typeof window === 'undefined') return;
|
|
@@ -71028,7 +71351,13 @@ function registerEarlyLoadUriListener() {
|
|
|
71028
71351
|
if (event.source !== window.parent) return;
|
|
71029
71352
|
if (!isAllowedOrigin(event.origin)) return;
|
|
71030
71353
|
if (event.data && event.data.eventType === IFRAME_EVENTS.LOAD_URI && event.data.eventProps) {
|
|
71354
|
+
var pinned = pinTrustedParentOrigin(event.origin, 'early-LOAD_URI');
|
|
71031
71355
|
window.__IFRAME_EARLY_LOAD_URI = event.data.eventProps.uri || '/';
|
|
71356
|
+
console.info('[iframe-bridge] early LOAD_URI received', {
|
|
71357
|
+
uri: window.__IFRAME_EARLY_LOAD_URI,
|
|
71358
|
+
shellOrigin: event.origin,
|
|
71359
|
+
pinned: pinned
|
|
71360
|
+
});
|
|
71032
71361
|
}
|
|
71033
71362
|
});
|
|
71034
71363
|
}
|
|
@@ -71179,7 +71508,7 @@ function bootstrapIframeApp(_x3) {
|
|
|
71179
71508
|
}
|
|
71180
71509
|
function _bootstrapIframeApp() {
|
|
71181
71510
|
_bootstrapIframeApp = _asyncToGenerator$1(/*#__PURE__*/_regenerator().m(function _callee4(options) {
|
|
71182
|
-
var _ref4, _ref4$appName, appName, permissionKeysOption, rootSelector, onInitCache, render, _ref4$standaloneError, standaloneErrorMessage, _ref4$fetchConfigFrom, fetchConfigFromShell, _ref4$configFallbackU, configFallbackUri, validateAppConfig, _ref4$permissionsOnly, permissionsOnlyIfArray, _ref4$autoSendAppEnv, autoSendAppEnv, toolkitEnv, _ref4$mihelpAgentProp, mihelpAgentProps, _ref4$installNavGuard, installNavGuard, rootNode, bridge, fetcher, storage, getInitialUri, getInitData, setInitCache, setExtraLocal, sendStorageGet, setAppName, sendAppEnv, resolveAppAuthName, _yield$Promise$all, _yield$Promise$all2, initialUri, initData, getCachedLocalItem, appAuthName, permissionKeys, tasks, _t;
|
|
71511
|
+
var _ref4, _ref4$appName, appName, permissionKeysOption, rootSelector, onInitCache, render, _ref4$standaloneError, standaloneErrorMessage, _ref4$fetchConfigFrom, fetchConfigFromShell, _ref4$configFallbackU, configFallbackUri, validateAppConfig, _ref4$permissionsOnly, permissionsOnlyIfArray, _ref4$autoSendAppEnv, autoSendAppEnv, toolkitEnv, _ref4$mihelpAgentProp, mihelpAgentProps, _ref4$installNavGuard, installNavGuard, rootNode, bridge, fetcher, storage, getInitialUri, getInitData, setInitCache, setExtraLocal, sendStorageGet, setAppName, sendAppEnv, resolveAppAuthName, getShellOrigin, getHandshakeDiagnostics, _yield$Promise$all, _yield$Promise$all2, initialUri, initData, getCachedLocalItem, appAuthName, permissionKeys, tasks, _t;
|
|
71183
71512
|
return _regenerator().w(function (_context4) {
|
|
71184
71513
|
while (1) switch (_context4.p = _context4.n) {
|
|
71185
71514
|
case 0:
|
|
@@ -71214,7 +71543,12 @@ function _bootstrapIframeApp() {
|
|
|
71214
71543
|
installNavigationGuard();
|
|
71215
71544
|
}
|
|
71216
71545
|
bridge = iframeFacade.bridge, fetcher = iframeFacade.fetcher, storage = iframeFacade.storage;
|
|
71217
|
-
getInitialUri = bridge.getInitialUri, getInitData = bridge.getInitData, setInitCache = bridge.setInitCache, setExtraLocal = bridge.setExtraLocal, sendStorageGet = bridge.sendStorageGet, setAppName = bridge.setAppName, sendAppEnv = bridge.sendAppEnv, resolveAppAuthName = bridge.resolveAppAuthName;
|
|
71546
|
+
getInitialUri = bridge.getInitialUri, getInitData = bridge.getInitData, setInitCache = bridge.setInitCache, setExtraLocal = bridge.setExtraLocal, sendStorageGet = bridge.sendStorageGet, setAppName = bridge.setAppName, sendAppEnv = bridge.sendAppEnv, resolveAppAuthName = bridge.resolveAppAuthName, getShellOrigin = bridge.getShellOrigin, getHandshakeDiagnostics = bridge.getHandshakeDiagnostics;
|
|
71547
|
+
console.info('[Iframe] bootstrap start', {
|
|
71548
|
+
appName: appName,
|
|
71549
|
+
appOrigin: typeof window !== 'undefined' ? window.location.origin : null,
|
|
71550
|
+
diagnostics: typeof getHandshakeDiagnostics === 'function' ? getHandshakeDiagnostics() : null
|
|
71551
|
+
});
|
|
71218
71552
|
_context4.n = 4;
|
|
71219
71553
|
return Promise.all([getInitialUri(), getInitData()]);
|
|
71220
71554
|
case 4:
|
|
@@ -71232,10 +71566,20 @@ function _bootstrapIframeApp() {
|
|
|
71232
71566
|
}
|
|
71233
71567
|
setInitCache(initData);
|
|
71234
71568
|
if (onInitCache) onInitCache(initData);
|
|
71569
|
+
console.info('[Iframe] bootstrap ready', {
|
|
71570
|
+
appName: appName,
|
|
71571
|
+
initialUri: initialUri,
|
|
71572
|
+
shellOrigin: typeof getShellOrigin === 'function' ? getShellOrigin() : null
|
|
71573
|
+
});
|
|
71235
71574
|
_context4.n = 6;
|
|
71236
71575
|
break;
|
|
71237
71576
|
case 5:
|
|
71238
|
-
console.error('[Iframe] failed to get initData from shell (handshake timeout)'
|
|
71577
|
+
console.error('[Iframe] failed to get initData from shell (handshake timeout)', {
|
|
71578
|
+
appName: appName,
|
|
71579
|
+
initialUri: initialUri,
|
|
71580
|
+
shellOrigin: typeof getShellOrigin === 'function' ? getShellOrigin() : null,
|
|
71581
|
+
diagnostics: typeof getHandshakeDiagnostics === 'function' ? getHandshakeDiagnostics() : null
|
|
71582
|
+
});
|
|
71239
71583
|
renderStandaloneError(rootNode, 'Failed to connect to the portal. Please refresh.');
|
|
71240
71584
|
return _context4.a(2);
|
|
71241
71585
|
case 6:
|