gdc-common-utils-ts 2.0.18 → 2.2.2

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 (185) hide show
  1. package/README.md +18 -1
  2. package/dist/claims/claims-helpers-allergy-intolerance.d.ts +8 -0
  3. package/dist/claims/claims-helpers-allergy-intolerance.js +30 -12
  4. package/dist/claims/claims-helpers-condition.d.ts +8 -0
  5. package/dist/claims/claims-helpers-condition.js +30 -12
  6. package/dist/claims/claims-helpers-consent.d.ts +4 -0
  7. package/dist/claims/claims-helpers-consent.js +15 -1
  8. package/dist/claims/claims-helpers-diagnostic-report.d.ts +4 -0
  9. package/dist/claims/claims-helpers-diagnostic-report.js +17 -2
  10. package/dist/claims/claims-helpers-medication-statement.d.ts +10 -2
  11. package/dist/claims/claims-helpers-medication-statement.js +32 -14
  12. package/dist/constants/didcomm.d.ts +22 -0
  13. package/dist/constants/didcomm.js +22 -0
  14. package/dist/constants/fhir-resource-types.d.ts +2 -0
  15. package/dist/constants/fhir-resource-types.js +1 -0
  16. package/dist/constants/index.d.ts +1 -0
  17. package/dist/constants/index.js +1 -0
  18. package/dist/constants/lifecycle.d.ts +2 -0
  19. package/dist/constants/lifecycle.js +2 -0
  20. package/dist/constants/verifiable-credentials.d.ts +9 -0
  21. package/dist/constants/verifiable-credentials.js +9 -0
  22. package/dist/examples/bundle-didcomm-payload.d.ts +11 -0
  23. package/dist/examples/bundle-didcomm-payload.js +15 -0
  24. package/dist/examples/communication-attached-bundle-session.js +28 -27
  25. package/dist/examples/communication-didcomm-payload.d.ts +39 -0
  26. package/dist/examples/communication-didcomm-payload.js +44 -0
  27. package/dist/examples/consent-access.js +2 -1
  28. package/dist/examples/employee.d.ts +21 -0
  29. package/dist/examples/employee.js +21 -0
  30. package/dist/examples/index.d.ts +4 -0
  31. package/dist/examples/index.js +4 -0
  32. package/dist/examples/individual-controller.d.ts +27 -0
  33. package/dist/examples/individual-controller.js +28 -1
  34. package/dist/examples/inter-tenant-access-contract.js +3 -2
  35. package/dist/examples/ips-bundle.js +17 -16
  36. package/dist/examples/lifecycle.js +13 -11
  37. package/dist/examples/profile-manager-mem.d.ts +45 -0
  38. package/dist/examples/profile-manager-mem.js +30 -0
  39. package/dist/examples/related-person.d.ts +14 -0
  40. package/dist/examples/related-person.js +18 -4
  41. package/dist/examples/shared.d.ts +13 -3
  42. package/dist/examples/shared.js +14 -4
  43. package/dist/examples/vital-signs.js +1 -1
  44. package/dist/examples/wallet-mem.d.ts +38 -0
  45. package/dist/examples/wallet-mem.js +42 -0
  46. package/dist/index.d.ts +1 -0
  47. package/dist/index.js +1 -0
  48. package/dist/interfaces/IProfileOutboxRepository.d.ts +36 -0
  49. package/dist/interfaces/IProfileOutboxRepository.js +2 -0
  50. package/dist/interfaces/IWallet.d.ts +74 -0
  51. package/dist/interfaces/IWallet.js +2 -0
  52. package/dist/interfaces/IWalletQueue.d.ts +30 -0
  53. package/dist/interfaces/IWalletQueue.js +2 -0
  54. package/dist/interfaces/index.d.ts +8 -0
  55. package/dist/interfaces/index.js +8 -0
  56. package/dist/models/authority-resolution.d.ts +56 -0
  57. package/dist/models/authority-resolution.js +2 -0
  58. package/dist/models/bundle-editor-types.d.ts +89 -0
  59. package/dist/models/bundle-editor-types.js +45 -0
  60. package/dist/models/bundle.d.ts +5 -0
  61. package/dist/models/communication-attached-bundle-session.d.ts +195 -0
  62. package/dist/models/communication-attached-bundle-session.js +36 -0
  63. package/dist/models/confidential-storage.d.ts +2 -1
  64. package/dist/models/consent-rule.d.ts +11 -1
  65. package/dist/models/consent-rule.js +9 -1
  66. package/dist/models/index.d.ts +5 -0
  67. package/dist/models/index.js +5 -0
  68. package/dist/models/individual-onboarding.d.ts +18 -0
  69. package/dist/models/interoperable-claims/allergy-intolerance-claims.d.ts +12 -1
  70. package/dist/models/interoperable-claims/allergy-intolerance-claims.js +12 -1
  71. package/dist/models/interoperable-claims/condition-claims.d.ts +12 -1
  72. package/dist/models/interoperable-claims/condition-claims.js +12 -1
  73. package/dist/models/interoperable-claims/diagnostic-report-claims.d.ts +14 -4
  74. package/dist/models/interoperable-claims/diagnostic-report-claims.js +13 -3
  75. package/dist/models/interoperable-claims/document-reference-claims.d.ts +1 -0
  76. package/dist/models/interoperable-claims/document-reference-claims.js +3 -0
  77. package/dist/models/interoperable-claims/medication-statement-claims.d.ts +17 -0
  78. package/dist/models/interoperable-claims/medication-statement-claims.js +17 -0
  79. package/dist/models/profile-manager.d.ts +85 -0
  80. package/dist/models/profile-manager.js +2 -0
  81. package/dist/models/wallet.d.ts +59 -0
  82. package/dist/models/wallet.js +22 -0
  83. package/dist/utils/allergy-intolerance-entry-editor.d.ts +51 -0
  84. package/dist/utils/allergy-intolerance-entry-editor.js +55 -0
  85. package/dist/utils/authority-resolution.d.ts +37 -0
  86. package/dist/utils/authority-resolution.js +112 -0
  87. package/dist/utils/backend-message-manager-mem.d.ts +78 -0
  88. package/dist/utils/backend-message-manager-mem.js +238 -0
  89. package/dist/utils/bundle-didcomm-payload.d.ts +29 -0
  90. package/dist/utils/bundle-didcomm-payload.js +49 -0
  91. package/dist/utils/bundle-document-builder.d.ts +1 -0
  92. package/dist/utils/bundle-document-builder.js +134 -14
  93. package/dist/utils/bundle-editor-core.d.ts +181 -0
  94. package/dist/utils/bundle-editor-core.js +467 -0
  95. package/dist/utils/bundle-editor-helpers.d.ts +53 -0
  96. package/dist/utils/bundle-editor-helpers.js +146 -0
  97. package/dist/utils/bundle-editor-registry.d.ts +6 -0
  98. package/dist/utils/bundle-editor-registry.js +14 -0
  99. package/dist/utils/bundle-editor.d.ts +21 -722
  100. package/dist/utils/bundle-editor.js +21 -1601
  101. package/dist/utils/bundle-entry-editor.d.ts +96 -0
  102. package/dist/utils/bundle-entry-editor.js +305 -0
  103. package/dist/utils/bundle-query.d.ts +1 -0
  104. package/dist/utils/bundle-query.js +12 -3
  105. package/dist/utils/bundle-reader.d.ts +48 -0
  106. package/dist/utils/bundle-reader.js +175 -1
  107. package/dist/utils/care-plan-entry-editor.d.ts +43 -0
  108. package/dist/utils/care-plan-entry-editor.js +47 -0
  109. package/dist/utils/client-assertion.d.ts +38 -0
  110. package/dist/utils/client-assertion.js +113 -0
  111. package/dist/utils/clinical-impression-entry-editor.d.ts +43 -0
  112. package/dist/utils/clinical-impression-entry-editor.js +47 -0
  113. package/dist/utils/clinical-resource-entry-editor.d.ts +123 -0
  114. package/dist/utils/clinical-resource-entry-editor.js +296 -0
  115. package/dist/utils/communication-attached-bundle-session-helpers.d.ts +54 -0
  116. package/dist/utils/communication-attached-bundle-session-helpers.js +519 -0
  117. package/dist/utils/communication-attached-bundle-session.d.ts +87 -304
  118. package/dist/utils/communication-attached-bundle-session.js +175 -841
  119. package/dist/utils/communication-consent-access-editor.d.ts +85 -0
  120. package/dist/utils/communication-consent-access-editor.js +244 -0
  121. package/dist/utils/communication-didcomm-payload.d.ts +38 -0
  122. package/dist/utils/communication-didcomm-payload.js +85 -0
  123. package/dist/utils/communication-document-reference.d.ts +23 -0
  124. package/dist/utils/communication-document-reference.js +89 -0
  125. package/dist/utils/communication-editor.d.ts +53 -0
  126. package/dist/utils/communication-editor.js +97 -0
  127. package/dist/utils/condition-entry-editor.d.ts +30 -0
  128. package/dist/utils/condition-entry-editor.js +34 -0
  129. package/dist/utils/consent-claim-helpers.d.ts +4 -0
  130. package/dist/utils/consent-claim-helpers.js +15 -1
  131. package/dist/utils/coverage-entry-editor.d.ts +51 -0
  132. package/dist/utils/coverage-entry-editor.js +55 -0
  133. package/dist/utils/device-entry-editor.d.ts +59 -0
  134. package/dist/utils/device-entry-editor.js +63 -0
  135. package/dist/utils/device-use-statement-entry-editor.d.ts +43 -0
  136. package/dist/utils/device-use-statement-entry-editor.js +47 -0
  137. package/dist/utils/diagnostic-report-entry-editor.d.ts +74 -0
  138. package/dist/utils/diagnostic-report-entry-editor.js +136 -0
  139. package/dist/utils/did.d.ts +8 -0
  140. package/dist/utils/did.js +22 -0
  141. package/dist/utils/document-reference-entry-editor.d.ts +62 -0
  142. package/dist/utils/document-reference-entry-editor.js +66 -0
  143. package/dist/utils/employee-entry-editor.d.ts +36 -0
  144. package/dist/utils/employee-entry-editor.js +88 -0
  145. package/dist/utils/employee.d.ts +1 -0
  146. package/dist/utils/employee.js +2 -1
  147. package/dist/utils/encounter-entry-editor.d.ts +51 -0
  148. package/dist/utils/encounter-entry-editor.js +55 -0
  149. package/dist/utils/flag-entry-editor.d.ts +47 -0
  150. package/dist/utils/flag-entry-editor.js +51 -0
  151. package/dist/utils/immunization-entry-editor.d.ts +87 -0
  152. package/dist/utils/immunization-entry-editor.js +169 -0
  153. package/dist/utils/index.d.ts +15 -0
  154. package/dist/utils/index.js +15 -0
  155. package/dist/utils/individual-onboarding-acceptance-credential.d.ts +35 -0
  156. package/dist/utils/individual-onboarding-acceptance-credential.js +55 -0
  157. package/dist/utils/individual-smart.d.ts +59 -0
  158. package/dist/utils/individual-smart.js +135 -0
  159. package/dist/utils/medication-statement-entry-editor.d.ts +90 -0
  160. package/dist/utils/medication-statement-entry-editor.js +94 -0
  161. package/dist/utils/observation-component-entry-editor.d.ts +57 -0
  162. package/dist/utils/observation-component-entry-editor.js +105 -0
  163. package/dist/utils/observation-entry-editor.d.ts +29 -0
  164. package/dist/utils/observation-entry-editor.js +68 -0
  165. package/dist/utils/procedure-entry-editor.d.ts +71 -0
  166. package/dist/utils/procedure-entry-editor.js +75 -0
  167. package/dist/utils/professional-smart.d.ts +87 -0
  168. package/dist/utils/professional-smart.js +118 -4
  169. package/dist/utils/profile-manager-mem.d.ts +69 -0
  170. package/dist/utils/profile-manager-mem.js +79 -0
  171. package/dist/utils/profile-outbox-memory-repository.d.ts +34 -0
  172. package/dist/utils/profile-outbox-memory-repository.js +57 -0
  173. package/dist/utils/same-as.d.ts +40 -0
  174. package/dist/utils/same-as.js +72 -0
  175. package/dist/utils/unified-health-id.d.ts +51 -0
  176. package/dist/utils/unified-health-id.js +92 -0
  177. package/dist/utils/vital-sign-day-batch.d.ts +25 -0
  178. package/dist/utils/vital-sign-day-batch.js +115 -0
  179. package/dist/utils/vital-sign-entry-editor.d.ts +61 -0
  180. package/dist/utils/vital-sign-entry-editor.js +152 -0
  181. package/dist/utils/wallet-mem.d.ts +93 -0
  182. package/dist/utils/wallet-mem.js +277 -0
  183. package/dist/utils/wallet-memory-queue.d.ts +32 -0
  184. package/dist/utils/wallet-memory-queue.js +82 -0
  185. package/package.json +2 -1
