@blamejs/core 0.14.27 → 0.15.0

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 (134) hide show
  1. package/CHANGELOG.md +4 -0
  2. package/README.md +2 -2
  3. package/index.js +4 -0
  4. package/lib/ai-content-detect.js +9 -10
  5. package/lib/api-key.js +107 -74
  6. package/lib/atomic-file.js +29 -1
  7. package/lib/audit-chain.js +47 -11
  8. package/lib/audit-sign.js +77 -2
  9. package/lib/audit-tools.js +79 -51
  10. package/lib/audit.js +218 -100
  11. package/lib/backup/index.js +13 -10
  12. package/lib/break-glass.js +202 -144
  13. package/lib/cache.js +174 -105
  14. package/lib/chain-writer.js +38 -16
  15. package/lib/cli.js +19 -14
  16. package/lib/cluster-provider-db.js +130 -104
  17. package/lib/cluster-storage.js +119 -22
  18. package/lib/cluster.js +119 -71
  19. package/lib/compliance.js +22 -0
  20. package/lib/consent.js +73 -24
  21. package/lib/constants.js +16 -11
  22. package/lib/crypto-field.js +387 -91
  23. package/lib/db-declare-row-policy.js +35 -22
  24. package/lib/db-file-lifecycle.js +3 -2
  25. package/lib/db-query.js +497 -255
  26. package/lib/db-schema.js +209 -44
  27. package/lib/db.js +176 -95
  28. package/lib/external-db-migrate.js +229 -139
  29. package/lib/external-db.js +25 -15
  30. package/lib/framework-error.js +11 -0
  31. package/lib/framework-files.js +73 -0
  32. package/lib/framework-schema.js +695 -394
  33. package/lib/gate-contract.js +596 -1
  34. package/lib/guard-agent-registry.js +26 -44
  35. package/lib/guard-all.js +1 -0
  36. package/lib/guard-auth.js +42 -112
  37. package/lib/guard-cidr.js +33 -154
  38. package/lib/guard-csv.js +46 -113
  39. package/lib/guard-domain.js +34 -157
  40. package/lib/guard-dsn.js +27 -43
  41. package/lib/guard-email.js +47 -69
  42. package/lib/guard-envelope.js +19 -32
  43. package/lib/guard-event-bus-payload.js +24 -42
  44. package/lib/guard-event-bus-topic.js +25 -43
  45. package/lib/guard-filename.js +42 -106
  46. package/lib/guard-graphql.js +42 -123
  47. package/lib/guard-html.js +53 -108
  48. package/lib/guard-idempotency-key.js +24 -42
  49. package/lib/guard-image.js +46 -103
  50. package/lib/guard-imap-command.js +18 -32
  51. package/lib/guard-jmap.js +16 -30
  52. package/lib/guard-json.js +38 -108
  53. package/lib/guard-jsonpath.js +38 -171
  54. package/lib/guard-jwt.js +49 -179
  55. package/lib/guard-list-id.js +25 -41
  56. package/lib/guard-list-unsubscribe.js +27 -43
  57. package/lib/guard-mail-compose.js +24 -42
  58. package/lib/guard-mail-move.js +26 -44
  59. package/lib/guard-mail-query.js +28 -46
  60. package/lib/guard-mail-reply.js +24 -42
  61. package/lib/guard-mail-sieve.js +24 -42
  62. package/lib/guard-managesieve-command.js +17 -31
  63. package/lib/guard-markdown.js +37 -104
  64. package/lib/guard-message-id.js +26 -45
  65. package/lib/guard-mime.js +39 -151
  66. package/lib/guard-oauth.js +54 -135
  67. package/lib/guard-pdf.js +45 -101
  68. package/lib/guard-pop3-command.js +21 -31
  69. package/lib/guard-posture-chain.js +24 -42
  70. package/lib/guard-regex.js +33 -107
  71. package/lib/guard-saga-config.js +24 -42
  72. package/lib/guard-shell.js +42 -172
  73. package/lib/guard-smtp-command.js +48 -54
  74. package/lib/guard-snapshot-envelope.js +24 -42
  75. package/lib/guard-sql.js +1491 -0
  76. package/lib/guard-stream-args.js +24 -43
  77. package/lib/guard-svg.js +47 -65
  78. package/lib/guard-template.js +35 -172
  79. package/lib/guard-tenant-id.js +26 -45
  80. package/lib/guard-time.js +32 -154
  81. package/lib/guard-trace-context.js +25 -44
  82. package/lib/guard-uuid.js +32 -153
  83. package/lib/guard-xml.js +38 -113
  84. package/lib/guard-yaml.js +51 -163
  85. package/lib/http-client.js +14 -0
  86. package/lib/inbox.js +120 -107
  87. package/lib/legal-hold.js +107 -50
  88. package/lib/log-stream-cloudwatch.js +47 -31
  89. package/lib/log-stream-otlp.js +32 -18
  90. package/lib/mail-crypto-smime.js +2 -6
  91. package/lib/mail-greylist.js +2 -6
  92. package/lib/mail-helo.js +2 -6
  93. package/lib/mail-journal.js +85 -64
  94. package/lib/mail-rbl.js +2 -6
  95. package/lib/mail-scan.js +2 -6
  96. package/lib/mail-spam-score.js +2 -6
  97. package/lib/mail-store.js +287 -154
  98. package/lib/middleware/fetch-metadata.js +17 -7
  99. package/lib/middleware/idempotency-key.js +54 -38
  100. package/lib/middleware/rate-limit.js +102 -32
  101. package/lib/middleware/security-headers.js +21 -5
  102. package/lib/migrations.js +108 -66
  103. package/lib/network-heartbeat.js +7 -0
  104. package/lib/nonce-store.js +31 -9
  105. package/lib/object-store/azure-blob-bucket-ops.js +9 -4
  106. package/lib/object-store/azure-blob.js +31 -3
  107. package/lib/object-store/sigv4.js +10 -0
  108. package/lib/outbox.js +136 -82
  109. package/lib/pqc-agent.js +44 -0
  110. package/lib/pubsub-cluster.js +42 -20
  111. package/lib/queue-local.js +202 -139
  112. package/lib/queue-redis.js +9 -1
  113. package/lib/queue-sqs.js +6 -0
  114. package/lib/retention.js +82 -39
  115. package/lib/safe-dns.js +29 -45
  116. package/lib/safe-ical.js +18 -33
  117. package/lib/safe-icap.js +27 -43
  118. package/lib/safe-sieve.js +21 -40
  119. package/lib/safe-sql.js +124 -3
  120. package/lib/safe-vcard.js +18 -33
  121. package/lib/scheduler.js +35 -12
  122. package/lib/seeders.js +122 -74
  123. package/lib/session-stores.js +42 -14
  124. package/lib/session.js +109 -72
  125. package/lib/sql.js +3885 -0
  126. package/lib/static.js +45 -7
  127. package/lib/subject.js +55 -17
  128. package/lib/vault/index.js +3 -2
  129. package/lib/vault/passphrase-ops.js +3 -2
  130. package/lib/vault/rotate.js +104 -64
  131. package/lib/vendor-data.js +2 -0
  132. package/lib/websocket.js +16 -0
  133. package/package.json +1 -1
  134. package/sbom.cdx.json +6 -6
