gdc-common-utils-ts 2.5.12 → 2.5.13
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/examples/organization-role-license.js +11 -10
- package/dist/models/organization-role-license.d.ts +2 -1
- package/dist/utils/actor-identifier.d.ts +5 -1
- package/dist/utils/actor-identifier.js +4 -0
- package/dist/utils/organization-role-license.d.ts +2 -1
- package/dist/utils/organization-role-license.js +9 -2
- package/package.json +1 -1
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
// Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
|
|
2
|
-
import { buildStableActorIdentifier } from '../utils/actor-identifier.js';
|
|
2
|
+
import { buildStableActorIdentifier, StableActorContactKinds } from '../utils/actor-identifier.js';
|
|
3
3
|
import { buildOrganizationRoleLicenseId, } from '../utils/organization-role-license.js';
|
|
4
|
+
import { EXAMPLE_EMAIL_PROFESSIONAL, EXAMPLE_EMPLOYEE_DEVICE_CLIENT_ID_PRIMARY, EXAMPLE_EMPLOYEE_DEVICE_INSTANCE_ID_PRIMARY, EXAMPLE_HOST_PUBLIC_HOSTNAME, EXAMPLE_JURISDICTION, EXAMPLE_LEGAL_ORGANIZATION_TAX_ID, EXAMPLE_ORGANIZATION_CONTROLLER_ROLE, EXAMPLE_SECTOR, } from './shared.js';
|
|
4
5
|
/** Reusable synthetic identity for role-licence contract and consumer tests. */
|
|
5
6
|
export const EXAMPLE_ORGANIZATION_ROLE_LICENSE_IDENTITY = Object.freeze({
|
|
6
|
-
jurisdiction:
|
|
7
|
-
|
|
7
|
+
jurisdiction: EXAMPLE_JURISDICTION,
|
|
8
|
+
organizationOfficialId: EXAMPLE_LEGAL_ORGANIZATION_TAX_ID,
|
|
8
9
|
stableContactIdentifier: buildStableActorIdentifier({
|
|
9
|
-
contactKind:
|
|
10
|
-
contact:
|
|
10
|
+
contactKind: StableActorContactKinds.Email,
|
|
11
|
+
contact: EXAMPLE_EMAIL_PROFESSIONAL,
|
|
11
12
|
}),
|
|
12
|
-
licensedRole:
|
|
13
|
+
licensedRole: EXAMPLE_ORGANIZATION_CONTROLLER_ROLE,
|
|
13
14
|
});
|
|
14
15
|
/** Reusable catch-all plus exact-override policy example. */
|
|
15
16
|
export const EXAMPLE_ORGANIZATION_ROLE_LICENSE_POLICIES = Object.freeze([
|
|
@@ -24,10 +25,10 @@ export const EXAMPLE_ORGANIZATION_ROLE_LICENSE = Object.freeze({
|
|
|
24
25
|
data: [...EXAMPLE_ORGANIZATION_ROLE_LICENSE_POLICIES],
|
|
25
26
|
devices: [
|
|
26
27
|
Object.freeze({
|
|
27
|
-
clientId:
|
|
28
|
-
clientInstanceId:
|
|
29
|
-
sector:
|
|
30
|
-
host:
|
|
28
|
+
clientId: EXAMPLE_EMPLOYEE_DEVICE_CLIENT_ID_PRIMARY,
|
|
29
|
+
clientInstanceId: EXAMPLE_EMPLOYEE_DEVICE_INSTANCE_ID_PRIMARY,
|
|
30
|
+
sector: EXAMPLE_SECTOR,
|
|
31
|
+
host: `https://${EXAMPLE_HOST_PUBLIC_HOSTNAME}`,
|
|
31
32
|
status: 'active',
|
|
32
33
|
activatedAt: 1_700_000_000,
|
|
33
34
|
}),
|
|
@@ -32,7 +32,8 @@ export interface OrganizationRoleLicenseDevice {
|
|
|
32
32
|
*/
|
|
33
33
|
export interface OrganizationRoleLicense {
|
|
34
34
|
id: string;
|
|
35
|
-
|
|
35
|
+
/** Official legal identifier value; never an embedded `urn:org:*` identifier. */
|
|
36
|
+
organizationOfficialId: string;
|
|
36
37
|
jurisdiction: string;
|
|
37
38
|
stableContactIdentifier: string;
|
|
38
39
|
licensedRole: string;
|
|
@@ -1,4 +1,8 @@
|
|
|
1
|
-
export
|
|
1
|
+
export declare const StableActorContactKinds: Readonly<{
|
|
2
|
+
readonly Email: "email";
|
|
3
|
+
readonly Phone: "phone";
|
|
4
|
+
}>;
|
|
5
|
+
export type StableActorContactKind = typeof StableActorContactKinds[keyof typeof StableActorContactKinds];
|
|
2
6
|
/**
|
|
3
7
|
* Builds the private, stable actor identifier shared by independent portals.
|
|
4
8
|
*
|
|
@@ -1,5 +1,9 @@
|
|
|
1
1
|
import { normalizePhone } from './consent.js';
|
|
2
2
|
import { normalizeSameAsHash, normalizeTelephoneHash } from './same-as.js';
|
|
3
|
+
export const StableActorContactKinds = Object.freeze({
|
|
4
|
+
Email: 'email',
|
|
5
|
+
Phone: 'phone',
|
|
6
|
+
});
|
|
3
7
|
/**
|
|
4
8
|
* Builds the private, stable actor identifier shared by independent portals.
|
|
5
9
|
*
|
|
@@ -1,10 +1,11 @@
|
|
|
1
1
|
import type { OrganizationRoleLicense, OrganizationRoleLicenseDevice, OrganizationRoleLicenseSectorPolicy } from '../models/organization-role-license';
|
|
2
2
|
export type OrganizationRoleLicenseIdentity = Readonly<{
|
|
3
3
|
jurisdiction: string;
|
|
4
|
-
|
|
4
|
+
organizationOfficialId: string;
|
|
5
5
|
stableContactIdentifier: string;
|
|
6
6
|
licensedRole: string;
|
|
7
7
|
}>;
|
|
8
|
+
export declare function validateOrganizationOfficialId(value: string): string;
|
|
8
9
|
/**
|
|
9
10
|
* Builds the exact, compact licence preimage agreed across portals and hosts.
|
|
10
11
|
* The preimage is hashed before persistence and is never itself a ledger key.
|
|
@@ -16,16 +16,23 @@ function validateStableContactIdentifier(value) {
|
|
|
16
16
|
}
|
|
17
17
|
return normalized;
|
|
18
18
|
}
|
|
19
|
+
export function validateOrganizationOfficialId(value) {
|
|
20
|
+
const normalized = required(value, 'organizationOfficialId');
|
|
21
|
+
if (normalized.includes(':') || /^urn:/i.test(normalized)) {
|
|
22
|
+
throw new TypeError('organizationOfficialId must be the official identifier value, not an organization URN.');
|
|
23
|
+
}
|
|
24
|
+
return normalized;
|
|
25
|
+
}
|
|
19
26
|
/**
|
|
20
27
|
* Builds the exact, compact licence preimage agreed across portals and hosts.
|
|
21
28
|
* The preimage is hashed before persistence and is never itself a ledger key.
|
|
22
29
|
*/
|
|
23
30
|
export function buildOrganizationRoleLicensePreimage(identity) {
|
|
24
31
|
const jurisdiction = required(identity.jurisdiction, 'jurisdiction').toLowerCase();
|
|
25
|
-
const
|
|
32
|
+
const organizationOfficialId = validateOrganizationOfficialId(identity.organizationOfficialId);
|
|
26
33
|
const stableContactIdentifier = validateStableContactIdentifier(identity.stableContactIdentifier);
|
|
27
34
|
const licensedRole = required(identity.licensedRole, 'licensedRole');
|
|
28
|
-
return `urn:cds-${jurisdiction}:${
|
|
35
|
+
return `urn:cds-${jurisdiction}:${organizationOfficialId}:${stableContactIdentifier}:${licensedRole}`;
|
|
29
36
|
}
|
|
30
37
|
/** SHA3-384 multihash identifier for organization + contact + licensed role. */
|
|
31
38
|
export function buildOrganizationRoleLicenseId(identity) {
|