gdc-common-utils-ts 2.7.0 → 2.7.1

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 CHANGED
@@ -152,6 +152,7 @@ entry types, FHIR-like resources, and `resource.meta.claims` fit together,
152
152
  read first:
153
153
 
154
154
  - [`docs/101-ID_TOKEN.md`](docs/101-ID_TOKEN.md)
155
+ - [`docs/101-DIDCOMM-IDENTITY-BOUNDARY.md`](docs/101-DIDCOMM-IDENTITY-BOUNDARY.md)
155
156
  - [`docs/101-COMMUNICATION_LAYERING.md`](docs/101-COMMUNICATION_LAYERING.md)
156
157
  - [`docs/101-BUNDLE_EDITOR_READER.md`](docs/101-BUNDLE_EDITOR_READER.md)
157
158
  - [`docs/101-CLINICAL-IPS.md`](docs/101-CLINICAL-IPS.md)
@@ -10,6 +10,7 @@ export declare const DidcommMessageTypes: Readonly<{
10
10
  readonly CommunicationAttachedBundle: "Communication-attached-bundle-v1.0";
11
11
  readonly CommunicationBundleSubmit: "Communication-bundle-submit-v1.0";
12
12
  readonly CommunicationResponse: "Communication-response-v1.0";
13
+ readonly SmartTokenRequest: "Smart-token-request-v1.0";
13
14
  }>;
