@futdevpro/fsm-dynamo 1.11.30 → 1.11.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/.github/workflows/main.yml +158 -173
- package/build/_collections/utils/async.util.d.ts.map +1 -1
- package/build/_collections/utils/async.util.js +5 -3
- package/build/_collections/utils/async.util.js.map +1 -1
- package/build/_modules/crypto/_collections/crypto-2-non-stable.util.d.ts.map +1 -1
- package/build/_modules/crypto/_collections/crypto-2-non-stable.util.js +3 -2
- package/build/_modules/crypto/_collections/crypto-2-non-stable.util.js.map +1 -1
- package/build/_modules/crypto/_collections/crypto.util.d.ts +28 -4
- package/build/_modules/crypto/_collections/crypto.util.d.ts.map +1 -1
- package/build/_modules/crypto/_collections/crypto.util.js +31 -4
- package/build/_modules/crypto/_collections/crypto.util.js.map +1 -1
- package/futdevpro-fsm-dynamo-01.11.32.tgz +0 -0
- package/package.json +5 -4
- package/src/_collections/utils/async.util.ts +9 -3
- package/src/_modules/crypto/_collections/crypto-2-non-stable.util.ts +3 -2
- package/src/_modules/crypto/_collections/crypto.util.ts +33 -16
- package/futdevpro-fsm-dynamo-01.11.30.tgz +0 -0
|
@@ -26,53 +26,75 @@ jobs:
|
|
|
26
26
|
outputs:
|
|
27
27
|
start: ${{ steps.mark_start.outputs.started }}
|
|
28
28
|
steps:
|
|
29
|
-
- uses: actions/checkout@
|
|
29
|
+
- uses: actions/checkout@v4
|
|
30
30
|
- id: mark_start
|
|
31
31
|
run: echo "started=$(date +%s)" >> "$GITHUB_OUTPUT"
|
|
32
|
-
- name:
|
|
33
|
-
uses:
|
|
32
|
+
- name: Send Discord start notification
|
|
33
|
+
uses: futdevpro/fdp-github-actions/discord-start-notification@latest
|
|
34
34
|
with:
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
35
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
36
|
+
APPLICATION_NAME: "Dynamo-FSM"
|
|
37
|
+
APPLICATION_EMOJI: "🧱"
|
|
38
|
+
COMMIT_MESSAGE: ${{ github.event.head_commit.message }}
|
|
39
|
+
EVENT_DATETIME: ${{ github.event.head_commit.timestamp }}
|
|
40
|
+
DISCORD_WEBHOOK_ID: ${{ secrets.DISCORD_WEBHOOK_ID }}
|
|
41
|
+
DISCORD_WEBHOOK_TOKEN: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
|
|
42
|
+
|
|
43
|
+
notification0_fail_report:
|
|
44
|
+
name: Discord Start Notification Fail Report
|
|
45
|
+
runs-on: ubuntu-latest
|
|
46
|
+
#runs-on: plo-koon
|
|
47
|
+
timeout-minutes: 20
|
|
48
|
+
if: always() && needs.notification0.result == 'failure'
|
|
49
|
+
needs: [notification0]
|
|
50
|
+
steps:
|
|
51
|
+
- name: send custom message with args
|
|
52
|
+
uses: appleboy/discord-action@master
|
|
53
|
+
with:
|
|
54
|
+
webhook_id: ${{ secrets.DISCORD_WEBHOOK_ID }}
|
|
55
|
+
webhook_token: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
|
|
56
|
+
message: |
|
|
57
|
+
🧱❌ Failed to send Discord start notification! [🔗](https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }})
|
|
44
58
|
|
|
45
59
|
check_secrets:
|
|
46
|
-
name: Check Required Secrets
|
|
60
|
+
name: Check Required Secrets and Variables
|
|
47
61
|
#runs-on: ubuntu-latest
|
|
48
62
|
runs-on: plo-koon
|
|
49
63
|
timeout-minutes: 20
|
|
50
64
|
steps:
|
|
51
65
|
- name: Check Required Secrets and Variables
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
66
|
+
uses: futdevpro/fdp-github-actions/check-secrets-and-variables@latest
|
|
67
|
+
with:
|
|
68
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
69
|
+
ITEMS_TO_CHECK: |
|
|
70
|
+
[
|
|
71
|
+
{
|
|
72
|
+
"name": "NPM_TOKEN",
|
|
73
|
+
"value": "${{ secrets.NPM_TOKEN }}",
|
|
74
|
+
"type": "SECRET"
|
|
75
|
+
},
|
|
76
|
+
{
|
|
77
|
+
"name": "DISCORD_WEBHOOK_ID",
|
|
78
|
+
"value": "${{ secrets.DISCORD_WEBHOOK_ID }}",
|
|
79
|
+
"type": "SECRET"
|
|
80
|
+
},
|
|
81
|
+
{
|
|
82
|
+
"name": "DISCORD_WEBHOOK_TOKEN",
|
|
83
|
+
"value": "${{ secrets.DISCORD_WEBHOOK_TOKEN }}",
|
|
84
|
+
"type": "SECRET"
|
|
85
|
+
},
|
|
86
|
+
{
|
|
87
|
+
"name": "OVERSEER_SECRET_KEY",
|
|
88
|
+
"value": "${{ secrets.OVERSEER_SECRET_KEY }}",
|
|
89
|
+
"type": "SECRET"
|
|
90
|
+
},
|
|
91
|
+
|
|
92
|
+
{
|
|
93
|
+
"name": "OVERSEER_URL",
|
|
94
|
+
"value": "${{ vars.OVERSEER_URL }}",
|
|
95
|
+
"type": "VARIABLE"
|
|
96
|
+
}
|
|
97
|
+
]
|
|
76
98
|
|
|
77
99
|
check_dev_leftovers:
|
|
78
100
|
name: Check Dev leftovers
|
|
@@ -88,6 +110,7 @@ jobs:
|
|
|
88
110
|
with:
|
|
89
111
|
node-version: '16'
|
|
90
112
|
|
|
113
|
+
# TODO: Check build version (to ALL packages)
|
|
91
114
|
- name: Check build folder
|
|
92
115
|
run: |
|
|
93
116
|
node -e "
|
|
@@ -238,110 +261,62 @@ jobs:
|
|
|
238
261
|
|
|
239
262
|
build_report:
|
|
240
263
|
name: Build Report
|
|
241
|
-
needs: [
|
|
242
|
-
|
|
243
|
-
|
|
264
|
+
needs: [
|
|
265
|
+
notification0,
|
|
266
|
+
check_dev_leftovers,
|
|
267
|
+
test,
|
|
268
|
+
check_version,
|
|
269
|
+
deploy
|
|
270
|
+
]
|
|
271
|
+
#runs-on: ubuntu-latest
|
|
272
|
+
runs-on: plo-koon
|
|
244
273
|
timeout-minutes: 20
|
|
245
274
|
if: always()
|
|
246
275
|
steps:
|
|
276
|
+
|
|
277
|
+
# NEW IMPLEMENTATION using futdevpro/fdp-github-actions/send-build-report@master:
|
|
247
278
|
- name: Checkout code
|
|
248
279
|
uses: actions/checkout@v2
|
|
249
|
-
|
|
250
|
-
- name:
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
run: |
|
|
259
|
-
START_TIME=${{ needs.notification0.outputs.start }}
|
|
260
|
-
END_TIME=$(date +%s)
|
|
261
|
-
DIFF=$((END_TIME - START_TIME))
|
|
262
|
-
echo "human=$(printf '%dm %ds' $((DIFF/60)) $((DIFF%60)))" >> "$GITHUB_OUTPUT"
|
|
263
|
-
|
|
264
|
-
- name: Wait for 30 seconds if overseer is not ready # to avoid sending report while builds and restarts are running
|
|
265
|
-
run: |
|
|
266
|
-
ATTEMPTS=0
|
|
267
|
-
MAX_ATTEMPTS=40
|
|
268
|
-
while true; do
|
|
269
|
-
OVERSEER_READY=$(curl -k -s -w "\n%{http_code}" -X GET ${{ vars.OVERSEER_URL }}/api/server/status --max-time 60)
|
|
270
|
-
HTTP_CODE=$(echo "$OVERSEER_READY" | tail -n1)
|
|
271
|
-
RESPONSE_BODY=$(echo "$OVERSEER_READY" | sed '$d')
|
|
272
|
-
echo "Overseer status check #$((ATTEMPTS+1)): HTTP $HTTP_CODE, response: $RESPONSE_BODY"
|
|
273
|
-
if [ "$HTTP_CODE" = "200" ]; then
|
|
274
|
-
echo "::debug::Overseer is ready"
|
|
275
|
-
break
|
|
276
|
-
fi
|
|
277
|
-
ATTEMPTS=$((ATTEMPTS+1))
|
|
278
|
-
if [ "$ATTEMPTS" -ge "$MAX_ATTEMPTS" ]; then
|
|
279
|
-
echo "::error::Overseer is not ready after 20 minutes, aborting"
|
|
280
|
-
exit 1
|
|
281
|
-
fi
|
|
282
|
-
echo "::warning::Overseer is not ready (HTTP $HTTP_CODE), waiting 1 minute before retrying..."
|
|
283
|
-
sleep 30
|
|
284
|
-
done
|
|
285
|
-
|
|
286
|
-
- name: Send Build Report to Overseer
|
|
287
|
-
run: |
|
|
288
|
-
# Calculate result based on job outcomes
|
|
289
|
-
if [ "${{ needs.check_dev_leftovers.result }}" == "success" ] && [ "${{ needs.check_secrets.result }}" == "success" ] && [ "${{ needs.check_dev_leftovers.result }}" == "success" ] && [ "${{ needs.test.result }}" == "success" ] && [ "${{ needs.check_version.result }}" == "success" ] && [ "${{ needs.deploy.result }}" != "failed" ]; then
|
|
290
|
-
RESULT="success"
|
|
291
|
-
else
|
|
292
|
-
RESULT="failed"
|
|
293
|
-
fi
|
|
294
|
-
|
|
295
|
-
RESPONSE=$(curl -k -s -w "\n%{http_code}" -X POST ${{ vars.OVERSEER_URL }}/api/build-report/new \
|
|
296
|
-
-H "Content-Type: application/json" \
|
|
297
|
-
-H "secret-key: ${{ secrets.OVERSEER_SECRET_KEY }}" \
|
|
298
|
-
-d '{
|
|
299
|
-
"project": "dynamo",
|
|
300
|
-
"system": "dynamo-fsm",
|
|
301
|
-
"version": "${{ env.THIS_VERSION }}",
|
|
302
|
-
"environment": "prod",
|
|
280
|
+
|
|
281
|
+
- name: Send Build Report
|
|
282
|
+
uses: futdevpro/fdp-github-actions/send-build-report@master
|
|
283
|
+
with:
|
|
284
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
285
|
+
SETTINGS: |
|
|
286
|
+
{
|
|
287
|
+
"overseerUrl": "${{ vars.OVERSEER_URL }}",
|
|
288
|
+
"secretKey": "${{ secrets.OVERSEER_SECRET_KEY }}",
|
|
303
289
|
"branch": "${{ github.ref_name }}",
|
|
304
|
-
"
|
|
305
|
-
"
|
|
306
|
-
"
|
|
307
|
-
{
|
|
308
|
-
"step": "Check Required Secrets",
|
|
309
|
-
"result": "${{ needs.check_secrets.result }}",
|
|
310
|
-
"detailedResult": "${{ toJSON(needs.check_secrets.outputs) }}"
|
|
311
|
-
},
|
|
312
|
-
{
|
|
313
|
-
"step": "Check Dev leftovers",
|
|
314
|
-
"result": "${{ needs.check_dev_leftovers.result }}",
|
|
315
|
-
"detailedResult": "${{ needs.check_dev_leftovers.outputs }}"
|
|
316
|
-
},
|
|
317
|
-
{
|
|
318
|
-
"step": "Test Build",
|
|
319
|
-
"result": "${{ needs.test.result }}",
|
|
320
|
-
"detailedResult": "${{ needs.test.outputs }}"
|
|
321
|
-
},
|
|
290
|
+
"linkToAction": "https://github.com/${{ github.repository }}/actions/runs/${{ github.run_id }}",
|
|
291
|
+
"startTime": "${{ needs.notification0.outputs.start }}",
|
|
292
|
+
"projects": [
|
|
322
293
|
{
|
|
323
|
-
"
|
|
324
|
-
"
|
|
325
|
-
|
|
326
|
-
|
|
327
|
-
|
|
328
|
-
|
|
329
|
-
|
|
330
|
-
|
|
294
|
+
"environment": "prod",
|
|
295
|
+
"jobResults": [
|
|
296
|
+
{
|
|
297
|
+
"name": "checkDevLeftovers",
|
|
298
|
+
"result": "${{ needs.check_dev_leftovers.result }}",
|
|
299
|
+
"requirement": "optional"
|
|
300
|
+
},
|
|
301
|
+
{
|
|
302
|
+
"name": "tests",
|
|
303
|
+
"result": "${{ needs.test.result }}",
|
|
304
|
+
"requirement": "required"
|
|
305
|
+
},
|
|
306
|
+
{
|
|
307
|
+
"name": "checkVersion",
|
|
308
|
+
"result": "${{ needs.check_version.result }}",
|
|
309
|
+
"requirement": "required"
|
|
310
|
+
},
|
|
311
|
+
{
|
|
312
|
+
"name": "deploy",
|
|
313
|
+
"result": "${{ needs.deploy.result }}",
|
|
314
|
+
"requirement": "required"
|
|
315
|
+
}
|
|
316
|
+
]
|
|
331
317
|
}
|
|
332
|
-
]
|
|
333
|
-
|
|
334
|
-
}')
|
|
335
|
-
|
|
336
|
-
HTTP_CODE=$(echo "$RESPONSE" | tail -n1)
|
|
337
|
-
RESPONSE_BODY=$(echo "$RESPONSE" | sed '$d')
|
|
338
|
-
|
|
339
|
-
if [ "$HTTP_CODE" != "200" ]; then
|
|
340
|
-
echo "::error::Build Report request failed with HTTP code $HTTP_CODE"
|
|
341
|
-
echo "Response body:"
|
|
342
|
-
echo "$RESPONSE_BODY"
|
|
343
|
-
exit 1
|
|
344
|
-
fi
|
|
318
|
+
]
|
|
319
|
+
}
|
|
345
320
|
|
|
346
321
|
|
|
347
322
|
end:
|
|
@@ -355,50 +330,60 @@ jobs:
|
|
|
355
330
|
deploy,
|
|
356
331
|
build_report
|
|
357
332
|
]
|
|
358
|
-
runs-on: ubuntu-latest
|
|
359
|
-
|
|
333
|
+
#runs-on: ubuntu-latest
|
|
334
|
+
runs-on: plo-koon
|
|
360
335
|
timeout-minutes: 20
|
|
361
336
|
if: always()
|
|
362
337
|
steps:
|
|
363
338
|
- name: Checkout code
|
|
364
|
-
uses: actions/checkout@
|
|
365
|
-
|
|
366
|
-
- name:
|
|
367
|
-
|
|
368
|
-
RAW_THIS_VERSION=$(node -p -e "require('./package.json').version")
|
|
369
|
-
# replace ALL: 'v0' with '', '01' with '1', '.0' with '.'
|
|
370
|
-
RAW_THIS_VERSION=$(echo $RAW_THIS_VERSION | sed 's:v0::g' | sed 's:01:1:g' | sed -e 's:\.0:\.:g')
|
|
371
|
-
echo "THIS_VERSION=$RAW_THIS_VERSION" >> $GITHUB_ENV
|
|
372
|
-
|
|
373
|
-
- uses: actions/checkout@master
|
|
374
|
-
- id: duration
|
|
375
|
-
run: |
|
|
376
|
-
START_TIME=${{ needs.notification0.outputs.start }}
|
|
377
|
-
END_TIME=$(date +%s)
|
|
378
|
-
DIFF=$((END_TIME - START_TIME))
|
|
379
|
-
echo "human=$(printf '%dm %ds' $((DIFF/60)) $((DIFF%60)))" >> "$GITHUB_OUTPUT"
|
|
380
|
-
- name: send custom message with args
|
|
381
|
-
uses: appleboy/discord-action@master
|
|
339
|
+
uses: actions/checkout@v4
|
|
340
|
+
|
|
341
|
+
- name: Send Discord result notification
|
|
342
|
+
uses: futdevpro/fdp-github-actions/discord-result-notification@latest
|
|
382
343
|
with:
|
|
383
|
-
|
|
384
|
-
|
|
385
|
-
|
|
386
|
-
|
|
387
|
-
|
|
388
|
-
|
|
389
|
-
|
|
390
|
-
|
|
391
|
-
|
|
392
|
-
|
|
393
|
-
|
|
394
|
-
|
|
395
|
-
|
|
396
|
-
|
|
397
|
-
|
|
398
|
-
|
|
399
|
-
|
|
400
|
-
|
|
401
|
-
|
|
402
|
-
|
|
344
|
+
NPM_TOKEN: ${{ secrets.NPM_TOKEN }}
|
|
345
|
+
APPLICATION_NAME: "Dynamo-FSM"
|
|
346
|
+
APPLICATION_EMOJI: "🧱"
|
|
347
|
+
BRANCH: ${{ github.ref_name }}
|
|
348
|
+
RUN_NUMBER: ${{ github.run_number }}
|
|
349
|
+
RUN_ID: ${{ github.run_id }}
|
|
350
|
+
REPOSITORY: ${{ github.repository }}
|
|
351
|
+
START_TIME: ${{ needs.notification0.outputs.start }}
|
|
352
|
+
STEPS_CONFIG: |
|
|
353
|
+
[
|
|
354
|
+
{
|
|
355
|
+
"name": "Secrets Check",
|
|
356
|
+
"emoji": "🔑",
|
|
357
|
+
"result": "${{ needs.check_secrets.result }}"
|
|
358
|
+
},
|
|
359
|
+
{
|
|
360
|
+
"name": "Dev Leftovers Check",
|
|
361
|
+
"emoji": "🔍",
|
|
362
|
+
"result": "${{ needs.check_dev_leftovers.result }}"
|
|
363
|
+
},
|
|
364
|
+
{
|
|
365
|
+
"name": "Test Build",
|
|
366
|
+
"emoji": "🧪",
|
|
367
|
+
"result": "${{ needs.test.result }}"
|
|
368
|
+
},
|
|
369
|
+
{
|
|
370
|
+
"name": "Check Version",
|
|
371
|
+
"emoji": "🔍",
|
|
372
|
+
"result": "${{ needs.check_version.result }}"
|
|
373
|
+
},
|
|
374
|
+
{
|
|
375
|
+
"name": "Deploy",
|
|
376
|
+
"emoji": "📦",
|
|
377
|
+
"result": "${{ needs.deploy.result }}",
|
|
378
|
+
"specialSuccessEmoji": "🚀🚀🚀"
|
|
379
|
+
},
|
|
380
|
+
{
|
|
381
|
+
"name": "Build Report",
|
|
382
|
+
"emoji": "📊",
|
|
383
|
+
"result": "${{ needs.build_report.result }}"
|
|
384
|
+
}
|
|
385
|
+
]
|
|
386
|
+
DISCORD_WEBHOOK_ID: ${{ secrets.DISCORD_WEBHOOK_ID }}
|
|
387
|
+
DISCORD_WEBHOOK_TOKEN: ${{ secrets.DISCORD_WEBHOOK_TOKEN }}
|
|
403
388
|
|
|
404
389
|
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async.util.d.ts","sourceRoot":"","sources":["../../../src/_collections/utils/async.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAIlC,qBAAa,UAAU;IAErB;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAGvC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,IAAI,CAAC,KAAK,CAAc;IACtD,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,IAAI,CAAC,KAAK,CAAc;IAErD;;;OAGG;IACH,MAAM,CAAC,SAAS,CACd,KAAK,EAAE,MAAM,OAAO,EACpB,QAAQ,GAAE,MAAY,EACtB,OAAO,GAAE,
|
|
1
|
+
{"version":3,"file":"async.util.d.ts","sourceRoot":"","sources":["../../../src/_collections/utils/async.util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,MAAM,CAAC;AAIlC,qBAAa,UAAU;IAErB;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAGvC,MAAM,CAAC,QAAQ,CAAC,KAAK,EAAE,OAAO,IAAI,CAAC,KAAK,CAAc;IACtD,MAAM,CAAC,QAAQ,CAAC,IAAI,EAAE,OAAO,IAAI,CAAC,KAAK,CAAc;IAErD;;;OAGG;IACH,MAAM,CAAC,SAAS,CACd,KAAK,EAAE,MAAM,OAAO,EACpB,QAAQ,GAAE,MAAY,EACtB,OAAO,GAAE,MAAe,GACvB,OAAO,CAAC,IAAI,CAAC;IAmBhB;;;;;;;;;;OAUG;IACH,MAAM,CAAC,cAAc,CACnB,KAAK,EAAE,MAAM,OAAO,CAAC,OAAO,CAAC,EAC7B,QAAQ,GAAE,MAAY,EACtB,OAAO,GAAE,MAAc,GACtB,OAAO,CAAC,IAAI,CAAC;IAmBhB;;OAEG;IACH,MAAM,CAAC,SAAS,CAAC,CAAC,EAChB,UAAU,EAAE,UAAU,CAAC,CAAC,CAAC,EACzB,KAAK,EAAE,CAAC,KAAK,CAAC,EAAE,CAAC,KAAK,OAAO,GAC5B,OAAO,CAAC,CAAC,CAAC;CAYd"}
|
|
@@ -16,7 +16,8 @@ class DyFM_Async {
|
|
|
16
16
|
* WARNING: This function is recommended to use ONLY for limited instances,
|
|
17
17
|
* because it can cause performance issues.
|
|
18
18
|
*/
|
|
19
|
-
static waitUntil(check, interval = 100, timeout =
|
|
19
|
+
static waitUntil(check, interval = 100, timeout = 10_000) {
|
|
20
|
+
const timeoutError = new Error('waitUntil timeout');
|
|
20
21
|
return new Promise((resolve, reject) => {
|
|
21
22
|
const startTime = Date.now();
|
|
22
23
|
const intervalId = setInterval(() => {
|
|
@@ -26,7 +27,7 @@ class DyFM_Async {
|
|
|
26
27
|
}
|
|
27
28
|
else if (Date.now() - startTime > timeout) {
|
|
28
29
|
clearInterval(intervalId);
|
|
29
|
-
reject(
|
|
30
|
+
reject(timeoutError);
|
|
30
31
|
}
|
|
31
32
|
}, interval);
|
|
32
33
|
});
|
|
@@ -43,6 +44,7 @@ class DyFM_Async {
|
|
|
43
44
|
* );
|
|
44
45
|
*/
|
|
45
46
|
static waitUntilAsync(check, interval = 100, timeout = 10000) {
|
|
47
|
+
const timeoutError = new Error('waitUntilAsync timeout');
|
|
46
48
|
return new Promise((resolve, reject) => {
|
|
47
49
|
const startTime = Date.now();
|
|
48
50
|
const intervalId = setInterval(async () => {
|
|
@@ -52,7 +54,7 @@ class DyFM_Async {
|
|
|
52
54
|
}
|
|
53
55
|
else if (Date.now() - startTime > timeout) {
|
|
54
56
|
clearInterval(intervalId);
|
|
55
|
-
reject(
|
|
57
|
+
reject(timeoutError);
|
|
56
58
|
}
|
|
57
59
|
}, interval);
|
|
58
60
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"async.util.js","sourceRoot":"","sources":["../../../src/_collections/utils/async.util.ts"],"names":[],"mappings":";;;AAIA,MAAa,UAAU;IAErB;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,EAAU;QACrB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAO,EAAE,CAAC,UAAU,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CAAC;IAChE,CAAC;IACD,MAAM,CAAU,KAAK,GAAsB,IAAI,CAAC,KAAK,CAAC;IACtD,MAAM,CAAU,IAAI,GAAsB,IAAI,CAAC,KAAK,CAAC;IAErD;;;OAGG;IACH,MAAM,CAAC,SAAS,CACd,KAAoB,EACpB,WAAmB,GAAG,EACtB,UAAkB,KAAK;
|
|
1
|
+
{"version":3,"file":"async.util.js","sourceRoot":"","sources":["../../../src/_collections/utils/async.util.ts"],"names":[],"mappings":";;;AAIA,MAAa,UAAU;IAErB;;;;OAIG;IACH,MAAM,CAAC,KAAK,CAAC,EAAU;QACrB,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAO,EAA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C;oBAClB,aAAa,CAAC,UAAU,CAAC,CAAC;oBAC1B,OAAO,EAAE,CAAC;gBACZ,CAAC;qBAAM,IAAI,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,GAAG,OAAO,EAAE,CAAC;oBAC5C,aAAa,CAAC,UAAU,CAAC,CAAC;oBAE1B,MAAM,CAAC,YAAY,CAAC,CAAC;gBACvB,CAAC;YACH,CAAC,EAAE,QAAQ,CAAC,CAAC;QACf,CAAC,CAAC,CAAC;IACL,CAAC;IAED;;OAEG;IACH,MAAM,CAAC,SAAS,CACd,UAAyB,EACzB,KAA6B;QAE7B,OAAO,IAAI,OAAO,CAAC,CAAC,OAAO,EAAQ,EAAE;YACnC,MAAM,GAAG,GAAG,UAAU,CAAC,SAAS,CAC9B,CAAC,KAAS,EAAQ,EAAE;gBAClB,IAAI,KAAK,CAAC,KAAK,CAAC,EAAE,CAAC;oBACjB,GAAG,CAAC,WAAW,EAAE,CAAC;oBAClB,OAAO,CAAC,KAAU,CAAC,CAAC;gBACtB,CAAC;YACH,CAAC,CACF,CAAC;QACJ,CAAC,CAAC,CAAC;IACL,CAAC;;AA3FH,gCA4FC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto-2-non-stable.util.d.ts","sourceRoot":"","sources":["../../../../src/_modules/crypto/_collections/crypto-2-non-stable.util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"crypto-2-non-stable.util.d.ts","sourceRoot":"","sources":["../../../../src/_modules/crypto/_collections/crypto-2-non-stable.util.ts"],"names":[],"mappings":"AAQA;;;GAGG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAEY;IAEvD;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,WAAW;IAkB1B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;IAY5B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IA6B9B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,SAAS;IAIxB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,qBAAqB;IAKpC;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,GAAG,MAAM;IA0C/C;;;;;;OAMG;IACH,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,GAAG,CAAC;IAyDxD;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;CAQvC"}
|
|
@@ -4,6 +4,7 @@ exports.DyFM_Crypto = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const CryptoJS = tslib_1.__importStar(require("crypto-js"));
|
|
6
6
|
const error_control_model_1 = require("../../../_models/control-models/error.control-model");
|
|
7
|
+
const object_util_1 = require("../../../_collections/utils/object.util");
|
|
7
8
|
/**
|
|
8
9
|
* A utility class for secure encryption and decryption of data
|
|
9
10
|
* Uses AES-256-CBC with deterministic IV and salt for consistent results
|
|
@@ -50,11 +51,11 @@ class DyFM_Crypto {
|
|
|
50
51
|
*/
|
|
51
52
|
static safeDeserialize(data) {
|
|
52
53
|
try {
|
|
53
|
-
let parsed =
|
|
54
|
+
let parsed = object_util_1.DyFM_Object.failableSafeParseJSON(data);
|
|
54
55
|
// Handle double-stringified JSON
|
|
55
56
|
if (typeof parsed === 'string') {
|
|
56
57
|
try {
|
|
57
|
-
parsed =
|
|
58
|
+
parsed = object_util_1.DyFM_Object.failableSafeParseJSON(parsed);
|
|
58
59
|
}
|
|
59
60
|
catch {
|
|
60
61
|
// If second parse fails, return the string as is
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto-2-non-stable.util.js","sourceRoot":"","sources":["../../../../src/_modules/crypto/_collections/crypto-2-non-stable.util.ts"],"names":[],"mappings":";;;;AAAA,4DAAsC;AACtC,6FAG6D;
|
|
1
|
+
{"version":3,"file":"crypto-2-non-stable.util.js","sourceRoot":"","sources":["../../../../src/_modules/crypto/_collections/crypto-2-non-stable.util.ts"],"names":[],"mappings":";;;;AAAA,4DAAsC;AACtC,6FAG6D;AAC7D,yEAAsE;AAGtE;;;GAGG;AACH,MAAa,WAAW;IACd,MAAM,CAAU,mBAAmB,GACzC,oDAAoD;QACpD,oDAAoD,CAAC;IAEvD;;OAEG;IACK,MAAM,CAAC,WAAW,CAAC,GAAW;QACpC,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;YACpC,MAAM,IAAI,gCAAU,CAAC;gBACnB,MAAM,EAAE,GAAG;gBACX,OAAO,EAAE,iDAAiD;gBAC1D,SAAS,EAAE,kBAAkB;aAC9B,CAAC,CAAC;QACL,CAAC;QAED,IAAI,GAAG,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;YAC5B,MAAM,IAAI,gCAAU,CAAC;gBACnB,MAAM,EAAE,GAAG;gBACX,OAAO,EAAE,mDAAmD;gBAC5D,SAAS,EAAE,oBAAoB;aAChC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,aAAa,CAAI,IAAO;QACrC,IAAI,CAAC;YACH,OAAO,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;QAC9B,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,gCAAU,CAAC;gBACnB,GAAG,IAAI,CAAC,uBAAuB,CAAC,eAAe,EAAE,KAAK,CAAC;gBACvD,SAAS,EAAE,cAAc;gBACzB,OAAO,EAAE,0BAA0B;aACpC,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,eAAe,CAAI,IAAY;QAC5C,IAAI,CAAC;YACH,IAAI,MAAM,GAAG,yBAAW,CAAC,qBAAqB,CAAC,IAAI,CAAC,CAAC;YAErD,iCAAiC;YAC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,CAAC;YAE3D,IAAI,CAAC,YAAY,EAAE,CAAC;gBAClB,MAAM,IAAI,gCAAU,CAAC;oBACnB,MAAM,EAAE,GAAG;oBACX,OAAO,EAAE,wDAAwD;oBACjE,SAAS,EAAE,mBAAmB;iBAC/B,CAAC,CAAC;YACL,CAAC;YAED,OAAO,IAAI,CAAC,eAAe,CAAI,YAAY,CAAC,CAAC;QAC/C,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,IAAI,gCAAU,CAAC;gBACnB,GAAG,IAAI,CAAC,uBAAuB,CAAC,SAAS,EAAE,KAAK,CAAC;gBACjD,SAAS,EAAE,cAAc;aAC1B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,uBAAuB,CAAC,SAAiB,EAAE,KAAW;QACnE,OAAO;YACL,MAAM,EAAG,KAAoB,EAAE,SAAS,IAAK,KAAa,EAAE,MAAM,IAAI,GAAG;YACzE,OAAO,EAAE,qBAAqB,SAAS,YAAY,GAAG,gCAAU,CAAC,aAAa,CAAC,KAAK,CAAC;YACrF,KAAK,EAAE,KAAK;YACZ,SAAS,EAAE,cAAc;SAC1B,CAAC;IACJ,CAAC;;AAnNH,kCAoNC"}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
|
-
/**
|
|
2
|
-
* Error codes for crypto operations
|
|
3
|
-
*/
|
|
4
1
|
/**
|
|
5
2
|
* Configuration options for encryption/decryption
|
|
6
3
|
*/
|
|
@@ -14,6 +11,15 @@ export interface CryptoConfig {
|
|
|
14
11
|
* A utility class for stable encryption and decryption of data
|
|
15
12
|
* Uses AES-256-CBC with deterministic IV and salt for consistent results across systems
|
|
16
13
|
* Prioritizes reliability and cross-platform compatibility over security
|
|
14
|
+
*
|
|
15
|
+
* @important DETERMINISTIC ENCRYPTION: This implementation produces identical encrypted
|
|
16
|
+
* output for identical input data and key across different systems and multiple calls.
|
|
17
|
+
* The same input will ALWAYS generate the same encrypted string on any platform.
|
|
18
|
+
*
|
|
19
|
+
* @warning SECURITY NOTICE: This deterministic behavior is intentional for cross-platform
|
|
20
|
+
* compatibility but reduces security. Identical inputs produce identical outputs, which
|
|
21
|
+
* can be exploited for pattern analysis attacks. Use only when consistency across
|
|
22
|
+
* systems is more important than cryptographic security.
|
|
17
23
|
*/
|
|
18
24
|
export declare class DyFM_Crypto {
|
|
19
25
|
private static readonly DEFAULT_CONFIG;
|
|
@@ -26,11 +32,17 @@ export declare class DyFM_Crypto {
|
|
|
26
32
|
/**
|
|
27
33
|
* Generates a deterministic IV based on the input data and key
|
|
28
34
|
* Uses MD5 for better stability across different CryptoJS versions
|
|
35
|
+
*
|
|
36
|
+
* @important DETERMINISTIC: Same data + key will ALWAYS produce the same IV
|
|
37
|
+
* across all systems and CryptoJS versions for consistent encryption results
|
|
29
38
|
*/
|
|
30
39
|
private static generateIV;
|
|
31
40
|
/**
|
|
32
41
|
* Generates a deterministic salt based on the input data and key
|
|
33
42
|
* Uses MD5 for better stability across different CryptoJS versions
|
|
43
|
+
*
|
|
44
|
+
* @important DETERMINISTIC: Same data + key will ALWAYS produce the same salt
|
|
45
|
+
* across all systems and CryptoJS versions for consistent encryption results
|
|
34
46
|
*/
|
|
35
47
|
private static generateSalt;
|
|
36
48
|
/**
|
|
@@ -47,11 +59,23 @@ export declare class DyFM_Crypto {
|
|
|
47
59
|
private static safeDeserialize;
|
|
48
60
|
/**
|
|
49
61
|
* Encrypts data using AES-256-CBC with deterministic IV and salt
|
|
62
|
+
*
|
|
63
|
+
* @important DETERMINISTIC BEHAVIOR: This method will produce identical encrypted
|
|
64
|
+
* output for identical input parameters across different systems, Node.js versions,
|
|
65
|
+
* and multiple function calls. The same data + key combination will ALWAYS generate
|
|
66
|
+
* the same encrypted string.
|
|
67
|
+
*
|
|
50
68
|
* @param data The data to encrypt
|
|
51
69
|
* @param key The encryption key
|
|
52
70
|
* @param config Optional configuration
|
|
53
|
-
* @returns URL-safe encrypted string
|
|
71
|
+
* @returns URL-safe encrypted string that is identical across systems for same input
|
|
54
72
|
* @throws {DyFM_Error} if encryption fails
|
|
73
|
+
*
|
|
74
|
+
* @example
|
|
75
|
+
* // These will produce identical results on any system:
|
|
76
|
+
* const result1 = DyFM_Crypto.encrypt({id: 1}, "mykey");
|
|
77
|
+
* const result2 = DyFM_Crypto.encrypt({id: 1}, "mykey");
|
|
78
|
+
* console.log(result1 === result2); // Always true
|
|
55
79
|
*/
|
|
56
80
|
static encrypt<T>(data: T, key: string, config?: CryptoConfig): string;
|
|
57
81
|
/**
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.util.d.ts","sourceRoot":"","sources":["../../../../src/_modules/crypto/_collections/crypto.util.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"crypto.util.d.ts","sourceRoot":"","sources":["../../../../src/_modules/crypto/_collections/crypto.util.ts"],"names":[],"mappings":"AAQA;;GAEG;AACH,MAAM,WAAW,YAAY;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAMD;;;;;;;;;;;;;GAaG;AACH,qBAAa,WAAW;IACtB,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,cAAc,CAKpC;IACF,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,mBAAmB,CAEY;IAEvD;;;OAGG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;IAmB5B;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,UAAU;IAQzB;;;;;;OAMG;IACH,OAAO,CAAC,MAAM,CAAC,YAAY;IAQ3B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,SAAS;IAOxB;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,aAAa;IAY5B;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,eAAe;IA6B9B;;;;;;;;;;;;;;;;;;;OAmBG;IACH,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,IAAI,EAAE,CAAC,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,MAAM;IAsCtE;;;;;;;OAOG;IACH,MAAM,CAAC,OAAO,CAAC,CAAC,EAAE,aAAa,EAAE,MAAM,EAAE,GAAG,EAAE,MAAM,EAAE,MAAM,CAAC,EAAE,YAAY,GAAG,CAAC;IAwD/E;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,MAAM,GAAE,MAAW,GAAG,MAAM;IAI/C;;;;OAIG;IACH,MAAM,CAAC,oBAAoB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO;IAO3D;;OAEG;IACH,OAAO,CAAC,MAAM,CAAC,uBAAuB;CAQvC"}
|
|
@@ -4,10 +4,22 @@ exports.DyFM_Crypto = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const CryptoJS = tslib_1.__importStar(require("crypto-js"));
|
|
6
6
|
const error_control_model_1 = require("../../../_models/control-models/error.control-model");
|
|
7
|
+
// Compact: about 60–80 character tokens, not 200+
|
|
8
|
+
// Non-standard: hard to reverse-engineer
|
|
9
|
+
// Usable in cookies, headers, URLs
|
|
7
10
|
/**
|
|
8
11
|
* A utility class for stable encryption and decryption of data
|
|
9
12
|
* Uses AES-256-CBC with deterministic IV and salt for consistent results across systems
|
|
10
13
|
* Prioritizes reliability and cross-platform compatibility over security
|
|
14
|
+
*
|
|
15
|
+
* @important DETERMINISTIC ENCRYPTION: This implementation produces identical encrypted
|
|
16
|
+
* output for identical input data and key across different systems and multiple calls.
|
|
17
|
+
* The same input will ALWAYS generate the same encrypted string on any platform.
|
|
18
|
+
*
|
|
19
|
+
* @warning SECURITY NOTICE: This deterministic behavior is intentional for cross-platform
|
|
20
|
+
* compatibility but reduces security. Identical inputs produce identical outputs, which
|
|
21
|
+
* can be exploited for pattern analysis attacks. Use only when consistency across
|
|
22
|
+
* systems is more important than cryptographic security.
|
|
11
23
|
*/
|
|
12
24
|
class DyFM_Crypto {
|
|
13
25
|
static DEFAULT_CONFIG = {
|
|
@@ -18,9 +30,6 @@ class DyFM_Crypto {
|
|
|
18
30
|
};
|
|
19
31
|
static defaultErrorUserMsg = `We encountered an unhandled Authentication Error, ` +
|
|
20
32
|
`\nplease contact the responsible development team.`;
|
|
21
|
-
// Tömör: kb. 60–80 karakteres token, nem 200+
|
|
22
|
-
// Nem szabványos: nehéz visszafejteni
|
|
23
|
-
// Használható cookie, header, URL-ben
|
|
24
33
|
/**
|
|
25
34
|
* Validates the input data and key
|
|
26
35
|
* @throws {DyFM_Error} if validation fails
|
|
@@ -45,6 +54,9 @@ class DyFM_Crypto {
|
|
|
45
54
|
/**
|
|
46
55
|
* Generates a deterministic IV based on the input data and key
|
|
47
56
|
* Uses MD5 for better stability across different CryptoJS versions
|
|
57
|
+
*
|
|
58
|
+
* @important DETERMINISTIC: Same data + key will ALWAYS produce the same IV
|
|
59
|
+
* across all systems and CryptoJS versions for consistent encryption results
|
|
48
60
|
*/
|
|
49
61
|
static generateIV(data, key, config) {
|
|
50
62
|
// Use MD5 for better stability - simpler hash algorithm, more consistent across versions
|
|
@@ -56,6 +68,9 @@ class DyFM_Crypto {
|
|
|
56
68
|
/**
|
|
57
69
|
* Generates a deterministic salt based on the input data and key
|
|
58
70
|
* Uses MD5 for better stability across different CryptoJS versions
|
|
71
|
+
*
|
|
72
|
+
* @important DETERMINISTIC: Same data + key will ALWAYS produce the same salt
|
|
73
|
+
* across all systems and CryptoJS versions for consistent encryption results
|
|
59
74
|
*/
|
|
60
75
|
static generateSalt(data, key, config) {
|
|
61
76
|
// Use MD5 for better stability - simpler hash algorithm, more consistent across versions
|
|
@@ -120,11 +135,23 @@ class DyFM_Crypto {
|
|
|
120
135
|
}
|
|
121
136
|
/**
|
|
122
137
|
* Encrypts data using AES-256-CBC with deterministic IV and salt
|
|
138
|
+
*
|
|
139
|
+
* @important DETERMINISTIC BEHAVIOR: This method will produce identical encrypted
|
|
140
|
+
* output for identical input parameters across different systems, Node.js versions,
|
|
141
|
+
* and multiple function calls. The same data + key combination will ALWAYS generate
|
|
142
|
+
* the same encrypted string.
|
|
143
|
+
*
|
|
123
144
|
* @param data The data to encrypt
|
|
124
145
|
* @param key The encryption key
|
|
125
146
|
* @param config Optional configuration
|
|
126
|
-
* @returns URL-safe encrypted string
|
|
147
|
+
* @returns URL-safe encrypted string that is identical across systems for same input
|
|
127
148
|
* @throws {DyFM_Error} if encryption fails
|
|
149
|
+
*
|
|
150
|
+
* @example
|
|
151
|
+
* // These will produce identical results on any system:
|
|
152
|
+
* const result1 = DyFM_Crypto.encrypt({id: 1}, "mykey");
|
|
153
|
+
* const result2 = DyFM_Crypto.encrypt({id: 1}, "mykey");
|
|
154
|
+
* console.log(result1 === result2); // Always true
|
|
128
155
|
*/
|
|
129
156
|
static encrypt(data, key, config) {
|
|
130
157
|
try {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"crypto.util.js","sourceRoot":"","sources":["../../../../src/_modules/crypto/_collections/crypto.util.ts"],"names":[],"mappings":";;;;AAAA,4DAAsC;AACtC,6FAG6D;
|
|
1
|
+
{"version":3,"file":"crypto.util.js","sourceRoot":"","sources":["../../../../src/_modules/crypto/_collections/crypto.util.ts"],"names":[],"mappings":";;;;AAAA,4DAAsC;AACtC,6FAG6D;AAc7D,kDAAkD;AAClD,yCAAyC;AACzC,mCAAmC;AAEnC;;;;;;;;;;;;;GAaG;AACH,MAAa,WAAW;IACd,MAAM,CAAU,cAAc,GAA2B;QAC/D,QAAQ,EAAE,EAAE,EAAE,WAAW;QACzB,UAAU,EAAE,EAAE,EAAE,WAAW;QAC3B,aAAa,EAAE,IAAI,EAAE,+CAA+C;QACpE,OAAO,EAAE,CAAC,CAAC,oBAAoB;KAChC,CAAC;IACM,MAAM,CAAU,mBAAmB,GACzC,oDAAoD;QACpD,oDAAoD,CAAC;IAEvD;;;OAGG;IACK,MAAM,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,EAAE,KAAK,CAAC;gBACjD,SAAS,EAAE,cAAc;aAC1B,CAAC,CAAC;QACL,CAAC;IACH,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,WAAW,CAAC,SAAiB,EAAE;QACpC,OAAO,QAAQ,CAAC,GAAG,CAAC,SAAS,CAAC,MAAM,CAAC,MAAM,CAAC,CAAC,QAAQ,EAAE,CAAC;IAC1D,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,oBAAoB,CAAC,aAAqB;QAC/C,IAAI,CAAC,aAAa,IAAI,OAAO,aAAa,KAAK,QAAQ,EAAE,CAAC;YACxD,OAAO,KAAK,CAAC;QACf,CAAC;QACD,OAAO,mBAAmB,CAAC,IAAI,CAAC,aAAa,CAAC,CAAC;IACjD,CAAC;IAED;;OAEG;IACK,MAAM,CAAC,uBAAuB,CAAC,SAAiB,EAAE,KAAW;QACnE,OAAO;YACL,MAAM,EAAG,KAAoB,EAAE,SAAS,IAAK,KAAa,EAAE,MAAM,IAAI,GAAG;YACzE,OAAO,EAAE,qBAAqB,SAAS,UAAU;YACjD,KAAK,EAAE,KAAK;YACZ,SAAS,EAAE,cAAc;SAC1B,CAAC;IACJ,CAAC;;AAlRH,kCAmRC"}
|
|
Binary file
|
package/package.json
CHANGED
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@futdevpro/fsm-dynamo",
|
|
3
|
-
"version": "01.11.
|
|
3
|
+
"version": "01.11.32",
|
|
4
4
|
"description": "Full Stack Model Collection for Dynamic (NodeJS-Typescript) Framework called Dynamo, by Future Development Ltd.",
|
|
5
5
|
"DyBu_settings": {
|
|
6
6
|
"packageType": "full-stack-package",
|
|
7
|
-
"tgzFolderName": "dynamo-fsm"
|
|
7
|
+
"tgzFolderName": "dynamo-fsm",
|
|
8
|
+
"systemName": "dynamo"
|
|
8
9
|
},
|
|
9
10
|
"scripts": {
|
|
10
11
|
"prep": "npm i -g pnpm rimraf nodemon jasmine && pnpm i",
|
|
@@ -116,7 +117,7 @@
|
|
|
116
117
|
"ts-node": "~10.9.1",
|
|
117
118
|
"tslib": "~2.6.2",
|
|
118
119
|
"typescript": "~5.5.4",
|
|
119
|
-
"uuid": "
|
|
120
|
+
"uuid": "12.0.0"
|
|
120
121
|
},
|
|
121
122
|
"devDependencies": {
|
|
122
123
|
"@types/jasmine": "~4.3.5",
|
|
@@ -125,7 +126,7 @@
|
|
|
125
126
|
"eslint": "^9.34.0",
|
|
126
127
|
"eslint-plugin-max-params-no-constructor": "^0.0.4",
|
|
127
128
|
"eslint-plugin-unused-imports": "^4.1.4",
|
|
128
|
-
"jasmine": "
|
|
129
|
+
"jasmine": "5.10.0",
|
|
129
130
|
"jasmine-spec-reporter": "^7.0.0",
|
|
130
131
|
"crypto-js": "~4.2.0",
|
|
131
132
|
"openai": "^4.93.0"
|
|
@@ -22,8 +22,10 @@ export class DyFM_Async {
|
|
|
22
22
|
static waitUntil(
|
|
23
23
|
check: () => boolean,
|
|
24
24
|
interval: number = 100,
|
|
25
|
-
timeout: number =
|
|
25
|
+
timeout: number = 10_000
|
|
26
26
|
): Promise<void> {
|
|
27
|
+
const timeoutError = new Error('waitUntil timeout');
|
|
28
|
+
|
|
27
29
|
return new Promise((resolve, reject): void => {
|
|
28
30
|
const startTime = Date.now();
|
|
29
31
|
|
|
@@ -33,7 +35,8 @@ export class DyFM_Async {
|
|
|
33
35
|
resolve();
|
|
34
36
|
} else if (Date.now() - startTime > timeout) {
|
|
35
37
|
clearInterval(intervalId);
|
|
36
|
-
|
|
38
|
+
|
|
39
|
+
reject(timeoutError);
|
|
37
40
|
}
|
|
38
41
|
}, interval);
|
|
39
42
|
});
|
|
@@ -55,6 +58,8 @@ export class DyFM_Async {
|
|
|
55
58
|
interval: number = 100,
|
|
56
59
|
timeout: number = 10000
|
|
57
60
|
): Promise<void> {
|
|
61
|
+
const timeoutError = new Error('waitUntilAsync timeout');
|
|
62
|
+
|
|
58
63
|
return new Promise((resolve, reject): void => {
|
|
59
64
|
const startTime = Date.now();
|
|
60
65
|
|
|
@@ -64,7 +69,8 @@ export class DyFM_Async {
|
|
|
64
69
|
resolve();
|
|
65
70
|
} else if (Date.now() - startTime > timeout) {
|
|
66
71
|
clearInterval(intervalId);
|
|
67
|
-
|
|
72
|
+
|
|
73
|
+
reject(timeoutError);
|
|
68
74
|
}
|
|
69
75
|
}, interval);
|
|
70
76
|
});
|
|
@@ -3,6 +3,7 @@ import {
|
|
|
3
3
|
DyFM_Error,
|
|
4
4
|
DyFM_Error_Settings
|
|
5
5
|
} from '../../../_models/control-models/error.control-model';
|
|
6
|
+
import { DyFM_Object } from '../../../_collections/utils/object.util';
|
|
6
7
|
|
|
7
8
|
|
|
8
9
|
/**
|
|
@@ -55,12 +56,12 @@ export class DyFM_Crypto {
|
|
|
55
56
|
*/
|
|
56
57
|
private static safeDeserialize<T>(data: string): T {
|
|
57
58
|
try {
|
|
58
|
-
let parsed =
|
|
59
|
+
let parsed = DyFM_Object.failableSafeParseJSON(data);
|
|
59
60
|
|
|
60
61
|
// Handle double-stringified JSON
|
|
61
62
|
if (typeof parsed === 'string') {
|
|
62
63
|
try {
|
|
63
|
-
parsed =
|
|
64
|
+
parsed = DyFM_Object.failableSafeParseJSON(parsed);
|
|
64
65
|
} catch {
|
|
65
66
|
// If second parse fails, return the string as is
|
|
66
67
|
return parsed as T;
|
|
@@ -3,19 +3,9 @@ import {
|
|
|
3
3
|
DyFM_Error,
|
|
4
4
|
DyFM_Error_Settings
|
|
5
5
|
} from '../../../_models/control-models/error.control-model';
|
|
6
|
+
import { DyFM_Object } from '../../../_collections/utils/object.util';
|
|
6
7
|
|
|
7
8
|
|
|
8
|
-
/**
|
|
9
|
-
* Error codes for crypto operations
|
|
10
|
-
*/
|
|
11
|
-
/* export enum CryptoErrorCode {
|
|
12
|
-
INVALID_INPUT = 'DyFM-CRY-EA0',
|
|
13
|
-
DECRYPTION_FAILED = '',
|
|
14
|
-
ENCRYPTION_FAILED = 'DyFM-CRY-ENF',
|
|
15
|
-
INVALID_KEY = 'DyFM-CRY-IKY',
|
|
16
|
-
INVALID_DATA = 'DyFM-CRY-IDT'
|
|
17
|
-
} */
|
|
18
|
-
|
|
19
9
|
/**
|
|
20
10
|
* Configuration options for encryption/decryption
|
|
21
11
|
*/
|
|
@@ -26,10 +16,23 @@ export interface CryptoConfig {
|
|
|
26
16
|
keySize?: number;
|
|
27
17
|
}
|
|
28
18
|
|
|
19
|
+
// Compact: about 60–80 character tokens, not 200+
|
|
20
|
+
// Non-standard: hard to reverse-engineer
|
|
21
|
+
// Usable in cookies, headers, URLs
|
|
22
|
+
|
|
29
23
|
/**
|
|
30
24
|
* A utility class for stable encryption and decryption of data
|
|
31
25
|
* Uses AES-256-CBC with deterministic IV and salt for consistent results across systems
|
|
32
26
|
* Prioritizes reliability and cross-platform compatibility over security
|
|
27
|
+
*
|
|
28
|
+
* @important DETERMINISTIC ENCRYPTION: This implementation produces identical encrypted
|
|
29
|
+
* output for identical input data and key across different systems and multiple calls.
|
|
30
|
+
* The same input will ALWAYS generate the same encrypted string on any platform.
|
|
31
|
+
*
|
|
32
|
+
* @warning SECURITY NOTICE: This deterministic behavior is intentional for cross-platform
|
|
33
|
+
* compatibility but reduces security. Identical inputs produce identical outputs, which
|
|
34
|
+
* can be exploited for pattern analysis attacks. Use only when consistency across
|
|
35
|
+
* systems is more important than cryptographic security.
|
|
33
36
|
*/
|
|
34
37
|
export class DyFM_Crypto {
|
|
35
38
|
private static readonly DEFAULT_CONFIG: Required<CryptoConfig> = {
|
|
@@ -42,10 +45,6 @@ export class DyFM_Crypto {
|
|
|
42
45
|
`We encountered an unhandled Authentication Error, ` +
|
|
43
46
|
`\nplease contact the responsible development team.`;
|
|
44
47
|
|
|
45
|
-
// Tömör: kb. 60–80 karakteres token, nem 200+
|
|
46
|
-
// Nem szabványos: nehéz visszafejteni
|
|
47
|
-
// Használható cookie, header, URL-ben
|
|
48
|
-
|
|
49
48
|
/**
|
|
50
49
|
* Validates the input data and key
|
|
51
50
|
* @throws {DyFM_Error} if validation fails
|
|
@@ -72,6 +71,9 @@ export class DyFM_Crypto {
|
|
|
72
71
|
/**
|
|
73
72
|
* Generates a deterministic IV based on the input data and key
|
|
74
73
|
* Uses MD5 for better stability across different CryptoJS versions
|
|
74
|
+
*
|
|
75
|
+
* @important DETERMINISTIC: Same data + key will ALWAYS produce the same IV
|
|
76
|
+
* across all systems and CryptoJS versions for consistent encryption results
|
|
75
77
|
*/
|
|
76
78
|
private static generateIV(data: string, key: string, config: Required<CryptoConfig>): CryptoJS.lib.WordArray {
|
|
77
79
|
// Use MD5 for better stability - simpler hash algorithm, more consistent across versions
|
|
@@ -84,6 +86,9 @@ export class DyFM_Crypto {
|
|
|
84
86
|
/**
|
|
85
87
|
* Generates a deterministic salt based on the input data and key
|
|
86
88
|
* Uses MD5 for better stability across different CryptoJS versions
|
|
89
|
+
*
|
|
90
|
+
* @important DETERMINISTIC: Same data + key will ALWAYS produce the same salt
|
|
91
|
+
* across all systems and CryptoJS versions for consistent encryption results
|
|
87
92
|
*/
|
|
88
93
|
private static generateSalt(data: string, key: string, config: Required<CryptoConfig>): CryptoJS.lib.WordArray {
|
|
89
94
|
// Use MD5 for better stability - simpler hash algorithm, more consistent across versions
|
|
@@ -152,11 +157,23 @@ export class DyFM_Crypto {
|
|
|
152
157
|
|
|
153
158
|
/**
|
|
154
159
|
* Encrypts data using AES-256-CBC with deterministic IV and salt
|
|
160
|
+
*
|
|
161
|
+
* @important DETERMINISTIC BEHAVIOR: This method will produce identical encrypted
|
|
162
|
+
* output for identical input parameters across different systems, Node.js versions,
|
|
163
|
+
* and multiple function calls. The same data + key combination will ALWAYS generate
|
|
164
|
+
* the same encrypted string.
|
|
165
|
+
*
|
|
155
166
|
* @param data The data to encrypt
|
|
156
167
|
* @param key The encryption key
|
|
157
168
|
* @param config Optional configuration
|
|
158
|
-
* @returns URL-safe encrypted string
|
|
169
|
+
* @returns URL-safe encrypted string that is identical across systems for same input
|
|
159
170
|
* @throws {DyFM_Error} if encryption fails
|
|
171
|
+
*
|
|
172
|
+
* @example
|
|
173
|
+
* // These will produce identical results on any system:
|
|
174
|
+
* const result1 = DyFM_Crypto.encrypt({id: 1}, "mykey");
|
|
175
|
+
* const result2 = DyFM_Crypto.encrypt({id: 1}, "mykey");
|
|
176
|
+
* console.log(result1 === result2); // Always true
|
|
160
177
|
*/
|
|
161
178
|
static encrypt<T>(data: T, key: string, config?: CryptoConfig): string {
|
|
162
179
|
try {
|
|
Binary file
|