gdc-common-utils-ts 2.0.4 → 2.0.6

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 (32) hide show
  1. package/dist/constants/verifiable-credentials.d.ts +6 -0
  2. package/dist/constants/verifiable-credentials.js +6 -0
  3. package/dist/examples/employee.d.ts +15 -0
  4. package/dist/examples/employee.js +15 -0
  5. package/dist/examples/individual-controller.d.ts +25 -0
  6. package/dist/examples/individual-controller.js +23 -0
  7. package/dist/examples/legal-organization-verification-transaction.js +10 -0
  8. package/dist/examples/shared.d.ts +7 -0
  9. package/dist/examples/shared.js +8 -1
  10. package/dist/utils/activation-request.d.ts +3 -3
  11. package/dist/utils/activation-request.js +3 -3
  12. package/dist/utils/bundle-reader.d.ts +2 -0
  13. package/dist/utils/bundle-reader.js +14 -0
  14. package/dist/utils/clinical-bundle-summary.d.ts +20 -0
  15. package/dist/utils/clinical-bundle-summary.js +34 -0
  16. package/dist/utils/didcomm-submit-policy.d.ts +20 -3
  17. package/dist/utils/didcomm-submit-policy.js +37 -6
  18. package/dist/utils/didcomm-submit.d.ts +10 -3
  19. package/dist/utils/didcomm-submit.js +12 -5
  20. package/dist/utils/family-organization-summary.d.ts +24 -0
  21. package/dist/utils/family-organization-summary.js +59 -0
  22. package/dist/utils/index.d.ts +4 -0
  23. package/dist/utils/index.js +4 -0
  24. package/dist/utils/legal-organization-onboarding-editor.d.ts +156 -0
  25. package/dist/utils/legal-organization-onboarding-editor.js +350 -0
  26. package/dist/utils/legal-organization-verification-transaction.d.ts +40 -0
  27. package/dist/utils/legal-organization-verification-transaction.js +53 -0
  28. package/dist/utils/professional-smart.d.ts +21 -0
  29. package/dist/utils/professional-smart.js +37 -0
  30. package/dist/utils/related-person-list.d.ts +14 -0
  31. package/dist/utils/related-person-list.js +31 -0
  32. package/package.json +1 -1
@@ -0,0 +1,37 @@
1
+ import { ProfessionalCredentialTypes, W3cCredentialTypes, } from '../constants/verifiable-credentials.js';
2
+ import { buildUnsignedVpJwt } from './jwt.js';
3
+ export function buildProfessionalEmployeeCredential(input) {
4
+ return {
5
+ type: [
6
+ W3cCredentialTypes.VerifiableCredential,
7
+ ProfessionalCredentialTypes.EmployeeCredential,
8
+ ],
9
+ credentialSubject: {
10
+ id: String(input.actorDid || '').trim(),
11
+ hasOccupation: String(input.role || '').trim(),
12
+ ...(input.additionalCredentialSubject || {}),
13
+ },
14
+ ...(input.additionalCredential || {}),
15
+ };
16
+ }
17
+ export function buildProfessionalSmartVpPayload(input) {
18
+ const credentials = Array.isArray(input.verifiableCredential)
19
+ ? [...input.verifiableCredential]
20
+ : input.verifiableCredential
21
+ ? [input.verifiableCredential]
22
+ : [buildProfessionalEmployeeCredential({
23
+ actorDid: input.actorDid,
24
+ role: input.role,
25
+ })];
26
+ return {
27
+ ...(input.additionalPayload || {}),
28
+ vp: {
29
+ holder: String(input.clientId || '').trim(),
30
+ verifiableCredential: credentials,
31
+ ...(input.additionalVp || {}),
32
+ },
33
+ };
34
+ }
35
+ export function buildUnsignedProfessionalSmartVpJwt(input, options = {}) {
36
+ return buildUnsignedVpJwt(buildProfessionalSmartVpPayload(input), options);
37
+ }
@@ -9,6 +9,14 @@ export type RelatedPersonListRecord = Readonly<{
9
9
  resourceId?: string;
10
10
  claims: Record<string, unknown>;
11
11
  }>;
12
+ export type RelatedPersonListSelection = Readonly<{
13
+ index?: number;
14
+ identifier?: string;
15
+ name?: string;
16
+ telecom?: string;
17
+ patient?: string;
18
+ activeOnly?: boolean;
19
+ }>;
12
20
  /**
13
21
  * Reads subject-side relationship records from one current GW-style result
14
22
  * body into one neutral list shape for frontend screens.
@@ -18,3 +26,9 @@ export declare function readRelatedPersonListRecords(body: unknown): RelatedPers
18
26
  * Returns one related-person record by canonical business identifier.
19
27
  */
20
28
  export declare function findRelatedPersonListRecord(body: unknown, identifier: string): RelatedPersonListRecord | undefined;
29
+ /**
30
+ * Selects one related-person record from one neutralized list/body using the
31
+ * same high-level criteria that channel apps usually expose to users:
32
+ * list position, identifier, display name, contact value, or linked patient.
33
+ */
34
+ export declare function selectRelatedPersonListRecord(body: unknown, selection: RelatedPersonListSelection): RelatedPersonListRecord | undefined;
@@ -52,3 +52,34 @@ export function findRelatedPersonListRecord(body, identifier) {
52
52
  return readRelatedPersonListRecords(body)
53
53
  .find((record) => record.identifier === normalizedIdentifier);
54
54
  }
55
+ /**
56
+ * Selects one related-person record from one neutralized list/body using the
57
+ * same high-level criteria that channel apps usually expose to users:
58
+ * list position, identifier, display name, contact value, or linked patient.
59
+ */
60
+ export function selectRelatedPersonListRecord(body, selection) {
61
+ const records = readRelatedPersonListRecords(body);
62
+ const candidates = selection.activeOnly
63
+ ? records.filter((record) => record.active === 'true')
64
+ : records;
65
+ if (typeof selection.index === 'number' && Number.isInteger(selection.index)) {
66
+ return candidates[selection.index];
67
+ }
68
+ const identifier = normalizeText(selection.identifier);
69
+ if (identifier) {
70
+ return candidates.find((record) => record.identifier === identifier);
71
+ }
72
+ const name = normalizeText(selection.name)?.toLowerCase();
73
+ if (name) {
74
+ return candidates.find((record) => normalizeText(record.name)?.toLowerCase() === name);
75
+ }
76
+ const telecom = normalizeText(selection.telecom)?.toLowerCase();
77
+ if (telecom) {
78
+ return candidates.find((record) => normalizeText(record.telecom)?.toLowerCase() === telecom);
79
+ }
80
+ const patient = normalizeText(selection.patient);
81
+ if (patient) {
82
+ return candidates.find((record) => record.patient === patient);
83
+ }
84
+ return undefined;
85
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "gdc-common-utils-ts",
3
- "version": "2.0.4",
3
+ "version": "2.0.6",
4
4
  "publishConfig": {
5
5
  "access": "public"
6
6
  },