gdc-common-utils-ts 1.6.0 → 1.7.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 (47) hide show
  1. package/dist/constants/index.d.ts +2 -0
  2. package/dist/constants/index.js +2 -0
  3. package/dist/constants/service-capabilities.d.ts +53 -0
  4. package/dist/constants/service-capabilities.js +72 -0
  5. package/dist/constants/verifiable-credentials.d.ts +34 -0
  6. package/dist/constants/verifiable-credentials.js +42 -0
  7. package/dist/examples/api-flow-examples.d.ts +1 -0
  8. package/dist/examples/api-flow-examples.js +1 -0
  9. package/dist/examples/consent-access.d.ts +12 -128
  10. package/dist/examples/consent-access.js +27 -18
  11. package/dist/examples/contract-examples.d.ts +1 -0
  12. package/dist/examples/contract-examples.js +1 -0
  13. package/dist/examples/frontend-session.d.ts +0 -4
  14. package/dist/examples/frontend-session.js +13 -7
  15. package/dist/examples/ica-activation-proof.d.ts +55 -0
  16. package/dist/examples/ica-activation-proof.js +67 -0
  17. package/dist/examples/index.d.ts +1 -0
  18. package/dist/examples/index.js +1 -0
  19. package/dist/examples/individual-controller.d.ts +19 -15
  20. package/dist/examples/individual-controller.js +16 -31
  21. package/dist/examples/lifecycle.d.ts +6 -4
  22. package/dist/examples/lifecycle.js +9 -7
  23. package/dist/examples/organization-controller.d.ts +5 -0
  24. package/dist/examples/organization-controller.js +17 -8
  25. package/dist/examples/professional.js +8 -7
  26. package/dist/examples/relationship-access.js +2 -2
  27. package/dist/examples/shared.d.ts +61 -7
  28. package/dist/examples/shared.js +55 -7
  29. package/dist/models/consent-rule.d.ts +1 -0
  30. package/dist/models/consent-rule.js +1 -0
  31. package/dist/models/interoperable-claims/allergy-intolerance-claims.js +1 -0
  32. package/dist/models/interoperable-claims/communication-claims.d.ts +14 -0
  33. package/dist/models/interoperable-claims/communication-claims.js +15 -0
  34. package/dist/models/interoperable-claims/condition-claims.js +1 -0
  35. package/dist/models/interoperable-claims/device-use-statement-claims.js +1 -0
  36. package/dist/models/interoperable-claims/document-reference-claims.js +1 -0
  37. package/dist/models/interoperable-claims/medication-statement-claims.d.ts +17 -0
  38. package/dist/models/interoperable-claims/medication-statement-claims.js +18 -0
  39. package/dist/utils/activation-policy.d.ts +8 -3
  40. package/dist/utils/activation-policy.js +26 -12
  41. package/dist/utils/clinical-resource-converters.js +70 -64
  42. package/dist/utils/communication-document-reference.js +10 -4
  43. package/dist/utils/communication-fhir-r4.js +40 -34
  44. package/dist/utils/consent.d.ts +1 -1
  45. package/dist/utils/consent.js +21 -20
  46. package/dist/utils/vp-token.js +8 -6
  47. package/package.json +1 -1
@@ -12,3 +12,5 @@ export * from './vital-signs';
12
12
  export * from './network';
13
13
  export * from './sectors';
14
14
  export * from './smart';
15
+ export * from './service-capabilities';
16
+ export * from './verifiable-credentials';
@@ -12,3 +12,5 @@ export * from './vital-signs.js';
12
12
  export * from './network.js';
13
13
  export * from './sectors.js';
14
14
  export * from './smart.js';
