gdc-common-utils-ts 2.5.9 → 2.5.11
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/dist/constants/fhir-code-systems.d.ts +1 -0
- package/dist/constants/fhir-code-systems.js +1 -0
- package/dist/constants/schemaorg.d.ts +2 -0
- package/dist/constants/schemaorg.js +2 -0
- package/dist/constants/vital-signs.d.ts +6 -0
- package/dist/constants/vital-signs.js +1 -0
- package/dist/examples/license.d.ts +14 -0
- package/dist/examples/license.js +15 -1
- package/dist/examples/shared.d.ts +23 -0
- package/dist/examples/shared.js +23 -0
- package/dist/utils/did.d.ts +4 -1
- package/dist/utils/did.js +28 -11
- package/dist/utils/license-list-search.js +33 -4
- package/dist/utils/organization-test-network-credential.d.ts +5 -1
- package/dist/utils/organization-test-network-credential.js +2 -0
- package/package.json +3 -2
|
@@ -10,4 +10,5 @@ export declare const FhirCodeSystems: Readonly<{
|
|
|
10
10
|
readonly Ucum: "http://unitsofmeasure.org";
|
|
11
11
|
readonly CommunicationCategory: "http://terminology.hl7.org/CodeSystem/communication-category";
|
|
12
12
|
readonly ObservationCategory: "http://terminology.hl7.org/CodeSystem/observation-category";
|
|
13
|
+
readonly EventTiming: "http://hl7.org/fhir/event-timing";
|
|
13
14
|
}>;
|
|
@@ -10,4 +10,5 @@ export const FhirCodeSystems = Object.freeze({
|
|
|
10
10
|
Ucum: 'http://unitsofmeasure.org',
|
|
11
11
|
CommunicationCategory: 'http://terminology.hl7.org/CodeSystem/communication-category',
|
|
12
12
|
ObservationCategory: 'http://terminology.hl7.org/CodeSystem/observation-category',
|
|
13
|
+
EventTiming: 'http://hl7.org/fhir/event-timing',
|
|
13
14
|
});
|
|
@@ -141,6 +141,8 @@ export declare enum ClaimsIndividualProductSchemaorg {
|
|
|
141
141
|
}
|
|
142
142
|
export declare enum ClaimsOrderSchemaorg {
|
|
143
143
|
acceptedOfferIdentifier = "org.schema.Order.acceptedOffer.identifier",
|
|
144
|
+
/** Schema.org Order.confirmationNumber; used for a customer-supplied order confirmation code. */
|
|
145
|
+
confirmationNumber = "org.schema.Order.confirmationNumber",
|
|
144
146
|
partOfInvoice = "org.schema.Order.partOfInvoice",
|
|
145
147
|
paymentMethod = "org.schema.Order.paymentMethod",
|
|
146
148
|
paymentUrl = "org.schema.Order.paymentUrl",
|
|
@@ -148,6 +148,8 @@ export var ClaimsIndividualProductSchemaorg;
|
|
|
148
148
|
export var ClaimsOrderSchemaorg;
|
|
149
149
|
(function (ClaimsOrderSchemaorg) {
|
|
150
150
|
ClaimsOrderSchemaorg["acceptedOfferIdentifier"] = "org.schema.Order.acceptedOffer.identifier";
|
|
151
|
+
/** Schema.org Order.confirmationNumber; used for a customer-supplied order confirmation code. */
|
|
152
|
+
ClaimsOrderSchemaorg["confirmationNumber"] = "org.schema.Order.confirmationNumber";
|
|
151
153
|
ClaimsOrderSchemaorg["partOfInvoice"] = "org.schema.Order.partOfInvoice";
|
|
152
154
|
ClaimsOrderSchemaorg["paymentMethod"] = "org.schema.Order.paymentMethod";
|
|
153
155
|
ClaimsOrderSchemaorg["paymentUrl"] = "org.schema.Order.paymentUrl";
|
|
@@ -4,6 +4,12 @@ export type { CodingDescriptor } from './observation-category';
|
|
|
4
4
|
* Canonical LOINC descriptors for the currently supported Vital Signs.
|
|
5
5
|
*/
|
|
6
6
|
export declare const VitalSignsCodes: Readonly<{
|
|
7
|
+
readonly BodyWeight: Readonly<{
|
|
8
|
+
system: string;
|
|
9
|
+
code: string;
|
|
10
|
+
display?: string;
|
|
11
|
+
claim: string;
|
|
12
|
+
}>;
|
|
7
13
|
readonly HeartRate: Readonly<{
|
|
8
14
|
system: string;
|
|
9
15
|
code: string;
|
|
@@ -12,6 +12,7 @@ function defineCoding(system, code, display) {
|
|
|
12
12
|
* Canonical LOINC descriptors for the currently supported Vital Signs.
|
|
13
13
|
*/
|
|
14
14
|
export const VitalSignsCodes = Object.freeze({
|
|
15
|
+
BodyWeight: defineCoding(FhirCodeSystems.Loinc, '29463-7', 'Body weight'),
|
|
15
16
|
HeartRate: defineCoding(FhirCodeSystems.Loinc, '8867-4', 'Heart rate'),
|
|
16
17
|
BloodPressure: defineCoding(FhirCodeSystems.Loinc, '85354-9', 'Blood pressure panel'),
|
|
17
18
|
SystolicBloodPressure: defineCoding(FhirCodeSystems.Loinc, '8480-6', 'Systolic blood pressure'),
|
|
@@ -78,6 +78,20 @@ export declare const EXAMPLE_LICENSE_AVAILABLE_RECORD: Readonly<{
|
|
|
78
78
|
readonly "org.schema.Person.hasOccupation.identifier.value": "ISCO-08|2211";
|
|
79
79
|
};
|
|
80
80
|
}>;
|
|
81
|
+
/** Complete stored device-license fixture for manager and repository tests. */
|
|
82
|
+
export declare const EXAMPLE_DEVICE_LICENSE_AVAILABLE: Readonly<{
|
|
83
|
+
readonly id: "8a8a5e1b-0d8e-4a7c-8c39-3b8034440009";
|
|
84
|
+
readonly tenantId: "acme-id";
|
|
85
|
+
readonly orderId: "invoice-001";
|
|
86
|
+
readonly userClass: "employee";
|
|
87
|
+
readonly userCategory: "ISCO-08|2211";
|
|
88
|
+
readonly type: "mobile";
|
|
89
|
+
readonly status: "available";
|
|
90
|
+
readonly plan: "default";
|
|
91
|
+
readonly renewalCycle: "12m";
|
|
92
|
+
readonly reactivationEnabled: false;
|
|
93
|
+
readonly exp: 1893456000;
|
|
94
|
+
}>;
|
|
81
95
|
export declare const EXAMPLE_LICENSE_LIST_RESPONSE_BODY: Readonly<{
|
|
82
96
|
readonly data: readonly [{
|
|
83
97
|
readonly meta: {
|
package/dist/examples/license.js
CHANGED
|
@@ -2,7 +2,7 @@ import { DeviceAppTypes, DeviceBindingStatuses, DeviceUserClasses } from '../con
|
|
|
2
2
|
import { ClaimsOrderSchemaorg, ClaimsIndividualProductSchemaorg, ClaimsOfferSchemaorg, ClaimsPersonSchemaorg, } from '../constants/schemaorg.js';
|
|
3
3
|
import { buildLicenseIssueClaims, buildLicensePurchaseClaims, LicenseClaimContext, LicenseCategories, LicenseStatuses, } from '../utils/license.js';
|
|
4
4
|
import { createLicenseOfferOrderEditor } from '../utils/license-offer-order.js';
|
|
5
|
-
import { EXAMPLE_LICENSE_ACCEPTED_OFFER_ID, EXAMPLE_LICENSE_AMOUNT, EXAMPLE_LICENSE_CHECKOUT_URL, EXAMPLE_LICENSE_CURRENCY, EXAMPLE_EMAIL_CONTROLLER_ORG, EXAMPLE_EMPLOYEE_ACTIVATION_CODE, EXAMPLE_EMPLOYEE_DEVICE_CLIENT_ID_PRIMARY, EXAMPLE_EMPLOYEE_DEVICE_CLIENT_ID_SECONDARY, EXAMPLE_EMPLOYEE_DEVICE_INSTANCE_ID_PRIMARY, EXAMPLE_EMPLOYEE_DEVICE_INSTANCE_ID_SECONDARY, EXAMPLE_EMPLOYEE_DEVICE_MODEL_PRIMARY, EXAMPLE_HEALTHCARE_ACTOR_ROLE_GENERALIST_MEDICAL_PRACTITIONER, EXAMPLE_LICENSE_INVOICE_ID, EXAMPLE_LICENSE_OFFER_ID, EXAMPLE_LICENSE_PLAN_DEFAULT, EXAMPLE_LICENSE_PAYMENT_METHOD_INVOICE, EXAMPLE_LICENSE_PAYMENT_URL, EXAMPLE_LICENSE_RENEWAL_CYCLE_YEARLY, EXAMPLE_LICENSE_PLAN_NAME, EXAMPLE_LICENSE_SEAT_UUID_ACTIVE, EXAMPLE_LICENSE_SEAT_UUID_AVAILABLE, EXAMPLE_LICENSE_SEAT_UUID_SECONDARY, EXAMPLE_LICENSE_SKU, EXAMPLE_LICENSE_SUBJECT_ID_ACTIVE, EXAMPLE_LICENSE_SUBJECT_ID_AVAILABLE, } from './shared.js';
|
|
5
|
+
import { EXAMPLE_LICENSE_ACCEPTED_OFFER_ID, EXAMPLE_LICENSE_AMOUNT, EXAMPLE_LICENSE_CHECKOUT_URL, EXAMPLE_LICENSE_CURRENCY, EXAMPLE_EMAIL_CONTROLLER_ORG, EXAMPLE_EMPLOYEE_ACTIVATION_CODE, EXAMPLE_EMPLOYEE_DEVICE_CLIENT_ID_PRIMARY, EXAMPLE_EMPLOYEE_DEVICE_CLIENT_ID_SECONDARY, EXAMPLE_EMPLOYEE_DEVICE_INSTANCE_ID_PRIMARY, EXAMPLE_EMPLOYEE_DEVICE_INSTANCE_ID_SECONDARY, EXAMPLE_EMPLOYEE_DEVICE_MODEL_PRIMARY, EXAMPLE_HEALTHCARE_ACTOR_ROLE_GENERALIST_MEDICAL_PRACTITIONER, EXAMPLE_LICENSE_INVOICE_ID, EXAMPLE_LICENSE_OFFER_ID, EXAMPLE_LICENSE_PLAN_DEFAULT, EXAMPLE_LICENSE_PAYMENT_METHOD_INVOICE, EXAMPLE_LICENSE_PAYMENT_URL, EXAMPLE_LICENSE_RENEWAL_CYCLE_YEARLY, EXAMPLE_LICENSE_PLAN_NAME, EXAMPLE_LICENSE_SEAT_UUID_ACTIVE, EXAMPLE_LICENSE_SEAT_UUID_AVAILABLE, EXAMPLE_LICENSE_SEAT_UUID_SECONDARY, EXAMPLE_LICENSE_SKU, EXAMPLE_LICENSE_SUBJECT_ID_ACTIVE, EXAMPLE_LICENSE_SUBJECT_ID_AVAILABLE, EXAMPLE_TENANT_IDENTIFIER, } from './shared.js';
|
|
6
6
|
import { DEFAULT_LICENSE_DEVICE_ALLOWANCE } from '../utils/license.js';
|
|
7
7
|
import { EXAMPLE_EMPLOYEE_CONTROLLER_ACTIVE } from './employee.js';
|
|
8
8
|
export const EXAMPLE_EMPLOYEE_DEVICE_BINDINGS = Object.freeze([
|
|
@@ -70,6 +70,20 @@ export const EXAMPLE_LICENSE_AVAILABLE_RECORD = Object.freeze({
|
|
|
70
70
|
[ClaimsIndividualProductSchemaorg.serialNumber]: EXAMPLE_LICENSE_SEAT_UUID_AVAILABLE,
|
|
71
71
|
},
|
|
72
72
|
});
|
|
73
|
+
/** Complete stored device-license fixture for manager and repository tests. */
|
|
74
|
+
export const EXAMPLE_DEVICE_LICENSE_AVAILABLE = Object.freeze({
|
|
75
|
+
id: EXAMPLE_LICENSE_SEAT_UUID_AVAILABLE,
|
|
76
|
+
tenantId: EXAMPLE_TENANT_IDENTIFIER,
|
|
77
|
+
orderId: EXAMPLE_LICENSE_INVOICE_ID,
|
|
78
|
+
userClass: DeviceUserClasses.Employee,
|
|
79
|
+
userCategory: EXAMPLE_HEALTHCARE_ACTOR_ROLE_GENERALIST_MEDICAL_PRACTITIONER,
|
|
80
|
+
type: DeviceAppTypes.Mobile,
|
|
81
|
+
status: LicenseStatuses.Available,
|
|
82
|
+
plan: EXAMPLE_LICENSE_PLAN_DEFAULT,
|
|
83
|
+
renewalCycle: EXAMPLE_LICENSE_RENEWAL_CYCLE_YEARLY,
|
|
84
|
+
reactivationEnabled: false,
|
|
85
|
+
exp: 1_893_456_000,
|
|
86
|
+
});
|
|
73
87
|
export const EXAMPLE_LICENSE_LIST_RESPONSE_BODY = Object.freeze({
|
|
74
88
|
data: [
|
|
75
89
|
{
|
|
@@ -296,9 +296,14 @@ export declare const EXAMPLE_LICENSE_CURRENCY: "EUR";
|
|
|
296
296
|
export declare const EXAMPLE_LICENSE_PLAN_NAME: "Family starter";
|
|
297
297
|
export declare const EXAMPLE_LICENSE_SKU: "FAM-START";
|
|
298
298
|
export declare const EXAMPLE_LICENSE_PAYMENT_METHOD_INVOICE: "invoice";
|
|
299
|
+
export declare const EXAMPLE_LICENSE_PAYMENT_METHOD_STRIPE: "Stripe";
|
|
299
300
|
export declare const EXAMPLE_LICENSE_CHECKOUT_URL: "https://pay.example/offer-001";
|
|
300
301
|
export declare const EXAMPLE_LICENSE_PAYMENT_URL: "https://pay.example/invoice-001";
|
|
301
302
|
export declare const EXAMPLE_LICENSE_INVOICE_ID: "invoice-001";
|
|
303
|
+
export declare const EXAMPLE_POSTAL_ACTIVATION_CODE: "EXAMPLE-ACTIVATION-001";
|
|
304
|
+
export declare const EXAMPLE_POSTAL_ACTIVATION_CODE_INVALID: "EXAMPLE-ACTIVATION-INVALID";
|
|
305
|
+
export declare const EXAMPLE_POSTAL_ACTIVATION_PEPPER: "example-host-pepper";
|
|
306
|
+
export declare const EXAMPLE_POSTAL_ACTIVATION_SALT: "example-base64url-salt";
|
|
302
307
|
export declare const EXAMPLE_INVOICE_DATE: "2026-06-11T10:00:00Z";
|
|
303
308
|
export declare const EXAMPLE_INVOICE_CHARGEITEM_PRODUCT_CODE: "08412345678903";
|
|
304
309
|
export declare const EXAMPLE_INVOICE_CHARGEITEM_PRODUCT_NAME: "Sterile saline bottle 500 mL";
|
|
@@ -347,6 +352,24 @@ export declare const EXAMPLE_VITAL_SIGN_VALUE_DIASTOLIC: 78;
|
|
|
347
352
|
export declare const EXAMPLE_VITAL_SIGN_VALUE_BODY_TEMPERATURE: 37.1;
|
|
348
353
|
export declare const EXAMPLE_VITAL_SIGN_UNIT_BEATS_PER_MINUTE: "/min";
|
|
349
354
|
export declare const EXAMPLE_OBSERVATION_CATEGORY_VITAL_SIGNS: "http://terminology.hl7.org/CodeSystem/observation-category|vital-signs";
|
|
355
|
+
/** Reusable LOINC Coding for body-weight Observation examples and metadata. */
|
|
356
|
+
export declare const EXAMPLE_OBSERVATION_BODY_WEIGHT_CODING: Readonly<{
|
|
357
|
+
system: "http://loinc.org";
|
|
358
|
+
code: "29463-7";
|
|
359
|
+
display: "Body weight";
|
|
360
|
+
}>;
|
|
361
|
+
/** Reusable SNOMED CT Coding for anxiety Observation examples and metadata. */
|
|
362
|
+
export declare const EXAMPLE_OBSERVATION_ANXIETY_CODING: Readonly<{
|
|
363
|
+
system: "http://snomed.info/sct";
|
|
364
|
+
code: "48694002";
|
|
365
|
+
display: "Anxiety";
|
|
366
|
+
}>;
|
|
367
|
+
/** Reusable FHIR event-timing Coding for a night-time event. */
|
|
368
|
+
export declare const EXAMPLE_OBSERVATION_EVENT_TIMING_NIGHT_CODING: Readonly<{
|
|
369
|
+
system: "http://hl7.org/fhir/event-timing";
|
|
370
|
+
code: "NIGHT";
|
|
371
|
+
display: "Night";
|
|
372
|
+
}>;
|
|
350
373
|
export declare const EXAMPLE_VITAL_SIGN_CODE_HEART_RATE: "8867-4";
|
|
351
374
|
export declare const EXAMPLE_VITAL_SIGN_CODE_BODY_TEMPERATURE: "8310-5";
|
|
352
375
|
export declare const EXAMPLE_VITAL_SIGN_CODE_BLOOD_PRESSURE_PANEL: "85354-9";
|
package/dist/examples/shared.js
CHANGED
|
@@ -338,9 +338,14 @@ export const EXAMPLE_LICENSE_CURRENCY = 'EUR';
|
|
|
338
338
|
export const EXAMPLE_LICENSE_PLAN_NAME = 'Family starter';
|
|
339
339
|
export const EXAMPLE_LICENSE_SKU = 'FAM-START';
|
|
340
340
|
export const EXAMPLE_LICENSE_PAYMENT_METHOD_INVOICE = 'invoice';
|
|
341
|
+
export const EXAMPLE_LICENSE_PAYMENT_METHOD_STRIPE = 'Stripe';
|
|
341
342
|
export const EXAMPLE_LICENSE_CHECKOUT_URL = 'https://pay.example/offer-001';
|
|
342
343
|
export const EXAMPLE_LICENSE_PAYMENT_URL = 'https://pay.example/invoice-001';
|
|
343
344
|
export const EXAMPLE_LICENSE_INVOICE_ID = 'invoice-001';
|
|
345
|
+
export const EXAMPLE_POSTAL_ACTIVATION_CODE = 'EXAMPLE-ACTIVATION-001';
|
|
346
|
+
export const EXAMPLE_POSTAL_ACTIVATION_CODE_INVALID = 'EXAMPLE-ACTIVATION-INVALID';
|
|
347
|
+
export const EXAMPLE_POSTAL_ACTIVATION_PEPPER = 'example-host-pepper';
|
|
348
|
+
export const EXAMPLE_POSTAL_ACTIVATION_SALT = 'example-base64url-salt';
|
|
344
349
|
export const EXAMPLE_INVOICE_DATE = '2026-06-11T10:00:00Z';
|
|
345
350
|
export const EXAMPLE_INVOICE_CHARGEITEM_PRODUCT_CODE = '08412345678903';
|
|
346
351
|
export const EXAMPLE_INVOICE_CHARGEITEM_PRODUCT_NAME = 'Sterile saline bottle 500 mL';
|
|
@@ -389,6 +394,24 @@ export const EXAMPLE_VITAL_SIGN_VALUE_DIASTOLIC = 78;
|
|
|
389
394
|
export const EXAMPLE_VITAL_SIGN_VALUE_BODY_TEMPERATURE = 37.1;
|
|
390
395
|
export const EXAMPLE_VITAL_SIGN_UNIT_BEATS_PER_MINUTE = '/min';
|
|
391
396
|
export const EXAMPLE_OBSERVATION_CATEGORY_VITAL_SIGNS = 'http://terminology.hl7.org/CodeSystem/observation-category|vital-signs';
|
|
397
|
+
/** Reusable LOINC Coding for body-weight Observation examples and metadata. */
|
|
398
|
+
export const EXAMPLE_OBSERVATION_BODY_WEIGHT_CODING = Object.freeze({
|
|
399
|
+
system: FhirCodeSystems.Loinc,
|
|
400
|
+
code: '29463-7',
|
|
401
|
+
display: 'Body weight',
|
|
402
|
+
});
|
|
403
|
+
/** Reusable SNOMED CT Coding for anxiety Observation examples and metadata. */
|
|
404
|
+
export const EXAMPLE_OBSERVATION_ANXIETY_CODING = Object.freeze({
|
|
405
|
+
system: FhirCodeSystems.SnomedCt,
|
|
406
|
+
code: '48694002',
|
|
407
|
+
display: 'Anxiety',
|
|
408
|
+
});
|
|
409
|
+
/** Reusable FHIR event-timing Coding for a night-time event. */
|
|
410
|
+
export const EXAMPLE_OBSERVATION_EVENT_TIMING_NIGHT_CODING = Object.freeze({
|
|
411
|
+
system: FhirCodeSystems.EventTiming,
|
|
412
|
+
code: 'NIGHT',
|
|
413
|
+
display: 'Night',
|
|
414
|
+
});
|
|
392
415
|
export const EXAMPLE_VITAL_SIGN_CODE_HEART_RATE = '8867-4';
|
|
393
416
|
export const EXAMPLE_VITAL_SIGN_CODE_BODY_TEMPERATURE = '8310-5';
|
|
394
417
|
export const EXAMPLE_VITAL_SIGN_CODE_BLOOD_PRESSURE_PANEL = '85354-9';
|
package/dist/utils/did.d.ts
CHANGED
|
@@ -36,7 +36,10 @@ export declare function generateServiceId(selector: ServiceEndpointSelector): st
|
|
|
36
36
|
* due to case sensitivity in the path component of the underlying URL.
|
|
37
37
|
*
|
|
38
38
|
* The rule is:
|
|
39
|
-
* -
|
|
39
|
+
* - The DNS authority and ordinary non-final path segments are lowercased.
|
|
40
|
+
* - A hosted VAT tenant segment is uppercased (`vates-b...` -> `VATES-B...`).
|
|
41
|
+
* - A `cds-<jurisdiction>` segment uses an uppercase ISO jurisdiction.
|
|
42
|
+
* - The final segment is preserved.
|
|
40
43
|
* - If the final segment represents a `system|code` pair (e.g., for a role),
|
|
41
44
|
* the `system` part is lowercased, but the `code` is preserved as-is.
|
|
42
45
|
* - If the final segment is a unique identifier (like a Tax ID), it is preserved as-is.
|
package/dist/utils/did.js
CHANGED
|
@@ -56,7 +56,10 @@ export function generateServiceId(selector) {
|
|
|
56
56
|
* due to case sensitivity in the path component of the underlying URL.
|
|
57
57
|
*
|
|
58
58
|
* The rule is:
|
|
59
|
-
* -
|
|
59
|
+
* - The DNS authority and ordinary non-final path segments are lowercased.
|
|
60
|
+
* - A hosted VAT tenant segment is uppercased (`vates-b...` -> `VATES-B...`).
|
|
61
|
+
* - A `cds-<jurisdiction>` segment uses an uppercase ISO jurisdiction.
|
|
62
|
+
* - The final segment is preserved.
|
|
60
63
|
* - If the final segment represents a `system|code` pair (e.g., for a role),
|
|
61
64
|
* the `system` part is lowercased, but the `code` is preserved as-is.
|
|
62
65
|
* - If the final segment is a unique identifier (like a Tax ID), it is preserved as-is.
|
|
@@ -70,16 +73,30 @@ export function normalizeDidWeb(did) {
|
|
|
70
73
|
// Not a valid did:web, return as is.
|
|
71
74
|
return did;
|
|
72
75
|
}
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
76
|
+
const lastIndex = parts.length - 1;
|
|
77
|
+
return parts.map((part, index) => {
|
|
78
|
+
if (index < 2)
|
|
79
|
+
return part.toLowerCase();
|
|
80
|
+
if (index === 2)
|
|
81
|
+
return part.toLowerCase().replace(/%3a/gi, '%3A');
|
|
82
|
+
// Hosted tenant identifiers use the canonical VAT + ISO country prefix.
|
|
83
|
+
// Keep this deliberately narrow so unrelated opaque DID path identifiers
|
|
84
|
+
// are not modified merely because they contain the letters "vat".
|
|
85
|
+
if (/^vat[a-z]{2}[-a-z0-9._]+$/i.test(part)) {
|
|
86
|
+
return part.toUpperCase();
|
|
87
|
+
}
|
|
88
|
+
const jurisdictionMatch = /^cds-([a-z]{2})$/i.exec(part);
|
|
89
|
+
if (jurisdictionMatch) {
|
|
90
|
+
return `cds-${jurisdictionMatch[1].toUpperCase()}`;
|
|
91
|
+
}
|
|
92
|
+
if (index === lastIndex) {
|
|
93
|
+
if (!part.includes('|'))
|
|
94
|
+
return part;
|
|
95
|
+
const [system, ...codeParts] = part.split('|');
|
|
96
|
+
return `${system.toLowerCase()}|${codeParts.join('|')}`;
|
|
97
|
+
}
|
|
98
|
+
return part.toLowerCase();
|
|
99
|
+
}).join(':');
|
|
83
100
|
}
|
|
84
101
|
/**
|
|
85
102
|
* Encodes a hostname according to did:web spec (percent-encodes port colons).
|
|
@@ -139,6 +139,35 @@ function extractClaims(entry) {
|
|
|
139
139
|
const resourceClaims = resourceMeta.claims && typeof resourceMeta.claims === 'object' ? resourceMeta.claims : undefined;
|
|
140
140
|
return { ...(resourceClaims || {}), ...(metaClaims || {}) };
|
|
141
141
|
}
|
|
142
|
+
function isLicenseListEntry(entry) {
|
|
143
|
+
const meta = entry.meta && typeof entry.meta === 'object'
|
|
144
|
+
? entry.meta
|
|
145
|
+
: {};
|
|
146
|
+
const claims = extractClaims(entry);
|
|
147
|
+
return !!(normalizeText(meta.status)
|
|
148
|
+
|| normalizeText(entry.status)
|
|
149
|
+
|| normalizeText(entry.id)
|
|
150
|
+
|| normalizeText(claims[ClaimsIndividualProductSchemaorg.serialNumber])
|
|
151
|
+
|| normalizeText(claims[ClaimsOfferSchemaorg.serialNumber]));
|
|
152
|
+
}
|
|
153
|
+
function extractLicenseListEntries(node) {
|
|
154
|
+
if (!node || typeof node !== 'object')
|
|
155
|
+
return [];
|
|
156
|
+
if (Array.isArray(node)) {
|
|
157
|
+
return node.flatMap((entry) => extractLicenseListEntries(entry));
|
|
158
|
+
}
|
|
159
|
+
const entry = node;
|
|
160
|
+
const resource = entry.resource && typeof entry.resource === 'object'
|
|
161
|
+
? entry.resource
|
|
162
|
+
: undefined;
|
|
163
|
+
if (resource && Array.isArray(resource.data)) {
|
|
164
|
+
return extractLicenseListEntries(resource.data);
|
|
165
|
+
}
|
|
166
|
+
if (Array.isArray(entry.data)) {
|
|
167
|
+
return extractLicenseListEntries(entry.data);
|
|
168
|
+
}
|
|
169
|
+
return isLicenseListEntry(entry) ? [entry] : [];
|
|
170
|
+
}
|
|
142
171
|
/**
|
|
143
172
|
* Reads license-like search/list records from one current GW-style response
|
|
144
173
|
* body without exposing raw claim access to frontend code.
|
|
@@ -146,7 +175,7 @@ function extractClaims(entry) {
|
|
|
146
175
|
export function readLicenseListRecords(body) {
|
|
147
176
|
const root = body && typeof body === 'object' ? body : {};
|
|
148
177
|
const bodyNode = root.body && typeof root.body === 'object' ? root.body : root;
|
|
149
|
-
const data =
|
|
178
|
+
const data = extractLicenseListEntries(bodyNode);
|
|
150
179
|
return data
|
|
151
180
|
.filter((entry) => !!entry && typeof entry === 'object')
|
|
152
181
|
.map((entry) => {
|
|
@@ -156,9 +185,9 @@ export function readLicenseListRecords(body) {
|
|
|
156
185
|
id: normalizeText(claims[ClaimsIndividualProductSchemaorg.serialNumber]
|
|
157
186
|
|| claims[ClaimsOfferSchemaorg.serialNumber]
|
|
158
187
|
|| entry.id),
|
|
159
|
-
status: normalizeText(meta.status),
|
|
160
|
-
subjectId: normalizeText(meta.subjectId),
|
|
161
|
-
ownerOrganizationId: normalizeText(meta.ownerOrganizationId || claims['License.ownerOrganizationId']),
|
|
188
|
+
status: normalizeText(meta.status || entry.status),
|
|
189
|
+
subjectId: normalizeText(meta.subjectId || entry.subjectId),
|
|
190
|
+
ownerOrganizationId: normalizeText(meta.ownerOrganizationId || entry.ownerOrganizationId || claims['License.ownerOrganizationId']),
|
|
162
191
|
email: normalizeText(claims[ClaimsPersonSchemaorg.email]),
|
|
163
192
|
telephone: normalizeText(claims[ClaimsPersonSchemaorg.telephone]),
|
|
164
193
|
role: normalizeText(claims[ClaimsPersonSchemaorg.hasOccupationalRoleValue]),
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import type { VerifiableCredentialV2 } from '../models/verifiable-credential';
|
|
2
|
+
/** Canonical protected-code algorithm used by postal activation bindings. */
|
|
3
|
+
export declare const POSTAL_ACTIVATION_CODE_BINDING_ALGORITHM: "scrypt-v1";
|
|
2
4
|
/** Lifecycle for a separate postal-address verification credential. */
|
|
3
5
|
export declare const PostalActivationLicenseStatuses: Readonly<{
|
|
4
6
|
readonly Issued: "issued";
|
|
@@ -22,7 +24,7 @@ export type PostalActivationLicenseBinding = Readonly<{
|
|
|
22
24
|
controllerKeyMaterial: string;
|
|
23
25
|
postalAddressHash: string;
|
|
24
26
|
protectedCode: Readonly<{
|
|
25
|
-
algorithm:
|
|
27
|
+
algorithm: typeof POSTAL_ACTIVATION_CODE_BINDING_ALGORITHM;
|
|
26
28
|
salt: string;
|
|
27
29
|
digest: string;
|
|
28
30
|
}>;
|
|
@@ -34,6 +36,8 @@ export type PostalActivationLicenseBinding = Readonly<{
|
|
|
34
36
|
deliveredAt?: string;
|
|
35
37
|
redeemedAt?: string;
|
|
36
38
|
}>;
|
|
39
|
+
/** Reusable protected-code slice stored in encrypted host registration state. */
|
|
40
|
+
export type PostalActivationCodeBinding = PostalActivationLicenseBinding['protectedCode'];
|
|
37
41
|
/** Input for the credential returned out-of-band to the applicant controller. */
|
|
38
42
|
export type OrganizationTestNetworkCredentialInput = Readonly<{
|
|
39
43
|
issuerDid: string;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { ContractCredentialTypes, W3cCredentialContexts, W3cCredentialTypes, } from '../constants/verifiable-credentials.js';
|
|
2
|
+
/** Canonical protected-code algorithm used by postal activation bindings. */
|
|
3
|
+
export const POSTAL_ACTIVATION_CODE_BINDING_ALGORITHM = 'scrypt-v1';
|
|
2
4
|
/** Lifecycle for a separate postal-address verification credential. */
|
|
3
5
|
export const PostalActivationLicenseStatuses = Object.freeze({
|
|
4
6
|
Issued: 'issued',
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "gdc-common-utils-ts",
|
|
3
|
-
"version": "2.5.
|
|
3
|
+
"version": "2.5.11",
|
|
4
4
|
"publishConfig": {
|
|
5
5
|
"access": "public"
|
|
6
6
|
},
|
|
@@ -24,7 +24,8 @@
|
|
|
24
24
|
"verify:dist": "node scripts/verify-dist-syntax.mjs",
|
|
25
25
|
"check:product-neutrality": "node scripts/check-product-neutrality.mjs",
|
|
26
26
|
"prepack": "npm run verify:dist",
|
|
27
|
-
"prepublishOnly": "npm run check:product-neutrality && npm run typecheck && npm test -- --watchman=false && npm run build"
|
|
27
|
+
"prepublishOnly": "npm run check:product-neutrality && npm run typecheck && npm test -- --watchman=false && npm run build",
|
|
28
|
+
"prepare": "npm run build"
|
|
28
29
|
},
|
|
29
30
|
"main": "./dist/index.js",
|
|
30
31
|
"types": "./dist/index.d.ts",
|