@pegasimed.com/pegasi-sail-connect-shared 0.2.0-dev.31 → 0.2.0-dev.33
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/README.md +339 -0
- package/dist/capabilities/catalog-data.d.ts +42 -2
- package/dist/capabilities/catalog-data.d.ts.map +1 -1
- package/dist/capabilities/catalog-data.js +44 -2
- package/dist/capabilities/catalog-data.js.map +1 -1
- package/dist/consent/index.d.ts +45 -0
- package/dist/consent/index.d.ts.map +1 -0
- package/dist/consent/index.js +121 -0
- package/dist/consent/index.js.map +1 -0
- package/dist/consent/schema.d.ts +169 -0
- package/dist/consent/schema.d.ts.map +1 -0
- package/dist/consent/schema.js +74 -0
- package/dist/consent/schema.js.map +1 -0
- package/dist/consent/vectors.d.ts +1709 -0
- package/dist/consent/vectors.d.ts.map +1 -0
- package/dist/consent/vectors.js +144 -0
- package/dist/consent/vectors.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +5 -1
|
@@ -0,0 +1,45 @@
|
|
|
1
|
+
export { CONSENT_DECISION_V1_SCHEMA } from "./schema.js";
|
|
2
|
+
export { CONSENT_DECISION_V1_VALID_VECTORS, CONSENT_DECISION_V1_INVALID_VECTORS, CONSENT_DECISION_V1_CANONICAL_VECTOR } from "./vectors.js";
|
|
3
|
+
export type ConsentScopeV1 = "adr" | "patient-privacy" | "research" | "treatment" | "contact";
|
|
4
|
+
export type ConsentChannelV1 = "whatsapp" | "sms" | "email" | "voice";
|
|
5
|
+
interface ConsentDecisionBaseV1 {
|
|
6
|
+
schemaVersion: "consent-decision.v1";
|
|
7
|
+
tenant: string;
|
|
8
|
+
subject: {
|
|
9
|
+
type: "candidate" | "patient";
|
|
10
|
+
ref: string;
|
|
11
|
+
};
|
|
12
|
+
itemCode: string;
|
|
13
|
+
scope: ConsentScopeV1;
|
|
14
|
+
templateRef: {
|
|
15
|
+
code: string;
|
|
16
|
+
revision: number;
|
|
17
|
+
};
|
|
18
|
+
textVersion: string;
|
|
19
|
+
textHash: string;
|
|
20
|
+
channel?: ConsentChannelV1;
|
|
21
|
+
decidedAt: string;
|
|
22
|
+
source: {
|
|
23
|
+
system: string;
|
|
24
|
+
kind: string;
|
|
25
|
+
evidenceRef: string;
|
|
26
|
+
flowRef: string;
|
|
27
|
+
flowDigest: string;
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
export type ConsentDecisionV1 = ConsentDecisionBaseV1 & ({
|
|
31
|
+
decision: "granted" | "declined";
|
|
32
|
+
revokedAt?: never;
|
|
33
|
+
} | {
|
|
34
|
+
decision: "revoked";
|
|
35
|
+
revokedAt: string;
|
|
36
|
+
});
|
|
37
|
+
/** Stable, payload-free rejection. No cause, input value, field value or proxy error. */
|
|
38
|
+
export declare class ConsentDecisionV1InvalidError extends Error {
|
|
39
|
+
constructor();
|
|
40
|
+
}
|
|
41
|
+
/** Pure structural validation; callers own tenant binding and template/evidence lookup. */
|
|
42
|
+
export declare function parseConsentDecisionV1(input: unknown): ConsentDecisionV1;
|
|
43
|
+
/** Validates first, then serializes a detached snapshot in fixed key order. */
|
|
44
|
+
export declare function canonicalizeConsentDecisionV1(input: unknown): string;
|
|
45
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/consent/index.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,iCAAiC,EAAE,mCAAmC,EAAE,oCAAoC,EAAE,MAAM,cAAc,CAAC;AAE5I,MAAM,MAAM,cAAc,GAAG,KAAK,GAAG,iBAAiB,GAAG,UAAU,GAAG,WAAW,GAAG,SAAS,CAAC;AAC9F,MAAM,MAAM,gBAAgB,GAAG,UAAU,GAAG,KAAK,GAAG,OAAO,GAAG,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TERN, CONSENT_HASH_PATTERN, CONSENT_REFERENCE_RULE, CONSENT_TEXT_VERSION_RULE } from "./schema.js";
|
|
3
|
+
export { CONSENT_DECISION_V1_SCHEMA } from "./schema.js";
|
|
4
|
+
export { CONSENT_DECISION_V1_VALID_VECTORS, CONSENT_DECISION_V1_INVALID_VECTORS, CONSENT_DECISION_V1_CANONICAL_VECTOR } from "./vectors.js";
|
|
5
|
+
/** Stable, payload-free rejection. No cause, input value, field value or proxy error. */
|
|
6
|
+
export class ConsentDecisionV1InvalidError extends Error {
|
|
7
|
+
constructor() {
|
|
8
|
+
super("Invalid consent-decision.v1");
|
|
9
|
+
this.name = "ConsentDecisionV1InvalidError";
|
|
10
|
+
}
|
|
11
|
+
}
|
|
12
|
+
function reject() { throw new ConsentDecisionV1InvalidError(); }
|
|
13
|
+
function nullRecord(value) {
|
|
14
|
+
Object.setPrototypeOf(value, null);
|
|
15
|
+
return value;
|
|
16
|
+
}
|
|
17
|
+
/** Snapshot only own enumerable data properties; never invoke an input getter. */
|
|
18
|
+
function record(value, required, optional = []) {
|
|
19
|
+
if (value === null || typeof value !== "object")
|
|
20
|
+
reject();
|
|
21
|
+
const proto = Object.getPrototypeOf(value);
|
|
22
|
+
if (proto !== Object.prototype && proto !== null)
|
|
23
|
+
reject();
|
|
24
|
+
const keys = Reflect.ownKeys(value);
|
|
25
|
+
if (keys.length < required.length || keys.length > required.length + optional.length)
|
|
26
|
+
reject();
|
|
27
|
+
const result = Object.create(null);
|
|
28
|
+
for (const key of keys) {
|
|
29
|
+
if (typeof key !== "string" || (!required.includes(key) && !optional.includes(key)))
|
|
30
|
+
reject();
|
|
31
|
+
const descriptor = Object.getOwnPropertyDescriptor(value, key);
|
|
32
|
+
if (!descriptor || !("value" in descriptor) || !descriptor.enumerable || descriptor.value === undefined)
|
|
33
|
+
reject();
|
|
34
|
+
Object.defineProperty(result, key, { value: descriptor.value, enumerable: true });
|
|
35
|
+
}
|
|
36
|
+
for (const key of required)
|
|
37
|
+
if (!Object.hasOwn(result, key))
|
|
38
|
+
reject();
|
|
39
|
+
return result;
|
|
40
|
+
}
|
|
41
|
+
function token(value, pattern, max) {
|
|
42
|
+
if (typeof value !== "string" || value.length > max || !new RegExp(pattern, "u").test(value))
|
|
43
|
+
reject();
|
|
44
|
+
return value;
|
|
45
|
+
}
|
|
46
|
+
function code(value) { return token(value, CONSENT_CODE_PATTERN, 64); }
|
|
47
|
+
function ref(value) { return token(value, CONSENT_REFERENCE_RULE.pattern, CONSENT_REFERENCE_RULE.maxLength); }
|
|
48
|
+
function textVersion(value) { return token(value, CONSENT_TEXT_VERSION_RULE.pattern, CONSENT_TEXT_VERSION_RULE.maxLength); }
|
|
49
|
+
function hash(value) { return token(value, CONSENT_HASH_PATTERN, 64); }
|
|
50
|
+
function oneOf(value, allowed) {
|
|
51
|
+
if (typeof value !== "string" || !allowed.includes(value))
|
|
52
|
+
reject();
|
|
53
|
+
return value;
|
|
54
|
+
}
|
|
55
|
+
function date(value) {
|
|
56
|
+
const text = token(value, CONSENT_DATE_PATTERN, 24);
|
|
57
|
+
const stamp = Date.parse(text);
|
|
58
|
+
if (!Number.isFinite(stamp))
|
|
59
|
+
reject();
|
|
60
|
+
const expected = text.length === 20 ? text.replace("Z", ".000Z") : text;
|
|
61
|
+
if (new Date(stamp).toISOString() !== expected)
|
|
62
|
+
reject();
|
|
63
|
+
return text;
|
|
64
|
+
}
|
|
65
|
+
/** Pure structural validation; callers own tenant binding and template/evidence lookup. */
|
|
66
|
+
export function parseConsentDecisionV1(input) {
|
|
67
|
+
try {
|
|
68
|
+
const raw = record(input, ["schemaVersion", "tenant", "subject", "itemCode", "scope", "templateRef",
|
|
69
|
+
"textVersion", "textHash", "decision", "decidedAt", "source"], ["channel", "revokedAt"]);
|
|
70
|
+
if (raw.schemaVersion !== "consent-decision.v1" || !isTenantId(raw.tenant))
|
|
71
|
+
reject();
|
|
72
|
+
const subject = record(raw.subject, ["type", "ref"]);
|
|
73
|
+
const template = record(raw.templateRef, ["code", "revision"]);
|
|
74
|
+
const source = record(raw.source, ["system", "kind", "evidenceRef", "flowRef", "flowDigest"]);
|
|
75
|
+
const itemCode = code(raw.itemCode);
|
|
76
|
+
const scope = oneOf(raw.scope, ["adr", "patient-privacy", "research", "treatment", "contact"]);
|
|
77
|
+
const decision = oneOf(raw.decision, ["granted", "declined", "revoked"]);
|
|
78
|
+
const decidedAt = date(raw.decidedAt);
|
|
79
|
+
if (typeof template.revision !== "number" || !Number.isSafeInteger(template.revision) || template.revision < 1)
|
|
80
|
+
reject();
|
|
81
|
+
// Fixed key order is also the wire canonicalization order. Copies have no toJSON.
|
|
82
|
+
const result = nullRecord({
|
|
83
|
+
schemaVersion: "consent-decision.v1",
|
|
84
|
+
tenant: raw.tenant,
|
|
85
|
+
subject: nullRecord({ type: oneOf(subject.type, ["candidate", "patient"]), ref: ref(subject.ref) }),
|
|
86
|
+
itemCode, scope,
|
|
87
|
+
templateRef: nullRecord({ code: code(template.code), revision: template.revision }),
|
|
88
|
+
textVersion: textVersion(raw.textVersion), textHash: hash(raw.textHash),
|
|
89
|
+
...(Object.hasOwn(raw, "channel") ? { channel: oneOf(raw.channel, ["whatsapp", "sms", "email", "voice"]) } : {}),
|
|
90
|
+
decidedAt,
|
|
91
|
+
source: nullRecord({ system: code(source.system), kind: code(source.kind), evidenceRef: ref(source.evidenceRef),
|
|
92
|
+
flowRef: ref(source.flowRef), flowDigest: hash(source.flowDigest) })
|
|
93
|
+
});
|
|
94
|
+
if (result.channel !== undefined && (!itemCode.startsWith("contact-") || scope !== "contact"))
|
|
95
|
+
reject();
|
|
96
|
+
if (decision === "revoked") {
|
|
97
|
+
const revokedAt = date(raw.revokedAt);
|
|
98
|
+
if (Date.parse(revokedAt) < Date.parse(decidedAt))
|
|
99
|
+
reject();
|
|
100
|
+
// Assemble in protocol order, including optional fields in their fixed positions.
|
|
101
|
+
return ordered(result, { decision, revokedAt });
|
|
102
|
+
}
|
|
103
|
+
if (Object.hasOwn(raw, "revokedAt"))
|
|
104
|
+
reject();
|
|
105
|
+
return ordered(result, { decision });
|
|
106
|
+
}
|
|
107
|
+
catch {
|
|
108
|
+
// Hostile proxies and thrown values cannot escape or be reflected.
|
|
109
|
+
throw new ConsentDecisionV1InvalidError();
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
function ordered(base, state) {
|
|
113
|
+
const { source, decidedAt, ...first } = base;
|
|
114
|
+
return nullRecord({ ...first, decision: state.decision, decidedAt,
|
|
115
|
+
...("revokedAt" in state ? { revokedAt: state.revokedAt } : {}), source });
|
|
116
|
+
}
|
|
117
|
+
/** Validates first, then serializes a detached snapshot in fixed key order. */
|
|
118
|
+
export function canonicalizeConsentDecisionV1(input) {
|
|
119
|
+
return JSON.stringify(parseConsentDecisionV1(input));
|
|
120
|
+
}
|
|
121
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/consent/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,0BAA0B,CAAC;AACtD,OAAO,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,oBAAoB,EAAE,sBAAsB,EAAE,yBAAyB,EAAE,MAAM,aAAa,CAAC;AAClJ,OAAO,EAAE,0BAA0B,EAAE,MAAM,aAAa,CAAC;AACzD,OAAO,EAAE,iCAAiC,EAAE,mCAAmC,EAAE,oCAAoC,EAAE,MAAM,cAAc,CAAC;AAsB5I,yFAAyF;AACzF,MAAM,OAAO,6BAA8B,SAAQ,KAAK;IACtD;QACE,KAAK,CAAC,6BAA6B,CAAC,CAAC;QACrC,IAAI,CAAC,IAAI,GAAG,+BAA+B,CAAC;IAC9C,CAAC;CACF;AAED,SAAS,MAAM,KAAY,MAAM,IAAI,6BAA6B,EAAE,CAAC,CAAC,CAAC;AACvE,SAAS,UAAU,CAAmB,KAAQ;IAC5C,MAAM,CAAC,cAAc,CAAC,KAAK,EAAE,IAAI,CAA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AAED,SAAS,OAAO,CAAC,IAA2B,EAAE,KAAwF;IACpI,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,GAAG,KAAK,EAAE,GAAG,IAAI,CAAC;IAC7C,OAAO,UAAU,CAAC,EAAE,GAAG,KAAK,EAAE,QAAQ,EAAE,KAAK,CAAC,QAAQ,EAAE,SAAS;QAC/D,GAAG,CAAC,WAAW,IAAI,KAAK,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,KAAK,CAAC,SAAS,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC,EAAE,MAAM,EAAE,CAAsB,CAAC;AACpG,CAAC;AAED,+EAA+E;AAC/E,MAAM,UAAU,6BAA6B,CAAC,KAAc;IAC1D,OAAO,IAAI,CAAC,SAAS,CAAC,sBAAsB,CAAC,KAAK,CAAC,CAAC,CAAC;AACvD,CAAC"}
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
/** Closed machine codes, not labels or consent text. Reference Data owns membership. */
|
|
2
|
+
export declare const CONSENT_CODE_PATTERN = "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?![\\s\\S])";
|
|
3
|
+
/** Lowercase RFC-variant UUID v1–v8, or mixed base64url; UUID-shaped tokens cannot bypass UUID validation. */
|
|
4
|
+
export declare const CONSENT_REF_PATTERN = "^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|(?![A-Za-z0-9_]{8}-[A-Za-z0-9_]{4}-[A-Za-z0-9_]{4}-[A-Za-z0-9_]{4}-[A-Za-z0-9_]{12}(?![\\s\\S]))(?=[A-Za-z0-9_-]*[A-Za-z])(?=[A-Za-z0-9_-]*[0-9])[A-Za-z0-9_-]{22,128})(?![\\s\\S])";
|
|
5
|
+
export declare const CONSENT_TEXT_VERSION_PATTERN = "^(?=[a-z0-9._-]*[0-9])(?![a-z0-9._-]*[0-9]{7})[a-z0-9][a-z0-9._-]{0,63}(?![\\s\\S])";
|
|
6
|
+
export declare const CONSENT_HASH_PATTERN = "^[a-f0-9]{64}(?![\\s\\S])";
|
|
7
|
+
export declare const CONSENT_DATE_PATTERN = "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\\.[0-9]{3})?Z(?![\\s\\S])";
|
|
8
|
+
export declare const CONSENT_REFERENCE_RULE: Readonly<{
|
|
9
|
+
readonly type: "string";
|
|
10
|
+
readonly pattern: "^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|(?![A-Za-z0-9_]{8}-[A-Za-z0-9_]{4}-[A-Za-z0-9_]{4}-[A-Za-z0-9_]{4}-[A-Za-z0-9_]{12}(?![\\s\\S]))(?=[A-Za-z0-9_-]*[A-Za-z])(?=[A-Za-z0-9_-]*[0-9])[A-Za-z0-9_-]{22,128})(?![\\s\\S])";
|
|
11
|
+
readonly maxLength: 128;
|
|
12
|
+
}>;
|
|
13
|
+
export declare const CONSENT_TEXT_VERSION_RULE: Readonly<{
|
|
14
|
+
readonly type: "string";
|
|
15
|
+
readonly pattern: "^(?=[a-z0-9._-]*[0-9])(?![a-z0-9._-]*[0-9]{7})[a-z0-9][a-z0-9._-]{0,63}(?![\\s\\S])";
|
|
16
|
+
readonly maxLength: 64;
|
|
17
|
+
}>;
|
|
18
|
+
/**
|
|
19
|
+
* JSON Schema draft 2020-12. Runtime parsing additionally checks real calendar
|
|
20
|
+
* dates and revokedAt >= decidedAt (a comparison outside standard JSON Schema).
|
|
21
|
+
* No field resolves a template, verifies a hash, or establishes authorization.
|
|
22
|
+
*/
|
|
23
|
+
export declare const CONSENT_DECISION_V1_SCHEMA: {
|
|
24
|
+
readonly $schema: "https://json-schema.org/draft/2020-12/schema";
|
|
25
|
+
readonly title: "consent-decision.v1";
|
|
26
|
+
readonly type: "object";
|
|
27
|
+
readonly additionalProperties: false;
|
|
28
|
+
readonly required: readonly ["schemaVersion", "tenant", "subject", "itemCode", "scope", "templateRef", "textVersion", "textHash", "decision", "decidedAt", "source"];
|
|
29
|
+
readonly properties: {
|
|
30
|
+
readonly schemaVersion: {
|
|
31
|
+
readonly const: "consent-decision.v1";
|
|
32
|
+
};
|
|
33
|
+
readonly tenant: {
|
|
34
|
+
readonly type: "string";
|
|
35
|
+
readonly pattern: "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,99}(?![\\s\\S])";
|
|
36
|
+
readonly maxLength: 100;
|
|
37
|
+
};
|
|
38
|
+
readonly subject: {
|
|
39
|
+
readonly type: "object";
|
|
40
|
+
readonly additionalProperties: false;
|
|
41
|
+
readonly required: readonly ["type", "ref"];
|
|
42
|
+
readonly properties: {
|
|
43
|
+
readonly type: {
|
|
44
|
+
readonly enum: readonly ["candidate", "patient"];
|
|
45
|
+
};
|
|
46
|
+
readonly ref: Readonly<{
|
|
47
|
+
readonly type: "string";
|
|
48
|
+
readonly pattern: "^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|(?![A-Za-z0-9_]{8}-[A-Za-z0-9_]{4}-[A-Za-z0-9_]{4}-[A-Za-z0-9_]{4}-[A-Za-z0-9_]{12}(?![\\s\\S]))(?=[A-Za-z0-9_-]*[A-Za-z])(?=[A-Za-z0-9_-]*[0-9])[A-Za-z0-9_-]{22,128})(?![\\s\\S])";
|
|
49
|
+
readonly maxLength: 128;
|
|
50
|
+
}>;
|
|
51
|
+
};
|
|
52
|
+
};
|
|
53
|
+
readonly itemCode: {
|
|
54
|
+
readonly type: "string";
|
|
55
|
+
readonly pattern: "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?![\\s\\S])";
|
|
56
|
+
readonly maxLength: 64;
|
|
57
|
+
};
|
|
58
|
+
readonly scope: {
|
|
59
|
+
readonly enum: readonly ["adr", "patient-privacy", "research", "treatment", "contact"];
|
|
60
|
+
};
|
|
61
|
+
readonly templateRef: {
|
|
62
|
+
readonly type: "object";
|
|
63
|
+
readonly additionalProperties: false;
|
|
64
|
+
readonly required: readonly ["code", "revision"];
|
|
65
|
+
readonly properties: {
|
|
66
|
+
readonly code: {
|
|
67
|
+
readonly type: "string";
|
|
68
|
+
readonly pattern: "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?![\\s\\S])";
|
|
69
|
+
readonly maxLength: 64;
|
|
70
|
+
};
|
|
71
|
+
readonly revision: {
|
|
72
|
+
readonly type: "integer";
|
|
73
|
+
readonly minimum: 1;
|
|
74
|
+
readonly maximum: number;
|
|
75
|
+
};
|
|
76
|
+
};
|
|
77
|
+
};
|
|
78
|
+
readonly textVersion: Readonly<{
|
|
79
|
+
readonly type: "string";
|
|
80
|
+
readonly pattern: "^(?=[a-z0-9._-]*[0-9])(?![a-z0-9._-]*[0-9]{7})[a-z0-9][a-z0-9._-]{0,63}(?![\\s\\S])";
|
|
81
|
+
readonly maxLength: 64;
|
|
82
|
+
}>;
|
|
83
|
+
readonly textHash: {
|
|
84
|
+
readonly type: "string";
|
|
85
|
+
readonly pattern: "^[a-f0-9]{64}(?![\\s\\S])";
|
|
86
|
+
};
|
|
87
|
+
readonly channel: {
|
|
88
|
+
readonly enum: readonly ["whatsapp", "sms", "email", "voice"];
|
|
89
|
+
};
|
|
90
|
+
readonly decision: {
|
|
91
|
+
readonly enum: readonly ["granted", "declined", "revoked"];
|
|
92
|
+
};
|
|
93
|
+
readonly decidedAt: {
|
|
94
|
+
readonly type: "string";
|
|
95
|
+
readonly pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\\.[0-9]{3})?Z(?![\\s\\S])";
|
|
96
|
+
readonly format: "date-time";
|
|
97
|
+
};
|
|
98
|
+
readonly revokedAt: {
|
|
99
|
+
readonly type: "string";
|
|
100
|
+
readonly pattern: "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\\.[0-9]{3})?Z(?![\\s\\S])";
|
|
101
|
+
readonly format: "date-time";
|
|
102
|
+
};
|
|
103
|
+
readonly source: {
|
|
104
|
+
readonly type: "object";
|
|
105
|
+
readonly additionalProperties: false;
|
|
106
|
+
readonly required: readonly ["system", "kind", "evidenceRef", "flowRef", "flowDigest"];
|
|
107
|
+
readonly properties: {
|
|
108
|
+
readonly system: {
|
|
109
|
+
readonly type: "string";
|
|
110
|
+
readonly pattern: "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?![\\s\\S])";
|
|
111
|
+
readonly maxLength: 64;
|
|
112
|
+
};
|
|
113
|
+
readonly kind: {
|
|
114
|
+
readonly type: "string";
|
|
115
|
+
readonly pattern: "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?![\\s\\S])";
|
|
116
|
+
readonly maxLength: 64;
|
|
117
|
+
};
|
|
118
|
+
readonly evidenceRef: Readonly<{
|
|
119
|
+
readonly type: "string";
|
|
120
|
+
readonly pattern: "^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|(?![A-Za-z0-9_]{8}-[A-Za-z0-9_]{4}-[A-Za-z0-9_]{4}-[A-Za-z0-9_]{4}-[A-Za-z0-9_]{12}(?![\\s\\S]))(?=[A-Za-z0-9_-]*[A-Za-z])(?=[A-Za-z0-9_-]*[0-9])[A-Za-z0-9_-]{22,128})(?![\\s\\S])";
|
|
121
|
+
readonly maxLength: 128;
|
|
122
|
+
}>;
|
|
123
|
+
readonly flowRef: Readonly<{
|
|
124
|
+
readonly type: "string";
|
|
125
|
+
readonly pattern: "^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|(?![A-Za-z0-9_]{8}-[A-Za-z0-9_]{4}-[A-Za-z0-9_]{4}-[A-Za-z0-9_]{4}-[A-Za-z0-9_]{12}(?![\\s\\S]))(?=[A-Za-z0-9_-]*[A-Za-z])(?=[A-Za-z0-9_-]*[0-9])[A-Za-z0-9_-]{22,128})(?![\\s\\S])";
|
|
126
|
+
readonly maxLength: 128;
|
|
127
|
+
}>;
|
|
128
|
+
readonly flowDigest: {
|
|
129
|
+
readonly type: "string";
|
|
130
|
+
readonly pattern: "^[a-f0-9]{64}(?![\\s\\S])";
|
|
131
|
+
};
|
|
132
|
+
};
|
|
133
|
+
};
|
|
134
|
+
};
|
|
135
|
+
readonly allOf: readonly [{
|
|
136
|
+
readonly if: {
|
|
137
|
+
readonly properties: {
|
|
138
|
+
readonly decision: {
|
|
139
|
+
readonly const: "revoked";
|
|
140
|
+
};
|
|
141
|
+
};
|
|
142
|
+
readonly required: readonly ["decision"];
|
|
143
|
+
};
|
|
144
|
+
readonly then: {
|
|
145
|
+
readonly required: readonly ["revokedAt"];
|
|
146
|
+
};
|
|
147
|
+
readonly else: {
|
|
148
|
+
readonly not: {
|
|
149
|
+
readonly required: readonly ["revokedAt"];
|
|
150
|
+
};
|
|
151
|
+
};
|
|
152
|
+
}, {
|
|
153
|
+
readonly if: {
|
|
154
|
+
readonly required: readonly ["channel"];
|
|
155
|
+
};
|
|
156
|
+
readonly then: {
|
|
157
|
+
readonly properties: {
|
|
158
|
+
readonly itemCode: {
|
|
159
|
+
readonly pattern: "^contact-";
|
|
160
|
+
};
|
|
161
|
+
readonly scope: {
|
|
162
|
+
readonly const: "contact";
|
|
163
|
+
};
|
|
164
|
+
};
|
|
165
|
+
readonly required: readonly ["itemCode", "scope"];
|
|
166
|
+
};
|
|
167
|
+
}];
|
|
168
|
+
};
|
|
169
|
+
//# sourceMappingURL=schema.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"schema.d.ts","sourceRoot":"","sources":["../../src/consent/schema.ts"],"names":[],"mappings":"AAAA,wFAAwF;AACxF,eAAO,MAAM,oBAAoB,+CAA+C,CAAC;AACjF,8GAA8G;AAC9G,eAAO,MAAM,mBAAmB,oQAAoQ,CAAC;AACrS,eAAO,MAAM,4BAA4B,wFAAwF,CAAC;AAClI,eAAO,MAAM,oBAAoB,8BAA8B,CAAC;AAChE,eAAO,MAAM,oBAAoB,wFAAwF,CAAC;AAI1H,eAAO,MAAM,sBAAsB;;;;EAA2F,CAAC;AAC/H,eAAO,MAAM,yBAAyB;;;;EAAmG,CAAC;AAY1I;;;;GAIG;AACH,eAAO,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA8C5B,CAAC"}
|
|
@@ -0,0 +1,74 @@
|
|
|
1
|
+
/** Closed machine codes, not labels or consent text. Reference Data owns membership. */
|
|
2
|
+
export const CONSENT_CODE_PATTERN = "^[a-z][a-z0-9]*(?:-[a-z0-9]+)*(?![\\s\\S])";
|
|
3
|
+
/** Lowercase RFC-variant UUID v1–v8, or mixed base64url; UUID-shaped tokens cannot bypass UUID validation. */
|
|
4
|
+
export const CONSENT_REF_PATTERN = "^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|(?![A-Za-z0-9_]{8}-[A-Za-z0-9_]{4}-[A-Za-z0-9_]{4}-[A-Za-z0-9_]{4}-[A-Za-z0-9_]{12}(?![\\s\\S]))(?=[A-Za-z0-9_-]*[A-Za-z])(?=[A-Za-z0-9_-]*[0-9])[A-Za-z0-9_-]{22,128})(?![\\s\\S])";
|
|
5
|
+
export const CONSENT_TEXT_VERSION_PATTERN = "^(?=[a-z0-9._-]*[0-9])(?![a-z0-9._-]*[0-9]{7})[a-z0-9][a-z0-9._-]{0,63}(?![\\s\\S])";
|
|
6
|
+
export const CONSENT_HASH_PATTERN = "^[a-f0-9]{64}(?![\\s\\S])";
|
|
7
|
+
export const CONSENT_DATE_PATTERN = "^[0-9]{4}-[0-9]{2}-[0-9]{2}T[0-9]{2}:[0-9]{2}:[0-9]{2}(?:\\.[0-9]{3})?Z(?![\\s\\S])";
|
|
8
|
+
const code = { type: "string", pattern: CONSENT_CODE_PATTERN, maxLength: 64 };
|
|
9
|
+
// Shared by the parser and every corresponding JSON Schema property.
|
|
10
|
+
export const CONSENT_REFERENCE_RULE = Object.freeze({ type: "string", pattern: CONSENT_REF_PATTERN, maxLength: 128 });
|
|
11
|
+
export const CONSENT_TEXT_VERSION_RULE = Object.freeze({ type: "string", pattern: CONSENT_TEXT_VERSION_PATTERN, maxLength: 64 });
|
|
12
|
+
const hash = { type: "string", pattern: CONSENT_HASH_PATTERN };
|
|
13
|
+
const date = { type: "string", pattern: CONSENT_DATE_PATTERN, format: "date-time" };
|
|
14
|
+
function freeze(value) {
|
|
15
|
+
if (value !== null && typeof value === "object") {
|
|
16
|
+
for (const child of Object.values(value))
|
|
17
|
+
freeze(child);
|
|
18
|
+
Object.freeze(value);
|
|
19
|
+
}
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* JSON Schema draft 2020-12. Runtime parsing additionally checks real calendar
|
|
24
|
+
* dates and revokedAt >= decidedAt (a comparison outside standard JSON Schema).
|
|
25
|
+
* No field resolves a template, verifies a hash, or establishes authorization.
|
|
26
|
+
*/
|
|
27
|
+
export const CONSENT_DECISION_V1_SCHEMA = freeze({
|
|
28
|
+
$schema: "https://json-schema.org/draft/2020-12/schema",
|
|
29
|
+
title: "consent-decision.v1",
|
|
30
|
+
type: "object",
|
|
31
|
+
additionalProperties: false,
|
|
32
|
+
required: ["schemaVersion", "tenant", "subject", "itemCode", "scope", "templateRef",
|
|
33
|
+
"textVersion", "textHash", "decision", "decidedAt", "source"],
|
|
34
|
+
properties: {
|
|
35
|
+
schemaVersion: { const: "consent-decision.v1" },
|
|
36
|
+
tenant: { type: "string", pattern: "^[A-Za-z0-9][A-Za-z0-9_.:-]{0,99}(?![\\s\\S])", maxLength: 100 },
|
|
37
|
+
subject: {
|
|
38
|
+
type: "object", additionalProperties: false, required: ["type", "ref"],
|
|
39
|
+
properties: { type: { enum: ["candidate", "patient"] }, ref: CONSENT_REFERENCE_RULE }
|
|
40
|
+
},
|
|
41
|
+
itemCode: code,
|
|
42
|
+
scope: { enum: ["adr", "patient-privacy", "research", "treatment", "contact"] },
|
|
43
|
+
templateRef: {
|
|
44
|
+
type: "object", additionalProperties: false, required: ["code", "revision"],
|
|
45
|
+
properties: { code, revision: { type: "integer", minimum: 1, maximum: Number.MAX_SAFE_INTEGER } }
|
|
46
|
+
},
|
|
47
|
+
textVersion: CONSENT_TEXT_VERSION_RULE,
|
|
48
|
+
textHash: hash,
|
|
49
|
+
channel: { enum: ["whatsapp", "sms", "email", "voice"] },
|
|
50
|
+
decision: { enum: ["granted", "declined", "revoked"] },
|
|
51
|
+
decidedAt: date,
|
|
52
|
+
revokedAt: date,
|
|
53
|
+
source: {
|
|
54
|
+
type: "object", additionalProperties: false,
|
|
55
|
+
required: ["system", "kind", "evidenceRef", "flowRef", "flowDigest"],
|
|
56
|
+
properties: { system: code, kind: code, evidenceRef: CONSENT_REFERENCE_RULE, flowRef: CONSENT_REFERENCE_RULE, flowDigest: hash }
|
|
57
|
+
}
|
|
58
|
+
},
|
|
59
|
+
allOf: [
|
|
60
|
+
{
|
|
61
|
+
if: { properties: { decision: { const: "revoked" } }, required: ["decision"] },
|
|
62
|
+
then: { required: ["revokedAt"] },
|
|
63
|
+
else: { not: { required: ["revokedAt"] } }
|
|
64
|
+
},
|
|
65
|
+
{
|
|
66
|
+
if: { required: ["channel"] },
|
|
67
|
+
then: {
|
|
68
|
+
properties: { itemCode: { pattern: "^contact-" }, scope: { const: "contact" } },
|
|
69
|
+
required: ["itemCode", "scope"]
|
|
70
|
+
}
|
|
71
|
+
}
|
|
72
|
+
]
|
|
73
|
+
});
|
|
74
|
+
//# sourceMappingURL=schema.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|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