15
+ export * from './service-capabilities.js';
16
+ export * from './verifiable-credentials.js';
@@ -0,0 +1,53 @@
1
+ /**
2
+ * Canonical capability families persisted through
3
+ * `org.schema.Service.serviceType`.
4
+ */
5
+ export declare const ServiceCapabilityFamily: {
6
+ readonly Indexing: "indexing";
7
+ readonly DigitalTwin: "digitaltwin";
8
+ };
9
+ export type ServiceCapabilityFamilyValue = typeof ServiceCapabilityFamily[keyof typeof ServiceCapabilityFamily];
10
+ /**
11
+ * Canonical capability tokens currently documented for tenant activation.
12
+ *
13
+ * The family prefix is the stable part of the contract. Suffixes such as
14
+ * `.rs` and `.cruds` can evolve independently across runtimes.
15
+ */
16
+ export declare const ServiceCapabilityToken: {
17
+ readonly IndexingReadSearch: "indexing.rs";
18
+ readonly IndexingCruds: "indexing.cruds";
19
+ readonly DigitalTwinReadSearch: "digitaltwin.rs";
20
+ readonly DigitalTwinCruds: "digitaltwin.cruds";
21
+ };
22
+ export type ServiceCapabilityTokenValue = typeof ServiceCapabilityToken[keyof typeof ServiceCapabilityToken];
23
+ /**
24
+ * SDK-facing capability names.
25
+ *
26
+ * These names are intentionally more explicit than the persisted claim tokens:
27
+ * - `Provider` maps to write/manage capability (`*.cruds`)
28
+ * - `Reader` maps to read/search capability (`*.rs`)
29
+ */
30
+ export declare const ServiceCapability: {
31
+ readonly IndexingProvider: "indexing.cruds";
32
+ readonly IndexingReader: "indexing.rs";
33
+ readonly DigitalTwinProvider: "digitaltwin.cruds";
34
+ readonly DigitalTwinReader: "digitaltwin.rs";
35
+ };
36
+ export type ServiceCapabilityValue = typeof ServiceCapability[keyof typeof ServiceCapability];
37
+ /**
38
+ * Parses the CSV stored in `org.schema.Service.serviceType`.
39
+ */
40
+ export declare function parseServiceCapabilityTokens(value: unknown): string[];
41
+ /**
42
+ * Serializes capability tokens into the canonical CSV claim format.
43
+ */
44
+ export declare function serializeServiceCapabilityTokens(values: ReadonlyArray<string | undefined | null>): string | undefined;
45
+ /**
46
+ * Returns the capability family prefix from a token.
47
+ */
48
+ export declare function getServiceCapabilityFamily(value: string | undefined): string | undefined;
49
+ /**
50
+ * Checks whether the claim contains at least one capability from the requested
51
+ * family.
52
+ */
53
+ export declare function hasServiceCapabilityFamily(value: unknown, family: ServiceCapabilityFamilyValue | string): boolean;
@@ -0,0 +1,72 @@
1
+ // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
+ // Always create JSDoc, do not use strings inline in keys nor values, use types instead, and reuse the data test examples.
3
+ /**
4
+ * Canonical capability families persisted through
5
+ * `org.schema.Service.serviceType`.
6
+ */
7
+ export const ServiceCapabilityFamily = {
8
+ Indexing: 'indexing',
9
+ DigitalTwin: 'digitaltwin',
10
+ };
11
+ /**
12
+ * Canonical capability tokens currently documented for tenant activation.
13
+ *
14
+ * The family prefix is the stable part of the contract. Suffixes such as
15
+ * `.rs` and `.cruds` can evolve independently across runtimes.
16
+ */
17
+ export const ServiceCapabilityToken = {
18
+ IndexingReadSearch: 'indexing.rs',
19
+ IndexingCruds: 'indexing.cruds',
20
+ DigitalTwinReadSearch: 'digitaltwin.rs',
21
+ DigitalTwinCruds: 'digitaltwin.cruds',
22
+ };
23
+ /**
24
+ * SDK-facing capability names.
25
+ *
26
+ * These names are intentionally more explicit than the persisted claim tokens:
27
+ * - `Provider` maps to write/manage capability (`*.cruds`)
28
+ * - `Reader` maps to read/search capability (`*.rs`)
29
+ */
30
+ export const ServiceCapability = {
31
+ IndexingProvider: ServiceCapabilityToken.IndexingCruds,
32
+ IndexingReader: ServiceCapabilityToken.IndexingReadSearch,
33
+ DigitalTwinProvider: ServiceCapabilityToken.DigitalTwinCruds,
34
+ DigitalTwinReader: ServiceCapabilityToken.DigitalTwinReadSearch,
35
+ };
36
+ /**
37
+ * Parses the CSV stored in `org.schema.Service.serviceType`.
38
+ */
39
+ export function parseServiceCapabilityTokens(value) {
40
+ return Array.from(new Set(String(value || '')
41
+ .split(',')
42
+ .map((item) => item.trim())
43
+ .filter(Boolean)));
44
+ }
45
+ /**
46
+ * Serializes capability tokens into the canonical CSV claim format.
47
+ */
48
+ export function serializeServiceCapabilityTokens(values) {
49
+ const normalized = Array.from(new Set(values
50
+ .map((item) => String(item || '').trim())
51
+ .filter(Boolean)));
52
+ return normalized.length ? normalized.join(',') : undefined;
53
+ }
54
+ /**
55
+ * Returns the capability family prefix from a token.
56
+ */
57
+ export function getServiceCapabilityFamily(value) {
58
+ const normalized = String(value || '').trim().toLowerCase();
59
+ if (!normalized)
60
+ return undefined;
61
+ return normalized.split('.')[0] || undefined;
62
+ }
63
+ /**
64
+ * Checks whether the claim contains at least one capability from the requested
65
+ * family.
66
+ */
67
+ export function hasServiceCapabilityFamily(value, family) {
68
+ const normalizedFamily = String(family || '').trim().toLowerCase();
69
+ if (!normalizedFamily)
70
+ return false;
71
+ return parseServiceCapabilityTokens(value).some((item) => getServiceCapabilityFamily(item) === normalizedFamily);
72
+ }
@@ -0,0 +1,34 @@
1
+ /**
2
+ * Canonical W3C credential contexts reused by activation/VP helpers and tests.
3
+ *
4
+ * Keep these values centralized so examples and unit suites do not re-hardcode
5
+ * W3C context URLs inline.
6
+ */
7
+ export declare const W3cCredentialContexts: Readonly<{
8
+ V1: "https://www.w3.org/2018/credentials/v1";
9
+ V2: "https://www.w3.org/ns/credentials/v2";
10
+ }>;
11
+ /**
12
+ * Canonical W3C credential and presentation base types.
13
+ */
14
+ export declare const W3cCredentialTypes: Readonly<{
15
+ VerifiableCredential: "VerifiableCredential";
16
+ VerifiablePresentation: "VerifiablePresentation";
17
+ }>;
18
+ /**
19
+ * Canonical activation VC subtype names currently accepted by CORE helpers.
20
+ *
21
+ * Notes:
22
+ * - `LegalOrganizationCredential` and `PersonCredential` remain accepted as
23
+ * compatibility aliases while ICA/GW contracts converge.
24
+ * - Example/test code must import these constants instead of re-hardcoding the
25
+ * subtype strings inline.
26
+ */
27
+ export declare const ActivationCredentialTypes: Readonly<{
28
+ OrganizationCredential: "OrganizationCredential";
29
+ LegalOrganizationCredential: "LegalOrganizationCredential";
30
+ LegalRepresentativeCredential: "LegalRepresentativeCredential";
31
+ PersonCredential: "PersonCredential";
32
+ }>;
33
+ export declare const ORGANIZATION_ACTIVATION_VC_TYPES: readonly ("OrganizationCredential" | "LegalOrganizationCredential")[];
34
+ export declare const REPRESENTATIVE_ACTIVATION_VC_TYPES: readonly ("LegalRepresentativeCredential" | "PersonCredential")[];
@@ -0,0 +1,42 @@
1
+ // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
+ // Always create JSDoc, do not use strings inline in keys nor values, use types instead, and reuse the data test examples.
3
+ /**
4
+ * Canonical W3C credential contexts reused by activation/VP helpers and tests.
5
+ *
6
+ * Keep these values centralized so examples and unit suites do not re-hardcode
7
+ * W3C context URLs inline.
8
+ */
9
+ export const W3cCredentialContexts = Object.freeze({
10
+ V1: 'https://www.w3.org/2018/credentials/v1',
11
+ V2: 'https://www.w3.org/ns/credentials/v2',
12
+ });
13
+ /**
14
+ * Canonical W3C credential and presentation base types.
15
+ */
16
+ export const W3cCredentialTypes = Object.freeze({
17
+ VerifiableCredential: 'VerifiableCredential',
18
+ VerifiablePresentation: 'VerifiablePresentation',
19
+ });
20
+ /**
21
+ * Canonical activation VC subtype names currently accepted by CORE helpers.
22
+ *
23
+ * Notes:
24
+ * - `LegalOrganizationCredential` and `PersonCredential` remain accepted as
25
+ * compatibility aliases while ICA/GW contracts converge.
26
+ * - Example/test code must import these constants instead of re-hardcoding the
27
+ * subtype strings inline.
28
+ */
29
+ export const ActivationCredentialTypes = Object.freeze({
30
+ OrganizationCredential: 'OrganizationCredential',
31
+ LegalOrganizationCredential: 'LegalOrganizationCredential',
32
+ LegalRepresentativeCredential: 'LegalRepresentativeCredential',
33
+ PersonCredential: 'PersonCredential',
34
+ });
35
+ export const ORGANIZATION_ACTIVATION_VC_TYPES = Object.freeze([
36
+ ActivationCredentialTypes.OrganizationCredential,
37
+ ActivationCredentialTypes.LegalOrganizationCredential,
38
+ ]);
39
+ export const REPRESENTATIVE_ACTIVATION_VC_TYPES = Object.freeze([
40
+ ActivationCredentialTypes.LegalRepresentativeCredential,
41
+ ActivationCredentialTypes.PersonCredential,
42
+ ]);
@@ -6,6 +6,7 @@
6
6
  * while preserving a stable migration target for older imports.
