@credo-ts/openid4vc 0.5.0-alpha.115
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 +202 -0
- package/README.md +31 -0
- package/build/index.d.ts +4 -0
- package/build/index.js +21 -0
- package/build/index.js.map +1 -0
- package/build/openid4vc-holder/OpenId4VcHolderApi.d.ts +83 -0
- package/build/openid4vc-holder/OpenId4VcHolderApi.js +115 -0
- package/build/openid4vc-holder/OpenId4VcHolderApi.js.map +1 -0
- package/build/openid4vc-holder/OpenId4VcHolderModule.d.ts +13 -0
- package/build/openid4vc-holder/OpenId4VcHolderModule.js +30 -0
- package/build/openid4vc-holder/OpenId4VcHolderModule.js.map +1 -0
- package/build/openid4vc-holder/OpenId4VciHolderService.d.ts +33 -0
- package/build/openid4vc-holder/OpenId4VciHolderService.js +510 -0
- package/build/openid4vc-holder/OpenId4VciHolderService.js.map +1 -0
- package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.d.ts +153 -0
- package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.js +11 -0
- package/build/openid4vc-holder/OpenId4VciHolderServiceOptions.js.map +1 -0
- package/build/openid4vc-holder/OpenId4vcSiopHolderService.d.ts +18 -0
- package/build/openid4vc-holder/OpenId4vcSiopHolderService.js +228 -0
- package/build/openid4vc-holder/OpenId4vcSiopHolderService.js.map +1 -0
- package/build/openid4vc-holder/OpenId4vcSiopHolderServiceOptions.d.ts +43 -0
- package/build/openid4vc-holder/OpenId4vcSiopHolderServiceOptions.js +3 -0
- package/build/openid4vc-holder/OpenId4vcSiopHolderServiceOptions.js.map +1 -0
- package/build/openid4vc-holder/index.d.ts +6 -0
- package/build/openid4vc-holder/index.js +23 -0
- package/build/openid4vc-holder/index.js.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerApi.d.ts +62 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerApi.js +111 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerApi.js.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModule.d.ts +21 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModule.js +103 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModule.js.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.d.ts +43 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.js +68 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerModuleConfig.js.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerService.d.ts +40 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerService.js +392 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerService.js.map +1 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerServiceOptions.d.ts +85 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerServiceOptions.js +3 -0
- package/build/openid4vc-issuer/OpenId4VcIssuerServiceOptions.js.map +1 -0
- package/build/openid4vc-issuer/index.d.ts +6 -0
- package/build/openid4vc-issuer/index.js +25 -0
- package/build/openid4vc-issuer/index.js.map +1 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.d.ts +37 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.js +31 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRecord.js.map +1 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRepository.d.ts +8 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRepository.js +35 -0
- package/build/openid4vc-issuer/repository/OpenId4VcIssuerRepository.js.map +1 -0
- package/build/openid4vc-issuer/repository/index.d.ts +2 -0
- package/build/openid4vc-issuer/repository/index.js +19 -0
- package/build/openid4vc-issuer/repository/index.js.map +1 -0
- package/build/openid4vc-issuer/router/accessTokenEndpoint.d.ts +34 -0
- package/build/openid4vc-issuer/router/accessTokenEndpoint.js +97 -0
- package/build/openid4vc-issuer/router/accessTokenEndpoint.js.map +1 -0
- package/build/openid4vc-issuer/router/credentialEndpoint.d.ts +16 -0
- package/build/openid4vc-issuer/router/credentialEndpoint.js +26 -0
- package/build/openid4vc-issuer/router/credentialEndpoint.js.map +1 -0
- package/build/openid4vc-issuer/router/index.d.ts +4 -0
- package/build/openid4vc-issuer/router/index.js +10 -0
- package/build/openid4vc-issuer/router/index.js.map +1 -0
- package/build/openid4vc-issuer/router/metadataEndpoint.d.ts +2 -0
- package/build/openid4vc-issuer/router/metadataEndpoint.js +30 -0
- package/build/openid4vc-issuer/router/metadataEndpoint.js.map +1 -0
- package/build/openid4vc-issuer/router/requestContext.d.ts +5 -0
- package/build/openid4vc-issuer/router/requestContext.js +3 -0
- package/build/openid4vc-issuer/router/requestContext.js.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.d.ts +27 -0
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.js +277 -0
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierService.js.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierServiceOptions.d.ts +44 -0
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierServiceOptions.js +3 -0
- package/build/openid4vc-verifier/OpenId4VcSiopVerifierServiceOptions.js.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierApi.d.ts +48 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierApi.js +89 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierApi.js.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierModule.d.ts +21 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierModule.js +98 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierModule.js.map +1 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.d.ts +34 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.js +45 -0
- package/build/openid4vc-verifier/OpenId4VcVerifierModuleConfig.js.map +1 -0
- package/build/openid4vc-verifier/index.d.ts +6 -0
- package/build/openid4vc-verifier/index.js +23 -0
- package/build/openid4vc-verifier/index.js.map +1 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRecord.d.ts +26 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRecord.js +28 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRecord.js.map +1 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRepository.d.ts +8 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRepository.js +35 -0
- package/build/openid4vc-verifier/repository/OpenId4VcVerifierRepository.js.map +1 -0
- package/build/openid4vc-verifier/repository/index.d.ts +2 -0
- package/build/openid4vc-verifier/repository/index.js +19 -0
- package/build/openid4vc-verifier/repository/index.js.map +1 -0
- package/build/openid4vc-verifier/router/authorizationEndpoint.d.ts +11 -0
- package/build/openid4vc-verifier/router/authorizationEndpoint.js +30 -0
- package/build/openid4vc-verifier/router/authorizationEndpoint.js.map +1 -0
- package/build/openid4vc-verifier/router/index.d.ts +2 -0
- package/build/openid4vc-verifier/router/index.js +6 -0
- package/build/openid4vc-verifier/router/index.js.map +1 -0
- package/build/openid4vc-verifier/router/requestContext.d.ts +5 -0
- package/build/openid4vc-verifier/router/requestContext.js +3 -0
- package/build/openid4vc-verifier/router/requestContext.js.map +1 -0
- package/build/shared/index.d.ts +2 -0
- package/build/shared/index.js +19 -0
- package/build/shared/index.js.map +1 -0
- package/build/shared/issuerMetadataUtils.d.ts +14 -0
- package/build/shared/issuerMetadataUtils.js +69 -0
- package/build/shared/issuerMetadataUtils.js.map +1 -0
- package/build/shared/models/CredentialHolderBinding.d.ts +10 -0
- package/build/shared/models/CredentialHolderBinding.js +3 -0
- package/build/shared/models/CredentialHolderBinding.js.map +1 -0
- package/build/shared/models/OpenId4VcJwtIssuer.d.ts +6 -0
- package/build/shared/models/OpenId4VcJwtIssuer.js +3 -0
- package/build/shared/models/OpenId4VcJwtIssuer.js.map +1 -0
- package/build/shared/models/OpenId4VciCredentialFormatProfile.d.ts +6 -0
- package/build/shared/models/OpenId4VciCredentialFormatProfile.js +11 -0
- package/build/shared/models/OpenId4VciCredentialFormatProfile.js.map +1 -0
- package/build/shared/models/index.d.ts +21 -0
- package/build/shared/models/index.js +20 -0
- package/build/shared/models/index.js.map +1 -0
- package/build/shared/router/context.d.ts +10 -0
- package/build/shared/router/context.js +22 -0
- package/build/shared/router/context.js.map +1 -0
- package/build/shared/router/express.d.ts +2 -0
- package/build/shared/router/express.js +16 -0
- package/build/shared/router/express.js.map +1 -0
- package/build/shared/router/index.d.ts +3 -0
- package/build/shared/router/index.js +20 -0
- package/build/shared/router/index.js.map +1 -0
- package/build/shared/router/tenants.d.ts +13 -0
- package/build/shared/router/tenants.js +50 -0
- package/build/shared/router/tenants.js.map +1 -0
- package/build/shared/transform.d.ts +5 -0
- package/build/shared/transform.js +61 -0
- package/build/shared/transform.js.map +1 -0
- package/build/shared/utils.d.ts +21 -0
- package/build/shared/utils.js +85 -0
- package/build/shared/utils.js.map +1 -0
- package/package.json +43 -0
|
@@ -0,0 +1,153 @@
|
|
|
1
|
+
import type { OpenId4VcCredentialHolderBinding, OpenId4VciCredentialOfferPayload, OpenId4VciCredentialSupportedWithId, OpenId4VciIssuerMetadata } from '../shared';
|
|
2
|
+
import type { JwaSignatureAlgorithm, KeyType } from '@credo-ts/core';
|
|
3
|
+
import type { AuthorizationServerMetadata, EndpointMetadataResult, OpenId4VCIVersion } from '@sphereon/oid4vci-common';
|
|
4
|
+
import { OpenId4VciCredentialFormatProfile } from '../shared/models/OpenId4VciCredentialFormatProfile';
|
|
5
|
+
export type OpenId4VciSupportedCredentialFormats = OpenId4VciCredentialFormatProfile.JwtVcJson | OpenId4VciCredentialFormatProfile.JwtVcJsonLd | OpenId4VciCredentialFormatProfile.SdJwtVc | OpenId4VciCredentialFormatProfile.LdpVc;
|
|
6
|
+
export declare const openId4VciSupportedCredentialFormats: OpenId4VciSupportedCredentialFormats[];
|
|
7
|
+
export interface OpenId4VciResolvedCredentialOffer {
|
|
8
|
+
metadata: EndpointMetadataResult & {
|
|
9
|
+
credentialIssuerMetadata: Partial<AuthorizationServerMetadata> & OpenId4VciIssuerMetadata;
|
|
10
|
+
};
|
|
11
|
+
credentialOfferPayload: OpenId4VciCredentialOfferPayload;
|
|
12
|
+
offeredCredentials: OpenId4VciCredentialSupportedWithId[];
|
|
13
|
+
version: OpenId4VCIVersion;
|
|
14
|
+
}
|
|
15
|
+
export interface OpenId4VciResolvedAuthorizationRequest extends OpenId4VciAuthCodeFlowOptions {
|
|
16
|
+
codeVerifier: string;
|
|
17
|
+
authorizationRequestUri: string;
|
|
18
|
+
}
|
|
19
|
+
export interface OpenId4VciResolvedAuthorizationRequestWithCode extends OpenId4VciResolvedAuthorizationRequest {
|
|
20
|
+
code: string;
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Options that are used to accept a credential offer for both the pre-authorized code flow and authorization code flow.
|
|
24
|
+
*/
|
|
25
|
+
export interface OpenId4VciAcceptCredentialOfferOptions {
|
|
26
|
+
/**
|
|
27
|
+
* String value containing a user PIN. This value MUST be present if user_pin_required was set to true in the Credential Offer.
|
|
28
|
+
* This parameter MUST only be used, if the grant_type is urn:ietf:params:oauth:grant-type:pre-authorized_code.
|
|
29
|
+
*/
|
|
30
|
+
userPin?: string;
|
|
31
|
+
/**
|
|
32
|
+
* This is the list of credentials that will be requested from the issuer.
|
|
33
|
+
* Should be a list of ids of the credentials that are included in the credential offer.
|
|
34
|
+
* If not provided all offered credentials will be requested.
|
|
35
|
+
*/
|
|
36
|
+
credentialsToRequest?: string[];
|
|
37
|
+
verifyCredentialStatus?: boolean;
|
|
38
|
+
/**
|
|
39
|
+
* A list of allowed proof of possession signature algorithms in order of preference.
|
|
40
|
+
*
|
|
41
|
+
* Note that the signature algorithms must be supported by the wallet implementation.
|
|
42
|
+
* Signature algorithms that are not supported by the wallet will be ignored.
|
|
43
|
+
*
|
|
44
|
+
* The proof of possession (pop) signature algorithm is used in the credential request
|
|
45
|
+
* to bind the credential to a did. In most cases the JWA signature algorithm
|
|
46
|
+
* that is used in the pop will determine the cryptographic suite that is used
|
|
47
|
+
* for signing the credential, but this not a requirement for the spec. E.g. if the
|
|
48
|
+
* pop uses EdDsa, the credential will most commonly also use EdDsa, or Ed25519Signature2018/2020.
|
|
49
|
+
*/
|
|
50
|
+
allowedProofOfPossessionSignatureAlgorithms?: JwaSignatureAlgorithm[];
|
|
51
|
+
/**
|
|
52
|
+
* A function that should resolve key material for binding the to-be-issued credential
|
|
53
|
+
* to the holder based on the options passed. This key material will be used for signing
|
|
54
|
+
* the proof of possession included in the credential request.
|
|
55
|
+
*
|
|
56
|
+
* This method will be called once for each of the credentials that are included
|
|
57
|
+
* in the credential offer.
|
|
58
|
+
*
|
|
59
|
+
* Based on the credential format, JWA signature algorithm, verification method types
|
|
60
|
+
* and binding methods (did methods, jwk), the resolver must return an object
|
|
61
|
+
* conformant to the `CredentialHolderBinding` interface, which will be used
|
|
62
|
+
* for the proof of possession signature.
|
|
63
|
+
*/
|
|
64
|
+
credentialBindingResolver: OpenId4VciCredentialBindingResolver;
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Options that are used for the authorization code flow.
|
|
68
|
+
* Extends the pre-authorized code flow options.
|
|
69
|
+
*/
|
|
70
|
+
export interface OpenId4VciAuthCodeFlowOptions {
|
|
71
|
+
clientId: string;
|
|
72
|
+
redirectUri: string;
|
|
73
|
+
scope?: string[];
|
|
74
|
+
}
|
|
75
|
+
export interface OpenId4VciCredentialBindingOptions {
|
|
76
|
+
/**
|
|
77
|
+
* The credential format that will be requested from the issuer.
|
|
78
|
+
* E.g. `jwt_vc` or `ldp_vc`.
|
|
79
|
+
*/
|
|
80
|
+
credentialFormat: OpenId4VciSupportedCredentialFormats;
|
|
81
|
+
/**
|
|
82
|
+
* The JWA Signature Algorithm that will be used in the proof of possession.
|
|
83
|
+
* This is based on the `allowedProofOfPossessionSignatureAlgorithms` passed
|
|
84
|
+
* to the request credential method, and the supported signature algorithms.
|
|
85
|
+
*/
|
|
86
|
+
signatureAlgorithm: JwaSignatureAlgorithm;
|
|
87
|
+
/**
|
|
88
|
+
* This is a list of verification methods types that are supported
|
|
89
|
+
* for creating the proof of possession signature. The returned
|
|
90
|
+
* verification method type must be of one of these types.
|
|
91
|
+
*/
|
|
92
|
+
supportedVerificationMethods: string[];
|
|
93
|
+
/**
|
|
94
|
+
* The key type that will be used to create the proof of possession signature.
|
|
95
|
+
* This is related to the verification method and the signature algorithm, and
|
|
96
|
+
* is added for convenience.
|
|
97
|
+
*/
|
|
98
|
+
keyType: KeyType;
|
|
99
|
+
/**
|
|
100
|
+
* The credential type that will be requested from the issuer. This is
|
|
101
|
+
* based on the credential types that are included the credential offer.
|
|
102
|
+
*
|
|
103
|
+
* If the offered credential is an inline credential offer, the value
|
|
104
|
+
* will be `undefined`.
|
|
105
|
+
*/
|
|
106
|
+
supportedCredentialId?: string;
|
|
107
|
+
/**
|
|
108
|
+
* Whether the issuer supports the `did` cryptographic binding method,
|
|
109
|
+
* indicating they support all did methods. In most cases, they do not
|
|
110
|
+
* support all did methods, and it means we have to make an assumption
|
|
111
|
+
* about the did methods they support.
|
|
112
|
+
*
|
|
113
|
+
* If this value is `false`, the `supportedDidMethods` property will
|
|
114
|
+
* contain a list of supported did methods.
|
|
115
|
+
*/
|
|
116
|
+
supportsAllDidMethods: boolean;
|
|
117
|
+
/**
|
|
118
|
+
* A list of supported did methods. This is only used if the `supportsAllDidMethods`
|
|
119
|
+
* property is `false`. When this array is populated, the returned verification method
|
|
120
|
+
* MUST be based on one of these did methods.
|
|
121
|
+
*
|
|
122
|
+
* The did methods are returned in the format `did:<method>`, e.g. `did:web`.
|
|
123
|
+
*
|
|
124
|
+
* The value is undefined in the case the supported did methods could not be extracted.
|
|
125
|
+
* This is the case when an inline credential was used, or when the issuer didn't include
|
|
126
|
+
* the supported did methods in the issuer metadata.
|
|
127
|
+
*
|
|
128
|
+
* NOTE: an empty array (no did methods supported) has a different meaning from the value
|
|
129
|
+
* being undefined (the supported did methods could not be extracted). If `supportsAllDidMethods`
|
|
130
|
+
* is true, the value of this property MUST be ignored.
|
|
131
|
+
*/
|
|
132
|
+
supportedDidMethods?: string[];
|
|
133
|
+
/**
|
|
134
|
+
* Whether the issuer supports the `jwk` cryptographic binding method,
|
|
135
|
+
* indicating they support proof of possession signatures bound to a jwk.
|
|
136
|
+
*/
|
|
137
|
+
supportsJwk: boolean;
|
|
138
|
+
}
|
|
139
|
+
/**
|
|
140
|
+
* The proof of possession verification method resolver is a function that can be passed by the
|
|
141
|
+
* user of the framework and allows them to determine which verification method should be used
|
|
142
|
+
* for the proof of possession signature.
|
|
143
|
+
*/
|
|
144
|
+
export type OpenId4VciCredentialBindingResolver = (options: OpenId4VciCredentialBindingOptions) => Promise<OpenId4VcCredentialHolderBinding> | OpenId4VcCredentialHolderBinding;
|
|
145
|
+
/**
|
|
146
|
+
* @internal
|
|
147
|
+
*/
|
|
148
|
+
export interface OpenId4VciProofOfPossessionRequirements {
|
|
149
|
+
signatureAlgorithm: JwaSignatureAlgorithm;
|
|
150
|
+
supportedDidMethods?: string[];
|
|
151
|
+
supportsAllDidMethods: boolean;
|
|
152
|
+
supportsJwk: boolean;
|
|
153
|
+
}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.openId4VciSupportedCredentialFormats = void 0;
|
|
4
|
+
const OpenId4VciCredentialFormatProfile_1 = require("../shared/models/OpenId4VciCredentialFormatProfile");
|
|
5
|
+
exports.openId4VciSupportedCredentialFormats = [
|
|
6
|
+
OpenId4VciCredentialFormatProfile_1.OpenId4VciCredentialFormatProfile.JwtVcJson,
|
|
7
|
+
OpenId4VciCredentialFormatProfile_1.OpenId4VciCredentialFormatProfile.JwtVcJsonLd,
|
|
8
|
+
OpenId4VciCredentialFormatProfile_1.OpenId4VciCredentialFormatProfile.SdJwtVc,
|
|
9
|
+
OpenId4VciCredentialFormatProfile_1.OpenId4VciCredentialFormatProfile.LdpVc,
|
|
10
|
+
];
|
|
11
|
+
//# sourceMappingURL=OpenId4VciHolderServiceOptions.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenId4VciHolderServiceOptions.js","sourceRoot":"","sources":["../../src/openid4vc-holder/OpenId4VciHolderServiceOptions.ts"],"names":[],"mappings":";;;AASA,0GAAsG;AAQzF,QAAA,oCAAoC,GAA2C;IAC1F,qEAAiC,CAAC,SAAS;IAC3C,qEAAiC,CAAC,WAAW;IAC7C,qEAAiC,CAAC,OAAO;IACzC,qEAAiC,CAAC,KAAK;CACxC,CAAA"}
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
import type { OpenId4VcSiopAcceptAuthorizationRequestOptions, OpenId4VcSiopResolvedAuthorizationRequest } from './OpenId4vcSiopHolderServiceOptions';
|
|
2
|
+
import type { AgentContext } from '@credo-ts/core';
|
|
3
|
+
import { DifPresentationExchangeService } from '@credo-ts/core';
|
|
4
|
+
export declare class OpenId4VcSiopHolderService {
|
|
5
|
+
private presentationExchangeService;
|
|
6
|
+
constructor(presentationExchangeService: DifPresentationExchangeService);
|
|
7
|
+
resolveAuthorizationRequest(agentContext: AgentContext, requestJwtOrUri: string): Promise<OpenId4VcSiopResolvedAuthorizationRequest>;
|
|
8
|
+
acceptAuthorizationRequest(agentContext: AgentContext, options: OpenId4VcSiopAcceptAuthorizationRequestOptions): Promise<{
|
|
9
|
+
serverResponse: {
|
|
10
|
+
status: number;
|
|
11
|
+
body: string | Record<string, unknown> | undefined;
|
|
12
|
+
};
|
|
13
|
+
submittedResponse: import("@sphereon/did-auth-siop").AuthorizationResponsePayload;
|
|
14
|
+
}>;
|
|
15
|
+
private getOpenIdProvider;
|
|
16
|
+
private getOpenIdTokenIssuerFromVerifiablePresentation;
|
|
17
|
+
private assertValidTokenIssuer;
|
|
18
|
+
}
|
|
@@ -0,0 +1,228 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
|
|
3
|
+
var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
|
|
4
|
+
if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
|
|
5
|
+
else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
|
|
6
|
+
return c > 3 && r && Object.defineProperty(target, key, r), r;
|
|
7
|
+
};
|
|
8
|
+
var __metadata = (this && this.__metadata) || function (k, v) {
|
|
9
|
+
if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.OpenId4VcSiopHolderService = void 0;
|
|
13
|
+
const core_1 = require("@credo-ts/core");
|
|
14
|
+
const did_auth_siop_1 = require("@sphereon/did-auth-siop");
|
|
15
|
+
const transform_1 = require("../shared/transform");
|
|
16
|
+
const utils_1 = require("../shared/utils");
|
|
17
|
+
let OpenId4VcSiopHolderService = class OpenId4VcSiopHolderService {
|
|
18
|
+
constructor(presentationExchangeService) {
|
|
19
|
+
this.presentationExchangeService = presentationExchangeService;
|
|
20
|
+
}
|
|
21
|
+
async resolveAuthorizationRequest(agentContext, requestJwtOrUri) {
|
|
22
|
+
var _a, _b;
|
|
23
|
+
const openidProvider = await this.getOpenIdProvider(agentContext, {});
|
|
24
|
+
// parsing happens automatically in verifyAuthorizationRequest
|
|
25
|
+
const verifiedAuthorizationRequest = await openidProvider.verifyAuthorizationRequest(requestJwtOrUri, {
|
|
26
|
+
verification: {
|
|
27
|
+
// FIXME: we want custom verification, but not supported currently
|
|
28
|
+
// https://github.com/Sphereon-Opensource/SIOP-OID4VP/issues/55
|
|
29
|
+
mode: did_auth_siop_1.VerificationMode.INTERNAL,
|
|
30
|
+
resolveOpts: { resolver: (0, utils_1.getSphereonDidResolver)(agentContext), noUniversalResolverFallback: true },
|
|
31
|
+
},
|
|
32
|
+
});
|
|
33
|
+
agentContext.config.logger.debug(`verified SIOP Authorization Request for issuer '${verifiedAuthorizationRequest.issuer}'`);
|
|
34
|
+
agentContext.config.logger.debug(`requestJwtOrUri '${requestJwtOrUri}'`);
|
|
35
|
+
if (verifiedAuthorizationRequest.presentationDefinitions &&
|
|
36
|
+
verifiedAuthorizationRequest.presentationDefinitions.length > 1) {
|
|
37
|
+
throw new core_1.CredoError('Only a single presentation definition is supported.');
|
|
38
|
+
}
|
|
39
|
+
const presentationDefinition = (_b = (_a = verifiedAuthorizationRequest.presentationDefinitions) === null || _a === void 0 ? void 0 : _a[0]) === null || _b === void 0 ? void 0 : _b.definition;
|
|
40
|
+
return {
|
|
41
|
+
authorizationRequest: verifiedAuthorizationRequest,
|
|
42
|
+
// Parameters related to DIF Presentation Exchange
|
|
43
|
+
presentationExchange: presentationDefinition
|
|
44
|
+
? {
|
|
45
|
+
definition: presentationDefinition,
|
|
46
|
+
credentialsForRequest: await this.presentationExchangeService.getCredentialsForRequest(agentContext, presentationDefinition),
|
|
47
|
+
}
|
|
48
|
+
: undefined,
|
|
49
|
+
};
|
|
50
|
+
}
|
|
51
|
+
async acceptAuthorizationRequest(agentContext, options) {
|
|
52
|
+
const { authorizationRequest, presentationExchange } = options;
|
|
53
|
+
let openIdTokenIssuer = options.openIdTokenIssuer;
|
|
54
|
+
let presentationExchangeOptions = undefined;
|
|
55
|
+
// Handle presentation exchange part
|
|
56
|
+
if (authorizationRequest.presentationDefinitions && authorizationRequest.presentationDefinitions.length > 0) {
|
|
57
|
+
if (!presentationExchange) {
|
|
58
|
+
throw new core_1.CredoError('Authorization request included presentation definition. `presentationExchange` MUST be supplied to accept authorization requests.');
|
|
59
|
+
}
|
|
60
|
+
const nonce = await authorizationRequest.authorizationRequest.getMergedProperty('nonce');
|
|
61
|
+
if (!nonce) {
|
|
62
|
+
throw new core_1.CredoError("Unable to extract 'nonce' from authorization request");
|
|
63
|
+
}
|
|
64
|
+
const clientId = await authorizationRequest.authorizationRequest.getMergedProperty('client_id');
|
|
65
|
+
if (!clientId) {
|
|
66
|
+
throw new core_1.CredoError("Unable to extract 'client_id' from authorization request");
|
|
67
|
+
}
|
|
68
|
+
const { verifiablePresentations, presentationSubmission } = await this.presentationExchangeService.createPresentation(agentContext, {
|
|
69
|
+
credentialsForInputDescriptor: presentationExchange.credentials,
|
|
70
|
+
presentationDefinition: authorizationRequest.presentationDefinitions[0].definition,
|
|
71
|
+
challenge: nonce,
|
|
72
|
+
domain: clientId,
|
|
73
|
+
presentationSubmissionLocation: core_1.DifPresentationExchangeSubmissionLocation.EXTERNAL,
|
|
74
|
+
});
|
|
75
|
+
presentationExchangeOptions = {
|
|
76
|
+
verifiablePresentations: verifiablePresentations.map((vp) => (0, transform_1.getSphereonVerifiablePresentation)(vp)),
|
|
77
|
+
presentationSubmission,
|
|
78
|
+
vpTokenLocation: did_auth_siop_1.VPTokenLocation.AUTHORIZATION_RESPONSE,
|
|
79
|
+
};
|
|
80
|
+
if (!openIdTokenIssuer) {
|
|
81
|
+
openIdTokenIssuer = this.getOpenIdTokenIssuerFromVerifiablePresentation(verifiablePresentations[0]);
|
|
82
|
+
}
|
|
83
|
+
}
|
|
84
|
+
else if (options.presentationExchange) {
|
|
85
|
+
throw new core_1.CredoError('`presentationExchange` was supplied, but no presentation definition was found in the presentation request.');
|
|
86
|
+
}
|
|
87
|
+
if (!openIdTokenIssuer) {
|
|
88
|
+
throw new core_1.CredoError('Unable to create authorization response. openIdTokenIssuer MUST be supplied when no presentation is active.');
|
|
89
|
+
}
|
|
90
|
+
this.assertValidTokenIssuer(authorizationRequest, openIdTokenIssuer);
|
|
91
|
+
const openidProvider = await this.getOpenIdProvider(agentContext, {
|
|
92
|
+
openIdTokenIssuer,
|
|
93
|
+
});
|
|
94
|
+
const suppliedSignature = await (0, utils_1.getSphereonSuppliedSignatureFromJwtIssuer)(agentContext, openIdTokenIssuer);
|
|
95
|
+
const authorizationResponseWithCorrelationId = await openidProvider.createAuthorizationResponse(authorizationRequest, {
|
|
96
|
+
signature: suppliedSignature,
|
|
97
|
+
issuer: suppliedSignature.did,
|
|
98
|
+
verification: {
|
|
99
|
+
resolveOpts: { resolver: (0, utils_1.getSphereonDidResolver)(agentContext), noUniversalResolverFallback: true },
|
|
100
|
+
mode: did_auth_siop_1.VerificationMode.INTERNAL,
|
|
101
|
+
},
|
|
102
|
+
presentationExchange: presentationExchangeOptions,
|
|
103
|
+
// https://openid.net/specs/openid-connect-self-issued-v2-1_0.html#name-aud-of-a-request-object
|
|
104
|
+
audience: authorizationRequest.authorizationRequestPayload.client_id,
|
|
105
|
+
});
|
|
106
|
+
const response = await openidProvider.submitAuthorizationResponse(authorizationResponseWithCorrelationId);
|
|
107
|
+
let responseDetails = undefined;
|
|
108
|
+
try {
|
|
109
|
+
responseDetails = await response.text();
|
|
110
|
+
if (responseDetails.includes('{')) {
|
|
111
|
+
responseDetails = JSON.parse(responseDetails);
|
|
112
|
+
}
|
|
113
|
+
}
|
|
114
|
+
catch (error) {
|
|
115
|
+
// no-op
|
|
116
|
+
}
|
|
117
|
+
return {
|
|
118
|
+
serverResponse: {
|
|
119
|
+
status: response.status,
|
|
120
|
+
body: responseDetails,
|
|
121
|
+
},
|
|
122
|
+
submittedResponse: authorizationResponseWithCorrelationId.response.payload,
|
|
123
|
+
};
|
|
124
|
+
}
|
|
125
|
+
async getOpenIdProvider(agentContext, options = {}) {
|
|
126
|
+
const { openIdTokenIssuer } = options;
|
|
127
|
+
const builder = did_auth_siop_1.OP.builder()
|
|
128
|
+
.withExpiresIn(6000)
|
|
129
|
+
.withIssuer(did_auth_siop_1.ResponseIss.SELF_ISSUED_V2)
|
|
130
|
+
.withResponseMode(did_auth_siop_1.ResponseMode.POST)
|
|
131
|
+
.withSupportedVersions([did_auth_siop_1.SupportedVersion.SIOPv2_D11, did_auth_siop_1.SupportedVersion.SIOPv2_D12_OID4VP_D18])
|
|
132
|
+
.withCustomResolver((0, utils_1.getSphereonDidResolver)(agentContext))
|
|
133
|
+
.withCheckLinkedDomain(did_auth_siop_1.CheckLinkedDomain.NEVER)
|
|
134
|
+
.withHasher(core_1.Hasher.hash);
|
|
135
|
+
if (openIdTokenIssuer) {
|
|
136
|
+
const suppliedSignature = await (0, utils_1.getSphereonSuppliedSignatureFromJwtIssuer)(agentContext, openIdTokenIssuer);
|
|
137
|
+
builder.withSignature(suppliedSignature);
|
|
138
|
+
}
|
|
139
|
+
// Add did methods
|
|
140
|
+
const supportedDidMethods = agentContext.dependencyManager.resolve(core_1.DidsApi).supportedResolverMethods;
|
|
141
|
+
for (const supportedDidMethod of supportedDidMethods) {
|
|
142
|
+
builder.addDidMethod(supportedDidMethod);
|
|
143
|
+
}
|
|
144
|
+
const openidProvider = builder.build();
|
|
145
|
+
return openidProvider;
|
|
146
|
+
}
|
|
147
|
+
getOpenIdTokenIssuerFromVerifiablePresentation(verifiablePresentation) {
|
|
148
|
+
let openIdTokenIssuer;
|
|
149
|
+
if (verifiablePresentation instanceof core_1.W3cJsonLdVerifiablePresentation) {
|
|
150
|
+
const [firstProof] = (0, core_1.asArray)(verifiablePresentation.proof);
|
|
151
|
+
if (!firstProof)
|
|
152
|
+
throw new core_1.CredoError('Verifiable presentation does not contain a proof');
|
|
153
|
+
if (!firstProof.verificationMethod.startsWith('did:')) {
|
|
154
|
+
throw new core_1.CredoError('Verifiable presentation proof verificationMethod is not a did. Unable to extract openIdTokenIssuer from verifiable presentation');
|
|
155
|
+
}
|
|
156
|
+
openIdTokenIssuer = {
|
|
157
|
+
method: 'did',
|
|
158
|
+
didUrl: firstProof.verificationMethod,
|
|
159
|
+
};
|
|
160
|
+
}
|
|
161
|
+
else if (verifiablePresentation instanceof core_1.W3cJwtVerifiablePresentation) {
|
|
162
|
+
const kid = verifiablePresentation.jwt.header.kid;
|
|
163
|
+
if (!kid)
|
|
164
|
+
throw new core_1.CredoError('Verifiable Presentation does not contain a kid in the jwt header');
|
|
165
|
+
if (kid.startsWith('#') && verifiablePresentation.presentation.holderId) {
|
|
166
|
+
openIdTokenIssuer = {
|
|
167
|
+
didUrl: `${verifiablePresentation.presentation.holderId}${kid}`,
|
|
168
|
+
method: 'did',
|
|
169
|
+
};
|
|
170
|
+
}
|
|
171
|
+
else if (kid.startsWith('did:')) {
|
|
172
|
+
openIdTokenIssuer = {
|
|
173
|
+
didUrl: kid,
|
|
174
|
+
method: 'did',
|
|
175
|
+
};
|
|
176
|
+
}
|
|
177
|
+
else {
|
|
178
|
+
throw new core_1.CredoError("JWT W3C Verifiable presentation does not include did in JWT header 'kid'. Unable to extract openIdTokenIssuer from verifiable presentation");
|
|
179
|
+
}
|
|
180
|
+
}
|
|
181
|
+
else {
|
|
182
|
+
const cnf = verifiablePresentation.payload.cnf;
|
|
183
|
+
// FIXME: SD-JWT VC should have better payload typing, so this doesn't become so ugly
|
|
184
|
+
if (!cnf ||
|
|
185
|
+
typeof cnf !== 'object' ||
|
|
186
|
+
!('kid' in cnf) ||
|
|
187
|
+
typeof cnf.kid !== 'string' ||
|
|
188
|
+
!cnf.kid.startsWith('did:') ||
|
|
189
|
+
!cnf.kid.includes('#')) {
|
|
190
|
+
throw new core_1.CredoError("SD-JWT Verifiable presentation has no 'cnf' claim or does not include 'cnf' claim where 'kid' is a didUrl pointing to a key. Unable to extract openIdTokenIssuer from verifiable presentation");
|
|
191
|
+
}
|
|
192
|
+
openIdTokenIssuer = {
|
|
193
|
+
didUrl: cnf.kid,
|
|
194
|
+
method: 'did',
|
|
195
|
+
};
|
|
196
|
+
}
|
|
197
|
+
return openIdTokenIssuer;
|
|
198
|
+
}
|
|
199
|
+
assertValidTokenIssuer(authorizationRequest, openIdTokenIssuer) {
|
|
200
|
+
// TODO: jwk thumbprint support
|
|
201
|
+
const subjectSyntaxTypesSupported = authorizationRequest.registrationMetadataPayload.subject_syntax_types_supported;
|
|
202
|
+
if (!subjectSyntaxTypesSupported) {
|
|
203
|
+
throw new core_1.CredoError('subject_syntax_types_supported is not supplied in the registration metadata. subject_syntax_types is REQUIRED.');
|
|
204
|
+
}
|
|
205
|
+
let allowedSubjectSyntaxTypes = [];
|
|
206
|
+
if (openIdTokenIssuer.method === 'did') {
|
|
207
|
+
const parsedDid = (0, core_1.parseDid)(openIdTokenIssuer.didUrl);
|
|
208
|
+
// Either did:<method> or did (for all did methods) is allowed
|
|
209
|
+
allowedSubjectSyntaxTypes = [`did:${parsedDid.method}`, 'did'];
|
|
210
|
+
}
|
|
211
|
+
else {
|
|
212
|
+
throw new core_1.CredoError("Only 'did' is supported as openIdTokenIssuer at the moment");
|
|
213
|
+
}
|
|
214
|
+
// At least one of the allowed subject syntax types must be supported by the RP
|
|
215
|
+
if (!allowedSubjectSyntaxTypes.some((allowed) => subjectSyntaxTypesSupported.includes(allowed))) {
|
|
216
|
+
throw new core_1.CredoError([
|
|
217
|
+
'The provided openIdTokenIssuer is not supported by the relying party.',
|
|
218
|
+
`Supported subject syntax types: '${subjectSyntaxTypesSupported.join(', ')}'`,
|
|
219
|
+
].join('\n'));
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
};
|
|
223
|
+
OpenId4VcSiopHolderService = __decorate([
|
|
224
|
+
(0, core_1.injectable)(),
|
|
225
|
+
__metadata("design:paramtypes", [core_1.DifPresentationExchangeService])
|
|
226
|
+
], OpenId4VcSiopHolderService);
|
|
227
|
+
exports.OpenId4VcSiopHolderService = OpenId4VcSiopHolderService;
|
|
228
|
+
//# sourceMappingURL=OpenId4vcSiopHolderService.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenId4vcSiopHolderService.js","sourceRoot":"","sources":["../../src/openid4vc-holder/OpenId4vcSiopHolderService.ts"],"names":[],"mappings":";;;;;;;;;;;;AAQA,yCAWuB;AACvB,2DAQgC;AAEhC,mDAAuE;AACvE,2CAAmG;AAG5F,IAAM,0BAA0B,GAAhC,MAAM,0BAA0B;IACrC,YAA2B,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,2BAA2B,CAAC,QAAQ,CAAC,OAAO,CAAC,CAAC,EAAE;YAC/F,MAAM,IAAI,iBAAU,CAClB;gBACE,uEAAuE;gBACvE,oCAAoC,2BAA2B,CAAC,IAAI,CAAC,IAAI,CAAC,GAAG;aAC9E,CAAC,IAAI,CAAC,IAAI,CAAC,CACb,CAAA;SACF;IACH,CAAC;CACF,CAAA;AAlRY,0BAA0B;IADtC,IAAA,iBAAU,GAAE;qCAE6C,qCAA8B;GAD3E,0BAA0B,CAkRtC;AAlRY,gEAA0B"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
import type { OpenId4VcJwtIssuer, OpenId4VcSiopVerifiedAuthorizationRequest, OpenId4VcSiopAuthorizationResponsePayload } from '../shared';
|
|
2
|
+
import type { DifPexCredentialsForRequest, DifPexInputDescriptorToCredentials, DifPresentationExchangeDefinition } from '@credo-ts/core';
|
|
3
|
+
export interface OpenId4VcSiopResolvedAuthorizationRequest {
|
|
4
|
+
/**
|
|
5
|
+
* Parameters related to DIF Presentation Exchange. Only defined when
|
|
6
|
+
* the request included
|
|
7
|
+
*/
|
|
8
|
+
presentationExchange?: {
|
|
9
|
+
definition: DifPresentationExchangeDefinition;
|
|
10
|
+
credentialsForRequest: DifPexCredentialsForRequest;
|
|
11
|
+
};
|
|
12
|
+
/**
|
|
13
|
+
* The verified authorization request.
|
|
14
|
+
*/
|
|
15
|
+
authorizationRequest: OpenId4VcSiopVerifiedAuthorizationRequest;
|
|
16
|
+
}
|
|
17
|
+
export interface OpenId4VcSiopAcceptAuthorizationRequestOptions {
|
|
18
|
+
/**
|
|
19
|
+
* Parameters related to DIF Presentation Exchange. MUST be present when the resolved
|
|
20
|
+
* authorization request included a `presentationExchange` parameter.
|
|
21
|
+
*/
|
|
22
|
+
presentationExchange?: {
|
|
23
|
+
credentials: DifPexInputDescriptorToCredentials;
|
|
24
|
+
};
|
|
25
|
+
/**
|
|
26
|
+
* The issuer of the ID Token.
|
|
27
|
+
*
|
|
28
|
+
* REQUIRED when presentation exchange is not used.
|
|
29
|
+
*
|
|
30
|
+
* In case presentation exchange is used, and `openIdTokenIssuer` is not provided, the issuer of the ID Token
|
|
31
|
+
* will be extracted from the signer of the first verifiable presentation.
|
|
32
|
+
*/
|
|
33
|
+
openIdTokenIssuer?: OpenId4VcJwtIssuer;
|
|
34
|
+
/**
|
|
35
|
+
* The verified authorization request.
|
|
36
|
+
*/
|
|
37
|
+
authorizationRequest: OpenId4VcSiopVerifiedAuthorizationRequest;
|
|
38
|
+
}
|
|
39
|
+
export interface OpenId4VcSiopAuthorizationResponseSubmission {
|
|
40
|
+
ok: boolean;
|
|
41
|
+
status: number;
|
|
42
|
+
submittedResponse: OpenId4VcSiopAuthorizationResponsePayload;
|
|
43
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"OpenId4vcSiopHolderServiceOptions.js","sourceRoot":"","sources":["../../src/openid4vc-holder/OpenId4vcSiopHolderServiceOptions.ts"],"names":[],"mappings":""}
|
|
@@ -0,0 +1,6 @@
|
|
|
1
|
+
export * from './OpenId4VcHolderApi';
|
|
2
|
+
export * from './OpenId4VcHolderModule';
|
|
3
|
+
export * from './OpenId4VciHolderService';
|
|
4
|
+
export * from './OpenId4VciHolderServiceOptions';
|
|
5
|
+
export * from './OpenId4vcSiopHolderService';
|
|
6
|
+
export * from './OpenId4vcSiopHolderServiceOptions';
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
|
|
3
|
+
if (k2 === undefined) k2 = k;
|
|
4
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
5
|
+
if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
6
|
+
desc = { enumerable: true, get: function() { return m[k]; } };
|
|
7
|
+
}
|
|
8
|
+
Object.defineProperty(o, k2, desc);
|
|
9
|
+
}) : (function(o, m, k, k2) {
|
|
10
|
+
if (k2 === undefined) k2 = k;
|
|
11
|
+
o[k2] = m[k];
|
|
12
|
+
}));
|
|
13
|
+
var __exportStar = (this && this.__exportStar) || function(m, exports) {
|
|
14
|
+
for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
|
|
15
|
+
};
|
|
16
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
17
|
+
__exportStar(require("./OpenId4VcHolderApi"), exports);
|
|
18
|
+
__exportStar(require("./OpenId4VcHolderModule"), exports);
|
|
19
|
+
__exportStar(require("./OpenId4VciHolderService"), exports);
|
|
20
|
+
__exportStar(require("./OpenId4VciHolderServiceOptions"), exports);
|
|
21
|
+
__exportStar(require("./OpenId4vcSiopHolderService"), exports);
|
|
22
|
+
__exportStar(require("./OpenId4vcSiopHolderServiceOptions"), exports);
|
|
23
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/openid4vc-holder/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,uDAAoC;AACpC,0DAAuC;AACvC,4DAAyC;AACzC,mEAAgD;AAChD,+DAA4C;AAC5C,sEAAmD"}
|
|
@@ -0,0 +1,62 @@
|
|
|
1
|
+
import type { OpenId4VciCreateCredentialResponseOptions, OpenId4VciCreateCredentialOfferOptions, OpenId4VciCreateIssuerOptions } from './OpenId4VcIssuerServiceOptions';
|
|
2
|
+
import type { OpenId4VcIssuerRecordProps } from './repository';
|
|
3
|
+
import type { OpenId4VciCredentialOfferPayload } from '../shared';
|
|
4
|
+
import { AgentContext } from '@credo-ts/core';
|
|
5
|
+
import { OpenId4VcIssuerModuleConfig } from './OpenId4VcIssuerModuleConfig';
|
|
6
|
+
import { OpenId4VcIssuerService } from './OpenId4VcIssuerService';
|
|
7
|
+
/**
|
|
8
|
+
* @public
|
|
9
|
+
* This class represents the API for interacting with the OpenID4VC Issuer service.
|
|
10
|
+
* It provides methods for creating a credential offer, creating a response to a credential issuance request,
|
|
11
|
+
* and retrieving a credential offer from a URI.
|
|
12
|
+
*/
|
|
13
|
+
export declare class OpenId4VcIssuerApi {
|
|
14
|
+
readonly config: OpenId4VcIssuerModuleConfig;
|
|
15
|
+
private agentContext;
|
|
16
|
+
private openId4VcIssuerService;
|
|
17
|
+
constructor(config: OpenId4VcIssuerModuleConfig, agentContext: AgentContext, openId4VcIssuerService: OpenId4VcIssuerService);
|
|
18
|
+
getAllIssuers(): Promise<import("./repository").OpenId4VcIssuerRecord[]>;
|
|
19
|
+
getByIssuerId(issuerId: string): Promise<import("./repository").OpenId4VcIssuerRecord>;
|
|
20
|
+
/**
|
|
21
|
+
* Creates an issuer and stores the corresponding issuer metadata. Multiple issuers can be created, to allow different sets of
|
|
22
|
+
* credentials to be issued with each issuer.
|
|
23
|
+
*/
|
|
24
|
+
createIssuer(options: OpenId4VciCreateIssuerOptions): Promise<import("./repository").OpenId4VcIssuerRecord>;
|
|
25
|
+
/**
|
|
26
|
+
* Rotate the key used for signing access tokens for the issuer with the given issuerId.
|
|
27
|
+
*/
|
|
28
|
+
rotateAccessTokenSigningKey(issuerId: string): Promise<void>;
|
|
29
|
+
getIssuerMetadata(issuerId: string): Promise<import("./OpenId4VcIssuerServiceOptions").OpenId4VcIssuerMetadata>;
|
|
30
|
+
updateIssuerMetadata(options: Pick<OpenId4VcIssuerRecordProps, 'issuerId' | 'credentialsSupported' | 'display'>): Promise<void>;
|
|
31
|
+
/**
|
|
32
|
+
* Creates a credential offer. Either the preAuthorizedCodeFlowConfig or the authorizationCodeFlowConfig must be provided.
|
|
33
|
+
*
|
|
34
|
+
* @returns Object containing the payload of the credential offer and the credential offer request, which can be sent to the wallet.
|
|
35
|
+
*/
|
|
36
|
+
createCredentialOffer(options: OpenId4VciCreateCredentialOfferOptions & {
|
|
37
|
+
issuerId: string;
|
|
38
|
+
}): Promise<{
|
|
39
|
+
credentialOfferPayload: import("@sphereon/oid4vci-common").CredentialOfferPayloadV1_0_11;
|
|
40
|
+
credentialOffer: string;
|
|
41
|
+
}>;
|
|
42
|
+
/**
|
|
43
|
+
* This function retrieves the credential offer referenced by the given URI.
|
|
44
|
+
* Retrieving a credential offer from a URI is possible after a credential offer was created with
|
|
45
|
+
* @see createCredentialOffer and the credentialOfferUri option.
|
|
46
|
+
*
|
|
47
|
+
* @throws if no credential offer can found for the given URI.
|
|
48
|
+
* @param uri - The URI referencing the credential offer.
|
|
49
|
+
* @returns The credential offer payload associated with the given URI.
|
|
50
|
+
*/
|
|
51
|
+
getCredentialOfferFromUri(uri: string): Promise<OpenId4VciCredentialOfferPayload>;
|
|
52
|
+
/**
|
|
53
|
+
* This function creates a response which can be send to the holder after receiving a credential issuance request.
|
|
54
|
+
*
|
|
55
|
+
* @param options.credentialRequest - The credential request, for which to create a response.
|
|
56
|
+
* @param options.credential - The credential to be issued.
|
|
57
|
+
* @param options.verificationMethod - The verification method used for signing the credential.
|
|
58
|
+
*/
|
|
59
|
+
createCredentialResponse(options: OpenId4VciCreateCredentialResponseOptions & {
|
|
60
|
+
issuerId: string;
|
|
61
|
+
}): Promise<import("@sphereon/oid4vci-common").CredentialResponse>;
|
|
62
|
+
}
|