@wooksjs/event-wf 0.7.12 → 0.7.14
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/dist/index.cjs +17 -6
- package/dist/index.mjs +17 -6
- package/package.json +10 -10
package/dist/index.cjs
CHANGED
|
@@ -146,6 +146,7 @@ async function handleWfOutletRequest(config, deps) {
|
|
|
146
146
|
const input = body?.input;
|
|
147
147
|
const resolveStrategy = (id) => typeof config.state === "function" ? config.state(id) : config.state;
|
|
148
148
|
let output;
|
|
149
|
+
let strategyReResolved = false;
|
|
149
150
|
if (token) {
|
|
150
151
|
const strategy = resolveStrategy(wfid ?? "");
|
|
151
152
|
ctx.set(stateStrategyKey, strategy);
|
|
@@ -156,7 +157,10 @@ async function handleWfOutletRequest(config, deps) {
|
|
|
156
157
|
}
|
|
157
158
|
if (state.schemaId !== (wfid ?? "")) {
|
|
158
159
|
const realStrategy = resolveStrategy(state.schemaId);
|
|
159
|
-
|
|
160
|
+
if (realStrategy !== strategy) {
|
|
161
|
+
ctx.set(stateStrategyKey, realStrategy);
|
|
162
|
+
strategyReResolved = true;
|
|
163
|
+
}
|
|
160
164
|
}
|
|
161
165
|
output = await deps.resume(state, {
|
|
162
166
|
input,
|
|
@@ -212,7 +216,8 @@ async function handleWfOutletRequest(config, deps) {
|
|
|
212
216
|
...output.state,
|
|
213
217
|
meta: { outlet: outletReq.outlet }
|
|
214
218
|
};
|
|
215
|
-
const
|
|
219
|
+
const reuseHandle = token && !strategyReResolved ? { handle: token } : void 0;
|
|
220
|
+
const newToken = await strategy.persist(stateWithMeta, output.expires ? { ttl: output.expires - Date.now() } : void 0, reuseHandle);
|
|
216
221
|
const outOfBand = outletHandler.tokenDelivery === "out-of-band";
|
|
217
222
|
if (tokenWrite === "cookie" && !outOfBand) response.setCookie(tokenName, newToken, {
|
|
218
223
|
httpOnly: true,
|
|
@@ -316,7 +321,7 @@ function createOutletHandler(wfApp) {
|
|
|
316
321
|
}
|
|
317
322
|
|
|
318
323
|
//#endregion
|
|
319
|
-
//#region node_modules/.pnpm/@prostojs+wf@0.2.
|
|
324
|
+
//#region node_modules/.pnpm/@prostojs+wf@0.2.1/node_modules/@prostojs/wf/dist/outlets/index.mjs
|
|
320
325
|
/**
|
|
321
326
|
* Generic outlet request. Use for custom outlets.
|
|
322
327
|
*
|
|
@@ -408,11 +413,17 @@ var EncapsulatedStateStrategy = class {
|
|
|
408
413
|
}
|
|
409
414
|
/**
|
|
410
415
|
* Encrypt workflow state into a self-contained token.
|
|
416
|
+
*
|
|
417
|
+
* NOTE: the `overrides.handle` hint from `WfStateStrategy` is silently
|
|
418
|
+
* ignored — the encapsulated token IS the ciphertext of the state, so a
|
|
419
|
+
* fixed handle cannot map to changing state. Callers that need handle
|
|
420
|
+
* stability across calls must use `HandleStateStrategy`.
|
|
421
|
+
*
|
|
411
422
|
* @param state — workflow state to persist
|
|
412
423
|
* @param options.ttl — time-to-live in ms (overrides defaultTtl)
|
|
413
424
|
* @returns base64url-encoded encrypted token
|
|
414
425
|
*/
|
|
415
|
-
async persist(state, options) {
|
|
426
|
+
async persist(state, options, _overrides) {
|
|
416
427
|
const ttl = options?.ttl ?? this.config.defaultTtl ?? 0;
|
|
417
428
|
const exp = ttl > 0 ? Date.now() + ttl : 0;
|
|
418
429
|
const payload = JSON.stringify({
|
|
@@ -466,8 +477,8 @@ var HandleStateStrategy = class {
|
|
|
466
477
|
constructor(config) {
|
|
467
478
|
this.config = config;
|
|
468
479
|
}
|
|
469
|
-
async persist(state, options) {
|
|
470
|
-
const handle = (this.config.generateHandle ?? node_crypto.randomUUID)();
|
|
480
|
+
async persist(state, options, overrides) {
|
|
481
|
+
const handle = overrides?.handle ?? (this.config.generateHandle ?? node_crypto.randomUUID)();
|
|
471
482
|
const ttl = options?.ttl ?? this.config.defaultTtl ?? 0;
|
|
472
483
|
const expiresAt = ttl > 0 ? Date.now() + ttl : void 0;
|
|
473
484
|
await this.config.store.set(handle, state, expiresAt);
|
package/dist/index.mjs
CHANGED
|
@@ -145,6 +145,7 @@ async function handleWfOutletRequest(config, deps) {
|
|
|
145
145
|
const input = body?.input;
|
|
146
146
|
const resolveStrategy = (id) => typeof config.state === "function" ? config.state(id) : config.state;
|
|
147
147
|
let output;
|
|
148
|
+
let strategyReResolved = false;
|
|
148
149
|
if (token) {
|
|
149
150
|
const strategy = resolveStrategy(wfid ?? "");
|
|
150
151
|
ctx.set(stateStrategyKey, strategy);
|
|
@@ -155,7 +156,10 @@ async function handleWfOutletRequest(config, deps) {
|
|
|
155
156
|
}
|
|
156
157
|
if (state.schemaId !== (wfid ?? "")) {
|
|
157
158
|
const realStrategy = resolveStrategy(state.schemaId);
|
|
158
|
-
|
|
159
|
+
if (realStrategy !== strategy) {
|
|
160
|
+
ctx.set(stateStrategyKey, realStrategy);
|
|
161
|
+
strategyReResolved = true;
|
|
162
|
+
}
|
|
159
163
|
}
|
|
160
164
|
output = await deps.resume(state, {
|
|
161
165
|
input,
|
|
@@ -211,7 +215,8 @@ async function handleWfOutletRequest(config, deps) {
|
|
|
211
215
|
...output.state,
|
|
212
216
|
meta: { outlet: outletReq.outlet }
|
|
213
217
|
};
|
|
214
|
-
const
|
|
218
|
+
const reuseHandle = token && !strategyReResolved ? { handle: token } : void 0;
|
|
219
|
+
const newToken = await strategy.persist(stateWithMeta, output.expires ? { ttl: output.expires - Date.now() } : void 0, reuseHandle);
|
|
215
220
|
const outOfBand = outletHandler.tokenDelivery === "out-of-band";
|
|
216
221
|
if (tokenWrite === "cookie" && !outOfBand) response.setCookie(tokenName, newToken, {
|
|
217
222
|
httpOnly: true,
|
|
@@ -315,7 +320,7 @@ function createOutletHandler(wfApp) {
|
|
|
315
320
|
}
|
|
316
321
|
|
|
317
322
|
//#endregion
|
|
318
|
-
//#region node_modules/.pnpm/@prostojs+wf@0.2.
|
|
323
|
+
//#region node_modules/.pnpm/@prostojs+wf@0.2.1/node_modules/@prostojs/wf/dist/outlets/index.mjs
|
|
319
324
|
/**
|
|
320
325
|
* Generic outlet request. Use for custom outlets.
|
|
321
326
|
*
|
|
@@ -407,11 +412,17 @@ var EncapsulatedStateStrategy = class {
|
|
|
407
412
|
}
|
|
408
413
|
/**
|
|
409
414
|
* Encrypt workflow state into a self-contained token.
|
|
415
|
+
*
|
|
416
|
+
* NOTE: the `overrides.handle` hint from `WfStateStrategy` is silently
|
|
417
|
+
* ignored — the encapsulated token IS the ciphertext of the state, so a
|
|
418
|
+
* fixed handle cannot map to changing state. Callers that need handle
|
|
419
|
+
* stability across calls must use `HandleStateStrategy`.
|
|
420
|
+
*
|
|
410
421
|
* @param state — workflow state to persist
|
|
411
422
|
* @param options.ttl — time-to-live in ms (overrides defaultTtl)
|
|
412
423
|
* @returns base64url-encoded encrypted token
|
|
413
424
|
*/
|
|
414
|
-
async persist(state, options) {
|
|
425
|
+
async persist(state, options, _overrides) {
|
|
415
426
|
const ttl = options?.ttl ?? this.config.defaultTtl ?? 0;
|
|
416
427
|
const exp = ttl > 0 ? Date.now() + ttl : 0;
|
|
417
428
|
const payload = JSON.stringify({
|
|
@@ -465,8 +476,8 @@ var HandleStateStrategy = class {
|
|
|
465
476
|
constructor(config) {
|
|
466
477
|
this.config = config;
|
|
467
478
|
}
|
|
468
|
-
async persist(state, options) {
|
|
469
|
-
const handle = (this.config.generateHandle ?? randomUUID)();
|
|
479
|
+
async persist(state, options, overrides) {
|
|
480
|
+
const handle = overrides?.handle ?? (this.config.generateHandle ?? randomUUID)();
|
|
470
481
|
const ttl = options?.ttl ?? this.config.defaultTtl ?? 0;
|
|
471
482
|
const expiresAt = ttl > 0 ? Date.now() + ttl : void 0;
|
|
472
483
|
await this.config.store.set(handle, state, expiresAt);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@wooksjs/event-wf",
|
|
3
|
-
"version": "0.7.
|
|
3
|
+
"version": "0.7.14",
|
|
4
4
|
"description": "@wooksjs/event-wf",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"app",
|
|
@@ -37,22 +37,22 @@
|
|
|
37
37
|
}
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@prostojs/wf": "^0.2.
|
|
40
|
+
"@prostojs/wf": "^0.2.1"
|
|
41
41
|
},
|
|
42
42
|
"devDependencies": {
|
|
43
43
|
"typescript": "^5.9.3",
|
|
44
44
|
"vitest": "^3.2.4",
|
|
45
|
-
"@wooksjs/event-
|
|
46
|
-
"
|
|
47
|
-
"@wooksjs/http-body": "^0.7.
|
|
48
|
-
"
|
|
45
|
+
"@wooksjs/event-http": "^0.7.14",
|
|
46
|
+
"wooks": "^0.7.14",
|
|
47
|
+
"@wooksjs/http-body": "^0.7.14",
|
|
48
|
+
"@wooksjs/event-core": "^0.7.14"
|
|
49
49
|
},
|
|
50
50
|
"peerDependencies": {
|
|
51
51
|
"@prostojs/logger": "^0.4.3",
|
|
52
|
-
"@wooksjs/event-core": "^0.7.
|
|
53
|
-
"@wooksjs/http
|
|
54
|
-
"wooks": "^0.7.
|
|
55
|
-
"@wooksjs/
|
|
52
|
+
"@wooksjs/event-core": "^0.7.14",
|
|
53
|
+
"@wooksjs/event-http": "^0.7.14",
|
|
54
|
+
"wooks": "^0.7.14",
|
|
55
|
+
"@wooksjs/http-body": "^0.7.14"
|
|
56
56
|
},
|
|
57
57
|
"peerDependenciesMeta": {
|
|
58
58
|
"@wooksjs/event-http": {
|