@spinajs/authn-keys 3.0.2 → 3.0.4

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.
Files changed (140) hide show
  1. package/README.md +11 -3
  2. package/lib/cjs/index.d.ts +0 -1
  3. package/lib/cjs/index.d.ts.map +1 -1
  4. package/lib/cjs/index.js +0 -1
  5. package/lib/cjs/index.js.map +1 -1
  6. package/lib/cjs/jws/index.d.ts +1 -0
  7. package/lib/cjs/jws/index.d.ts.map +1 -1
  8. package/lib/cjs/jws/index.js +1 -0
  9. package/lib/cjs/jws/index.js.map +1 -1
  10. package/lib/cjs/jws/register.d.ts +18 -0
  11. package/lib/cjs/jws/register.d.ts.map +1 -0
  12. package/lib/cjs/jws/register.js +66 -0
  13. package/lib/cjs/jws/register.js.map +1 -0
  14. package/lib/cjs/models/index.d.ts +0 -1
  15. package/lib/cjs/models/index.d.ts.map +1 -1
  16. package/lib/cjs/models/index.js +0 -1
  17. package/lib/cjs/models/index.js.map +1 -1
  18. package/lib/cjs/options/options.d.ts +10 -0
  19. package/lib/cjs/options/options.d.ts.map +1 -1
  20. package/lib/cjs/options/options.js +9 -0
  21. package/lib/cjs/options/options.js.map +1 -1
  22. package/lib/cjs/registry/cache.d.ts +26 -0
  23. package/lib/cjs/registry/cache.d.ts.map +1 -0
  24. package/lib/cjs/registry/cache.js +73 -0
  25. package/lib/cjs/registry/cache.js.map +1 -0
  26. package/lib/cjs/registry/index.d.ts +1 -0
  27. package/lib/cjs/registry/index.d.ts.map +1 -1
  28. package/lib/cjs/registry/index.js +1 -0
  29. package/lib/cjs/registry/index.js.map +1 -1
  30. package/lib/cjs/registry/registry.d.ts +15 -2
  31. package/lib/cjs/registry/registry.d.ts.map +1 -1
  32. package/lib/cjs/registry/registry.js +35 -2
  33. package/lib/cjs/registry/registry.js.map +1 -1
  34. package/lib/cjs/schema.d.ts +40 -0
  35. package/lib/cjs/schema.d.ts.map +1 -1
  36. package/lib/cjs/schema.js +19 -0
  37. package/lib/cjs/schema.js.map +1 -1
  38. package/lib/cjs/strategies/assertion.d.ts +4 -5
  39. package/lib/cjs/strategies/assertion.d.ts.map +1 -1
  40. package/lib/cjs/strategies/assertion.js +6 -5
  41. package/lib/cjs/strategies/assertion.js.map +1 -1
  42. package/lib/cjs/strategies/httpsig.d.ts +5 -4
  43. package/lib/cjs/strategies/httpsig.d.ts.map +1 -1
  44. package/lib/cjs/strategies/httpsig.js +9 -5
  45. package/lib/cjs/strategies/httpsig.js.map +1 -1
  46. package/lib/cjs/strategies/index.d.ts +1 -0
  47. package/lib/cjs/strategies/index.d.ts.map +1 -1
  48. package/lib/cjs/strategies/index.js +1 -0
  49. package/lib/cjs/strategies/index.js.map +1 -1
  50. package/lib/cjs/strategies/keys.d.ts +3 -1
  51. package/lib/cjs/strategies/keys.d.ts.map +1 -1
  52. package/lib/cjs/strategies/keys.js +9 -0
  53. package/lib/cjs/strategies/keys.js.map +1 -1
  54. package/lib/cjs/strategies/nonce-key.d.ts +3 -0
  55. package/lib/cjs/strategies/nonce-key.d.ts.map +1 -0
  56. package/lib/cjs/strategies/nonce-key.js +8 -0
  57. package/lib/cjs/strategies/nonce-key.js.map +1 -0
  58. package/lib/mjs/index.d.ts +0 -1
  59. package/lib/mjs/index.d.ts.map +1 -1
  60. package/lib/mjs/index.js +0 -1
  61. package/lib/mjs/index.js.map +1 -1
  62. package/lib/mjs/jws/index.d.ts +1 -0
  63. package/lib/mjs/jws/index.d.ts.map +1 -1
  64. package/lib/mjs/jws/index.js +1 -0
  65. package/lib/mjs/jws/index.js.map +1 -1
  66. package/lib/mjs/jws/register.d.ts +18 -0
  67. package/lib/mjs/jws/register.d.ts.map +1 -0
  68. package/lib/mjs/jws/register.js +62 -0
  69. package/lib/mjs/jws/register.js.map +1 -0
  70. package/lib/mjs/models/index.d.ts +0 -1
  71. package/lib/mjs/models/index.d.ts.map +1 -1
  72. package/lib/mjs/models/index.js +0 -1
  73. package/lib/mjs/models/index.js.map +1 -1
  74. package/lib/mjs/options/options.d.ts +10 -0
  75. package/lib/mjs/options/options.d.ts.map +1 -1
  76. package/lib/mjs/options/options.js +8 -0
  77. package/lib/mjs/options/options.js.map +1 -1
  78. package/lib/mjs/registry/cache.d.ts +26 -0
  79. package/lib/mjs/registry/cache.d.ts.map +1 -0
  80. package/lib/mjs/registry/cache.js +69 -0
  81. package/lib/mjs/registry/cache.js.map +1 -0
  82. package/lib/mjs/registry/index.d.ts +1 -0
  83. package/lib/mjs/registry/index.d.ts.map +1 -1
  84. package/lib/mjs/registry/index.js +1 -0
  85. package/lib/mjs/registry/index.js.map +1 -1
  86. package/lib/mjs/registry/registry.d.ts +15 -2
  87. package/lib/mjs/registry/registry.d.ts.map +1 -1
  88. package/lib/mjs/registry/registry.js +37 -4
  89. package/lib/mjs/registry/registry.js.map +1 -1
  90. package/lib/mjs/schema.d.ts +40 -0
  91. package/lib/mjs/schema.d.ts.map +1 -1
  92. package/lib/mjs/schema.js +19 -0
  93. package/lib/mjs/schema.js.map +1 -1
  94. package/lib/mjs/strategies/assertion.d.ts +4 -5
  95. package/lib/mjs/strategies/assertion.d.ts.map +1 -1
  96. package/lib/mjs/strategies/assertion.js +7 -6
  97. package/lib/mjs/strategies/assertion.js.map +1 -1
  98. package/lib/mjs/strategies/httpsig.d.ts +5 -4
  99. package/lib/mjs/strategies/httpsig.d.ts.map +1 -1
  100. package/lib/mjs/strategies/httpsig.js +10 -6
  101. package/lib/mjs/strategies/httpsig.js.map +1 -1
  102. package/lib/mjs/strategies/index.d.ts +1 -0
  103. package/lib/mjs/strategies/index.d.ts.map +1 -1
  104. package/lib/mjs/strategies/index.js +1 -0
  105. package/lib/mjs/strategies/index.js.map +1 -1
  106. package/lib/mjs/strategies/keys.d.ts +3 -1
  107. package/lib/mjs/strategies/keys.d.ts.map +1 -1
  108. package/lib/mjs/strategies/keys.js +8 -0
  109. package/lib/mjs/strategies/keys.js.map +1 -1
  110. package/lib/mjs/strategies/nonce-key.d.ts +3 -0
  111. package/lib/mjs/strategies/nonce-key.d.ts.map +1 -0
  112. package/lib/mjs/strategies/nonce-key.js +4 -0
  113. package/lib/mjs/strategies/nonce-key.js.map +1 -0
  114. package/lib/tsconfig.cjs.tsbuildinfo +1 -1
  115. package/lib/tsconfig.mjs.tsbuildinfo +1 -1
  116. package/package.json +20 -11
  117. package/lib/cjs/models/AuthnNonce.d.ts +0 -8
  118. package/lib/cjs/models/AuthnNonce.d.ts.map +0 -1
  119. package/lib/cjs/models/AuthnNonce.js +0 -31
  120. package/lib/cjs/models/AuthnNonce.js.map +0 -1
  121. package/lib/cjs/nonce/index.d.ts +0 -2
  122. package/lib/cjs/nonce/index.d.ts.map +0 -1
  123. package/lib/cjs/nonce/index.js +0 -18
  124. package/lib/cjs/nonce/index.js.map +0 -1
  125. package/lib/cjs/nonce/store.d.ts +0 -22
  126. package/lib/cjs/nonce/store.d.ts.map +0 -1
  127. package/lib/cjs/nonce/store.js +0 -98
  128. package/lib/cjs/nonce/store.js.map +0 -1
  129. package/lib/mjs/models/AuthnNonce.d.ts +0 -8
  130. package/lib/mjs/models/AuthnNonce.d.ts.map +0 -1
  131. package/lib/mjs/models/AuthnNonce.js +0 -28
  132. package/lib/mjs/models/AuthnNonce.js.map +0 -1
  133. package/lib/mjs/nonce/index.d.ts +0 -2
  134. package/lib/mjs/nonce/index.d.ts.map +0 -1
  135. package/lib/mjs/nonce/index.js +0 -2
  136. package/lib/mjs/nonce/index.js.map +0 -1
  137. package/lib/mjs/nonce/store.d.ts +0 -22
  138. package/lib/mjs/nonce/store.d.ts.map +0 -1
  139. package/lib/mjs/nonce/store.js +0 -92
  140. package/lib/mjs/nonce/store.js.map +0 -1
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@spinajs/authn-keys",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "description": "Key registry, JWS and HTTP signature authentication for SpinaJS",
5
5
  "main": "lib/cjs/index.js",