7
7
  */
8
8
  export * from './shared';
9
+ export * from './ica-activation-proof';
9
10
  export * from './organization-controller';
10
11
  export * from './individual-controller';
11
12
  export * from './professional';
@@ -7,6 +7,7 @@
7
7
  * while preserving a stable migration target for older imports.
8
8
  */
9
9
  export * from './shared.js';
10
+ export * from './ica-activation-proof.js';
10
11
  export * from './organization-controller.js';
11
12
  export * from './individual-controller.js';
12
13
  export * from './professional.js';
@@ -1,7 +1,8 @@
1
+ import { ClaimConsent, type ConsentRule } from '../models/consent-rule';
2
+ import { EXAMPLE_EMAIL_PROFESSIONAL, EXAMPLE_EMAIL_RELATED_PERSON } from './shared';
1
3
  export declare const EXAMPLE_INDIVIDUAL_DID_WEB: "did:web:api.acme.org:individual:123";
2
4
  export declare const EXAMPLE_PROVIDER_ORGANIZATION_DID_WEB: "did:web:hospital.acme.org";
3
- export declare const EXAMPLE_EMAIL_PROFESSIONAL: "doctor.oncall@example.org";
4
- export declare const EXAMPLE_EMAIL_RELATED_PERSON: "parent.guardian@example.org";
5
+ export { EXAMPLE_EMAIL_PROFESSIONAL, EXAMPLE_EMAIL_RELATED_PERSON };
5
6
  export declare const EXAMPLE_CONSENT_ACCESS_JURISDICTION: "ES";
