gdc-common-utils-ts 1.0.1
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/PUBLISHING.md +33 -0
- package/__tests__/AesManager.test.ts +53 -0
- package/__tests__/CryptographyService.test.ts +194 -0
- package/__tests__/bundle.test.ts +29 -0
- package/__tests__/content.test.ts +72 -0
- package/__tests__/crypto-encode-decode.test.ts +52 -0
- package/__tests__/crypto-hmac.test.ts +21 -0
- package/__tests__/did-generateServiceId.errors.test.ts +8 -0
- package/__tests__/did-generateServiceId.test.ts +18 -0
- package/__tests__/models-clinical-sections.test.ts +32 -0
- package/__tests__/models-multibase58.test.ts +33 -0
- package/__tests__/multibase58.errors.test.ts +7 -0
- package/__tests__/multibase58.test.ts +28 -0
- package/__tests__/multibasehash.test.ts +25 -0
- package/__tests__/utils-actor.test.ts +22 -0
- package/__tests__/utils-base-convert.test.ts +57 -0
- package/__tests__/utils-baseN.test.ts +40 -0
- package/__tests__/utils-did-extra.test.ts +33 -0
- package/__tests__/utils-format-converter.test.ts +87 -0
- package/__tests__/utils-jwt.test.ts +57 -0
- package/__tests__/utils-manager-error.test.ts +11 -0
- package/__tests__/utils-normalize.test.ts +15 -0
- package/__tests__/utils-object-convert.test.ts +38 -0
- package/__tests__/utils-string-convert.test.ts +20 -0
- package/__tests__/utils-string-utils.test.ts +25 -0
- package/__tests__/utils-url.test.ts +21 -0
- package/babel.config.cjs +5 -0
- package/jest.config.ts +46 -0
- package/package.json +36 -0
- package/src/AesManager.ts +82 -0
- package/src/CryptographyService.ts +461 -0
- package/src/JweManager.ts.txt +365 -0
- package/src/KmsService.txt +493 -0
- package/src/constants/Schemas.ts +61 -0
- package/src/constants/index.ts +1 -0
- package/src/constants/schemaorg.ts +193 -0
- package/src/cryptoDecode.ts +104 -0
- package/src/cryptoEncode.ts +36 -0
- package/src/cryptography.abstract.ts +29 -0
- package/src/hmac.ts +15 -0
- package/src/index.ts +3 -0
- package/src/interfaces/Cryptography.types.ts +131 -0
- package/src/interfaces/ICryptoHelper.ts +33 -0
- package/src/interfaces/ICryptography.ts +177 -0
- package/src/interfaces/IWallet.ts +62 -0
- package/src/interfaces/MlDsa.ts +25 -0
- package/src/interfaces/MlKem.ts +18 -0
- package/src/models/aes.ts +93 -0
- package/src/models/auth.ts +38 -0
- package/src/models/bundle.ts +152 -0
- package/src/models/bundle.txt +93 -0
- package/src/models/clinical-sections.en.ts +82 -0
- package/src/models/clinical-sections.ts +64 -0
- package/src/models/comm.ts +63 -0
- package/src/models/confidential-job.ts +100 -0
- package/src/models/confidential-message.ts +137 -0
- package/src/models/confidential-storage.ts +170 -0
- package/src/models/consent-rule.ts +141 -0
- package/src/models/crypto.ts +43 -0
- package/src/models/device-license.ts +161 -0
- package/src/models/did.ts +81 -0
- package/src/models/index.ts +31 -0
- package/src/models/indexing.ts +20 -0
- package/src/models/issue.ts +85 -0
- package/src/models/jsonapi.ts +19 -0
- package/src/models/jwe.ts +132 -0
- package/src/models/jwk.ts +50 -0
- package/src/models/jws.ts +42 -0
- package/src/models/jwt.ts +15 -0
- package/src/models/multibase58.ts +46 -0
- package/src/models/oidc4ida.common.model.ts +39 -0
- package/src/models/oidc4ida.document.model.ts +61 -0
- package/src/models/oidc4ida.electronicRecord.model.ts +86 -0
- package/src/models/oidc4ida.evidence.model.ts +69 -0
- package/src/models/openid-device.ts +146 -0
- package/src/models/operation-outcome.ts +34 -0
- package/src/models/params.ts +142 -0
- package/src/models/resource-document.ts +21 -0
- package/src/models/response.ts +5 -0
- package/src/models/urlPath.ts +76 -0
- package/src/models/verifiable-credential.ts +52 -0
- package/src/types/noble-hashes.d.ts +4 -0
- package/src/utils/actor.ts +52 -0
- package/src/utils/base-convert.ts +77 -0
- package/src/utils/baseN.ts +203 -0
- package/src/utils/bundle.ts +30 -0
- package/src/utils/content.ts +66 -0
- package/src/utils/did.ts +155 -0
- package/src/utils/format-converter.ts +119 -0
- package/src/utils/index.ts +13 -0
- package/src/utils/jwt.ts +165 -0
- package/src/utils/manager-error.ts +27 -0
- package/src/utils/multibase58.ts +46 -0
- package/src/utils/multibasehash.ts +28 -0
- package/src/utils/normalize.ts +43 -0
- package/src/utils/object-convert.ts +57 -0
- package/src/utils/string-convert.ts +71 -0
- package/src/utils/string-utils.ts +70 -0
- package/src/utils/url.ts +46 -0
- package/tsconfig.json +13 -0
|
@@ -0,0 +1,132 @@
|
|
|
1
|
+
// Copyright 2025 Antifraud Services Inc. under the Apache License, Version 2.0.
|
|
2
|
+
// File: crypto-ts/models/jwe.ts
|
|
3
|
+
|
|
4
|
+
import { JWK } from "./jwk";
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents the core components of a JWE (JSON Web Encryption) structure,
|
|
8
|
+
* based on RFC 7516. This is the standard for encrypted data.
|
|
9
|
+
*/
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* Decoded protected header claims in a JWE.
|
|
13
|
+
* @see https://datatracker.ietf.org/doc/html/rfc7516#section-4.1
|
|
14
|
+
*/
|
|
15
|
+
export interface ProtectedHeadersJWE {
|
|
16
|
+
alg?: string; // CEK encryption algorithm
|
|
17
|
+
enc?: string; // Content encryption algorithm (e.g., "A256GCM")
|
|
18
|
+
cty?: string; // Content type
|
|
19
|
+
jwk?: JWK; // Senders JWK
|
|
20
|
+
typ?: string; // Type, e.g., "didcomm-envelope-enc"
|
|
21
|
+
kid?: string; // Recipient's key ID
|
|
22
|
+
skid?: string; // Sender's key ID
|
|
23
|
+
zip?: string; // Compression algorithm
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
/**
|
|
27
|
+
* Unprotected headers that are not integrity protected.
|
|
28
|
+
*/
|
|
29
|
+
export interface UnprotectedHeadersJWE {
|
|
30
|
+
jku?: string; // JWK Set URL
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/**
|
|
34
|
+
* Represents the data for a single recipient of the JWE.
|
|
35
|
+
*/
|
|
36
|
+
export interface RecipientDataJWE {
|
|
37
|
+
encrypted_key?: string;
|
|
38
|
+
header: {
|
|
39
|
+
alg: string;
|
|
40
|
+
kid: string;
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
/**
|
|
45
|
+
* Represents the protected (integrity-protected) header of a JWE.
|
|
46
|
+
* These parameters are combined with the AAD (Additional Authenticated Data)
|
|
47
|
+
* to ensure they are not tampered with.
|
|
48
|
+
*
|
|
49
|
+
* JWE defines two algorithms:
|
|
50
|
+
* - 'alg': The algorithm for key encryption (wrapping the CEK). In our case, a PQC KEM like Kyber.
|
|
51
|
+
* This is defined per-recipient, not in the main protected header.
|
|
52
|
+
* - 'enc': The algorithm for content encryption (e.g., 'A256GCM').
|
|
53
|
+
*/
|
|
54
|
+
export interface ProtectedHeadersJWE {
|
|
55
|
+
/** Algorithm for Content Encryption Key (CEK) wrapping (e.g., Kyber KEM). Defined per-recipient. */
|
|
56
|
+
alg?: string;
|
|
57
|
+
/** Content Type of the payload. */
|
|
58
|
+
cty?: string;
|
|
59
|
+
/** Encryption Algorithm for the content (e.g., 'A256GCM'). */
|
|
60
|
+
enc?: string;
|
|
61
|
+
/** Key ID of the recipient's public key. */
|
|
62
|
+
kid?: string;
|
|
63
|
+
/** Sender's public key identifier. */
|
|
64
|
+
skid?: string;
|
|
65
|
+
/** Type of the JWE (e.g., 'didcomm-envelope-enc'). */
|
|
66
|
+
typ?: string;
|
|
67
|
+
/** Compression algorithm ('DEF' for DEFLATE). */
|
|
68
|
+
zip?: string;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Represents the unprotected header of a JWE.
|
|
73
|
+
* These parameters are not integrity-protected.
|
|
74
|
+
*/
|
|
75
|
+
export interface UnprotectedHeadersJWE {
|
|
76
|
+
/** JWK Set URL, a URL pointing to a set of keys. */
|
|
77
|
+
jku?: string;
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
/**
|
|
81
|
+
* Represents the data specific to a single recipient of a JWE.
|
|
82
|
+
*/
|
|
83
|
+
export interface RecipientDataJWE {
|
|
84
|
+
/** The Content Encryption Key (CEK), encrypted for this specific recipient. Base64URL encoded. */
|
|
85
|
+
encrypted_key?: string;
|
|
86
|
+
/** Unprotected header parameters specific to this recipient. */
|
|
87
|
+
header: {
|
|
88
|
+
/** Key Encryption Algorithm used for this recipient (e.g., 'kyber-768-r3'). */
|
|
89
|
+
alg: string;
|
|
90
|
+
/** Key ID of the recipient's public key (thumbprint of the JWK). */
|
|
91
|
+
kid: string;
|
|
92
|
+
};
|
|
93
|
+
}
|
|
94
|
+
|
|
95
|
+
/**
|
|
96
|
+
* Represents a JWE object before encryption.
|
|
97
|
+
* It contains the plaintext data and the configuration for encryption.
|
|
98
|
+
*/
|
|
99
|
+
export interface UnencryptedJWE {
|
|
100
|
+
/** The decoded protected header object. This will be base64url encoded. */
|
|
101
|
+
protectHdersDecoded?: ProtectedHeadersJWE;
|
|
102
|
+
/** The unprotected header object. */
|
|
103
|
+
unprotected?: UnprotectedHeadersJWE;
|
|
104
|
+
/** The list of recipients for whom the content is encrypted. */
|
|
105
|
+
recipients: RecipientDataJWE[];
|
|
106
|
+
/**
|
|
107
|
+
* The plaintext data to be encrypted, already serialized.
|
|
108
|
+
* For structured data (like a TenantConfig), this MUST be the result of `JSON.stringify`.
|
|
109
|
+
* For binary data (like a PDF), this MUST be a Uint8Array.
|
|
110
|
+
* The cryptography layer does NOT perform serialization.
|
|
111
|
+
*/
|
|
112
|
+
plaintext: string | Uint8Array;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/**
|
|
116
|
+
* Represents a JWE (JSON Web Encryption) in the General JSON Serialization format.
|
|
117
|
+
* This structure supports multiple recipients.
|
|
118
|
+
*/
|
|
119
|
+
export interface JweObject {
|
|
120
|
+
/** Base64URL encoded, integrity-protected header. */
|
|
121
|
+
protected: string;
|
|
122
|
+
/** Unprotected header (not integrity-protected). */
|
|
123
|
+
unprotected?: UnprotectedHeadersJWE;
|
|
124
|
+
/** Array of recipient-specific data. */
|
|
125
|
+
recipients: RecipientDataJWE[];
|
|
126
|
+
/** Initialization Vector, Base64URL encoded. */
|
|
127
|
+
iv: string;
|
|
128
|
+
/** The encrypted plaintext, Base64URL encoded. */
|
|
129
|
+
ciphertext: string;
|
|
130
|
+
/** The authentication tag, Base64URL encoded. */
|
|
131
|
+
tag: string;
|
|
132
|
+
}
|
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// Copyright 2025 Antifraud Services Inc. under the Apache License, Version 2.0.
|
|
2
|
+
// File: crypto-ts/models/jwk.ts
|
|
3
|
+
|
|
4
|
+
/**
|
|
5
|
+
* Represents a JSON Web Key (JWK), a standard format for representing cryptographic keys.
|
|
6
|
+
* This interface supports both symmetric (oct) and asymmetric keys (EC, RSA, OKP, and Post-Quantum).
|
|
7
|
+
* Based on RFC 7517.
|
|
8
|
+
*/
|
|
9
|
+
export interface JWK {
|
|
10
|
+
/** Algorithm intended for use with a ML-DSA or other signature keys (e.g., 'ES256'). */
|
|
11
|
+
alg?: string;
|
|
12
|
+
/** Key Operations for which the key is intended (e.g., ['sign', 'verify']). */
|
|
13
|
+
key_ops?: string[];
|
|
14
|
+
/** Key ID - a unique identifier for the key (e.g., RFC 7638 thumbprint). */
|
|
15
|
+
kid?: string;
|
|
16
|
+
/** Key Type (e.g., 'AKP' for ML-DSA, 'OKP' for ML-KEM, 'EC' for Elliptic Curve, 'RSA', ...). */
|
|
17
|
+
kty?: string;
|
|
18
|
+
/** Public Key Use ('sig' for signature, 'enc' for encryption). */
|
|
19
|
+
use?: string;
|
|
20
|
+
|
|
21
|
+
// --- Asymmetric Key Parameters ---
|
|
22
|
+
/** The curve for an ML-KEM or EC key (e.g., 'P-256'). */
|
|
23
|
+
crv?: string;
|
|
24
|
+
/** The private key component for ML-KEM or EC asymmetric keys. */
|
|
25
|
+
d?: string;
|
|
26
|
+
/** The public key for ML-KEM or 'x' coordinate for an EC key. */
|
|
27
|
+
x?: string;
|
|
28
|
+
/** The public 'y' coordinate for an EC key. */
|
|
29
|
+
y?: string;
|
|
30
|
+
|
|
31
|
+
// --- Post-Quantum ML-DSA (Dilithium) Parameters ---
|
|
32
|
+
/** The public key component for an ML-DSA key. */
|
|
33
|
+
pub?: string;
|
|
34
|
+
/** The private key component for an ML-DSA key. */
|
|
35
|
+
priv?: string;
|
|
36
|
+
|
|
37
|
+
// --- Symmetric Key Parameters ---
|
|
38
|
+
/** The symmetric key value. */
|
|
39
|
+
k?: string;
|
|
40
|
+
|
|
41
|
+
/** Any other custom JWK properties. */
|
|
42
|
+
[propName: string]: unknown;
|
|
43
|
+
}
|
|
44
|
+
|
|
45
|
+
/**
|
|
46
|
+
* Represents a set of JSON Web Keys (JWKs).
|
|
47
|
+
*/
|
|
48
|
+
export interface JwkSet {
|
|
49
|
+
keys: JWK[];
|
|
50
|
+
}
|
|
@@ -0,0 +1,42 @@
|
|
|
1
|
+
// Copyright 2025 Antifraud Services Inc. under the Apache License, Version 2.0.
|
|
2
|
+
// File: crypto-ts/models/jws.ts
|
|
3
|
+
|
|
4
|
+
import { JWK } from './jwk';
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Represents the header parameters of a JSON Web Signature (JWS).
|
|
8
|
+
*/
|
|
9
|
+
export interface JwsHeader {
|
|
10
|
+
/** Algorithm used to secure the JWS. Must not be "none". */
|
|
11
|
+
alg: string;
|
|
12
|
+
/** Key ID that indicates which key was used for the JWS signature. */
|
|
13
|
+
kid: string;
|
|
14
|
+
/** Content type, usually "didcomm-signed+json". */
|
|
15
|
+
cty?: string;
|
|
16
|
+
/** Type of the message, usually "jwt". */
|
|
17
|
+
typ?: string;
|
|
18
|
+
/** The full public key, used in bootstrapping scenarios. */
|
|
19
|
+
jwk?: JWK;
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
/**
|
|
23
|
+
* Represents a signature entry in a JWS using the General JSON Serialization format.
|
|
24
|
+
*/
|
|
25
|
+
export interface JwsDetachedSignParts {
|
|
26
|
+
/** The Base64URL encoded protected (signed) header. */
|
|
27
|
+
protected: string;
|
|
28
|
+
/** The Base64URL encoded signature. */
|
|
29
|
+
signature: string;
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
/**
|
|
33
|
+
* Represents a JWS (JSON Web Signature) in the General JSON Serialization format.
|
|
34
|
+
* This structure supports multiple signatures.
|
|
35
|
+
*/
|
|
36
|
+
export interface JwsMultiSign {
|
|
37
|
+
/** The Base64URL encoded payload. */
|
|
38
|
+
payload: string;
|
|
39
|
+
/** An array of one or more signatures. */
|
|
40
|
+
signatures: JwsDetachedSignParts[];
|
|
41
|
+
}
|
|
42
|
+
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
// Copyright 2025 Antifraud Services Inc. under the Apache License, Version 2.0.
|
|
2
|
+
// File: crypto-ts/models/jwt.ts
|
|
3
|
+
|
|
4
|
+
import { JwsDetachedSignParts } from "./jws";
|
|
5
|
+
|
|
6
|
+
export interface JwtCompactParts extends JwsDetachedSignParts {
|
|
7
|
+
payload: string,
|
|
8
|
+
}
|
|
9
|
+
|
|
10
|
+
export interface DataCompactJWT {
|
|
11
|
+
protected: object, // header protected by the signature (compact does not have unprotected header but JSON JWT does)
|
|
12
|
+
payload: object,
|
|
13
|
+
signature?: Uint8Array,
|
|
14
|
+
}
|
|
15
|
+
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
// Copyright 2025 Antifraud Services Inc. under the Apache License, Version 2.0.
|
|
2
|
+
// File: crypto-ts/multibase58.ts
|
|
3
|
+
|
|
4
|
+
import baseX from "base-x";
|
|
5
|
+
|
|
6
|
+
const BASE58_BTC_ALPHABET = "123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz";
|
|
7
|
+
const base58btc = baseX(BASE58_BTC_ALPHABET);
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* Encode bytes into multibase base58btc string (prefixed with 'z').
|
|
11
|
+
* Equivalent to multiformats base58btc.encode.
|
|
12
|
+
*/
|
|
13
|
+
export function encodeMultibase58btc(data: Uint8Array): string {
|
|
14
|
+
return "z" + base58btc.encode(Buffer.from(data));
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
/**
|
|
18
|
+
* Decode a multibase base58btc string (must start with 'z').
|
|
19
|
+
* Equivalent to multiformats base58btc.decode.
|
|
20
|
+
*/
|
|
21
|
+
export function decodeMultibase58btc(multibaseStr: string): Uint8Array {
|
|
22
|
+
if (!multibaseStr.startsWith("z")) {
|
|
23
|
+
throw new Error("Invalid multibase58btc string: missing 'z' prefix");
|
|
24
|
+
}
|
|
25
|
+
return new Uint8Array(base58btc.decode(multibaseStr.slice(1)));
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
// HEX ➜ multibase base58btc (quita guiones si los hay)
|
|
29
|
+
export function encodeHexToMultibase58btc(hexStr: string): string {
|
|
30
|
+
const hexClean = hexStr.replace(/-/g, "").toLowerCase();
|
|
31
|
+
if (!/^[0-9a-f]{32}$/i.test(hexClean)) throw new Error("Invalid 16-byte hex string");
|
|
32
|
+
const bytes = new Uint8Array(hexClean.match(/.{1,2}/g)!.map(b => parseInt(b, 16)));
|
|
33
|
+
return encodeMultibase58btc(bytes);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// multibase base58btc ➜ hex (no hyppens)
|
|
37
|
+
export function decodeMultibase58btcToHex(b58str: string): string {
|
|
38
|
+
const bytes = decodeMultibase58btc(b58str);
|
|
39
|
+
return Array.from(bytes).map(b => b.toString(16).padStart(2, "0")).join("");
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
// multibase base58btc ➜ UUID (with hyppens)
|
|
43
|
+
export function decodeMultibase58btcToUUID(b58str: string): string {
|
|
44
|
+
const hex = decodeMultibase58btcToHex(b58str);
|
|
45
|
+
return `${hex.slice(0, 8)}-${hex.slice(8, 12)}-${hex.slice(12, 16)}-${hex.slice(16, 20)}-${hex.slice(20)}`;
|
|
46
|
+
}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
// Copyright 2025 Antifraud Services Inc. under the Apache License, Version 2.0.
|
|
2
|
+
// File: crypto-ts/models/oidc4ida.common.model.ts
|
|
3
|
+
|
|
4
|
+
/** Digest object represents a cryptographic hash of some bytes (e.g.: the content of a document).
|
|
5
|
+
* It has 'alg' and 'value' (Base64 encoded, not hexadecimal such as in W3C format).
|
|
6
|
+
*/
|
|
7
|
+
export interface DigestResultOpenIdData {
|
|
8
|
+
alg: string; // REQUIRED. Specifies the algorithm used for the calculation of the cryptographic hash. The algorithm has been negotiated previously between RP and OP during Client Registration or Management.
|
|
9
|
+
value: string; // REQUIRED. Base64 encoded representation of the cryptographic hash.
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
/** Attachment OpenID
|
|
13
|
+
* The "digest" is REQUIRED: digest.alg and digest.value (Base64 encoded, not Base64Url).
|
|
14
|
+
* The "url" is REQUIRED to be "urn:uuid:<uuidv4>" for the resource/record (same as the FHIR "fullUrl" property with urn:uuid:<uuidv4>).
|
|
15
|
+
*/
|
|
16
|
+
export interface AttachmentExternalDLT {
|
|
17
|
+
digest: DigestResultOpenIdData; // REQUIRED. JSON object representing a cryptographic hash of the document content.
|
|
18
|
+
url?: string; // URI where the content can be recovered (NOTE: do not store on blockchain personal identifiers, just the URN with the UUID of the record/resoruce)
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** CheckDetails is a JSON array representing the checks done in relation to the evidence.
|
|
22
|
+
* The "check_method" is REQUIRED (see https://bitbucket.org/openid/ekyc-ida/wiki/identifiers#check_methods):
|
|
23
|
+
* - check_method: REQUIRED. String representing the check done, this includes processes such as checking the authenticity of the document, or verifying the user's biometric against an identity document (e.g.: vcrypt, vdig, vpip, vpvp...)
|
|
24
|
+
* - organization: OPTIONAL. String denoting the legal entity that performed the check. This SHOULD be included if the OP did not perform the check itself.
|
|
25
|
+
* - txn: OPTIONAL. Identifier referring to the identity verification transaction. The OP MUST ensure that this is present when evidence_ref element is used. The OP MUST ensure that the transaction identifier can be resolved into transaction details during an audit.
|
|
26
|
+
* - time: OPTIONAL. Time stamp in ISO 8601 [ISO8601] YYYY-MM-DDThh:mm[:ss]TZD format representing the date when the check was completed.
|
|
27
|
+
*/
|
|
28
|
+
export interface CheckDetails {
|
|
29
|
+
check_method: string; // REQUIRED. String representing the check done, this includes processes such as checking the authenticity of the document, or verifying the user's biometric against an identity document. For information on predefined check_details values see Section 14.
|
|
30
|
+
organization?: string; // OPTIONAL. String (did:web or URN) denoting the legal entity that performed the check. This SHOULD be included if the OP did not perform the check itself.
|
|
31
|
+
txn?: string; // OPTIONAL. Identifier referring to the identity verification transaction. The OP MUST ensure that this is present when evidence_ref element is used. The OP MUST ensure that the transaction identifier can be resolved into transaction details during an audit.
|
|
32
|
+
time?: string; // OPTIONAL. Time stamp in ISO 8601 [ISO8601] YYYY-MM-DDThh:mm[:ss]TZD format representing the date when the check was completed.
|
|
33
|
+
}
|
|
34
|
+
|
|
35
|
+
/** 'organization' is the organization ID which performed the verification on behalf of the OP */
|
|
36
|
+
export interface VerifierDLT {
|
|
37
|
+
organization: string; // organization (did:web or URN) which performed the verification on behalf of the OP.
|
|
38
|
+
txn?: string; // evidence transaction ID (base58) for audit (added by SC)
|
|
39
|
+
}
|
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
// Copyright 2025 Antifraud Services Inc. under the Apache License, Version 2.0.
|
|
2
|
+
// File: crypto-ts/models/oidc4ida.document.model.ts
|
|
3
|
+
|
|
4
|
+
import { AttachmentExternalDLT, CheckDetails, VerifierDLT } from './oidc4ida.common.model';
|
|
5
|
+
import { IssuerElectronicRecordDLT } from './oidc4ida.electronicRecord.model';
|
|
6
|
+
|
|
7
|
+
/** Common for Document and Bill evidences */
|
|
8
|
+
export interface EvidenceCommonSubElementDLT {
|
|
9
|
+
method: string; // REQUIRED. The method used to verify it: pipp (Physical In-Person Proofing), sripp (Supervised remote In-Person Proofing), eid (Online verification of an electronic ID card), uripp (Unsupervised remote in-person proofing with video capture of the ID document, user self-portrait video and liveness checks). Predefined values are given in Verification Methods
|
|
10
|
+
time?: string; // OPTIONAL. Time stamp in ISO 8601:2004 [ISO8601-2004] YYYY-MM-DDThh:mm[:ss]TZD format representing the date when it was verified
|
|
11
|
+
}
|
|
12
|
+
|
|
13
|
+
/** Predefined method values are given in Verification Methods (https://bitbucket.org/openid/ekyc-ida/wiki/identifiers)
|
|
14
|
+
* - pipp (Physical In-Person Proofing)
|
|
15
|
+
* - sripp (Supervised remote In-Person Proofing)
|
|
16
|
+
* - eid (Online verification of an electronic ID card)
|
|
17
|
+
* - uripp (Unsupervised remote in-person proofing with video capture of the ID document, user self-portrait video and liveness checks).
|
|
18
|
+
*/
|
|
19
|
+
export interface EvidenceDocumentDLT extends
|
|
20
|
+
EvidenceCommonSubElementDLT // method, time
|
|
21
|
+
{
|
|
22
|
+
attachments?: AttachmentExternalDLT; // OPTIONAL. Representing proofs of attachments like photocopies of documents or certificates.
|
|
23
|
+
check_details?: CheckDetails[]; // OPTIONAL. Checks done in relation to the evidence. https://bitbucket.org/openid/ekyc-ida/wiki/identifiers
|
|
24
|
+
document_details?: DocumentDetailsDLT; // OPTIONAL. Object representing the id document used to perform the identity verification.
|
|
25
|
+
method: string; // REQUIRED. The method used to verify it: pipp (Physical In-Person Proofing), sripp (Supervised remote In-Person Proofing), eid (Online verification of an electronic ID card), uripp (Unsupervised remote in-person proofing with video capture of the ID document, user self-portrait video and liveness checks). Predefined values are given in Verification Methods
|
|
26
|
+
time?: string; // OPTIONAL. Time stamp in ISO 8601:2004 [ISO8601-2004] YYYY-MM-DDThh:mm[:ss]TZD format representing the date when it was verified
|
|
27
|
+
type: 'document'; // REQUIRED. Value MUST be set to 'document'. Note: id_document is an alias for document for backward compatibilty purposes but will be deprecated in future releases, implementers are recommended to use document.
|
|
28
|
+
verifier: VerifierDLT; // txn is required: legal entity that performed the identity verification on behalf of the OP.
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/** OpenID 'document' evidence sub-element.
|
|
32
|
+
* - 'type' of the (physical) document (standarized).
|
|
33
|
+
* - 'date_of_issuance' is the date the document was issued as ISO 8601:2004 YYYY-MM-DD format.
|
|
34
|
+
* - 'date_of_expiry' is the date the document will expire as ISO 8601:2004 YYYY-MM-DD format.
|
|
35
|
+
* - 'serial_number' is the model of the document irrespective of any personalization information (usually physical artefacts and is present before personalization).
|
|
36
|
+
* - 'document_number' is the unique document ID that was issued to the End-User and will change if it is reissued, e.g., a passport number, certificate number, etc.
|
|
37
|
+
* Note: number can be used as an alias for 'document_number' for backward compatibilty purposes but will be deprecated in future releases, implementers are recommended to use document_number.
|
|
38
|
+
*/
|
|
39
|
+
export interface DocumentDetailsBase {
|
|
40
|
+
date_of_expiry?: string; // OPTIONAL. If this attribute exists for the particular type of document. The date the document will expire as ISO 8601:2004 YYYY-MM-DD format.
|
|
41
|
+
date_of_issuance?: string; // OPTIONAL. If this attribute exists for the particular type of document. The date the document was issued as ISO 8601:2004 YYYY-MM-DD format.
|
|
42
|
+
document_number?: string; // OPTIONAL. Unique document ID that was issued to the End-User. This is used on one document and will change if it is reissued, e.g., a passport number, certificate number, etc. Note: number can be used as an alias for 'document_number' for backward compatibilty purposes but will be deprecated in future releases, implementers are recommended to use document_number.
|
|
43
|
+
serial_number?: string; // OPTIONAL. Model of document irrespective of any personalization information (usually physical artefacts and is present before personalization).
|
|
44
|
+
type: string; // REQUIRED. Standardized values are defined in the Identity Documents section. The OP MAY use other than the predefined values in which case the RPs will either be unable to process the assertion, just store this value for audit purposes, or apply bespoken business logic to it.
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** JSON object representing the document used to perform the identity verification.
|
|
48
|
+
* - type: REQUIRED. Standardized values are defined in the Identity Documents section. The OP MAY use other than the predefined values in which case the RPs will either be unable to process the assertion, just store this value for audit purposes, or apply bespoken business logic to it.
|
|
49
|
+
* - personal_number: OPTIONAL. It is the subject's DID URI (can be also the holder).
|
|
50
|
+
* - issuer: OPTIONAL. JSON object containing information about the issuer of this document.
|
|
51
|
+
* - date_of_issuance: REQUIRED. If this attribute exists for the particular type of document. The date the document was issued as ISO 8601:2004 YYYY-MM-DD format.
|
|
52
|
+
* - date_of_expiry: REQUIRED. If this attribute exists for the particular type of document. The date the document will expire as ISO 8601:2004 YYYY-MM-DD format.
|
|
53
|
+
* - document_number: OPTIONAL. Unique document ID that was issued to the End-User. This is used on one document and will change if it is reissued, e.g., a passport number, certificate number, etc. Note: number can be used as an alias for 'document_number' for backward compatibilty purposes but will be deprecated in future releases, implementers are recommended to use document_number.
|
|
54
|
+
* - serial_number: OPTIONAL. Model of document irrespective of any personalization information (usually physical artefacts and is present before personalization).
|
|
55
|
+
*/
|
|
56
|
+
export interface DocumentDetailsDLT extends
|
|
57
|
+
DocumentDetailsBase // type, date_of_issuance, date_of_expiry, document_number, serial_number (model of the document irrespective of any personalization information)
|
|
58
|
+
{
|
|
59
|
+
issuer?: IssuerElectronicRecordDLT; // OPTIONAL. Object containing information about the issuer of this document.
|
|
60
|
+
personal_number?: string; // OPTIONAL. Holder.id / subjectId
|
|
61
|
+
}
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
// Copyright 2025 Antifraud Services Inc. under the Apache License, Version 2.0.
|
|
2
|
+
// File: crypto-ts/models/oidc4ida.electronicRecord.model.ts
|
|
3
|
+
|
|
4
|
+
import { AttachmentExternalDLT, CheckDetails, VerifierDLT } from './oidc4ida.common.model';
|
|
5
|
+
|
|
6
|
+
// TODO: IssuerElectronicRecordOpenID with personal_number
|
|
7
|
+
|
|
8
|
+
/** OpenID 'electronic_record' evidence sub-element base data
|
|
9
|
+
* to be extended with 'attachments' and 'record' elements for blockchain or OpenID Evidence of Electronic Record
|
|
10
|
+
* The electronic health record can be about a VC, SHC, DGC, FHIR Bundle or single resource (e.g.: a single medical record).
|
|
11
|
+
* - 'type': always 'electronic_record.
|
|
12
|
+
* - 'check_details': OPTIONAL. Checks done in relation to the evidence. https://bitbucket.org/openid/ekyc-ida/wiki/identifiers
|
|
13
|
+
* - 'verifier': legal entity that performed the identity verification on behalf of the OP (OpenID Provider)
|
|
14
|
+
* - 'time': Time stamp in ISO 8601:2004 format representing the date when it was verified.
|
|
15
|
+
*/
|
|
16
|
+
export interface EvidenceElectronicRecordBase {
|
|
17
|
+
check_details?: CheckDetails[]; // OPTIONAL. Checks done in relation to the evidence. https://bitbucket.org/openid/ekyc-ida/wiki/identifiers
|
|
18
|
+
time?: string; // OPTIONAL. Time stamp in ISO 8601:2004 [ISO8601-2004] YYYY-MM-DDThh:mm[:ss]TZD format representing the date when it was verified
|
|
19
|
+
type?: 'electronic_record'; // REQUIRED but not stored on blockchain in case of FHIR resources (they always are 'electronic_records').
|
|
20
|
+
verifier?: VerifierDLT; // OPTIONAL. A JSON object denoting the legal entity that performed the identity verification on behalf of the OP.
|
|
21
|
+
}
|
|
22
|
+
|
|
23
|
+
/** OpenID 'electronic_record' evidence sub-element for blockchain.
|
|
24
|
+
* The electronic health record can be about a VC, SHC, DGC, FHIR Bundle or single resource (e.g.: a single medical record).
|
|
25
|
+
* - 'record': 'source' (issuer), 'personal_number' (subject's DID), 'created_at', 'date_of_expiry', 'type' ('idcard' or 'vc', 'shc', 'dgc', 'fhir', etc: see 'Electronic Records' at https://bitbucket.org/openid/ekyc-ida/wiki/identifiers)
|
|
26
|
+
* - 'attachments': only external attachments are allowed for blockchain certification (no inline data)
|
|
27
|
+
* - 'type': always 'electronic_record.
|
|
28
|
+
* - 'validation_method': how the authenticity of the document was determined.
|
|
29
|
+
* - 'verification_method': how the user was proven to be the owner of the claims.
|
|
30
|
+
* - 'verifier': legal entity that performed the identity verification on behalf of the OP (OpenID Provider)
|
|
31
|
+
* - 'time': Time stamp in ISO 8601:2004 format representing the date when it was verified.
|
|
32
|
+
*
|
|
33
|
+
* NOTE: 'document_details' is not for electronic records (use 'record' instead).
|
|
34
|
+
*/
|
|
35
|
+
export interface EvidenceElectronicRecordDLT extends
|
|
36
|
+
EvidenceElectronicRecordBase // 'type', 'validation_method', 'verification_method', 'verifier', 'time'
|
|
37
|
+
{
|
|
38
|
+
attachments?: AttachmentExternalDLT[]; // OPTIONAL. Array of JSON objects representing attachments like photocopies of documents or certificates.
|
|
39
|
+
record?: ElectronicRecordDLT; // JSON object representing the id document used to perform the id verification
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
/** OpenID 'electronic_record' evidence sub-element can be about an ID card, VC, SHC, DGC, etc.
|
|
43
|
+
* - 'type': can be 'idcard', 'vc', 'shc', 'dgc', 'fhir', etc (see 'Electronic Records' at https://bitbucket.org/openid/ekyc-ida/wiki/identifiers)
|
|
44
|
+
* - 'created_at': is the same as 'validFrom' property in a W3C credential.
|
|
45
|
+
* - 'date_of_expiry': it the same as 'validUntil' in a W3C credential.
|
|
46
|
+
* - 'personal_number' is the subject's DID URI, similar to 'holder.id' property in a W3C credential.
|
|
47
|
+
*
|
|
48
|
+
* NOTE: 'personal_number' (subject DID URI) is not excluded for now?
|
|
49
|
+
*/
|
|
50
|
+
export interface ElectronicRecordBase {
|
|
51
|
+
type: string; // REQUIRED. string;denoting the type of electronic record. See https://bitbucket.org/openid/ekyc-ida/wiki/identifiers
|
|
52
|
+
created_at?: string; // OPTIONAL. The time the record was created as ISO 8601:2004 [ISO8601-2004] YYYY-MM-DDThh:mm[:ss]TZD format date_of_expiry?: string; // REQUIRED. If this attribute exists for the particular type of document. The date the document will expire as ISO 8601:2004 YYYY-MM-DD format.
|
|
53
|
+
date_of_expiry?: string; // OPTIONAL. The date the evidence will expire as ISO 8601:2004 [ISO8601-2004] YYYY-MM-DD format.
|
|
54
|
+
source?: IssuerElectronicRecordBase; // OPTIONAL. Issuer as source of the record (can have jurisdiction and )
|
|
55
|
+
// personal_number?: string; // OPTIONAL. Subject DID URI (it can be also the holder ID).
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** OpenID 'electronic_record' evidence sub-element can be about a VC, SHC of DGC.
|
|
59
|
+
* - 'type': String denoting the type of electronic record. It can be a predefined value (idcard, etc) or 'vc', 'shc', 'dgc', 'fhir', etc (see 'Electronic Records' at https://bitbucket.org/openid/ekyc-ida/wiki/identifiers)
|
|
60
|
+
* - 'created_at' is the issued property.
|
|
61
|
+
* - 'date_of_expiry' it the periodEnd.
|
|
62
|
+
* NOTE:
|
|
63
|
+
* - 'personal_number' (subject DID) is excluded for now? (it is also the same as the 'holder.id' property in VC).
|
|
64
|
+
*/
|
|
65
|
+
export interface ElectronicRecordDLT extends
|
|
66
|
+
ElectronicRecordBase // 'type', 'personal_number', 'created_at', 'date_of_expiry'
|
|
67
|
+
{
|
|
68
|
+
source?: IssuerElectronicRecordDLT; // OPTIONAL. Issuer as source of the record (API can set the name and jurisdiction for the OpenID source element)
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/** Issuer's anonymized information (can be used for research purposes) */
|
|
72
|
+
export interface IssuerElectronicRecordBase {
|
|
73
|
+
country_code?: string; // ISO 3166/ICAO 3-letter codes [ICAO-Doc9303]. 2-letter ISO 3166/ICAO codes MAY be used in some circumstances for compatibility reasons.
|
|
74
|
+
jurisdiction?: string; // ISO: String containing the region(s) / state(s) / province(s) / municipality(ies) that source has jurisdiction over
|
|
75
|
+
// postal_code?:string; // Zip code or postal code component.
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** It replaces the issuer 'name' by 'id' and 'type' (for blockchain)
|
|
79
|
+
* and also includes 'country' and 'region' (but not 'postal_code', 'locality' or 'stree_address').
|
|
80
|
+
*/
|
|
81
|
+
export interface IssuerElectronicRecordDLT extends
|
|
82
|
+
IssuerElectronicRecordBase
|
|
83
|
+
{
|
|
84
|
+
id?: string; // custom UHC property instead of 'name'
|
|
85
|
+
type?: string; // custom UHC property
|
|
86
|
+
}
|
|
@@ -0,0 +1,69 @@
|
|
|
1
|
+
// Copyright 2025 Antifraud Services Inc. under the Apache License, Version 2.0.
|
|
2
|
+
// File: crypto-ts/models/oidc4ida.evidence.model.ts
|
|
3
|
+
|
|
4
|
+
import { EvidenceDocumentDLT } from "./oidc4ida.document.model";
|
|
5
|
+
import { EvidenceElectronicRecordDLT } from "./oidc4ida.electronicRecord.model";
|
|
6
|
+
|
|
7
|
+
/** W3C Evidence for VCs can be generated by the API from some OpenID evidence stored on blockchain.
|
|
8
|
+
* See EBSI v2: https://ec.europa.eu/digital-building-blocks/wikis/display/EBSIDOC/Verifiable+Attestation
|
|
9
|
+
* - id: OPTIONAL. If present, it MUST contain a URL that points to where more information about this instance of evidence can be found (e.g.: urn:unid:uhc:vc:xyz or e.g.: "https://example.edu/evidence/f2aeec97-fc0d-42bf-8ca7-0548192dxyzab")
|
|
10
|
+
* - type: REQUIRED. Defines the evidence type, e.g.: ["DocumentVerification"], ["id_document"], ["utility_bill"], ["qes"]
|
|
11
|
+
* - verifier: REQUIRED. Defines entity that has verified documents before Verifiable Attestation issuance, e.g.: "https://example.edu/issuers/14"
|
|
12
|
+
* - evidenceDocument: REQUIRED. Defines document(s) which have been verified before Verifiable Attestation issuance, e.g.: "DriversLicense" (TODO: can be used HL7 instead?). QUESTION: Should it be the universal ID instead a description? RESPONSE: No, because it is linked to a credentialSubject within a credential
|
|
13
|
+
* - subjectPresence: REQUIRED. Defines if the Verifiable Attestation Subject was physically present in the course of the verification, e.g.: 'Physical' or 'Digital'
|
|
14
|
+
* - documentPresence: REQUIRED. Defines how the document(s) which have been verified before Verifiable Credentials issuance have been provided, e.g.: 'Physical' or 'Digital'
|
|
15
|
+
*/
|
|
16
|
+
export interface EvidenceW3C {
|
|
17
|
+
id?: string;
|
|
18
|
+
type?: string[];
|
|
19
|
+
verifier?: string;
|
|
20
|
+
evidenceDocument?: string;
|
|
21
|
+
subjectPresence?: string;
|
|
22
|
+
documentPresence?: string;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
/** OpenID 'electronic_signature' evidence sub-element
|
|
26
|
+
* 'serial_number' can be the DID of the public key for doing the verification process instead of the serial number of a certificate.
|
|
27
|
+
*/
|
|
28
|
+
export interface EvidenceElectronicSignatureBase{
|
|
29
|
+
type: 'electronic_signature'; // REQUIRED: Fixed to 'electronic_signature'
|
|
30
|
+
signature_type: string; // REQUIRED. Type of signature used as evidence. The value range might be restricted by the respective trust framework.
|
|
31
|
+
issuer: string; // REQUIRED. Certification authority that issued the signer's certificate.
|
|
32
|
+
serial_number: string; // REQUIRED. DID#KID or Serial number of the certificate used to sign.
|
|
33
|
+
created_at: string; // REQUIRED. The time the signature was created as ISO 8601:2004 YYYY-MM-DDThh:mm:ss±hh format
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
/** The used language is not specified, but is usually bound to the jurisdiction of the underlying trust framework of the OP. */
|
|
37
|
+
export interface AttachedSignatureDLT {
|
|
38
|
+
// desc?: string; // OPTIONAL. Description of the document. This can be the filename or just an explanation of the content (e.g. "Back of id document")
|
|
39
|
+
content_type: string; // e.g.: 'jws'
|
|
40
|
+
content: string; // e.g. detached signature string (compact JWS) or bytes encoded in Base64
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** OpenID 'electronic_signature' evidence sub-element
|
|
44
|
+
* 'serial_number' can be the DID of the public key for doing the verification process instead of the serial number of a certificate.
|
|
45
|
+
* It also contains 'type', 'signature_type', 'issuer', 'serial_number', 'created_at' and external 'attachments' with 'digest.alg' and 'digest.value'.
|
|
46
|
+
*/
|
|
47
|
+
export interface EvidenceElectronicSignatureDLT extends
|
|
48
|
+
EvidenceElectronicSignatureBase // 'type', 'signature_type', 'issuer', 'serial_number', 'created_at'
|
|
49
|
+
{
|
|
50
|
+
attachments?: AttachedSignatureDLT[]; // OPTIONAL. Array of JSON objects containing signatures, e.g. 'jws' or 'Ed25519' signature types.
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** Evidence is the certification of the authenticity of some (physical) document, (electronic) record, (electronic) signature, (utility) bill or vouch.
|
|
54
|
+
* OpenID Connect for Identity Assurance 1.0: https://openid.net/specs/openid-connect-4-identity-assurance-1_0.html
|
|
55
|
+
* 5.1.1. Evidence Element - types of evidence:
|
|
56
|
+
* - document: Verification based on any kind of physical or electronic document provided by the End-User.
|
|
57
|
+
* - electronic_record: Verification based on data or information obtained electronically from an approved or recognized source.
|
|
58
|
+
* - vouch: Verification based on an attestation or reference given by an approved or recognized person declaring they believe to the best of their knowledge that the Claim(s) are genuine and true.
|
|
59
|
+
* - utility_bill: Verification based on a utility bill (this is to be deprecated in future releases and implementers are recommended to use the document type instead).
|
|
60
|
+
* - electronic_signature: Verification based on an electronic signature.
|
|
61
|
+
*/
|
|
62
|
+
export type EvidenceObjectDLT =
|
|
63
|
+
EvidenceElectronicRecordDLT // e.g.: VC, SHC, DGC, FHIR record, etc.
|
|
64
|
+
| EvidenceDocumentDLT // e.g.: evidence of a physical document
|
|
65
|
+
| EvidenceElectronicSignatureDLT // evidence from a digital certificate signature (e.g. PDF document)
|
|
66
|
+
// | EvidenceVouchDLT
|
|
67
|
+
// | EvidenceBillDLT
|
|
68
|
+
|
|
69
|
+
|