@cardanowall/poe-standard 0.3.0 → 0.4.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.
@@ -2,22 +2,63 @@ import { ErrorCode, Severity } from './error-codes.cjs';
2
2
  import { PoeRecord } from './schema.cjs';
3
3
  import 'zod';
4
4
 
5
+ type ValidatorRole = 'public' | 'recipient_or_strict';
6
+ interface Argon2ParamsCeiling {
7
+ readonly m: number;
8
+ readonly t: number;
9
+ readonly p: number;
10
+ }
11
+ declare const DEFAULT_PASSPHRASE_PARAMS_CEILING: Argon2ParamsCeiling;
12
+ interface ValidatorOptions {
13
+ /**
14
+ * Names of the critical extensions this validator implements. Default: the
15
+ * empty set — a default-configured validator therefore fails every
16
+ * `crit`-bearing record with `EXTENSION_UNSUPPORTED_CRITICAL`, by design.
17
+ */
18
+ readonly supportedCriticalExtensions?: ReadonlySet<string>;
19
+ /**
20
+ * The validation reading for dual-severity envelope dispositions.
21
+ * `public` (default): an envelope under an unsupported `scheme` / `kem` /
22
+ * `aead` degrades to opaque and `ENC_UNSUPPORTED` is informational.
23
+ * `recipient_or_strict` (the recipient verifier and strict sealed-crypto
24
+ * mode): the same condition is a hard reject — `ENC_UNSUPPORTED` escalates
25
+ * to `error` and co-fires with the identifier-specific `UNSUPPORTED_*`
26
+ * code.
27
+ */
28
+ readonly role?: ValidatorRole;
29
+ /** Slot-count resource bound (reference bound 1024; deployments MAY tighten). */
30
+ readonly maxSlots?: number;
31
+ /** Decoded-envelope byte resource bound (reference bound 65536). */
32
+ readonly maxEncEnvelopeBytes?: number;
33
+ /**
34
+ * Upper policy ceiling on Argon2id parameters
35
+ * (`ENC_PASSPHRASE_PARAMS_EXCEED_POLICY`). Defaults to
36
+ * `DEFAULT_PASSPHRASE_PARAMS_CEILING`; `null` disables the ceiling.
37
+ */
38
+ readonly passphraseParamsCeiling?: Argon2ParamsCeiling | null;
39
+ }
5
40
  interface ValidationIssue {
6
- readonly code: ErrorCode;
41
+ /**
42
+ * Segments from the record root: text map keys and integer array indices
43
+ * (e.g. `["items", 0, "hashes", "sha2-256"]`). A dotted string is a display
44
+ * rendering only — the segment list is the API form, so map keys containing
45
+ * `.` need no escaping.
46
+ */
7
47
  readonly path: ReadonlyArray<string | number>;
8
- readonly message: string;
48
+ readonly code: ErrorCode;
9
49
  readonly severity: Severity;
50
+ readonly message: string;
10
51
  }
11
- type ValidateResult = {
12
- readonly ok: true;
52
+ type ValidationResult = {
53
+ readonly valid: true;
13
54
  readonly record: PoeRecord;
14
55
  readonly warnings?: ReadonlyArray<ValidationIssue>;
15
56
  readonly info?: ReadonlyArray<ValidationIssue>;
16
57
  } | {
17
- readonly ok: false;
58
+ readonly valid: false;
18
59
  readonly issues: ReadonlyArray<ValidationIssue>;
19
60
  };
20
- declare function validatePoeRecord(bytes: Uint8Array): ValidateResult;
61
+ declare function validatePoeRecord(bytes: Uint8Array, options?: ValidatorOptions): ValidationResult;
21
62
  declare function validateCidProfile(cid: string): boolean;
22
63
 
23
- export { type ValidateResult, type ValidationIssue, validateCidProfile, validatePoeRecord };
64
+ export { type Argon2ParamsCeiling, DEFAULT_PASSPHRASE_PARAMS_CEILING, type ValidationIssue, type ValidationResult, type ValidatorOptions, type ValidatorRole, validateCidProfile, validatePoeRecord };
@@ -2,22 +2,63 @@ import { ErrorCode, Severity } from './error-codes.js';
2
2
  import { PoeRecord } from './schema.js';
3
3
  import 'zod';
4
4
 
5
+ type ValidatorRole = 'public' | 'recipient_or_strict';
6
+ interface Argon2ParamsCeiling {
7
+ readonly m: number;
8
+ readonly t: number;
9
+ readonly p: number;
10
+ }
11
+ declare const DEFAULT_PASSPHRASE_PARAMS_CEILING: Argon2ParamsCeiling;
12
+ interface ValidatorOptions {
13
+ /**
14
+ * Names of the critical extensions this validator implements. Default: the
15
+ * empty set — a default-configured validator therefore fails every
16
+ * `crit`-bearing record with `EXTENSION_UNSUPPORTED_CRITICAL`, by design.
17
+ */
18
+ readonly supportedCriticalExtensions?: ReadonlySet<string>;
19
+ /**
20
+ * The validation reading for dual-severity envelope dispositions.
21
+ * `public` (default): an envelope under an unsupported `scheme` / `kem` /
22
+ * `aead` degrades to opaque and `ENC_UNSUPPORTED` is informational.
23
+ * `recipient_or_strict` (the recipient verifier and strict sealed-crypto
24
+ * mode): the same condition is a hard reject — `ENC_UNSUPPORTED` escalates
25
+ * to `error` and co-fires with the identifier-specific `UNSUPPORTED_*`
26
+ * code.
27
+ */
28
+ readonly role?: ValidatorRole;
29
+ /** Slot-count resource bound (reference bound 1024; deployments MAY tighten). */
30
+ readonly maxSlots?: number;
31
+ /** Decoded-envelope byte resource bound (reference bound 65536). */
32
+ readonly maxEncEnvelopeBytes?: number;
33
+ /**
34
+ * Upper policy ceiling on Argon2id parameters
35
+ * (`ENC_PASSPHRASE_PARAMS_EXCEED_POLICY`). Defaults to
36
+ * `DEFAULT_PASSPHRASE_PARAMS_CEILING`; `null` disables the ceiling.
37
+ */
38
+ readonly passphraseParamsCeiling?: Argon2ParamsCeiling | null;
39
+ }
5
40
  interface ValidationIssue {
6
- readonly code: ErrorCode;
41
+ /**
42
+ * Segments from the record root: text map keys and integer array indices
43
+ * (e.g. `["items", 0, "hashes", "sha2-256"]`). A dotted string is a display
44
+ * rendering only — the segment list is the API form, so map keys containing
45
+ * `.` need no escaping.
46
+ */
7
47
  readonly path: ReadonlyArray<string | number>;
8
- readonly message: string;
48
+ readonly code: ErrorCode;
9
49
  readonly severity: Severity;
50
+ readonly message: string;
10
51
  }
11
- type ValidateResult = {
12
- readonly ok: true;
52
+ type ValidationResult = {
53
+ readonly valid: true;
13
54
  readonly record: PoeRecord;
14
55
  readonly warnings?: ReadonlyArray<ValidationIssue>;
15
56
  readonly info?: ReadonlyArray<ValidationIssue>;
16
57
  } | {
17
- readonly ok: false;
58
+ readonly valid: false;
18
59
  readonly issues: ReadonlyArray<ValidationIssue>;
19
60
  };
20
- declare function validatePoeRecord(bytes: Uint8Array): ValidateResult;
61
+ declare function validatePoeRecord(bytes: Uint8Array, options?: ValidatorOptions): ValidationResult;
21
62
  declare function validateCidProfile(cid: string): boolean;
22
63
 
23
- export { type ValidateResult, type ValidationIssue, validateCidProfile, validatePoeRecord };
64
+ export { type Argon2ParamsCeiling, DEFAULT_PASSPHRASE_PARAMS_CEILING, type ValidationIssue, type ValidationResult, type ValidatorOptions, type ValidatorRole, validateCidProfile, validatePoeRecord };