6
7
  /**
7
8
  * Legacy compatibility aliases kept so older docs/tests/imports continue to work
@@ -12,132 +13,15 @@ export declare const EXAMPLE_CONSENT_ACCESS_PROVIDER_DID: "did:web:hospital.acme
12
13
  export declare const EXAMPLE_CONSENT_ACCESS_PROVIDER_EMAIL: "doctor.oncall@example.org";
13
14
  export declare const EXAMPLE_CONSENT_ACCESS_RELATED_PERSON_EMAIL: "parent.guardian@example.org";
14
15
  export declare const EXAMPLE_CONSENT_ACCESS_RULES: Readonly<{
15
- physicianByEmailContinuousCare: {
16
- readonly 'Consent.date': "2026-05-20";
17
- readonly 'Consent.period-end'?: string | undefined;
18
- readonly 'Consent.period-start'?: string | undefined;
19
- readonly 'Consent.resourceType'?: string | undefined;
20
- readonly '@context': "org.hl7.fhir.api";
21
- readonly 'Consent.identifier': string;
22
- readonly 'Consent.subject': "did:web:api.acme.org:individual:123";
23
- readonly 'Consent.actor-identifier': string;
24
- readonly 'Consent.actor-role': string;
25
- readonly 'Consent.decision': "permit" | "deny";
26
- readonly 'Consent.purpose': string;
27
- readonly 'Consent.action': string;
28
- };
29
- physicianByEmailEmergency: {
30
- readonly 'Consent.date': "2026-05-20";
31
- readonly 'Consent.period-end'?: string | undefined;
32
- readonly 'Consent.period-start'?: string | undefined;
33
- readonly 'Consent.resourceType'?: string | undefined;
34
- readonly '@context': "org.hl7.fhir.api";
35
- readonly 'Consent.identifier': string;
36
- readonly 'Consent.subject': "did:web:api.acme.org:individual:123";
37
- readonly 'Consent.actor-identifier': string;
38
- readonly 'Consent.actor-role': string;
39
- readonly 'Consent.decision': "permit" | "deny";
40
- readonly 'Consent.purpose': string;
41
- readonly 'Consent.action': string;
42
- };
43
- physicianByOrganizationContinuousCare: {
44
- readonly 'Consent.date': "2026-05-20";
45
- readonly 'Consent.period-end'?: string | undefined;
46
- readonly 'Consent.period-start'?: string | undefined;
47
- readonly 'Consent.resourceType'?: string | undefined;
48
- readonly '@context': "org.hl7.fhir.api";
49
- readonly 'Consent.identifier': string;
50
- readonly 'Consent.subject': "did:web:api.acme.org:individual:123";
51
- readonly 'Consent.actor-identifier': string;
52
- readonly 'Consent.actor-role': string;
53
- readonly 'Consent.decision': "permit" | "deny";
54
- readonly 'Consent.purpose': string;
55
- readonly 'Consent.action': string;
56
- };
57
- physicianByJurisdictionEmergency: {
58
- readonly 'Consent.date': "2026-05-20";
59
- readonly 'Consent.period-end'?: string | undefined;
60
- readonly 'Consent.period-start'?: string | undefined;
61
- readonly 'Consent.resourceType'?: string | undefined;
62
- readonly '@context': "org.hl7.fhir.api";
63
- readonly 'Consent.identifier': string;
64
- readonly 'Consent.subject': "did:web:api.acme.org:individual:123";
65
- readonly 'Consent.actor-identifier': string;
66
- readonly 'Consent.actor-role': string;
67
- readonly 'Consent.decision': "permit" | "deny";
68
- readonly 'Consent.purpose': string;
69
- readonly 'Consent.action': string;
70
- };
71
- nurseByOrganization: {
72
- readonly 'Consent.date': "2026-05-20";
73
- readonly 'Consent.period-end'?: string | undefined;
74
- readonly 'Consent.period-start'?: string | undefined;
75
- readonly 'Consent.resourceType'?: string | undefined;
76
- readonly '@context': "org.hl7.fhir.api";
77
- readonly 'Consent.identifier': string;
78
- readonly 'Consent.subject': "did:web:api.acme.org:individual:123";
79
- readonly 'Consent.actor-identifier': string;
80
- readonly 'Consent.actor-role': string;
81
- readonly 'Consent.decision': "permit" | "deny";
82
- readonly 'Consent.purpose': string;
83
- readonly 'Consent.action': string;
84
- };
85
- paramedicByJurisdiction: {
86
- readonly 'Consent.date': "2026-05-20";
87
- readonly 'Consent.period-end'?: string | undefined;
88
- readonly 'Consent.period-start'?: string | undefined;
89
- readonly 'Consent.resourceType'?: string | undefined;
90
- readonly '@context': "org.hl7.fhir.api";
91
- readonly 'Consent.identifier': string;
92
- readonly 'Consent.subject': "did:web:api.acme.org:individual:123";
93
- readonly 'Consent.actor-identifier': string;
94
- readonly 'Consent.actor-role': string;
95
- readonly 'Consent.decision': "permit" | "deny";
96
- readonly 'Consent.purpose': string;
97
- readonly 'Consent.action': string;
98
- };
99
- directPhysicianDenyInsideAllowedOrganization: {
100
- readonly 'Consent.date': "2026-05-20";
101
- readonly 'Consent.period-end'?: string | undefined;
102
- readonly 'Consent.period-start'?: string | undefined;
103
- readonly 'Consent.resourceType'?: string | undefined;
104
- readonly '@context': "org.hl7.fhir.api";
105
- readonly 'Consent.identifier': string;
106
- readonly 'Consent.subject': "did:web:api.acme.org:individual:123";
107
- readonly 'Consent.actor-identifier': string;
108
- readonly 'Consent.actor-role': string;
109
- readonly 'Consent.decision': "permit" | "deny";
110
- readonly 'Consent.purpose': string;
111
- readonly 'Consent.action': string;
112
- };
113
- relatedPersonByEmail: {
114
- readonly 'Consent.date': "2026-05-20";
115
- readonly 'Consent.period-end'?: string | undefined;
116
- readonly 'Consent.period-start'?: string | undefined;
117
- readonly 'Consent.resourceType'?: string | undefined;
118
- readonly '@context': "org.hl7.fhir.api";
119
- readonly 'Consent.identifier': string;
120
- readonly 'Consent.subject': "did:web:api.acme.org:individual:123";
121
- readonly 'Consent.actor-identifier': string;
122
- readonly 'Consent.actor-role': string;
123
- readonly 'Consent.decision': "permit" | "deny";
124
- readonly 'Consent.purpose': string;
125
- readonly 'Consent.action': string;
126
- };
127
- revokedPhysicianEmailConsent: {
128
- readonly 'Consent.date': "2026-05-20";
129
- readonly 'Consent.period-end'?: string | undefined;
130
- readonly 'Consent.period-start'?: string | undefined;
131
- readonly 'Consent.resourceType'?: string | undefined;
132
- readonly '@context': "org.hl7.fhir.api";
133
- readonly 'Consent.identifier': string;
134
- readonly 'Consent.subject': "did:web:api.acme.org:individual:123";
135
- readonly 'Consent.actor-identifier': string;
136
- readonly 'Consent.actor-role': string;
137
- readonly 'Consent.decision': "permit" | "deny";
138
- readonly 'Consent.purpose': string;
139
- readonly 'Consent.action': string;
140
- };
16
+ physicianByEmailContinuousCare: ConsentRule & Partial<Record<ClaimConsent.resourceType, string>>;
17
+ physicianByEmailEmergency: ConsentRule & Partial<Record<ClaimConsent.resourceType, string>>;
18
+ physicianByOrganizationContinuousCare: ConsentRule & Partial<Record<ClaimConsent.resourceType, string>>;
19
+ physicianByJurisdictionEmergency: ConsentRule & Partial<Record<ClaimConsent.resourceType, string>>;
20
+ nurseByOrganization: ConsentRule & Partial<Record<ClaimConsent.resourceType, string>>;
21
+ paramedicByJurisdiction: ConsentRule & Partial<Record<ClaimConsent.resourceType, string>>;
22
+ directPhysicianDenyInsideAllowedOrganization: ConsentRule & Partial<Record<ClaimConsent.resourceType, string>>;
23
+ relatedPersonByEmail: ConsentRule & Partial<Record<ClaimConsent.resourceType, string>>;
24
+ revokedPhysicianEmailConsent: ConsentRule & Partial<Record<ClaimConsent.resourceType, string>>;
141
25
  }>;
142
26
  export declare const EXAMPLE_CONSENT_PHONE_EXTENSION_PENDING: Readonly<{
143
27
  target: "tel:+34600111222";
@@ -1,11 +1,12 @@
1
1
  // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
2
  import { HealthcareActorRoles, HealthcareBasicSections, HealthcareConsentPurposes, } from '../constants/healthcare.js';
3
+ import { ClaimConsent } from '../models/consent-rule.js';
3
4
  import { ResourceTypesFhirR4 } from '../constants/fhir-resource-types.js';
4
- export const EXAMPLE_INDIVIDUAL_DID_WEB = 'did:web:api.acme.org:individual:123';
5
- export const EXAMPLE_PROVIDER_ORGANIZATION_DID_WEB = 'did:web:hospital.acme.org';
6
- export const EXAMPLE_EMAIL_PROFESSIONAL = 'doctor.oncall@example.org';
7
- export const EXAMPLE_EMAIL_RELATED_PERSON = 'parent.guardian@example.org';
8
- export const EXAMPLE_CONSENT_ACCESS_JURISDICTION = 'ES';
5
+ import { EXAMPLE_CONSENT_DATE, EXAMPLE_CONSENT_PERIOD_END, EXAMPLE_EMAIL_PROFESSIONAL, EXAMPLE_EMAIL_RELATED_PERSON, EXAMPLE_HEALTHCARE_JURISDICTION, EXAMPLE_PROVIDER_ORGANIZATION_DID, EXAMPLE_RELATED_PERSON_ROLE, EXAMPLE_SUBJECT_DID, } from './shared.js';
6
+ export const EXAMPLE_INDIVIDUAL_DID_WEB = EXAMPLE_SUBJECT_DID;
7
+ export const EXAMPLE_PROVIDER_ORGANIZATION_DID_WEB = EXAMPLE_PROVIDER_ORGANIZATION_DID;
8
+ export { EXAMPLE_EMAIL_PROFESSIONAL, EXAMPLE_EMAIL_RELATED_PERSON };
9
+ export const EXAMPLE_CONSENT_ACCESS_JURISDICTION = EXAMPLE_HEALTHCARE_JURISDICTION;
9
10
  /**
10
11
  * Legacy compatibility aliases kept so older docs/tests/imports continue to work
11
12
  * while the canonical variable names converge.
@@ -14,20 +15,28 @@ export const EXAMPLE_CONSENT_ACCESS_SUBJECT = EXAMPLE_INDIVIDUAL_DID_WEB;
14
15
  export const EXAMPLE_CONSENT_ACCESS_PROVIDER_DID = EXAMPLE_PROVIDER_ORGANIZATION_DID_WEB;
15
16
  export const EXAMPLE_CONSENT_ACCESS_PROVIDER_EMAIL = EXAMPLE_EMAIL_PROFESSIONAL;
16
17
  export const EXAMPLE_CONSENT_ACCESS_RELATED_PERSON_EMAIL = EXAMPLE_EMAIL_RELATED_PERSON;
18
+ /**
19
+ * Consent example builder used by docs/tests.
20
+ *
21
+ * Contract note:
22
+ * repeated actor identifiers, dates, jurisdictions, role fixtures, and
23
+ * canonical consent claim keys must be imported, never re-hardcoded inline in
24
+ * each example rule.
25
+ */
17
26
  function buildRule(input) {
18
27
  return {
19
28
  '@context': 'org.hl7.fhir.api',
20
- 'Consent.identifier': input.identifier,
21
- 'Consent.subject': EXAMPLE_INDIVIDUAL_DID_WEB,
22
- 'Consent.actor-identifier': input.actorIdentifier,
23
- 'Consent.actor-role': input.actorRole,
24
- 'Consent.decision': input.decision || 'permit',
25
- 'Consent.purpose': input.purpose,
26
- 'Consent.action': input.actions.join(','),
27
- ...(input.resourceTypes?.length ? { 'Consent.resourceType': input.resourceTypes.join(',') } : {}),
28
- ...(input.periodStart ? { 'Consent.period-start': input.periodStart } : {}),
29
- ...(input.periodEnd ? { 'Consent.period-end': input.periodEnd } : {}),
30
- 'Consent.date': '2026-05-20',
29
+ [ClaimConsent.identifier]: input.identifier,
30
+ [ClaimConsent.subject]: EXAMPLE_INDIVIDUAL_DID_WEB,
31
+ [ClaimConsent.actorIdentifier]: input.actorIdentifier,
32
+ [ClaimConsent.actorRole]: input.actorRole,
33
+ [ClaimConsent.decision]: input.decision || 'permit',
34
+ [ClaimConsent.purpose]: input.purpose,
35
+ [ClaimConsent.action]: input.actions.join(','),
36
+ ...(input.resourceTypes?.length ? { [ClaimConsent.resourceType]: input.resourceTypes.join(',') } : {}),
37
+ ...(input.periodStart ? { [ClaimConsent.periodStart]: input.periodStart } : {}),
38
+ ...(input.periodEnd ? { [ClaimConsent.periodEnd]: input.periodEnd } : {}),
39
+ [ClaimConsent.date]: EXAMPLE_CONSENT_DATE,
31
40
  };
32
41
  }