@@ -0,0 +1,75 @@
1
+ import { ClinicalResourceEntryEditor } from './clinical-resource-entry-editor.js';
2
+ import { ProcedureClaim } from '../models/interoperable-claims/procedure-claims.js';
3
+ import { BundleEditableResourceTypes } from '../models/bundle-editor-types.js';
4
+ import { registerBundleEntryEditor } from './bundle-editor-registry.js';
5
+ /**
6
+ * Typed editor for one staged Procedure resource entry.
7
+ *
8
+ * Use this when a caller needs to stage one procedure row with claims-first
9
+ * accessors in a bundle authoring flow.
10
+ */
11
+ export class ProcedureEntryEditor extends ClinicalResourceEntryEditor {
12
+ /** Writes the canonical procedure identifier. */
13
+ setIdentifier(identifier) { return this.setIdentifierValue(ProcedureClaim.Identifier, identifier); }
14
+ /** Reads the canonical procedure identifier. */
15
+ getIdentifier() { return this.getIdentifierValue(ProcedureClaim.Identifier); }
16
+ /** Ensures the procedure entry has one canonical `urn:uuid:*` identifier. */
17
+ ensureIdentifier() { return this.ensureIdentifierValue(ProcedureClaim.Identifier); }
18
+ /** Writes the subject/patient reference. */
19
+ setSubject(subject) { return this.setSubjectClaims(ProcedureClaim.Subject, ProcedureClaim.Patient, subject); }
20
+ /** Reads the subject/patient reference. */
21
+ getSubject() { return this.getSubjectClaims(ProcedureClaim.Subject, ProcedureClaim.Patient); }
22
+ /** Writes the procedure status. */
23
+ setStatus(status) { return this.setScalarClaim(ProcedureClaim.Status, status); }
24
+ /** Reads the procedure status. */
25
+ getStatus() { return this.getScalarClaim(ProcedureClaim.Status); }
26
+ /** Writes the procedure date. */
27
+ setDate(date) { return this.setScalarClaim(ProcedureClaim.Date, date); }
28
+ /** Reads the procedure date. */
29
+ getDate() { return this.getScalarClaim(ProcedureClaim.Date); }
30
+ /** Writes the procedure code. */
31
+ setCode(code) { return this.setScalarClaim(ProcedureClaim.Code, code); }
32
+ /** Reads the procedure code. */
33
+ getCode() { return this.getScalarClaim(ProcedureClaim.Code); }
34
+ /** Writes the local code text. */
35
+ setCodeTextLocal(text) { return this.setScalarClaim(ProcedureClaim.CodeText, text); }
36
+ /** Reads the local code text. */
37
+ getCodeTextLocal() { return this.getScalarClaim(ProcedureClaim.CodeText); }
38
+ /** Writes the code display text. */
39
+ setCodeDisplay(display) { return this.setScalarClaim(ProcedureClaim.CodeDisplay, display); }
40
+ /** Reads the code display text. */
41
+ getCodeDisplay() { return this.getScalarClaim(ProcedureClaim.CodeDisplay); }
42
+ /** Writes the encounter reference. */
43
+ setEncounter(reference) { return this.setScalarClaim(ProcedureClaim.Encounter, reference); }
44
+ /** Reads the encounter reference. */
45
+ getEncounter() { return this.getScalarClaim(ProcedureClaim.Encounter); }
46
+ /** Writes the location reference. */
47
+ setLocation(reference) { return this.setScalarClaim(ProcedureClaim.Location, reference); }
48
+ /** Reads the location reference. */
49
+ getLocation() { return this.getScalarClaim(ProcedureClaim.Location); }
50
+ /** Writes the reason code. */
51
+ setReasonCode(code) { return this.setScalarClaim(ProcedureClaim.ReasonCode, code); }
52
+ /** Reads the reason code. */
53
+ getReasonCode() { return this.getScalarClaim(ProcedureClaim.ReasonCode); }
54
+ /** Writes the note text. */
55
+ setNote(note) { return this.setScalarClaim(ProcedureClaim.Note, note); }
56
+ /** Reads the note text. */
57
+ getNote() { return this.getScalarClaim(ProcedureClaim.Note); }
58
+ /** Alias for `setNote(...)` used by callers that expect clinical wording. */
59
+ setClinicalNote(note) { return this.setNote(note); }
60
+ /** Alias for `getNote()` used by callers that expect clinical wording. */
61
+ getClinicalNote() { return this.getNote(); }
62
+ /** Writes the performer list. */
63
+ setPerformerList(references) { return this.setCsvClaimList(ProcedureClaim.Performer, references); }
64
+ /** Reads the performer list. */
65
+ getPerformerList() { return this.getCsvClaimList(ProcedureClaim.Performer); }
66
+ /** Writes the based-on list. */
67
+ setBasedOnList(references) { return this.setCsvClaimList(ProcedureClaim.BasedOn, references); }
68
+ /** Reads the based-on list. */
69
+ getBasedOnList() { return this.getCsvClaimList(ProcedureClaim.BasedOn); }
70
+ /** Writes the reason-reference list. */
71
+ setReasonReferenceList(references) { return this.setCsvClaimList(ProcedureClaim.ReasonReference, references); }
72
+ /** Reads the reason-reference list. */
73
+ getReasonReferenceList() { return this.getCsvClaimList(ProcedureClaim.ReasonReference); }
74
+ }
75
+ registerBundleEntryEditor(BundleEditableResourceTypes.procedure, ProcedureEntryEditor);
@@ -1,6 +1,10 @@
1
1
  export type ProfessionalEmployeeCredentialInput = Readonly<{
2
2
  actorDid: string;
3
3
  role: string;
4
+ email?: string;
5
+ sameAs?: string | readonly string[];
6
+ telephone?: string;
7
+ credentialMaterial?: string;
4
8
  additionalCredentialSubject?: Record<string, unknown>;
5
9
  additionalCredential?: Record<string, unknown>;
6
10
  }>;