6
6
  "module": "lib/mjs/index.js",
@@ -64,18 +64,27 @@
64
64
  },
65
65
  "homepage": "https://github.com/spinajs/main#readme",
66
66
  "dependencies": {
67
- "@spinajs/authn": "3.0.2",
68
- "@spinajs/cli": "3.0.2",
69
- "@spinajs/configuration": "3.0.2",
70
- "@spinajs/di": "3.0.2",
71
- "@spinajs/exceptions": "3.0.2",
72
- "@spinajs/log": "3.0.2",
73
- "@spinajs/orm": "3.0.2",
74
- "@spinajs/util": "3.0.2",
67
+ "@spinajs/authn": "3.0.4",
68
+ "@spinajs/cli": "3.0.4",
69
+ "@spinajs/configuration": "3.0.4",
70
+ "@spinajs/di": "3.0.4",
71
+ "@spinajs/exceptions": "3.0.4",
72
+ "@spinajs/log": "3.0.4",
73
+ "@spinajs/orm": "3.0.4",
74
+ "@spinajs/util": "3.0.4",
75
75
  "luxon": "^3.6.1"
76
76
  },
77
+ "peerDependencies": {
78
+ "@spinajs/authn-orm": "3.0.4"
79
+ },
80
+ "peerDependenciesMeta": {
81
+ "@spinajs/authn-orm": {
82
+ "optional": true
83
+ }
84
+ },
77
85
  "devDependencies": {
78
- "@spinajs/authn-testing": "3.0.2",
79
- "@spinajs/orm-sqlite": "3.0.2"
86
+ "@spinajs/authn-orm": "3.0.4",
87
+ "@spinajs/authn-testing": "3.0.4",
88
+ "@spinajs/orm-sqlite": "3.0.4"
80
89
  }