33
42
  export const EXAMPLE_CONSENT_ACCESS_RULES = Object.freeze({
@@ -91,7 +100,7 @@ export const EXAMPLE_CONSENT_ACCESS_RULES = Object.freeze({
91
100
  relatedPersonByEmail: buildRule({
92
101
  identifier: 'urn:uuid:consent-related-person-email',
93
102
  actorIdentifier: EXAMPLE_EMAIL_RELATED_PERSON,
94
- actorRole: 'v3-RoleCode|RESPRSN',
103
+ actorRole: EXAMPLE_RELATED_PERSON_ROLE,
95
104
  purpose: HealthcareConsentPurposes.Treatment,
96
105
  actions: [HealthcareBasicSections.PatientSummaryDocument.claim],
97
106
  resourceTypes: [ResourceTypesFhirR4.Composition, ResourceTypesFhirR4.DocumentReference],
@@ -102,7 +111,7 @@ export const EXAMPLE_CONSENT_ACCESS_RULES = Object.freeze({
102
111
  actorRole: HealthcareActorRoles.Physician,
103
112
  purpose: HealthcareConsentPurposes.EmergencyTreatment,
104
113
  actions: [HealthcareBasicSections.PatientSummaryDocument.claim],
105
- periodEnd: '2026-05-01T00:00:00Z',
114
+ periodEnd: EXAMPLE_CONSENT_PERIOD_END,
106
115
  }),
107
116
  });
108
117
  export const EXAMPLE_CONSENT_PHONE_EXTENSION_PENDING = Object.freeze({
@@ -6,6 +6,7 @@
6
6
  * breaking while the examples are reorganized by flow/case of use.
7
7
  */
8
8
  export * from './shared';
9
+ export * from './ica-activation-proof';
9
10
  export * from './organization-controller';
10
11
  export * from './individual-controller';
11
12
  export * from './professional';
@@ -7,6 +7,7 @@
7
7
  * breaking while the examples are reorganized by flow/case of use.
8
8
  */
9
9
  export * from './shared.js';
10
+ export * from './ica-activation-proof.js';
10
11
  export * from './organization-controller.js';
11
12
  export * from './individual-controller.js';
12
13
  export * from './professional.js';
@@ -1,7 +1,3 @@
1
- /**
2
- * Examples for frontend session/profile bootstrap flows.
3
- */
4
- export declare const EXAMPLE_PROFILE_PROVIDER_DID = "did:web:provider.example.org";
5
1
  export declare const EXAMPLE_PROFILE_SESSION_INPUT: {
6
2
  readonly profileId: " profile-1 ";
7
3
  readonly email: " user@example.com ";
@@ -1,18 +1,24 @@
1
1
  // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
2
  /**
3
3
  * Examples for frontend session/profile bootstrap flows.
4
+ *
5
+ * Note:
6
+ *
7
+ * - profile/provider identifiers in this file are synthetic fixtures imported
8
+ * from `./shared`
9
+ * - do not inline DID/email/profile literals directly in frontend examples
4
10
  */
5
- export const EXAMPLE_PROFILE_PROVIDER_DID = 'did:web:provider.example.org';
11
+ import { EXAMPLE_PROFILE_EMAIL, EXAMPLE_PROFILE_ID, EXAMPLE_PROFILE_ORGANIZATION_DID, } from './shared.js';
6
12
  export const EXAMPLE_PROFILE_SESSION_INPUT = {
7
- profileId: ' profile-1 ',
8
- email: ' user@example.com ',
13
+ profileId: ` ${EXAMPLE_PROFILE_ID} `,
14
+ email: ` ${EXAMPLE_PROFILE_EMAIL} `,
9
15
  role: ' controller ',
10
- providerDid: ' did:web:org.example ',
16
+ providerDid: ` ${EXAMPLE_PROFILE_ORGANIZATION_DID} `,
11
17
  appType: 'Family',
12
18
  };
13
19
  export const EXAMPLE_PROFILE_REGISTRY_ENTRY = {
14
- id: 'profile-1',
15
- email: 'user@example.com',
20
+ id: EXAMPLE_PROFILE_ID,
21
+ email: EXAMPLE_PROFILE_EMAIL,
16
22
  role: 'controller',
17
- providerDid: 'did:web:org.example',
23
+ providerDid: EXAMPLE_PROFILE_ORGANIZATION_DID,
18
24
  };
@@ -0,0 +1,55 @@
1
+ /**
2
+ * Shared synthetic ICA activation-proof fixtures reused by docs/tests.
3
+ *
4
+ * Contract note:
5
+ * - issuer/holder/audience DIDs, VC subtype names, and representative binding
6
+ * fields must be imported from this module instead of re-hardcoded inline
7
+ * - the representative `hasCredential.material` shape below reflects the
8
+ * current `activation-policy` helper contract; if ICA finalizes a different
9
+ * VC shape, update this module first and then the dependent helpers/tests
10
+ */
11
+ export declare const EXAMPLE_ICA_VP_ISSUER_DID: "did:web:controller.example.org";
12
+ export declare const EXAMPLE_ICA_VP_AUDIENCE_DID: "did:web:host.example.com";
13
+ export declare const EXAMPLE_ICA_VP_HOLDER_DID: "did:web:controller.example.org";
14
+ export declare const EXAMPLE_ICA_ORGANIZATION_DID: "did:web:org.example.org";
15
+ export declare const EXAMPLE_ICA_REPRESENTATIVE_DID: "did:web:rep.example.org";
16
+ export declare const EXAMPLE_ICA_ORGANIZATION_TAX_ID: "ESB00112233";
17
+ export declare const EXAMPLE_ICA_REPRESENTATIVE_ROLE_CODE: "RESPRSN";
18
+ export declare const EXAMPLE_ICA_REPRESENTATIVE_BINDING_MATERIAL: "controller-sig-kid";
19
+ export declare const EXAMPLE_ICA_ORGANIZATION_CREDENTIAL: Readonly<{
20
+ '@context': string[];
21
+ type: ("VerifiableCredential" | "OrganizationCredential")[];
22
+ credentialSubject: {
23
+ id: "did:web:org.example.org";
24
+ taxID: "ESB00112233";
25
+ };
26
+ }>;
27
+ export declare const EXAMPLE_ICA_LEGAL_REPRESENTATIVE_CREDENTIAL: Readonly<{
28
+ '@context': string[];
29
+ type: ("VerifiableCredential" | "LegalRepresentativeCredential")[];
30
+ credentialSubject: {
31
+ id: "did:web:rep.example.org";
32
+ memberOf: {
33
+ taxID: "ESB00112233";
34
+ };
35
+ hasOccupation: {
36
+ identifier: {
37
+ value: "RESPRSN";
38
+ };
39
+ };
40
+ hasCredential: {
41
+ material: "controller-sig-kid";
42
+ };
43
+ };
44
+ }>;
45
+ export declare const EXAMPLE_ICA_ACTIVATION_VP_PAYLOAD: Readonly<{
46
+ iss: "did:web:controller.example.org";
47
+ sub: "did:web:controller.example.org";
48
+ aud: "did:web:host.example.com";
49
+ vp: {
50
+ '@context': "https://www.w3.org/2018/credentials/v1"[];
51
+ type: "VerifiablePresentation"[];
52
+ holder: "did:web:controller.example.org";
53
+ verifiableCredential: string[];
54
+ };
55
+ }>;
@@ -0,0 +1,67 @@
1
+ // Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
2
+ // Always create JSDoc, do not use strings inline in keys nor values, use types instead, and reuse the data test examples.
3
+ import { ActivationCredentialTypes, W3cCredentialContexts, W3cCredentialTypes, } from '../constants/verifiable-credentials.js';
4
+ /**
5
+ * Shared synthetic ICA activation-proof fixtures reused by docs/tests.
6
+ *
7
+ * Contract note:
8
+ * - issuer/holder/audience DIDs, VC subtype names, and representative binding
9
+ * fields must be imported from this module instead of re-hardcoded inline
10
+ * - the representative `hasCredential.material` shape below reflects the
11
+ * current `activation-policy` helper contract; if ICA finalizes a different
12
+ * VC shape, update this module first and then the dependent helpers/tests
13
+ */
14
+ export const EXAMPLE_ICA_VP_ISSUER_DID = 'did:web:controller.example.org';
15
+ export const EXAMPLE_ICA_VP_AUDIENCE_DID = 'did:web:host.example.com';
16
+ export const EXAMPLE_ICA_VP_HOLDER_DID = EXAMPLE_ICA_VP_ISSUER_DID;
17
+ export const EXAMPLE_ICA_ORGANIZATION_DID = 'did:web:org.example.org';
18
+ export const EXAMPLE_ICA_REPRESENTATIVE_DID = 'did:web:rep.example.org';
19
+ export const EXAMPLE_ICA_ORGANIZATION_TAX_ID = 'ESB00112233';
20
+ export const EXAMPLE_ICA_REPRESENTATIVE_ROLE_CODE = 'RESPRSN';
21
+ export const EXAMPLE_ICA_REPRESENTATIVE_BINDING_MATERIAL = 'controller-sig-kid';
22
+ export const EXAMPLE_ICA_ORGANIZATION_CREDENTIAL = Object.freeze({
23
+ '@context': [W3cCredentialContexts.V2, 'https://schema.org'],
24
+ type: [
25
+ W3cCredentialTypes.VerifiableCredential,
26
+ ActivationCredentialTypes.OrganizationCredential,
27
+ ],
28
+ credentialSubject: {
29
+ id: EXAMPLE_ICA_ORGANIZATION_DID,
30
+ taxID: EXAMPLE_ICA_ORGANIZATION_TAX_ID,
31
+ },
32
+ });
33
+ export const EXAMPLE_ICA_LEGAL_REPRESENTATIVE_CREDENTIAL = Object.freeze({
34
+ '@context': [W3cCredentialContexts.V2, 'https://schema.org'],
35
+ type: [
36
+ W3cCredentialTypes.VerifiableCredential,
37
+ ActivationCredentialTypes.LegalRepresentativeCredential,
38
+ ],
39
+ credentialSubject: {
40
+ id: EXAMPLE_ICA_REPRESENTATIVE_DID,
41
+ memberOf: {
42
+ taxID: EXAMPLE_ICA_ORGANIZATION_TAX_ID,
43
+ },
44
+ hasOccupation: {
45
+ identifier: {
46
+ value: EXAMPLE_ICA_REPRESENTATIVE_ROLE_CODE,
47
+ },
48
+ },
49
+ hasCredential: {
50
+ material: EXAMPLE_ICA_REPRESENTATIVE_BINDING_MATERIAL,
51
+ },
52
+ },
53
+ });
54
+ export const EXAMPLE_ICA_ACTIVATION_VP_PAYLOAD = Object.freeze({
55
+ iss: EXAMPLE_ICA_VP_ISSUER_DID,
56
+ sub: EXAMPLE_ICA_VP_ISSUER_DID,
57
+ aud: EXAMPLE_ICA_VP_AUDIENCE_DID,
58
+ vp: {
59
+ '@context': [W3cCredentialContexts.V1],
60
+ type: [W3cCredentialTypes.VerifiablePresentation],
61
+ holder: EXAMPLE_ICA_VP_HOLDER_DID,
62
+ verifiableCredential: [
63
+ JSON.stringify(EXAMPLE_ICA_ORGANIZATION_CREDENTIAL),
64
+ JSON.stringify(EXAMPLE_ICA_LEGAL_REPRESENTATIVE_CREDENTIAL),
65
+ ],
66
+ },
67
+ });