@@ -8,14 +12,97 @@ export type ProfessionalSmartVpPayloadInput = Readonly<{
8
12
  clientId: string;
9
13
  actorDid: string;
10
14
  role: string;
15
+ email?: string;
16
+ sameAs?: string | readonly string[];
17
+ telephone?: string;
18
+ credentialMaterial?: string;
11
19
  verifiableCredential?: string | Record<string, unknown> | ReadonlyArray<string | Record<string, unknown>>;
12
20
  additionalVp?: Record<string, unknown>;
13
21
  additionalPayload?: Record<string, unknown>;
14
22
  }>;
23
+ /**
24
+ * Returns the normalized public continuity aliases for one professional
25
+ * identity VC.
26
+ *
27
+ * The canonical source is:
28
+ * - explicit `sameAs` values when present
29
+ * - otherwise the public employee email
30
+ *
31
+ * When both are present they are merged and deduplicated after normalization.
32
+ *
33
+ * @param input Professional identity source values.
34
+ */
35
+ export declare function getProfessionalIdentitySameAs(input: Readonly<Pick<ProfessionalEmployeeCredentialInput, 'sameAs' | 'email'>>): string[];
36
+ /**
37
+ * Returns the normalized public telephone continuity value for one
38
+ * professional identity VC.
39
+ *
40
+ * Telephone continuity is kept separate from `sameAs` so callers can reuse
41
+ * ICA-compatible hashing without overloading the public alias slot.
42
+ *
43
+ * @param input Professional identity source values.
44
+ */
45
+ export declare function getProfessionalIdentityTelephone(input: Readonly<Pick<ProfessionalEmployeeCredentialInput, 'telephone'>>): string | undefined;
46
+ /**
47
+ * Builds the canonical professional identity VC payload reused by SMART VP
48
+ * token helpers and higher SDK facades.
49
+ *
50
+ * Current projection rules:
51
+ * - `credentialSubject.sameAs` stores one CSV string to preserve compatibility
52
+ * with the current flat/shared claim style
53
+ * - `credentialSubject.telephone` stores the hashed public phone continuity
54
+ * value when present
55
+ * - `credentialSubject.hasCredential.material` carries the public signing/bind
56
+ * material when present
57
+ *
58
+ * @param input Professional identity source values.
59
+ */
60
+ export declare function getProfessionalIdentityVC(input: ProfessionalEmployeeCredentialInput): Record<string, unknown>;
61
+ /**
62
+ * Backwards-compatible alias kept for existing SMART demo callers.
63
+ *
64
+ * @param input Professional identity source values.
65
+ */
15
66
  export declare function buildProfessionalEmployeeCredential(input: ProfessionalEmployeeCredentialInput): Record<string, unknown>;
