gdc-common-utils-ts 1.0.4 → 1.0.7
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/AesManager.d.ts +27 -0
- package/dist/AesManager.js +62 -0
- package/dist/CryptographyService.d.ts +76 -0
- package/dist/CryptographyService.js +403 -0
- package/dist/constants/Schemas.d.ts +45 -0
- package/dist/constants/Schemas.js +48 -0
- package/dist/constants/index.js +1 -0
- package/{src/constants/schemaorg.ts → dist/constants/schemaorg.d.ts} +24 -116
- package/dist/constants/schemaorg.js +185 -0
- package/dist/cryptoDecode.d.ts +3 -0
- package/dist/cryptoDecode.js +90 -0
- package/dist/cryptoEncode.d.ts +1 -0
- package/dist/cryptoEncode.js +30 -0
- package/dist/cryptography.abstract.d.ts +13 -0
- package/{src/cryptography.abstract.ts → dist/cryptography.abstract.js} +6 -14
- package/dist/hmac.d.ts +2 -0
- package/{src/hmac.ts → dist/hmac.js} +4 -7
- package/dist/index.js +3 -0
- package/{src/interfaces/Cryptography.types.ts → dist/interfaces/Cryptography.types.d.ts} +71 -71
- package/dist/interfaces/Cryptography.types.js +8 -0
- package/dist/interfaces/ICryptoHelper.d.ts +28 -0
- package/dist/interfaces/ICryptoHelper.js +3 -0
- package/dist/interfaces/ICryptography.d.ts +154 -0
- package/dist/interfaces/ICryptography.js +3 -0
- package/dist/interfaces/IWallet.d.ts +55 -0
- package/dist/interfaces/IWallet.js +3 -0
- package/dist/interfaces/MlDsa.d.ts +9 -0
- package/{src/interfaces/MlDsa.ts → dist/interfaces/MlDsa.js} +1 -5
- package/dist/interfaces/MlKem.d.ts +11 -0
- package/{src/interfaces/MlKem.ts → dist/interfaces/MlKem.js} +0 -5
- package/dist/models/aes.d.ts +85 -0
- package/dist/models/aes.js +10 -0
- package/dist/models/auth.d.ts +35 -0
- package/dist/models/auth.js +3 -0
- package/{src/models/bundle.ts → dist/models/bundle.d.ts} +41 -63
- package/dist/models/bundle.js +26 -0
- package/dist/models/clinical-sections.d.ts +36 -0
- package/dist/models/clinical-sections.en.d.ts +75 -0
- package/dist/models/clinical-sections.en.js +81 -0
- package/dist/models/clinical-sections.js +32 -0
- package/dist/models/comm.d.ts +44 -0
- package/dist/models/comm.js +4 -0
- package/{src/models/confidential-job.ts → dist/models/confidential-job.d.ts} +23 -45
- package/dist/models/confidential-job.js +20 -0
- package/dist/models/confidential-message.d.ts +97 -0
- package/dist/models/confidential-message.js +4 -0
- package/{src/models/confidential-storage.ts → dist/models/confidential-storage.d.ts} +35 -56
- package/dist/models/confidential-storage.js +3 -0
- package/{src/models/consent-rule.ts → dist/models/consent-rule.d.ts} +22 -42
- package/dist/models/consent-rule.js +21 -0
- package/{src/models/crypto.ts → dist/models/crypto.d.ts} +5 -13
- package/dist/models/crypto.js +3 -0
- package/dist/models/device-license.d.ts +133 -0
- package/dist/models/device-license.js +3 -0
- package/{src/models/did.ts → dist/models/did.d.ts} +21 -30
- package/dist/models/did.js +3 -0
- package/dist/models/index.js +31 -0
- package/dist/models/indexing.d.ts +11 -0
- package/dist/models/indexing.js +18 -0
- package/dist/models/issue.d.ts +57 -0
- package/dist/models/issue.js +75 -0
- package/dist/models/jsonapi.d.ts +13 -0
- package/dist/models/jsonapi.js +3 -0
- package/{src/models/jwe.ts → dist/models/jwe.d.ts} +10 -22
- package/dist/models/jwe.js +3 -0
- package/{src/models/jwk.ts → dist/models/jwk.d.ts} +0 -11
- package/dist/models/jwk.js +3 -0
- package/{src/models/jws.ts → dist/models/jws.d.ts} +0 -7
- package/dist/models/jws.js +3 -0
- package/dist/models/jwt.d.ts +9 -0
- package/dist/models/jwt.js +3 -0
- package/dist/models/multibase58.d.ts +13 -0
- package/dist/models/multibase58.js +40 -0
- package/dist/models/oidc4ida.common.model.d.ts +33 -0
- package/dist/models/oidc4ida.common.model.js +3 -0
- package/dist/models/oidc4ida.document.model.d.ts +50 -0
- package/dist/models/oidc4ida.document.model.js +3 -0
- package/{src/models/oidc4ida.electronicRecord.model.ts → dist/models/oidc4ida.electronicRecord.model.d.ts} +18 -37
- package/dist/models/oidc4ida.electronicRecord.model.js +3 -0
- package/{src/models/oidc4ida.evidence.model.ts → dist/models/oidc4ida.evidence.model.d.ts} +17 -35
- package/dist/models/oidc4ida.evidence.model.js +5 -0
- package/dist/models/openid-device.d.ts +119 -0
- package/dist/models/openid-device.js +3 -0
- package/dist/models/operation-outcome.d.ts +26 -0
- package/dist/models/operation-outcome.js +3 -0
- package/{src/models/params.ts → dist/models/params.d.ts} +20 -29
- package/dist/models/params.js +3 -0
- package/dist/models/resource-document.d.ts +14 -0
- package/dist/models/resource-document.js +3 -0
- package/dist/models/response.d.ts +1 -0
- package/dist/models/response.js +3 -0
- package/dist/models/urlPath.d.ts +58 -0
- package/dist/models/urlPath.js +76 -0
- package/dist/models/verifiable-credential.d.ts +45 -0
- package/dist/models/verifiable-credential.js +8 -0
- package/dist/utils/actor.d.ts +18 -0
- package/dist/utils/actor.js +36 -0
- package/dist/utils/base-convert.d.ts +20 -0
- package/{src/utils/base-convert.ts → dist/utils/base-convert.js} +23 -36
- package/dist/utils/baseN.d.ts +35 -0
- package/dist/utils/baseN.js +174 -0
- package/dist/utils/bundle.d.ts +6 -0
- package/dist/utils/bundle.js +32 -0
- package/dist/utils/content.d.ts +55 -0
- package/{src/utils/content.ts → dist/utils/content.js} +4 -10
- package/dist/utils/did.d.ts +67 -0
- package/dist/utils/did.js +123 -0
- package/dist/utils/format-converter.d.ts +21 -0
- package/dist/utils/format-converter.js +109 -0
- package/dist/utils/index.js +13 -0
- package/dist/utils/jwt.d.ts +52 -0
- package/dist/utils/jwt.js +153 -0
- package/dist/utils/manager-error.d.ts +15 -0
- package/dist/utils/manager-error.js +23 -0
- package/dist/utils/multibase58.d.ts +13 -0
- package/dist/utils/multibase58.js +40 -0
- package/dist/utils/multibasehash.d.ts +8 -0
- package/{src/utils/multibasehash.ts → dist/utils/multibasehash.js} +8 -13
- package/dist/utils/normalize.d.ts +16 -0
- package/{src/utils/normalize.ts → dist/utils/normalize.js} +15 -18
- package/dist/utils/object-convert.d.ts +20 -0
- package/{src/utils/object-convert.ts → dist/utils/object-convert.js} +10 -16
- package/dist/utils/string-convert.d.ts +24 -0
- package/{src/utils/string-convert.ts → dist/utils/string-convert.js} +5 -14
- package/dist/utils/string-utils.d.ts +25 -0
- package/{src/utils/string-utils.ts → dist/utils/string-utils.js} +12 -16
- package/dist/utils/url.d.ts +27 -0
- package/{src/utils/url.ts → dist/utils/url.js} +6 -7
- package/package.json +56 -14
- package/PUBLISHING.md +0 -33
- package/__tests__/AesManager.test.ts +0 -53
- package/__tests__/CryptographyService.test.ts +0 -194
- package/__tests__/bundle.test.ts +0 -29
- package/__tests__/content.test.ts +0 -72
- package/__tests__/crypto-encode-decode.test.ts +0 -52
- package/__tests__/crypto-hmac.test.ts +0 -21
- package/__tests__/did-generateServiceId.errors.test.ts +0 -8
- package/__tests__/did-generateServiceId.test.ts +0 -18
- package/__tests__/models-clinical-sections.test.ts +0 -32
- package/__tests__/models-multibase58.test.ts +0 -33
- package/__tests__/multibase58.errors.test.ts +0 -7
- package/__tests__/multibase58.test.ts +0 -28
- package/__tests__/multibasehash.test.ts +0 -25
- package/__tests__/utils-actor.test.ts +0 -46
- package/__tests__/utils-base-convert.test.ts +0 -57
- package/__tests__/utils-baseN.test.ts +0 -40
- package/__tests__/utils-did-extra.test.ts +0 -33
- package/__tests__/utils-format-converter.test.ts +0 -87
- package/__tests__/utils-jwt.test.ts +0 -57
- package/__tests__/utils-manager-error.test.ts +0 -11
- package/__tests__/utils-normalize.test.ts +0 -15
- package/__tests__/utils-object-convert.test.ts +0 -38
- package/__tests__/utils-string-convert.test.ts +0 -20
- package/__tests__/utils-string-utils.test.ts +0 -25
- package/__tests__/utils-url.test.ts +0 -21
- package/babel.config.cjs +0 -5
- package/jest.config.ts +0 -47
- package/src/AesManager.ts +0 -82
- package/src/CryptographyService.ts +0 -461
- package/src/JweManager.ts.txt +0 -365
- package/src/KmsService.txt +0 -493
- package/src/constants/Schemas.ts +0 -61
- package/src/cryptoDecode.ts +0 -104
- package/src/cryptoEncode.ts +0 -36
- package/src/interfaces/ICryptoHelper.ts +0 -33
- package/src/interfaces/ICryptography.ts +0 -177
- package/src/interfaces/IWallet.ts +0 -62
- package/src/models/aes.ts +0 -93
- package/src/models/auth.ts +0 -38
- package/src/models/bundle.txt +0 -93
- package/src/models/clinical-sections.en.ts +0 -82
- package/src/models/clinical-sections.ts +0 -64
- package/src/models/comm.ts +0 -63
- package/src/models/confidential-message.ts +0 -137
- package/src/models/device-license.ts +0 -161
- package/src/models/indexing.ts +0 -20
- package/src/models/issue.ts +0 -85
- package/src/models/jsonapi.ts +0 -19
- package/src/models/jwt.ts +0 -15
- package/src/models/multibase58.ts +0 -46
- package/src/models/oidc4ida.common.model.ts +0 -39
- package/src/models/oidc4ida.document.model.ts +0 -61
- package/src/models/openid-device.ts +0 -146
- package/src/models/operation-outcome.ts +0 -34
- package/src/models/resource-document.ts +0 -21
- package/src/models/response.ts +0 -5
- package/src/models/urlPath.ts +0 -76
- package/src/models/verifiable-credential.ts +0 -52
- package/src/types/noble-hashes.d.ts +0 -4
- package/src/utils/actor.ts +0 -56
- package/src/utils/baseN.ts +0 -203
- package/src/utils/bundle.ts +0 -30
- package/src/utils/did.ts +0 -155
- package/src/utils/format-converter.ts +0 -119
- package/src/utils/jwt.ts +0 -165
- package/src/utils/manager-error.ts +0 -27
- package/src/utils/multibase58.ts +0 -46
- package/tsconfig.json +0 -15
- /package/{src/constants/index.ts → dist/constants/index.d.ts} +0 -0
- /package/{src/index.ts → dist/index.d.ts} +0 -0
- /package/{src/models/index.ts → dist/models/index.d.ts} +0 -0
- /package/{src/utils/index.ts → dist/utils/index.d.ts} +0 -0
|
@@ -0,0 +1,97 @@
|
|
|
1
|
+
import { ProtectedHeadersJWE } from "./jwe";
|
|
2
|
+
import { JwsHeader } from "./jws";
|
|
3
|
+
export type { DataEntry } from "./comm";
|
|
4
|
+
/**
|
|
5
|
+
* Defines the structure of the cryptographic metadata associated with a job request.
|
|
6
|
+
*/
|
|
7
|
+
export interface DidCommDecodedMetadata {
|
|
8
|
+
jws?: {
|
|
9
|
+
protected?: JwsHeader;
|
|
10
|
+
/** Detached signature of the request JWS (when available). */
|
|
11
|
+
signature?: string;
|
|
12
|
+
};
|
|
13
|
+
jwe?: {
|
|
14
|
+
header?: ProtectedHeadersJWE;
|
|
15
|
+
};
|
|
16
|
+
bearer?: {
|
|
17
|
+
compact?: string;
|
|
18
|
+
jwt: {
|
|
19
|
+
header?: JwsHeader;
|
|
20
|
+
payload?: Record<string, any>;
|
|
21
|
+
};
|
|
22
|
+
};
|
|
23
|
+
}
|
|
24
|
+
/**
|
|
25
|
+
* Represents the standard payload of a DIDComm v2 message.
|
|
26
|
+
* @see https://identity.foundation/didcomm-messaging/spec/v2.0/#plaintext-message-structure
|
|
27
|
+
*/
|
|
28
|
+
/**
|
|
29
|
+
* Represents the plaintext of a decoded DIDComm message.
|
|
30
|
+
* This is the core business-level "input" for a job.
|
|
31
|
+
* For FAPI compliance, this entire object is typically the payload of a signed JWS.
|
|
32
|
+
*/
|
|
33
|
+
export interface IDecodedDidcommPayload {
|
|
34
|
+
/** Relevant information available through the decryption and verification process */
|
|
35
|
+
meta?: DidCommDecodedMetadata;
|
|
36
|
+
/**
|
|
37
|
+
* (Issuer) The DID of the entity that issued the message.
|
|
38
|
+
* REQUIRED for FAPI. MUST match the signer of the enclosing JWS.
|
|
39
|
+
*/
|
|
40
|
+
iss: string;
|
|
41
|
+
/**
|
|
42
|
+
* (Audience) The URL of the backend endpoint that will process this message.
|
|
43
|
+
* REQUIRED for FAPI. The backend MUST validate that this value matches its own URL.
|
|
44
|
+
*/
|
|
45
|
+
aud: string;
|
|
46
|
+
/** (Expiration Time) Timestamp after which the message is considered invalid. REQUIRED for FAPI (instead of expires_time). */
|
|
47
|
+
exp?: number;
|
|
48
|
+
/** (Not Before) Timestamp before which the message must not be processed. REQUIRED for FAPI (instead of created_time). */
|
|
49
|
+
nbf?: number;
|
|
50
|
+
/** (Issued At) Timestamp when the message was issued. REQUIRED for FAPI. */
|
|
51
|
+
iat?: number;
|
|
52
|
+
/**
|
|
53
|
+
* (JWT ID) A unique identifier for this message/token. Can be used to prevent replay attacks.
|
|
54
|
+
* In our architecture, this can also serve as the version hash of the data content.
|
|
55
|
+
*/
|
|
56
|
+
jti: string;
|
|
57
|
+
/** Optional. The `jti` identifies both the message and job for processing */
|
|
58
|
+
id?: string;
|
|
59
|
+
/** The Transaction ID / Thread ID for message correlation across an interaction. */
|
|
60
|
+
thid: string;
|
|
61
|
+
/** Parent Thread ID */
|
|
62
|
+
pthid?: string;
|
|
63
|
+
/** The DID of the intended recipient. Used for P2P messaging, informational in client-server requests. */
|
|
64
|
+
to?: string[];
|
|
65
|
+
/** The DID of the sender. Used for P2P messaging, but `iss` is the authoritative value for FAPI. */
|
|
66
|
+
from?: string;
|
|
67
|
+
/**
|
|
68
|
+
* The Message Type URI, identifying the type of data in the body or protocol used.
|
|
69
|
+
* (e.g. 'application/json')
|
|
70
|
+
*/
|
|
71
|
+
type: string;
|
|
72
|
+
/** The main business payload of the message. The structure is defined by the 'type' protocol. */
|
|
73
|
+
body: any;
|
|
74
|
+
}
|
|
75
|
+
/**
|
|
76
|
+
* Represents a data entry in the `body` of a CommMsgExtended,
|
|
77
|
+
* following a hybrid JSON:API and FHIR structure.
|
|
78
|
+
*/
|
|
79
|
+
export interface CommDataEntry {
|
|
80
|
+
id: string;
|
|
81
|
+
type: 'Annotation' | 'Reference' | 'Attachment' | 'CodeableConcept' | string;
|
|
82
|
+
resource: {
|
|
83
|
+
[key: string]: any;
|
|
84
|
+
};
|
|
85
|
+
meta?: {
|
|
86
|
+
claims: any;
|
|
87
|
+
};
|
|
88
|
+
}
|
|
89
|
+
/**
|
|
90
|
+
* The canonical, internal representation of a secure message, extending
|
|
91
|
+
* the standard DIDComm payload with FHIR-specific, flattened metadata.
|
|
92
|
+
*/
|
|
93
|
+
export interface ICommPayloadExtended extends IDecodedDidcommPayload {
|
|
94
|
+
body: {
|
|
95
|
+
data: CommDataEntry[];
|
|
96
|
+
};
|
|
97
|
+
}
|
|
@@ -1,35 +1,29 @@
|
|
|
1
|
-
// Copyright 2025 Antifraud Services Inc. under the Apache License, Version 2.0.
|
|
2
|
-
// File: gdc-common-utils-ts/src/models/confidential-storage.ts
|
|
3
|
-
|
|
4
1
|
import { ParameterType } from './params';
|
|
5
|
-
|
|
6
2
|
/**
|
|
7
3
|
* FHIR `Coding`-like tag used for research/analytics metadata.
|
|
8
4
|
* Keep values coarse and coded; avoid free text in `display` unless explicitly policy-approved.
|
|
9
5
|
*/
|
|
10
6
|
export interface MetaTagCoding {
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
7
|
+
system?: string;
|
|
8
|
+
code?: string;
|
|
9
|
+
version?: string;
|
|
10
|
+
display?: string;
|
|
11
|
+
userSelected?: boolean;
|
|
16
12
|
}
|
|
17
|
-
|
|
18
13
|
/**
|
|
19
14
|
* Research/analytics metadata kept outside encrypted `content`.
|
|
20
15
|
* Policy-dependent: treat these fields as potentially sensitive.
|
|
21
16
|
*/
|
|
22
17
|
export interface ResearchInfo {
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
18
|
+
/** Coarse jurisdiction identifier (e.g., "cds-es" or "ES"). */
|
|
19
|
+
jurisdiction?: string;
|
|
20
|
+
/** Year of birth (YYYY). */
|
|
21
|
+
yearOfBirth?: string;
|
|
22
|
+
/** Gender identity (user-identified). Keep coded and coarse. */
|
|
23
|
+
gender?: string;
|
|
24
|
+
/** Sex assigned at birth (if collected). Keep coded and coarse. */
|
|
25
|
+
sexAtBirth?: string;
|
|
31
26
|
}
|
|
32
|
-
|
|
33
27
|
/**
|
|
34
28
|
* Audit metadata for traceability.
|
|
35
29
|
*
|
|
@@ -39,37 +33,35 @@ export interface ResearchInfo {
|
|
|
39
33
|
* - any `meta` object inside encrypted `content` (e.g., entry `meta.claims`)
|
|
40
34
|
*/
|
|
41
35
|
export interface AuditInfo {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
36
|
+
/** When the document was first created off-ledger (ISO 8601). */
|
|
37
|
+
created?: string;
|
|
38
|
+
/** When the document was last updated off-ledger (ISO 8601). */
|
|
39
|
+
updated?: string;
|
|
40
|
+
/** True if removed/deactivated (deactivation time is typically `updated`). */
|
|
41
|
+
deactivated?: boolean;
|
|
42
|
+
/** Name of the channel/network where the data is audited/anchored. */
|
|
43
|
+
channel?: string;
|
|
44
|
+
/** Base58/Base64Url transaction identifier, depending on the attestation layer. */
|
|
45
|
+
txId?: string;
|
|
46
|
+
/** Transaction timestamp (ISO 8601). */
|
|
47
|
+
txTime?: string;
|
|
54
48
|
}
|
|
55
|
-
|
|
56
49
|
/**
|
|
57
50
|
* Defines the structure of an attribute to be indexed for blind, searchable queries.
|
|
58
51
|
* @see https://identity.foundation/confidential-storage/#indexed-attributes
|
|
59
52
|
*/
|
|
60
53
|
export interface IndexedAttribute {
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
54
|
+
name: string;
|
|
55
|
+
value: string;
|
|
56
|
+
unique?: boolean;
|
|
57
|
+
/**
|
|
58
|
+
* The original data type of the `value` before it was converted to a string
|
|
59
|
+
* for HMAC protection. This is essential for performing type-aware queries
|
|
60
|
+
* (e.g., numerical range queries) on the indexed data.
|
|
61
|
+
* If not present, the type is assumed to be 'string'.
|
|
62
|
+
*/
|
|
63
|
+
type?: ParameterType | string;
|
|
71
64
|
}
|
|
72
|
-
|
|
73
65
|
/**
|
|
74
66
|
* Defines an indexed portion of a confidential document, allowing specific attributes to be searchable.
|
|
75
67
|
*/
|
|
@@ -81,14 +73,12 @@ export interface IndexedData {
|
|
|
81
73
|
};
|
|
82
74
|
sequence?: number;
|
|
83
75
|
}
|
|
84
|
-
|
|
85
76
|
/**
|
|
86
77
|
* Represents a complete Structured Document as defined by the Confidential Storage specification.
|
|
87
78
|
* This is the canonical format for all documents persisted in a vault.
|
|
88
79
|
* @see https://identity.foundation/confidential-storage/#structureddocument
|
|
89
80
|
*/
|
|
90
81
|
export interface ConfidentialStorageDoc {
|
|
91
|
-
// 'id' is inherited from RecordBase
|
|
92
82
|
id: string;
|
|
93
83
|
status: string;
|
|
94
84
|
/**
|
|
@@ -102,46 +92,36 @@ export interface ConfidentialStorageDoc {
|
|
|
102
92
|
versionId?: string;
|
|
103
93
|
vaultId?: string;
|
|
104
94
|
chunks?: number;
|
|
105
|
-
|
|
106
95
|
/** A number that MUST be incremented each time the document is updated. */
|
|
107
96
|
sequence: number;
|
|
108
|
-
|
|
109
97
|
/** Contains an array of indexed attributes protected with HMAC for blind queries. */
|
|
110
98
|
indexed?: IndexedData;
|
|
111
|
-
|
|
112
99
|
/** The main, potentially encrypted, content of the document. */
|
|
113
100
|
content?: Record<string, any>;
|
|
114
|
-
|
|
115
101
|
/** The JWE representation of the encrypted content. It could be a URL in case of a bucket is used to store the JWE or chunks */
|
|
116
102
|
jwe?: Record<string, any>;
|
|
117
|
-
|
|
118
103
|
/**
|
|
119
104
|
* Document-level created timestamp (outside encrypted `content`).
|
|
120
105
|
* This is distinct from any `meta` objects inside `content` (e.g., entry meta.claims).
|
|
121
106
|
*/
|
|
122
107
|
audit?: AuditInfo;
|
|
123
|
-
|
|
124
108
|
/**
|
|
125
109
|
* @deprecated Use `audit.created` instead.
|
|
126
110
|
*/
|
|
127
111
|
created?: string;
|
|
128
|
-
|
|
129
112
|
/**
|
|
130
113
|
* Document-level content type label (outside encrypted `content`).
|
|
131
114
|
* This is distinct from any `contentType` claims inside `content`.
|
|
132
115
|
*/
|
|
133
116
|
contentType?: string;
|
|
134
|
-
|
|
135
117
|
/**
|
|
136
118
|
* Optional research/routing tags kept outside encrypted `content`.
|
|
137
119
|
* These tags are intended for analytics/routing and may be mirrored back to API responses.
|
|
138
120
|
* Avoid free text in `display` unless explicitly policy-approved.
|
|
139
121
|
*/
|
|
140
122
|
tag?: MetaTagCoding[];
|
|
141
|
-
|
|
142
123
|
/** Policy-dependent research/analytics metadata, kept outside encrypted `content`. */
|
|
143
124
|
research?: ResearchInfo;
|
|
144
|
-
|
|
145
125
|
/**
|
|
146
126
|
* @deprecated Use `created`, `contentType`, and `research` instead.
|
|
147
127
|
* This legacy field is kept for backwards compatibility with older stored documents.
|
|
@@ -158,7 +138,6 @@ export interface ConfidentialStorageDoc {
|
|
|
158
138
|
tags?: string;
|
|
159
139
|
};
|
|
160
140
|
}
|
|
161
|
-
|
|
162
141
|
/**
|
|
163
142
|
* Represents a document whose sensitive content has been decrypted and is held
|
|
164
143
|
* in memory. The `jwe` property is removed, and the `content` is guaranteed to exist.
|
|
@@ -1,25 +1,22 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
'
|
|
5
|
-
'
|
|
6
|
-
'
|
|
7
|
-
'
|
|
8
|
-
'
|
|
9
|
-
'
|
|
10
|
-
'
|
|
11
|
-
'
|
|
12
|
-
'
|
|
13
|
-
'
|
|
14
|
-
'
|
|
15
|
-
'
|
|
16
|
-
'
|
|
17
|
-
'
|
|
18
|
-
'
|
|
19
|
-
'attachmentData' = 'Consent.attachment-data',
|
|
20
|
-
'attachmentId' = 'Consent.attachment-id',
|
|
1
|
+
export declare enum ClaimConsent {
|
|
2
|
+
'decision' = "Consent.decision",
|
|
3
|
+
'action' = "Consent.action",
|
|
4
|
+
'category' = "Consent.category",
|
|
5
|
+
'subject' = "Consent.subject",
|
|
6
|
+
'actorIdentifier' = "Consent.actor-identifier",
|
|
7
|
+
'actorRole' = "Consent.actor-role",
|
|
8
|
+
'date' = "Consent.date",
|
|
9
|
+
'periodStart' = "Consent.period-start",
|
|
10
|
+
'periodEnd' = "Consent.period-end",
|
|
11
|
+
'grantee' = "Consent.grantee",
|
|
12
|
+
'verifiedBy' = "Consent.verified-by",
|
|
13
|
+
'verifiedDate' = "Consent.verified-date",
|
|
14
|
+
'purpose' = "Consent.purpose",
|
|
15
|
+
'identifier' = "Consent.identifier",
|
|
16
|
+
'attachmentContentType' = "Consent.attachment-contentType",
|
|
17
|
+
'attachmentData' = "Consent.attachment-data",
|
|
18
|
+
'attachmentId' = "Consent.attachment-id"
|
|
21
19
|
}
|
|
22
|
-
|
|
23
20
|
/**
|
|
24
21
|
* Defines the structured, query-optimized format for storing a single, atomic consent rule
|
|
25
22
|
* in the vault (e.g., Firestore, CouchDB).
|
|
@@ -40,20 +37,17 @@ export interface ConsentRule {
|
|
|
40
37
|
* Value MUST be "org.hl7.fhir.api".
|
|
41
38
|
*/
|
|
42
39
|
'@context': 'org.hl7.fhir.api';
|
|
43
|
-
|
|
44
40
|
/**
|
|
45
41
|
* The decision of the rule: permit or deny.
|
|
46
42
|
* Derived from the `org.hl7.fhir.api.Consent.decision` claim.
|
|
47
43
|
*/
|
|
48
44
|
'Consent.decision': 'permit' | 'deny';
|
|
49
|
-
|
|
50
45
|
/**
|
|
51
46
|
* The data sections this rule applies to, as a comma-separated list of coded values.
|
|
52
47
|
* Derived from the `org.hl7.fhir.api.Consent.action` claim.
|
|
53
48
|
* Example claim: "LOINC|48765-2,SNOMED|12345"
|
|
54
49
|
*/
|
|
55
50
|
'Consent.action': string;
|
|
56
|
-
|
|
57
51
|
/**
|
|
58
52
|
* The type of consent document, as a comma-serpareted list of coded values.
|
|
59
53
|
* Used for classifying the consent itself (e.g., for release of information).
|
|
@@ -61,13 +55,11 @@ export interface ConsentRule {
|
|
|
61
55
|
* Example claim: "LOINC|59284-0,LOINC|57016-8"
|
|
62
56
|
*/
|
|
63
57
|
'Consent.category'?: string;
|
|
64
|
-
|
|
65
58
|
/**
|
|
66
59
|
* The subject of the consent.
|
|
67
60
|
* Derived from the `org.hl7.fhir.api.Consent.patient.identifier` claim.
|
|
68
61
|
*/
|
|
69
62
|
'Consent.subject': string;
|
|
70
|
-
|
|
71
63
|
/**
|
|
72
64
|
* The identifier of the actor (jurisdiction, organization, professional) this rule applies to.
|
|
73
65
|
* This is the party whose access is being controlled.
|
|
@@ -75,67 +67,55 @@ export interface ConsentRule {
|
|
|
75
67
|
* e.g., "urn:iso:3166-2:ES-CT", "did:web:hospital.example.com", "urn:email:dr-smith@example.com"
|
|
76
68
|
*/
|
|
77
69
|
'Consent.actor-identifier': string;
|
|
78
|
-
|
|
79
70
|
/**
|
|
80
71
|
* The role of the actor this rule applies to.
|
|
81
72
|
* Derived from a claim like `org.hl7.fhir.api.Consent.actor.role`.
|
|
82
73
|
* e.g., "doctor", "nurse"
|
|
83
74
|
*/
|
|
84
75
|
'Consent.actor-role': string;
|
|
85
|
-
|
|
86
76
|
/**
|
|
87
77
|
* The date the consent was granted (ISO 8601 Date).
|
|
88
78
|
* Derived from the `org.hl7.fhir.api.Consent.date` claim.
|
|
89
79
|
*/
|
|
90
80
|
'Consent.date': string;
|
|
91
|
-
|
|
92
81
|
/**
|
|
93
82
|
* Start of the consent's validity period (ISO 8601 DateTime).
|
|
94
83
|
* Note: This is different from the date the consent was signed.
|
|
95
84
|
* Derived from the start of the `org.hl7.fhir.api.Consent.period` claim.
|
|
96
85
|
*/
|
|
97
86
|
'Consent.period-start'?: string;
|
|
98
|
-
|
|
99
87
|
/**
|
|
100
88
|
* End of the consent's validity period (ISO 8601 DateTime).
|
|
101
89
|
* Derived from the end of the `org.hl7.fhir.api.Consent.period` claim.
|
|
102
90
|
*/
|
|
103
91
|
'Consent.period-end'?: string;
|
|
104
|
-
|
|
105
92
|
/**
|
|
106
93
|
* The party to whom the consent is granted.
|
|
107
94
|
* Use both 'Consent.actor-identifier' and 'Consent.actor-role' instead.
|
|
108
95
|
* Derived from the `org.hl7.fhir.api.Consent.grantee` claim.
|
|
109
96
|
*/
|
|
110
|
-
// 'Consent.grantee': string;
|
|
111
|
-
|
|
112
97
|
/**
|
|
113
98
|
* The DID of the entity (person or system) that verified the consent.
|
|
114
99
|
* Derived from the `org.hl7.fhir.api.Consent.verified-by` claim.
|
|
115
100
|
*/
|
|
116
101
|
'Consent.verified-by'?: string;
|
|
117
|
-
|
|
118
102
|
/**
|
|
119
103
|
* The date the consent was verified (ISO 8601 DateTime).
|
|
120
104
|
* Derived from the `org.hl7.fhir.api.Consent.verified-date` claim.
|
|
121
105
|
*/
|
|
122
106
|
'Consent.verified-date'?: string;
|
|
123
|
-
|
|
124
|
-
|
|
125
107
|
/**
|
|
126
108
|
* The purpose of use for this rule.
|
|
127
109
|
* Derived from the `org.hl7.fhir.api.Consent.purpose` claim.
|
|
128
110
|
* e.g., "ETREAT", "CAREMGT"
|
|
129
111
|
*/
|
|
130
112
|
'Consent.purpose': string;
|
|
131
|
-
|
|
132
113
|
/**
|
|
133
114
|
* The original Consent resource ID for auditing.
|
|
134
115
|
* Derived from the `org.hl7.fhir.api.Consent.identifier` claim.
|
|
135
116
|
*/
|
|
136
117
|
'Consent.identifier': string;
|
|
137
|
-
|
|
138
|
-
'Consent.attachment-
|
|
139
|
-
'Consent.attachment-
|
|
140
|
-
|
|
141
|
-
}
|
|
118
|
+
'Consent.attachment-contentType'?: string;
|
|
119
|
+
'Consent.attachment-data'?: string;
|
|
120
|
+
'Consent.attachment-id'?: string;
|
|
121
|
+
}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
// src/models/consent-rule.ts
|
|
2
|
+
export var ClaimConsent;
|
|
3
|
+
(function (ClaimConsent) {
|
|
4
|
+
ClaimConsent["decision"] = "Consent.decision";
|
|
5
|
+
ClaimConsent["action"] = "Consent.action";
|
|
6
|
+
ClaimConsent["category"] = "Consent.category";
|
|
7
|
+
ClaimConsent["subject"] = "Consent.subject";
|
|
8
|
+
ClaimConsent["actorIdentifier"] = "Consent.actor-identifier";
|
|
9
|
+
ClaimConsent["actorRole"] = "Consent.actor-role";
|
|
10
|
+
ClaimConsent["date"] = "Consent.date";
|
|
11
|
+
ClaimConsent["periodStart"] = "Consent.period-start";
|
|
12
|
+
ClaimConsent["periodEnd"] = "Consent.period-end";
|
|
13
|
+
ClaimConsent["grantee"] = "Consent.grantee";
|
|
14
|
+
ClaimConsent["verifiedBy"] = "Consent.verified-by";
|
|
15
|
+
ClaimConsent["verifiedDate"] = "Consent.verified-date";
|
|
16
|
+
ClaimConsent["purpose"] = "Consent.purpose";
|
|
17
|
+
ClaimConsent["identifier"] = "Consent.identifier";
|
|
18
|
+
ClaimConsent["attachmentContentType"] = "Consent.attachment-contentType";
|
|
19
|
+
ClaimConsent["attachmentData"] = "Consent.attachment-data";
|
|
20
|
+
ClaimConsent["attachmentId"] = "Consent.attachment-id";
|
|
21
|
+
})(ClaimConsent || (ClaimConsent = {}));
|
|
@@ -1,20 +1,15 @@
|
|
|
1
|
-
// Copyright 2025 Antifraud Services Inc. under the Apache License, Version 2.0.
|
|
2
|
-
// File: crypto-ts/models/crypto.ts
|
|
3
|
-
|
|
4
1
|
import { PublicJwk } from "../interfaces/Cryptography.types";
|
|
5
|
-
|
|
6
2
|
/**
|
|
7
3
|
* Describes a public key and its controller, for use in JWE recipients or DID documents.
|
|
8
4
|
* @see https://w3c-ccg.github.io/ld-cryptosuite-registry/
|
|
9
5
|
*/
|
|
10
6
|
export interface RecipientPublicKey {
|
|
11
|
-
type: string;
|
|
12
|
-
controller?: string;
|
|
7
|
+
type: string;
|
|
8
|
+
controller?: string;
|
|
13
9
|
publicKeyJwk: PublicJwk;
|
|
14
|
-
nbf?: number;
|
|
15
|
-
exp?: number;
|
|
10
|
+
nbf?: number;
|
|
11
|
+
exp?: number;
|
|
16
12
|
}
|
|
17
|
-
|
|
18
13
|
/**
|
|
19
14
|
* Represents a full cryptographic key pair, including the private key material.
|
|
20
15
|
* This format is for internal use by the KMS and should never be exposed.
|
|
@@ -23,7 +18,6 @@ export interface KeyPair extends RecipientPublicKey {
|
|
|
23
18
|
/** The raw private key bytes. This MUST be protected at rest (encrypted). */
|
|
24
19
|
privateKeyBytes: Uint8Array;
|
|
25
20
|
}
|
|
26
|
-
|
|
27
21
|
/**
|
|
28
22
|
|
|
29
23
|
* Contains all cryptographic material for a single tenant, managed by the Gateway Service.
|
|
@@ -33,11 +27,9 @@ export interface TenantCryptoData {
|
|
|
33
27
|
/** A cache of public keys of recipients this tenant frequently interacts with. */
|
|
34
28
|
recipients: RecipientPublicKey[];
|
|
35
29
|
/** A protected PIN/Password used to derive a key for local cryptographic operations. */
|
|
36
|
-
passKey: Uint8Array;
|
|
30
|
+
passKey: Uint8Array;
|
|
37
31
|
/** The history of encryption key pairs used by the tenant (for key rotation). The last one is the current key. */
|
|
38
32
|
keyAgreement: KeyPair[];
|
|
39
33
|
/** The history of signature key pairs used by the tenant (for key rotation). The last one is the current key. */
|
|
40
34
|
verificationMethod: KeyPair[];
|
|
41
35
|
}
|
|
42
|
-
|
|
43
|
-
|
|
@@ -0,0 +1,133 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* A fingerprint of a specific device, used for binding a license to it.
|
|
3
|
+
*/
|
|
4
|
+
export interface DeviceInfo {
|
|
5
|
+
/**
|
|
6
|
+
* A stable, unique identifier for the specific app installation, generated by the client.
|
|
7
|
+
* This is the primary key for device binding.
|
|
8
|
+
*/
|
|
9
|
+
clientInstanceId: string;
|
|
10
|
+
/** The operating system of the device (e.g., "iOS", "Android", "Windows"). */
|
|
11
|
+
os?: string;
|
|
12
|
+
/** The specific OS version. */
|
|
13
|
+
osVersion?: string;
|
|
14
|
+
/** The manufacturer of the device (e.g., "Apple", "Samsung"). */
|
|
15
|
+
manufacturer?: string;
|
|
16
|
+
/** The model of the device (e.g., "iPhone14,6"). */
|
|
17
|
+
model?: string;
|
|
18
|
+
}
|
|
19
|
+
/**
|
|
20
|
+
* A set of rules that a device must match to be eligible to activate a license.
|
|
21
|
+
*/
|
|
22
|
+
export interface DeviceRestrictions {
|
|
23
|
+
/** A regex pattern for the allowed manufacturer(s). */
|
|
24
|
+
manufacturer?: string;
|
|
25
|
+
/** A regex pattern for the allowed model(s). */
|
|
26
|
+
model?: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* Represents a single device activation license, enabling a user to register a specific device
|
|
30
|
+
* for a tenant's service. It governs access based on user class, platform, and subscription terms.
|
|
31
|
+
* Timestamps are stored as Unix epoch seconds (numeric).
|
|
32
|
+
* All property names follow the camelCase convention.
|
|
33
|
+
*/
|
|
34
|
+
export interface DeviceLicense {
|
|
35
|
+
/**
|
|
36
|
+
* The unique identifier for this license document in the vault.
|
|
37
|
+
*/
|
|
38
|
+
id: string;
|
|
39
|
+
/**
|
|
40
|
+
* The logical identifier of the tenant organization that owns this license.
|
|
41
|
+
* @example "acme"
|
|
42
|
+
*/
|
|
43
|
+
tenantId: string;
|
|
44
|
+
/**
|
|
45
|
+
* Identifier for the purchase order or invoice that generated this license.
|
|
46
|
+
* All licenses created from the same purchase will share the same orderId.
|
|
47
|
+
* @example "inv_12345"
|
|
48
|
+
*/
|
|
49
|
+
orderId: string;
|
|
50
|
+
/**
|
|
51
|
+
* A secure, single-use code given to a user to activate a device.
|
|
52
|
+
* This is generated when the license status becomes 'issued'.
|
|
53
|
+
*/
|
|
54
|
+
activationCode?: string;
|
|
55
|
+
/**
|
|
56
|
+
* **CRITICAL:** Defines the class of user this license is intended for.
|
|
57
|
+
* This allows for stratified licensing (e.g., selling "professional seats"
|
|
58
|
+
* separately from "individual access").
|
|
59
|
+
*/
|
|
60
|
+
userClass: 'employee' | 'individual';
|
|
61
|
+
/**
|
|
62
|
+
* **Specifies the functional category for an 'employee' license.**
|
|
63
|
+
* This determines the set of roles the user is permitted to have.
|
|
64
|
+
* This field MUST be present if userClass is 'employee'.
|
|
65
|
+
* It is typically undefined for 'individual' licenses.
|
|
66
|
+
* @example "medicalStaff", "firstResponder", "admin"
|
|
67
|
+
*/
|
|
68
|
+
userCategory?: string;
|
|
69
|
+
/**
|
|
70
|
+
* Defines the platform this license is for.
|
|
71
|
+
*/
|
|
72
|
+
type: 'mobile' | 'web';
|
|
73
|
+
/**
|
|
74
|
+
* The current lifecycle status of the license.
|
|
75
|
+
* - 'available': Fresh license, ready to be assigned to a user.
|
|
76
|
+
* - 'issued': Assigned to a user and an activation code has been generated.
|
|
77
|
+
* - 'active': The user has successfully used the activation code to register a device.
|
|
78
|
+
* - 'inactive': Deactivated by an administrator or user, or has expired.
|
|
79
|
+
*/
|
|
80
|
+
status: 'available' | 'issued' | 'active' | 'inactive';
|
|
81
|
+
/**
|
|
82
|
+
* The subscription or purchase plan associated with this license.
|
|
83
|
+
* @example "premium_annual" | "standard_monthly" | "trial"
|
|
84
|
+
*/
|
|
85
|
+
plan: string;
|
|
86
|
+
/**
|
|
87
|
+
* Defines the renewal period for the license.
|
|
88
|
+
* '1m' for one month, '12m' for one year.
|
|
89
|
+
* A null value indicates the license does not auto-renew.
|
|
90
|
+
*/
|
|
91
|
+
renewalCycle: '1m' | '12m' | null;
|
|
92
|
+
/**
|
|
93
|
+
* If true, the license can be reactivated after being made inactive
|
|
94
|
+
* (e.g., after a user clicks "Log out everywhere"). If false, an inactive
|
|
95
|
+
* license cannot be used again.
|
|
96
|
+
*/
|
|
97
|
+
reactivationEnabled: boolean;
|
|
98
|
+
/**
|
|
99
|
+
* "Issued At" timestamp. The time the license was assigned to a user, as a Unix epoch in seconds.
|
|
100
|
+
* Set when status moves to 'issued'.
|
|
101
|
+
*/
|
|
102
|
+
issuedAt?: number;
|
|
103
|
+
/**
|
|
104
|
+
* "Activation Time" timestamp. The time the license was successfully used to register a device,
|
|
105
|
+
* as a Unix epoch in seconds. Set when status moves to 'active'.
|
|
106
|
+
*/
|
|
107
|
+
activatedAt?: number;
|
|
108
|
+
/**
|
|
109
|
+
* "Expiration Time" timestamp. The time at which the license and the device's authorization
|
|
110
|
+
* expire, as a Unix epoch in seconds.
|
|
111
|
+
*/
|
|
112
|
+
exp: number;
|
|
113
|
+
/**
|
|
114
|
+
* The unique identifier of the user (e.g., employeeId or customerId) to whom the license is issued.
|
|
115
|
+
* Populated when the status becomes 'issued'.
|
|
116
|
+
*/
|
|
117
|
+
subjectId?: string;
|
|
118
|
+
/**
|
|
119
|
+
* The unique identifier (`client_id`) of the device registered with this license.
|
|
120
|
+
* Populated when the status becomes 'active'.
|
|
121
|
+
*/
|
|
122
|
+
deviceId?: string;
|
|
123
|
+
/**
|
|
124
|
+
* Optional, pre-defined restrictions on which devices are allowed to activate this license.
|
|
125
|
+
* Set at the time of license creation.
|
|
126
|
+
*/
|
|
127
|
+
deviceRestrictions?: DeviceRestrictions;
|
|
128
|
+
/**
|
|
129
|
+
* A fingerprint of the device that successfully activated this license.
|
|
130
|
+
* This is captured upon activation and is used to lock the license to that specific device.
|
|
131
|
+
*/
|
|
132
|
+
deviceInfo?: DeviceInfo;
|
|
133
|
+
}
|