@cortexkit/opencode-antigravity-auth 3.0.9 → 3.0.11
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/cli.js +803 -281
- package/dist/cli.js.map +4 -4
- package/dist/cli.meta.json +142 -53
- package/dist/index.js +1114 -471
- package/dist/index.js.map +4 -4
- package/dist/index.meta.json +152 -63
- package/dist/server.js +1145 -502
- package/dist/server.js.map +4 -4
- package/dist/server.meta.json +1 -1
- package/dist/src/common-auth-embedded/claustrum/consumer.d.ts +3 -1
- package/dist/src/common-auth-embedded/claustrum/consumer.js +25 -21
- package/dist/src/common-auth-embedded/claustrum/enrollment.d.ts +5 -0
- package/dist/src/common-auth-embedded/claustrum/enrollment.js +27 -0
- package/dist/src/common-auth-embedded/claustrum/index.d.ts +1 -0
- package/dist/src/common-auth-embedded/claustrum/index.js +1 -0
- package/dist/src/common-auth-embedded/claustrum/quota-writer.d.ts +18 -0
- package/dist/src/common-auth-embedded/claustrum/quota-writer.js +253 -0
- package/dist/src/common-auth-embedded/claustrum/roster.d.ts +18 -2
- package/dist/src/common-auth-embedded/claustrum/roster.js +100 -43
- package/dist/src/common-auth-embedded/fs/private-files.d.ts +2 -0
- package/dist/src/common-auth-embedded/fs/private-files.js +49 -3
- package/dist/src/common-auth-embedded/fs/with-lock.d.ts +1 -0
- package/dist/src/common-auth-embedded/fs/with-lock.js +2 -0
- package/dist/src/common-auth-embedded/quota/format.d.ts +19 -0
- package/dist/src/common-auth-embedded/quota/format.js +50 -5
- package/dist/src/common-auth-embedded/quota/index.d.ts +3 -3
- package/dist/src/common-auth-embedded/quota/index.js +2 -2
- package/dist/src/common-auth-embedded/quota/map.d.ts +24 -1
- package/dist/src/common-auth-embedded/quota/map.js +31 -6
- package/dist/src/common-auth-embedded/quota/merge.d.ts +6 -1
- package/dist/src/common-auth-embedded/quota/merge.js +17 -3
- package/dist/src/common-auth-embedded/quota/projection.d.ts +3 -1
- package/dist/src/common-auth-embedded/quota/projection.js +3 -1
- package/dist/src/common-auth-embedded/setup/enroll.d.ts +34 -0
- package/dist/src/common-auth-embedded/setup/enroll.js +116 -34
- package/dist/src/common-auth-embedded/setup/index.d.ts +1 -0
- package/dist/src/common-auth-embedded/setup/index.js +1 -0
- package/dist/src/common-auth-embedded/setup/process-fence.d.ts +14 -0
- package/dist/src/common-auth-embedded/setup/process-fence.js +61 -4
- package/dist/src/common-auth-embedded/setup/types.d.ts +5 -0
- package/dist/src/common-auth-embedded/source-output.json +115 -91
- package/dist/src/plugin/lifecycle.d.ts.map +1 -1
- package/dist/src/plugin/lifecycle.js +48 -27
- package/dist/src/plugin/lifecycle.js.map +1 -1
- package/dist/src/plugin/request-helpers.d.ts +5 -0
- package/dist/src/plugin/request-helpers.d.ts.map +1 -1
- package/dist/src/plugin/request-helpers.js +1 -0
- package/dist/src/plugin/request-helpers.js.map +1 -1
- package/dist/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/src/plugin/shared/request-services.js +125 -7
- package/dist/src/plugin/shared/request-services.js.map +1 -1
- package/dist/src/plugin/vault-custody.d.ts.map +1 -1
- package/dist/src/plugin/vault-custody.js +13 -3
- package/dist/src/plugin/vault-custody.js.map +1 -1
- package/dist/tui-build-map.json +25 -25
- package/dist/tui-ga-build-map.json +21 -21
- package/dist/types/src/common-auth-embedded/claustrum/consumer.d.ts +3 -1
- package/dist/types/src/common-auth-embedded/claustrum/enrollment.d.ts +5 -0
- package/dist/types/src/common-auth-embedded/claustrum/index.d.ts +1 -0
- package/dist/types/src/common-auth-embedded/claustrum/quota-writer.d.ts +18 -0
- package/dist/types/src/common-auth-embedded/claustrum/roster.d.ts +18 -2
- package/dist/types/src/common-auth-embedded/quota/format.d.ts +19 -0
- package/dist/types/src/common-auth-embedded/quota/index.d.ts +3 -3
- package/dist/types/src/common-auth-embedded/quota/map.d.ts +24 -1
- package/dist/types/src/common-auth-embedded/quota/merge.d.ts +6 -1
- package/dist/types/src/common-auth-embedded/quota/projection.d.ts +3 -1
- package/dist/types/src/common-auth-embedded/setup/enroll.d.ts +34 -0
- package/dist/types/src/common-auth-embedded/setup/index.d.ts +1 -0
- package/dist/types/src/common-auth-embedded/setup/process-fence.d.ts +14 -0
- package/dist/types/src/common-auth-embedded/setup/types.d.ts +5 -0
- package/dist/types/src/plugin/config/schema.d.ts +2 -2
- package/dist/types/src/plugin/lifecycle.d.ts.map +1 -1
- package/dist/types/src/plugin/request-helpers.d.ts +5 -0
- package/dist/types/src/plugin/request-helpers.d.ts.map +1 -1
- package/dist/types/src/plugin/shared/request-services.d.ts.map +1 -1
- package/dist/types/src/plugin/vault-custody.d.ts.map +1 -1
- package/package.json +2 -2
- package/src/common-auth-embedded/claustrum/consumer.d.ts +3 -1
- package/src/common-auth-embedded/claustrum/consumer.js +25 -21
- package/src/common-auth-embedded/claustrum/enrollment.d.ts +5 -0
- package/src/common-auth-embedded/claustrum/enrollment.js +27 -0
- package/src/common-auth-embedded/claustrum/index.d.ts +1 -0
- package/src/common-auth-embedded/claustrum/index.js +1 -0
- package/src/common-auth-embedded/claustrum/quota-writer.d.ts +18 -0
- package/src/common-auth-embedded/claustrum/quota-writer.js +253 -0
- package/src/common-auth-embedded/claustrum/roster.d.ts +18 -2
- package/src/common-auth-embedded/claustrum/roster.js +100 -43
- package/src/common-auth-embedded/fs/private-files.d.ts +2 -0
- package/src/common-auth-embedded/fs/private-files.js +49 -3
- package/src/common-auth-embedded/fs/with-lock.d.ts +1 -0
- package/src/common-auth-embedded/fs/with-lock.js +2 -0
- package/src/common-auth-embedded/quota/format.d.ts +19 -0
- package/src/common-auth-embedded/quota/format.js +50 -5
- package/src/common-auth-embedded/quota/index.d.ts +3 -3
- package/src/common-auth-embedded/quota/index.js +2 -2
- package/src/common-auth-embedded/quota/map.d.ts +24 -1
- package/src/common-auth-embedded/quota/map.js +31 -6
- package/src/common-auth-embedded/quota/merge.d.ts +6 -1
- package/src/common-auth-embedded/quota/merge.js +17 -3
- package/src/common-auth-embedded/quota/projection.d.ts +3 -1
- package/src/common-auth-embedded/quota/projection.js +3 -1
- package/src/common-auth-embedded/setup/enroll.d.ts +34 -0
- package/src/common-auth-embedded/setup/enroll.js +116 -34
- package/src/common-auth-embedded/setup/index.d.ts +1 -0
- package/src/common-auth-embedded/setup/index.js +1 -0
- package/src/common-auth-embedded/setup/process-fence.d.ts +14 -0
- package/src/common-auth-embedded/setup/process-fence.js +61 -4
- package/src/common-auth-embedded/setup/types.d.ts +5 -0
- package/src/common-auth-embedded/source-output.json +115 -91
- package/src/tui-compiled/common-auth-embedded/fs/private-files.js +49 -3
- package/src/tui-compiled/common-auth-embedded/quota/format.js +50 -5
- package/src/tui-compiled/common-auth-embedded/quota/index.js +2 -2
- package/src/tui-compiled/common-auth-embedded/quota/map.js +31 -6
- package/src/tui-compiled/common-auth-embedded/quota/merge.js +17 -3
- package/src/tui-compiled/common-auth-embedded/quota/projection.js +3 -1
- package/src/tui-ga-compiled/shared/1ff34afa7c42d196-projection.js +3 -1
- package/src/tui-ga-compiled/shared/77138df80c7ae006-map.js +31 -6
- package/src/tui-ga-compiled/shared/aef2402f8fc342f0-format.js +50 -5
- package/src/tui-ga-compiled/shared/bf17cbee28e58197-index.js +2 -2
- package/src/tui-ga-compiled/shared/ecc214300932dfb6-merge.js +17 -3
- package/src/tui-ga-raw/shared/1ff34afa7c42d196-projection.js +3 -1
- package/src/tui-ga-raw/shared/77138df80c7ae006-map.js +31 -6
- package/src/tui-ga-raw/shared/aef2402f8fc342f0-format.js +50 -5
- package/src/tui-ga-raw/shared/bf17cbee28e58197-index.js +2 -2
- package/src/tui-ga-raw/shared/ecc214300932dfb6-merge.js +17 -3
- package/src/tui-raw/common-auth-embedded/fs/private-files.js +49 -3
- package/src/tui-raw/common-auth-embedded/quota/format.js +50 -5
- package/src/tui-raw/common-auth-embedded/quota/index.js +2 -2
- package/src/tui-raw/common-auth-embedded/quota/map.js +31 -6
- package/src/tui-raw/common-auth-embedded/quota/merge.js +17 -3
- package/src/tui-raw/common-auth-embedded/quota/projection.js +3 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"schema": 1,
|
|
3
3
|
"package": "@cortexkit/common-auth",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.24.0",
|
|
5
5
|
"artifactStatus": "published",
|
|
6
6
|
"publicRoots": {
|
|
7
7
|
"./rpc": {
|
|
@@ -61,15 +61,15 @@
|
|
|
61
61
|
"import": "./dist/opencode2/index.js"
|
|
62
62
|
}
|
|
63
63
|
},
|
|
64
|
-
"input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.
|
|
65
|
-
"tarballSha256": "
|
|
66
|
-
"sri": "sha512-
|
|
67
|
-
"canonicalFiles":
|
|
68
|
-
"canonicalBytes":
|
|
64
|
+
"input": "tools/common-auth-build/inputs/cortexkit-common-auth-0.24.0.tgz",
|
|
65
|
+
"tarballSha256": "7b96e74e4017df1678050b1fe18ca821a548da4412414d4df222307a7c1d0ca0",
|
|
66
|
+
"sri": "sha512-dHGHnWBbVC/NHTq22GlFaqYFWg7M1TcCYZvYVIML1bx/rQiIoG05t/ojXjRWdrymHV7GYoaE+yx0YdYHHrPByQ==",
|
|
67
|
+
"canonicalFiles": 185,
|
|
68
|
+
"canonicalBytes": 1068841,
|
|
69
69
|
"generator": {
|
|
70
70
|
"path": "packages/opencode/scripts/embed-common-auth.ts",
|
|
71
71
|
"version": 3,
|
|
72
|
-
"sha256": "
|
|
72
|
+
"sha256": "0d093bc6e05261723f521904c32a328d890fdac5d00bf8b7035708ae44674103"
|
|
73
73
|
},
|
|
74
74
|
"files": [
|
|
75
75
|
{
|
|
@@ -251,17 +251,17 @@
|
|
|
251
251
|
{
|
|
252
252
|
"source": "package/dist/claustrum/consumer.d.ts",
|
|
253
253
|
"output": "claustrum/consumer.d.ts",
|
|
254
|
-
"bytes":
|
|
255
|
-
"sourceSha256": "
|
|
256
|
-
"outputSha256": "
|
|
254
|
+
"bytes": 9548,
|
|
255
|
+
"sourceSha256": "150eac9038881740a78e5664501a6ef0aa5e177a6dd46854cbeaf38513463e90",
|
|
256
|
+
"outputSha256": "150eac9038881740a78e5664501a6ef0aa5e177a6dd46854cbeaf38513463e90",
|
|
257
257
|
"transform": "verbatim"
|
|
258
258
|
},
|
|
259
259
|
{
|
|
260
260
|
"source": "package/dist/claustrum/consumer.js",
|
|
261
261
|
"output": "claustrum/consumer.js",
|
|
262
|
-
"bytes":
|
|
263
|
-
"sourceSha256": "
|
|
264
|
-
"outputSha256": "
|
|
262
|
+
"bytes": 25698,
|
|
263
|
+
"sourceSha256": "ec47dc016bf4d95655c17093a78d9c214b623214c821d352f73ea60f830c0d83",
|
|
264
|
+
"outputSha256": "ec47dc016bf4d95655c17093a78d9c214b623214c821d352f73ea60f830c0d83",
|
|
265
265
|
"transform": "verbatim"
|
|
266
266
|
},
|
|
267
267
|
{
|
|
@@ -283,17 +283,17 @@
|
|
|
283
283
|
{
|
|
284
284
|
"source": "package/dist/claustrum/enrollment.d.ts",
|
|
285
285
|
"output": "claustrum/enrollment.d.ts",
|
|
286
|
-
"bytes":
|
|
287
|
-
"sourceSha256": "
|
|
288
|
-
"outputSha256": "
|
|
286
|
+
"bytes": 7976,
|
|
287
|
+
"sourceSha256": "d6b4e8561ccc0ff2f9b4386856c5fe3dc7c475e13f98314a0666d0b20458d43b",
|
|
288
|
+
"outputSha256": "d6b4e8561ccc0ff2f9b4386856c5fe3dc7c475e13f98314a0666d0b20458d43b",
|
|
289
289
|
"transform": "verbatim"
|
|
290
290
|
},
|
|
291
291
|
{
|
|
292
292
|
"source": "package/dist/claustrum/enrollment.js",
|
|
293
293
|
"output": "claustrum/enrollment.js",
|
|
294
|
-
"bytes":
|
|
295
|
-
"sourceSha256": "
|
|
296
|
-
"outputSha256": "
|
|
294
|
+
"bytes": 35060,
|
|
295
|
+
"sourceSha256": "a9ca3a23778cc86ab9798051ba19dcb3b2b8e3dc4c4fda356cbd56eca50097db",
|
|
296
|
+
"outputSha256": "a9ca3a23778cc86ab9798051ba19dcb3b2b8e3dc4c4fda356cbd56eca50097db",
|
|
297
297
|
"transform": "verbatim"
|
|
298
298
|
},
|
|
299
299
|
{
|
|
@@ -331,17 +331,17 @@
|
|
|
331
331
|
{
|
|
332
332
|
"source": "package/dist/claustrum/index.d.ts",
|
|
333
333
|
"output": "claustrum/index.d.ts",
|
|
334
|
-
"bytes":
|
|
335
|
-
"sourceSha256": "
|
|
336
|
-
"outputSha256": "
|
|
334
|
+
"bytes": 3761,
|
|
335
|
+
"sourceSha256": "f2c1b8d99048666c068805b08b430492b2632be08e2beda466ee56b871572847",
|
|
336
|
+
"outputSha256": "f2c1b8d99048666c068805b08b430492b2632be08e2beda466ee56b871572847",
|
|
337
337
|
"transform": "verbatim"
|
|
338
338
|
},
|
|
339
339
|
{
|
|
340
340
|
"source": "package/dist/claustrum/index.js",
|
|
341
341
|
"output": "claustrum/index.js",
|
|
342
|
-
"bytes":
|
|
343
|
-
"sourceSha256": "
|
|
344
|
-
"outputSha256": "
|
|
342
|
+
"bytes": 2509,
|
|
343
|
+
"sourceSha256": "5f8b4bebfc2dec055b69769adcd1ce48ad7acc2c26256edbe4a2e984dc788147",
|
|
344
|
+
"outputSha256": "5f8b4bebfc2dec055b69769adcd1ce48ad7acc2c26256edbe4a2e984dc788147",
|
|
345
345
|
"transform": "verbatim"
|
|
346
346
|
},
|
|
347
347
|
{
|
|
@@ -376,20 +376,36 @@
|
|
|
376
376
|
"outputSha256": "031b95ccc3b3779ddb3be78278b29d6b2a741fc8217443a610ad2f98fe33ef33",
|
|
377
377
|
"transform": "verbatim"
|
|
378
378
|
},
|
|
379
|
+
{
|
|
380
|
+
"source": "package/dist/claustrum/quota-writer.d.ts",
|
|
381
|
+
"output": "claustrum/quota-writer.d.ts",
|
|
382
|
+
"bytes": 1112,
|
|
383
|
+
"sourceSha256": "35c3193c833ef169b5ebd9fdb03a8e08c234e9154b68b04d3cbea79975fffd14",
|
|
384
|
+
"outputSha256": "35c3193c833ef169b5ebd9fdb03a8e08c234e9154b68b04d3cbea79975fffd14",
|
|
385
|
+
"transform": "verbatim"
|
|
386
|
+
},
|
|
387
|
+
{
|
|
388
|
+
"source": "package/dist/claustrum/quota-writer.js",
|
|
389
|
+
"output": "claustrum/quota-writer.js",
|
|
390
|
+
"bytes": 9694,
|
|
391
|
+
"sourceSha256": "5a7d5d1059dcadc06aa41e81e0707cc444636473822047f0ec72da7589c770f1",
|
|
392
|
+
"outputSha256": "5a7d5d1059dcadc06aa41e81e0707cc444636473822047f0ec72da7589c770f1",
|
|
393
|
+
"transform": "verbatim"
|
|
394
|
+
},
|
|
379
395
|
{
|
|
380
396
|
"source": "package/dist/claustrum/roster.d.ts",
|
|
381
397
|
"output": "claustrum/roster.d.ts",
|
|
382
|
-
"bytes":
|
|
383
|
-
"sourceSha256": "
|
|
384
|
-
"outputSha256": "
|
|
398
|
+
"bytes": 10931,
|
|
399
|
+
"sourceSha256": "c394bc08c7cce4dc68fd539ac03cb200727534693600c7daf5ba7c9c4d0618ce",
|
|
400
|
+
"outputSha256": "c394bc08c7cce4dc68fd539ac03cb200727534693600c7daf5ba7c9c4d0618ce",
|
|
385
401
|
"transform": "verbatim"
|
|
386
402
|
},
|
|
387
403
|
{
|
|
388
404
|
"source": "package/dist/claustrum/roster.js",
|
|
389
405
|
"output": "claustrum/roster.js",
|
|
390
|
-
"bytes":
|
|
391
|
-
"sourceSha256": "
|
|
392
|
-
"outputSha256": "
|
|
406
|
+
"bytes": 27602,
|
|
407
|
+
"sourceSha256": "45ed2d4e69fad154ce86f5ff4f839c2ae9269dd9146ce7a8b2e5b6f49476ddf8",
|
|
408
|
+
"outputSha256": "45ed2d4e69fad154ce86f5ff4f839c2ae9269dd9146ce7a8b2e5b6f49476ddf8",
|
|
393
409
|
"transform": "verbatim"
|
|
394
410
|
},
|
|
395
411
|
{
|
|
@@ -555,17 +571,17 @@
|
|
|
555
571
|
{
|
|
556
572
|
"source": "package/dist/fs/private-files.d.ts",
|
|
557
573
|
"output": "fs/private-files.d.ts",
|
|
558
|
-
"bytes":
|
|
559
|
-
"sourceSha256": "
|
|
560
|
-
"outputSha256": "
|
|
574
|
+
"bytes": 3398,
|
|
575
|
+
"sourceSha256": "b344509a32fcd983f09e5814286630a53c8e577ad1b973eabe19f8e58659e8d3",
|
|
576
|
+
"outputSha256": "b344509a32fcd983f09e5814286630a53c8e577ad1b973eabe19f8e58659e8d3",
|
|
561
577
|
"transform": "verbatim"
|
|
562
578
|
},
|
|
563
579
|
{
|
|
564
580
|
"source": "package/dist/fs/private-files.js",
|
|
565
581
|
"output": "fs/private-files.js",
|
|
566
|
-
"bytes":
|
|
567
|
-
"sourceSha256": "
|
|
568
|
-
"outputSha256": "
|
|
582
|
+
"bytes": 14779,
|
|
583
|
+
"sourceSha256": "114c06ce4c0998087878d99c5dc37425e90d5fad205f57fe0bdf9694e3c8e31d",
|
|
584
|
+
"outputSha256": "114c06ce4c0998087878d99c5dc37425e90d5fad205f57fe0bdf9694e3c8e31d",
|
|
569
585
|
"transform": "verbatim"
|
|
570
586
|
},
|
|
571
587
|
{
|
|
@@ -587,17 +603,17 @@
|
|
|
587
603
|
{
|
|
588
604
|
"source": "package/dist/fs/with-lock.d.ts",
|
|
589
605
|
"output": "fs/with-lock.d.ts",
|
|
590
|
-
"bytes":
|
|
591
|
-
"sourceSha256": "
|
|
592
|
-
"outputSha256": "
|
|
606
|
+
"bytes": 1179,
|
|
607
|
+
"sourceSha256": "403d301f0cc332b72f8e7d904ac26f8efc93081cbd2cddd46b3f6a5a61d52685",
|
|
608
|
+
"outputSha256": "403d301f0cc332b72f8e7d904ac26f8efc93081cbd2cddd46b3f6a5a61d52685",
|
|
593
609
|
"transform": "verbatim"
|
|
594
610
|
},
|
|
595
611
|
{
|
|
596
612
|
"source": "package/dist/fs/with-lock.js",
|
|
597
613
|
"output": "fs/with-lock.js",
|
|
598
|
-
"bytes":
|
|
599
|
-
"sourceSha256": "
|
|
600
|
-
"outputSha256": "
|
|
614
|
+
"bytes": 1789,
|
|
615
|
+
"sourceSha256": "94fa839ec83d730280048f7e586453daadc590c4fbcf5601fd96f4a2d4193d6b",
|
|
616
|
+
"outputSha256": "94fa839ec83d730280048f7e586453daadc590c4fbcf5601fd96f4a2d4193d6b",
|
|
601
617
|
"transform": "verbatim"
|
|
602
618
|
},
|
|
603
619
|
{
|
|
@@ -811,81 +827,81 @@
|
|
|
811
827
|
{
|
|
812
828
|
"source": "package/dist/quota/format.d.ts",
|
|
813
829
|
"output": "quota/format.d.ts",
|
|
814
|
-
"bytes":
|
|
815
|
-
"sourceSha256": "
|
|
816
|
-
"outputSha256": "
|
|
830
|
+
"bytes": 5507,
|
|
831
|
+
"sourceSha256": "7df60af3e135f34e157bf41c05b59052047f1a583ff3f1dabb3ca4e525b8089a",
|
|
832
|
+
"outputSha256": "7df60af3e135f34e157bf41c05b59052047f1a583ff3f1dabb3ca4e525b8089a",
|
|
817
833
|
"transform": "verbatim"
|
|
818
834
|
},
|
|
819
835
|
{
|
|
820
836
|
"source": "package/dist/quota/format.js",
|
|
821
837
|
"output": "quota/format.js",
|
|
822
|
-
"bytes":
|
|
823
|
-
"sourceSha256": "
|
|
824
|
-
"outputSha256": "
|
|
838
|
+
"bytes": 18143,
|
|
839
|
+
"sourceSha256": "e00f3bb6d9da8b13522f02f953387e218f9cc6b62b80821ca081aa06f76d27c6",
|
|
840
|
+
"outputSha256": "e00f3bb6d9da8b13522f02f953387e218f9cc6b62b80821ca081aa06f76d27c6",
|
|
825
841
|
"transform": "verbatim"
|
|
826
842
|
},
|
|
827
843
|
{
|
|
828
844
|
"source": "package/dist/quota/index.d.ts",
|
|
829
845
|
"output": "quota/index.d.ts",
|
|
830
|
-
"bytes":
|
|
831
|
-
"sourceSha256": "
|
|
832
|
-
"outputSha256": "
|
|
846
|
+
"bytes": 1107,
|
|
847
|
+
"sourceSha256": "bbc90a42ee076209b368a3ffd477b0554dbe86da63c7e345cd3515b8ffc8950a",
|
|
848
|
+
"outputSha256": "bbc90a42ee076209b368a3ffd477b0554dbe86da63c7e345cd3515b8ffc8950a",
|
|
833
849
|
"transform": "verbatim"
|
|
834
850
|
},
|
|
835
851
|
{
|
|
836
852
|
"source": "package/dist/quota/index.js",
|
|
837
853
|
"output": "quota/index.js",
|
|
838
|
-
"bytes":
|
|
839
|
-
"sourceSha256": "
|
|
840
|
-
"outputSha256": "
|
|
854
|
+
"bytes": 545,
|
|
855
|
+
"sourceSha256": "781024edb9aa55a4cb88dfd0657abe569a1d9d15ac2b9a4a90456499a21a85fd",
|
|
856
|
+
"outputSha256": "781024edb9aa55a4cb88dfd0657abe569a1d9d15ac2b9a4a90456499a21a85fd",
|
|
841
857
|
"transform": "verbatim"
|
|
842
858
|
},
|
|
843
859
|
{
|
|
844
860
|
"source": "package/dist/quota/map.d.ts",
|
|
845
861
|
"output": "quota/map.d.ts",
|
|
846
|
-
"bytes":
|
|
847
|
-
"sourceSha256": "
|
|
848
|
-
"outputSha256": "
|
|
862
|
+
"bytes": 3876,
|
|
863
|
+
"sourceSha256": "95a8545c91726fecad46289ffd7fb400b62c376bfbc44477348ae30efe2ee853",
|
|
864
|
+
"outputSha256": "95a8545c91726fecad46289ffd7fb400b62c376bfbc44477348ae30efe2ee853",
|
|
849
865
|
"transform": "verbatim"
|
|
850
866
|
},
|
|
851
867
|
{
|
|
852
868
|
"source": "package/dist/quota/map.js",
|
|
853
869
|
"output": "quota/map.js",
|
|
854
|
-
"bytes":
|
|
855
|
-
"sourceSha256": "
|
|
856
|
-
"outputSha256": "
|
|
870
|
+
"bytes": 6610,
|
|
871
|
+
"sourceSha256": "c25cf67edc7d9cdc697d8956181d55cd13e823bead30c6acc82477c8222eb1df",
|
|
872
|
+
"outputSha256": "c25cf67edc7d9cdc697d8956181d55cd13e823bead30c6acc82477c8222eb1df",
|
|
857
873
|
"transform": "verbatim"
|
|
858
874
|
},
|
|
859
875
|
{
|
|
860
876
|
"source": "package/dist/quota/merge.d.ts",
|
|
861
877
|
"output": "quota/merge.d.ts",
|
|
862
|
-
"bytes":
|
|
863
|
-
"sourceSha256": "
|
|
864
|
-
"outputSha256": "
|
|
878
|
+
"bytes": 1997,
|
|
879
|
+
"sourceSha256": "b1f5d76d4176b118f7dbc19dd7d2f986697c8ecae2476b2cbe0c5a2538560527",
|
|
880
|
+
"outputSha256": "b1f5d76d4176b118f7dbc19dd7d2f986697c8ecae2476b2cbe0c5a2538560527",
|
|
865
881
|
"transform": "verbatim"
|
|
866
882
|
},
|
|
867
883
|
{
|
|
868
884
|
"source": "package/dist/quota/merge.js",
|
|
869
885
|
"output": "quota/merge.js",
|
|
870
|
-
"bytes":
|
|
871
|
-
"sourceSha256": "
|
|
872
|
-
"outputSha256": "
|
|
886
|
+
"bytes": 8096,
|
|
887
|
+
"sourceSha256": "b1d76faf1fb480b97ef1886ce75dbd2156002baedc39249468559cb4eece5bbb",
|
|
888
|
+
"outputSha256": "b1d76faf1fb480b97ef1886ce75dbd2156002baedc39249468559cb4eece5bbb",
|
|
873
889
|
"transform": "verbatim"
|
|
874
890
|
},
|
|
875
891
|
{
|
|
876
892
|
"source": "package/dist/quota/projection.d.ts",
|
|
877
893
|
"output": "quota/projection.d.ts",
|
|
878
|
-
"bytes":
|
|
879
|
-
"sourceSha256": "
|
|
880
|
-
"outputSha256": "
|
|
894
|
+
"bytes": 3661,
|
|
895
|
+
"sourceSha256": "c4f4c8c53245bd0c8bd08a1483aede705a4c3e21e4a131f14835340ffee38fab",
|
|
896
|
+
"outputSha256": "c4f4c8c53245bd0c8bd08a1483aede705a4c3e21e4a131f14835340ffee38fab",
|
|
881
897
|
"transform": "verbatim"
|
|
882
898
|
},
|
|
883
899
|
{
|
|
884
900
|
"source": "package/dist/quota/projection.js",
|
|
885
901
|
"output": "quota/projection.js",
|
|
886
|
-
"bytes":
|
|
887
|
-
"sourceSha256": "
|
|
888
|
-
"outputSha256": "
|
|
902
|
+
"bytes": 5787,
|
|
903
|
+
"sourceSha256": "762f4ba4f64accc7f7344402897ddaad3cfc908c11ff8e6ee9b6277602b78702",
|
|
904
|
+
"outputSha256": "762f4ba4f64accc7f7344402897ddaad3cfc908c11ff8e6ee9b6277602b78702",
|
|
889
905
|
"transform": "verbatim"
|
|
890
906
|
},
|
|
891
907
|
{
|
|
@@ -1144,28 +1160,36 @@
|
|
|
1144
1160
|
"outputSha256": "025b5f7b429978cc3842cc72240b8bc154a86859ceb2ad3b5ad8636ab334e649",
|
|
1145
1161
|
"transform": "verbatim"
|
|
1146
1162
|
},
|
|
1163
|
+
{
|
|
1164
|
+
"source": "package/dist/setup/enroll.d.ts",
|
|
1165
|
+
"output": "setup/enroll.d.ts",
|
|
1166
|
+
"bytes": 2199,
|
|
1167
|
+
"sourceSha256": "d7599ee67d3906d57f599447d243c6695d53b22d2105af317d36120e9f7c8ca7",
|
|
1168
|
+
"outputSha256": "d7599ee67d3906d57f599447d243c6695d53b22d2105af317d36120e9f7c8ca7",
|
|
1169
|
+
"transform": "verbatim"
|
|
1170
|
+
},
|
|
1147
1171
|
{
|
|
1148
1172
|
"source": "package/dist/setup/enroll.js",
|
|
1149
1173
|
"output": "setup/enroll.js",
|
|
1150
|
-
"bytes":
|
|
1151
|
-
"sourceSha256": "
|
|
1152
|
-
"outputSha256": "
|
|
1174
|
+
"bytes": 8484,
|
|
1175
|
+
"sourceSha256": "2ec864a300326a2ce9b8dd79750704e438af04ef5fa9e3b744a8ecdd7e0e41d6",
|
|
1176
|
+
"outputSha256": "2ec864a300326a2ce9b8dd79750704e438af04ef5fa9e3b744a8ecdd7e0e41d6",
|
|
1153
1177
|
"transform": "verbatim"
|
|
1154
1178
|
},
|
|
1155
1179
|
{
|
|
1156
1180
|
"source": "package/dist/setup/index.d.ts",
|
|
1157
1181
|
"output": "setup/index.d.ts",
|
|
1158
|
-
"bytes":
|
|
1159
|
-
"sourceSha256": "
|
|
1160
|
-
"outputSha256": "
|
|
1182
|
+
"bytes": 970,
|
|
1183
|
+
"sourceSha256": "f443b8d501334f8384878606ff19beee0241e70e7f4cc3dd0d0fd4636f8433c5",
|
|
1184
|
+
"outputSha256": "f443b8d501334f8384878606ff19beee0241e70e7f4cc3dd0d0fd4636f8433c5",
|
|
1161
1185
|
"transform": "verbatim"
|
|
1162
1186
|
},
|
|
1163
1187
|
{
|
|
1164
1188
|
"source": "package/dist/setup/index.js",
|
|
1165
1189
|
"output": "setup/index.js",
|
|
1166
|
-
"bytes":
|
|
1167
|
-
"sourceSha256": "
|
|
1168
|
-
"outputSha256": "
|
|
1190
|
+
"bytes": 617,
|
|
1191
|
+
"sourceSha256": "3ab259b0ba5e5e6d83ea9077adf11e2c561d4a7788710adbb6e8e0ed88dcd44b",
|
|
1192
|
+
"outputSha256": "3ab259b0ba5e5e6d83ea9077adf11e2c561d4a7788710adbb6e8e0ed88dcd44b",
|
|
1169
1193
|
"transform": "verbatim"
|
|
1170
1194
|
},
|
|
1171
1195
|
{
|
|
@@ -1179,17 +1203,17 @@
|
|
|
1179
1203
|
{
|
|
1180
1204
|
"source": "package/dist/setup/process-fence.d.ts",
|
|
1181
1205
|
"output": "setup/process-fence.d.ts",
|
|
1182
|
-
"bytes":
|
|
1183
|
-
"sourceSha256": "
|
|
1184
|
-
"outputSha256": "
|
|
1206
|
+
"bytes": 2223,
|
|
1207
|
+
"sourceSha256": "ed246d2c16821cc51170e4099466450e26821c81fc3b96ad2d7fde18ea4ee9c6",
|
|
1208
|
+
"outputSha256": "ed246d2c16821cc51170e4099466450e26821c81fc3b96ad2d7fde18ea4ee9c6",
|
|
1185
1209
|
"transform": "verbatim"
|
|
1186
1210
|
},
|
|
1187
1211
|
{
|
|
1188
1212
|
"source": "package/dist/setup/process-fence.js",
|
|
1189
1213
|
"output": "setup/process-fence.js",
|
|
1190
|
-
"bytes":
|
|
1191
|
-
"sourceSha256": "
|
|
1192
|
-
"outputSha256": "
|
|
1214
|
+
"bytes": 14008,
|
|
1215
|
+
"sourceSha256": "8ca9546a205fe9d6daecc2604c7e4608df5d09e0bd0f774fe8da40f26a3ffefb",
|
|
1216
|
+
"outputSha256": "8ca9546a205fe9d6daecc2604c7e4608df5d09e0bd0f774fe8da40f26a3ffefb",
|
|
1193
1217
|
"transform": "verbatim"
|
|
1194
1218
|
},
|
|
1195
1219
|
{
|
|
@@ -1219,9 +1243,9 @@
|
|
|
1219
1243
|
{
|
|
1220
1244
|
"source": "package/dist/setup/types.d.ts",
|
|
1221
1245
|
"output": "setup/types.d.ts",
|
|
1222
|
-
"bytes":
|
|
1223
|
-
"sourceSha256": "
|
|
1224
|
-
"outputSha256": "
|
|
1246
|
+
"bytes": 5722,
|
|
1247
|
+
"sourceSha256": "db068b3f2428734ad731c120443c7e5a432f5d568a8a61c21c7978855e613063",
|
|
1248
|
+
"outputSha256": "db068b3f2428734ad731c120443c7e5a432f5d568a8a61c21c7978855e613063",
|
|
1225
1249
|
"transform": "verbatim"
|
|
1226
1250
|
},
|
|
1227
1251
|
{
|
|
@@ -1,6 +1,7 @@
|
|
|
1
1
|
import { randomUUID } from "node:crypto";
|
|
2
2
|
import { lstat, readFile, rename, unlink } from "node:fs/promises";
|
|
3
|
-
import {
|
|
3
|
+
import { tmpdir } from "node:os";
|
|
4
|
+
import { dirname, join, resolve } from "node:path";
|
|
4
5
|
export const windowsPrivateFiles = process.platform === 'win32';
|
|
5
6
|
const migrationNotices = new Set();
|
|
6
7
|
function ioCode(detail) {
|
|
@@ -20,8 +21,51 @@ let backend;
|
|
|
20
21
|
export function setPrivateFilesBackendForTest(api) {
|
|
21
22
|
backend = api ? Promise.resolve(api) : undefined;
|
|
22
23
|
}
|
|
24
|
+
/** The fixed `reason` of a refusal because the Windows native addon did not load. */
|
|
25
|
+
export const PRIVATE_FILES_UNAVAILABLE_REASON = 'native-addon-unavailable';
|
|
26
|
+
function privateFilesUnavailable(cause) {
|
|
27
|
+
return Object.assign(new Error('Windows private-files native addon is unavailable', { cause }), {
|
|
28
|
+
code: 'ERR_PRIVATE_FILES_UNAVAILABLE',
|
|
29
|
+
reason: PRIVATE_FILES_UNAVAILABLE_REASON,
|
|
30
|
+
});
|
|
31
|
+
}
|
|
32
|
+
function isUnavailable(api, error) {
|
|
33
|
+
return (error instanceof api.PrivateFilesUnavailableError ||
|
|
34
|
+
error?.code ===
|
|
35
|
+
'ERR_PRIVATE_FILES_UNAVAILABLE');
|
|
36
|
+
}
|
|
37
|
+
/**
|
|
38
|
+
* Importing @cortexkit/private-files succeeds even when its Windows addon
|
|
39
|
+
* cannot load: the package loads the addon on first use, and some of its
|
|
40
|
+
* checks then report the failure as an ordinary refusal such as
|
|
41
|
+
* `unsupported-filesystem`. So prove the addon loads before handing the
|
|
42
|
+
* package out. Verifying a path that does not exist loads the addon first and
|
|
43
|
+
* then fails harmlessly; only the package's own "unavailable" error means the
|
|
44
|
+
* addon is missing.
|
|
45
|
+
*/
|
|
46
|
+
async function assertNativeAddonLoads(api) {
|
|
47
|
+
try {
|
|
48
|
+
await api.verifyPrivatePath(join(tmpdir(), `.common-auth-private-files-probe-${randomUUID()}`), 'file');
|
|
49
|
+
}
|
|
50
|
+
catch (error) {
|
|
51
|
+
if (isUnavailable(api, error))
|
|
52
|
+
throw privateFilesUnavailable(error);
|
|
53
|
+
}
|
|
54
|
+
}
|
|
55
|
+
/**
|
|
56
|
+
* Load the package once per process. On Windows a failed import or addon load
|
|
57
|
+
* is kept, so every later private-file operation refuses at once with
|
|
58
|
+
* ERR_PRIVATE_FILES_UNAVAILABLE. There is no fallback to permission bits:
|
|
59
|
+
* they do not protect files on Windows.
|
|
60
|
+
*/
|
|
23
61
|
function loadBackend() {
|
|
24
|
-
backend ??= import("@cortexkit/private-files")
|
|
62
|
+
backend ??= import("@cortexkit/private-files").then(async (api) => {
|
|
63
|
+
if (windowsPrivateFiles)
|
|
64
|
+
await assertNativeAddonLoads(api);
|
|
65
|
+
return api;
|
|
66
|
+
}, (cause) => {
|
|
67
|
+
throw windowsPrivateFiles ? privateFilesUnavailable(cause) : cause;
|
|
68
|
+
});
|
|
25
69
|
return backend;
|
|
26
70
|
}
|
|
27
71
|
export class PrivateFileError extends Error {
|
|
@@ -38,7 +82,9 @@ export class PrivateFileError extends Error {
|
|
|
38
82
|
orphanPath;
|
|
39
83
|
constructor(path, stage, cause) {
|
|
40
84
|
const detail = cause;
|
|
41
|
-
super(
|
|
85
|
+
super(detail?.code === 'ERR_PRIVATE_FILES_UNAVAILABLE'
|
|
86
|
+
? `Private file refused at ${stage}: ${path} (${PRIVATE_FILES_UNAVAILABLE_REASON}). The Windows native addon of @cortexkit/private-files could not be loaded, so owner-only access cannot be enforced and nothing was read or written. Reinstall the plugin so the private-files Windows prebuild for this architecture is present; Windows has no safe fallback to permission bits.`
|
|
87
|
+
: `Private file refused at ${stage}: ${path} (${detail?.reason ?? detail?.code ?? 'io-error'}). Keep this file in a folder that only you, the system or administrators can change, such as a folder in your home directory. If other users could read the file before, sign in again to replace the credentials it held. On Windows the file must also be on a local drive that keeps Windows file permissions, such as NTFS.`, { cause });
|
|
42
88
|
this.path = path;
|
|
43
89
|
this.stage = stage;
|
|
44
90
|
this.name = 'PrivateFileError';
|
|
@@ -106,6 +106,25 @@ export function quotaWindowParts(quota, options) {
|
|
|
106
106
|
const parts = windows.map(({ part }) => part);
|
|
107
107
|
return age === undefined ? { windows: parts } : { windows: parts, age };
|
|
108
108
|
}
|
|
109
|
+
/**
|
|
110
|
+
* The narrow label of each scoped window part, as `narrowTextParts` names
|
|
111
|
+
* them: model short names are worked out over every model-scoped window in
|
|
112
|
+
* the reading, so two models never share a short name.
|
|
113
|
+
*/
|
|
114
|
+
function withShortNames(windows) {
|
|
115
|
+
const abbreviations = scopeAbbreviations(windows
|
|
116
|
+
.filter(({ part, scope }) => part.kind === 'window' && scope !== ALL_SCOPE)
|
|
117
|
+
.map(({ scope }) => scope));
|
|
118
|
+
for (const window of windows) {
|
|
119
|
+
window.part.short =
|
|
120
|
+
window.part.kind === 'budget'
|
|
121
|
+
? 'cr'
|
|
122
|
+
: window.scope === ALL_SCOPE
|
|
123
|
+
? window.part.name
|
|
124
|
+
: (abbreviations.get(window.scope) ?? window.scope);
|
|
125
|
+
}
|
|
126
|
+
return windows;
|
|
127
|
+
}
|
|
109
128
|
/**
|
|
110
129
|
* `quotaWindowParts` with each window's scope kept beside it. The narrow form
|
|
111
130
|
* needs the scope to name and pick model-scoped windows; the public parts do
|
|
@@ -128,6 +147,7 @@ function scopedWindowParts(quota, options) {
|
|
|
128
147
|
part: {
|
|
129
148
|
kind: 'window',
|
|
130
149
|
name: quotaWindowName(limit),
|
|
150
|
+
short: '',
|
|
131
151
|
figure: percentLeft(limit.remainingPercent ?? 0),
|
|
132
152
|
remainingPercent,
|
|
133
153
|
checkedAt: limit.checkedAt,
|
|
@@ -149,6 +169,7 @@ function scopedWindowParts(quota, options) {
|
|
|
149
169
|
part: {
|
|
150
170
|
kind: 'budget',
|
|
151
171
|
name: 'credits',
|
|
172
|
+
short: '',
|
|
152
173
|
figure,
|
|
153
174
|
...(remainingPercent === undefined
|
|
154
175
|
? {}
|
|
@@ -158,6 +179,7 @@ function scopedWindowParts(quota, options) {
|
|
|
158
179
|
},
|
|
159
180
|
});
|
|
160
181
|
}
|
|
182
|
+
withShortNames(windows);
|
|
161
183
|
if (windows.length > 0) {
|
|
162
184
|
const age = now - Math.min(...windows.map(({ part }) => part.checkedAt));
|
|
163
185
|
if (age > (options.staleAfterMs ?? QUOTA_STALE_AFTER_MS)) {
|
|
@@ -298,20 +320,21 @@ function narrowTextParts(quota, options) {
|
|
|
298
320
|
return grouped;
|
|
299
321
|
const general = windows.filter(({ part, scope }) => part.kind === 'window' && scope === ALL_SCOPE);
|
|
300
322
|
const scoped = windows.filter(({ part, scope }) => part.kind === 'window' && scope !== ALL_SCOPE);
|
|
301
|
-
const abbreviations = scopeAbbreviations(scoped.map(({ scope }) => scope));
|
|
302
323
|
// The items competing for the one slot after the account-wide windows, in
|
|
303
324
|
// tie-break order: scoped windows in display order, then the budget. A
|
|
304
325
|
// spent budget counts as 0% left; one without a percentage cannot compete.
|
|
326
|
+
// Their labels are the parts' short names, so the narrow line and a layout
|
|
327
|
+
// reading `short` always agree.
|
|
305
328
|
const budget = windows.find(({ part }) => part.kind === 'budget');
|
|
306
329
|
const budgetLeft = budget?.spent ? 0 : budget?.part.remainingPercent;
|
|
307
330
|
const extras = [
|
|
308
|
-
...scoped.map(({
|
|
309
|
-
label:
|
|
331
|
+
...scoped.map(({ part }) => ({
|
|
332
|
+
label: part.short,
|
|
310
333
|
remaining: part.remainingPercent ?? 0,
|
|
311
334
|
})),
|
|
312
|
-
...(budgetLeft === undefined
|
|
335
|
+
...(budgetLeft === undefined || budget === undefined
|
|
313
336
|
? []
|
|
314
|
-
: [{ label:
|
|
337
|
+
: [{ label: budget.part.short, remaining: budgetLeft }]),
|
|
315
338
|
];
|
|
316
339
|
// Strictly lower wins, so on a tie the earlier item keeps the slot.
|
|
317
340
|
const tightest = extras.reduce((best, item) => best === undefined || item.remaining < best.remaining ? item : best, undefined);
|
|
@@ -357,3 +380,25 @@ export function formatQuota(quota, options) {
|
|
|
357
380
|
? NO_LIMITS_REPORTED
|
|
358
381
|
: NO_QUOTA_READING;
|
|
359
382
|
}
|
|
383
|
+
/**
|
|
384
|
+
* Prepaid credits as one short value, worded as the official Codex client's
|
|
385
|
+
* status view words them: `Unlimited` for unlimited credits, `<n> credits`
|
|
386
|
+
* for a finite positive balance (rounded to a whole number), `Available` when
|
|
387
|
+
* the account has credits but no usable balance was reported, and undefined
|
|
388
|
+
* when the account has no credits (or `credits` is undefined), so a caller
|
|
389
|
+
* shows no credits row at all. Unlimited wins even when `hasCredits` is false.
|
|
390
|
+
* No other formatter adds this text; a caller that wants a credits row asks
|
|
391
|
+
* for it.
|
|
392
|
+
*/
|
|
393
|
+
export function quotaCreditsText(credits) {
|
|
394
|
+
if (credits === undefined)
|
|
395
|
+
return undefined;
|
|
396
|
+
if (credits.unlimited)
|
|
397
|
+
return 'Unlimited';
|
|
398
|
+
if (!credits.hasCredits)
|
|
399
|
+
return undefined;
|
|
400
|
+
const { balance } = credits;
|
|
401
|
+
return typeof balance === 'number' && Number.isFinite(balance) && balance > 0
|
|
402
|
+
? `${Math.round(balance)} credits`
|
|
403
|
+
: 'Available';
|
|
404
|
+
}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
export { quotaCodec } from "./codec.js";
|
|
2
|
-
export { formatQuota, isQuotaStale, NO_LIMITS_REPORTED, NO_QUOTA_READING, QUOTA_STALE_AFTER_MS, quotaTextParts, quotaWindowName, quotaWindowParts, } from "./format.js";
|
|
3
|
-
export { ALL_SCOPE, DEFAULT_REQUIRED_LABELS, decodeQuotaMap, emptyQuotaMap, isQuotaMap, } from "./map.js";
|
|
2
|
+
export { formatQuota, isQuotaStale, NO_LIMITS_REPORTED, NO_QUOTA_READING, QUOTA_STALE_AFTER_MS, quotaCreditsText, quotaTextParts, quotaWindowName, quotaWindowParts, } from "./format.js";
|
|
3
|
+
export { ALL_SCOPE, DEFAULT_REQUIRED_LABELS, decodeQuotaMap, emptyQuotaMap, isQuotaCredits, isQuotaMap, } from "./map.js";
|
|
4
4
|
export { isQuotaObservation, mergeQuotaObservation, QuotaCodecError, } from "./merge.js";
|
|
5
5
|
export { budgetExhaustedResetAt, futureResetAt, projectQuota, readsExhausted, } from "./projection.js";
|
|
@@ -14,6 +14,9 @@
|
|
|
14
14
|
// reset clock. It is a tri-state: absent (never reported), a reading, or
|
|
15
15
|
// cleared (the provider reported that no budget exists).
|
|
16
16
|
//
|
|
17
|
+
// Provider-named counters and the prepaid credits record sit beside them too,
|
|
18
|
+
// each judged by its own observation time rather than the limits'.
|
|
19
|
+
//
|
|
17
20
|
// The map is plain JSON so the store can persist it without interpreting it.
|
|
18
21
|
/** The scope of a limit that binds every request regardless of model. */
|
|
19
22
|
export const ALL_SCOPE = 'all';
|
|
@@ -93,6 +96,18 @@ function isQuotaCounter(value) {
|
|
|
93
96
|
export function isQuotaCounters(value) {
|
|
94
97
|
return isRecord(value) && Object.values(value).every(isQuotaCounter);
|
|
95
98
|
}
|
|
99
|
+
function isBoolean(value) {
|
|
100
|
+
return typeof value === 'boolean';
|
|
101
|
+
}
|
|
102
|
+
/** True when `value` is a well-formed prepaid-credits record. */
|
|
103
|
+
export function isQuotaCredits(value) {
|
|
104
|
+
return (isRecord(value) &&
|
|
105
|
+
typeof value.hasCredits === 'boolean' &&
|
|
106
|
+
typeof value.unlimited === 'boolean' &&
|
|
107
|
+
optional(value, 'balance', isFiniteNumber) &&
|
|
108
|
+
optional(value, 'overageLimitReached', isBoolean) &&
|
|
109
|
+
isFiniteNumber(value.checkedAt));
|
|
110
|
+
}
|
|
96
111
|
/** Keep usable counters without letting one malformed count hide a quota map. */
|
|
97
112
|
export function readQuotaCounters(value) {
|
|
98
113
|
if (!isRecord(value))
|
|
@@ -102,20 +117,29 @@ export function readQuotaCounters(value) {
|
|
|
102
117
|
? undefined
|
|
103
118
|
: Object.fromEntries(entries);
|
|
104
119
|
}
|
|
105
|
-
/**
|
|
120
|
+
/**
|
|
121
|
+
* Decode persisted quota, dropping malformed counters or a malformed credits
|
|
122
|
+
* record but not limit or budget evidence.
|
|
123
|
+
*/
|
|
106
124
|
export function decodeQuotaMap(value) {
|
|
107
125
|
// A valid map is returned as the same object, so stored quota keeps the
|
|
108
|
-
// identity it had before counters existed
|
|
109
|
-
// counter is copied
|
|
126
|
+
// identity it had before counters and credits existed. A map with a
|
|
127
|
+
// malformed counter or credits record is copied with those malformed
|
|
128
|
+
// fields left out.
|
|
110
129
|
if (isQuotaMap(value))
|
|
111
130
|
return value;
|
|
112
131
|
if (!isRecord(value))
|
|
113
132
|
return undefined;
|
|
114
|
-
const { counters: rawCounters, ...rest } = value;
|
|
133
|
+
const { counters: rawCounters, credits: rawCredits, ...rest } = value;
|
|
115
134
|
if (!isQuotaMap(rest))
|
|
116
135
|
return undefined;
|
|
117
136
|
const counters = readQuotaCounters(rawCounters);
|
|
118
|
-
|
|
137
|
+
const credits = isQuotaCredits(rawCredits) ? rawCredits : undefined;
|
|
138
|
+
return {
|
|
139
|
+
...rest,
|
|
140
|
+
...(counters === undefined ? {} : { counters }),
|
|
141
|
+
...(credits === undefined ? {} : { credits }),
|
|
142
|
+
};
|
|
119
143
|
}
|
|
120
144
|
/**
|
|
121
145
|
* True when `value` is a well-formed quota map. Unrecognised top-level keys
|
|
@@ -136,5 +160,6 @@ export function isQuotaMap(value) {
|
|
|
136
160
|
seen.add(key);
|
|
137
161
|
}
|
|
138
162
|
return (optional(value, 'budget', isCreditBudgetEntry) &&
|
|
139
|
-
optional(value, 'counters', isQuotaCounters)
|
|
163
|
+
optional(value, 'counters', isQuotaCounters) &&
|
|
164
|
+
optional(value, 'credits', isQuotaCredits));
|
|
140
165
|
}
|