@@ -36,6 +36,7 @@
36
36
  */
37
37
 
38
38
  var { defineClass } = require("./framework-error");
39
+ var gateContract = require("./gate-contract");
39
40
 
40
41
  var GuardMailComposeError = defineClass("GuardMailComposeError", { alwaysPermanent: true });
41
42
 
@@ -47,11 +48,14 @@ var PROFILES = Object.freeze({
47
48
  permissive: { maxRecipients: 2000, maxAttachmentBytes: 104857600, maxSubjectBytes: 998 }, // 100 MiB
48
49
  });
49
50
 
50
- var COMPLIANCE_POSTURES = Object.freeze({
51
- hipaa: "strict",
52
- "pci-dss": "strict",
53
- gdpr: "strict",
54
- soc2: "strict",
51
+ var COMPLIANCE_POSTURES = gateContract.ALL_STRICT_POSTURES;
52
+
53
+ var _resolveProfile = gateContract.makeProfileResolver({
54
+ profiles: PROFILES,
55
+ postures: COMPLIANCE_POSTURES,
56
+ defaults: DEFAULT_PROFILE,
57
+ errorClass: GuardMailComposeError,
58
+ codePrefix: "mail-compose",
55
59
  });
56
60
 
57
61
  /**
@@ -131,22 +135,10 @@ function validate(draft, opts) {
131
135
  return draft;
132
136
  }
133
137
 
134
- /**
135
- * @primitive b.guardMailCompose.compliancePosture
136
- * @signature b.guardMailCompose.compliancePosture(posture)
137
- * @since 0.9.20
138
- * @status stable
139
- *
140
- * Return the effective profile for a given compliance posture name.
141
- * Returns `null` for unknown posture names so operator typos surface
142
- * here instead of silently falling through to the default profile.
143
- *
144
- * @example
145
- * b.guardMailCompose.compliancePosture("hipaa"); // → "strict"
146
- */
147
- function compliancePosture(posture) {
148
- return COMPLIANCE_POSTURES[posture] || null;
149
- }
138
+ // compliancePosture is assembled by gateContract.defineParser below; its
139
+ // wiki section renders from the single-sourced @abiTemplate (defineParser)
140
+ // block in gate-contract.js, instantiated for this guard by the page
141
+ // generator.
150
142
 
151
143
  function _checkAddrList(list, label, profile) {
152
144
  if (typeof list === "undefined" || list === null) return;
@@ -259,24 +251,14 @@ function _anyRecipient(draft) {
259
251
  });
260
252
  }
261
253
 
262
- function _resolveProfile(opts) {
263
- if (opts.posture && COMPLIANCE_POSTURES[opts.posture]) {
264
- return COMPLIANCE_POSTURES[opts.posture];
265
- }
266
- var p = opts.profile || DEFAULT_PROFILE;
267
- if (!PROFILES[p]) {
268
- throw new GuardMailComposeError("mail-compose/bad-profile",
269
- "guardMailCompose: unknown profile '" + p + "'");
270
- }
271
- return p;
272
- }
273
-
274
- module.exports = {
275
- validate: validate,
276
- compliancePosture: compliancePosture,
277
- PROFILES: PROFILES,
278
- COMPLIANCE_POSTURES: COMPLIANCE_POSTURES,
279
- GuardMailComposeError: GuardMailComposeError,
280
- NAME: "mailCompose",
281
- KIND: "mail-compose",
282
- };
254
+ module.exports = gateContract.defineParser({
255
+ name: "mailCompose",
256
+ entry: validate,
257
+ errorClass: GuardMailComposeError,
258
+ profiles: PROFILES,
259
+ postures: COMPLIANCE_POSTURES,
260
+ extra: {
261
+ NAME: "mailCompose",
262
+ KIND: "mail-compose",
263
+ },
264
+ });
@@ -34,6 +34,7 @@
34
34
  */
35
35
 
36
36
  var { defineClass } = require("./framework-error");
37
+ var gateContract = require("./gate-contract");
37
38
 
38
39
  var GuardMailMoveError = defineClass("GuardMailMoveError", { alwaysPermanent: true });
39
40
 
@@ -45,18 +46,21 @@ var PROFILES = Object.freeze({
45
46
  permissive: { maxObjectIds: 50000, maxFolderNameBytes: 1024 },
46
47
  });
47
48
 
48
- var COMPLIANCE_POSTURES = Object.freeze({
49
- hipaa: "strict",
50
- "pci-dss": "strict",
51
- gdpr: "strict",
52
- soc2: "strict",
53
- });
49
+ var COMPLIANCE_POSTURES = gateContract.ALL_STRICT_POSTURES;
54
50
 
55
51
  // System folders every actor may write to without admin scope.
56
52
  var SYSTEM_FOLDERS = Object.freeze({
57
53
  INBOX: true, Sent: true, Drafts: true, Trash: true, Junk: true, Archive: true,
58
54
  });
59
55
 
56
+ var _resolveProfile = gateContract.makeProfileResolver({
57
+ profiles: PROFILES,
58
+ postures: COMPLIANCE_POSTURES,
59
+ defaults: DEFAULT_PROFILE,
60
+ errorClass: GuardMailMoveError,
61
+ codePrefix: "mail-move",
62
+ });
63
+
60
64
  /**
61
65
  * @primitive b.guardMailMove.validate
62
66
  * @signature b.guardMailMove.validate(move, opts?)
@@ -128,22 +132,10 @@ function validate(move, opts) {
128
132
  "' requires mailScope:'admin' or membership in actor.allowedFolders");
129
133
  }
130
134
 
131
- /**
132
- * @primitive b.guardMailMove.compliancePosture
133
- * @signature b.guardMailMove.compliancePosture(posture)
134
- * @since 0.9.20
135
- * @status stable
136
- *
137
- * Return the effective profile for a given compliance posture name.
138
- * Returns `null` for unknown posture names so operator typos surface
139
- * here instead of silently falling through to the default profile.
140
- *
141
- * @example
142
- * b.guardMailMove.compliancePosture("hipaa"); // → "strict"
143
- */
144
- function compliancePosture(posture) {
145
- return COMPLIANCE_POSTURES[posture] || null;
146
- }
135
+ // compliancePosture is assembled by gateContract.defineParser below; its
136
+ // wiki section renders from the single-sourced @abiTemplate (defineParser)
137
+ // block in gate-contract.js, instantiated for this guard by the page
138
+ // generator.
147
139
 
148
140
  function _checkFolderName(name, label, profile) {
149
141
  if (typeof name !== "string" || name.length === 0) {
@@ -178,25 +170,15 @@ function _checkFolderName(name, label, profile) {
178
170
  }
179
171
  }
180
172
 
181
- function _resolveProfile(opts) {
182
- if (opts.posture && COMPLIANCE_POSTURES[opts.posture]) {
183
- return COMPLIANCE_POSTURES[opts.posture];
184
- }
185
- var p = opts.profile || DEFAULT_PROFILE;
186
- if (!PROFILES[p]) {
187
- throw new GuardMailMoveError("mail-move/bad-profile",
188
- "guardMailMove: unknown profile '" + p + "'");
189
- }
190
- return p;
191
- }
192
-
193
- module.exports = {
194
- validate: validate,
195
- compliancePosture: compliancePosture,
196
- PROFILES: PROFILES,
197
- COMPLIANCE_POSTURES: COMPLIANCE_POSTURES,
198
- SYSTEM_FOLDERS: SYSTEM_FOLDERS,
199
- GuardMailMoveError: GuardMailMoveError,
200
- NAME: "mailMove",
201
- KIND: "mail-move",
202
- };
173
+ module.exports = gateContract.defineParser({
174
+ name: "mailMove",
175
+ entry: validate,
176
+ errorClass: GuardMailMoveError,
177
+ profiles: PROFILES,
178
+ postures: COMPLIANCE_POSTURES,
179
+ extra: {
180
+ SYSTEM_FOLDERS: SYSTEM_FOLDERS,
181
+ NAME: "mailMove",
182
+ KIND: "mail-move",
183
+ },
184
+ });
@@ -27,6 +27,7 @@
27
27
  */
28
28
 
29
29
  var { defineClass } = require("./framework-error");
30
+ var gateContract = require("./gate-contract");
30
31
 
31
32
  var GuardMailQueryError = defineClass("GuardMailQueryError", { alwaysPermanent: true });
32
33
 
@@ -38,12 +39,7 @@ var PROFILES = Object.freeze({
38
39
  permissive: { maxDepth: 24, maxKeys: 512, maxStringBytes: 65536, maxArrayLen: 4096 },
39
40
  });
40
41
 
41
- var COMPLIANCE_POSTURES = Object.freeze({
42
- hipaa: "strict",
43
- "pci-dss": "strict",
44
- gdpr: "strict",
45
- soc2: "strict",
46
- });
42
+ var COMPLIANCE_POSTURES = gateContract.ALL_STRICT_POSTURES;
47
43
 
48
44
  // Columns the filter may reference and the projection may request.
49
45
  // Sealed columns can be `=` / `IN` matched (the mail-store walks
@@ -92,6 +88,14 @@ var POSTURE_ACTOR_FIELDS = Object.freeze({
92
88
  soc2: [],
93
89
  });
94
90
 
91
+ var _resolveProfile = gateContract.makeProfileResolver({
92
+ profiles: PROFILES,
93
+ postures: COMPLIANCE_POSTURES,
94
+ defaults: DEFAULT_PROFILE,
95
+ errorClass: GuardMailQueryError,
96
+ codePrefix: "mail-query",
97
+ });
98
+
95
99
  /**
96
100
  * @primitive b.guardMailQuery.validate
97
101
  * @signature b.guardMailQuery.validate(filter, opts?)
@@ -174,22 +178,10 @@ function validateActor(actor, posture) {
174
178
  return actor;
175
179
  }
176
180
 
177
- /**
178
- * @primitive b.guardMailQuery.compliancePosture
179
- * @signature b.guardMailQuery.compliancePosture(posture)
180
- * @since 0.9.20
181
- * @status stable
182
- *
183
- * Return the effective profile for a given compliance posture name.
184
- * Returns `null` when the posture is unknown (operator-supplied typos
185
- * surface here instead of silently falling back to the default).
186
- *
187
- * @example
188
- * b.guardMailQuery.compliancePosture("hipaa"); // → "strict"
189
- */
190
- function compliancePosture(posture) {
191
- return COMPLIANCE_POSTURES[posture] || null;
192
- }
181
+ // compliancePosture is assembled by gateContract.defineParser below; its
182
+ // wiki section renders from the single-sourced @abiTemplate (defineParser)
183
+ // block in gate-contract.js, instantiated for this guard by the page
184
+ // generator.
193
185
 
194
186
  function _walk(node, depth, profile, visited) {
195
187
  if (depth > profile.maxDepth) {
@@ -284,27 +276,17 @@ function _checkScalar(v, profile) {
284
276
  }
285
277
  }
286
278
 
287
- function _resolveProfile(opts) {
288
- if (opts.posture && COMPLIANCE_POSTURES[opts.posture]) {
289
- return COMPLIANCE_POSTURES[opts.posture];
290
- }
291
- var p = opts.profile || DEFAULT_PROFILE;
292
- if (!PROFILES[p]) {
293
- throw new GuardMailQueryError("mail-query/bad-profile",
294
- "guardMailQuery: unknown profile '" + p + "'");
295
- }
296
- return p;
297
- }
298
-
299
- module.exports = {
300
- validate: validate,
301
- validateActor: validateActor,
302
- compliancePosture: compliancePosture,
303
- PROFILES: PROFILES,
304
- COMPLIANCE_POSTURES: COMPLIANCE_POSTURES,
305
- FILTERABLE_COLUMNS: FILTERABLE_COLUMNS,
306
- POSTURE_ACTOR_FIELDS: POSTURE_ACTOR_FIELDS,
307
- GuardMailQueryError: GuardMailQueryError,
308
- NAME: "mailQuery",
309
- KIND: "mail-query",
310
- };
279
+ module.exports = gateContract.defineParser({
280
+ name: "mailQuery",
281
+ entry: validate,
282
+ errorClass: GuardMailQueryError,
283
+ profiles: PROFILES,
284
+ postures: COMPLIANCE_POSTURES,
285
+ extra: {
286
+ validateActor: validateActor,
287
+ FILTERABLE_COLUMNS: FILTERABLE_COLUMNS,
288
+ POSTURE_ACTOR_FIELDS: POSTURE_ACTOR_FIELDS,
289
+ NAME: "mailQuery",
290
+ KIND: "mail-query",
291
+ },
292
+ });
@@ -30,6 +30,7 @@
30
30
 
31
31
  var { defineClass } = require("./framework-error");
32
32
  var guardMessageId = require("./guard-message-id");
33
+ var gateContract = require("./gate-contract");
33
34
 
34
35
  var GuardMailReplyError = defineClass("GuardMailReplyError", { alwaysPermanent: true });
35
36
 
@@ -41,11 +42,14 @@ var PROFILES = Object.freeze({
41
42
  permissive: { maxChainLength: 2000, maxQuotedBytes: 10485760, maxForwardedAttachments: 512 }, // chain count + 10 MiB
42
43
  });
43
44
 
44
- var COMPLIANCE_POSTURES = Object.freeze({
45
- hipaa: "strict",
46
- "pci-dss": "strict",
47
- gdpr: "strict",
48
- soc2: "strict",
45
+ var COMPLIANCE_POSTURES = gateContract.ALL_STRICT_POSTURES;
46
+
47
+ var _resolveProfile = gateContract.makeProfileResolver({
48
+ profiles: PROFILES,
49
+ postures: COMPLIANCE_POSTURES,
50
+ defaults: DEFAULT_PROFILE,
51
+ errorClass: GuardMailReplyError,
52
+ codePrefix: "mail-reply",
49
53
  });
50
54
 
51
55
  /**
@@ -132,41 +136,19 @@ function validate(reply, opts) {
132
136
  return reply;
133
137
  }
134
138
 
135
- /**
136
- * @primitive b.guardMailReply.compliancePosture
137
- * @signature b.guardMailReply.compliancePosture(posture)
138
- * @since 0.9.20
139
- * @status stable
140
- *
141
- * Return the effective profile for a given compliance posture name.
142
- * Returns `null` for unknown posture names so operator typos surface
143
- * here instead of silently falling through to the default profile.
144
- *
145
- * @example
146
- * b.guardMailReply.compliancePosture("hipaa"); // → "strict"
147
- */
148
- function compliancePosture(posture) {
149
- return COMPLIANCE_POSTURES[posture] || null;
150
- }
151
-
152
- function _resolveProfile(opts) {
153
- if (opts.posture && COMPLIANCE_POSTURES[opts.posture]) {
154
- return COMPLIANCE_POSTURES[opts.posture];
155
- }
156
- var p = opts.profile || DEFAULT_PROFILE;
157
- if (!PROFILES[p]) {
158
- throw new GuardMailReplyError("mail-reply/bad-profile",
159
- "guardMailReply: unknown profile '" + p + "'");
160
- }
161
- return p;
162
- }
139
+ // compliancePosture is assembled by gateContract.defineParser below; its
140
+ // wiki section renders from the single-sourced @abiTemplate (defineParser)
141
+ // block in gate-contract.js, instantiated for this guard by the page
142
+ // generator.
163
143
 
164
- module.exports = {
165
- validate: validate,
166
- compliancePosture: compliancePosture,
167
- PROFILES: PROFILES,
168
- COMPLIANCE_POSTURES: COMPLIANCE_POSTURES,
169
- GuardMailReplyError: GuardMailReplyError,
170
- NAME: "mailReply",
171
- KIND: "mail-reply",
172
- };
144
+ module.exports = gateContract.defineParser({
145
+ name: "mail-reply",
146
+ entry: validate,
147
+ errorClass: GuardMailReplyError,
148
+ profiles: PROFILES,
149
+ postures: COMPLIANCE_POSTURES,
150
+ extra: {
151
+ NAME: "mailReply",
152
+ KIND: "mail-reply",
153
+ },
154
+ });
@@ -33,6 +33,7 @@
33
33
  */
34
34
 
35
35
  var { defineClass } = require("./framework-error");
36
+ var gateContract = require("./gate-contract");
36
37
 
37
38
  var GuardMailSieveError = defineClass("GuardMailSieveError", { alwaysPermanent: true });
38
39
 
@@ -44,11 +45,14 @@ var PROFILES = Object.freeze({
44
45
  permissive: { maxScriptBytes: 1048576, maxNameBytes: 1024, maxLines: 50000 },
45
46
  });
46
47
 
47
- var COMPLIANCE_POSTURES = Object.freeze({
48
- hipaa: "strict",
49
- "pci-dss": "strict",
50
- gdpr: "strict",
51
- soc2: "strict",
48
+ var COMPLIANCE_POSTURES = gateContract.ALL_STRICT_POSTURES;
49
+
50
+ var _resolveProfile = gateContract.makeProfileResolver({
51
+ profiles: PROFILES,
52
+ postures: COMPLIANCE_POSTURES,
53
+ defaults: DEFAULT_PROFILE,
54
+ errorClass: GuardMailSieveError,
55
+ codePrefix: "mail-sieve",
52
56
  });
53
57
 
54
58
  /**
@@ -145,22 +149,10 @@ function validate(op, opts) {
145
149
  return op;
146
150
  }
147
151
 
148
- /**
149
- * @primitive b.guardMailSieve.compliancePosture
150
- * @signature b.guardMailSieve.compliancePosture(posture)
151
- * @since 0.9.20
152
- * @status stable
153
- *
154
- * Return the effective profile for a given compliance posture name.
155
- * Returns `null` for unknown posture names so operator typos surface
156
- * here instead of silently falling through to the default profile.
157
- *
158
- * @example
159
- * b.guardMailSieve.compliancePosture("hipaa"); // → "strict"
160
- */
161
- function compliancePosture(posture) {
162
- return COMPLIANCE_POSTURES[posture] || null;
163
- }
152
+ // compliancePosture is assembled by gateContract.defineParser below; its
153
+ // wiki section renders from the single-sourced @abiTemplate (defineParser)
154
+ // block in gate-contract.js, instantiated for this guard by the page
155
+ // generator.
164
156
 
165
157
  function _checkName(name, profile) {
166
158
  if (typeof name !== "string" || name.length === 0) {
@@ -184,24 +176,14 @@ function _checkName(name, profile) {
184
176
  }
185
177
  }
186
178
 
187
- function _resolveProfile(opts) {
188
- if (opts.posture && COMPLIANCE_POSTURES[opts.posture]) {
189
- return COMPLIANCE_POSTURES[opts.posture];
190
- }
191
- var p = opts.profile || DEFAULT_PROFILE;
192
- if (!PROFILES[p]) {
193
- throw new GuardMailSieveError("mail-sieve/bad-profile",
194
- "guardMailSieve: unknown profile '" + p + "'");
195
- }
196
- return p;
197
- }
198
-
199
- module.exports = {
200
- validate: validate,
201
- compliancePosture: compliancePosture,
202
- PROFILES: PROFILES,
203
- COMPLIANCE_POSTURES: COMPLIANCE_POSTURES,
204
- GuardMailSieveError: GuardMailSieveError,
205
- NAME: "mailSieve",
206
- KIND: "mail-sieve",
207
- };
179
+ module.exports = gateContract.defineParser({
180
+ name: "mail-sieve",
181
+ entry: validate,
182
+ errorClass: GuardMailSieveError,
183
+ profiles: PROFILES,
184
+ postures: COMPLIANCE_POSTURES,
185
+ extra: {
186
+ NAME: "mailSieve",
187
+ KIND: "mail-sieve",
188
+ },
189
+ });
@@ -101,6 +101,7 @@
101
101
  */
102
102
 
103
103
  var { defineClass } = require("./framework-error");
104
+ var gateContract = require("./gate-contract");
104
105
 
105
106
  var GuardManageSieveCommandError = defineClass("GuardManageSieveCommandError",
106
107
  { alwaysPermanent: true });
@@ -134,12 +135,7 @@ var PROFILES = Object.freeze({
134
135
  },
135
136
  });
136
137
 
137
- var COMPLIANCE_POSTURES = Object.freeze({
138
- hipaa: "strict",
139
- "pci-dss": "strict",
140
- gdpr: "strict",
141
- soc2: "strict",
142
- });
138
+ var COMPLIANCE_POSTURES = gateContract.ALL_STRICT_POSTURES;
143
139
 
144
140
  // ManageSieve verbs per RFC 5804 §2.
145
141
  var KNOWN_VERBS = Object.freeze({
@@ -539,28 +535,18 @@ function _checkScriptNameBytes(name, caps) {
539
535
  }
540
536
  }
541
537
 
542
- /**
543
- * @primitive b.guardManageSieveCommand.compliancePosture
544
- * @signature b.guardManageSieveCommand.compliancePosture(posture)
545
- * @since 0.9.57
546
- * @status stable
547
- *
548
- * Return the effective profile for a compliance posture, or `null`
549
- * for unknown names.
550
- *
551
- * @example
552
- * b.guardManageSieveCommand.compliancePosture("hipaa"); // → "strict"
553
- */
554
- function compliancePosture(posture) {
555
- return COMPLIANCE_POSTURES[posture] || null;
556
- }
557
-
558
- module.exports = {
559
- validate: validate,
560
- compliancePosture: compliancePosture,
561
- PROFILES: PROFILES,
562
- COMPLIANCE_POSTURES: COMPLIANCE_POSTURES,
563
- KNOWN_VERBS: KNOWN_VERBS,
564
- ZERO_ARG_VERBS: ZERO_ARG_VERBS,
565
- GuardManageSieveCommandError: GuardManageSieveCommandError,
566
- };
538
+ // compliancePosture is assembled by gateContract.defineParser below; its
539
+ // wiki section renders from the single-sourced @abiTemplate (defineParser)
540
+ // block in gate-contract.js, instantiated for this guard by the page
541
+ // generator.
542
+ module.exports = gateContract.defineParser({
543
+ name: "managesieve-command",
544
+ entry: validate,
545
+ errorClass: GuardManageSieveCommandError,
546
+ profiles: PROFILES,
547
+ postures: COMPLIANCE_POSTURES,
548
+ extra: {
549
+ KNOWN_VERBS: KNOWN_VERBS,
550
+ ZERO_ARG_VERBS: ZERO_ARG_VERBS,
551
+ },
552
+ });