14
15
  /**
15
16
  * Canonical low-level DIDComm acknowledgement body keys used in shared tests
@@ -10,6 +10,7 @@ export const DidcommMessageTypes = Object.freeze({
10
10
  CommunicationAttachedBundle: 'Communication-attached-bundle-v1.0',
11
11
  CommunicationBundleSubmit: 'Communication-bundle-submit-v1.0',
12
12
  CommunicationResponse: 'Communication-response-v1.0',
13
+ SmartTokenRequest: 'Smart-token-request-v1.0',
13
14
  });
14
15
  /**
15
16
  * Canonical low-level DIDComm acknowledgement body keys used in shared tests
@@ -0,0 +1,23 @@
1
+ import type { IDecodedDidcommPayload } from '../models/confidential-message';
2
+ /** Signing verification method controlled by the direct actor DID. */
3
+ export declare const EXAMPLE_DIRECT_ACTOR_SIGNING_KEY_ID: `${string}#communication-signing`;
4
+ /** Signing verification method registered for the DCR client/device. */
5
+ export declare const EXAMPLE_DCR_DEVICE_SIGNING_KEY_ID: "did:web:device-001#dcr-signing";
6
+ /**
7
+ * Canonical direct DIDComm/FAPI message.
8
+ *
9
+ * `from` and `iss` identify the same direct sender. `kid` identifies the
10
+ * concrete signing key and therefore remains in the signed JWS header. The
11
+ * FHIR-like Communication stays inside `body`; transport identity never
12
+ * becomes a FHIR field.
13
+ */
14
+ export declare const EXAMPLE_DIRECT_ACTOR_DIDCOMM_MESSAGE: IDecodedDidcommPayload;
15
+ /**
16
+ * Canonical device-bound SMART request.
17
+ *
18
+ * The DCR client/device is the DIDComm/FAPI sender and issuer because it signs
19
+ * the request. Its registered `kid` selects the proof key. SMART `sub`
20
+ * separately identifies the professional actor and `scope` separately limits
21
+ * the subject data requested by that actor.
22
+ */
23
+ export declare const EXAMPLE_DEVICE_BOUND_SMART_DIDCOMM_MESSAGE: IDecodedDidcommPayload;
@@ -0,0 +1,65 @@
1
+ import { DidcommMessageTypes } from '../constants/didcomm.js';
2
+ import { buildSmartCompositionReadScope } from '../utils/smart-scope.js';
3
+ import { EXAMPLE_DEVICE_CLIENT_ID, EXAMPLE_HOSTING_OPERATOR_DID, EXAMPLE_PROFESSIONAL_DID, EXAMPLE_SUBJECT_DID, buildExampleCommunicationIngestionPayload, } from './shared.js';
4
+ /** Signing verification method controlled by the direct actor DID. */
5
+ export const EXAMPLE_DIRECT_ACTOR_SIGNING_KEY_ID = `${EXAMPLE_PROFESSIONAL_DID}#communication-signing`;
6
+ /** Signing verification method registered for the DCR client/device. */
7
+ export const EXAMPLE_DCR_DEVICE_SIGNING_KEY_ID = `${EXAMPLE_DEVICE_CLIENT_ID}#dcr-signing`;
8
+ /**
9
+ * Canonical direct DIDComm/FAPI message.
10
+ *
11
+ * `from` and `iss` identify the same direct sender. `kid` identifies the
12
+ * concrete signing key and therefore remains in the signed JWS header. The
13
+ * FHIR-like Communication stays inside `body`; transport identity never
14
+ * becomes a FHIR field.
15
+ */
16
+ export const EXAMPLE_DIRECT_ACTOR_DIDCOMM_MESSAGE = {
17
+ meta: {
18
+ jws: {
19
+ protected: {
20
+ alg: 'ES384',
21
+ kid: EXAMPLE_DIRECT_ACTOR_SIGNING_KEY_ID,
22
+ typ: 'JWT',
23
+ cty: 'application/didcomm-signed+json',
24
+ },
25
+ },
26
+ },
27
+ iss: EXAMPLE_PROFESSIONAL_DID,
28
+ from: EXAMPLE_PROFESSIONAL_DID,
29
+ aud: EXAMPLE_HOSTING_OPERATOR_DID,
30
+ jti: 'urn:uuid:didcomm-direct-example',
31
+ thid: 'didcomm-direct-example',
32
+ type: DidcommMessageTypes.CommunicationAttachedBundle,
33
+ body: buildExampleCommunicationIngestionPayload().body,
34
+ };
35
+ /**
36
+ * Canonical device-bound SMART request.
37
+ *
38
+ * The DCR client/device is the DIDComm/FAPI sender and issuer because it signs
39
+ * the request. Its registered `kid` selects the proof key. SMART `sub`
40
+ * separately identifies the professional actor and `scope` separately limits
41
+ * the subject data requested by that actor.
42
+ */
43
+ export const EXAMPLE_DEVICE_BOUND_SMART_DIDCOMM_MESSAGE = {
44
+ meta: {
45
+ jws: {
46
+ protected: {
47
+ alg: 'ES384',
48
+ kid: EXAMPLE_DCR_DEVICE_SIGNING_KEY_ID,
49
+ typ: 'JWT',
50
+ cty: 'application/didcomm-signed+json',
51
+ },
52
+ },
53
+ },
54
+ iss: EXAMPLE_DEVICE_CLIENT_ID,
55
+ from: EXAMPLE_DEVICE_CLIENT_ID,
56
+ aud: EXAMPLE_HOSTING_OPERATOR_DID,
57
+ jti: 'urn:uuid:didcomm-smart-example',
58
+ thid: 'didcomm-smart-example',
59
+ type: DidcommMessageTypes.SmartTokenRequest,
60
+ body: {
61
+ client_id: EXAMPLE_DEVICE_CLIENT_ID,
62
+ sub: EXAMPLE_PROFESSIONAL_DID,
63
+ scope: buildSmartCompositionReadScope({ subjectDid: EXAMPLE_SUBJECT_DID }),
64
+ },
65
+ };
@@ -30,3 +30,4 @@ export * from './ips-bundle';
30
30
  export * from './vital-signs';
31
31
  export * from './wallet-mem';
32
32
  export * from './profile-manager-mem';
33
+ export * from './didcomm-identity';
@@ -30,3 +30,4 @@ export * from './ips-bundle.js';
30
30
  export * from './vital-signs.js';