67
+ /**
68
+ * Builds one SMART/OpenID4VP payload for the current professional identity
69
+ * contract.
70
+ *
71
+ * When no credential is supplied explicitly, the payload embeds the canonical
72
+ * professional identity VC built from the current actor identity input.
73
+ *
74
+ * @param input SMART/OpenID4VP actor payload input.
75
+ */
16
76
  export declare function buildProfessionalSmartVpPayload(input: ProfessionalSmartVpPayloadInput): Record<string, unknown>;
77
+ /**
78
+ * Alias that makes the VC/VP naming more explicit for consumers that want one
79
+ * identity-oriented surface rather than the historical SMART-specific helper
80
+ * names.
81
+ *
82
+ * @param input SMART/OpenID4VP actor payload input.
83
+ */
84
+ export declare function buildProfessionalIdentityVpPayload(input: ProfessionalSmartVpPayloadInput): Record<string, unknown>;
85
+ /**
86
+ * Builds one unsigned compact VP JWT for the canonical professional identity
87
+ * payload.
88
+ *
89
+ * @param input SMART/OpenID4VP actor payload input.
90
+ * @param options Optional unsigned JWT timing controls.
91
+ */
17
92
  export declare function buildUnsignedProfessionalSmartVpJwt(input: ProfessionalSmartVpPayloadInput, options?: Readonly<{
18
93
  nowSeconds?: number;
19
94
  ttlSeconds?: number;
20
95
  nonce?: string;
21
96
  }>): string;
