@walkeros/core 4.3.0-next-1783710078012 → 4.3.0-next-1784055686454
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/CHANGELOG.md +7 -1
- package/dist/index.d.mts +166 -1
- package/dist/index.d.ts +166 -1
- package/dist/index.js +1 -1
- package/dist/index.js.map +1 -1
- package/dist/index.mjs +1 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# @walkeros/core
|
|
2
2
|
|
|
3
|
-
## 4.3.0-next-
|
|
3
|
+
## 4.3.0-next-1784055686454
|
|
4
4
|
|
|
5
5
|
### Minor Changes
|
|
6
6
|
|
|
@@ -19,6 +19,12 @@
|
|
|
19
19
|
to agents. Batching destinations now emit per-event records, and live-web
|
|
20
20
|
vendor calls are captured when a destination reaches its callable through
|
|
21
21
|
`getEnv`, though batched sends stay uncaptured.
|
|
22
|
+
- f8408fd: Preview links are now app-signed and bound to your site's origin,
|
|
23
|
+
verified locally in the bundle with no server round trip. Bundles that support
|
|
24
|
+
preview activation import a new `browserSwapActivator` from `@walkeros/core`.
|
|
25
|
+
The CLI wrap step's `preview` option replaces `previewOrigin`/`previewScope`,
|
|
26
|
+
and a new `previewGrantTargets` option lets a preview forward its grant to
|
|
27
|
+
server-bound destinations too.
|
|
22
28
|
- 9506e3e: Events now carry per-flow config provenance on
|
|
23
29
|
`event.source.release`, a flow-name to release map that accumulates as an
|
|
24
30
|
event crosses flows (web capture to server processing), so a delivered event
|
package/dist/index.d.mts
CHANGED
|
@@ -4323,6 +4323,171 @@ interface ResolveTelemetryInput {
|
|
|
4323
4323
|
*/
|
|
4324
4324
|
declare function resolveTelemetryOptions(input: ResolveTelemetryInput): TelemetryOptions | null;
|
|
4325
4325
|
|
|
4326
|
+
/** Claims carried by an activation grant. See the preview-sessions design spec. */
|
|
4327
|
+
interface ActivationGrant {
|
|
4328
|
+
/** Issuing environment, e.g. 'app:stage'. Verifier rejects a foreign issuer. */
|
|
4329
|
+
iss: string;
|
|
4330
|
+
/** Exact origins this grant may activate on. Exact-membership match only. */
|
|
4331
|
+
aud: string[];
|
|
4332
|
+
/** Issue time, epoch seconds. The URL window is enforced against this. */
|
|
4333
|
+
iat: number;
|
|
4334
|
+
/** Session expiry, epoch seconds. Storage-sourced grants are rejected after it. */
|
|
4335
|
+
sxp: number;
|
|
4336
|
+
/** Opaque artifact id: the preview bundle is `preview/<art>.js`. */
|
|
4337
|
+
art: string;
|
|
4338
|
+
/** Subresource integrity of the artifact bytes, e.g. 'sha384-…'. */
|
|
4339
|
+
sri: string;
|
|
4340
|
+
/** Opaque per-project binding. Must equal the value baked into the host bundle. */
|
|
4341
|
+
pb: string;
|
|
4342
|
+
/** Capability. Only 'activate' exists today. */
|
|
4343
|
+
cap: 'activate';
|
|
4344
|
+
/** Per-grant unique id, for audit and revocation. */
|
|
4345
|
+
jti: string;
|
|
4346
|
+
/** Preview id, for correlation. Never a project id. */
|
|
4347
|
+
pid: string;
|
|
4348
|
+
/** Session id, present only on cross-part (web+server) grants. */
|
|
4349
|
+
ses?: string;
|
|
4350
|
+
/** Opaque per-session binding. Present iff `ses` is. */
|
|
4351
|
+
sb?: string;
|
|
4352
|
+
}
|
|
4353
|
+
type PreviewFailure = 'no-grant' | 'malformed' | 'kid-mismatch' | 'bad-signature' | 'foreign-issuer' | 'expired' | 'aud-mismatch' | 'pb-mismatch' | 'sb-mismatch' | 'cap-mismatch' | 'no-subtle' | 'swap-failed';
|
|
4354
|
+
interface ParsedGrant {
|
|
4355
|
+
grant: ActivationGrant;
|
|
4356
|
+
kid: string;
|
|
4357
|
+
/** The exact bytes covered by the signature: `${header}.${payload}` as UTF-8. */
|
|
4358
|
+
signed: Uint8Array;
|
|
4359
|
+
/** Raw r‖s signature, 64 bytes. */
|
|
4360
|
+
signature: Uint8Array;
|
|
4361
|
+
}
|
|
4362
|
+
type VerifyResult = {
|
|
4363
|
+
ok: true;
|
|
4364
|
+
grant: ActivationGrant;
|
|
4365
|
+
} | {
|
|
4366
|
+
ok: false;
|
|
4367
|
+
reason: PreviewFailure;
|
|
4368
|
+
};
|
|
4369
|
+
/**
|
|
4370
|
+
* Parse a compact JWS activation grant. Pure and synchronous: this is the cheap
|
|
4371
|
+
* gate that runs before any crypto is touched. Returns null on anything
|
|
4372
|
+
* malformed: callers treat null as "ignore, do not clear existing state".
|
|
4373
|
+
*/
|
|
4374
|
+
declare function parseGrant(raw: string): ParsedGrant | null;
|
|
4375
|
+
/** A public key a bundle or container will accept grants from. */
|
|
4376
|
+
interface PreviewKey {
|
|
4377
|
+
kid: string;
|
|
4378
|
+
/** base64url-encoded P-256 SPKI. */
|
|
4379
|
+
spki: string;
|
|
4380
|
+
}
|
|
4381
|
+
type PreviewBinary = ArrayBuffer | ArrayBufferView;
|
|
4382
|
+
/**
|
|
4383
|
+
* Structural slice of WebCrypto used by the verifier. Core compiles without
|
|
4384
|
+
* the DOM lib, so the ambient `Crypto` type is unavailable here: a structural
|
|
4385
|
+
* type also lets tests inject `node:crypto`'s webcrypto without casts and lets
|
|
4386
|
+
* `{}` model a subtle-less environment (same pattern as batchedPoster's
|
|
4387
|
+
* PosterFetch).
|
|
4388
|
+
*/
|
|
4389
|
+
interface PreviewSubtle {
|
|
4390
|
+
importKey(format: 'spki', keyData: PreviewBinary, algorithm: {
|
|
4391
|
+
name: string;
|
|
4392
|
+
namedCurve: string;
|
|
4393
|
+
}, extractable: boolean, keyUsages: string[]): Promise<unknown>;
|
|
4394
|
+
verify(algorithm: {
|
|
4395
|
+
name: string;
|
|
4396
|
+
hash: string;
|
|
4397
|
+
}, key: unknown, signature: PreviewBinary, data: PreviewBinary): Promise<boolean>;
|
|
4398
|
+
}
|
|
4399
|
+
interface PreviewCrypto {
|
|
4400
|
+
subtle?: PreviewSubtle;
|
|
4401
|
+
}
|
|
4402
|
+
/**
|
|
4403
|
+
* The two real callers of `verifyActivation` bind audience differently: the
|
|
4404
|
+
* web loader always has a page origin and checks `aud` against it, while a
|
|
4405
|
+
* container has no origin at all and is bound to one session instead. A
|
|
4406
|
+
* discriminated union (rather than an optional `origin`) turns "the caller
|
|
4407
|
+
* forgot `origin`" from a silent aud-check skip into a compile error on the
|
|
4408
|
+
* web arm; `expectSession` is forced on the container arm for the same
|
|
4409
|
+
* reason, since that arm's whole job is proving it checked *something*.
|
|
4410
|
+
*/
|
|
4411
|
+
type VerifyAudience = {
|
|
4412
|
+
origin: string;
|
|
4413
|
+
expectSession?: undefined;
|
|
4414
|
+
} | {
|
|
4415
|
+
origin?: undefined;
|
|
4416
|
+
expectSession: {
|
|
4417
|
+
ses: string;
|
|
4418
|
+
sb: string;
|
|
4419
|
+
};
|
|
4420
|
+
};
|
|
4421
|
+
type VerifyParams = VerifyAudience & {
|
|
4422
|
+
/** Keys this host accepts. Current + previous, so rotation is non-disruptive. */
|
|
4423
|
+
keyring: PreviewKey[];
|
|
4424
|
+
/** Expected issuer, e.g. 'app:stage'. */
|
|
4425
|
+
iss: string;
|
|
4426
|
+
/** This host's baked project binding. Required unless `acceptForeign`. */
|
|
4427
|
+
pb?: string;
|
|
4428
|
+
/** Demo hosts only: skip the pb match, require aud to be a single allowlisted origin. */
|
|
4429
|
+
acceptForeign?: boolean;
|
|
4430
|
+
demoAllowlist?: string[];
|
|
4431
|
+
/** Which clock applies: the URL handover window, or the session expiry. */
|
|
4432
|
+
source: 'url' | 'storage';
|
|
4433
|
+
/** Epoch milliseconds. Injected so tests and the server control the clock. */
|
|
4434
|
+
now: number;
|
|
4435
|
+
/** Defaults to globalThis.crypto. Injectable for jsdom/node tests. */
|
|
4436
|
+
crypto?: PreviewCrypto;
|
|
4437
|
+
};
|
|
4438
|
+
/** A grant handed over in a URL is only accepted this long after `iat`. */
|
|
4439
|
+
declare const URL_WINDOW_MS: number;
|
|
4440
|
+
/**
|
|
4441
|
+
* How far a grant's `iat` may sit in the future and still count as ordinary
|
|
4442
|
+
* clock skew rather than a broken or hostile mint clock (RFC 7519 §4.1.5
|
|
4443
|
+
* iat/nbf practice: reject a token issued in the future, with tolerance).
|
|
4444
|
+
*/
|
|
4445
|
+
declare const CLOCK_SKEW_MS: number;
|
|
4446
|
+
/**
|
|
4447
|
+
* Verifier-side ceiling on `sxp - iat`, independent of whatever the mint's
|
|
4448
|
+
* clock claims. The design spec's session TTL is a 60-minute ceiling
|
|
4449
|
+
* (`sxp = min(iat + 60 min, session remaining)`); this adds a modest margin
|
|
4450
|
+
* above that so a legitimate boundary-exact grant is never rejected by
|
|
4451
|
+
* rounding, while still bounding how long a leaked grant stays usable if a
|
|
4452
|
+
* mint clock is skewed or wrong.
|
|
4453
|
+
*/
|
|
4454
|
+
declare const MAX_SESSION_MS: number;
|
|
4455
|
+
/**
|
|
4456
|
+
* Verify an activation grant locally: no network, no DB, the signature plus
|
|
4457
|
+
* the baked bindings carry the whole decision.
|
|
4458
|
+
*
|
|
4459
|
+
* Claim checks run before the signature check so a hostile or malformed
|
|
4460
|
+
* value costs almost nothing, but `ok: true` is only ever reached after the
|
|
4461
|
+
* ES256 verify succeeds: no unsigned claim value is trusted on its own, it
|
|
4462
|
+
* only ever decides which rejection reason comes back.
|
|
4463
|
+
*/
|
|
4464
|
+
declare function verifyActivation(raw: string, params: VerifyParams): Promise<VerifyResult>;
|
|
4465
|
+
interface SwapActivatorConfig {
|
|
4466
|
+
keyring: PreviewKey[];
|
|
4467
|
+
iss: string;
|
|
4468
|
+
/** This bundle's project binding. Absent on demo hosts (see acceptForeign). */
|
|
4469
|
+
pb?: string;
|
|
4470
|
+
acceptForeign?: boolean;
|
|
4471
|
+
demoAllowlist?: string[];
|
|
4472
|
+
/** Bare CDN hostname, e.g. 'cdn.walkeros.io'. */
|
|
4473
|
+
previewOrigin: string;
|
|
4474
|
+
/** Injectable for tests. */
|
|
4475
|
+
now?: () => number;
|
|
4476
|
+
crypto?: PreviewCrypto;
|
|
4477
|
+
}
|
|
4478
|
+
/**
|
|
4479
|
+
* Decide whether a preview bundle should boot in place of this bundle's own flow.
|
|
4480
|
+
*
|
|
4481
|
+
* Returns true iff a preview took over, in which case the caller must not boot
|
|
4482
|
+
* the production flow. Every failure path deterministically returns false: the
|
|
4483
|
+
* loader never throws, never retries, and never leaves a page without a walker.
|
|
4484
|
+
*
|
|
4485
|
+
* Anti-griefing invariant: a rejected URL grant never touches stored state,
|
|
4486
|
+
* the activator falls back to the stored grant instead. Only a failing stored
|
|
4487
|
+
* grant clears storage (self-heal), plus `off` and `swap-failed`.
|
|
4488
|
+
*/
|
|
4489
|
+
declare function browserSwapActivator(cfg: SwapActivatorConfig): Promise<boolean>;
|
|
4490
|
+
|
|
4326
4491
|
/**
|
|
4327
4492
|
* Pure assembly of raw `FlowState` records into cross-runtime journeys. The
|
|
4328
4493
|
* function is idempotent (duplicate records are deduped first) and
|
|
@@ -4861,4 +5026,4 @@ declare const REF_CODE_PREFIX = "$code:";
|
|
|
4861
5026
|
*/
|
|
4862
5027
|
declare function scanFlowRefs(value: unknown, into?: Set<string>): Set<string>;
|
|
4863
5028
|
|
|
4864
|
-
export { type AssembleJourneysOptions, type BatchedPosterOptions, type BreakerState, cache as Cache, type CacheEnvelope, type CacheResult, type ClickIdEntry, collector as Collector, type CompiledCache, Const, context as Context, type Credential, type Debounced, destination as Destination, type DestroyContext, type DestroyFn, type DroppedCounters, ENV_MARKER_PREFIX, elb as Elb, type EmitFn, type ExampleSummary, FatalError, Flow, type FlowConfigResolver, type FlowState, type FlowStateBatch, type FlowStatePhase, type FlowStepType, type GetStore, hint as Hint, hooks as Hooks, type Ingest, type IngestMeta, type Journey, type JourneyAssembly, type JourneyBranch, type JourneyCorrelation, type JourneyEntry, type JourneyGap, type JourneyHop, type JourneyHopStatus, type JourneyPlatform, type JourneyStatus, type JourneyTopology, type JourneyTopologyNode, type JsonSchema, Level, lifecycle as Lifecycle, type LifecycleContext, logger as Logger, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, OBSERVE_ENV_KEY, type ObserverFn, on as On, type ParsedTraceparent, type PosterFetch, type PosterResponse, REF_CODE_PREFIX, REF_CONTRACT, REF_ENV, REF_FLOW, REF_SECRET, REF_STORE, REF_VAR_FULL, REF_VAR_INLINE, request as Request, type ResolveContractsOptions, type ResolveOptions, type RespondFn, type RespondOptions, SECRET_MARKER_PREFIX, STEP_OPERATIVE_FIELDS, type ScheduleOptions, type SendDataValue, type SendHeaders, type SendResponse, type ServiceAccount, type SetupFn, simulation as Simulation, source as Source, type State, type StepEntryErrorCode, type StepEntryValidation, type StepKind, type StorageType, store as Store, StoreCodecError, type TelemetryLevel, type TelemetryOptions, type TelemetryOptionsSupplier, transformer as Transformer, trigger as Trigger, type ValidateEvents, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, anonymizeIP, applyState, applyUpdate, assembleJourneys, assign, branch, buildCacheContext, castToProperty, castValue, checkCache, clone, compileCache, compileMatcher, compileState, createBatchedPoster, createDestination, createEvent, createIngest, createLogger, createMockContext, createMockLogger, createRespond, createTelemetryObserver, debounce, deepMerge, defaultClickIds, deleteByPath, deserializeStoreValue, emitStep, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, formatOut, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getNextSteps, getOS, getOSVersion, getPlatform, getSpanId, getTraceId, getTraceUntil, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isEnvObserve, isFunction, isNumber, isObject, isPathStepEntry, isPropertyType, isRouteArray, isRouteConfigEntry, isSameType, isSampled, isStoreValue, isString, mcpError, mcpResult, mergeContractSchemas, mergeMappingRule, mockEnv, packageNameToVariable, parseCallPath, parseTraceparent, parseUserAgent, processEventMapping, readCacheEnvelope, requestToData, requestToParameter, resolveContracts, resolveSetup, resolveTelemetryOptions, scanFlowRefs, serializeStoreValue, setByPath, setTraceUntil, stepId, storeCache, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateStepEntry, walkPath, wrapCacheEnvelope, wrapCondition, wrapFn, wrapValidate };
|
|
5029
|
+
export { type ActivationGrant, type AssembleJourneysOptions, type BatchedPosterOptions, type BreakerState, CLOCK_SKEW_MS, cache as Cache, type CacheEnvelope, type CacheResult, type ClickIdEntry, collector as Collector, type CompiledCache, Const, context as Context, type Credential, type Debounced, destination as Destination, type DestroyContext, type DestroyFn, type DroppedCounters, ENV_MARKER_PREFIX, elb as Elb, type EmitFn, type ExampleSummary, FatalError, Flow, type FlowConfigResolver, type FlowState, type FlowStateBatch, type FlowStatePhase, type FlowStepType, type GetStore, hint as Hint, hooks as Hooks, type Ingest, type IngestMeta, type Journey, type JourneyAssembly, type JourneyBranch, type JourneyCorrelation, type JourneyEntry, type JourneyGap, type JourneyHop, type JourneyHopStatus, type JourneyPlatform, type JourneyStatus, type JourneyTopology, type JourneyTopologyNode, type JsonSchema, Level, lifecycle as Lifecycle, type LifecycleContext, logger as Logger, MAX_SESSION_MS, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, OBSERVE_ENV_KEY, type ObserverFn, on as On, type ParsedGrant, type ParsedTraceparent, type PosterFetch, type PosterResponse, type PreviewCrypto, type PreviewFailure, type PreviewKey, type PreviewSubtle, REF_CODE_PREFIX, REF_CONTRACT, REF_ENV, REF_FLOW, REF_SECRET, REF_STORE, REF_VAR_FULL, REF_VAR_INLINE, request as Request, type ResolveContractsOptions, type ResolveOptions, type RespondFn, type RespondOptions, SECRET_MARKER_PREFIX, STEP_OPERATIVE_FIELDS, type ScheduleOptions, type SendDataValue, type SendHeaders, type SendResponse, type ServiceAccount, type SetupFn, simulation as Simulation, source as Source, type State, type StepEntryErrorCode, type StepEntryValidation, type StepKind, type StorageType, store as Store, StoreCodecError, type SwapActivatorConfig, type TelemetryLevel, type TelemetryOptions, type TelemetryOptionsSupplier, transformer as Transformer, trigger as Trigger, URL_WINDOW_MS, type ValidateEvents, type VerifyParams, type VerifyResult, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, anonymizeIP, applyState, applyUpdate, assembleJourneys, assign, branch, browserSwapActivator, buildCacheContext, castToProperty, castValue, checkCache, clone, compileCache, compileMatcher, compileState, createBatchedPoster, createDestination, createEvent, createIngest, createLogger, createMockContext, createMockLogger, createRespond, createTelemetryObserver, debounce, deepMerge, defaultClickIds, deleteByPath, deserializeStoreValue, emitStep, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, formatOut, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getNextSteps, getOS, getOSVersion, getPlatform, getSpanId, getTraceId, getTraceUntil, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isEnvObserve, isFunction, isNumber, isObject, isPathStepEntry, isPropertyType, isRouteArray, isRouteConfigEntry, isSameType, isSampled, isStoreValue, isString, mcpError, mcpResult, mergeContractSchemas, mergeMappingRule, mockEnv, packageNameToVariable, parseCallPath, parseGrant, parseTraceparent, parseUserAgent, processEventMapping, readCacheEnvelope, requestToData, requestToParameter, resolveContracts, resolveSetup, resolveTelemetryOptions, scanFlowRefs, serializeStoreValue, setByPath, setTraceUntil, stepId, storeCache, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateStepEntry, verifyActivation, walkPath, wrapCacheEnvelope, wrapCondition, wrapFn, wrapValidate };
|
package/dist/index.d.ts
CHANGED
|
@@ -4323,6 +4323,171 @@ interface ResolveTelemetryInput {
|
|
|
4323
4323
|
*/
|
|
4324
4324
|
declare function resolveTelemetryOptions(input: ResolveTelemetryInput): TelemetryOptions | null;
|
|
4325
4325
|
|
|
4326
|
+
/** Claims carried by an activation grant. See the preview-sessions design spec. */
|
|
4327
|
+
interface ActivationGrant {
|
|
4328
|
+
/** Issuing environment, e.g. 'app:stage'. Verifier rejects a foreign issuer. */
|
|
4329
|
+
iss: string;
|
|
4330
|
+
/** Exact origins this grant may activate on. Exact-membership match only. */
|
|
4331
|
+
aud: string[];
|
|
4332
|
+
/** Issue time, epoch seconds. The URL window is enforced against this. */
|
|
4333
|
+
iat: number;
|
|
4334
|
+
/** Session expiry, epoch seconds. Storage-sourced grants are rejected after it. */
|
|
4335
|
+
sxp: number;
|
|
4336
|
+
/** Opaque artifact id: the preview bundle is `preview/<art>.js`. */
|
|
4337
|
+
art: string;
|
|
4338
|
+
/** Subresource integrity of the artifact bytes, e.g. 'sha384-…'. */
|
|
4339
|
+
sri: string;
|
|
4340
|
+
/** Opaque per-project binding. Must equal the value baked into the host bundle. */
|
|
4341
|
+
pb: string;
|
|
4342
|
+
/** Capability. Only 'activate' exists today. */
|
|
4343
|
+
cap: 'activate';
|
|
4344
|
+
/** Per-grant unique id, for audit and revocation. */
|
|
4345
|
+
jti: string;
|
|
4346
|
+
/** Preview id, for correlation. Never a project id. */
|
|
4347
|
+
pid: string;
|
|
4348
|
+
/** Session id, present only on cross-part (web+server) grants. */
|
|
4349
|
+
ses?: string;
|
|
4350
|
+
/** Opaque per-session binding. Present iff `ses` is. */
|
|
4351
|
+
sb?: string;
|
|
4352
|
+
}
|
|
4353
|
+
type PreviewFailure = 'no-grant' | 'malformed' | 'kid-mismatch' | 'bad-signature' | 'foreign-issuer' | 'expired' | 'aud-mismatch' | 'pb-mismatch' | 'sb-mismatch' | 'cap-mismatch' | 'no-subtle' | 'swap-failed';
|
|
4354
|
+
interface ParsedGrant {
|
|
4355
|
+
grant: ActivationGrant;
|
|
4356
|
+
kid: string;
|
|
4357
|
+
/** The exact bytes covered by the signature: `${header}.${payload}` as UTF-8. */
|
|
4358
|
+
signed: Uint8Array;
|
|
4359
|
+
/** Raw r‖s signature, 64 bytes. */
|
|
4360
|
+
signature: Uint8Array;
|
|
4361
|
+
}
|
|
4362
|
+
type VerifyResult = {
|
|
4363
|
+
ok: true;
|
|
4364
|
+
grant: ActivationGrant;
|
|
4365
|
+
} | {
|
|
4366
|
+
ok: false;
|
|
4367
|
+
reason: PreviewFailure;
|
|
4368
|
+
};
|
|
4369
|
+
/**
|
|
4370
|
+
* Parse a compact JWS activation grant. Pure and synchronous: this is the cheap
|
|
4371
|
+
* gate that runs before any crypto is touched. Returns null on anything
|
|
4372
|
+
* malformed: callers treat null as "ignore, do not clear existing state".
|
|
4373
|
+
*/
|
|
4374
|
+
declare function parseGrant(raw: string): ParsedGrant | null;
|
|
4375
|
+
/** A public key a bundle or container will accept grants from. */
|
|
4376
|
+
interface PreviewKey {
|
|
4377
|
+
kid: string;
|
|
4378
|
+
/** base64url-encoded P-256 SPKI. */
|
|
4379
|
+
spki: string;
|
|
4380
|
+
}
|
|
4381
|
+
type PreviewBinary = ArrayBuffer | ArrayBufferView;
|
|
4382
|
+
/**
|
|
4383
|
+
* Structural slice of WebCrypto used by the verifier. Core compiles without
|
|
4384
|
+
* the DOM lib, so the ambient `Crypto` type is unavailable here: a structural
|
|
4385
|
+
* type also lets tests inject `node:crypto`'s webcrypto without casts and lets
|
|
4386
|
+
* `{}` model a subtle-less environment (same pattern as batchedPoster's
|
|
4387
|
+
* PosterFetch).
|
|
4388
|
+
*/
|
|
4389
|
+
interface PreviewSubtle {
|
|
4390
|
+
importKey(format: 'spki', keyData: PreviewBinary, algorithm: {
|
|
4391
|
+
name: string;
|
|
4392
|
+
namedCurve: string;
|
|
4393
|
+
}, extractable: boolean, keyUsages: string[]): Promise<unknown>;
|
|
4394
|
+
verify(algorithm: {
|
|
4395
|
+
name: string;
|
|
4396
|
+
hash: string;
|
|
4397
|
+
}, key: unknown, signature: PreviewBinary, data: PreviewBinary): Promise<boolean>;
|
|
4398
|
+
}
|
|
4399
|
+
interface PreviewCrypto {
|
|
4400
|
+
subtle?: PreviewSubtle;
|
|
4401
|
+
}
|
|
4402
|
+
/**
|
|
4403
|
+
* The two real callers of `verifyActivation` bind audience differently: the
|
|
4404
|
+
* web loader always has a page origin and checks `aud` against it, while a
|
|
4405
|
+
* container has no origin at all and is bound to one session instead. A
|
|
4406
|
+
* discriminated union (rather than an optional `origin`) turns "the caller
|
|
4407
|
+
* forgot `origin`" from a silent aud-check skip into a compile error on the
|
|
4408
|
+
* web arm; `expectSession` is forced on the container arm for the same
|
|
4409
|
+
* reason, since that arm's whole job is proving it checked *something*.
|
|
4410
|
+
*/
|
|
4411
|
+
type VerifyAudience = {
|
|
4412
|
+
origin: string;
|
|
4413
|
+
expectSession?: undefined;
|
|
4414
|
+
} | {
|
|
4415
|
+
origin?: undefined;
|
|
4416
|
+
expectSession: {
|
|
4417
|
+
ses: string;
|
|
4418
|
+
sb: string;
|
|
4419
|
+
};
|
|
4420
|
+
};
|
|
4421
|
+
type VerifyParams = VerifyAudience & {
|
|
4422
|
+
/** Keys this host accepts. Current + previous, so rotation is non-disruptive. */
|
|
4423
|
+
keyring: PreviewKey[];
|
|
4424
|
+
/** Expected issuer, e.g. 'app:stage'. */
|
|
4425
|
+
iss: string;
|
|
4426
|
+
/** This host's baked project binding. Required unless `acceptForeign`. */
|
|
4427
|
+
pb?: string;
|
|
4428
|
+
/** Demo hosts only: skip the pb match, require aud to be a single allowlisted origin. */
|
|
4429
|
+
acceptForeign?: boolean;
|
|
4430
|
+
demoAllowlist?: string[];
|
|
4431
|
+
/** Which clock applies: the URL handover window, or the session expiry. */
|
|
4432
|
+
source: 'url' | 'storage';
|
|
4433
|
+
/** Epoch milliseconds. Injected so tests and the server control the clock. */
|
|
4434
|
+
now: number;
|
|
4435
|
+
/** Defaults to globalThis.crypto. Injectable for jsdom/node tests. */
|
|
4436
|
+
crypto?: PreviewCrypto;
|
|
4437
|
+
};
|
|
4438
|
+
/** A grant handed over in a URL is only accepted this long after `iat`. */
|
|
4439
|
+
declare const URL_WINDOW_MS: number;
|
|
4440
|
+
/**
|
|
4441
|
+
* How far a grant's `iat` may sit in the future and still count as ordinary
|
|
4442
|
+
* clock skew rather than a broken or hostile mint clock (RFC 7519 §4.1.5
|
|
4443
|
+
* iat/nbf practice: reject a token issued in the future, with tolerance).
|
|
4444
|
+
*/
|
|
4445
|
+
declare const CLOCK_SKEW_MS: number;
|
|
4446
|
+
/**
|
|
4447
|
+
* Verifier-side ceiling on `sxp - iat`, independent of whatever the mint's
|
|
4448
|
+
* clock claims. The design spec's session TTL is a 60-minute ceiling
|
|
4449
|
+
* (`sxp = min(iat + 60 min, session remaining)`); this adds a modest margin
|
|
4450
|
+
* above that so a legitimate boundary-exact grant is never rejected by
|
|
4451
|
+
* rounding, while still bounding how long a leaked grant stays usable if a
|
|
4452
|
+
* mint clock is skewed or wrong.
|
|
4453
|
+
*/
|
|
4454
|
+
declare const MAX_SESSION_MS: number;
|
|
4455
|
+
/**
|
|
4456
|
+
* Verify an activation grant locally: no network, no DB, the signature plus
|
|
4457
|
+
* the baked bindings carry the whole decision.
|
|
4458
|
+
*
|
|
4459
|
+
* Claim checks run before the signature check so a hostile or malformed
|
|
4460
|
+
* value costs almost nothing, but `ok: true` is only ever reached after the
|
|
4461
|
+
* ES256 verify succeeds: no unsigned claim value is trusted on its own, it
|
|
4462
|
+
* only ever decides which rejection reason comes back.
|
|
4463
|
+
*/
|
|
4464
|
+
declare function verifyActivation(raw: string, params: VerifyParams): Promise<VerifyResult>;
|
|
4465
|
+
interface SwapActivatorConfig {
|
|
4466
|
+
keyring: PreviewKey[];
|
|
4467
|
+
iss: string;
|
|
4468
|
+
/** This bundle's project binding. Absent on demo hosts (see acceptForeign). */
|
|
4469
|
+
pb?: string;
|
|
4470
|
+
acceptForeign?: boolean;
|
|
4471
|
+
demoAllowlist?: string[];
|
|
4472
|
+
/** Bare CDN hostname, e.g. 'cdn.walkeros.io'. */
|
|
4473
|
+
previewOrigin: string;
|
|
4474
|
+
/** Injectable for tests. */
|
|
4475
|
+
now?: () => number;
|
|
4476
|
+
crypto?: PreviewCrypto;
|
|
4477
|
+
}
|
|
4478
|
+
/**
|
|
4479
|
+
* Decide whether a preview bundle should boot in place of this bundle's own flow.
|
|
4480
|
+
*
|
|
4481
|
+
* Returns true iff a preview took over, in which case the caller must not boot
|
|
4482
|
+
* the production flow. Every failure path deterministically returns false: the
|
|
4483
|
+
* loader never throws, never retries, and never leaves a page without a walker.
|
|
4484
|
+
*
|
|
4485
|
+
* Anti-griefing invariant: a rejected URL grant never touches stored state,
|
|
4486
|
+
* the activator falls back to the stored grant instead. Only a failing stored
|
|
4487
|
+
* grant clears storage (self-heal), plus `off` and `swap-failed`.
|
|
4488
|
+
*/
|
|
4489
|
+
declare function browserSwapActivator(cfg: SwapActivatorConfig): Promise<boolean>;
|
|
4490
|
+
|
|
4326
4491
|
/**
|
|
4327
4492
|
* Pure assembly of raw `FlowState` records into cross-runtime journeys. The
|
|
4328
4493
|
* function is idempotent (duplicate records are deduped first) and
|
|
@@ -4861,4 +5026,4 @@ declare const REF_CODE_PREFIX = "$code:";
|
|
|
4861
5026
|
*/
|
|
4862
5027
|
declare function scanFlowRefs(value: unknown, into?: Set<string>): Set<string>;
|
|
4863
5028
|
|
|
4864
|
-
export { type AssembleJourneysOptions, type BatchedPosterOptions, type BreakerState, cache as Cache, type CacheEnvelope, type CacheResult, type ClickIdEntry, collector as Collector, type CompiledCache, Const, context as Context, type Credential, type Debounced, destination as Destination, type DestroyContext, type DestroyFn, type DroppedCounters, ENV_MARKER_PREFIX, elb as Elb, type EmitFn, type ExampleSummary, FatalError, Flow, type FlowConfigResolver, type FlowState, type FlowStateBatch, type FlowStatePhase, type FlowStepType, type GetStore, hint as Hint, hooks as Hooks, type Ingest, type IngestMeta, type Journey, type JourneyAssembly, type JourneyBranch, type JourneyCorrelation, type JourneyEntry, type JourneyGap, type JourneyHop, type JourneyHopStatus, type JourneyPlatform, type JourneyStatus, type JourneyTopology, type JourneyTopologyNode, type JsonSchema, Level, lifecycle as Lifecycle, type LifecycleContext, logger as Logger, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, OBSERVE_ENV_KEY, type ObserverFn, on as On, type ParsedTraceparent, type PosterFetch, type PosterResponse, REF_CODE_PREFIX, REF_CONTRACT, REF_ENV, REF_FLOW, REF_SECRET, REF_STORE, REF_VAR_FULL, REF_VAR_INLINE, request as Request, type ResolveContractsOptions, type ResolveOptions, type RespondFn, type RespondOptions, SECRET_MARKER_PREFIX, STEP_OPERATIVE_FIELDS, type ScheduleOptions, type SendDataValue, type SendHeaders, type SendResponse, type ServiceAccount, type SetupFn, simulation as Simulation, source as Source, type State, type StepEntryErrorCode, type StepEntryValidation, type StepKind, type StorageType, store as Store, StoreCodecError, type TelemetryLevel, type TelemetryOptions, type TelemetryOptionsSupplier, transformer as Transformer, trigger as Trigger, type ValidateEvents, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, anonymizeIP, applyState, applyUpdate, assembleJourneys, assign, branch, buildCacheContext, castToProperty, castValue, checkCache, clone, compileCache, compileMatcher, compileState, createBatchedPoster, createDestination, createEvent, createIngest, createLogger, createMockContext, createMockLogger, createRespond, createTelemetryObserver, debounce, deepMerge, defaultClickIds, deleteByPath, deserializeStoreValue, emitStep, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, formatOut, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getNextSteps, getOS, getOSVersion, getPlatform, getSpanId, getTraceId, getTraceUntil, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isEnvObserve, isFunction, isNumber, isObject, isPathStepEntry, isPropertyType, isRouteArray, isRouteConfigEntry, isSameType, isSampled, isStoreValue, isString, mcpError, mcpResult, mergeContractSchemas, mergeMappingRule, mockEnv, packageNameToVariable, parseCallPath, parseTraceparent, parseUserAgent, processEventMapping, readCacheEnvelope, requestToData, requestToParameter, resolveContracts, resolveSetup, resolveTelemetryOptions, scanFlowRefs, serializeStoreValue, setByPath, setTraceUntil, stepId, storeCache, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateStepEntry, walkPath, wrapCacheEnvelope, wrapCondition, wrapFn, wrapValidate };
|
|
5029
|
+
export { type ActivationGrant, type AssembleJourneysOptions, type BatchedPosterOptions, type BreakerState, CLOCK_SKEW_MS, cache as Cache, type CacheEnvelope, type CacheResult, type ClickIdEntry, collector as Collector, type CompiledCache, Const, context as Context, type Credential, type Debounced, destination as Destination, type DestroyContext, type DestroyFn, type DroppedCounters, ENV_MARKER_PREFIX, elb as Elb, type EmitFn, type ExampleSummary, FatalError, Flow, type FlowConfigResolver, type FlowState, type FlowStateBatch, type FlowStatePhase, type FlowStepType, type GetStore, hint as Hint, hooks as Hooks, type Ingest, type IngestMeta, type Journey, type JourneyAssembly, type JourneyBranch, type JourneyCorrelation, type JourneyEntry, type JourneyGap, type JourneyHop, type JourneyHopStatus, type JourneyPlatform, type JourneyStatus, type JourneyTopology, type JourneyTopologyNode, type JsonSchema, Level, lifecycle as Lifecycle, type LifecycleContext, logger as Logger, MAX_SESSION_MS, mapping as Mapping, type MarketingParameters, matcher as Matcher, type MockLogger, OBSERVE_ENV_KEY, type ObserverFn, on as On, type ParsedGrant, type ParsedTraceparent, type PosterFetch, type PosterResponse, type PreviewCrypto, type PreviewFailure, type PreviewKey, type PreviewSubtle, REF_CODE_PREFIX, REF_CONTRACT, REF_ENV, REF_FLOW, REF_SECRET, REF_STORE, REF_VAR_FULL, REF_VAR_INLINE, request as Request, type ResolveContractsOptions, type ResolveOptions, type RespondFn, type RespondOptions, SECRET_MARKER_PREFIX, STEP_OPERATIVE_FIELDS, type ScheduleOptions, type SendDataValue, type SendHeaders, type SendResponse, type ServiceAccount, type SetupFn, simulation as Simulation, source as Source, type State, type StepEntryErrorCode, type StepEntryValidation, type StepKind, type StorageType, store as Store, StoreCodecError, type SwapActivatorConfig, type TelemetryLevel, type TelemetryOptions, type TelemetryOptionsSupplier, transformer as Transformer, trigger as Trigger, URL_WINDOW_MS, type ValidateEvents, type VerifyParams, type VerifyResult, walkeros as WalkerOS, type WalkerOSPackage, type WalkerOSPackageInfo, type WalkerOSPackageMeta, anonymizeIP, applyState, applyUpdate, assembleJourneys, assign, branch, browserSwapActivator, buildCacheContext, castToProperty, castValue, checkCache, clone, compileCache, compileMatcher, compileState, createBatchedPoster, createDestination, createEvent, createIngest, createLogger, createMockContext, createMockLogger, createRespond, createTelemetryObserver, debounce, deepMerge, defaultClickIds, deleteByPath, deserializeStoreValue, emitStep, fetchPackage, fetchPackageSchema, filterValues, flattenIncludeSections, formatOut, getBrowser, getBrowserVersion, getByPath, getDeviceType, getEvent, getFlowSettings, getGrantedConsent, getHeaders, getId, getMappingEvent, getMappingValue, getMarketingParameters, getNextSteps, getOS, getOSVersion, getPlatform, getSpanId, getTraceId, getTraceUntil, isArguments, isArray, isBoolean, isCommand, isDefined, isElementOrDocument, isEnvObserve, isFunction, isNumber, isObject, isPathStepEntry, isPropertyType, isRouteArray, isRouteConfigEntry, isSameType, isSampled, isStoreValue, isString, mcpError, mcpResult, mergeContractSchemas, mergeMappingRule, mockEnv, packageNameToVariable, parseCallPath, parseGrant, parseTraceparent, parseUserAgent, processEventMapping, readCacheEnvelope, requestToData, requestToParameter, resolveContracts, resolveSetup, resolveTelemetryOptions, scanFlowRefs, serializeStoreValue, setByPath, setTraceUntil, stepId, storeCache, throttle, throwError, transformData, traverseEnv, trim, tryCatch, tryCatchAsync, useHooks, validateStepEntry, verifyActivation, walkPath, wrapCacheEnvelope, wrapCondition, wrapFn, wrapValidate };
|