81
90
  }
@@ -1,8 +0,0 @@
1
- import { ModelBase } from '@spinajs/orm';
2
- import { DateTime } from 'luxon';
3
- /** A row of authn_nonce (design §22.16; the table comes with authn-orm's AuthnInitial migration). */
4
- export declare class AuthnNonce extends ModelBase<AuthnNonce> {
5
- k: string;
6
- expires_at: DateTime;
7
- }
8
- //# sourceMappingURL=AuthnNonce.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AuthnNonce.d.ts","sourceRoot":"","sources":["../../../src/models/AuthnNonce.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,SAAS,EAAW,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,qGAAqG;AACrG,qBAEa,UAAW,SAAQ,SAAS,CAAC,UAAU,CAAC;IAE5C,CAAC,EAAE,MAAM,CAAC;IAGV,UAAU,EAAE,QAAQ,CAAC;CAC7B"}
@@ -1,31 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.AuthnNonce = void 0;
13
- const orm_1 = require("@spinajs/orm");
14
- const luxon_1 = require("luxon");
15
- /** A row of authn_nonce (design §22.16; the table comes with authn-orm's AuthnInitial migration). */
16
- let AuthnNonce = class AuthnNonce extends orm_1.ModelBase {
17
- };
18
- exports.AuthnNonce = AuthnNonce;
19
- __decorate([
20
- (0, orm_1.Primary)(),
21
- __metadata("design:type", String)
22
- ], AuthnNonce.prototype, "k", void 0);
23
- __decorate([
24
- (0, orm_1.DateTime)(),
25
- __metadata("design:type", luxon_1.DateTime)
26
- ], AuthnNonce.prototype, "expires_at", void 0);
27
- exports.AuthnNonce = AuthnNonce = __decorate([
28
- (0, orm_1.Connection)('default'),
29
- (0, orm_1.Model)('authn_nonce')
30
- ], AuthnNonce);
31
- //# sourceMappingURL=AuthnNonce.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AuthnNonce.js","sourceRoot":"","sources":["../../../src/models/AuthnNonce.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,sCAAqF;AACrF,iCAAiC;AAEjC,qGAAqG;AAG9F,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,eAAqB;CAMpD,CAAA;;AAJQ;IADN,IAAA,aAAO,GAAE;;qCACO;AAGV;IADN,IAAA,cAAE,GAAE;8BACc,gBAAQ;8CAAC;qBALjB,UAAU;IAFtB,IAAA,gBAAU,EAAC,SAAS,CAAC;IACrB,IAAA,WAAK,EAAC,aAAa,CAAC;GACR,UAAU,CAMtB"}
@@ -1,2 +0,0 @@
1
- export * from './store.js';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/nonce/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
- };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- __exportStar(require("./store.js"), exports);
18
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/nonce/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,6CAA2B"}
@@ -1,22 +0,0 @@
1
- import { Orm } from '@spinajs/orm';
2
- /** Single-use values (assertion jti, HTTP signature nonces) until they expire. */
3
- export declare abstract class KeyNonceStore {
4
- /** True exactly once while `key` is live: the first claim keeps it until `expiresAt`; an expired key may be claimed again. */
5
- abstract claim(key: string, expiresAt: Date, now: Date): Promise<boolean>;
6
- }
7
- /** A fixed-length store key for a value a client chose, scoped to the key that signed it. */
8
- export declare const nonceKey: (scope: 'jti' | 'sig', kid: string, value: string) => string;
9
- export declare class MemoryKeyNonceStore extends KeyNonceStore {
10
- private readonly live;
11
- private claims;
12
- claim(key: string, expiresAt: Date, now: Date): Promise<boolean>;
13
- }
14
- /** authn_nonce through the ORM: the primary key makes a claim atomic across processes. */
15
- export declare class DbKeyNonceStore extends KeyNonceStore {
16
- /** Binds the models when nothing else brought the Orm up. */
17
- protected Orm: Orm;
18
- private claims;
19
- claim(key: string, expiresAt: Date, now: Date): Promise<boolean>;
20
- private purge;
21
- }
22
- //# sourceMappingURL=store.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/nonce/store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAInC,kFAAkF;AAClF,8BAAsB,aAAa;IACjC,8HAA8H;IAC9H,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3E;AAED,6FAA6F;AAC7F,eAAO,MAAM,QAAQ,UAAW,KAAK,GAAG,KAAK,OAAO,MAAM,SAAS,MAAM,KAAG,MAAmG,CAAC;AAIhL,qBAAa,mBAAoB,SAAQ,aAAa;IACpD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA6B;IAClD,OAAO,CAAC,MAAM,CAAK;IAEb,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAgBrE;CACF;AAKD,0FAA0F;AAC1F,qBACa,eAAgB,SAAQ,aAAa;IAChD,6DAA6D;IAE7D,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;IAEnB,OAAO,CAAC,MAAM,CAAK;IAEb,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAsBrE;YAEa,KAAK;CAMpB"}
@@ -1,98 +0,0 @@
1
- "use strict";
2
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
- return c > 3 && r && Object.defineProperty(target, key, r), r;
7
- };
8
- var __metadata = (this && this.__metadata) || function (k, v) {
9
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.DbKeyNonceStore = exports.MemoryKeyNonceStore = exports.nonceKey = exports.KeyNonceStore = void 0;
13
- const node_crypto_1 = require("node:crypto");
14
- const di_1 = require("@spinajs/di");
15
- const orm_1 = require("@spinajs/orm");
16
- const luxon_1 = require("luxon");
17
- const AuthnNonce_js_1 = require("../models/AuthnNonce.js");
18
- /** Single-use values (assertion jti, HTTP signature nonces) until they expire. */
19
- class KeyNonceStore {
20
- }
21
- exports.KeyNonceStore = KeyNonceStore;
22
- /** A fixed-length store key for a value a client chose, scoped to the key that signed it. */
23
- const nonceKey = (scope, kid, value) => `${scope}:${(0, node_crypto_1.createHash)('sha256').update(`${kid}\n${value}`, 'utf8').digest('base64url')}`;
24
- exports.nonceKey = nonceKey;
25
- const SWEEP_EVERY = 256;
26
- class MemoryKeyNonceStore extends KeyNonceStore {
27
- constructor() {
28
- super(...arguments);
29
- this.live = new Map();
30
- this.claims = 0;
31
- }
32
- async claim(key, expiresAt, now) {
33
- const nowMs = now.getTime();
34
- this.claims += 1;
35
- if (this.claims % SWEEP_EVERY === 0) {
36
- for (const [k, until] of this.live) {
37
- if (until <= nowMs) {
38
- this.live.delete(k);
39
- }
40
- }
41
- }
42
- const until = this.live.get(key);
43
- if (until !== undefined && until > nowMs) {
44
- return false;
45
- }
46
- this.live.set(key, expiresAt.getTime());
47
- return true;
48
- }
49
- }
50
- exports.MemoryKeyNonceStore = MemoryKeyNonceStore;
51
- const PURGE_EVERY = 64;
52
- const PURGE_BATCH = 500;
53
- /** authn_nonce through the ORM: the primary key makes a claim atomic across processes. */
54
- let DbKeyNonceStore = class DbKeyNonceStore extends KeyNonceStore {
55
- constructor() {
56
- super(...arguments);
57
- this.claims = 0;
58
- }
59
- async claim(key, expiresAt, now) {
60
- const nowDt = luxon_1.DateTime.fromJSDate(now);
61
- this.claims += 1;
62
- if (this.claims % PURGE_EVERY === 0) {
63
- await this.purge(nowDt);
64
- }
65
- try {
66
- await new AuthnNonce_js_1.AuthnNonce({ k: key, expires_at: luxon_1.DateTime.fromJSDate(expiresAt) }).insert();
67
- return true;
68
- }
69
- catch (e) {
70
- // Taken: only an expired row may be taken over, and the conditional update lets one claimant win.
71
- const r = (await AuthnNonce_js_1.AuthnNonce.update({ expires_at: luxon_1.DateTime.fromJSDate(expiresAt) })
72
- .where('k', key)
73
- .where('expires_at', '<=', nowDt));
74
- if ((r?.RowsAffected ?? 0) === 1) {
75
- return true;
76
- }
77
- if ((await AuthnNonce_js_1.AuthnNonce.where('k', key)).length === 0) {
78
- throw e;
79
- }
80
- return false;
81
- }
82
- }
83
- async purge(now) {
84
- const expired = await AuthnNonce_js_1.AuthnNonce.where('expires_at', '<=', now).take(PURGE_BATCH);
85
- if (expired.length > 0) {
86
- await AuthnNonce_js_1.AuthnNonce.destroy(expired.map((r) => r.k)).where('expires_at', '<=', now);
87
- }
88
- }
89
- };
90
- exports.DbKeyNonceStore = DbKeyNonceStore;
91
- __decorate([
92
- (0, di_1.Autoinject)(orm_1.Orm),
93
- __metadata("design:type", orm_1.Orm)
94
- ], DbKeyNonceStore.prototype, "Orm", void 0);
95
- exports.DbKeyNonceStore = DbKeyNonceStore = __decorate([
96
- (0, di_1.Injectable)(KeyNonceStore)
97
- ], DbKeyNonceStore);
98
- //# sourceMappingURL=store.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"store.js","sourceRoot":"","sources":["../../../src/nonce/store.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,6CAAyC;AACzC,oCAAqD;AACrD,sCAAmC;AACnC,iCAAiC;AACjC,2DAAqD;AAErD,kFAAkF;AAClF;CAGC;;AAED,6FAA6F;AACtF,MAAM,QAAQ,GAAG,CAAC,KAAoB,EAAE,GAAW,EAAE,KAAa,EAAU,EAAE,CAAC,GAAG,KAAK,IAAI,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,GAAG,GAAG,KAAK,KAAK,EAAE,EAAE,MAAM,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,EAAE,CAAC;AAAnK,QAAA,QAAQ,GAAR,QAAQ,CAA2J;AAEhL,MAAM,WAAW,GAAG,GAAG,CAAC;AAExB,yBAAiC,SAAQ,aAAa;IAAtD;;QACmB,SAAI,GAAG,IAAI,GAAG,EAAkB,CAAC;QAC1C,WAAM,GAAG,CAAC,CAAC;IAmBrB,CAAC;IAjBC,KAAK,CAAC,KAAK,CAAC,GAAW,EAAE,SAAe,EAAE,GAAS;QACjD,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,EAAE,CAAC;QAC5B,IAAI,CAAC,MAAM,IAAI,CAAC,CAAC;QACjB,IAAI,IAAI,CAAC,MAAM,GAAG,WAAW,KAAK,CAAC,EAAE,CAAC;YACpC,KAAK,MAAM,CAAC,CAAC,EAAE,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;YAClG,MAAM,CAAC,GAAG,CAAC,MAAM,0BAAU,CAAC,MAAM,CAAC,EAAE,UAAU,EAAE,gBAAQ,CAAC,UAAU,CAAC,SAAS,CAAC,EAAE,CAAC;iBAC/E,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC;iBACf,KAAK,CAAC,YAAY,EAAE,IAAI,EAAE,KAAK,CAAC,CAAyC,CAAC;YAC7E,IAAI,CAAC,CAAC,EAAE,YAAY,IAAI,CAAC,CAAC,KAAK,CAAC,EAAE,CAAC;gBACjC,OAAO,IAAI,CAAC;YACd,CAAC;YACD,IAAI,CAAC,MAAM,0BAAU,CAAC,KAAK,CAAC,GAAG,EAAE,GAAG,CAAC,CAAC,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;gBACpD,MAAM,CAAC,CAAC;YACV,CAAC;YACD,OAAO,KAAK,CAAC;QACf,CAAC;IACH,CAAC;IAEO,KAAK,CAAC,KAAK,CAAC,GAAa;QAC/B,MAAM,OAAO,GAAiB,MAAM,0BAAU,CAAC,KAAK,CAAC,YAAY,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAChG,IAAI,OAAO,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;YACvB,MAAM,0BAAU,CAAC,OAAO,CAAC,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,KAAK,CAAC,YAAY,EAAE,IAAI,EAAE,GAAG,CAAC,CAAC;QACnF,CAAC;IACH,CAAC;CACF,CAAA;;AAlCW;IADT,IAAA,eAAU,EAAC,SAAG,CAAC;8BACD,SAAG;4CAAC;0BAHR,eAAe;IAD3B,IAAA,eAAU,EAAC,aAAa,CAAC;GACb,eAAe,CAqC3B"}
@@ -1,8 +0,0 @@
1
- import { ModelBase } from '@spinajs/orm';
2
- import { DateTime } from 'luxon';
3
- /** A row of authn_nonce (design §22.16; the table comes with authn-orm's AuthnInitial migration). */
4
- export declare class AuthnNonce extends ModelBase<AuthnNonce> {
5
- k: string;
6
- expires_at: DateTime;
7
- }
8
- //# sourceMappingURL=AuthnNonce.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AuthnNonce.d.ts","sourceRoot":"","sources":["../../../src/models/AuthnNonce.ts"],"names":[],"mappings":"AAAA,OAAO,EAAqC,SAAS,EAAW,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,qGAAqG;AACrG,qBAEa,UAAW,SAAQ,SAAS,CAAC,UAAU,CAAC;IAE5C,CAAC,EAAE,MAAM,CAAC;IAGV,UAAU,EAAE,QAAQ,CAAC;CAC7B"}
@@ -1,28 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import { Connection, DateTime as DT, Model, ModelBase, Primary } from '@spinajs/orm';
11
- import { DateTime } from 'luxon';
12
- /** A row of authn_nonce (design §22.16; the table comes with authn-orm's AuthnInitial migration). */
13
- let AuthnNonce = class AuthnNonce extends ModelBase {
14
- };
15
- __decorate([
16
- Primary(),
17
- __metadata("design:type", String)
18
- ], AuthnNonce.prototype, "k", void 0);
19
- __decorate([
20
- DT(),
21
- __metadata("design:type", DateTime)
22
- ], AuthnNonce.prototype, "expires_at", void 0);
23
- AuthnNonce = __decorate([
24
- Connection('default'),
25
- Model('authn_nonce')
26
- ], AuthnNonce);
27
- export { AuthnNonce };
28
- //# sourceMappingURL=AuthnNonce.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"AuthnNonce.js","sourceRoot":"","sources":["../../../src/models/AuthnNonce.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,QAAQ,IAAI,EAAE,EAAE,KAAK,EAAE,SAAS,EAAE,OAAO,EAAE,MAAM,cAAc,CAAC;AACrF,OAAO,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAEjC,qGAAqG;AAG9F,IAAM,UAAU,GAAhB,MAAM,UAAW,SAAQ,SAAqB;CAMpD,CAAA;AAJQ;IADN,OAAO,EAAE;;qCACO;AAGV;IADN,EAAE,EAAE;8BACc,QAAQ;8CAAC;AALjB,UAAU;IAFtB,UAAU,CAAC,SAAS,CAAC;IACrB,KAAK,CAAC,aAAa,CAAC;GACR,UAAU,CAMtB"}
@@ -1,2 +0,0 @@
1
- export * from './store.js';
2
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/nonce/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -1,2 +0,0 @@
1
- export * from './store.js';
2
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/nonce/index.ts"],"names":[],"mappings":"AAAA,cAAc,YAAY,CAAC"}
@@ -1,22 +0,0 @@
1
- import { Orm } from '@spinajs/orm';
2
- /** Single-use values (assertion jti, HTTP signature nonces) until they expire. */
3
- export declare abstract class KeyNonceStore {
4
- /** True exactly once while `key` is live: the first claim keeps it until `expiresAt`; an expired key may be claimed again. */
5
- abstract claim(key: string, expiresAt: Date, now: Date): Promise<boolean>;
6
- }
7
- /** A fixed-length store key for a value a client chose, scoped to the key that signed it. */
8
- export declare const nonceKey: (scope: 'jti' | 'sig', kid: string, value: string) => string;
9
- export declare class MemoryKeyNonceStore extends KeyNonceStore {
10
- private readonly live;
11
- private claims;
12
- claim(key: string, expiresAt: Date, now: Date): Promise<boolean>;
13
- }
14
- /** authn_nonce through the ORM: the primary key makes a claim atomic across processes. */
15
- export declare class DbKeyNonceStore extends KeyNonceStore {
16
- /** Binds the models when nothing else brought the Orm up. */
17
- protected Orm: Orm;
18
- private claims;
19
- claim(key: string, expiresAt: Date, now: Date): Promise<boolean>;
20
- private purge;
21
- }
22
- //# sourceMappingURL=store.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"store.d.ts","sourceRoot":"","sources":["../../../src/nonce/store.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AAInC,kFAAkF;AAClF,8BAAsB,aAAa;IACjC,8HAA8H;IAC9H,QAAQ,CAAC,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC;CAC3E;AAED,6FAA6F;AAC7F,eAAO,MAAM,QAAQ,UAAW,KAAK,GAAG,KAAK,OAAO,MAAM,SAAS,MAAM,KAAG,MAAmG,CAAC;AAIhL,qBAAa,mBAAoB,SAAQ,aAAa;IACpD,OAAO,CAAC,QAAQ,CAAC,IAAI,CAA6B;IAClD,OAAO,CAAC,MAAM,CAAK;IAEb,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAgBrE;CACF;AAKD,0FAA0F;AAC1F,qBACa,eAAgB,SAAQ,aAAa;IAChD,6DAA6D;IAE7D,SAAS,CAAC,GAAG,EAAE,GAAG,CAAC;IAEnB,OAAO,CAAC,MAAM,CAAK;IAEb,KAAK,CAAC,GAAG,EAAE,MAAM,EAAE,SAAS,EAAE,IAAI,EAAE,GAAG,EAAE,IAAI,GAAG,OAAO,CAAC,OAAO,CAAC,CAsBrE;YAEa,KAAK;CAMpB"}
@@ -1,92 +0,0 @@
1
- var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
2
- var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
3
- if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
4
- else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
5
- return c > 3 && r && Object.defineProperty(target, key, r), r;
6
- };
7
- var __metadata = (this && this.__metadata) || function (k, v) {
8
- if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
9
- };
10
- import { createHash } from 'node:crypto';
11
- import { Autoinject, Injectable } from '@spinajs/di';
12
- import { Orm } from '@spinajs/orm';
13
- import { DateTime } from 'luxon';
14
- import { AuthnNonce } from '../models/AuthnNonce.js';
15
- /** Single-use values (assertion jti, HTTP signature nonces) until they expire. */
16
- export class KeyNonceStore {
17
- }
18
- /** A fixed-length store key for a value a client chose, scoped to the key that signed it. */
19
- export const nonceKey = (scope, kid, value) => `${scope}:${createHash('sha256').update(`${kid}\n${value}`, 'utf8').digest('base64url')}`;
20
- const SWEEP_EVERY = 256;
21
- export class MemoryKeyNonceStore extends KeyNonceStore {
22
- constructor() {
23
- super(...arguments);
24
- this.live = new Map();
25
- this.claims = 0;
26
- }
27
- async claim(key, expiresAt, now) {
28
- const nowMs = now.getTime();
29
- this.claims += 1;
30
- if (this.claims % SWEEP_EVERY === 0) {
31
- for (const [k, until] of this.live) {
32
- if (until <= nowMs) {
33
- this.live.delete(k);
34
- }
35
- }
36
- }
37
- const until = this.live.get(key);
38
- if (until !== undefined && until > nowMs) {
39
- return false;
40
- }
41
- this.live.set(key, expiresAt.getTime());
42
- return true;
43
- }
44
- }
45
- const PURGE_EVERY = 64;
46
- const PURGE_BATCH = 500;
47
- /** authn_nonce through the ORM: the primary key makes a claim atomic across processes. */
48
- let DbKeyNonceStore = class DbKeyNonceStore extends KeyNonceStore {
49
- constructor() {
50
- super(...arguments);
51
- this.claims = 0;
52
- }
53
- async claim(key, expiresAt, now) {
54
- const nowDt = DateTime.fromJSDate(now);
55
- this.claims += 1;
56
- if (this.claims % PURGE_EVERY === 0) {
57
- await this.purge(nowDt);
58
- }
59
- try {
60
- await new AuthnNonce({ k: key, expires_at: DateTime.fromJSDate(expiresAt) }).insert();
61
- return true;
62
- }
63
- catch (e) {
64
- // Taken: only an expired row may be taken over, and the conditional update lets one claimant win.
65
- const r = (await AuthnNonce.update({ expires_at: DateTime.fromJSDate(expiresAt) })
66
- .where('k', key)
67
- .where('expires_at', '<=', nowDt));
68
- if ((r?.RowsAffected ?? 0) === 1) {
69
- return true;
70
- }
71
- if ((await AuthnNonce.where('k', key)).length === 0) {
72
- throw e;
73
- }
74
- return false;
75
- }
76
- }
77
- async purge(now) {
78
- const expired = await AuthnNonce.where('expires_at', '<=', now).take(PURGE_BATCH);
79
- if (expired.length > 0) {
80
- await AuthnNonce.destroy(expired.map((r) => r.k)).where('expires_at', '<=', now);
81
- }
82
- }
83
- };
84
- __decorate([
85
- Autoinject(Orm),
86
- __metadata("design:type", Orm)
87
- ], DbKeyNonceStore.prototype, "Orm", void 0);
88
- DbKeyNonceStore = __decorate([
89
- Injectable(KeyNonceStore)
90
- ], DbKeyNonceStore);
91
- export { DbKeyNonceStore };
92
- //# sourceMappingURL=store.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"store.js","sourceRoot":"","sources":["../../../src/nonce/store.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACzC,OAAO,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AACrD,OAAO,EAAE,GAAG,EAAE,MAAM,cAAc,CAAC;AACnC,OAAO,EAAE,QAAQ,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