97
+ /**
98
+ * Alias that makes the unsigned identity VP helper explicit for shared SDK
99
+ * facades.
100
+ *
101
+ * @param input SMART/OpenID4VP actor payload input.
102
+ * @param options Optional unsigned JWT timing controls.
103
+ */
104
+ export declare function buildUnsignedProfessionalIdentityVpJwt(input: ProfessionalSmartVpPayloadInput, options?: Readonly<{
105
+ nowSeconds?: number;
106
+ ttlSeconds?: number;
107
+ nonce?: string;
108
+ }>): string;
@@ -1,27 +1,114 @@
1
+ import { ClaimsPersonSchemaorg } from '../constants/schemaorg.js';
1
2
  import { ProfessionalCredentialTypes, W3cCredentialTypes, } from '../constants/verifiable-credentials.js';
3
+ import { normalizeSameAsHashCsv, normalizeSameAsHashList, normalizeTelephoneHash } from './same-as.js';
2
4
  import { buildUnsignedVpJwt } from './jwt.js';
3
- export function buildProfessionalEmployeeCredential(input) {
5
+ /**
6
+ * Returns the normalized public continuity aliases for one professional
7
+ * identity VC.
8
+ *
9
+ * The canonical source is:
10
+ * - explicit `sameAs` values when present
11
+ * - otherwise the public employee email
12
+ *
13
+ * When both are present they are merged and deduplicated after normalization.
14
+ *
15
+ * @param input Professional identity source values.
16
+ */
17
+ export function getProfessionalIdentitySameAs(input) {
18
+ const sameAsCandidates = [];
19
+ if (input.sameAs) {
20
+ sameAsCandidates.push(...normalizeSameAsHashList(input.sameAs));
21
+ }
22
+ if (input.email) {
23
+ sameAsCandidates.push(...normalizeSameAsHashList(input.email));
24
+ }
25
+ return [...new Set(sameAsCandidates)];
26
+ }
27
+ /**
28
+ * Returns the normalized public telephone continuity value for one
29
+ * professional identity VC.
30
+ *
31
+ * Telephone continuity is kept separate from `sameAs` so callers can reuse
32
+ * ICA-compatible hashing without overloading the public alias slot.
33
+ *
34
+ * @param input Professional identity source values.
35
+ */
36
+ export function getProfessionalIdentityTelephone(input) {
37
+ const normalized = normalizeTelephoneHash(String(input.telephone || ''));
38
+ return normalized || undefined;
39
+ }
40
+ /**
41
+ * Builds the canonical professional identity VC payload reused by SMART VP
42
+ * token helpers and higher SDK facades.
43
+ *
44
+ * Current projection rules:
45
+ * - `credentialSubject.sameAs` stores one CSV string to preserve compatibility
46
+ * with the current flat/shared claim style
47
+ * - `credentialSubject.telephone` stores the hashed public phone continuity
48
+ * value when present
49
+ * - `credentialSubject.hasCredential.material` carries the public signing/bind
50
+ * material when present
51
+ *
52
+ * @param input Professional identity source values.
53
+ */
54
+ export function getProfessionalIdentityVC(input) {
55
+ const normalizedSameAs = getProfessionalIdentitySameAs(input);
56
+ const normalizedTelephone = getProfessionalIdentityTelephone(input);
57
+ const normalizedCredentialMaterial = String(input.credentialMaterial || '').trim();
58
+ const canonicalCredentialSubject = {
59
+ id: String(input.actorDid || '').trim(),
60
+ hasOccupation: String(input.role || '').trim(),
61
+ ...(normalizedSameAs.length
62
+ ? { sameAs: normalizeSameAsHashCsv(normalizedSameAs) }
63
+ : {}),
64
+ ...(normalizedTelephone
65
+ ? { [ClaimsPersonSchemaorg.telephone]: normalizedTelephone }
66
+ : {}),
67
+ ...(normalizedCredentialMaterial
68
+ ? { [ClaimsPersonSchemaorg.hasCredentialMaterial]: normalizedCredentialMaterial }
69
+ : {}),
70
+ };
4
71
  return {
5
72
  type: [
6
73
  W3cCredentialTypes.VerifiableCredential,
7
74
  ProfessionalCredentialTypes.EmployeeCredential,
8
75
  ],
9
76
  credentialSubject: {
10
- id: String(input.actorDid || '').trim(),
11
- hasOccupation: String(input.role || '').trim(),
77
+ ...canonicalCredentialSubject,
12
78
  ...(input.additionalCredentialSubject || {}),
13
79
  },
14
80
  ...(input.additionalCredential || {}),
15
81
  };
16
82
  }
83
+ /**
84
+ * Backwards-compatible alias kept for existing SMART demo callers.
85
+ *
86
+ * @param input Professional identity source values.
87
+ */
88
+ export function buildProfessionalEmployeeCredential(input) {
89
+ return getProfessionalIdentityVC(input);
90
+ }
91
+ /**
92
+ * Builds one SMART/OpenID4VP payload for the current professional identity
93
+ * contract.
94
+ *
95
+ * When no credential is supplied explicitly, the payload embeds the canonical
96
+ * professional identity VC built from the current actor identity input.
97
+ *
98
+ * @param input SMART/OpenID4VP actor payload input.
99
+ */
17
100
  export function buildProfessionalSmartVpPayload(input) {
18
101
  const credentials = Array.isArray(input.verifiableCredential)
19
102
  ? [...input.verifiableCredential]
20
103
  : input.verifiableCredential
21
104
  ? [input.verifiableCredential]
22
- : [buildProfessionalEmployeeCredential({
105
+ : [getProfessionalIdentityVC({
23
106
  actorDid: input.actorDid,
24
107
  role: input.role,
108
+ email: input.email,
109
+ sameAs: input.sameAs,
110
+ telephone: input.telephone,
111
+ credentialMaterial: input.credentialMaterial,
25
112
  })];
26
113
  return {
27
114
  ...(input.additionalPayload || {}),
@@ -32,6 +119,33 @@ export function buildProfessionalSmartVpPayload(input) {
32
119
  },
33
120
  };
34
121
  }
122
+ /**
123
+ * Alias that makes the VC/VP naming more explicit for consumers that want one
124
+ * identity-oriented surface rather than the historical SMART-specific helper
125
+ * names.
126
+ *
127
+ * @param input SMART/OpenID4VP actor payload input.
128
+ */
129
+ export function buildProfessionalIdentityVpPayload(input) {
130
+ return buildProfessionalSmartVpPayload(input);
131
+ }
132
+ /**
133
+ * Builds one unsigned compact VP JWT for the canonical professional identity
134
+ * payload.
135
+ *
136
+ * @param input SMART/OpenID4VP actor payload input.
137
+ * @param options Optional unsigned JWT timing controls.
138
+ */
35
139
  export function buildUnsignedProfessionalSmartVpJwt(input, options = {}) {
36
140
  return buildUnsignedVpJwt(buildProfessionalSmartVpPayload(input), options);
37
141
  }
142
+ /**
143
+ * Alias that makes the unsigned identity VP helper explicit for shared SDK
144
+ * facades.
145
+ *
146
+ * @param input SMART/OpenID4VP actor payload input.
147
+ * @param options Optional unsigned JWT timing controls.
148
+ */
149
+ export function buildUnsignedProfessionalIdentityVpJwt(input, options = {}) {
150
+ return buildUnsignedProfessionalSmartVpJwt(input, options);
151
+ }
@@ -0,0 +1,69 @@
1
+ import type { IWallet } from '../interfaces/IWallet';
2
+ import type { IProfileOutboxRepository } from '../interfaces/IProfileOutboxRepository';
3
+ import type { BackendMessageResponseRecord, BackendMessageTransport, ProfileOutboxMessageRecord, ProfileManagerMemProfile, QueueProfileMessageInput } from '../models/profile-manager';
4
+ import type { WalletQueuedMessage } from '../models/wallet';
5
+ import { BackendMessageManagerMem } from './backend-message-manager-mem';
6
+ export type ProfileManagerMemOptions = Readonly<{
7
+ profile: ProfileManagerMemProfile;
8
+ wallet: IWallet;
9
+ transport: BackendMessageTransport;
10
+ outboxRepository?: IProfileOutboxRepository;
11
+ }>;
12
+ /**
13
+ * Minimal memory-backed profile manager for low-level tests.
14
+ *
15
+ * Responsibility:
16
+ * - own one logical profile
17
+ * - ensure the profile keys exist in the wallet
18
+ * - delegate queue/submit/response operations to `BackendMessageManagerMem`
19
+ *
20
+ * Non-goal:
21
+ * - actor-specific orchestration belongs to higher SDK layers
22
+ */
23
+ export declare class ProfileManagerMem {
24
+ readonly profile: ProfileManagerMemProfile;
25
+ readonly wallet: IWallet;
26
+ readonly messageManager: BackendMessageManagerMem;
27
+ readonly outboxRepository: IProfileOutboxRepository;
28
+ constructor(options: ProfileManagerMemOptions);
29
+ /**
30
+ * Provisions the local profile keys before any queue or transport operation.
31
+ */
32
+ initialize(): Promise<void>;
33
+ /**
34
+ * Queues one outbound profile payload.
35
+ */
36
+ queueMessage(input: QueueProfileMessageInput): Promise<WalletQueuedMessage>;
37
+ /**
38
+ * Returns the current queued messages in processing order.
39
+ */
40
+ listQueuedMessages(): Promise<WalletQueuedMessage[]>;
41
+ /**
42
+ * Submits the next pending message and optionally stores the decoded response.
43
+ */
44
+ submitNextPendingMessage(recipientEncryptionJwk: Record<string, unknown>): Promise<{
45
+ message: WalletQueuedMessage;
46
+ response?: BackendMessageResponseRecord;
47
+ pending?: boolean;
48
+ }>;
49
+ /**
50
+ * Reads the latest decoded response for one thread id.
51
+ */
52
+ getResponseByThreadId(thid: string): BackendMessageResponseRecord | undefined;
53
+ /**
54
+ * Reads one decoded response by thread id from memory or repository storage.
55
+ */
56
+ readResponseByThreadId(thid: string): Promise<BackendMessageResponseRecord | undefined>;
57
+ /**
58
+ * Lists historical outbox records already submitted through this profile manager.
59
+ */
60
+ listOutboxHistory(): Promise<ProfileOutboxMessageRecord[]>;
61
+ /**
62
+ * Polls one asynchronous outbox record by id.
63
+ */
64
+ pollSubmittedMessage(messageId: string): Promise<{
65
+ pending: boolean;
66
+ response?: BackendMessageResponseRecord;
67
+ record: ProfileOutboxMessageRecord;
68
+ }>;
69
+ }
@@ -0,0 +1,79 @@
1
+ // Copyright 2026 Conectate Soluciones y Aplicaciones SL under the Apache License, Version 2.0.
2
+ import { BackendMessageManagerMem } from './backend-message-manager-mem.js';
3
+ import { MemoryProfileOutboxRepository } from './profile-outbox-memory-repository.js';
4
+ /**
5
+ * Minimal memory-backed profile manager for low-level tests.
6
+ *
7
+ * Responsibility:
8
+ * - own one logical profile
9
+ * - ensure the profile keys exist in the wallet
10
+ * - delegate queue/submit/response operations to `BackendMessageManagerMem`
11
+ *
12
+ * Non-goal:
13
+ * - actor-specific orchestration belongs to higher SDK layers
14
+ */
15
+ export class ProfileManagerMem {
16
+ profile;
17
+ wallet;
18
+ messageManager;
19
+ outboxRepository;
20
+ constructor(options) {
21
+ this.profile = options.profile;
22
+ this.wallet = options.wallet;
23
+ this.outboxRepository = options.outboxRepository ?? new MemoryProfileOutboxRepository();
24
+ this.messageManager = new BackendMessageManagerMem({
25
+ wallet: options.wallet,
26
+ entityId: options.profile.profileId,
27
+ transport: options.transport,
28
+ outboxRepository: this.outboxRepository,
29
+ });
30
+ }
31
+ /**
32
+ * Provisions the local profile keys before any queue or transport operation.
33
+ */
34
+ async initialize() {
35
+ await this.wallet.provisionKeys(this.profile.profileId);
36
+ }
37
+ /**
38
+ * Queues one outbound profile payload.
39
+ */
40
+ async queueMessage(input) {
41
+ return this.messageManager.queueMessage(input);
42
+ }
43
+ /**
44
+ * Returns the current queued messages in processing order.
45
+ */
46
+ async listQueuedMessages() {
47
+ return this.messageManager.listQueuedMessages();
48
+ }
49
+ /**
50
+ * Submits the next pending message and optionally stores the decoded response.
51
+ */
52
+ async submitNextPendingMessage(recipientEncryptionJwk) {
53
+ return this.messageManager.submitNextPendingMessage(recipientEncryptionJwk);
54
+ }
55
+ /**
56
+ * Reads the latest decoded response for one thread id.
57
+ */
58
+ getResponseByThreadId(thid) {
59
+ return this.messageManager.getResponseByThreadId(thid);
60
+ }
61
+ /**
62
+ * Reads one decoded response by thread id from memory or repository storage.
63
+ */
64
+ async readResponseByThreadId(thid) {
65
+ return this.messageManager.readResponseByThreadId(thid);
66
+ }
67
+ /**
68
+ * Lists historical outbox records already submitted through this profile manager.
69
+ */
70
+ async listOutboxHistory() {
71
+ return this.messageManager.listOutboxHistory();
72
+ }
73
+ /**
74
+ * Polls one asynchronous outbox record by id.
75
+ */
76
+ async pollSubmittedMessage(messageId) {
77
+ return this.messageManager.pollSubmittedMessage(messageId);
78
+ }
79
+ }
@@ -0,0 +1,34 @@
1
+ import type { IProfileOutboxRepository } from '../interfaces/IProfileOutboxRepository';
2
+ import type { BackendMessageResponseRecord, ProfileOutboxMessageRecord } from '../models/profile-manager';
3
+ /**
4
+ * In-memory profile outbox repository used by low-level tests and as the
5
+ * default history/response store for `ProfileManagerMem`.
6
+ */
7
+ export declare class MemoryProfileOutboxRepository implements IProfileOutboxRepository {
8
+ private readonly messages;
9
+ private readonly responses;
10
+ /**
11
+ * Stores one immutable message history record.
12
+ */
13
+ putMessage(record: ProfileOutboxMessageRecord): Promise<ProfileOutboxMessageRecord>;
14
+ /**
15
+ * Reads one message history record.
16
+ */
17
+ getMessage(messageId: string): Promise<ProfileOutboxMessageRecord | undefined>;
18
+ /**
19
+ * Lists all message history records in insertion order.
20
+ */
21
+ listMessages(): Promise<ProfileOutboxMessageRecord[]>;
22
+ /**
23
+ * Stores one decoded response record grouped by thread id.
24
+ */
25
+ putResponse(record: BackendMessageResponseRecord): Promise<BackendMessageResponseRecord>;
26
+ /**
27
+ * Returns the latest decoded response for the provided thread id.
28
+ */
29
+ getLatestResponseByThreadId(thid: string): Promise<BackendMessageResponseRecord | undefined>;
30
+ /**
31
+ * Lists all decoded responses across all threads.
32
+ */
33
+ listResponses(): Promise<BackendMessageResponseRecord[]>;
34
+ }
@@ -0,0 +1,57 @@
1
+ // Copyright 2026 Conectate Soluciones y Aplicaciones SL under the Apache License, Version 2.0.
2
+ function clone(value) {
3
+ return JSON.parse(JSON.stringify(value));
4
+ }
5
+ /**
6
+ * In-memory profile outbox repository used by low-level tests and as the
7
+ * default history/response store for `ProfileManagerMem`.
8
+ */
9
+ export class MemoryProfileOutboxRepository {
10
+ messages = new Map();
11
+ responses = new Map();
12
+ /**
13
+ * Stores one immutable message history record.
14
+ */
15
+ async putMessage(record) {
16
+ this.messages.set(record.id, clone(record));
17
+ return clone(record);
18
+ }
19
+ /**
20
+ * Reads one message history record.
21
+ */
22
+ async getMessage(messageId) {
23
+ const stored = this.messages.get(String(messageId || '').trim());
24
+ return stored ? clone(stored) : undefined;
25
+ }
26
+ /**
27
+ * Lists all message history records in insertion order.
28
+ */
29
+ async listMessages() {
30
+ return [...this.messages.values()].map((record) => clone(record));
31
+ }
32
+ /**
33
+ * Stores one decoded response record grouped by thread id.
34
+ */
35
+ async putResponse(record) {
36
+ const normalizedThreadId = String(record.thid || '').trim();
37
+ const current = this.responses.get(normalizedThreadId) || [];
38
+ current.push(clone(record));
39
+ this.responses.set(normalizedThreadId, current);
40
+ return clone(record);
41
+ }
42
+ /**
43
+ * Returns the latest decoded response for the provided thread id.
44
+ */
45
+ async getLatestResponseByThreadId(thid) {
46
+ const stored = this.responses.get(String(thid || '').trim());
47
+ const latest = stored?.[stored.length - 1];
48
+ return latest ? clone(latest) : undefined;
49
+ }
50
+ /**
51
+ * Lists all decoded responses across all threads.
52
+ */
53
+ async listResponses() {
54
+ return [...this.responses.values()]
55
+ .flatMap((records) => records.map((record) => clone(record)));
56
+ }
57
+ }
@@ -32,6 +32,46 @@ export declare function multibase58MultihashSha3_256(value: string): string;
32
32
  * @param value Email, phone, DID, URN, or any other public alias string.
33
33
  */
34
34
  export declare function normalizeSameAsHash(value: string): string;
35
+ /**
36
+ * Normalizes one or more `sameAs` aliases into one deduplicated array.
37
+ *
38
+ * Input forms:
39
+ * - one plain string
40
+ * - one CSV string
41
+ * - one array of plain/CSV strings
42
+ *
43
+ * Normalization rules:
44
+ * - whitespace-only entries are discarded
45
+ * - emails are hashed into ICA-compatible `urn:multibase:z...`
46
+ * - already-normalized `urn:multibase:z...` values are preserved
47
+ * - duplicate normalized entries are removed while preserving order
48
+ *
49
+ * @param value Canonical sameAs source value(s).
50
+ */
51
+ export declare function normalizeSameAsHashList(value: string | readonly string[] | undefined): string[];
52
+ /**
53
+ * Joins one or more normalized `sameAs` aliases into the current flat CSV
54
+ * storage form used by some shared VC/profile helpers.
55
+ *
56
+ * @param value Canonical sameAs source value(s).
57
+ */
58
+ export declare function normalizeSameAsHashCsv(value: string | readonly string[] | undefined): string;
59
+ /**
60
+ * Normalizes one public telephone alias into the same hashed
61
+ * `urn:multibase:z...` representation used for ICA-compatible public
62
+ * continuity identifiers, while keeping the telephone claim separate from
63
+ * `sameAs`.
64
+ *
65
+ * Rules:
66
+ * - empty input becomes `''`
67
+ * - `urn:multibase:z...` stays unchanged
68
+ * - bare `z...` becomes `urn:multibase:z...`
69
+ * - plain phone-like values are compacted through `normalizePhone(...)`
70
+ * before hashing
71
+ *
72
+ * @param value Plain or already-normalized public telephone alias.
73
+ */
74
+ export declare function normalizeTelephoneHash(value: string): string;
35
75
  /**
36
76
  * Compares two public controller aliases after ICA-compatible normalization.
37
77
  *