antifraud-data-utils-ts 0.1.10 → 0.2.0
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/CHANGELOG.md +187 -134
- package/LICENSE +13 -13
- package/README.md +257 -243
- package/dist/cryptography/index.d.ts +1 -0
- package/dist/cryptography/index.d.ts.map +1 -1
- package/dist/cryptography/index.js +1 -0
- package/dist/cryptography/index.js.map +1 -1
- package/dist/cryptography/numeric-qr.d.ts +4 -0
- package/dist/cryptography/numeric-qr.d.ts.map +1 -0
- package/dist/cryptography/numeric-qr.js +22 -0
- package/dist/cryptography/numeric-qr.js.map +1 -0
- package/dist/cryptography/post-quantum-detached-qr.d.ts +14 -0
- package/dist/cryptography/post-quantum-detached-qr.d.ts.map +1 -0
- package/dist/cryptography/post-quantum-detached-qr.js +76 -0
- package/dist/cryptography/post-quantum-detached-qr.js.map +1 -0
- package/dist/encoding/base58btc.d.ts +3 -0
- package/dist/encoding/base58btc.d.ts.map +1 -0
- package/dist/encoding/base58btc.js +19 -0
- package/dist/encoding/base58btc.js.map +1 -0
- package/dist/identity-assurance/antifraud-data-card.d.ts +42 -0
- package/dist/identity-assurance/antifraud-data-card.d.ts.map +1 -0
- package/dist/identity-assurance/antifraud-data-card.js +120 -0
- package/dist/identity-assurance/antifraud-data-card.js.map +1 -0
- package/dist/identity-assurance/didcomm-binary-attachment.d.ts.map +1 -1
- package/dist/identity-assurance/didcomm-binary-attachment.js +1 -18
- package/dist/identity-assurance/didcomm-binary-attachment.js.map +1 -1
- package/dist/identity-assurance/identity-evidence.d.ts.map +1 -1
- package/dist/identity-assurance/identity-evidence.js +1 -16
- package/dist/identity-assurance/identity-evidence.js.map +1 -1
- package/dist/identity-assurance/index.d.ts +1 -0
- package/dist/identity-assurance/index.d.ts.map +1 -1
- package/dist/identity-assurance/index.js +1 -0
- package/dist/identity-assurance/index.js.map +1 -1
- package/dist/index.d.ts +3 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -1
- package/dist/organization-credentials.d.ts +75 -0
- package/dist/organization-credentials.d.ts.map +1 -0
- package/dist/organization-credentials.js +162 -0
- package/dist/organization-credentials.js.map +1 -0
- package/dist/organization-identity.d.ts +21 -0
- package/dist/organization-identity.d.ts.map +1 -0
- package/dist/organization-identity.js +47 -0
- package/dist/organization-identity.js.map +1 -0
- package/dist/service-conversation.d.ts +40 -0
- package/dist/service-conversation.d.ts.map +1 -0
- package/dist/service-conversation.js +58 -0
- package/dist/service-conversation.js.map +1 -0
- package/docs/ANTIFRAUD_DATA_CARD_V1.md +47 -0
- package/docs/DC4EU_EDUCATION_AND_MEDICAL_CREDENTIALS.md +93 -0
- package/docs/DIDCOMM_SCHEMA_ORG_ATTACHMENTS.md +73 -0
- package/docs/EDUCATION_ADMINISTRATIVE_ASSISTANT_IDENTITY_EVIDENCE.md +90 -0
- package/docs/IDENTITY_VERIFICATION_AND_ATTESTATION.md +354 -0
- package/docs/ORGANIZATION_CONTACT_IDENTITY.md +113 -0
- package/package.json +69 -55
|
@@ -0,0 +1,162 @@
|
|
|
1
|
+
import { buildStableActorIdentifier, normalizeActorContact } from './organization-identity.js';
|
|
2
|
+
export const ReviewedOrganizationCredentialTypes = Object.freeze({
|
|
3
|
+
VerifiableCredential: 'VerifiableCredential',
|
|
4
|
+
Admission: 'OrganizationTestNetworkCredential',
|
|
5
|
+
Organization: 'OrganizationCredential',
|
|
6
|
+
Person: 'PersonCredential',
|
|
7
|
+
LegalRepresentative: 'LegalRepresentativeCredential',
|
|
8
|
+
ServiceController: 'ServiceControllerCredential',
|
|
9
|
+
TestNetwork: 'TestNetworkCredential',
|
|
10
|
+
});
|
|
11
|
+
export const TestNetworkOrganizationCredentialTypes = Object.freeze([
|
|
12
|
+
ReviewedOrganizationCredentialTypes.Organization,
|
|
13
|
+
ReviewedOrganizationCredentialTypes.LegalRepresentative,
|
|
14
|
+
ReviewedOrganizationCredentialTypes.ServiceController,
|
|
15
|
+
]);
|
|
16
|
+
const CONTEXTS = ['https://www.w3.org/ns/credentials/v2', 'https://schema.org'];
|
|
17
|
+
function required(value, name) {
|
|
18
|
+
const normalized = String(value || '').trim();
|
|
19
|
+
if (!normalized)
|
|
20
|
+
throw new TypeError(`Reviewed organization credentials require ${name}`);
|
|
21
|
+
return normalized;
|
|
22
|
+
}
|
|
23
|
+
function partyContact(email, telephone, party) {
|
|
24
|
+
if ((email !== undefined && typeof email !== 'string') || (telephone !== undefined && typeof telephone !== 'string')) {
|
|
25
|
+
throw new TypeError(`${party} contact must be a string`);
|
|
26
|
+
}
|
|
27
|
+
const hasEmail = Boolean(String(email || '').trim());
|
|
28
|
+
const hasTelephone = Boolean(String(telephone || '').trim());
|
|
29
|
+
if (hasEmail === hasTelephone)
|
|
30
|
+
throw new TypeError(`${party} requires exactly one email or telephone`);
|
|
31
|
+
const contactKind = hasEmail ? 'email' : 'phone';
|
|
32
|
+
return { contactKind, contact: normalizeActorContact({ contactKind, contact: String(hasEmail ? email : telephone) }) };
|
|
33
|
+
}
|
|
34
|
+
/** Creates a draft only; the host must sign and verify the exact admission evidence. */
|
|
35
|
+
export function buildOrganizationTestNetworkCredential(input) {
|
|
36
|
+
const applicationId = required(input.applicationId, 'applicationId');
|
|
37
|
+
const organizationIdentifier = required(input.organizationIdentifier, 'organizationIdentifier');
|
|
38
|
+
const contact = partyContact(input.controllerEmail, input.controllerTelephone, 'controller');
|
|
39
|
+
return {
|
|
40
|
+
'@context': [...CONTEXTS],
|
|
41
|
+
id: required(input.credentialId, 'credentialId'),
|
|
42
|
+
type: [ReviewedOrganizationCredentialTypes.VerifiableCredential, ReviewedOrganizationCredentialTypes.Admission],
|
|
43
|
+
issuer: required(input.issuerDid, 'issuerDid'),
|
|
44
|
+
credentialSubject: {
|
|
45
|
+
id: required(input.subjectDid, 'subjectDid'),
|
|
46
|
+
applicationId,
|
|
47
|
+
accessPath: input.accessPath,
|
|
48
|
+
organization: { legalName: required(input.legalName, 'legalName'), identifier: organizationIdentifier },
|
|
49
|
+
controller: {
|
|
50
|
+
...(contact.contactKind === 'email' ? { email: contact.contact } : { telephone: contact.contact }),
|
|
51
|
+
hasCredential: { material: required(input.controllerKeyMaterial, 'controllerKeyMaterial') },
|
|
52
|
+
},
|
|
53
|
+
},
|
|
54
|
+
validFrom: required(input.validFrom, 'validFrom'),
|
|
55
|
+
validUntil: required(input.validUntil, 'validUntil'),
|
|
56
|
+
...(input.proof ? { proof: input.proof } : {}),
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
/** Projects governed parties and roles; this builder never assigns or verifies them. */
|
|
60
|
+
export function buildTestNetworkOrganizationCredentialSet(input) {
|
|
61
|
+
const issuer = required(input.issuerDid, 'issuerDid');
|
|
62
|
+
const organizationDid = required(input.organizationDid, 'organizationDid');
|
|
63
|
+
const applicationId = required(input.applicationId, 'applicationId');
|
|
64
|
+
const validFrom = required(input.validFrom, 'validFrom');
|
|
65
|
+
const validUntil = required(input.validUntil, 'validUntil');
|
|
66
|
+
const legalName = required(input.legalName, 'legalName');
|
|
67
|
+
const organizationIdentifier = required(input.organizationIdentifier, 'organizationIdentifier');
|
|
68
|
+
const identifierType = required(input.identifierType, 'identifierType');
|
|
69
|
+
const addressCountry = required(input.addressCountry, 'addressCountry').toUpperCase();
|
|
70
|
+
const serviceCategory = required(input.serviceCategory, 'serviceCategory');
|
|
71
|
+
const representativeContact = partyContact(input.legalRepresentativeEmail, input.legalRepresentativeTelephone, 'legal representative');
|
|
72
|
+
const legalRepresentativeFullName = required(input.legalRepresentativeFullName, 'legalRepresentativeFullName');
|
|
73
|
+
const controllerContact = partyContact(input.controllerEmail, input.controllerTelephone, 'controller');
|
|
74
|
+
const representativeActor = buildStableActorIdentifier(representativeContact);
|
|
75
|
+
const controllerActor = buildStableActorIdentifier(controllerContact);
|
|
76
|
+
const representativeOccupation = required(input.legalRepresentativeOccupation, 'legalRepresentativeOccupation');
|
|
77
|
+
const controllerOccupation = required(input.controllerOccupation, 'controllerOccupation');
|
|
78
|
+
const controllerAuthorityRole = required(input.controllerAuthorityRole, 'controllerAuthorityRole');
|
|
79
|
+
const evidence = [{
|
|
80
|
+
type: 'DocumentVerification',
|
|
81
|
+
id: `urn:sha256:${required(input.pdfSha256, 'pdfSha256')}`,
|
|
82
|
+
documentVersion: required(input.documentVersion, 'documentVersion'),
|
|
83
|
+
applicationId,
|
|
84
|
+
}];
|
|
85
|
+
const base = { '@context': [...CONTEXTS], issuer, validFrom, validUntil, evidence };
|
|
86
|
+
const organization = {
|
|
87
|
+
...base,
|
|
88
|
+
id: `urn:uuid:${applicationId}:organization`,
|
|
89
|
+
type: [ReviewedOrganizationCredentialTypes.VerifiableCredential, ReviewedOrganizationCredentialTypes.Organization, ReviewedOrganizationCredentialTypes.TestNetwork],
|
|
90
|
+
credentialSubject: {
|
|
91
|
+
id: organizationDid,
|
|
92
|
+
'@type': 'Organization',
|
|
93
|
+
legalName,
|
|
94
|
+
identifier: { additionalType: identifierType, value: organizationIdentifier },
|
|
95
|
+
...(identifierType === 'taxID' ? { taxID: organizationIdentifier } : {}),
|
|
96
|
+
address: { '@type': 'PostalAddress', addressCountry },
|
|
97
|
+
makesOffer: { '@type': 'Offer', category: serviceCategory },
|
|
98
|
+
},
|
|
99
|
+
};
|
|
100
|
+
const representative = {
|
|
101
|
+
...base,
|
|
102
|
+
id: `urn:uuid:${applicationId}:legal-representative`,
|
|
103
|
+
type: [ReviewedOrganizationCredentialTypes.VerifiableCredential, ReviewedOrganizationCredentialTypes.Person, ReviewedOrganizationCredentialTypes.LegalRepresentative, ReviewedOrganizationCredentialTypes.TestNetwork],
|
|
104
|
+
credentialSubject: {
|
|
105
|
+
id: representativeActor,
|
|
106
|
+
'@type': 'Person',
|
|
107
|
+
name: legalRepresentativeFullName,
|
|
108
|
+
sameAs: representativeActor,
|
|
109
|
+
hasOccupation: { '@type': 'Occupation', occupationalCategory: representativeOccupation },
|
|
110
|
+
memberOf: {
|
|
111
|
+
'@type': 'Organization', legalName,
|
|
112
|
+
...(identifierType === 'taxID' ? { taxID: organizationIdentifier } : { identifier: { additionalType: identifierType, value: organizationIdentifier } }),
|
|
113
|
+
},
|
|
114
|
+
},
|
|
115
|
+
};
|
|
116
|
+
const controller = {
|
|
117
|
+
...base,
|
|
118
|
+
id: `urn:uuid:${applicationId}:service-controller`,
|
|
119
|
+
type: [ReviewedOrganizationCredentialTypes.VerifiableCredential, 'ServiceCredential', ReviewedOrganizationCredentialTypes.ServiceController, ReviewedOrganizationCredentialTypes.TestNetwork],
|
|
120
|
+
credentialSubject: {
|
|
121
|
+
id: organizationDid,
|
|
122
|
+
'@type': 'Service',
|
|
123
|
+
serviceType: 'OrganizationControllerService',
|
|
124
|
+
provider: {
|
|
125
|
+
'@type': 'Organization', legalName,
|
|
126
|
+
...(identifierType === 'taxID' ? { taxID: organizationIdentifier } : { identifier: { additionalType: identifierType, value: organizationIdentifier } }),
|
|
127
|
+
},
|
|
128
|
+
owner: {
|
|
129
|
+
'@type': 'Person',
|
|
130
|
+
additionalType: controllerAuthorityRole,
|
|
131
|
+
sameAs: controllerActor,
|
|
132
|
+
hasOccupation: { '@type': 'Occupation', occupationalCategory: controllerOccupation },
|
|
133
|
+
hasCredential: { material: required(input.controllerKeyMaterial, 'controllerKeyMaterial') },
|
|
134
|
+
},
|
|
135
|
+
},
|
|
136
|
+
};
|
|
137
|
+
return [organization, representative, controller];
|
|
138
|
+
}
|
|
139
|
+
/** Faithful existing proof-free JSON contract, not a new signing algorithm. */
|
|
140
|
+
function canonicalizeValue(value) {
|
|
141
|
+
if (Array.isArray(value))
|
|
142
|
+
return value.map(canonicalizeValue);
|
|
143
|
+
if (!value || typeof value !== 'object')
|
|
144
|
+
return value;
|
|
145
|
+
return Object.fromEntries(Object.entries(value)
|
|
146
|
+
.filter(([key]) => key !== 'proof')
|
|
147
|
+
.sort(([left], [right]) => left.localeCompare(right))
|
|
148
|
+
.map(([key, nested]) => [key, canonicalizeValue(nested)]));
|
|
149
|
+
}
|
|
150
|
+
export function canonicalizeOrganizationTestNetworkCredential(credential) {
|
|
151
|
+
if (!credential.type.includes(ReviewedOrganizationCredentialTypes.Admission))
|
|
152
|
+
throw new TypeError('Credential is not an organization Test Network admission');
|
|
153
|
+
return JSON.stringify(canonicalizeValue(credential));
|
|
154
|
+
}
|
|
155
|
+
export function canonicalizeTestNetworkOrganizationCredential(credential) {
|
|
156
|
+
if (!TestNetworkOrganizationCredentialTypes.some(type => credential.type.includes(type)))
|
|
157
|
+
throw new TypeError('Credential is not a Test Network organization credential');
|
|
158
|
+
if (!credential.type.includes(ReviewedOrganizationCredentialTypes.TestNetwork))
|
|
159
|
+
throw new TypeError('Test Network credential marker is required');
|
|
160
|
+
return JSON.stringify(canonicalizeValue(credential));
|
|
161
|
+
}
|
|
162
|
+
//# sourceMappingURL=organization-credentials.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization-credentials.js","sourceRoot":"","sources":["../src/organization-credentials.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAA0B,MAAM,4BAA4B,CAAA;AAEtH,MAAM,CAAC,MAAM,mCAAmC,GAAG,MAAM,CAAC,MAAM,CAAC;IAC/D,oBAAoB,EAAE,sBAAsB;IAC5C,SAAS,EAAE,mCAAmC;IAC9C,YAAY,EAAE,wBAAwB;IACtC,MAAM,EAAE,kBAAkB;IAC1B,mBAAmB,EAAE,+BAA+B;IACpD,iBAAiB,EAAE,6BAA6B;IAChD,WAAW,EAAE,uBAAuB;CAC5B,CAAC,CAAA;AACX,MAAM,CAAC,MAAM,sCAAsC,GAAG,MAAM,CAAC,MAAM,CAAC;IAClE,mCAAmC,CAAC,YAAY;IAChD,mCAAmC,CAAC,mBAAmB;IACvD,mCAAmC,CAAC,iBAAiB;CAC7C,CAAC,CAAA;AACX,MAAM,QAAQ,GAAG,CAAC,sCAAsC,EAAE,oBAAoB,CAAC,CAAA;AAmC/E,SAAS,QAAQ,CAAC,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C;IACtG,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,mCAAmC,CAAC,SAAS,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,0DAA0D,CAAC,CAAA;IAC7J,OAAO,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAA;AACtD,CAAC;AAED,MAAM,UAAU,6CAA6C,CAAC,UAA0C;IACtG,IAAI,CAAC,sCAAsC,CAAC,IAAI,CAAC,IAAI,CAAC,EAAE,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,0DAA0D,CAAC,CAAA;IACzK,IAAI,CAAC,UAAU,CAAC,IAAI,CAAC,QAAQ,CAAC,mCAAmC,CAAC,WAAW,CAAC;QAAE,MAAM,IAAI,SAAS,CAAC,4CAA4C,CAAC,CAAA;IACjJ,OAAO,IAAI,CAAC,SAAS,CAAC,iBAAiB,CAAC,UAAU,CAAC,CAAC,CAAA;AACtD,CAAC"}
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
export declare const StableActorContactKinds: Readonly<{
|
|
2
|
+
readonly Email: "email";
|
|
3
|
+
readonly Phone: "phone";
|
|
4
|
+
}>;
|
|
5
|
+
export type StableActorContactKind = typeof StableActorContactKinds[keyof typeof StableActorContactKinds];
|
|
6
|
+
export type ActorContactInput = Readonly<{
|
|
7
|
+
contactKind: StableActorContactKind;
|
|
8
|
+
contact: string;
|
|
9
|
+
}>;
|
|
10
|
+
export type OrganizationEmployeeIdentityInput = ActorContactInput & Readonly<{
|
|
11
|
+
organizationDidWeb: string;
|
|
12
|
+
role: string;
|
|
13
|
+
deviceId?: string;
|
|
14
|
+
}>;
|
|
15
|
+
/** Normalization is a data operation, never proof of contact possession. */
|
|
16
|
+
export declare function normalizeActorContact(input: ActorContactInput): string;
|
|
17
|
+
/** Builds the existing opaque SHA3-256 multihash actor identifier. */
|
|
18
|
+
export declare function buildStableActorIdentifier(input: ActorContactInput): string;
|
|
19
|
+
/** Builds the existing organization employee DID, keeping role and actor separate. */
|
|
20
|
+
export declare function buildOrganizationEmployeeDidWeb(input: OrganizationEmployeeIdentityInput): string;
|
|
21
|
+
//# sourceMappingURL=organization-identity.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization-identity.d.ts","sourceRoot":"","sources":["../src/organization-identity.ts"],"names":[],"mappings":"AAIA,eAAO,MAAM,uBAAuB;;;EAA6D,CAAA;AACjG,MAAM,MAAM,sBAAsB,GAAG,OAAO,uBAAuB,CAAC,MAAM,OAAO,uBAAuB,CAAC,CAAA;AACzG,MAAM,MAAM,iBAAiB,GAAG,QAAQ,CAAC;IAAE,WAAW,EAAE,sBAAsB,CAAC;IAAC,OAAO,EAAE,MAAM,CAAA;CAAE,CAAC,CAAA;AAClG,MAAM,MAAM,iCAAiC,GAAG,iBAAiB,GAAG,QAAQ,CAAC;IAC3E,kBAAkB,EAAE,MAAM,CAAA;IAC1B,IAAI,EAAE,MAAM,CAAA;IACZ,QAAQ,CAAC,EAAE,MAAM,CAAA;CAClB,CAAC,CAAA;AAEF,4EAA4E;AAC5E,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAiBtE;AAED,sEAAsE;AACtE,wBAAgB,0BAA0B,CAAC,KAAK,EAAE,iBAAiB,GAAG,MAAM,CAO3E;AAED,sFAAsF;AACtF,wBAAgB,+BAA+B,CAAC,KAAK,EAAE,iCAAiC,GAAG,MAAM,CAQhG"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
// Copyright 2026 Antifraud Services Inc. under the Apache License, Version 2.0.
|
|
2
|
+
import { sha3_256 } from '@noble/hashes/sha3.js';
|
|
3
|
+
import { encodeBase58btc } from './encoding/base58btc.js';
|
|
4
|
+
export const StableActorContactKinds = Object.freeze({ Email: 'email', Phone: 'phone' });
|
|
5
|
+
/** Normalization is a data operation, never proof of contact possession. */
|
|
6
|
+
export function normalizeActorContact(input) {
|
|
7
|
+
const raw = String(input.contact || '').trim();
|
|
8
|
+
if (input.contactKind === StableActorContactKinds.Email) {
|
|
9
|
+
const email = raw.replace(/^mailto:/iu, '').replace(/\s+/gu, '').toLowerCase();
|
|
10
|
+
if (email.length > 254 || !/^[^\s@]+@[^\s@]+\.[^\s@]+$/u.test(email)) {
|
|
11
|
+
throw new TypeError('Actor email is invalid');
|
|
12
|
+
}
|
|
13
|
+
return email;
|
|
14
|
+
}
|
|
15
|
+
if (input.contactKind === StableActorContactKinds.Phone) {
|
|
16
|
+
const telephone = raw.replace(/^tel:/iu, '');
|
|
17
|
+
if (/[^\d+\s().-]/u.test(telephone))
|
|
18
|
+
throw new TypeError('Actor telephone is invalid');
|
|
19
|
+
const normalized = telephone.replace(/[^\d+]/gu, '');
|
|
20
|
+
if (!/^\+[1-9]\d{1,14}$/u.test(normalized))
|
|
21
|
+
throw new TypeError('Actor telephone requires E.164');
|
|
22
|
+
return normalized;
|
|
23
|
+
}
|
|
24
|
+
throw new TypeError('Actor contact kind must be email or phone');
|
|
25
|
+
}
|
|
26
|
+
/** Builds the existing opaque SHA3-256 multihash actor identifier. */
|
|
27
|
+
export function buildStableActorIdentifier(input) {
|
|
28
|
+
const contact = normalizeActorContact(input);
|
|
29
|
+
// Existing actor contract: multihash(SHA3-256), code 0x16, digest size 0x20.
|
|
30
|
+
// Compatibility is checked against the published predecessor in tests only;
|
|
31
|
+
// the runtime does not depend on that frozen package.
|
|
32
|
+
const digest = sha3_256(new TextEncoder().encode(contact));
|
|
33
|
+
return `urn:multibase:${encodeBase58btc(Uint8Array.from([0x16, 0x20, ...digest]))}`;
|
|
34
|
+
}
|
|
35
|
+
/** Builds the existing organization employee DID, keeping role and actor separate. */
|
|
36
|
+
export function buildOrganizationEmployeeDidWeb(input) {
|
|
37
|
+
const organizationDidWeb = String(input.organizationDidWeb || '').trim();
|
|
38
|
+
const role = String(input.role || '').trim();
|
|
39
|
+
if (!/^did:web:[^\s]+$/u.test(organizationDidWeb))
|
|
40
|
+
throw new TypeError('Organization did:web is required');
|
|
41
|
+
if (!role)
|
|
42
|
+
throw new TypeError('Organization employee role is required');
|
|
43
|
+
const stableActor = buildStableActorIdentifier(input).slice('urn:multibase:'.length);
|
|
44
|
+
return [organizationDidWeb, 'employee', stableActor, role, input.deviceId?.trim()]
|
|
45
|
+
.filter(Boolean).join(':');
|
|
46
|
+
}
|
|
47
|
+
//# sourceMappingURL=organization-identity.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"organization-identity.js","sourceRoot":"","sources":["../src/organization-identity.ts"],"names":[],"mappings":"AAAA,gFAAgF;AAChF,OAAO,EAAE,QAAQ,EAAE,MAAM,uBAAuB,CAAA;AAChD,OAAO,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAA;AAEzD,MAAM,CAAC,MAAM,uBAAuB,GAAG,MAAM,CAAC,MAAM,CAAC,EAAE,KAAK,EAAE,OAAO,EAAE,KAAK,EAAE,OAAO,EAAW,CAAC,CAAA;AASjG,4EAA4E;AAC5E,MAAM,UAAU,qBAAqB,CAAC,KAAwB;IAC5D,MAAM,GAAG,GAAG,MAAM,CAAC,KAAK,CAAC,OAAO,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IAC9C,IAAI,KAAK,CAAC,WAAW,KAAK,uBAAuB,CAAC,KAAK,EAAE,CAAC;QACxD,MAAM,KAAK,GAAG,GAAG,CAAC,OAAO,CAAC,YAAY,EAAE,EAAE,CAAC,CAAC,OAAO,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,WAAW,EAAE,CAAA;QAC9E,IAAI,KAAK,CAAC,MAAM,GAAG,GAAG,IAAI,CAAC,6BAA6B,CAAC,IAAI,CAAC,KAAK,CAAC,EAAE,CAAC;YACrE,MAAM,IAAI,SAAS,CAAC,wBAAwB,CAAC,CAAA;QAC/C,CAAC;QACD,OAAO,KAAK,CAAA;IACd,CAAC;IACD,I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E,MAAM,IAAI,SAAS,CAAC,kCAAkC,CAAC,CAAA;IAC1G,IAAI,CAAC,IAAI;QAAE,MAAM,IAAI,SAAS,CAAC,wCAAwC,CAAC,CAAA;IACxE,MAAM,WAAW,GAAG,0BAA0B,CAAC,KAAK,CAAC,CAAC,KAAK,CAAC,gBAAgB,CAAC,MAAM,CAAC,CAAA;IACpF,OAAO,CAAC,kBAAkB,EAAE,UAAU,EAAE,WAAW,EAAE,IAAI,EAAE,KAAK,CAAC,QAAQ,EAAE,IAAI,EAAE,CAAC;SAC/E,MAAM,CAAC,OAAO,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAA;AAC9B,CAAC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
export declare const AuthoritativeServiceSystem: Readonly<{
|
|
2
|
+
readonly Ehr: "ehr";
|
|
3
|
+
readonly Cms: "cms";
|
|
4
|
+
readonly DocumentManagementSystem: "document-management-system";
|
|
5
|
+
readonly Other: "other";
|
|
6
|
+
}>;
|
|
7
|
+
export type AuthoritativeServiceSystem = typeof AuthoritativeServiceSystem[keyof typeof AuthoritativeServiceSystem];
|
|
8
|
+
export type ServiceSubjectIndexReference = Readonly<{
|
|
9
|
+
label: string;
|
|
10
|
+
href: string;
|
|
11
|
+
mediaType?: string;
|
|
12
|
+
}>;
|
|
13
|
+
export type ServiceSubjectIndexUpdate = Readonly<{
|
|
14
|
+
id: string;
|
|
15
|
+
createdAt: string;
|
|
16
|
+
content: Readonly<{
|
|
17
|
+
kind: 'subject-index-update';
|
|
18
|
+
organizationReference: string;
|
|
19
|
+
serviceReference: string;
|
|
20
|
+
serviceName: string;
|
|
21
|
+
authoritativeSystem: AuthoritativeServiceSystem;
|
|
22
|
+
references: readonly ServiceSubjectIndexReference[];
|
|
23
|
+
}>;
|
|
24
|
+
}>;
|
|
25
|
+
/**
|
|
26
|
+
* Builds the presentation-neutral event emitted into the subject's
|
|
27
|
+
* application conversation after an authorized service updates its index.
|
|
28
|
+
* It carries links and labels only; authority, access and the indexed data
|
|
29
|
+
* remain owned by the service host.
|
|
30
|
+
*/
|
|
31
|
+
export declare function buildServiceSubjectIndexUpdate(input: Readonly<{
|
|
32
|
+
id: string;
|
|
33
|
+
createdAt: string;
|
|
34
|
+
organizationReference: string;
|
|
35
|
+
serviceReference: string;
|
|
36
|
+
serviceName: string;
|
|
37
|
+
authoritativeSystem: AuthoritativeServiceSystem;
|
|
38
|
+
references: readonly ServiceSubjectIndexReference[];
|
|
39
|
+
}>): ServiceSubjectIndexUpdate;
|
|
40
|
+
//# sourceMappingURL=service-conversation.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-conversation.d.ts","sourceRoot":"","sources":["../src/service-conversation.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,0BAA0B;;;;;EAK5B,CAAA;AAEX,MAAM,MAAM,0BAA0B,GAAG,OAAO,0BAA0B,CAAC,MAAM,OAAO,0BAA0B,CAAC,CAAA;AAEnH,MAAM,MAAM,4BAA4B,GAAG,QAAQ,CAAC;IAClD,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,SAAS,CAAC,EAAE,MAAM,CAAA;CACnB,CAAC,CAAA;AAEF,MAAM,MAAM,yBAAyB,GAAG,QAAQ,CAAC;IAC/C,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,OAAO,EAAE,QAAQ,CAAC;QAChB,IAAI,EAAE,sBAAsB,CAAA;QAC5B,qBAAqB,EAAE,MAAM,CAAA;QAC7B,gBAAgB,EAAE,MAAM,CAAA;QACxB,WAAW,EAAE,MAAM,CAAA;QACnB,mBAAmB,EAAE,0BAA0B,CAAA;QAC/C,UAAU,EAAE,SAAS,4BAA4B,EAAE,CAAA;KACpD,CAAC,CAAA;CACH,CAAC,CAAA;AAEF;;;;;GAKG;AACH,wBAAgB,8BAA8B,CAAC,KAAK,EAAE,QAAQ,CAAC;IAC7D,EAAE,EAAE,MAAM,CAAA;IACV,SAAS,EAAE,MAAM,CAAA;IACjB,qBAAqB,EAAE,MAAM,CAAA;IAC7B,gBAAgB,EAAE,MAAM,CAAA;IACxB,WAAW,EAAE,MAAM,CAAA;IACnB,mBAAmB,EAAE,0BAA0B,CAAA;IAC/C,UAAU,EAAE,SAAS,4BAA4B,EAAE,CAAA;CACpD,CAAC,GAAG,yBAAyB,CAkC7B"}
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
export const AuthoritativeServiceSystem = Object.freeze({
|
|
2
|
+
Ehr: 'ehr',
|
|
3
|
+
Cms: 'cms',
|
|
4
|
+
DocumentManagementSystem: 'document-management-system',
|
|
5
|
+
Other: 'other',
|
|
6
|
+
});
|
|
7
|
+
/**
|
|
8
|
+
* Builds the presentation-neutral event emitted into the subject's
|
|
9
|
+
* application conversation after an authorized service updates its index.
|
|
10
|
+
* It carries links and labels only; authority, access and the indexed data
|
|
11
|
+
* remain owned by the service host.
|
|
12
|
+
*/
|
|
13
|
+
export function buildServiceSubjectIndexUpdate(input) {
|
|
14
|
+
const id = required(input.id, 'id');
|
|
15
|
+
const createdAt = required(input.createdAt, 'createdAt');
|
|
16
|
+
if (!Number.isFinite(Date.parse(createdAt)))
|
|
17
|
+
throw new TypeError('createdAt must be an ISO date-time');
|
|
18
|
+
const organizationReference = required(input.organizationReference, 'organizationReference');
|
|
19
|
+
const serviceReference = required(input.serviceReference, 'serviceReference');
|
|
20
|
+
const serviceName = required(input.serviceName, 'serviceName');
|
|
21
|
+
if (!Object.values(AuthoritativeServiceSystem).includes(input.authoritativeSystem)) {
|
|
22
|
+
throw new TypeError('authoritativeSystem is invalid');
|
|
23
|
+
}
|
|
24
|
+
if (!input.references.length)
|
|
25
|
+
throw new TypeError('references must contain at least one governed link');
|
|
26
|
+
const references = Object.freeze(input.references.map((reference, index) => {
|
|
27
|
+
const href = required(reference.href, `references[${index}].href`);
|
|
28
|
+
const url = new URL(href);
|
|
29
|
+
if (url.protocol !== 'https:')
|
|
30
|
+
throw new TypeError(`references[${index}].href must use https`);
|
|
31
|
+
if (url.username || url.password)
|
|
32
|
+
throw new TypeError(`references[${index}].href must not contain credentials`);
|
|
33
|
+
return Object.freeze({
|
|
34
|
+
label: required(reference.label, `references[${index}].label`),
|
|
35
|
+
href: url.href,
|
|
36
|
+
...(reference.mediaType ? { mediaType: required(reference.mediaType, `references[${index}].mediaType`) } : {}),
|
|
37
|
+
});
|
|
38
|
+
}));
|
|
39
|
+
return Object.freeze({
|
|
40
|
+
id,
|
|
41
|
+
createdAt: new Date(createdAt).toISOString(),
|
|
42
|
+
content: Object.freeze({
|
|
43
|
+
kind: 'subject-index-update',
|
|
44
|
+
organizationReference,
|
|
45
|
+
serviceReference,
|
|
46
|
+
serviceName,
|
|
47
|
+
authoritativeSystem: input.authoritativeSystem,
|
|
48
|
+
references,
|
|
49
|
+
}),
|
|
50
|
+
});
|
|
51
|
+
}
|
|
52
|
+
function required(value, field) {
|
|
53
|
+
const normalized = String(value || '').trim();
|
|
54
|
+
if (!normalized)
|
|
55
|
+
throw new TypeError(`${field} is required`);
|
|
56
|
+
return normalized;
|
|
57
|
+
}
|
|
58
|
+
//# sourceMappingURL=service-conversation.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"service-conversation.js","sourceRoot":"","sources":["../src/service-conversation.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,0BAA0B,GAAG,MAAM,CAAC,MAAM,CAAC;IACtD,GAAG,EAAE,KAAK;IACV,GAAG,EAAE,KAAK;IACV,wBAAwB,EAAE,4BAA4B;IACtD,KAAK,EAAE,OAAO;CACN,CAAC,CAAA;AAuBX;;;;;GAKG;AACH,MAAM,UAAU,8BAA8B,CAAC,KAQ7C;IACA,MAAM,EAAE,GAAG,QAAQ,CAAC,KAAK,CAAC,EAAE,EAAE,IAAI,CAAC,CAAA;IACnC,MAAM,SAAS,GAAG,QAAQ,CAAC,KAAK,CAAC,SAAS,EAAE,WAAW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AE,QAAQ,CAAC,SAAS,CAAC,KAAK,EAAE,cAAc,KAAK,SAAS,CAAC;YAC9D,IAAI,EAAE,GAAG,CAAC,IAAI;YACd,GAAG,CAAC,SAAS,CAAC,SAAS,CAAC,CAAC,CAAC,EAAE,SAAS,EAAE,QAAQ,CAAC,SAAS,CAAC,SAAS,EAAE,cAAc,KAAK,aAAa,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,CAAC;SAC/G,CAAC,CAAA;IACJ,CAAC,CAAC,CAAC,CAAA;IACH,OAAO,MAAM,CAAC,MAAM,CAAC;QACnB,EAAE;QACF,SAAS,EAAE,IAAI,IAAI,CAAC,SAAS,CAAC,CAAC,WAAW,EAAE;QAC5C,OAAO,EAAE,MAAM,CAAC,MAAM,CAAC;YACrB,IAAI,EAAE,sBAA+B;YACrC,qBAAqB;YACrB,gBAAgB;YAChB,WAAW;YACX,mBAAmB,EAAE,KAAK,CAAC,mBAAmB;YAC9C,UAAU;SACX,CAAC;KACH,CAAC,CAAA;AACJ,CAAC;AAED,SAAS,QAAQ,CAAC,KAAa,EAAE,KAAa;IAC5C,MAAM,UAAU,GAAG,MAAM,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC,IAAI,EAAE,CAAA;IAC7C,IAAI,CAAC,UAAU;QAAE,MAAM,IAAI,SAAS,CAAC,GAAG,KAAK,cAAc,CAAC,CAAA;IAC5D,OAAO,UAAU,CAAA;AACnB,CAAC"}
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
# Antifraud Data Card v1
|
|
2
|
+
|
|
3
|
+
Status: executable draft. This document defines the public contract implemented
|
|
4
|
+
by `antifraud-data-utils-ts`; it should move unchanged to a future
|
|
5
|
+
`antifraud-specifications` repository when that repository exists.
|
|
6
|
+
|
|
7
|
+
## Scope
|
|
8
|
+
|
|
9
|
+
Antifraud Data Card (ADC) is a non-health compact Verifiable Credential transport.
|
|
10
|
+
It is not SMART Health Cards and is not HL7 Structured Data Capture.
|
|
11
|
+
|
|
12
|
+
- QR values use the collision-resistant project prefix `afdc:/`.
|
|
13
|
+
- `vc.type` starts with
|
|
14
|
+
`urn:antifraudservices:credential:antifraud-data-card:v1`.
|
|
15
|
+
- `vc.credentialSubject.jsonApiDocument` is exactly one canonical JSON:API
|
|
16
|
+
primary document whose resources use Schema.org types and attributes.
|
|
17
|
+
- `fhirVersion` and `fhirBundle` are forbidden by the model.
|
|
18
|
+
- The compact JWS protected header uses `alg: ES256`, `zip: DEF` and an issuer
|
|
19
|
+
key identifier. Signing is performed by an authorized KMS/SDK, not data-utils.
|
|
20
|
+
- The payload is canonical JSON encoded as UTF-8 and raw-DEFLATE compressed
|
|
21
|
+
before base64url encoding.
|
|
22
|
+
|
|
23
|
+
## QR transport
|
|
24
|
+
|
|
25
|
+
The compact JWS uses the decimal-pair encoding familiar from SHC, but the
|
|
26
|
+
namespace is distinct. A single symbol is `afdc:/<digits>`. Multi-symbol values
|
|
27
|
+
are `afdc:/<one-based-index>/<count>/<digits>` and must reject duplicates,
|
|
28
|
+
missing chunks or conflicting counts.
|
|
29
|
+
|
|
30
|
+
## Post-quantum companion proof
|
|
31
|
+
|
|
32
|
+
An optional ML-DSA proof signs the exact external payload bytes as an RFC 7797
|
|
33
|
+
detached JWS (`b64=false`, with `b64` critical). It travels independently under
|
|
34
|
+
`pqc:/`; it never duplicates or changes the ADC payload. Key custody, signature
|
|
35
|
+
creation, verification, issuer trust, status and authorization belong to the
|
|
36
|
+
trusted SDK/KMS boundary.
|
|
37
|
+
|
|
38
|
+
## Security and authority
|
|
39
|
+
|
|
40
|
+
Possession or successful decoding grants no access or authority. A verifier
|
|
41
|
+
must validate the issuer, key purpose, signature, subject binding, audience or
|
|
42
|
+
purpose policy, validity/status and every governed Schema.org claim. Links and
|
|
43
|
+
attachments remain protected references resolved by their authoritative host.
|
|
44
|
+
|
|
45
|
+
The executable conformance vectors are
|
|
46
|
+
`test/antifraud-data-card.test.mjs` and
|
|
47
|
+
`test/post-quantum-detached-qr.test.mjs`.
|
|
@@ -0,0 +1,93 @@
|
|
|
1
|
+
# DC4EU Education and Medical Credential Reference
|
|
2
|
+
|
|
3
|
+
Status reviewed: 17 October 2026.
|
|
4
|
+
|
|
5
|
+
The [DC4EU educational pilot](https://github.com/dc4eu/educational-pilot)
|
|
6
|
+
publishes the European Educational and Professional Qualifications framework.
|
|
7
|
+
It includes the sector rulebook, the Electronic Attestation of Attributes
|
|
8
|
+
catalogue, European Learning Model 3.2 based data models, W3C Verifiable
|
|
9
|
+
Credential serializations, examples and trust-governance material for the
|
|
10
|
+
European Digital Identity Wallet ecosystem.
|
|
11
|
+
|
|
12
|
+
This repository is a source for future interoperability adapters. It is not
|
|
13
|
+
copied into the Antifraud canonical model and its draft schemas are not treated
|
|
14
|
+
as stable production contracts.
|
|
15
|
+
|
|
16
|
+
## Relevant DC4EU credentials
|
|
17
|
+
|
|
18
|
+
The university qualification and the current authority to practise are not the
|
|
19
|
+
same assertion.
|
|
20
|
+
|
|
21
|
+
The European Higher Education Diploma (`EUHED`) represents a higher-education
|
|
22
|
+
diploma awarded by an educational institution. Its current catalogue entry and
|
|
23
|
+
schema are linked from the [DC4EU sectorial EAA catalogue](https://github.com/dc4eu/educational-pilot/tree/main/sectorial-eaa-catalogue#table-with-available-datamodels-based-on-edc-w3c-w3c-vcdm-11-aligned-to-1st-batch-of-implementing-acts).
|
|
24
|
+
This is the likely source of the university-issued medical-degree fields.
|
|
25
|
+
|
|
26
|
+
The [Doctor ID schema](https://github.com/dc4eu/educational-pilot/blob/main/sectorial-eaa-catalogue/non-foundational-id/doctor-id-schema.md)
|
|
27
|
+
is a separate non-foundational professional identity credential. Its draft
|
|
28
|
+
credential subject includes the physician identifier, given and family names,
|
|
29
|
+
medical board, professional administrative number, legal entitlement to
|
|
30
|
+
practise and medical specialities. The issuer includes its identifier,
|
|
31
|
+
multilingual legal name and issuing country. Issuance, expiry and cryptographic
|
|
32
|
+
proof data are credential-level properties.
|
|
33
|
+
|
|
34
|
+
The [Certificate of Professional Suitability](https://github.com/dc4eu/educational-pilot/blob/main/sectorial-eaa-catalogue/professional-qualifications/CertificateProfessionalSuitability.md)
|
|
35
|
+
is another distinct credential. It represents current professional competence
|
|
36
|
+
and entitlement to practise. Its draft subject carries `legally_entitled` and
|
|
37
|
+
one or more medical registrations, including medical board, professional
|
|
38
|
+
administrative number, membership start date and optional membership end date.
|
|
39
|
+
|
|
40
|
+
The catalogue also identifies Professional Medical Certification, Continuing
|
|
41
|
+
Professional Development, Professional Training Certificate and
|
|
42
|
+
[Accreditation Medical Training](https://github.com/dc4eu/educational-pilot/blob/main/sectorial-eaa-catalogue/professional-qualifications/AccreditationMedicalTraining.md).
|
|
43
|
+
Medical training accreditation concerns a programme or activity and its
|
|
44
|
+
accreditation. It must not be presented as the holder's medical licence.
|
|
45
|
+
|
|
46
|
+
## Trust and disclosure boundary
|
|
47
|
+
|
|
48
|
+
DC4EU characterises Doctor ID as issuable by an authorised professional body
|
|
49
|
+
or regulated authority, not by an arbitrary employer. The proposal requires a
|
|
50
|
+
Person Identification Data credential, proof of possession, cryptographic
|
|
51
|
+
holder binding, restricted disclosure and verifier-role checks. Its validity
|
|
52
|
+
is linked to the professional affiliation or membership period.
|
|
53
|
+
|
|
54
|
+
This supports the Antifraud separation between:
|
|
55
|
+
|
|
56
|
+
- a university-issued educational qualification;
|
|
57
|
+
- a professional-body identity or registration;
|
|
58
|
+
- current legal entitlement or licence status;
|
|
59
|
+
- an employer attestation about evidence it reviewed;
|
|
60
|
+
- active employment and application authorization.
|
|
61
|
+
|
|
62
|
+
No proof may silently substitute for another authority. An employer can attest
|
|
63
|
+
that it reviewed a diploma, but it cannot issue the university's diploma or the
|
|
64
|
+
professional body's registration.
|
|
65
|
+
|
|
66
|
+
## Current maturity warning
|
|
67
|
+
|
|
68
|
+
The medical schemas are explicitly marked as drafts. The checked Doctor ID
|
|
69
|
+
schema and its example are not fully consistent: the schema and example use
|
|
70
|
+
different name casing for some subject fields; the medical-board cardinality
|
|
71
|
+
differs; the administrative-number example does not satisfy the schema's
|
|
72
|
+
numeric pattern; and `expirationDate` is required without being declared in
|
|
73
|
+
the schema properties. Some characterisation documents still contain
|
|
74
|
+
`TO_BE_DEFINED` values and example trust identifiers.
|
|
75
|
+
|
|
76
|
+
Consequently, implementers must pin an exact upstream revision and validate an
|
|
77
|
+
actual issuer and verifier profile before enabling interoperability. These
|
|
78
|
+
draft field names must not be copied directly into a stable public API.
|
|
79
|
+
|
|
80
|
+
## Antifraud integration rule
|
|
81
|
+
|
|
82
|
+
Antifraud keeps product-neutral Schema.org
|
|
83
|
+
`EducationalOccupationalCredential` flat claims and independent proof
|
|
84
|
+
bindings as its canonical application contract. A future DC4EU adapter may
|
|
85
|
+
import or export a pinned EUHED, Doctor ID or professional-qualification
|
|
86
|
+
profile. OpenID for Verifiable Credential Issuance and OpenID for Verifiable
|
|
87
|
+
Presentations handle issuance and presentation; OpenID Connect for Identity
|
|
88
|
+
Assurance remains a separate verified-identity projection.
|
|
89
|
+
|
|
90
|
+
Health-specific FHIR projections remain outside this package. A SOS data
|
|
91
|
+
utility may convert the neutral qualification and verification evidence to the
|
|
92
|
+
required FHIR version without making FHIR the Antifraud storage model.
|
|
93
|
+
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# Schema.org documents delivered with DIDComm attachments
|
|
2
|
+
|
|
3
|
+
## Use-case boundary
|
|
4
|
+
|
|
5
|
+
Antifraud is Schema.org-native. A governed document is a `DigitalDocument` and
|
|
6
|
+
its concrete file encoding is a `MediaObject`. It is not a FHIR resource and it
|
|
7
|
+
must never be serialized, stored, searched or displayed as `DocumentReference`.
|
|
8
|
+
|
|
9
|
+
DIDComm is the authenticated and encrypted transport. Its `attachments[]`
|
|
10
|
+
array can carry PDF, spreadsheet, word-processing, image, video or any other
|
|
11
|
+
media type allowed by policy. Transport does not change the Schema.org type of
|
|
12
|
+
the business record.
|
|
13
|
+
|
|
14
|
+
## Two transport forms
|
|
15
|
+
|
|
16
|
+
For a bounded file, `buildDidCommInlineBinaryAttachment` emits:
|
|
17
|
+
|
|
18
|
+
```json
|
|
19
|
+
{
|
|
20
|
+
"id": "urn:attachment:example",
|
|
21
|
+
"media_type": "application/pdf",
|
|
22
|
+
"byte_count": 123,
|
|
23
|
+
"data": { "base64": "...base64url..." }
|
|
24
|
+
}
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
For a confidential file already described by a governed `MediaObject`,
|
|
28
|
+
`buildDidCommLinkedBinaryAttachment` emits an authorized URL and a multibase
|
|
29
|
+
multihash:
|
|
30
|
+
|
|
31
|
+
```json
|
|
32
|
+
{
|
|
33
|
+
"id": "urn:attachment:example",
|
|
34
|
+
"media_type": "application/pdf",
|
|
35
|
+
"byte_count": 123,
|
|
36
|
+
"data": {
|
|
37
|
+
"links": ["https://protected.example/objects/example"],
|
|
38
|
+
"hash": "z..."
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
```
|
|
42
|
+
|
|
43
|
+
The linked attachment hash is the multihash carried inside the canonical
|
|
44
|
+
CIDv1; it is not the complete CID. The `MediaObject.identifier.value` retains
|
|
45
|
+
the complete CIDv1 value.
|
|
46
|
+
|
|
47
|
+
## Minimal PDF proof
|
|
48
|
+
|
|
49
|
+
`test/didcomm-binary-attachment.test.mjs` constructs a minimal synthetic PDF,
|
|
50
|
+
places its exact bytes in a DIDComm inline attachment, decodes the base64url
|
|
51
|
+
payload and verifies the original bytes, `%PDF-1.4` header and `%%EOF` marker.
|
|
52
|
+
The same suite proves protected-reference delivery from the canonical
|
|
53
|
+
`SyntheticConfidentialDocumentFixture` and rejects empty or incomplete input.
|
|
54
|
+
|
|
55
|
+
## Ownership and tasks
|
|
56
|
+
|
|
57
|
+
- Canonical contract and fixture proof:
|
|
58
|
+
[antifraud-data-utils-ts issue #2](https://github.com/antifraudservices/antifraud-data-utils-ts/issues/2).
|
|
59
|
+
- Runtime-neutral orchestration:
|
|
60
|
+
[antifraud-sdk-core-ts issue #5](https://github.com/antifraudservices/antifraud-sdk-core-ts/issues/5).
|
|
61
|
+
- Trusted Node transport:
|
|
62
|
+
[antifraud-sdk-node-ts issue #5](https://github.com/antifraudservices/antifraud-sdk-node-ts/issues/5).
|
|
63
|
+
- Confidential persistence and retrieval:
|
|
64
|
+
[antifraud-gw-node-ts issue #1](https://github.com/antifraudservices/antifraud-gw-node-ts/issues/1).
|
|
65
|
+
- Reusable controlled attachment panel:
|
|
66
|
+
[antifraud-portal-components-react issue #5](https://github.com/antifraudservices/antifraud-portal-components-react/issues/5).
|
|
67
|
+
- Professional portal:
|
|
68
|
+
[antifraud-professional-nextjs issue #1](https://github.com/antifraudservices/antifraud-professional-nextjs/issues/1).
|
|
69
|
+
- Personal portal:
|
|
70
|
+
[antifraud-personal-next issue #1](https://github.com/antifraudservices/antifraud-personal-next/issues/1).
|
|
71
|
+
|
|
72
|
+
The C2PA and ML-DSA interoperability proof is tracked separately in
|
|
73
|
+
[antifraud-data-utils-ts issue #3](https://github.com/antifraudservices/antifraud-data-utils-ts/issues/3).
|