@zanii/vc 0.1.0 → 0.1.2
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/README.md +4 -0
- package/dist/ecosystem.d.ts +189 -0
- package/dist/ecosystem.d.ts.map +1 -0
- package/dist/ecosystem.js +194 -0
- package/dist/ecosystem.js.map +1 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/ecosystem.ts +201 -0
- package/src/index.ts +1 -0
package/README.md
CHANGED
|
@@ -52,3 +52,7 @@ domain-bound issuer root-of-trust, and ledger-backed history remain Zanii-side c
|
|
|
52
52
|
(`@zanii/credentials`, `@zanii/kya`); W3C StatusList is deliberately not implemented —
|
|
53
53
|
mapping it would claim a liveness this bridge cannot provide. And `verifyVC` checks
|
|
54
54
|
the proof, not the issuer's institutional identity — say what it does, never more.
|
|
55
|
+
|
|
56
|
+
## Changelog
|
|
57
|
+
|
|
58
|
+
- **0.1.2** — OpenID4VCI issuer metadata and credential offers, presentations bound to a verifier nonce and domain (OpenID4VP) with DCQL queries, Bitstring Status List revocation, did:web issuer verification, agent credentials, trust-registry checks, verification receipts.
|
|
@@ -0,0 +1,189 @@
|
|
|
1
|
+
import { type DataIntegrityProof, type VerifiableCredential } from './index.js';
|
|
2
|
+
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
3
|
+
/** Issuer metadata for `/.well-known/openid-credential-issuer`, offering Data Integrity VCs (`ldp_vc`). */
|
|
4
|
+
export declare function issuerMetadata(input: {
|
|
5
|
+
issuerUrl: string;
|
|
6
|
+
credentialEndpoint?: string;
|
|
7
|
+
configurations: Record<string, {
|
|
8
|
+
types: string[];
|
|
9
|
+
display?: Array<{
|
|
10
|
+
name: string;
|
|
11
|
+
locale?: string;
|
|
12
|
+
}>;
|
|
13
|
+
}>;
|
|
14
|
+
}): {
|
|
15
|
+
credential_issuer: string;
|
|
16
|
+
credential_endpoint: string;
|
|
17
|
+
credential_configurations_supported: {
|
|
18
|
+
[k: string]: {
|
|
19
|
+
display?: {
|
|
20
|
+
name: string;
|
|
21
|
+
locale?: string;
|
|
22
|
+
}[] | undefined;
|
|
23
|
+
format: string;
|
|
24
|
+
cryptographic_binding_methods_supported: string[];
|
|
25
|
+
credential_signing_alg_values_supported: string[];
|
|
26
|
+
credential_definition: {
|
|
27
|
+
'@context': string[];
|
|
28
|
+
type: string[];
|
|
29
|
+
};
|
|
30
|
+
};
|
|
31
|
+
};
|
|
32
|
+
};
|
|
33
|
+
/** A pre-authorised credential offer and the `openid-credential-offer://` link a wallet scans. */
|
|
34
|
+
export declare function credentialOffer(input: {
|
|
35
|
+
issuerUrl: string;
|
|
36
|
+
configurationIds: string[];
|
|
37
|
+
preAuthorizedCode: string;
|
|
38
|
+
txCode?: {
|
|
39
|
+
length: number;
|
|
40
|
+
input_mode?: 'numeric' | 'text';
|
|
41
|
+
};
|
|
42
|
+
}): {
|
|
43
|
+
offer: {
|
|
44
|
+
credential_issuer: string;
|
|
45
|
+
credential_configuration_ids: string[];
|
|
46
|
+
grants: {
|
|
47
|
+
'urn:ietf:params:oauth:grant-type:pre-authorized_code': {
|
|
48
|
+
tx_code?: {
|
|
49
|
+
length: number;
|
|
50
|
+
input_mode?: "numeric" | "text";
|
|
51
|
+
} | undefined;
|
|
52
|
+
'pre-authorized_code': string;
|
|
53
|
+
};
|
|
54
|
+
};
|
|
55
|
+
};
|
|
56
|
+
uri: string;
|
|
57
|
+
};
|
|
58
|
+
export interface VerifiablePresentation {
|
|
59
|
+
'@context': string[];
|
|
60
|
+
type: string[];
|
|
61
|
+
holder: string;
|
|
62
|
+
verifiableCredential: VerifiableCredential[];
|
|
63
|
+
proof?: DataIntegrityProof & {
|
|
64
|
+
challenge: string;
|
|
65
|
+
domain: string;
|
|
66
|
+
};
|
|
67
|
+
}
|
|
68
|
+
/** The holder wraps credentials in a presentation bound to the verifier's nonce (challenge) and identity (domain). */
|
|
69
|
+
export declare function createPresentation(vcs: VerifiableCredential[], holder: {
|
|
70
|
+
did: string;
|
|
71
|
+
privateKey: Uint8Array;
|
|
72
|
+
}, opts: {
|
|
73
|
+
challenge: string;
|
|
74
|
+
domain: string;
|
|
75
|
+
created: string;
|
|
76
|
+
}): VerifiablePresentation;
|
|
77
|
+
/** Verify a presentation: holder proof over this nonce and domain, then every credential; optionally require subjects to be the holder. */
|
|
78
|
+
export declare function verifyPresentation(vp: VerifiablePresentation, opts: {
|
|
79
|
+
challenge: string;
|
|
80
|
+
domain: string;
|
|
81
|
+
at?: string;
|
|
82
|
+
requireHolderBinding?: boolean;
|
|
83
|
+
}): {
|
|
84
|
+
ok: boolean;
|
|
85
|
+
reasons: string[];
|
|
86
|
+
holder: string;
|
|
87
|
+
};
|
|
88
|
+
/** A DCQL query asking for Data Integrity credentials of given types (OpenID4VP). */
|
|
89
|
+
export declare function dcqlQuery(requests: Array<{
|
|
90
|
+
id: string;
|
|
91
|
+
types: string[];
|
|
92
|
+
}>): {
|
|
93
|
+
credentials: {
|
|
94
|
+
id: string;
|
|
95
|
+
format: string;
|
|
96
|
+
meta: {
|
|
97
|
+
type_values: string[][];
|
|
98
|
+
};
|
|
99
|
+
}[];
|
|
100
|
+
};
|
|
101
|
+
/** A status list of `size` bits (default 131,072, the minimum for herd privacy); bit 0 is the first byte's highest bit. */
|
|
102
|
+
export declare function createStatusList(size?: number): {
|
|
103
|
+
size: number;
|
|
104
|
+
set(index: number, value?: boolean): void;
|
|
105
|
+
encoded: () => string;
|
|
106
|
+
};
|
|
107
|
+
/** Read one status bit from an `encodedList`. */
|
|
108
|
+
export declare function statusAt(encodedList: string, index: number): boolean;
|
|
109
|
+
/** The signed status list credential to publish at `listUrl`. */
|
|
110
|
+
export declare function statusListCredential(input: {
|
|
111
|
+
listUrl: string;
|
|
112
|
+
encodedList: string;
|
|
113
|
+
purpose?: 'revocation' | 'suspension';
|
|
114
|
+
validFrom: string;
|
|
115
|
+
}, issuer: {
|
|
116
|
+
did: string;
|
|
117
|
+
privateKey: Uint8Array;
|
|
118
|
+
}): VerifiableCredential;
|
|
119
|
+
/** The `credentialStatus` entry to put on a credential before signing it. */
|
|
120
|
+
export declare function statusEntry(listUrl: string, index: number, purpose?: 'revocation' | 'suspension'): {
|
|
121
|
+
id: string;
|
|
122
|
+
type: string;
|
|
123
|
+
statusPurpose: "revocation" | "suspension";
|
|
124
|
+
statusListIndex: string;
|
|
125
|
+
statusListCredential: string;
|
|
126
|
+
};
|
|
127
|
+
/** Check a credential's status against its (verified) list credential from the same issuer. */
|
|
128
|
+
export declare function checkStatus(vc: VerifiableCredential, list: VerifiableCredential): {
|
|
129
|
+
ok: boolean;
|
|
130
|
+
status: "no-status";
|
|
131
|
+
} | {
|
|
132
|
+
ok: boolean;
|
|
133
|
+
status: "list-invalid";
|
|
134
|
+
} | {
|
|
135
|
+
ok: boolean;
|
|
136
|
+
status: "suspended" | "revoked" | "valid";
|
|
137
|
+
};
|
|
138
|
+
/** The URL of a did:web document: `did:web:example.com` -> `https://example.com/.well-known/did.json`; path segments become directories. */
|
|
139
|
+
export declare function didWebUrl(did: string): string;
|
|
140
|
+
/**
|
|
141
|
+
* Verify a VC from a did:web issuer: fetch the DID document, take the Multikey
|
|
142
|
+
* (Ed25519) verification method the proof names, check the issuer lists it for assertion.
|
|
143
|
+
*/
|
|
144
|
+
export declare function verifyDidWebVC(vc: VerifiableCredential, fetchImpl?: FetchLike): Promise<{
|
|
145
|
+
ok: boolean;
|
|
146
|
+
reasons: string[];
|
|
147
|
+
}>;
|
|
148
|
+
/** A credential describing an agent: who owns it, what it may do, its licences and model. */
|
|
149
|
+
export declare function agentCredential(input: {
|
|
150
|
+
agent: string;
|
|
151
|
+
owner: string;
|
|
152
|
+
capabilities: string[];
|
|
153
|
+
licences?: string[];
|
|
154
|
+
model?: string;
|
|
155
|
+
validFrom: string;
|
|
156
|
+
validUntil?: string;
|
|
157
|
+
}, issuer: {
|
|
158
|
+
did: string;
|
|
159
|
+
privateKey: Uint8Array;
|
|
160
|
+
}): VerifiableCredential;
|
|
161
|
+
/** Is the issuer accredited, in a registry you trust, for this credential type at this time? */
|
|
162
|
+
export declare function trustRegistryCheck(issuer: string, credentialType: string, registry: Array<{
|
|
163
|
+
did: string;
|
|
164
|
+
accreditedFor: string[];
|
|
165
|
+
validUntil?: string;
|
|
166
|
+
}>, at?: string): {
|
|
167
|
+
accredited: boolean;
|
|
168
|
+
reason: string;
|
|
169
|
+
} | {
|
|
170
|
+
accredited: boolean;
|
|
171
|
+
reason: null;
|
|
172
|
+
};
|
|
173
|
+
/** Record a verification as a receipt: what was checked, the result, never the credential's claims. */
|
|
174
|
+
export declare function verificationReceipt(vc: VerifiableCredential, check: {
|
|
175
|
+
ok: boolean;
|
|
176
|
+
reasons: string[];
|
|
177
|
+
}, at: string): {
|
|
178
|
+
target: string;
|
|
179
|
+
payload: {
|
|
180
|
+
vc: string;
|
|
181
|
+
issuer: string;
|
|
182
|
+
types: string[];
|
|
183
|
+
ok: boolean;
|
|
184
|
+
reasons: string[];
|
|
185
|
+
at: string;
|
|
186
|
+
};
|
|
187
|
+
};
|
|
188
|
+
export {};
|
|
189
|
+
//# sourceMappingURL=ecosystem.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecosystem.d.ts","sourceRoot":"","sources":["../src/ecosystem.ts"],"names":[],"mappings":"AAWA,OAAO,EAAmE,KAAK,kBAAkB,EAAE,KAAK,oBAAoB,EAAE,MAAM,YAAY,CAAC;AAEjJ,KAAK,SAAS,GAAG,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,WAAW,KAAK,OAAO,CAAC,QAAQ,CAAC,CAAC;AA0B1E,2GAA2G;AAC3G,wBAAgB,cAAc,CAAC,KAAK,EAAE;IAAE,SAAS,EAAE,MAAM,CAAC;IAAC,kBAAkB,CAAC,EAAE,MAAM,CAAC;IAAC,cAAc,EAAE,MAAM,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eAAe,CAAC,KAAK,EAAE;IAAE,KAAK,EAAE,MAAM,CAAC;IAAC,KAAK,EAAE,MAAM,CAAC;IAAC,YAAY,EAAE,MAAM,EAAE,CAAC;IAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,CAAC;IAAC,KAAK,CAAC,EAAE,MAAM,CAAC;IAAC,SAAS,EAAE,MAAM,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,EAAE,MAAM,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,wBAE5N;AAED,gGAAgG;AAChG,wBAAgB,kBAAkB,CAAC,MAAM,EAAE,MAAM,EAAE,cAAc,EAAE,MAAM,EAAE,QAAQ,EAAE,KAAK,CAAC;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,aAAa,EAAE,MAAM,EAAE,CAAC;IAAC,UAAU,CAAC,EAAE,MAAM,CAAA;CAAE,CAAC,EAAE,EAAE,SAA2B;;;;;;EAMvL;AAED,uGAAuG;AACvG,wBAAgB,mBAAmB,CAAC,EAAE,EAAE,oBAAoB,EAAE,KAAK,EAAE;IAAE,EAAE,EAAE,OAAO,CAAC;IAAC,OAAO,EAAE,MAAM,EAAE,CAAA;CAAE,EAAE,EAAE,EAAE,MAAM;;;;;;;;;;EAElH"}
|
|
@@ -0,0 +1,194 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VCs in the wider ecosystem: OpenID4VCI offers and issuer metadata, presentations bound to
|
|
3
|
+
* a verifier's nonce (for OpenID4VP), Bitstring Status List revocation, did:web issuers,
|
|
4
|
+
* agent credentials, trust-registry checks and verification receipts. Same
|
|
5
|
+
* `eddsa-jcs-2022` proofs as `signVC` / `verifyVC`.
|
|
6
|
+
*/
|
|
7
|
+
import { gunzipSync, gzipSync } from 'node:zlib';
|
|
8
|
+
import { ed25519 } from '@noble/curves/ed25519';
|
|
9
|
+
import { sha256 } from '@noble/hashes/sha256';
|
|
10
|
+
import { base58 } from '@scure/base';
|
|
11
|
+
import { canonicalBytes, jcsHash, publicKeyFromDid } from '@zanii/core';
|
|
12
|
+
import { CRYPTOSUITE, signVC, verificationMethodOf, verifyVC, VC_CONTEXT } from './index.js';
|
|
13
|
+
// The eddsa-jcs-2022 signing input, as in index.ts: sha256(JCS(options)) || sha256(JCS(document without proof)).
|
|
14
|
+
function hashData(doc, options) {
|
|
15
|
+
const { proof: _omit, ...unsecured } = doc;
|
|
16
|
+
const out = new Uint8Array(64);
|
|
17
|
+
out.set(sha256(canonicalBytes(options)), 0);
|
|
18
|
+
out.set(sha256(canonicalBytes(unsecured)), 32);
|
|
19
|
+
return out;
|
|
20
|
+
}
|
|
21
|
+
function verifyProofWithKey(doc, publicKey) {
|
|
22
|
+
const p = doc.proof;
|
|
23
|
+
if (!p || p.type !== 'DataIntegrityProof' || p.cryptosuite !== CRYPTOSUITE || typeof p.proofValue !== 'string' || !p.proofValue.startsWith('z'))
|
|
24
|
+
return false;
|
|
25
|
+
try {
|
|
26
|
+
const { proofValue, ...options } = p;
|
|
27
|
+
return ed25519.verify(base58.decode(proofValue.slice(1)), hashData(doc, { '@context': doc['@context'], ...options }), publicKey);
|
|
28
|
+
}
|
|
29
|
+
catch {
|
|
30
|
+
return false;
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
// ------------------------------------------------------------------------------ //
|
|
34
|
+
// OpenID4VCI
|
|
35
|
+
// ------------------------------------------------------------------------------ //
|
|
36
|
+
/** Issuer metadata for `/.well-known/openid-credential-issuer`, offering Data Integrity VCs (`ldp_vc`). */
|
|
37
|
+
export function issuerMetadata(input) {
|
|
38
|
+
return {
|
|
39
|
+
credential_issuer: input.issuerUrl,
|
|
40
|
+
credential_endpoint: input.credentialEndpoint ?? `${input.issuerUrl.replace(/\/$/, '')}/credential`,
|
|
41
|
+
credential_configurations_supported: Object.fromEntries(Object.entries(input.configurations).map(([id, c]) => [id, {
|
|
42
|
+
format: 'ldp_vc', cryptographic_binding_methods_supported: ['did:key'], credential_signing_alg_values_supported: [CRYPTOSUITE],
|
|
43
|
+
credential_definition: { '@context': [VC_CONTEXT], type: c.types }, ...(c.display ? { display: c.display } : {}),
|
|
44
|
+
}])),
|
|
45
|
+
};
|
|
46
|
+
}
|
|
47
|
+
/** A pre-authorised credential offer and the `openid-credential-offer://` link a wallet scans. */
|
|
48
|
+
export function credentialOffer(input) {
|
|
49
|
+
const offer = {
|
|
50
|
+
credential_issuer: input.issuerUrl,
|
|
51
|
+
credential_configuration_ids: input.configurationIds,
|
|
52
|
+
grants: { 'urn:ietf:params:oauth:grant-type:pre-authorized_code': { 'pre-authorized_code': input.preAuthorizedCode, ...(input.txCode ? { tx_code: input.txCode } : {}) } },
|
|
53
|
+
};
|
|
54
|
+
return { offer, uri: `openid-credential-offer://?credential_offer=${encodeURIComponent(JSON.stringify(offer))}` };
|
|
55
|
+
}
|
|
56
|
+
/** The holder wraps credentials in a presentation bound to the verifier's nonce (challenge) and identity (domain). */
|
|
57
|
+
export function createPresentation(vcs, holder, opts) {
|
|
58
|
+
const unsecured = { '@context': [VC_CONTEXT], type: ['VerifiablePresentation'], holder: holder.did, verifiableCredential: vcs };
|
|
59
|
+
const options = { '@context': unsecured['@context'], type: 'DataIntegrityProof', cryptosuite: CRYPTOSUITE, created: opts.created, verificationMethod: verificationMethodOf(holder.did), proofPurpose: 'authentication', challenge: opts.challenge, domain: opts.domain };
|
|
60
|
+
const sig = ed25519.sign(hashData(unsecured, options), holder.privateKey);
|
|
61
|
+
const { '@context': _c, ...proofFields } = options;
|
|
62
|
+
return { ...unsecured, proof: { ...proofFields, challenge: opts.challenge, domain: opts.domain, proofValue: `z${base58.encode(sig)}` } };
|
|
63
|
+
}
|
|
64
|
+
/** Verify a presentation: holder proof over this nonce and domain, then every credential; optionally require subjects to be the holder. */
|
|
65
|
+
export function verifyPresentation(vp, opts) {
|
|
66
|
+
const reasons = [];
|
|
67
|
+
const p = vp.proof;
|
|
68
|
+
if (!p || p.proofPurpose !== 'authentication')
|
|
69
|
+
reasons.push('presentation proof missing or not for authentication');
|
|
70
|
+
else {
|
|
71
|
+
if (p.challenge !== opts.challenge)
|
|
72
|
+
reasons.push('challenge does not match (replayed presentation?)');
|
|
73
|
+
if (p.domain !== opts.domain)
|
|
74
|
+
reasons.push('domain does not match this verifier');
|
|
75
|
+
if (p.verificationMethod !== verificationMethodOf(vp.holder))
|
|
76
|
+
reasons.push('proof key is not the holder');
|
|
77
|
+
const holderKey = publicKeyFromDid(vp.holder);
|
|
78
|
+
if (!holderKey || !verifyProofWithKey(vp, holderKey))
|
|
79
|
+
reasons.push('holder proof does not verify');
|
|
80
|
+
}
|
|
81
|
+
const credentials = vp.verifiableCredential.map((vc) => verifyVC(vc, opts.at ? { at: opts.at } : {}));
|
|
82
|
+
credentials.forEach((c, i) => { if (!c.ok)
|
|
83
|
+
reasons.push(`credential ${i}: ${c.reasons.join('; ')}`); });
|
|
84
|
+
if (opts.requireHolderBinding)
|
|
85
|
+
vp.verifiableCredential.forEach((vc, i) => { if (vc.credentialSubject.id !== vp.holder)
|
|
86
|
+
reasons.push(`credential ${i} is about someone else`); });
|
|
87
|
+
return { ok: reasons.length === 0, reasons, holder: vp.holder };
|
|
88
|
+
}
|
|
89
|
+
/** A DCQL query asking for Data Integrity credentials of given types (OpenID4VP). */
|
|
90
|
+
export function dcqlQuery(requests) {
|
|
91
|
+
return { credentials: requests.map((r) => ({ id: r.id, format: 'ldp_vc', meta: { type_values: [r.types] } })) };
|
|
92
|
+
}
|
|
93
|
+
// ------------------------------------------------------------------------------ //
|
|
94
|
+
// Bitstring Status List
|
|
95
|
+
// ------------------------------------------------------------------------------ //
|
|
96
|
+
/** A status list of `size` bits (default 131,072, the minimum for herd privacy); bit 0 is the first byte's highest bit. */
|
|
97
|
+
export function createStatusList(size = 131_072) {
|
|
98
|
+
if (size % 8 !== 0 || size <= 0)
|
|
99
|
+
throw new Error('vc: status list size must be a positive multiple of 8');
|
|
100
|
+
const bits = new Uint8Array(size / 8);
|
|
101
|
+
return {
|
|
102
|
+
size,
|
|
103
|
+
set(index, value = true) {
|
|
104
|
+
if (!Number.isInteger(index) || index < 0 || index >= size)
|
|
105
|
+
throw new Error('vc: status index out of range');
|
|
106
|
+
const mask = 0x80 >> (index % 8);
|
|
107
|
+
bits[index >> 3] = value ? bits[index >> 3] | mask : bits[index >> 3] & ~mask;
|
|
108
|
+
},
|
|
109
|
+
encoded: () => `u${gzipSync(bits).toString('base64url')}`,
|
|
110
|
+
};
|
|
111
|
+
}
|
|
112
|
+
/** Read one status bit from an `encodedList`. */
|
|
113
|
+
export function statusAt(encodedList, index) {
|
|
114
|
+
if (!encodedList.startsWith('u'))
|
|
115
|
+
throw new Error('vc: encodedList must be multibase base64url');
|
|
116
|
+
const bits = gunzipSync(Buffer.from(encodedList.slice(1), 'base64url'));
|
|
117
|
+
if (index < 0 || index >= bits.length * 8)
|
|
118
|
+
throw new Error('vc: status index out of range');
|
|
119
|
+
return (bits[index >> 3] & (0x80 >> (index % 8))) !== 0;
|
|
120
|
+
}
|
|
121
|
+
/** The signed status list credential to publish at `listUrl`. */
|
|
122
|
+
export function statusListCredential(input, issuer) {
|
|
123
|
+
return signVC({ '@context': [VC_CONTEXT], id: input.listUrl, type: ['VerifiableCredential', 'BitstringStatusListCredential'], issuer: issuer.did, validFrom: input.validFrom, credentialSubject: { id: `${input.listUrl}#list`, type: 'BitstringStatusList', statusPurpose: input.purpose ?? 'revocation', encodedList: input.encodedList } }, issuer, { created: input.validFrom });
|
|
124
|
+
}
|
|
125
|
+
/** The `credentialStatus` entry to put on a credential before signing it. */
|
|
126
|
+
export function statusEntry(listUrl, index, purpose = 'revocation') {
|
|
127
|
+
return { id: `${listUrl}#${index}`, type: 'BitstringStatusListEntry', statusPurpose: purpose, statusListIndex: String(index), statusListCredential: listUrl };
|
|
128
|
+
}
|
|
129
|
+
/** Check a credential's status against its (verified) list credential from the same issuer. */
|
|
130
|
+
export function checkStatus(vc, list) {
|
|
131
|
+
const s = vc.credentialStatus;
|
|
132
|
+
if (!s)
|
|
133
|
+
return { ok: true, status: 'no-status' };
|
|
134
|
+
const lv = verifyVC(list);
|
|
135
|
+
if (!lv.ok || list.issuer !== vc.issuer || list.id !== s.statusListCredential)
|
|
136
|
+
return { ok: false, status: 'list-invalid' };
|
|
137
|
+
const set = statusAt(String(list.credentialSubject.encodedList), Number(s.statusListIndex));
|
|
138
|
+
return { ok: !set, status: set ? (s.statusPurpose === 'suspension' ? 'suspended' : 'revoked') : 'valid' };
|
|
139
|
+
}
|
|
140
|
+
// ------------------------------------------------------------------------------ //
|
|
141
|
+
// did:web, agents, registries, receipts
|
|
142
|
+
// ------------------------------------------------------------------------------ //
|
|
143
|
+
/** The URL of a did:web document: `did:web:example.com` -> `https://example.com/.well-known/did.json`; path segments become directories. */
|
|
144
|
+
export function didWebUrl(did) {
|
|
145
|
+
if (!did.startsWith('did:web:'))
|
|
146
|
+
throw new Error('vc: not a did:web');
|
|
147
|
+
const [host, ...path] = did.slice('did:web:'.length).split(':');
|
|
148
|
+
return `https://${decodeURIComponent(host)}/${path.length ? `${path.map(decodeURIComponent).join('/')}/did.json` : '.well-known/did.json'}`;
|
|
149
|
+
}
|
|
150
|
+
/**
|
|
151
|
+
* Verify a VC from a did:web issuer: fetch the DID document, take the Multikey
|
|
152
|
+
* (Ed25519) verification method the proof names, check the issuer lists it for assertion.
|
|
153
|
+
*/
|
|
154
|
+
export async function verifyDidWebVC(vc, fetchImpl = (u, i) => fetch(u, i)) {
|
|
155
|
+
const reasons = [];
|
|
156
|
+
if (!vc.issuer?.startsWith('did:web:'))
|
|
157
|
+
return { ok: false, reasons: ['issuer is not did:web'] };
|
|
158
|
+
const res = await fetchImpl(didWebUrl(vc.issuer)).catch(() => null);
|
|
159
|
+
if (!res?.ok)
|
|
160
|
+
return { ok: false, reasons: ['DID document not reachable'] };
|
|
161
|
+
const doc = (await res.json());
|
|
162
|
+
if (doc.id !== vc.issuer)
|
|
163
|
+
reasons.push('DID document id does not match the issuer');
|
|
164
|
+
const vmId = vc.proof?.verificationMethod ?? '';
|
|
165
|
+
const vm = doc.verificationMethod?.find((m) => m.id === vmId || `${doc.id}${m.id}` === vmId);
|
|
166
|
+
const listed = (doc.assertionMethod ?? []).some((a) => (typeof a === 'string' ? a : a.id) === vmId || `${doc.id}${typeof a === 'string' ? a : a.id}` === vmId);
|
|
167
|
+
if (!vm || vm.type !== 'Multikey' || !vm.publicKeyMultibase?.startsWith('z6Mk'))
|
|
168
|
+
reasons.push('verification method missing or not an Ed25519 Multikey');
|
|
169
|
+
if (!listed)
|
|
170
|
+
reasons.push('verification method is not an assertion method of the issuer');
|
|
171
|
+
if (reasons.length === 0 && !verifyProofWithKey(vc, base58.decode(vm.publicKeyMultibase.slice(1)).slice(2)))
|
|
172
|
+
reasons.push('proof does not verify');
|
|
173
|
+
return { ok: reasons.length === 0, reasons };
|
|
174
|
+
}
|
|
175
|
+
/** A credential describing an agent: who owns it, what it may do, its licences and model. */
|
|
176
|
+
export function agentCredential(input, issuer) {
|
|
177
|
+
return signVC({ '@context': [VC_CONTEXT], type: ['VerifiableCredential', 'AgentCredential'], issuer: issuer.did, validFrom: input.validFrom, ...(input.validUntil ? { validUntil: input.validUntil } : {}), credentialSubject: { id: input.agent, owner: input.owner, capabilities: input.capabilities, ...(input.licences ? { licences: input.licences } : {}), ...(input.model ? { model: input.model } : {}) } }, issuer, { created: input.validFrom });
|
|
178
|
+
}
|
|
179
|
+
/** Is the issuer accredited, in a registry you trust, for this credential type at this time? */
|
|
180
|
+
export function trustRegistryCheck(issuer, credentialType, registry, at = new Date().toISOString()) {
|
|
181
|
+
const e = registry.find((x) => x.did === issuer);
|
|
182
|
+
if (!e)
|
|
183
|
+
return { accredited: false, reason: 'issuer not in the registry' };
|
|
184
|
+
if (e.validUntil && at > e.validUntil)
|
|
185
|
+
return { accredited: false, reason: 'accreditation expired' };
|
|
186
|
+
if (!e.accreditedFor.includes(credentialType))
|
|
187
|
+
return { accredited: false, reason: `not accredited for ${credentialType}` };
|
|
188
|
+
return { accredited: true, reason: null };
|
|
189
|
+
}
|
|
190
|
+
/** Record a verification as a receipt: what was checked, the result, never the credential's claims. */
|
|
191
|
+
export function verificationReceipt(vc, check, at) {
|
|
192
|
+
return { target: 'vc.verified', payload: { vc: jcsHash(vc), issuer: vc.issuer, types: vc.type, ok: check.ok, reasons: check.reasons, at } };
|
|
193
|
+
}
|
|
194
|
+
//# sourceMappingURL=ecosystem.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"ecosystem.js","sourceRoot":"","sources":["../src/ecosystem.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,EAAE,UAAU,EAAE,QAAQ,EAAE,MAAM,WAAW,CAAC;AACjD,OAAO,EAAE,OAAO,EAAE,MAAM,uBAAuB,CAAC;AAChD,OAAO,EAAE,MAAM,EAAE,MAAM,sBAAsB,CAAC;AAC9C,OAAO,EAAE,MAAM,EAAE,MAAM,aAAa,CAAC;AACrC,OAAO,EAAE,cAAc,EAAE,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AACxE,OAAO,EAAE,WAAW,EAAE,MAAM,EAAE,oBAAoB,EAAE,QAAQ,EAAE,UAAU,EAAsD,MAAM,YAAY,CAAC;AAIjJ,iHAAiH;AACjH,SAAS,QAAQ,CAAC,GAA4B,EAAE,OAAgC;IAC9E,MAAM,EAAE,KAAK,EAAE,KAAK,EAAE,GAAG,SAAS,EAAE,GAAG,GAAG,CAAC;IAC3C,MAAM,GAAG,GAAG,IAAI,UAAU,CAAC,EAAE,CAAC,CAAC;IAC/B,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC;IAC5C,GAAG,CAAC,GAAG,CAAC,MAAM,CAAC,cAAc,CAAC,SAAS,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC;IAC/C,OAAO,GAAG,CAAC;AACb,CAAC;AAED,SAAS,kB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QAAE,OAAO,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,EAAE,sBAAsB,cAAc,EAAE,EAAE,CAAC;IAC5H,OAAO,EAAE,UAAU,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,EAAE,CAAC;AAC5C,CAAC;AAED,uGAAuG;AACvG,MAAM,UAAU,mBAAmB,CAAC,EAAwB,EAAE,KAAyC,EAAE,EAAU;IACjH,OAAO,EAAE,MAAM,EAAE,aAAa,EAAE,OAAO,EAAE,EAAE,EAAE,EAAE,OAAO,CAAC,EAAW,CAAC,EAAE,MAAM,EAAE,EAAE,CAAC,MAAM,EAAE,KAAK,EAAE,EAAE,CAAC,IAAI,EAAE,EAAE,EAAE,KAAK,CAAC,EAAE,EAAE,OAAO,EAAE,KAAK,CAAC,OAAO,EAAE,EAAE,EAAE,EAAE,CAAC;AACvJ,CAAC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -65,4 +65,5 @@ export declare function cvToVC(cv: AgentCV, agentPrivateKey: Uint8Array, opts: {
|
|
|
65
65
|
}): VerifiableCredential;
|
|
66
66
|
/** Decode helper for tests/interop: raw signature bytes from a multibase proofValue. */
|
|
67
67
|
export declare function proofSignatureBytes(proofValue: string): Uint8Array;
|
|
68
|
+
export * from './ecosystem.js';
|
|
68
69
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAiCA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,oBAAoB,CAAC;AACrD,OAAO,EAAY,KAAK,OAAO,EAAE,MAAM,WAAW,CAAC;AAEnD,eAAO,MAAM,UAAU,yCAAyC,CAAC;AACjE,eAAO,MAAM,WAAW,mBAAmB,CAAC;AAE5C,MAAM,WAAW,kBAAkB;IACjC,IAAI,EAAE,oBAAoB,CAAC;IAC3B,WAAW,EAAE,OAAO,WAAW,CAAC;IACh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gB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAExD;AAgBD;;;GAGG;AACH,wBAAgB,MAAM,CACpB,SAAS,EAAE,IAAI,CAAC,oBAAoB,EAAE,OAAO,CAAC,EAC9C,MAAM,EAAE;IAAE,GAAG,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,UAAU,CAAA;CAAE,EAC/C,IAAI,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GACxB,oBAAoB,CAuBtB;AAED,MAAM,WAAW,OAAO;IACtB,EAAE,EAAE,OAAO,CAAC;IACZ,OAAO,EAAE,MAAM,EAAE,CAAC;IAClB,sEAAsE;IACtE,MAAM,EAAE,MAAM,GAAG,IAAI,CAAC;CACvB;AAED;;;;;GAKG;AACH,wBAAgB,QAAQ,CAAC,EAAE,EAAE,oBAAoB,GAAG,SAAS,EAAE,IAAI,GAAE;IAAE,EAAE,CAAC,EAAE,MAAM,CAAA;CAAO,GAAG,OAAO,CA+ClG;AAeD;;;;;;GAMG;AACH,wBAAgB,IAAI,CAClB,UAAU,EAAE,UAAU,EACtB,gBAAgB,EAAE,UAAU,EAC5B,IAAI,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GACxB,oBAAoB,CAwBtB;AAED,wFAAwF;AACxF,wBAAgB,MAAM,CAAC,EAAE,EAAE,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,IAAI,EAAE;IAAE,OAAO,EAAE,MAAM,CAAA;CAAE,GAAG,oBAAoB,CAuBhH;AAED,wFAAwF;AACxF,wBAAgB,mBAAmB,CAAC,UAAU,EAAE,MAAM,GAAG,UAAU,CAGlE;AACD,cAAc,gBAAgB,CAAC"}
|
package/dist/index.js
CHANGED
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;GA2BG;AACH,OAAO,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IAAI,EAAE,CAAC,sBAAsB,EAAE,cAAc,CAAC;QAC9C,MAAM,EAAE,EAAE,CAAC,GAAG;QACd,SAAS,EAAE,EAAE,CAAC,YAAY;QAC1B,iBAAiB,EAAE;YACjB,EAAE,EAAE,EAAE,CAAC,GAAG;YACV,OAAO,EAAE,EAAE,CAAC,OAA6C;YACzD,IAAI,EAAE,EAAE,CAAC,IAAI;YACb,SAAS,EAAE,EAAE,CAAC,SAAS;YACvB,UAAU,EAAE,EAAE,CAAC,UAAU;YACzB,MAAM,EAAE,EAAE,CAAC,MAAM;SAClB;KACF,EACD,EAAE,GAAG,EAAE,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,eAAe,EAAE,EAC5C,IAAI,CACL,CAAC;AACJ,CAAC;AAED,wFAAwF;AACxF,MAAM,UAAU,mBAAmB,CAAC,UAAkB;IACpD,IAAI,CAAC,UAAU,CAAC,UAAU,CAAC,GAAG,CAAC;QAAE,MAAM,IAAI,KAAK,CAAC,yBAAyB,CAAC,CAAC;IAC5E,OAAO,MAAM,CAAC,MAAM,CAAC,UAAU,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;AAC5C,CAAC;AACD,cAAc,gBAAgB,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zanii/vc",
|
|
3
|
-
"version": "0.1.
|
|
3
|
+
"version": "0.1.2",
|
|
4
4
|
"description": "W3C Verifiable Credentials 2.0 bridge - export Zanii credentials and AgentCVs as spec-conformant VCs with genuine eddsa-jcs-2022 DataIntegrityProofs (Zanii already speaks did:key + Ed25519 + JCS, which IS that cryptosuite), and verify any did:key eddsa-jcs-2022 VC from anyone. Bridges the format, not the trust model: revocation freshness and domain binding remain Zanii-side checks.",
|
|
5
5
|
"license": "Apache-2.0",
|
|
6
6
|
"homepage": "https://ledger.zanii.agency",
|
|
@@ -34,9 +34,9 @@
|
|
|
34
34
|
"@noble/curves": "^1.8.1",
|
|
35
35
|
"@noble/hashes": "^1.7.1",
|
|
36
36
|
"@scure/base": "^1.2.1",
|
|
37
|
-
"@zanii/core": "0.4
|
|
38
|
-
"@zanii/cv": "0.1.
|
|
39
|
-
"@zanii/credentials": "0.1.
|
|
37
|
+
"@zanii/core": "^0.5.4",
|
|
38
|
+
"@zanii/cv": "^0.1.2",
|
|
39
|
+
"@zanii/credentials": "^0.1.2"
|
|
40
40
|
},
|
|
41
41
|
"scripts": {
|
|
42
42
|
"build": "tsc -p tsconfig.build.json",
|
package/src/ecosystem.ts
ADDED
|
@@ -0,0 +1,201 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* VCs in the wider ecosystem: OpenID4VCI offers and issuer metadata, presentations bound to
|
|
3
|
+
* a verifier's nonce (for OpenID4VP), Bitstring Status List revocation, did:web issuers,
|
|
4
|
+
* agent credentials, trust-registry checks and verification receipts. Same
|
|
5
|
+
* `eddsa-jcs-2022` proofs as `signVC` / `verifyVC`.
|
|
6
|
+
*/
|
|
7
|
+
import { gunzipSync, gzipSync } from 'node:zlib';
|
|
8
|
+
import { ed25519 } from '@noble/curves/ed25519';
|
|
9
|
+
import { sha256 } from '@noble/hashes/sha256';
|
|
10
|
+
import { base58 } from '@scure/base';
|
|
11
|
+
import { canonicalBytes, jcsHash, publicKeyFromDid } from '@zanii/core';
|
|
12
|
+
import { CRYPTOSUITE, signVC, verificationMethodOf, verifyVC, VC_CONTEXT, type DataIntegrityProof, type VerifiableCredential } from './index.js';
|
|
13
|
+
|
|
14
|
+
type FetchLike = (input: string, init?: RequestInit) => Promise<Response>;
|
|
15
|
+
|
|
16
|
+
// The eddsa-jcs-2022 signing input, as in index.ts: sha256(JCS(options)) || sha256(JCS(document without proof)).
|
|
17
|
+
function hashData(doc: Record<string, unknown>, options: Record<string, unknown>): Uint8Array {
|
|
18
|
+
const { proof: _omit, ...unsecured } = doc;
|
|
19
|
+
const out = new Uint8Array(64);
|
|
20
|
+
out.set(sha256(canonicalBytes(options)), 0);
|
|
21
|
+
out.set(sha256(canonicalBytes(unsecured)), 32);
|
|
22
|
+
return out;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
function verifyProofWithKey(doc: Record<string, unknown> & { proof?: DataIntegrityProof & Record<string, unknown> }, publicKey: Uint8Array): boolean {
|
|
26
|
+
const p = doc.proof;
|
|
27
|
+
if (!p || p.type !== 'DataIntegrityProof' || p.cryptosuite !== CRYPTOSUITE || typeof p.proofValue !== 'string' || !p.proofValue.startsWith('z')) return false;
|
|
28
|
+
try {
|
|
29
|
+
const { proofValue, ...options } = p;
|
|
30
|
+
return ed25519.verify(base58.decode(proofValue.slice(1)), hashData(doc, { '@context': doc['@context'], ...options }), publicKey);
|
|
31
|
+
} catch {
|
|
32
|
+
return false;
|
|
33
|
+
}
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
// ------------------------------------------------------------------------------ //
|
|
37
|
+
// OpenID4VCI
|
|
38
|
+
// ------------------------------------------------------------------------------ //
|
|
39
|
+
|
|
40
|
+
/** Issuer metadata for `/.well-known/openid-credential-issuer`, offering Data Integrity VCs (`ldp_vc`). */
|
|
41
|
+
export function issuerMetadata(input: { issuerUrl: string; credentialEndpoint?: string; configurations: Record<string, { types: string[]; display?: Array<{ name: string; locale?: string }> }> }) {
|
|
42
|
+
return {
|
|
43
|
+
credential_issuer: input.issuerUrl,
|
|
44
|
+
credential_endpoint: input.credentialEndpoint ?? `${input.issuerUrl.replace(/\/$/, '')}/credential`,
|
|
45
|
+
credential_configurations_supported: Object.fromEntries(Object.entries(input.configurations).map(([id, c]) => [id, {
|
|
46
|
+
format: 'ldp_vc', cryptographic_binding_methods_supported: ['did:key'], credential_signing_alg_values_supported: [CRYPTOSUITE],
|
|
47
|
+
credential_definition: { '@context': [VC_CONTEXT], type: c.types }, ...(c.display ? { display: c.display } : {}),
|
|
48
|
+
}])),
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
/** A pre-authorised credential offer and the `openid-credential-offer://` link a wallet scans. */
|
|
53
|
+
export function credentialOffer(input: { issuerUrl: string; configurationIds: string[]; preAuthorizedCode: string; txCode?: { length: number; input_mode?: 'numeric' | 'text' } }) {
|
|
54
|
+
const offer = {
|
|
55
|
+
credential_issuer: input.issuerUrl,
|
|
56
|
+
credential_configuration_ids: input.configurationIds,
|
|
57
|
+
grants: { 'urn:ietf:params:oauth:grant-type:pre-authorized_code': { 'pre-authorized_code': input.preAuthorizedCode, ...(input.txCode ? { tx_code: input.txCode } : {}) } },
|
|
58
|
+
};
|
|
59
|
+
return { offer, uri: `openid-credential-offer://?credential_offer=${encodeURIComponent(JSON.stringify(offer))}` };
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
// ------------------------------------------------------------------------------ //
|
|
63
|
+
// Presentations (OpenID4VP)
|
|
64
|
+
// ------------------------------------------------------------------------------ //
|
|
65
|
+
|
|
66
|
+
export interface VerifiablePresentation {
|
|
67
|
+
'@context': string[];
|
|
68
|
+
type: string[];
|
|
69
|
+
holder: string;
|
|
70
|
+
verifiableCredential: VerifiableCredential[];
|
|
71
|
+
proof?: DataIntegrityProof & { challenge: string; domain: string };
|
|
72
|
+
}
|
|
73
|
+
|
|
74
|
+
/** The holder wraps credentials in a presentation bound to the verifier's nonce (challenge) and identity (domain). */
|
|
75
|
+
export function createPresentation(vcs: VerifiableCredential[], holder: { did: string; privateKey: Uint8Array }, opts: { challenge: string; domain: string; created: string }): VerifiablePresentation {
|
|
76
|
+
const unsecured = { '@context': [VC_CONTEXT], type: ['VerifiablePresentation'], holder: holder.did, verifiableCredential: vcs };
|
|
77
|
+
const options = { '@context': unsecured['@context'], type: 'DataIntegrityProof', cryptosuite: CRYPTOSUITE, created: opts.created, verificationMethod: verificationMethodOf(holder.did), proofPurpose: 'authentication', challenge: opts.challenge, domain: opts.domain };
|
|
78
|
+
const sig = ed25519.sign(hashData(unsecured, options), holder.privateKey);
|
|
79
|
+
const { '@context': _c, ...proofFields } = options;
|
|
80
|
+
return { ...unsecured, proof: { ...(proofFields as unknown as DataIntegrityProof), challenge: opts.challenge, domain: opts.domain, proofValue: `z${base58.encode(sig)}` } };
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** Verify a presentation: holder proof over this nonce and domain, then every credential; optionally require subjects to be the holder. */
|
|
84
|
+
export function verifyPresentation(vp: VerifiablePresentation, opts: { challenge: string; domain: string; at?: string; requireHolderBinding?: boolean }) {
|
|
85
|
+
const reasons: string[] = [];
|
|
86
|
+
const p = vp.proof;
|
|
87
|
+
if (!p || (p as { proofPurpose?: string }).proofPurpose !== 'authentication') reasons.push('presentation proof missing or not for authentication');
|
|
88
|
+
else {
|
|
89
|
+
if (p.challenge !== opts.challenge) reasons.push('challenge does not match (replayed presentation?)');
|
|
90
|
+
if (p.domain !== opts.domain) reasons.push('domain does not match this verifier');
|
|
91
|
+
if (p.verificationMethod !== verificationMethodOf(vp.holder)) reasons.push('proof key is not the holder');
|
|
92
|
+
const holderKey = publicKeyFromDid(vp.holder);
|
|
93
|
+
if (!holderKey || !verifyProofWithKey(vp as never, holderKey)) reasons.push('holder proof does not verify');
|
|
94
|
+
}
|
|
95
|
+
const credentials = vp.verifiableCredential.map((vc) => verifyVC(vc, opts.at ? { at: opts.at } : {}));
|
|
96
|
+
credentials.forEach((c, i) => { if (!c.ok) reasons.push(`credential ${i}: ${c.reasons.join('; ')}`); });
|
|
97
|
+
if (opts.requireHolderBinding) vp.verifiableCredential.forEach((vc, i) => { if (vc.credentialSubject.id !== vp.holder) reasons.push(`credential ${i} is about someone else`); });
|
|
98
|
+
return { ok: reasons.length === 0, reasons, holder: vp.holder };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
/** A DCQL query asking for Data Integrity credentials of given types (OpenID4VP). */
|
|
102
|
+
export function dcqlQuery(requests: Array<{ id: string; types: string[] }>) {
|
|
103
|
+
return { credentials: requests.map((r) => ({ id: r.id, format: 'ldp_vc', meta: { type_values: [r.types] } })) };
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
// ------------------------------------------------------------------------------ //
|
|
107
|
+
// Bitstring Status List
|
|
108
|
+
// ------------------------------------------------------------------------------ //
|
|
109
|
+
|
|
110
|
+
/** A status list of `size` bits (default 131,072, the minimum for herd privacy); bit 0 is the first byte's highest bit. */
|
|
111
|
+
export function createStatusList(size = 131_072) {
|
|
112
|
+
if (size % 8 !== 0 || size <= 0) throw new Error('vc: status list size must be a positive multiple of 8');
|
|
113
|
+
const bits = new Uint8Array(size / 8);
|
|
114
|
+
return {
|
|
115
|
+
size,
|
|
116
|
+
set(index: number, value = true) {
|
|
117
|
+
if (!Number.isInteger(index) || index < 0 || index >= size) throw new Error('vc: status index out of range');
|
|
118
|
+
const mask = 0x80 >> (index % 8);
|
|
119
|
+
bits[index >> 3] = value ? bits[index >> 3]! | mask : bits[index >> 3]! & ~mask;
|
|
120
|
+
},
|
|
121
|
+
encoded: () => `u${gzipSync(bits).toString('base64url')}`,
|
|
122
|
+
};
|
|
123
|
+
}
|
|
124
|
+
|
|
125
|
+
/** Read one status bit from an `encodedList`. */
|
|
126
|
+
export function statusAt(encodedList: string, index: number): boolean {
|
|
127
|
+
if (!encodedList.startsWith('u')) throw new Error('vc: encodedList must be multibase base64url');
|
|
128
|
+
const bits = gunzipSync(Buffer.from(encodedList.slice(1), 'base64url'));
|
|
129
|
+
if (index < 0 || index >= bits.length * 8) throw new Error('vc: status index out of range');
|
|
130
|
+
return (bits[index >> 3]! & (0x80 >> (index % 8))) !== 0;
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
/** The signed status list credential to publish at `listUrl`. */
|
|
134
|
+
export function statusListCredential(input: { listUrl: string; encodedList: string; purpose?: 'revocation' | 'suspension'; validFrom: string }, issuer: { did: string; privateKey: Uint8Array }) {
|
|
135
|
+
return signVC({ '@context': [VC_CONTEXT], id: input.listUrl, type: ['VerifiableCredential', 'BitstringStatusListCredential'], issuer: issuer.did, validFrom: input.validFrom, credentialSubject: { id: `${input.listUrl}#list`, type: 'BitstringStatusList', statusPurpose: input.purpose ?? 'revocation', encodedList: input.encodedList } }, issuer, { created: input.validFrom });
|
|
136
|
+
}
|
|
137
|
+
|
|
138
|
+
/** The `credentialStatus` entry to put on a credential before signing it. */
|
|
139
|
+
export function statusEntry(listUrl: string, index: number, purpose: 'revocation' | 'suspension' = 'revocation') {
|
|
140
|
+
return { id: `${listUrl}#${index}`, type: 'BitstringStatusListEntry', statusPurpose: purpose, statusListIndex: String(index), statusListCredential: listUrl };
|
|
141
|
+
}
|
|
142
|
+
|
|
143
|
+
/** Check a credential's status against its (verified) list credential from the same issuer. */
|
|
144
|
+
export function checkStatus(vc: VerifiableCredential, list: VerifiableCredential) {
|
|
145
|
+
const s = vc.credentialStatus as ReturnType<typeof statusEntry> | undefined;
|
|
146
|
+
if (!s) return { ok: true, status: 'no-status' as const };
|
|
147
|
+
const lv = verifyVC(list);
|
|
148
|
+
if (!lv.ok || list.issuer !== vc.issuer || list.id !== s.statusListCredential) return { ok: false, status: 'list-invalid' as const };
|
|
149
|
+
const set = statusAt(String(list.credentialSubject.encodedList), Number(s.statusListIndex));
|
|
150
|
+
return { ok: !set, status: set ? (s.statusPurpose === 'suspension' ? ('suspended' as const) : ('revoked' as const)) : ('valid' as const) };
|
|
151
|
+
}
|
|
152
|
+
|
|
153
|
+
// ------------------------------------------------------------------------------ //
|
|
154
|
+
// did:web, agents, registries, receipts
|
|
155
|
+
// ------------------------------------------------------------------------------ //
|
|
156
|
+
|
|
157
|
+
/** The URL of a did:web document: `did:web:example.com` -> `https://example.com/.well-known/did.json`; path segments become directories. */
|
|
158
|
+
export function didWebUrl(did: string): string {
|
|
159
|
+
if (!did.startsWith('did:web:')) throw new Error('vc: not a did:web');
|
|
160
|
+
const [host, ...path] = did.slice('did:web:'.length).split(':');
|
|
161
|
+
return `https://${decodeURIComponent(host!)}/${path.length ? `${path.map(decodeURIComponent).join('/')}/did.json` : '.well-known/did.json'}`;
|
|
162
|
+
}
|
|
163
|
+
|
|
164
|
+
/**
|
|
165
|
+
* Verify a VC from a did:web issuer: fetch the DID document, take the Multikey
|
|
166
|
+
* (Ed25519) verification method the proof names, check the issuer lists it for assertion.
|
|
167
|
+
*/
|
|
168
|
+
export async function verifyDidWebVC(vc: VerifiableCredential, fetchImpl: FetchLike = (u, i) => fetch(u, i)) {
|
|
169
|
+
const reasons: string[] = [];
|
|
170
|
+
if (!vc.issuer?.startsWith('did:web:')) return { ok: false, reasons: ['issuer is not did:web'] };
|
|
171
|
+
const res = await fetchImpl(didWebUrl(vc.issuer)).catch(() => null);
|
|
172
|
+
if (!res?.ok) return { ok: false, reasons: ['DID document not reachable'] };
|
|
173
|
+
const doc = (await res.json()) as { id: string; verificationMethod?: Array<{ id: string; type: string; publicKeyMultibase?: string }>; assertionMethod?: Array<string | { id: string }> };
|
|
174
|
+
if (doc.id !== vc.issuer) reasons.push('DID document id does not match the issuer');
|
|
175
|
+
const vmId = vc.proof?.verificationMethod ?? '';
|
|
176
|
+
const vm = doc.verificationMethod?.find((m) => m.id === vmId || `${doc.id}${m.id}` === vmId);
|
|
177
|
+
const listed = (doc.assertionMethod ?? []).some((a) => (typeof a === 'string' ? a : a.id) === vmId || `${doc.id}${typeof a === 'string' ? a : a.id}` === vmId);
|
|
178
|
+
if (!vm || vm.type !== 'Multikey' || !vm.publicKeyMultibase?.startsWith('z6Mk')) reasons.push('verification method missing or not an Ed25519 Multikey');
|
|
179
|
+
if (!listed) reasons.push('verification method is not an assertion method of the issuer');
|
|
180
|
+
if (reasons.length === 0 && !verifyProofWithKey(vc as never, base58.decode(vm!.publicKeyMultibase!.slice(1)).slice(2))) reasons.push('proof does not verify');
|
|
181
|
+
return { ok: reasons.length === 0, reasons };
|
|
182
|
+
}
|
|
183
|
+
|
|
184
|
+
/** A credential describing an agent: who owns it, what it may do, its licences and model. */
|
|
185
|
+
export function agentCredential(input: { agent: string; owner: string; capabilities: string[]; licences?: string[]; model?: string; validFrom: string; validUntil?: string }, issuer: { did: string; privateKey: Uint8Array }) {
|
|
186
|
+
return signVC({ '@context': [VC_CONTEXT], type: ['VerifiableCredential', 'AgentCredential'], issuer: issuer.did, validFrom: input.validFrom, ...(input.validUntil ? { validUntil: input.validUntil } : {}), credentialSubject: { id: input.agent, owner: input.owner, capabilities: input.capabilities, ...(input.licences ? { licences: input.licences } : {}), ...(input.model ? { model: input.model } : {}) } }, issuer, { created: input.validFrom });
|
|
187
|
+
}
|
|
188
|
+
|
|
189
|
+
/** Is the issuer accredited, in a registry you trust, for this credential type at this time? */
|
|
190
|
+
export function trustRegistryCheck(issuer: string, credentialType: string, registry: Array<{ did: string; accreditedFor: string[]; validUntil?: string }>, at = new Date().toISOString()) {
|
|
191
|
+
const e = registry.find((x) => x.did === issuer);
|
|
192
|
+
if (!e) return { accredited: false, reason: 'issuer not in the registry' };
|
|
193
|
+
if (e.validUntil && at > e.validUntil) return { accredited: false, reason: 'accreditation expired' };
|
|
194
|
+
if (!e.accreditedFor.includes(credentialType)) return { accredited: false, reason: `not accredited for ${credentialType}` };
|
|
195
|
+
return { accredited: true, reason: null };
|
|
196
|
+
}
|
|
197
|
+
|
|
198
|
+
/** Record a verification as a receipt: what was checked, the result, never the credential's claims. */
|
|
199
|
+
export function verificationReceipt(vc: VerifiableCredential, check: { ok: boolean; reasons: string[] }, at: string) {
|
|
200
|
+
return { target: 'vc.verified', payload: { vc: jcsHash(vc as never), issuer: vc.issuer, types: vc.type, ok: check.ok, reasons: check.reasons, at } };
|
|
201
|
+
}
|
package/src/index.ts
CHANGED