31
31
  export * from './wallet-mem.js';
32
32
  export * from './profile-manager-mem.js';
33
+ export * from './didcomm-identity.js';
@@ -661,7 +661,7 @@ export declare function buildExampleCommunicationIngestionPayload({ subjectDid,
661
661
  }[];
662
662
  meta: {
663
663
  claims: {
664
- '@context': "org.hl7.fhir.r4";
664
+ '@context': "org.hl7.fhir.api";
665
665
  "Communication.category": string;
666
666
  "Communication.subject": string;
667
667
  "Communication.sent": string;
@@ -640,7 +640,9 @@ export function buildExampleCommunicationIngestionPayload({ subjectDid = EXAMPLE
640
640
  note: [{ text: EXAMPLE_IPS_BUNDLE_NOTE_TEXT }],
641
641
  meta: {
642
642
  claims: {
643
- '@context': Format.FHIR_R4,
643
+ // The surrounding resource is native FHIR R4, while flat
644
+ // claims remain version-neutral and can later render as R4 or R5.
645
+ '@context': Format.FHIR_API,
644
646
  [CommunicationClaim.Category]: CommunicationCategoryCodes.Notification.claim,
645
647
  [CommunicationClaim.Subject]: subjectDid,
646
648
  [CommunicationClaim.Sent]: sent,
@@ -43,8 +43,11 @@ export interface IDecodedDidcommPayload {
43
43
  /** Relevant information available through the decryption and verification process */
44
44
  meta?: DidCommDecodedMetadata;
45
45
  /**
46
- * (Issuer) The DID of the entity that issued the message.
47
- * REQUIRED for FAPI. MUST match the signer of the enclosing JWS.
46
+ * (Issuer) DID of the entity that issued and signed the message.
47
+ * REQUIRED for FAPI. It MUST be bound to the signer of the enclosing JWS.
48
+ * The signing key is identified separately by `meta.jws.protected.kid`;
49
+ * `iss` is never the key id. For a DCR-bound client this is normally the
50
+ * client/device DID, while a SMART human actor remains in `body.sub`.
48
51
  */
49
52
  iss: string;
50
53
  /**
@@ -71,7 +74,13 @@ export interface IDecodedDidcommPayload {
71
74
  pthid?: string;
72
75
  /** The DID of the intended recipient. Used for P2P messaging, informational in client-server requests. */
73
76
  to?: string[];
74
- /** The DID of the sender. Used for P2P messaging, but `iss` is the authoritative value for FAPI. */
77
+ /**
78
+ * DIDComm sender DID. In a direct signed request this normally equals `iss`.
79
+ * It is never a raw email, telephone, card id or `urn:multibase` alias. When
80
+ * a DCR client acts for a human, `from`/`iss` identify the client and SMART
81
+ * `body.sub` identifies the human actor. `iss` remains authoritative for
82
+ * the FAPI signature boundary.
83
+ */
75
84
  from?: string;
76
85
  /**
77
86
  * The Message Type URI, identifying the type of data in the body or protocol used.
@@ -1,4 +1,5 @@
1
1
  import { ResourceTypesFhirR4 } from '../constants/fhir-resource-types.js';
2
+ import { Format } from '../constants/Schemas.js';
2
3
  import { AllergyIntoleranceClaim } from '../models/interoperable-claims/allergy-intolerance-claims.js';
3
4
  import { CompositionClaim } from '../models/interoperable-claims/composition-claims.js';
4
5
  import { ConditionClaim } from '../models/interoperable-claims/condition-claims.js';
@@ -7,7 +8,13 @@ import { MedicationStatementClaim } from '../models/interoperable-claims/medicat
7
8
  import { ClaimConsent } from '../models/consent-rule.js';
8
9
  import { allergyIntoleranceFlatToFhirR4, appointmentResponseFlatToFhirR4, appointmentFlatToFhirR4, carePlanFlatToFhirR4, clinicalImpressionFlatToFhirR4, compositionFlatToFhirR4, conditionFlatToFhirR4, consentFlatToFhirR4, convertFhirResourceToClaims, coverageFlatToFhirR4, deviceFlatToFhirR4, deviceUseStatementFlatToFhirR4, documentReferenceFlatToFhirR4, diagnosticReportFlatToFhirR4, encounterFlatToFhirR4, flagFlatToFhirR4, flatClaimsToFhirResource, immunizationFlatToFhirR4, locationFlatToFhirR4, medicationStatementFlatToFhirR4, observationFromFlatToFhirR4, organizationFlatToFhirR4, procedureFlatToFhirR4, practitionerRoleFlatToFhirR4, relatedPersonFlatToFhirR4, } from './clinical-resource-converters.js';
9
10
  /** Version-independent FHIR SearchParameter claim context. */
10
- const FHIR_API_CLAIMS_CONTEXT = 'org.hl7.fhir.api';
11
+ const FHIR_API_CLAIMS_CONTEXT = Format.FHIR_API;
12
+ const READABLE_FHIR_CLAIMS_CONTEXTS = [
13
+ Format.FHIR_API,
14
+ // Deprecated response compatibility. New flat-claim writers use FHIR_API
15
+ // regardless of the selected native FHIR representation version.
16
+ Format.FHIR_R4,
17
+ ];
11
18
  function asTrimmedString(value) {
12
19
  if (value === undefined || value === null)
13
20
  return '';
@@ -23,9 +30,7 @@ export function getSimpleClaimAttributeName(key) {
23
30
  const value = asTrimmedString(key);
24
31
  if (!value)
25
32
  return '';
26
- const knownPrefixes = [
27
- `${FHIR_API_CLAIMS_CONTEXT}.`,
28
- ];
33
+ const knownPrefixes = READABLE_FHIR_CLAIMS_CONTEXTS.map((context) => `${context}.`);
29
34
  for (const prefix of knownPrefixes) {
30
35
  if (value.startsWith(prefix)) {
31
36
  return value.slice(prefix.length);
@@ -40,15 +45,19 @@ export function extractFlatClaimValue(record, key) {
40
45
  const direct = record[normalizedKey];
41
46
  if (typeof direct === 'string' && direct.trim())
42
47
  return direct.trim();
43
- const contextualizedApi = record[`${FHIR_API_CLAIMS_CONTEXT}.${normalizedKey}`];
44
- if (typeof contextualizedApi === 'string' && contextualizedApi.trim())
45
- return contextualizedApi.trim();
48
+ for (const context of READABLE_FHIR_CLAIMS_CONTEXTS) {
49
+ const contextualized = record[`${context}.${normalizedKey}`];
50
+ if (typeof contextualized === 'string' && contextualized.trim())
51
+ return contextualized.trim();
52
+ }
46
53
  const nested = record?.meta?.claims?.[normalizedKey];
47
54
  if (typeof nested === 'string' && nested.trim())
48
55
  return nested.trim();
49
- const nestedApi = record?.meta?.claims?.[`${FHIR_API_CLAIMS_CONTEXT}.${normalizedKey}`];
50
- if (typeof nestedApi === 'string' && nestedApi.trim())
51
- return nestedApi.trim();
56
+ for (const context of READABLE_FHIR_CLAIMS_CONTEXTS) {
57
+ const nestedContextualized = record?.meta?.claims?.[`${context}.${normalizedKey}`];
58
+ if (typeof nestedContextualized === 'string' && nestedContextualized.trim())
59
+ return nestedContextualized.trim();
60
+ }
52
61
  return '';
53
62
  }
54
63
  function claimsToFlatStrings(claims) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdc-common-utils-ts",
3
- "version": "2.7.0",
3
+ "version": "2.7.1",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },