@openvtc/trust-tasks 0.27.8 → 0.28.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 (77) hide show
  1. package/CHANGELOG.md +164 -0
  2. package/README.md +9 -0
  3. package/dist/_runtime/codes.d.ts +22 -3
  4. package/dist/_runtime/codes.d.ts.map +1 -1
  5. package/dist/_runtime/codes.js +26 -19
  6. package/dist/_runtime/codes.js.map +1 -1
  7. package/dist/_runtime/document.d.ts +1 -1
  8. package/dist/_runtime/document.js +1 -1
  9. package/dist/_runtime/extends.d.ts +16 -7
  10. package/dist/_runtime/extends.d.ts.map +1 -1
  11. package/dist/_runtime/extends.js +44 -35
  12. package/dist/_runtime/extends.js.map +1 -1
  13. package/dist/_runtime/index.d.ts +1 -0
  14. package/dist/_runtime/index.d.ts.map +1 -1
  15. package/dist/_runtime/index.js +1 -0
  16. package/dist/_runtime/index.js.map +1 -1
  17. package/dist/_runtime/type-uri.d.ts +96 -0
  18. package/dist/_runtime/type-uri.d.ts.map +1 -0
  19. package/dist/_runtime/type-uri.js +194 -0
  20. package/dist/_runtime/type-uri.js.map +1 -0
  21. package/dist/_shared/components.d.ts +39 -0
  22. package/dist/_shared/components.d.ts.map +1 -1
  23. package/dist/index.d.ts +3778 -1257
  24. package/dist/index.d.ts.map +1 -1
  25. package/dist/index.js +3778 -1257
  26. package/dist/index.js.map +1 -1
  27. package/dist/policy/_shared/0.4/policy.d.ts +16 -0
  28. package/dist/policy/_shared/0.4/policy.d.ts.map +1 -0
  29. package/dist/policy/_shared/0.4/policy.js +6 -0
  30. package/dist/policy/_shared/0.4/policy.js.map +1 -0
  31. package/dist/policy/evaluate/0.1/payload.d.ts +4 -4
  32. package/dist/policy/evaluate/0.1/payload.js +1 -1
  33. package/dist/policy/evaluate/0.2/payload.d.ts +4 -4
  34. package/dist/policy/evaluate/0.2/payload.js +1 -1
  35. package/dist/policy/evaluate/0.3/payload.d.ts +13 -2
  36. package/dist/policy/evaluate/0.3/payload.d.ts.map +1 -1
  37. package/dist/policy/evaluate/0.3/payload.js +1 -1
  38. package/dist/policy/evaluate/0.3/payload.js.map +1 -1
  39. package/dist/policy/evaluate/0.4/payload.d.ts +1416 -0
  40. package/dist/policy/evaluate/0.4/payload.d.ts.map +1 -0
  41. package/dist/policy/evaluate/0.4/payload.js +899 -0
  42. package/dist/policy/evaluate/0.4/payload.js.map +1 -0
  43. package/dist/trust-task-error/0.1/payload.d.ts +2 -2
  44. package/dist/trust-task-error/0.1/payload.js +1 -1
  45. package/dist/trust-task-error/0.2/payload.d.ts +2 -2
  46. package/dist/trust-task-error/0.2/payload.js +1 -1
  47. package/dist/trust-task-error/0.3/payload.d.ts +2 -2
  48. package/dist/trust-task-error/0.3/payload.js +1 -1
  49. package/dist/trust-task-error/0.4/payload.d.ts +2 -2
  50. package/dist/trust-task-error/0.4/payload.js +1 -1
  51. package/dist/trust-task-error/0.5/payload.d.ts +7 -1
  52. package/dist/trust-task-error/0.5/payload.d.ts.map +1 -1
  53. package/dist/trust-task-error/0.5/payload.js +1 -1
  54. package/dist/trust-task-error/0.5/payload.js.map +1 -1
  55. package/dist/trust-task-error/0.6/payload.d.ts +199 -0
  56. package/dist/trust-task-error/0.6/payload.d.ts.map +1 -0
  57. package/dist/trust-task-error/0.6/payload.js +126 -0
  58. package/dist/trust-task-error/0.6/payload.js.map +1 -0
  59. package/package.json +1 -1
  60. package/src/_runtime/codes.ts +27 -21
  61. package/src/_runtime/document.ts +1 -1
  62. package/src/_runtime/extends.ts +50 -40
  63. package/src/_runtime/index.ts +14 -0
  64. package/src/_runtime/type-uri.ts +252 -0
  65. package/src/_shared/components.ts +39 -0
  66. package/src/index.ts +3778 -1257
  67. package/src/policy/_shared/0.4/policy.ts +17 -0
  68. package/src/policy/evaluate/0.1/payload.ts +5 -5
  69. package/src/policy/evaluate/0.2/payload.ts +5 -5
  70. package/src/policy/evaluate/0.3/payload.ts +14 -3
  71. package/src/policy/evaluate/0.4/payload.ts +944 -0
  72. package/src/trust-task-error/0.1/payload.ts +3 -3
  73. package/src/trust-task-error/0.2/payload.ts +3 -3
  74. package/src/trust-task-error/0.3/payload.ts +3 -3
  75. package/src/trust-task-error/0.4/payload.ts +3 -3
  76. package/src/trust-task-error/0.5/payload.ts +8 -2
  77. package/src/trust-task-error/0.6/payload.ts +195 -0
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/_runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,iBAAiB,EACjB,UAAU,EACV,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,aAAa,GAQd,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,cAAc,EACd,YAAY,EACZ,UAAU,EACV,cAAc,EACd,aAAa,EACb,eAAe,GAEhB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,sBAAsB,EACtB,MAAM,EACN,cAAc,GAKf,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,4BAA4B,EAC5B,yBAAyB,EACzB,mBAAmB,EACnB,cAAc,EACd,sBAAsB,EACtB,MAAM,GAQP,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EACL,cAAc,EACd,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,WAAW,EACX,kBAAkB,GAGnB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,yBAAyB,EACzB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,GAElB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,mBAAmB,EACnB,cAAc,GAIf,MAAM,aAAa,CAAC"}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/_runtime/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EACL,yBAAyB,EACzB,sBAAsB,EACtB,iBAAiB,EACjB,UAAU,EACV,mBAAmB,EACnB,WAAW,EACX,cAAc,EACd,aAAa,GAQd,MAAM,eAAe,CAAC;AAEvB,OAAO,EACL,cAAc,EACd,YAAY,EACZ,UAAU,EACV,cAAc,EACd,aAAa,EACb,eAAe,GAEhB,MAAM,YAAY,CAAC;AAEpB,OAAO,EACL,eAAe,EACf,wBAAwB,EACxB,sBAAsB,EACtB,MAAM,EACN,cAAc,GAKf,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,wBAAwB,EACxB,0BAA0B,EAC1B,4BAA4B,EAC5B,yBAAyB,EACzB,mBAAmB,EACnB,cAAc,EACd,sBAAsB,EACtB,MAAM,GAQP,MAAM,cAAc,CAAC;AAEtB,OAAO,EACL,wBAAwB,EACxB,2BAA2B,EAC3B,YAAY,EACZ,aAAa,EACb,YAAY,EACZ,iBAAiB,EACjB,eAAe,EACf,kBAAkB,GAInB,MAAM,eAAe,CAAC;AAEvB,OAAO,EAAE,aAAa,EAAE,SAAS,EAAE,MAAM,gBAAgB,CAAC;AAE1D,OAAO,EACL,cAAc,EACd,YAAY,EACZ,SAAS,EACT,YAAY,EACZ,WAAW,EACX,kBAAkB,GAGnB,MAAM,cAAc,CAAC;AAEtB,OAAO,EAAE,mBAAmB,EAAE,MAAM,gBAAgB,CAAC;AAErD,OAAO,EACL,uBAAuB,EACvB,iBAAiB,EACjB,kBAAkB,EAClB,eAAe,EACf,yBAAyB,EACzB,gBAAgB,EAChB,kBAAkB,EAClB,kBAAkB,EAClB,YAAY,EACZ,iBAAiB,GAElB,MAAM,gBAAgB,CAAC;AAExB,OAAO,EACL,mBAAmB,EACnB,cAAc,GAIf,MAAM,aAAa,CAAC"}
@@ -0,0 +1,96 @@
1
+ /**
2
+ * Parsed Trust Task *Type URI* — every form SPEC.md §6.1 defines: the public
3
+ * registry's canonical form, and the two shapes a third-party specification
4
+ * (SPEC.md §6.5) may use under any other authority:
5
+ *
6
+ * ```text
7
+ * https://trusttasks.org/spec/<slug>/<MAJOR.MINOR> public registry
8
+ * <prefix>/spec/<slug>/<MAJOR.MINOR> path form (https, DID URL, …)
9
+ * urn:<NID>:<prefix>:spec:<slug-segments>:<MAJOR.MINOR> URN form
10
+ * ```
11
+ *
12
+ * each optionally followed by `#request` or `#response` (§4.4.1). A Type URI
13
+ * whose scheme is `urn` must use the URN form, and every other scheme the path
14
+ * form; `http` is refused in every form. {@link formatTypeUri} reproduces the
15
+ * parsed string exactly — a Type URI is a name, compared by its whole string
16
+ * (§6.1), so the authority is kept verbatim and is part of identity: the same
17
+ * slug under two authorities is two specifications.
18
+ *
19
+ * Hand-written. Mirrors `type_uri.rs` in trust-tasks-rs, whose unit tests are
20
+ * the source of most of the vectors in `test/type-uri.test.ts`.
21
+ */
22
+ /** The `#request` / `#response` fragment of a Type URI (SPEC §4.4.1). */
23
+ export type TypeUriVariant = "request" | "response";
24
+ /** A parsed Type URI. Plain data; build a string back with {@link formatTypeUri}. */
25
+ export interface TypeUri {
26
+ /**
27
+ * Everything before `/spec/` (path form) or `:spec:` (URN form), verbatim —
28
+ * e.g. `https://trusttasks.org`, `did:web:acme.example`, `urn:example:tasks`.
29
+ */
30
+ readonly authority: string;
31
+ /** `"path"` — `<authority>/spec/<slug>/<M.N>`; `"urn"` — `<authority>:spec:<seg>:…:<M.N>`. */
32
+ readonly form: "path" | "urn";
33
+ /** The slug, `/`-separated in both forms (`payments:settle` in a URN is `payments/settle`). */
34
+ readonly slug: string;
35
+ readonly major: number;
36
+ readonly minor: number;
37
+ /** The fragment, or `null` when absent (semantically equivalent to `"request"`, §4.4.1). */
38
+ readonly variant: TypeUriVariant | null;
39
+ }
40
+ /** Why a string is not a Type URI — the cases of Rust's `ParseTypeUriError`. */
41
+ export type TypeUriErrorKind =
42
+ /** No scheme, a malformed one, or `http` (refused in every form, §6.1). */
43
+ "scheme"
44
+ /** Neither the path form nor (for `urn:`) the URN form. */
45
+ | "shape"
46
+ /** The slug fails the §6.1 grammar. */
47
+ | "slug"
48
+ /** The slug is in the §6.1 reserved namespace and is not a framework slug. */
49
+ | "reservedSlug"
50
+ /** The version is not `MAJOR.MINOR` (§5.1). */
51
+ | "version"
52
+ /** A fragment other than `#request` / `#response`. */
53
+ | "fragment";
54
+ /** Thrown by {@link parseTypeUri}. */
55
+ export declare class TypeUriError extends Error {
56
+ readonly kind: TypeUriErrorKind;
57
+ /** The string that failed to parse (for `slug` / `version` / `fragment`, the offending part). */
58
+ readonly input: string;
59
+ constructor(kind: TypeUriErrorKind, input: string, message: string);
60
+ }
61
+ /** The public registry's authority. */
62
+ export declare const REGISTRY_TYPE_URI_AUTHORITY = "https://trusttasks.org";
63
+ /**
64
+ * The framework slugs permitted inside the §6.1 reservation. A third
65
+ * hand-maintained copy of `#/properties/slug/anyOf[1]/enum` in
66
+ * `specs/spec.meta.schema.json` (Rust's `is_allowed_framework_slug` is the
67
+ * second); `test/type-uri.test.ts` reads that file and fails if they disagree.
68
+ */
69
+ export declare const FRAMEWORK_RESERVED_SLUGS: readonly string[];
70
+ /**
71
+ * Parse a Type URI in any SPEC §6.1 form.
72
+ *
73
+ * @throws {TypeUriError} if `typeUri` is not one — its `kind` says why.
74
+ */
75
+ export declare function parseTypeUri(typeUri: string): TypeUri;
76
+ /** {@link parseTypeUri}, returning `null` instead of throwing. */
77
+ export declare function tryParseTypeUri(typeUri: string): TypeUri | null;
78
+ /**
79
+ * The string form of `uri`. For a value {@link parseTypeUri} returned, exactly
80
+ * the string it parsed.
81
+ */
82
+ export declare function formatTypeUri(uri: TypeUri): string;
83
+ /**
84
+ * A sibling of `uri` at `major.minor`: the same authority, form, slug and
85
+ * variant, only the version changed. A declared-extension chain (SPEC §5.2)
86
+ * names only versions, so this is how it is walked — and why a chain never
87
+ * crosses authorities. (Rust's `TypeUri::with_version`.)
88
+ */
89
+ export declare function typeUriWithVersion(uri: TypeUri, major: number, minor: number): TypeUri;
90
+ /**
91
+ * Whether `a` and `b` name versions of the same specification: the same
92
+ * authority, form and slug. Two Type URIs with the same slug under different
93
+ * authorities are different specifications (SPEC §6.1).
94
+ */
95
+ export declare function sameSpecification(a: TypeUri, b: TypeUri): boolean;
96
+ //# sourceMappingURL=type-uri.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-uri.d.ts","sourceRoot":"","sources":["../../src/_runtime/type-uri.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAEH,yEAAyE;AACzE,MAAM,MAAM,cAAc,GAAG,SAAS,GAAG,UAAU,CAAC;AAEpD,qFAAqF;AACrF,MAAM,WAAW,OAAO;IACtB;;;OAGG;IACH,QAAQ,CAAC,SAAS,EAAE,MAAM,CAAC;IAC3B,8FAA8F;IAC9F,QAAQ,CAAC,IAAI,EAAE,MAAM,GAAG,KAAK,CAAC;IAC9B,+FAA+F;IAC/F,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;IACvB,4FAA4F;IAC5F,QAAQ,CAAC,OAAO,EAAE,cAAc,GAAG,IAAI,CAAC;CACzC;AAED,gFAAgF;AAChF,MAAM,MAAM,gBAAgB;AAC1B,2EAA2E;AACzE,QAAQ;AACV,2DAA2D;GACzD,OAAO;AACT,uCAAuC;GACrC,MAAM;AACR,8EAA8E;GAC5E,cAAc;AAChB,+CAA+C;GAC7C,SAAS;AACX,sDAAsD;GACpD,UAAU,CAAC;AAEf,sCAAsC;AACtC,qBAAa,YAAa,SAAQ,KAAK;IACrC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAC;IAChC,iGAAiG;IACjG,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;gBAEX,IAAI,EAAE,gBAAgB,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM;CAMnE;AAED,uCAAuC;AACvC,eAAO,MAAM,2BAA2B,2BAA2B,CAAC;AAOpE;;;;;GAKG;AACH,eAAO,MAAM,wBAAwB,EAAE,SAAS,MAAM,EAQpD,CAAC;AA4BH;;;;GAIG;AACH,wBAAgB,YAAY,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,CAmFrD;AAED,kEAAkE;AAClE,wBAAgB,eAAe,CAAC,OAAO,EAAE,MAAM,GAAG,OAAO,GAAG,IAAI,CAO/D;AAED;;;GAGG;AACH,wBAAgB,aAAa,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CAOlD;AAED;;;;;GAKG;AACH,wBAAgB,kBAAkB,CAAC,GAAG,EAAE,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAEtF;AAED;;;;GAIG;AACH,wBAAgB,iBAAiB,CAAC,CAAC,EAAE,OAAO,EAAE,CAAC,EAAE,OAAO,GAAG,OAAO,CAEjE"}
@@ -0,0 +1,194 @@
1
+ /**
2
+ * Parsed Trust Task *Type URI* — every form SPEC.md §6.1 defines: the public
3
+ * registry's canonical form, and the two shapes a third-party specification
4
+ * (SPEC.md §6.5) may use under any other authority:
5
+ *
6
+ * ```text
7
+ * https://trusttasks.org/spec/<slug>/<MAJOR.MINOR> public registry
8
+ * <prefix>/spec/<slug>/<MAJOR.MINOR> path form (https, DID URL, …)
9
+ * urn:<NID>:<prefix>:spec:<slug-segments>:<MAJOR.MINOR> URN form
10
+ * ```
11
+ *
12
+ * each optionally followed by `#request` or `#response` (§4.4.1). A Type URI
13
+ * whose scheme is `urn` must use the URN form, and every other scheme the path
14
+ * form; `http` is refused in every form. {@link formatTypeUri} reproduces the
15
+ * parsed string exactly — a Type URI is a name, compared by its whole string
16
+ * (§6.1), so the authority is kept verbatim and is part of identity: the same
17
+ * slug under two authorities is two specifications.
18
+ *
19
+ * Hand-written. Mirrors `type_uri.rs` in trust-tasks-rs, whose unit tests are
20
+ * the source of most of the vectors in `test/type-uri.test.ts`.
21
+ */
22
+ /** Thrown by {@link parseTypeUri}. */
23
+ export class TypeUriError extends Error {
24
+ kind;
25
+ /** The string that failed to parse (for `slug` / `version` / `fragment`, the offending part). */
26
+ input;
27
+ constructor(kind, input, message) {
28
+ super(message);
29
+ this.name = "TypeUriError";
30
+ this.kind = kind;
31
+ this.input = input;
32
+ }
33
+ }
34
+ /** The public registry's authority. */
35
+ export const REGISTRY_TYPE_URI_AUTHORITY = "https://trusttasks.org";
36
+ const SCHEME_RE = /^[A-Za-z][A-Za-z0-9+.-]*$/;
37
+ const SEGMENT_RE = /^[a-z][a-z0-9]*(-[a-z0-9]+)*$/;
38
+ const VERSION_RE = /^(0|[1-9][0-9]*)\.(0|[1-9][0-9]*)$/;
39
+ const U32_MAX = 0xffff_ffff;
40
+ /**
41
+ * The framework slugs permitted inside the §6.1 reservation. A third
42
+ * hand-maintained copy of `#/properties/slug/anyOf[1]/enum` in
43
+ * `specs/spec.meta.schema.json` (Rust's `is_allowed_framework_slug` is the
44
+ * second); `test/type-uri.test.ts` reads that file and fails if they disagree.
45
+ */
46
+ export const FRAMEWORK_RESERVED_SLUGS = Object.freeze([
47
+ "trust-task",
48
+ "trust-task-error",
49
+ "trust-task-ok",
50
+ "trust-task-next-step",
51
+ "trust-task-discovery",
52
+ "trust-task-control",
53
+ "trust-ceremony-receipt",
54
+ ]);
55
+ /** Whether `slug` is in the §6.1 reserved namespace `^trust-(task|ceremony)($|-|/)`. */
56
+ function isReservedNamespace(slug) {
57
+ const first = slug.split("/")[0];
58
+ return ["trust-task", "trust-ceremony"].some((stem) => first === stem || first.startsWith(`${stem}-`));
59
+ }
60
+ /** Throws unless `slug` satisfies the §6.1 grammar and reservation. */
61
+ function checkSlug(slug) {
62
+ if (slug.length === 0 || !slug.split("/").every((s) => SEGMENT_RE.test(s))) {
63
+ throw new TypeUriError("slug", slug, `slug ${JSON.stringify(slug)} does not satisfy SPEC §6.1 grammar`);
64
+ }
65
+ if (isReservedNamespace(slug) && !FRAMEWORK_RESERVED_SLUGS.includes(slug)) {
66
+ throw new TypeUriError("reservedSlug", slug, `slug ${JSON.stringify(slug)} is reserved per SPEC §6.1`);
67
+ }
68
+ }
69
+ function parseVersion(s) {
70
+ const m = VERSION_RE.exec(s);
71
+ const major = m ? Number(m[1]) : NaN;
72
+ const minor = m ? Number(m[2]) : NaN;
73
+ if (!(major <= U32_MAX && minor <= U32_MAX)) {
74
+ throw new TypeUriError("version", s, `version ${JSON.stringify(s)} must be MAJOR.MINOR per SPEC §5.1`);
75
+ }
76
+ return [major, minor];
77
+ }
78
+ /**
79
+ * Parse a Type URI in any SPEC §6.1 form.
80
+ *
81
+ * @throws {TypeUriError} if `typeUri` is not one — its `kind` says why.
82
+ */
83
+ export function parseTypeUri(typeUri) {
84
+ if (typeof typeUri !== "string") {
85
+ throw new TypeUriError("scheme", String(typeUri), "a Type URI must be a string");
86
+ }
87
+ const hash = typeUri.indexOf("#");
88
+ const bare = hash < 0 ? typeUri : typeUri.slice(0, hash);
89
+ const fragment = hash < 0 ? null : typeUri.slice(hash + 1);
90
+ let variant = null;
91
+ if (fragment !== null) {
92
+ if (fragment !== "request" && fragment !== "response") {
93
+ throw new TypeUriError("fragment", fragment, `only #request and #response fragments are permitted in a Type URI (got #${fragment})`);
94
+ }
95
+ variant = fragment;
96
+ }
97
+ // SPEC §6.1: any absolute URI, but never `http` — an `http` Type URI would
98
+ // normalise a transport-downgrade path for a consumer that dereferences it.
99
+ const colon = bare.indexOf(":");
100
+ const scheme = colon < 0 ? "" : bare.slice(0, colon);
101
+ if (!SCHEME_RE.test(scheme) || scheme.toLowerCase() === "http") {
102
+ throw new TypeUriError("scheme", typeUri, `Type URI must have a scheme other than http (SPEC §6.1): ${JSON.stringify(typeUri)}`);
103
+ }
104
+ const shape = () => new TypeUriError("shape", typeUri, `Type URI must be <prefix>/spec/<slug>/<major.minor>, or ` +
105
+ `urn:<nid>:<prefix>:spec:<slug-segments>:<major.minor>: ${JSON.stringify(typeUri)}`);
106
+ let authority;
107
+ let slug;
108
+ let version;
109
+ let form;
110
+ if (scheme.toLowerCase() === "urn") {
111
+ // `urn:<NID>:<prefix>:spec:<seg>:…:<MAJOR.MINOR>` — the slug is the
112
+ // segments between the first `:spec:` and the version.
113
+ const at = bare.indexOf(":spec:");
114
+ if (at < 0)
115
+ throw shape();
116
+ authority = bare.slice(0, at);
117
+ const rest = bare.slice(at + ":spec:".length);
118
+ const parts = authority.split(":");
119
+ const nid = parts[1];
120
+ const ns = parts.slice(2).join(":");
121
+ if (!nid || !ns || rest.includes("/"))
122
+ throw shape();
123
+ const cut = rest.lastIndexOf(":");
124
+ if (cut < 0)
125
+ throw shape();
126
+ slug = rest.slice(0, cut).replace(/:/g, "/");
127
+ version = rest.slice(cut + 1);
128
+ form = "urn";
129
+ }
130
+ else {
131
+ // `<prefix>/spec/<slug>/<MAJOR.MINOR>` — an https authority (with an
132
+ // optional path prefix), a DID URL, or any other scheme's prefix.
133
+ const at = bare.indexOf("/spec/");
134
+ if (at < 0)
135
+ throw shape();
136
+ authority = bare.slice(0, at);
137
+ const afterScheme = authority.slice(scheme.length + 1);
138
+ if (afterScheme.replace(/^\/+/, "").length === 0 ||
139
+ (scheme.toLowerCase() === "https" && !afterScheme.startsWith("//"))) {
140
+ throw shape();
141
+ }
142
+ const rest = bare.slice(at + "/spec/".length);
143
+ // The version is the final '/' segment; everything before it is the slug.
144
+ const cut = rest.lastIndexOf("/");
145
+ if (cut < 0)
146
+ throw shape();
147
+ slug = rest.slice(0, cut);
148
+ version = rest.slice(cut + 1);
149
+ form = "path";
150
+ }
151
+ checkSlug(slug);
152
+ const [major, minor] = parseVersion(version);
153
+ return { authority, form, slug, major, minor, variant };
154
+ }
155
+ /** {@link parseTypeUri}, returning `null` instead of throwing. */
156
+ export function tryParseTypeUri(typeUri) {
157
+ try {
158
+ return parseTypeUri(typeUri);
159
+ }
160
+ catch (e) {
161
+ if (e instanceof TypeUriError)
162
+ return null;
163
+ throw e;
164
+ }
165
+ }
166
+ /**
167
+ * The string form of `uri`. For a value {@link parseTypeUri} returned, exactly
168
+ * the string it parsed.
169
+ */
170
+ export function formatTypeUri(uri) {
171
+ const v = `${uri.major}.${uri.minor}`;
172
+ const base = uri.form === "urn"
173
+ ? `${uri.authority}:spec:${uri.slug.replace(/\//g, ":")}:${v}`
174
+ : `${uri.authority}/spec/${uri.slug}/${v}`;
175
+ return uri.variant === null ? base : `${base}#${uri.variant}`;
176
+ }
177
+ /**
178
+ * A sibling of `uri` at `major.minor`: the same authority, form, slug and
179
+ * variant, only the version changed. A declared-extension chain (SPEC §5.2)
180
+ * names only versions, so this is how it is walked — and why a chain never
181
+ * crosses authorities. (Rust's `TypeUri::with_version`.)
182
+ */
183
+ export function typeUriWithVersion(uri, major, minor) {
184
+ return { ...uri, major, minor };
185
+ }
186
+ /**
187
+ * Whether `a` and `b` name versions of the same specification: the same
188
+ * authority, form and slug. Two Type URIs with the same slug under different
189
+ * authorities are different specifications (SPEC §6.1).
190
+ */
191
+ export function sameSpecification(a, b) {
192
+ return a.authority === b.authority && a.form === b.form && a.slug === b.slug;
193
+ }
194
+ //# sourceMappingURL=type-uri.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"type-uri.js","sourceRoot":"","sources":["../../src/_runtime/type-uri.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AAqCH,sCAAsC;AACtC,MAAM,OAAO,YAAa,SAAQ,KAAK;IAC5B,IAAI,CAAmB;IAChC,iGAAiG;IACxF,KAAK,CAAS;IAEvB,YAAY,IAAsB,EAAE,KAAa,EAAE,OAAe;QAChE,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,cAAc,CAAC;QAC3B,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QAC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,aAAa,CAAC,GAAY;IACxC,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC,KAAK,IAAI,GAAG,CAAC,KAAK,EAAE,CAAC;IACtC,MAAM,IAAI,GACR,GAAG,CAAC,IAAI,KAAK,KAAK;QAChB,CAAC,CAAC,GAAG,GAAG,CAAC,SAAS,SAAS,GAAG,CAAC,IAAI,CAAC,OAAO,CAAC,KAAK,EAAE,GAAG,CAAC,IAAI,CAAC,EAAE;QAC9D,CAAC,CAAC,GAAG,GAAG,CAAC,SAAS,SAAS,GAAG,CAAC,IAAI,IAAI,CAAC,EAAE,CAAC;IAC/C,OAAO,GAAG,CAAC,OAAO,KAAK,IAAI,CAAC,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,GAAG,IAAI,IAAI,GAAG,CAAC,OAAO,EAAE,CAAC;AAChE,CAAC;AAED;;;;;GAKG;AACH,MAAM,UAAU,kBAAkB,CAAC,GAAY,EAAE,KAAa,EAAE,KAAa;IAC3E,OAAO,EAAE,GAAG,GAAG,EAAE,KAAK,EAAE,KAAK,EAAE,CAAC;AAClC,CAAC;AAED;;;;GAIG;AACH,MAAM,UAAU,iBAAiB,CAAC,CAAU,EAAE,CAAU;IACtD,OAAO,CAAC,CAAC,SAAS,KAAK,CAAC,CAAC,SAAS,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,IAAI,CAAC,CAAC,IAAI,KAAK,CAAC,CAAC,IAAI,CAAC;AAC/E,CAAC"}
@@ -9558,6 +9558,45 @@ export interface PolicyDecision_PolicyV0_3 {
9558
9558
  */
9559
9559
  explanation?: string;
9560
9560
  }
9561
+ export interface PolicyDecision_PolicyV0_4 {
9562
+ decision: "allow" | "deny" | "requireStepUp" | "requireConsent";
9563
+ /**
9564
+ * Vault-flow-specific. When decision == "allow" for a proxy-login/release request, whether the maintainer should proxy-login or release-for-fill. Default: proxy. Ignored for other task kinds.
9565
+ */
9566
+ mode?: "proxy" | "fill";
9567
+ /**
9568
+ * When decision == "requireStepUp", which method to demand.
9569
+ */
9570
+ stepUp?: {
9571
+ method: "webauthnUv" | "pushApproval" | "totp";
9572
+ ttlSeconds?: number;
9573
+ };
9574
+ /**
9575
+ * When decision == "requireConsent", the approver constraint the enforcement point MUST satisfy — a signed consent decision from the named set, bound to the request's payloadDigest — before executing.
9576
+ */
9577
+ requireConsent?: {
9578
+ /**
9579
+ * Named set of enrolled approver devices permitted to approve this task (resolved by the enforcement point against its device registry).
9580
+ */
9581
+ approverSet: string;
9582
+ /**
9583
+ * REQUIRED, with no default: whether the requester may approve its own request is the community's choice, not this schema's (SPEC §6.6 rule 5). When true, the device that issued the request MUST NOT be accepted as the approver — forcing cross-device approval so a compromised requesting device cannot self-approve.
9584
+ */
9585
+ excludeRequester: boolean;
9586
+ /**
9587
+ * REQUIRED, with no default: the quorum is the community's choice, not this schema's (SPEC §6.6 rule 5), and an omitted quorum is malformedRequest rather than one. Number of distinct approvers from the set required before the task may execute.
9588
+ */
9589
+ minApprovals: number;
9590
+ };
9591
+ /**
9592
+ * When decision == "allow", maximum lifetime of any issued session blob / released secret.
9593
+ */
9594
+ ttlSecondsCap?: number;
9595
+ /**
9596
+ * Human-readable explanation for diagnostic display.
9597
+ */
9598
+ explanation?: string;
9599
+ }
9561
9600
  /**
9562
9601
  * The structured input fed to a policy evaluator on every vault/proxy-login, vault/release, and policy/evaluate call.
9563
9602
  */