@verana-labs/vs-agent-plugin-openid4vc 1.11.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/LICENSE +201 -0
- package/README.md +193 -0
- package/build/config.d.ts +5 -0
- package/build/config.js +279 -0
- package/build/config.js.map +1 -0
- package/build/index.d.ts +12 -0
- package/build/index.js +28 -0
- package/build/index.js.map +1 -0
- package/build/nestjs/IssuerController.d.ts +8 -0
- package/build/nestjs/IssuerController.js +66 -0
- package/build/nestjs/IssuerController.js.map +1 -0
- package/build/nestjs/OpenId4VcPlugin.d.ts +3 -0
- package/build/nestjs/OpenId4VcPlugin.js +61 -0
- package/build/nestjs/OpenId4VcPlugin.js.map +1 -0
- package/build/nestjs/VerifierController.d.ts +8 -0
- package/build/nestjs/VerifierController.js +66 -0
- package/build/nestjs/VerifierController.js.map +1 -0
- package/build/nestjs/dto.d.ts +7 -0
- package/build/nestjs/dto.js +34 -0
- package/build/nestjs/dto.js.map +1 -0
- package/build/sdk/setupOpenId4Vc.d.ts +18 -0
- package/build/sdk/setupOpenId4Vc.js +111 -0
- package/build/sdk/setupOpenId4Vc.js.map +1 -0
- package/build/services/CertificateService.d.ts +22 -0
- package/build/services/CertificateService.js +249 -0
- package/build/services/CertificateService.js.map +1 -0
- package/build/services/IssuerService.d.ts +47 -0
- package/build/services/IssuerService.js +185 -0
- package/build/services/IssuerService.js.map +1 -0
- package/build/services/VerifierService.d.ts +57 -0
- package/build/services/VerifierService.js +289 -0
- package/build/services/VerifierService.js.map +1 -0
- package/build/trust/CertificateTrust.d.ts +7 -0
- package/build/trust/CertificateTrust.js +29 -0
- package/build/trust/CertificateTrust.js.map +1 -0
- package/build/trust/TrustClient.d.ts +12 -0
- package/build/trust/TrustClient.js +120 -0
- package/build/trust/TrustClient.js.map +1 -0
- package/build/trust/keyBinding.d.ts +14 -0
- package/build/trust/keyBinding.js +171 -0
- package/build/trust/keyBinding.js.map +1 -0
- package/build/trust/types.d.ts +28 -0
- package/build/trust/types.js +3 -0
- package/build/trust/types.js.map +1 -0
- package/build/trust/verdict.d.ts +2 -0
- package/build/trust/verdict.js +13 -0
- package/build/trust/verdict.js.map +1 -0
- package/build/types.d.ts +55 -0
- package/build/types.js +3 -0
- package/build/types.js.map +1 -0
- package/package.json +47 -0
|
@@ -0,0 +1,185 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.IssuerService = exports.OpenId4VcOfferNotFoundError = exports.OpenId4VcIssuerRequestError = void 0;
|
|
4
|
+
const core_1 = require("@credo-ts/core");
|
|
5
|
+
const config_1 = require("../config");
|
|
6
|
+
const keyBinding_1 = require("../trust/keyBinding");
|
|
7
|
+
const CertificateService_1 = require("./CertificateService");
|
|
8
|
+
class OpenId4VcIssuerRequestError extends Error {
|
|
9
|
+
}
|
|
10
|
+
exports.OpenId4VcIssuerRequestError = OpenId4VcIssuerRequestError;
|
|
11
|
+
class OpenId4VcOfferNotFoundError extends Error {
|
|
12
|
+
}
|
|
13
|
+
exports.OpenId4VcOfferNotFoundError = OpenId4VcOfferNotFoundError;
|
|
14
|
+
class IssuerService {
|
|
15
|
+
constructor(agent, options) {
|
|
16
|
+
this.agent = agent;
|
|
17
|
+
this.options = options;
|
|
18
|
+
this.initialized = false;
|
|
19
|
+
this.mapCredentialRequest = async (input) => {
|
|
20
|
+
this.assertInitialized();
|
|
21
|
+
const signingCertificate = this.signingCertificateHandle();
|
|
22
|
+
const configuration = (0, config_1.findCredentialConfiguration)(this.options, input.credentialConfigurationId);
|
|
23
|
+
if (!configuration) {
|
|
24
|
+
throw new Error(`unknown credential configuration '${input.credentialConfigurationId}'`);
|
|
25
|
+
}
|
|
26
|
+
const claims = (0, config_1.parseOfferClaims)(configuration, input.issuanceSession.issuanceMetadata);
|
|
27
|
+
const issuedAt = Math.floor(Date.now() / 1000);
|
|
28
|
+
const payload = Object.assign(Object.assign({}, claims), { vct: configuration.vct, iat: issuedAt, exp: issuedAt + configuration.ttlSeconds });
|
|
29
|
+
return {
|
|
30
|
+
type: 'credentials',
|
|
31
|
+
format: core_1.ClaimFormat.SdJwtDc,
|
|
32
|
+
credentials: input.holderBinding.keys.map(holderKey => ({
|
|
33
|
+
payload,
|
|
34
|
+
holder: holderKey.method === 'did'
|
|
35
|
+
? { method: 'did', didUrl: holderKey.didUrl }
|
|
36
|
+
: { method: 'jwk', jwk: holderKey.jwk },
|
|
37
|
+
issuer: {
|
|
38
|
+
method: 'x5c',
|
|
39
|
+
x5c: signingCertificate.chain,
|
|
40
|
+
issuer: this.options.publicApiBaseUrl,
|
|
41
|
+
},
|
|
42
|
+
disclosureFrame: { _sd: configuration.disclosureFrame },
|
|
43
|
+
headerType: 'dc+sd-jwt',
|
|
44
|
+
})),
|
|
45
|
+
};
|
|
46
|
+
};
|
|
47
|
+
}
|
|
48
|
+
ensureInitialized() {
|
|
49
|
+
var _a;
|
|
50
|
+
(_a = this.initialization) !== null && _a !== void 0 ? _a : (this.initialization = this.initialize());
|
|
51
|
+
return this.initialization;
|
|
52
|
+
}
|
|
53
|
+
async createOffer(credentialConfigurationId, inputClaims) {
|
|
54
|
+
this.assertInitialized();
|
|
55
|
+
const configuration = (0, config_1.findCredentialConfiguration)(this.options, credentialConfigurationId);
|
|
56
|
+
if (!configuration) {
|
|
57
|
+
throw new OpenId4VcIssuerRequestError(`unknown credential configuration '${credentialConfigurationId}'`);
|
|
58
|
+
}
|
|
59
|
+
let claims;
|
|
60
|
+
try {
|
|
61
|
+
claims = (0, config_1.parseOfferClaims)(configuration, inputClaims);
|
|
62
|
+
}
|
|
63
|
+
catch (error) {
|
|
64
|
+
throw new OpenId4VcIssuerRequestError(error instanceof Error ? error.message : 'invalid claims');
|
|
65
|
+
}
|
|
66
|
+
const { credentialOffer, issuanceSession } = await this.issuerApi().createCredentialOffer({
|
|
67
|
+
issuerId: this.issuerOptions().id,
|
|
68
|
+
credentialConfigurationIds: [configuration.id],
|
|
69
|
+
preAuthorizedCodeFlowConfig: {},
|
|
70
|
+
issuanceMetadata: claims,
|
|
71
|
+
});
|
|
72
|
+
return { credentialOffer, issuanceSessionId: issuanceSession.id };
|
|
73
|
+
}
|
|
74
|
+
async getOfferState(id) {
|
|
75
|
+
this.assertInitialized();
|
|
76
|
+
let session;
|
|
77
|
+
try {
|
|
78
|
+
session = await this.issuerApi().getIssuanceSessionById(id);
|
|
79
|
+
}
|
|
80
|
+
catch (error) {
|
|
81
|
+
if (error instanceof core_1.RecordNotFoundError) {
|
|
82
|
+
throw new OpenId4VcOfferNotFoundError(`OpenID4VC offer '${id}' was not found`);
|
|
83
|
+
}
|
|
84
|
+
throw error;
|
|
85
|
+
}
|
|
86
|
+
return Object.assign({ id: session.id, state: session.state, createdAt: session.createdAt }, (session.expiresAt ? { expiresAt: session.expiresAt } : {}));
|
|
87
|
+
}
|
|
88
|
+
getVctMetadata(configurationId) {
|
|
89
|
+
const configuration = (0, config_1.findCredentialConfiguration)(this.options, configurationId);
|
|
90
|
+
if (!configuration)
|
|
91
|
+
return undefined;
|
|
92
|
+
return Object.assign(Object.assign({ vct: configuration.vct, name: configuration.name }, (configuration.description ? { description: configuration.description } : {})), { display: [
|
|
93
|
+
Object.assign({ locale: 'en', name: configuration.name }, (configuration.description ? { description: configuration.description } : {})),
|
|
94
|
+
], claims: configuration.claims.map(claim => ({ path: [claim] })) });
|
|
95
|
+
}
|
|
96
|
+
async initialize() {
|
|
97
|
+
const agentDid = this.agent.did;
|
|
98
|
+
if (!agentDid)
|
|
99
|
+
throw new Error('OpenID4VC issuer initialization requires an agent DID');
|
|
100
|
+
const signingCertificate = await (0, CertificateService_1.loadSigningCertificate)(this.agent, this.issuerOptions().signing, this.options.publicApiBaseUrl, 'issuer');
|
|
101
|
+
const certificateDid = (0, CertificateService_1.didFromValidatedCertificate)(signingCertificate.certificate);
|
|
102
|
+
if (certificateDid !== agentDid) {
|
|
103
|
+
throw new Error('OpenID4VC issuer certificate DID does not match the agent DID');
|
|
104
|
+
}
|
|
105
|
+
await (0, CertificateService_1.publishDevelopmentSigningKey)(this.agent, signingCertificate, 'issuer');
|
|
106
|
+
const binding = await (0, keyBinding_1.verifyKeyBoundToDid)(this.agent, agentDid, signingCertificate.certificate.publicJwk.toJson(), ['assertionMethod'], (0, keyBinding_1.ownDidResolutionPolicy)(agentDid));
|
|
107
|
+
if (binding === 'unresolvable') {
|
|
108
|
+
throw new Error('OpenID4VC issuer DID could not be resolved for assertionMethod key binding');
|
|
109
|
+
}
|
|
110
|
+
if (binding !== 'bound') {
|
|
111
|
+
throw new Error('OpenID4VC issuer certificate key is not bound to the agent DID assertionMethod');
|
|
112
|
+
}
|
|
113
|
+
await this.createOrUpdateIssuer(signingCertificate);
|
|
114
|
+
this.signingCertificate = signingCertificate;
|
|
115
|
+
this.initialized = true;
|
|
116
|
+
}
|
|
117
|
+
async createOrUpdateIssuer(signingCertificate) {
|
|
118
|
+
const issuer = this.issuerOptions();
|
|
119
|
+
const issuerId = issuer.id;
|
|
120
|
+
const metadata = {
|
|
121
|
+
issuerId,
|
|
122
|
+
display: [{ name: issuer.displayName, locale: 'en' }],
|
|
123
|
+
credentialConfigurationsSupported: this.credentialConfigurationsSupported(),
|
|
124
|
+
};
|
|
125
|
+
try {
|
|
126
|
+
await this.issuerApi().getIssuerByIssuerId(issuerId);
|
|
127
|
+
}
|
|
128
|
+
catch (error) {
|
|
129
|
+
if (!(error instanceof core_1.RecordNotFoundError))
|
|
130
|
+
throw error;
|
|
131
|
+
await this.issuerApi().createIssuer(Object.assign(Object.assign({}, metadata), { metadataSigner: {
|
|
132
|
+
method: 'x5c',
|
|
133
|
+
x5c: signingCertificate.development
|
|
134
|
+
? signingCertificate.chain
|
|
135
|
+
: signingCertificate.chain.filter((certificate, index, chain) => index !== chain.length - 1 || certificate.subject !== certificate.issuer),
|
|
136
|
+
} }));
|
|
137
|
+
return;
|
|
138
|
+
}
|
|
139
|
+
await this.issuerApi().updateIssuerMetadata(metadata);
|
|
140
|
+
}
|
|
141
|
+
credentialConfigurationsSupported() {
|
|
142
|
+
return Object.fromEntries(this.options.credentialConfigurations.map(configuration => [
|
|
143
|
+
configuration.id,
|
|
144
|
+
{
|
|
145
|
+
format: 'dc+sd-jwt',
|
|
146
|
+
vct: configuration.vct,
|
|
147
|
+
cryptographic_binding_methods_supported: ['jwk'],
|
|
148
|
+
credential_signing_alg_values_supported: ['ES256'],
|
|
149
|
+
proof_types_supported: { jwt: { proof_signing_alg_values_supported: ['ES256'] } },
|
|
150
|
+
credential_metadata: {
|
|
151
|
+
display: [
|
|
152
|
+
Object.assign(Object.assign({ name: configuration.name }, (configuration.description ? { description: configuration.description } : {})), { locale: 'en' }),
|
|
153
|
+
],
|
|
154
|
+
claims: configuration.claims.map(claim => ({ path: [claim] })),
|
|
155
|
+
},
|
|
156
|
+
},
|
|
157
|
+
]));
|
|
158
|
+
}
|
|
159
|
+
issuerApi() {
|
|
160
|
+
var _a;
|
|
161
|
+
const issuer = (_a = this.agent.modules.openId4Vc) === null || _a === void 0 ? void 0 : _a.issuer;
|
|
162
|
+
if (!issuer)
|
|
163
|
+
throw new Error('OpenID4VC issuer API is not enabled on this agent');
|
|
164
|
+
return issuer;
|
|
165
|
+
}
|
|
166
|
+
issuerOptions() {
|
|
167
|
+
const issuer = this.options.issuer;
|
|
168
|
+
if (!issuer)
|
|
169
|
+
throw new Error('OpenID4VC issuer capability is not configured');
|
|
170
|
+
return issuer;
|
|
171
|
+
}
|
|
172
|
+
signingCertificateHandle() {
|
|
173
|
+
const signingCertificate = this.signingCertificate;
|
|
174
|
+
if (!signingCertificate)
|
|
175
|
+
throw new Error('OpenID4VC issuer service is not initialized');
|
|
176
|
+
return signingCertificate;
|
|
177
|
+
}
|
|
178
|
+
assertInitialized() {
|
|
179
|
+
if (!this.initialized || !this.signingCertificate) {
|
|
180
|
+
throw new Error('OpenID4VC issuer service is not initialized');
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
}
|
|
184
|
+
exports.IssuerService = IssuerService;
|
|
185
|
+
//# sourceMappingURL=IssuerService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"IssuerService.js","sourceRoot":"","sources":["../../src/services/IssuerService.ts"],"names":[],"mappings":";;;AASA,yCAAiE;AAEjE,sCAAyE;AACzE,oDAAiF;AAEjF,6DAK6B;AAgC7B,MAAa,2BAA4B,SAAQ,KAAK;CAAG;AAAzD,kEAAyD;AACzD,MAAa,2BAA4B,SAAQ,KAAK;CAAG;AAAzD,kEAAyD;AAEzD,MAAa,aAAa;IAKxB,YACmB,KAA2B,EAC3B,OAA+B;QAD/B,UAAK,GAAL,KAAK,CAAsB;QAC3B,YAAO,GAAP,OAAO,CAAwB;QAJ1C,gBAAW,GAAG,KAAK,CAAA;QA+EpB,yBAAoB,GAAkD,KAAK,EAAC,KAAK,EAAC,EAAE;YACzF,IAAI,CAAC,iBAAiB,EAAE,CAAA;YACxB,MAAM,kBAAkB,GAAG,IAAI,CAAC,wBAAwB,EAAE,CAAA;YAC1D,MAAM,aAAa,GAAG,IAAA,oCAA2B,EAAC,IAAI,CAAC,OAAO,EAAE,KAAK,CAAC,yBAAyB,CAAC,CAAA;YAChG,IAAI,CAAC,aAAa,EAAE,CAAC;gBACnB,MAAM,IAAI,KAAK,CAAC,qCAAqC,KAAK,CAAC,yBAAyB,GAAG,CAAC,CAAA;YAC1F,CAAC;YAED,MAAM,MAAM,GAAG,IAAA,yBAAgB,EAAC,aAAa,EAAE,KAAK,CAAC,eAAe,CAAC,gBAAgB,CAAC,CAAA;YACtF,MAAM,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAK,CAAC,CAAA;YAC/C,MAAM,OAAO,mCACR,MAAM,KACT,GAAG,EAAE,aAAa,CAAC,GAAG,EACtB,GAAG,EAAE,QAAQ,EACb,GAAG,EAAE,QAAQ,GAAG,aAAa,CAAC,UAAU,GACzC,CAAA;YAED,OAAO;g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C,KAAK,CAAC,EAAE,CAAC,CAAC;iBAC/D;aACF;SACF,CAAC,CACH,CAAA;IACH,CAAC;IAEO,SAAS;;QACf,MAAM,MAAM,GAAG,MAAA,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,SAAS,0CAAE,MAAM,CAAA;QACnD,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,mDAAmD,CAAC,CAAA;QACjF,OAAO,MAAM,CAAA;IACf,CAAC;IAEO,aAAa;QACnB,MAAM,MAAM,GAAG,IAAI,CAAC,OAAO,CAAC,MAAM,CAAA;QAClC,IAAI,CAAC,MAAM;YAAE,MAAM,IAAI,KAAK,CAAC,+CAA+C,CAAC,CAAA;QAC7E,OAAO,MAAM,CAAA;IACf,CAAC;IAEO,wBAAwB;QAC9B,MAAM,kBAAkB,GAAG,IAAI,CAAC,kBAAkB,CAAA;QAClD,IAAI,CAAC,kBAAkB;YAAE,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;QACvF,OAAO,kBAAkB,CAAA;IAC3B,CAAC;IAEO,iBAAiB;QACvB,IAAI,CAAC,IAAI,CAAC,WAAW,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC;YAClD,MAAM,IAAI,KAAK,CAAC,6CAA6C,CAAC,CAAA;QAChE,CAAC;IACH,CAAC;CACF;AAzOD,sCAyOC"}
|
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import type { TrustVerdict } from '../trust/types';
|
|
2
|
+
import type { OpenId4VcPluginOptions } from '../types';
|
|
3
|
+
import type { BaseAgent } from '@credo-ts/core';
|
|
4
|
+
import type { OpenId4VcVerificationSessionRecord, OpenId4VcVerifierApi } from '@credo-ts/openid4vc';
|
|
5
|
+
type VerifierApi = Pick<OpenId4VcVerifierApi, 'getVerifierByVerifierId' | 'createVerifier' | 'updateVerifierMetadata' | 'createAuthorizationRequest' | 'getVerificationSessionById' | 'getVerifiedAuthorizationResponse'>;
|
|
6
|
+
export type OpenId4VcVerifierAgent = Pick<BaseAgent, 'dids' | 'genericRecords' | 'kms' | 'x509'> & {
|
|
7
|
+
did?: string;
|
|
8
|
+
modules: {
|
|
9
|
+
openId4Vc?: {
|
|
10
|
+
verifier?: VerifierApi;
|
|
11
|
+
};
|
|
12
|
+
};
|
|
13
|
+
};
|
|
14
|
+
export interface OpenId4VcVerificationRequest {
|
|
15
|
+
authorizationRequest: string;
|
|
16
|
+
verificationSessionId: string;
|
|
17
|
+
}
|
|
18
|
+
export interface OpenId4VcVerifiedCredentialResult {
|
|
19
|
+
vct: string;
|
|
20
|
+
disclosedClaims: Record<string, unknown>;
|
|
21
|
+
}
|
|
22
|
+
export interface OpenId4VcVerificationResult {
|
|
23
|
+
state: OpenId4VcVerificationSessionRecord['state'];
|
|
24
|
+
cryptographicVerified: boolean;
|
|
25
|
+
accepted: boolean;
|
|
26
|
+
trust?: TrustVerdict;
|
|
27
|
+
credential?: OpenId4VcVerifiedCredentialResult;
|
|
28
|
+
}
|
|
29
|
+
export declare class OpenId4VcVerifierRequestError extends Error {
|
|
30
|
+
}
|
|
31
|
+
export declare class UnknownVerificationSessionError extends Error {
|
|
32
|
+
}
|
|
33
|
+
export declare class VerifierService {
|
|
34
|
+
private readonly agent;
|
|
35
|
+
private readonly options;
|
|
36
|
+
private initialization?;
|
|
37
|
+
private signingCertificate?;
|
|
38
|
+
private initialized;
|
|
39
|
+
private readonly trustClient;
|
|
40
|
+
constructor(agent: OpenId4VcVerifierAgent, options: OpenId4VcPluginOptions);
|
|
41
|
+
ensureInitialized(): Promise<void>;
|
|
42
|
+
createRequest(policyId: string): Promise<OpenId4VcVerificationRequest>;
|
|
43
|
+
getResult(sessionId: string): Promise<OpenId4VcVerificationResult>;
|
|
44
|
+
private initialize;
|
|
45
|
+
private createOrUpdateVerifier;
|
|
46
|
+
private getSession;
|
|
47
|
+
private getVerifiedResponse;
|
|
48
|
+
private assertSessionOwnership;
|
|
49
|
+
private assertStableVerifiedSession;
|
|
50
|
+
private matchConfiguredPolicy;
|
|
51
|
+
private blockedResult;
|
|
52
|
+
private verifierApi;
|
|
53
|
+
private verifierOptions;
|
|
54
|
+
private trustOptions;
|
|
55
|
+
private signingCertificateHandle;
|
|
56
|
+
}
|
|
57
|
+
export {};
|
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.VerifierService = exports.UnknownVerificationSessionError = exports.OpenId4VcVerifierRequestError = void 0;
|
|
4
|
+
const core_1 = require("@credo-ts/core");
|
|
5
|
+
const openid4vc_1 = require("@credo-ts/openid4vc");
|
|
6
|
+
const config_1 = require("../config");
|
|
7
|
+
const TrustClient_1 = require("../trust/TrustClient");
|
|
8
|
+
const keyBinding_1 = require("../trust/keyBinding");
|
|
9
|
+
const CertificateService_1 = require("./CertificateService");
|
|
10
|
+
class OpenId4VcVerifierRequestError extends Error {
|
|
11
|
+
}
|
|
12
|
+
exports.OpenId4VcVerifierRequestError = OpenId4VcVerifierRequestError;
|
|
13
|
+
class UnknownVerificationSessionError extends Error {
|
|
14
|
+
}
|
|
15
|
+
exports.UnknownVerificationSessionError = UnknownVerificationSessionError;
|
|
16
|
+
class VerifierService {
|
|
17
|
+
constructor(agent, options) {
|
|
18
|
+
this.agent = agent;
|
|
19
|
+
this.options = options;
|
|
20
|
+
this.initialized = false;
|
|
21
|
+
const trust = this.options.trust;
|
|
22
|
+
if (!trust)
|
|
23
|
+
throw new Error('OpenID4VC verifier requires trust configuration');
|
|
24
|
+
this.trustClient = new TrustClient_1.TrustClient(trust);
|
|
25
|
+
}
|
|
26
|
+
ensureInitialized() {
|
|
27
|
+
var _a;
|
|
28
|
+
(_a = this.initialization) !== null && _a !== void 0 ? _a : (this.initialization = this.initialize());
|
|
29
|
+
return this.initialization;
|
|
30
|
+
}
|
|
31
|
+
async createRequest(policyId) {
|
|
32
|
+
await this.ensureInitialized();
|
|
33
|
+
const policy = (0, config_1.findVerifierPolicy)(this.options, policyId);
|
|
34
|
+
if (!policy) {
|
|
35
|
+
throw new OpenId4VcVerifierRequestError(`unknown verifier policy '${policyId}'`);
|
|
36
|
+
}
|
|
37
|
+
const configuration = (0, config_1.findCredentialConfiguration)(this.options, policy.credentialConfigurationId);
|
|
38
|
+
if (!configuration) {
|
|
39
|
+
throw new OpenId4VcVerifierRequestError(`verifier policy '${policyId}' references an unknown credential configuration`);
|
|
40
|
+
}
|
|
41
|
+
const { authorizationRequest, verificationSession } = await this.verifierApi().createAuthorizationRequest({
|
|
42
|
+
verifierId: this.verifierOptions().id,
|
|
43
|
+
requestSigner: {
|
|
44
|
+
method: 'x5c',
|
|
45
|
+
x5c: this.signingCertificateHandle().chain,
|
|
46
|
+
clientIdPrefix: 'x509_hash',
|
|
47
|
+
},
|
|
48
|
+
responseMode: 'direct_post.jwt',
|
|
49
|
+
dcql: {
|
|
50
|
+
query: {
|
|
51
|
+
credentials: [
|
|
52
|
+
{
|
|
53
|
+
id: configuration.id,
|
|
54
|
+
format: 'dc+sd-jwt',
|
|
55
|
+
meta: { vct_values: [configuration.vct] },
|
|
56
|
+
claims: policy.requestedClaims.map(name => ({ path: [name] })),
|
|
57
|
+
},
|
|
58
|
+
],
|
|
59
|
+
},
|
|
60
|
+
},
|
|
61
|
+
});
|
|
62
|
+
return {
|
|
63
|
+
authorizationRequest,
|
|
64
|
+
verificationSessionId: verificationSession.id,
|
|
65
|
+
};
|
|
66
|
+
}
|
|
67
|
+
async getResult(sessionId) {
|
|
68
|
+
var _a, _b;
|
|
69
|
+
const session = await this.getSession(sessionId);
|
|
70
|
+
this.assertSessionOwnership(session, sessionId);
|
|
71
|
+
if (session.state !== openid4vc_1.OpenId4VcVerificationSessionState.ResponseVerified) {
|
|
72
|
+
return {
|
|
73
|
+
state: session.state,
|
|
74
|
+
cryptographicVerified: false,
|
|
75
|
+
accepted: false,
|
|
76
|
+
};
|
|
77
|
+
}
|
|
78
|
+
const verified = await this.getVerifiedResponse(sessionId);
|
|
79
|
+
this.assertStableVerifiedSession(verified, sessionId);
|
|
80
|
+
const matched = this.matchConfiguredPolicy(verified);
|
|
81
|
+
if (!matched) {
|
|
82
|
+
return this.blockedResult(session.state, null, null, 'unbound');
|
|
83
|
+
}
|
|
84
|
+
const { policy } = matched;
|
|
85
|
+
const configuration = (0, config_1.findCredentialConfiguration)(this.options, policy.credentialConfigurationId);
|
|
86
|
+
if (!configuration) {
|
|
87
|
+
return this.blockedResult(session.state, null, null, 'unbound');
|
|
88
|
+
}
|
|
89
|
+
const presentation = (_b = (_a = verified.dcql) === null || _a === void 0 ? void 0 : _a.presentations[configuration.id]) === null || _b === void 0 ? void 0 : _b[0];
|
|
90
|
+
if (!isX5cSdJwtDcPresentation(presentation)) {
|
|
91
|
+
return this.blockedResult(session.state, null, configuration.vtjscId, 'unbound');
|
|
92
|
+
}
|
|
93
|
+
const disclosedClaims = configuredDisclosedClaims(presentation.prettyClaims, policy.requestedClaims);
|
|
94
|
+
if (presentation.prettyClaims.vct !== configuration.vct || !disclosedClaims) {
|
|
95
|
+
return this.blockedResult(session.state, null, configuration.vtjscId, 'unbound');
|
|
96
|
+
}
|
|
97
|
+
const issuerCertificate = presentation.issuer.x5c[0];
|
|
98
|
+
let issuerDid;
|
|
99
|
+
let issuerPublicJwk;
|
|
100
|
+
try {
|
|
101
|
+
issuerDid = (0, CertificateService_1.didFromValidatedCertificate)(issuerCertificate);
|
|
102
|
+
issuerPublicJwk = issuerCertificate.publicJwk.toJson();
|
|
103
|
+
}
|
|
104
|
+
catch (_c) {
|
|
105
|
+
return this.blockedResult(session.state, null, configuration.vtjscId, 'unbound');
|
|
106
|
+
}
|
|
107
|
+
const credential = { vct: configuration.vct, disclosedClaims };
|
|
108
|
+
const binding = await (0, keyBinding_1.verifyKeyBoundToDid)(this.agent, issuerDid, issuerPublicJwk, ['assertionMethod'], {
|
|
109
|
+
allowedWebHosts: this.trustOptions().allowedDidWebHosts,
|
|
110
|
+
timeoutMs: this.trustOptions().timeoutMs,
|
|
111
|
+
});
|
|
112
|
+
if (binding !== 'bound') {
|
|
113
|
+
return {
|
|
114
|
+
state: session.state,
|
|
115
|
+
cryptographicVerified: true,
|
|
116
|
+
accepted: false,
|
|
117
|
+
trust: (0, keyBinding_1.blockingBindingVerdict)(issuerDid, configuration.vtjscId, binding),
|
|
118
|
+
credential,
|
|
119
|
+
};
|
|
120
|
+
}
|
|
121
|
+
const trust = await this.trustClient.verdictFor('issuer', issuerDid, configuration.vtjscId);
|
|
122
|
+
return {
|
|
123
|
+
state: session.state,
|
|
124
|
+
cryptographicVerified: true,
|
|
125
|
+
accepted: trust.verdict === 'TRUSTED_AUTHORIZED',
|
|
126
|
+
trust,
|
|
127
|
+
credential,
|
|
128
|
+
};
|
|
129
|
+
}
|
|
130
|
+
async initialize() {
|
|
131
|
+
const agentDid = this.agent.did;
|
|
132
|
+
if (!agentDid)
|
|
133
|
+
throw new Error('OpenID4VC verifier initialization requires an agent DID');
|
|
134
|
+
const signingCertificate = await (0, CertificateService_1.loadSigningCertificate)(this.agent, this.verifierOptions().signing, this.options.publicApiBaseUrl, 'verifier');
|
|
135
|
+
const certificateDid = (0, CertificateService_1.didFromValidatedCertificate)(signingCertificate.certificate);
|
|
136
|
+
if (certificateDid !== agentDid) {
|
|
137
|
+
throw new Error('OpenID4VC verifier certificate DID does not match the agent DID');
|
|
138
|
+
}
|
|
139
|
+
await (0, CertificateService_1.publishDevelopmentSigningKey)(this.agent, signingCertificate, 'verifier');
|
|
140
|
+
const binding = await (0, keyBinding_1.verifyKeyBoundToDid)(this.agent, agentDid, signingCertificate.certificate.publicJwk.toJson(), ['authentication'], (0, keyBinding_1.ownDidResolutionPolicy)(agentDid, this.trustOptions().timeoutMs));
|
|
141
|
+
if (binding === 'unresolvable') {
|
|
142
|
+
throw new Error('OpenID4VC verifier DID could not be resolved for authentication key binding');
|
|
143
|
+
}
|
|
144
|
+
if (binding !== 'bound') {
|
|
145
|
+
throw new Error('OpenID4VC verifier certificate key is not bound to the agent DID authentication');
|
|
146
|
+
}
|
|
147
|
+
await this.createOrUpdateVerifier();
|
|
148
|
+
this.signingCertificate = signingCertificate;
|
|
149
|
+
this.initialized = true;
|
|
150
|
+
}
|
|
151
|
+
async createOrUpdateVerifier() {
|
|
152
|
+
const verifier = this.verifierOptions();
|
|
153
|
+
const metadata = {
|
|
154
|
+
verifierId: verifier.id,
|
|
155
|
+
clientMetadata: { client_name: verifier.displayName },
|
|
156
|
+
};
|
|
157
|
+
try {
|
|
158
|
+
await this.verifierApi().getVerifierByVerifierId(verifier.id);
|
|
159
|
+
}
|
|
160
|
+
catch (error) {
|
|
161
|
+
if (!(error instanceof core_1.RecordNotFoundError))
|
|
162
|
+
throw error;
|
|
163
|
+
await this.verifierApi().createVerifier(metadata);
|
|
164
|
+
return;
|
|
165
|
+
}
|
|
166
|
+
await this.verifierApi().updateVerifierMetadata(metadata);
|
|
167
|
+
}
|
|
168
|
+
async getSession(sessionId) {
|
|
169
|
+
try {
|
|
170
|
+
return await this.verifierApi().getVerificationSessionById(sessionId);
|
|
171
|
+
}
|
|
172
|
+
catch (error) {
|
|
173
|
+
if (error instanceof core_1.RecordNotFoundError) {
|
|
174
|
+
throw new UnknownVerificationSessionError(`OpenID4VC verification session '${sessionId}' was not found`);
|
|
175
|
+
}
|
|
176
|
+
throw error;
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
async getVerifiedResponse(sessionId) {
|
|
180
|
+
try {
|
|
181
|
+
return await this.verifierApi().getVerifiedAuthorizationResponse(sessionId);
|
|
182
|
+
}
|
|
183
|
+
catch (error) {
|
|
184
|
+
if (error instanceof core_1.RecordNotFoundError) {
|
|
185
|
+
throw new UnknownVerificationSessionError(`OpenID4VC verification session '${sessionId}' was not found`);
|
|
186
|
+
}
|
|
187
|
+
throw error;
|
|
188
|
+
}
|
|
189
|
+
}
|
|
190
|
+
assertSessionOwnership(session, sessionId) {
|
|
191
|
+
if (session.verifierId !== this.verifierOptions().id) {
|
|
192
|
+
throw new UnknownVerificationSessionError(`OpenID4VC verification session '${sessionId}' was not found`);
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
assertStableVerifiedSession(verified, sessionId) {
|
|
196
|
+
if (verified.verificationSession.id !== sessionId ||
|
|
197
|
+
verified.verificationSession.verifierId !== this.verifierOptions().id ||
|
|
198
|
+
verified.verificationSession.state !== openid4vc_1.OpenId4VcVerificationSessionState.ResponseVerified) {
|
|
199
|
+
throw new Error('OpenID4VC verification session changed while reading its verified result');
|
|
200
|
+
}
|
|
201
|
+
}
|
|
202
|
+
matchConfiguredPolicy(verified) {
|
|
203
|
+
var _a, _b, _c, _d;
|
|
204
|
+
const credentials = (_a = verified.dcql) === null || _a === void 0 ? void 0 : _a.query.credentials;
|
|
205
|
+
if (!credentials || credentials.length !== 1)
|
|
206
|
+
return undefined;
|
|
207
|
+
const query = credentials[0];
|
|
208
|
+
if (query.format !== 'dc+sd-jwt')
|
|
209
|
+
return undefined;
|
|
210
|
+
const configuration = (0, config_1.findCredentialConfiguration)(this.options, query.id);
|
|
211
|
+
if (!configuration)
|
|
212
|
+
return undefined;
|
|
213
|
+
if (((_c = (_b = query.meta) === null || _b === void 0 ? void 0 : _b.vct_values) === null || _c === void 0 ? void 0 : _c.length) !== 1 || query.meta.vct_values[0] !== configuration.vct) {
|
|
214
|
+
return undefined;
|
|
215
|
+
}
|
|
216
|
+
const requestedClaims = (_d = query.claims) === null || _d === void 0 ? void 0 : _d.map(claim => {
|
|
217
|
+
const path = claim.path;
|
|
218
|
+
return path.length === 1 && typeof path[0] === 'string' ? path[0] : undefined;
|
|
219
|
+
});
|
|
220
|
+
if (!requestedClaims || requestedClaims.some(claim => claim === undefined))
|
|
221
|
+
return undefined;
|
|
222
|
+
const policy = this.options.verifierPolicies.find(candidate => candidate.credentialConfigurationId === configuration.id &&
|
|
223
|
+
equalStrings(candidate.requestedClaims, requestedClaims));
|
|
224
|
+
return policy ? { policy } : undefined;
|
|
225
|
+
}
|
|
226
|
+
blockedResult(state, did, vtjscId, binding) {
|
|
227
|
+
return {
|
|
228
|
+
state,
|
|
229
|
+
cryptographicVerified: true,
|
|
230
|
+
accepted: false,
|
|
231
|
+
trust: (0, keyBinding_1.blockingBindingVerdict)(did, vtjscId, binding),
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
verifierApi() {
|
|
235
|
+
var _a;
|
|
236
|
+
const verifier = (_a = this.agent.modules.openId4Vc) === null || _a === void 0 ? void 0 : _a.verifier;
|
|
237
|
+
if (!verifier)
|
|
238
|
+
throw new Error('OpenID4VC verifier API is not enabled on this agent');
|
|
239
|
+
return verifier;
|
|
240
|
+
}
|
|
241
|
+
verifierOptions() {
|
|
242
|
+
const verifier = this.options.verifier;
|
|
243
|
+
if (!verifier)
|
|
244
|
+
throw new Error('OpenID4VC verifier capability is not configured');
|
|
245
|
+
return verifier;
|
|
246
|
+
}
|
|
247
|
+
trustOptions() {
|
|
248
|
+
const trust = this.options.trust;
|
|
249
|
+
if (!trust)
|
|
250
|
+
throw new Error('OpenID4VC verifier requires trust configuration');
|
|
251
|
+
return trust;
|
|
252
|
+
}
|
|
253
|
+
signingCertificateHandle() {
|
|
254
|
+
if (!this.initialized || !this.signingCertificate) {
|
|
255
|
+
throw new Error('OpenID4VC verifier service is not initialized');
|
|
256
|
+
}
|
|
257
|
+
return this.signingCertificate;
|
|
258
|
+
}
|
|
259
|
+
}
|
|
260
|
+
exports.VerifierService = VerifierService;
|
|
261
|
+
function isX5cSdJwtDcPresentation(value) {
|
|
262
|
+
if (!isRecord(value) || value.claimFormat !== core_1.ClaimFormat.SdJwtDc || !isRecord(value.prettyClaims)) {
|
|
263
|
+
return false;
|
|
264
|
+
}
|
|
265
|
+
if (!isRecord(value.issuer) || value.issuer.method !== 'x5c' || !Array.isArray(value.issuer.x5c)) {
|
|
266
|
+
return false;
|
|
267
|
+
}
|
|
268
|
+
const leaf = value.issuer.x5c[0];
|
|
269
|
+
return (isRecord(leaf) &&
|
|
270
|
+
Array.isArray(leaf.sanUriNames) &&
|
|
271
|
+
isRecord(leaf.publicJwk) &&
|
|
272
|
+
typeof leaf.publicJwk.toJson === 'function');
|
|
273
|
+
}
|
|
274
|
+
function configuredDisclosedClaims(claims, requestedClaims) {
|
|
275
|
+
const disclosedClaims = {};
|
|
276
|
+
for (const name of requestedClaims) {
|
|
277
|
+
if (!Object.prototype.hasOwnProperty.call(claims, name))
|
|
278
|
+
return undefined;
|
|
279
|
+
disclosedClaims[name] = claims[name];
|
|
280
|
+
}
|
|
281
|
+
return disclosedClaims;
|
|
282
|
+
}
|
|
283
|
+
function equalStrings(left, right) {
|
|
284
|
+
return left.length === right.length && left.every((value, index) => value === right[index]);
|
|
285
|
+
}
|
|
286
|
+
function isRecord(value) {
|
|
287
|
+
return value !== null && typeof value === 'object' && !Array.isArray(value);
|
|
288
|
+
}
|
|
289
|
+
//# sourceMappingURL=VerifierService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"VerifierService.js","sourceRoot":"","sources":["../../src/services/VerifierService.ts"],"names":[],"mappings":";;;AASA,yCAAiE;AACjE,mDAAuE;AAEvE,sCAA2E;AAC3E,sDAAkD;AAClD,oDAAyG;AAEzG,6DAK6B;AAuC7B,MAAa,6BAA8B,SAAQ,KAAK;CAAG;AAA3D,sEAA2D;AAC3D,MAAa,+BAAgC,SAAQ,KAAK;CAAG;AAA7D,0EAA6D;AAE7D,MAAa,eAAe;IAM1B,YACmB,KAA6B,EAC7B,OAA+B;QAD/B,UAAK,GAAL,KAAK,CAAwB;QAC7B,YAAO,GAAP,OAAO,CAAwB;QAL1C,gBAAW,GAAG,KAAK,CAAA;QAOzB,MAAM,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,KAAK,CAAA;QAChC,IAAI,CAAC,KAAK;YAAE,MAAM,IAAI,KAAK,CAAC,iDAAiD,CAAC,CAAA;QAC9E,IAAI,CAAC,WAAW,GAAG,IAAI,yBAAW,CAAC,KAAK,CAAC,CAAA;IAC3C,CA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,CAAC;AAED,SAAS,YAAY,CAAC,IAAc,EAAE,KAAgC;IACpE,OAAO,IAAI,CAAC,MAAM,KAAK,KAAK,CAAC,MAAM,IAAI,IAAI,CAAC,KAAK,CAAC,CAAC,KAAK,EAAE,KAAK,EAAE,EAAE,CAAC,KAAK,KAAK,KAAK,CAAC,KAAK,CAAC,CAAC,CAAA;AAC7F,CAAC;AAED,SAAS,QAAQ,CAAC,KAAc;IAC9B,OAAO,KAAK,KAAK,IAAI,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,CAAC,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,CAAA;AAC7E,CAAC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
import type { OpenId4VcPluginOptions } from '../types';
|
|
2
|
+
import type { X509Certificate } from '@credo-ts/core';
|
|
3
|
+
export declare function trustedCertificatesForVerification(options: OpenId4VcPluginOptions, verification: {
|
|
4
|
+
type: string;
|
|
5
|
+
certificateChain: X509Certificate[];
|
|
6
|
+
}): string[] | undefined;
|
|
7
|
+
export declare function certificateFingerprint(certificate: X509Certificate): string;
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.trustedCertificatesForVerification = trustedCertificatesForVerification;
|
|
4
|
+
exports.certificateFingerprint = certificateFingerprint;
|
|
5
|
+
const node_crypto_1 = require("node:crypto");
|
|
6
|
+
function trustedCertificatesForVerification(options, verification) {
|
|
7
|
+
var _a, _b, _c, _d, _e;
|
|
8
|
+
if (verification.type === 'credential') {
|
|
9
|
+
if ((_a = options.trust) === null || _a === void 0 ? void 0 : _a.credentialIssuerCertificates.length) {
|
|
10
|
+
return options.trust.credentialIssuerCertificates;
|
|
11
|
+
}
|
|
12
|
+
const leaf = verification.certificateChain[0];
|
|
13
|
+
const fingerprint = leaf ? certificateFingerprint(leaf) : undefined;
|
|
14
|
+
return fingerprint && ((_c = (_b = options.trust) === null || _b === void 0 ? void 0 : _b.developmentCertificateFingerprints) === null || _c === void 0 ? void 0 : _c.includes(fingerprint))
|
|
15
|
+
? [leaf.toString('base64')]
|
|
16
|
+
: undefined;
|
|
17
|
+
}
|
|
18
|
+
if (verification.type === 'oauth2ClientAttestation') {
|
|
19
|
+
return ((_e = (_d = options.issuer) === null || _d === void 0 ? void 0 : _d.walletAttestationCertificates) === null || _e === void 0 ? void 0 : _e.length)
|
|
20
|
+
? options.issuer.walletAttestationCertificates
|
|
21
|
+
: undefined;
|
|
22
|
+
}
|
|
23
|
+
return undefined;
|
|
24
|
+
}
|
|
25
|
+
function certificateFingerprint(certificate) {
|
|
26
|
+
const digest = (0, node_crypto_1.createHash)('sha256').update(certificate.rawCertificate).digest('hex');
|
|
27
|
+
return `SHA256:${digest}`;
|
|
28
|
+
}
|
|
29
|
+
//# sourceMappingURL=CertificateTrust.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"CertificateTrust.js","sourceRoot":"","sources":["../../src/trust/CertificateTrust.ts"],"names":[],"mappings":";;AAKA,gFAuBC;AAED,wDAGC;AA9BD,6CAAwC;AAExC,SAAgB,kCAAkC,CAChD,OAA+B,EAC/B,YAAmE;;IAEnE,IAAI,YAAY,CAAC,IAAI,KAAK,YAAY,EAAE,CAAC;QACvC,IAAI,MAAA,OAAO,CAAC,KAAK,0CAAE,4BAA4B,CAAC,MAAM,EAAE,CAAC;YACvD,OAAO,OAAO,CAAC,KAAK,CAAC,4BAA4B,CAAA;QACnD,CAAC;QAED,MAAM,IAAI,GAAG,YAAY,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAA;QAC7C,MAAM,WAAW,GAAG,IAAI,CAAC,CAAC,CAAC,sBAAsB,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,SAAS,CAAA;QACnE,OAAO,WAAW,KAAI,MAAA,MAAA,OAAO,CAAC,KAAK,0CAAE,kCAAkC,0CAAE,QAAQ,CAAC,WAAW,CAAC,CAAA;YAC5F,CAAC,CAAC,CAAC,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,CAAC;YAC3B,CAAC,CAAC,SAAS,CAAA;IACf,CAAC;IAED,IAAI,YAAY,CAAC,IAAI,KAAK,yBAAyB,EAAE,CAAC;QACpD,OAAO,CAAA,MAAA,MAAA,OAAO,CAAC,MAAM,0CAAE,6BAA6B,0CAAE,MAAM;YAC1D,CAAC,CAAC,OAAO,CAAC,MAAM,CAAC,6BAA6B;YAC9C,CAAC,CAAC,SAAS,CAAA;IACf,CAAC;IAED,OAAO,SAAS,CAAA;AAClB,CAAC;AAED,SAAgB,sBAAsB,CAAC,WAA4B;IACjE,MAAM,MAAM,GAAG,IAAA,wBAAU,EAAC,QAAQ,CAAC,CAAC,MAAM,CAAC,WAAW,CAAC,cAAc,CAAC,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACpF,OAAO,UAAU,MAAM,EAAE,CAAA;AAC3B,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { TrustClientOptions, TrustResolution, TrustRole, TrustVerdict } from './types';
|
|
2
|
+
export declare class TrustClient {
|
|
3
|
+
private readonly options;
|
|
4
|
+
private readonly fetchImplementation;
|
|
5
|
+
private readonly resolverUrl;
|
|
6
|
+
constructor(options: TrustClientOptions, fetchImplementation?: typeof fetch);
|
|
7
|
+
resolve(did: string): Promise<TrustResolution>;
|
|
8
|
+
checkAuthorization(role: TrustRole, did: string, vtjscId: string): Promise<boolean | null>;
|
|
9
|
+
verdictFor(role: TrustRole, did: string | null, vtjscId: string | null): Promise<TrustVerdict>;
|
|
10
|
+
private endpoint;
|
|
11
|
+
private request;
|
|
12
|
+
}
|