@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth 0.33.1-feature.vcdm2.tsup.31 → 0.33.1-next.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.
@@ -0,0 +1,243 @@
1
+ "use strict";
2
+ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
+ function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
+ return new (P || (P = Promise))(function (resolve, reject) {
5
+ function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
+ function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
+ function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
+ step((generator = generator.apply(thisArg, _arguments || [])).next());
9
+ });
10
+ };
11
+ Object.defineProperty(exports, "__esModule", { value: true });
12
+ exports.getRequestVersion = getRequestVersion;
13
+ exports.getPresentationVerificationCallback = getPresentationVerificationCallback;
14
+ exports.createRPBuilder = createRPBuilder;
15
+ exports.signCallback = signCallback;
16
+ exports.createRP = createRP;
17
+ exports.getSigningAlgo = getSigningAlgo;
18
+ const did_auth_siop_1 = require("@sphereon/did-auth-siop");
19
+ const oid4vc_common_1 = require("@sphereon/oid4vc-common");
20
+ const ssi_sdk_ext_did_utils_1 = require("@sphereon/ssi-sdk-ext.did-utils");
21
+ const ssi_sdk_ext_identifier_resolution_1 = require("@sphereon/ssi-sdk-ext.identifier-resolution");
22
+ const ssi_types_1 = require("@sphereon/ssi-types");
23
+ const events_1 = require("events");
24
+ const ssi_sdk_core_1 = require("@sphereon/ssi-sdk.core");
25
+ function getRequestVersion(rpOptions) {
26
+ if (Array.isArray(rpOptions.supportedVersions) && rpOptions.supportedVersions.length > 0) {
27
+ return rpOptions.supportedVersions[0];
28
+ }
29
+ return did_auth_siop_1.SupportedVersion.JWT_VC_PRESENTATION_PROFILE_v1;
30
+ }
31
+ function getWellKnownDIDVerifyCallback(siopIdentifierOpts, context) {
32
+ return siopIdentifierOpts.wellknownDIDVerifyCallback
33
+ ? siopIdentifierOpts.wellknownDIDVerifyCallback
34
+ : (args) => __awaiter(this, void 0, void 0, function* () {
35
+ const result = yield context.agent.cvVerifyCredential({
36
+ credential: args.credential,
37
+ fetchRemoteContexts: true,
38
+ });
39
+ return { verified: result.result };
40
+ });
41
+ }
42
+ function getPresentationVerificationCallback(idOpts, context) {
43
+ function presentationVerificationCallback(args, // FIXME any
44
+ presentationSubmission) {
45
+ return __awaiter(this, void 0, void 0, function* () {
46
+ var _a;
47
+ if (ssi_types_1.CredentialMapper.isSdJwtEncoded(args)) {
48
+ const result = yield context.agent.verifySdJwtPresentation({
49
+ presentation: args,
50
+ kb: true,
51
+ });
52
+ // fixme: investigate the correct way to handle this
53
+ return { verified: !!result.payload };
54
+ }
55
+ if (ssi_types_1.CredentialMapper.isMsoMdocOid4VPEncoded(args)) {
56
+ // TODO Funke reevaluate
57
+ if (context.agent.mdocOid4vpRPVerify === undefined) {
58
+ return Promise.reject('ImDLMdoc agent plugin must be enabled to support MsoMdoc types');
59
+ }
60
+ if (presentationSubmission !== undefined && presentationSubmission !== null) {
61
+ const verifyResult = yield context.agent.mdocOid4vpRPVerify({
62
+ vp_token: args,
63
+ presentation_submission: presentationSubmission,
64
+ });
65
+ return { verified: !verifyResult.error };
66
+ }
67
+ throw Error(`mdocOid4vpRPVerify(...) method requires a presentation submission`);
68
+ }
69
+ const result = yield context.agent.verifyPresentation({
70
+ presentation: args,
71
+ fetchRemoteContexts: true,
72
+ domain: (_a = (yield context.agent.identifierManagedGet(idOpts)).kid) === null || _a === void 0 ? void 0 : _a.split('#')[0],
73
+ });
74
+ return { verified: result.verified };
75
+ });
76
+ }
77
+ return presentationVerificationCallback;
78
+ }
79
+ function createRPBuilder(args) {
80
+ return __awaiter(this, void 0, void 0, function* () {
81
+ var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
82
+ const { rpOpts, pexOpts, context } = args;
83
+ const { identifierOpts } = rpOpts;
84
+ let definition = args.definition;
85
+ let dcqlQuery = args.dcql;
86
+ if (!definition && pexOpts && pexOpts.definitionId) {
87
+ const presentationDefinitionItems = yield context.agent.pdmGetDefinitions({
88
+ filter: [
89
+ {
90
+ definitionId: pexOpts.definitionId,
91
+ version: pexOpts.version,
92
+ tenantId: pexOpts.tenantId,
93
+ },
94
+ ],
95
+ });
96
+ if (presentationDefinitionItems.length > 0) {
97
+ const presentationDefinitionItem = presentationDefinitionItems[0];
98
+ definition = presentationDefinitionItem.definitionPayload;
99
+ if (!dcqlQuery && presentationDefinitionItem.dcqlPayload) {
100
+ dcqlQuery = presentationDefinitionItem.dcqlPayload; // cast from DcqlQueryREST back to valibot DcqlQuery
101
+ }
102
+ }
103
+ }
104
+ const didMethods = (_a = identifierOpts.supportedDIDMethods) !== null && _a !== void 0 ? _a : (yield (0, ssi_sdk_ext_did_utils_1.getAgentDIDMethods)(context));
105
+ const eventEmitter = (_b = rpOpts.eventEmitter) !== null && _b !== void 0 ? _b : new events_1.EventEmitter();
106
+ const defaultClientMetadata = {
107
+ // FIXME: All of the below should be configurable. Some should come from builder, some should be determined by the agent.
108
+ // For now it is either preconfigured or everything passed in as a single object
109
+ idTokenSigningAlgValuesSupported: [oid4vc_common_1.SigningAlgo.EDDSA, oid4vc_common_1.SigningAlgo.ES256, oid4vc_common_1.SigningAlgo.ES256K], // added newly
110
+ requestObjectSigningAlgValuesSupported: [oid4vc_common_1.SigningAlgo.EDDSA, oid4vc_common_1.SigningAlgo.ES256, oid4vc_common_1.SigningAlgo.ES256K], // added newly
111
+ responseTypesSupported: [did_auth_siop_1.ResponseType.ID_TOKEN], // added newly
112
+ client_name: 'Sphereon',
113
+ vpFormatsSupported: {
114
+ jwt_vc: { alg: ['EdDSA', 'ES256K'] },
115
+ jwt_vp: { alg: ['ES256K', 'EdDSA'] },
116
+ },
117
+ scopesSupported: [did_auth_siop_1.Scope.OPENID_DIDAUTHN],
118
+ subjectTypesSupported: [did_auth_siop_1.SubjectType.PAIRWISE],
119
+ subject_syntax_types_supported: didMethods.map((method) => `did:${method}`),
120
+ passBy: did_auth_siop_1.PassBy.VALUE,
121
+ };
122
+ const resolver = (_d = (_c = rpOpts.identifierOpts.resolveOpts) === null || _c === void 0 ? void 0 : _c.resolver) !== null && _d !== void 0 ? _d : (0, ssi_sdk_ext_did_utils_1.getAgentResolver)(context, {
123
+ resolverResolution: true,
124
+ localResolution: true,
125
+ uniresolverResolution: ((_e = rpOpts.identifierOpts.resolveOpts) === null || _e === void 0 ? void 0 : _e.noUniversalResolverFallback) !== true,
126
+ });
127
+ //todo: probably wise to first look and see if we actually need the hasher to begin with
128
+ let hasher = (_f = rpOpts.credentialOpts) === null || _f === void 0 ? void 0 : _f.hasher;
129
+ if (!((_g = rpOpts.credentialOpts) === null || _g === void 0 ? void 0 : _g.hasher) || typeof ((_h = rpOpts.credentialOpts) === null || _h === void 0 ? void 0 : _h.hasher) !== 'function') {
130
+ hasher = ssi_sdk_core_1.defaultHasher;
131
+ }
132
+ const builder = did_auth_siop_1.RP.builder({ requestVersion: getRequestVersion(rpOpts) })
133
+ .withScope('openid', did_auth_siop_1.PropertyTarget.REQUEST_OBJECT)
134
+ .withResponseMode((_j = rpOpts.responseMode) !== null && _j !== void 0 ? _j : did_auth_siop_1.ResponseMode.POST)
135
+ .withResponseType(did_auth_siop_1.ResponseType.VP_TOKEN, did_auth_siop_1.PropertyTarget.REQUEST_OBJECT)
136
+ // todo: move to options fill/correct method
137
+ .withSupportedVersions((_k = rpOpts.supportedVersions) !== null && _k !== void 0 ? _k : [did_auth_siop_1.SupportedVersion.JWT_VC_PRESENTATION_PROFILE_v1, did_auth_siop_1.SupportedVersion.SIOPv2_ID1, did_auth_siop_1.SupportedVersion.SIOPv2_D11])
138
+ .withEventEmitter(eventEmitter)
139
+ .withSessionManager((_l = rpOpts.sessionManager) !== null && _l !== void 0 ? _l : new did_auth_siop_1.InMemoryRPSessionManager(eventEmitter))
140
+ .withClientMetadata((_m = rpOpts.clientMetadataOpts) !== null && _m !== void 0 ? _m : defaultClientMetadata, did_auth_siop_1.PropertyTarget.REQUEST_OBJECT)
141
+ .withVerifyJwtCallback(rpOpts.verifyJwtCallback
142
+ ? rpOpts.verifyJwtCallback
143
+ : getVerifyJwtCallback({
144
+ resolver,
145
+ verifyOpts: {
146
+ wellknownDIDVerifyCallback: getWellKnownDIDVerifyCallback(rpOpts.identifierOpts, context),
147
+ checkLinkedDomain: 'if_present',
148
+ },
149
+ }, context))
150
+ .withRevocationVerification(did_auth_siop_1.RevocationVerification.NEVER)
151
+ .withPresentationVerification(getPresentationVerificationCallback(identifierOpts.idOpts, context));
152
+ const oidfOpts = identifierOpts.oidfOpts;
153
+ if (oidfOpts && (0, ssi_sdk_ext_identifier_resolution_1.isExternalIdentifierOIDFEntityIdOpts)(oidfOpts)) {
154
+ builder.withEntityId(oidfOpts.identifier, did_auth_siop_1.PropertyTarget.REQUEST_OBJECT).withClientIdScheme('entity_id', did_auth_siop_1.PropertyTarget.REQUEST_OBJECT);
155
+ }
156
+ else {
157
+ const resolution = yield context.agent.identifierManagedGet(identifierOpts.idOpts);
158
+ builder
159
+ .withClientId((_o = resolution.issuer) !== null && _o !== void 0 ? _o : ((0, ssi_sdk_ext_identifier_resolution_1.isManagedIdentifierDidResult)(resolution) ? resolution.did : resolution.jwkThumbprint), did_auth_siop_1.PropertyTarget.REQUEST_OBJECT)
160
+ .withClientIdScheme((_p = resolution.clientIdScheme) !== null && _p !== void 0 ? _p : identifierOpts.idOpts.clientIdScheme, did_auth_siop_1.PropertyTarget.REQUEST_OBJECT);
161
+ }
162
+ if (hasher) {
163
+ builder.withHasher(hasher);
164
+ }
165
+ //fixme: this has been removed in the new version of did-auth-siop
166
+ /*if (!rpOpts.clientMetadataOpts?.subjectTypesSupported) {
167
+ // Do not update in case it is already provided via client metadata opts
168
+ didMethods.forEach((method) => builder.addDidMethod(method))
169
+ }*/
170
+ //fixme: this has been removed in the new version of did-auth-siop
171
+ // builder.withWellknownDIDVerifyCallback(getWellKnownDIDVerifyCallback(didOpts, context))
172
+ if (definition) {
173
+ builder.withPresentationDefinition({ definition }, did_auth_siop_1.PropertyTarget.REQUEST_OBJECT);
174
+ }
175
+ if (dcqlQuery) {
176
+ builder.withDcqlQuery(dcqlQuery);
177
+ }
178
+ if (rpOpts.responseRedirectUri) {
179
+ builder.withResponseRedirectUri(rpOpts.responseRedirectUri);
180
+ }
181
+ //const key = resolution.key
182
+ //fixme: this has been removed in the new version of did-auth-siop
183
+ //builder.withSuppliedSignature(SuppliedSigner(key, context, getSigningAlgo(key.type) as unknown as KeyAlgo), did, kid, getSigningAlgo(key.type))
184
+ /*if (isManagedIdentifierDidResult(resolution)) {
185
+ //fixme: only accepts dids in version used. New SIOP lib also accepts other types
186
+ builder.withSuppliedSignature(
187
+ SuppliedSigner(key, context, getSigningAlgo(key.type) as unknown as KeyAlgo),
188
+ resolution.did,
189
+ resolution.kid,
190
+ getSigningAlgo(key.type),
191
+ )
192
+ }*/
193
+ //fixme: signcallback and it's return type are not totally compatible with our CreateJwtCallbackBase
194
+ const createJwtCallback = signCallback(rpOpts.identifierOpts.idOpts, context);
195
+ builder.withCreateJwtCallback(createJwtCallback);
196
+ return builder;
197
+ });
198
+ }
199
+ function signCallback(idOpts, context) {
200
+ return (jwtIssuer, jwt, kid) => __awaiter(this, void 0, void 0, function* () {
201
+ if (!((0, ssi_sdk_ext_identifier_resolution_1.isManagedIdentifierDidOpts)(idOpts) || (0, ssi_sdk_ext_identifier_resolution_1.isManagedIdentifierX5cOpts)(idOpts))) {
202
+ return Promise.reject(Error(`JWT issuer method ${jwtIssuer.method} not yet supported`));
203
+ }
204
+ const result = yield context.agent.jwtCreateJwsCompactSignature({
205
+ // FIXME fix cose-key inference
206
+ // @ts-ignore
207
+ issuer: { identifier: idOpts.identifier, kmsKeyRef: idOpts.kmsKeyRef, noIdentifierInHeader: false },
208
+ // FIXME fix JWK key_ops
209
+ // @ts-ignore
210
+ protectedHeader: jwt.header,
211
+ payload: jwt.payload,
212
+ });
213
+ return result.jwt;
214
+ });
215
+ }
216
+ function getVerifyJwtCallback(_opts, context) {
217
+ return (_jwtVerifier, jwt) => __awaiter(this, void 0, void 0, function* () {
218
+ const result = yield context.agent.jwtVerifyJwsSignature({ jws: jwt.raw });
219
+ console.log(result.message);
220
+ return !result.error;
221
+ });
222
+ }
223
+ function createRP(_a) {
224
+ return __awaiter(this, arguments, void 0, function* ({ rpOptions, context }) {
225
+ return (yield createRPBuilder({ rpOpts: rpOptions, context })).build();
226
+ });
227
+ }
228
+ function getSigningAlgo(type) {
229
+ switch (type) {
230
+ case 'Ed25519':
231
+ return oid4vc_common_1.SigningAlgo.EDDSA;
232
+ case 'Secp256k1':
233
+ return oid4vc_common_1.SigningAlgo.ES256K;
234
+ case 'Secp256r1':
235
+ return oid4vc_common_1.SigningAlgo.ES256;
236
+ // @ts-ignore
237
+ case 'RSA':
238
+ return oid4vc_common_1.SigningAlgo.RS256;
239
+ default:
240
+ throw Error('Key type not yet supported');
241
+ }
242
+ }
243
+ //# sourceMappingURL=functions.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"functions.js","sourceRoot":"","sources":["../src/functions.ts"],"names":[],"mappings":";;;;;;;;;;;AAyCA,8CAKC;AAcD,kFAyCC;AAED,0CAqJC;AAED,oCAmBC;AAmBD,4BAEC;AAED,wCAcC;AAtTD,2DAiBgC;AAChC,2DAA0G;AAE1G,2EAAsF;AACtF,mGAMoD;AAGpD,mDAAoH;AAMpH,mCAAqC;AAGrC,yDAAsD;AAEtD,SAAgB,iBAAiB,CAAC,SAAqB;IACrD,IAAI,KAAK,CAAC,OAAO,CAAC,SAAS,CAAC,iBAAiB,CAAC,IAAI,SAAS,CAAC,iBAAiB,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;QACzF,OAAO,SAAS,CAAC,iBAAiB,CAAC,CAAC,CAAC,CAAA;IACvC,CAAC;IACD,O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Context, IResolver, IDIDManager, IKeyManager, ICredentialIssuer, ICredentialVerifier, IAgentPlugin } from '@veramo/core';
2
- import { ResponseURIType, ClaimPayloadCommonOpts, AuthorizationRequestPayload, RequestObjectPayload, AuthorizationRequestState, AuthorizationResponseState, AuthorizationResponsePayload, PresentationDefinitionWithLocation, VerifiedAuthorizationResponse, ResponseMode, SupportedVersion, IRPSessionManager, ClientMetadataOpts, VerifyJwtCallback, PresentationVerificationCallback, VPTokenLocation, VerifiablePresentationTypeFormat, RP, URI, AuthorizationRequest } from '@sphereon/did-auth-siop';
3
- import { IIdentifierResolution, ManagedIdentifierOptsOrResult, ExternalIdentifierOIDFEntityIdOpts } from '@sphereon/ssi-sdk-ext.identifier-resolution';
4
- import { AdditionalClaims, DcqlQueryREST, HasherSync, W3CVerifiablePresentation } from '@sphereon/ssi-types';
5
- import { Resolvable } from 'did-resolver';
6
- import { DIDDocument } from '@sphereon/did-uni-client';
7
- import { EventEmitter } from 'events';
8
- import { IPresentationDefinition } from '@sphereon/pex';
9
- import { IDIDOptions } from '@sphereon/ssi-sdk-ext.did-utils';
10
- import { IPresentationExchange } from '@sphereon/ssi-sdk.presentation-exchange';
11
- import { VerifyCallback } from '@sphereon/wellknown-dids-client';
12
- import { AuthorizationRequestStateStatus } from '@sphereon/ssi-sdk.siopv2-oid4vp-common';
13
- import { IPDManager, VersionControlMode } from '@sphereon/ssi-sdk.pd-manager';
14
- import { CheckLinkedDomain } from '@sphereon/did-auth-siop-adapter';
15
- import { ISDJwtPlugin } from '@sphereon/ssi-sdk.sd-jwt';
16
- import { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service';
17
- import { JwtIssuer } from '@sphereon/oid4vc-common';
18
- import { ImDLMdoc } from '@sphereon/ssi-sdk.mdl-mdoc';
19
- import { ICredentialValidation, SchemaValidation } from '@sphereon/ssi-sdk.credential-validation';
20
-
21
- declare enum VerifiedDataMode {
22
- NONE = "none",
23
- VERIFIED_PRESENTATION = "vp",
24
- CREDENTIAL_SUBJECT_FLATTENED = "cs-flat"
25
- }
26
- interface ISIOPv2RP extends IPluginMethodMap {
27
- siopCreateAuthRequestURI(createArgs: ICreateAuthRequestArgs, context: IRequiredContext): Promise<string>;
28
- siopCreateAuthRequestPayloads(createArgs: ICreateAuthRequestArgs, context: IRequiredContext): Promise<IAuthorizationRequestPayloads>;
29
- siopGetAuthRequestState(args: IGetAuthRequestStateArgs, context: IRequiredContext): Promise<AuthorizationRequestState | undefined>;
30
- siopGetAuthResponseState(args: IGetAuthResponseStateArgs, context: IRequiredContext): Promise<AuthorizationResponseStateWithVerifiedData | undefined>;
31
- siopUpdateAuthRequestState(args: IUpdateRequestStateArgs, context: IRequiredContext): Promise<AuthorizationRequestState>;
32
- siopDeleteAuthState(args: IDeleteAuthStateArgs, context: IRequiredContext): Promise<boolean>;
33
- siopVerifyAuthResponse(args: IVerifyAuthResponseStateArgs, context: IRequiredContext): Promise<VerifiedAuthorizationResponse>;
34
- siopImportDefinitions(args: ImportDefinitionsArgs, context: IRequiredContext): Promise<void>;
35
- siopGetRedirectURI(args: IGetRedirectUriArgs, context: IRequiredContext): Promise<string | undefined>;
36
- }
37
- interface ISiopv2RPOpts {
38
- defaultOpts?: IRPDefaultOpts;
39
- instanceOpts?: IPEXInstanceOptions[];
40
- }
41
- interface IRPDefaultOpts extends IRPOptions {
42
- }
43
- interface ICreateAuthRequestArgs {
44
- definitionId: string;
45
- correlationId: string;
46
- responseURIType: ResponseURIType;
47
- responseURI: string;
48
- responseRedirectURI?: string;
49
- jwtIssuer?: JwtIssuer;
50
- requestByReferenceURI?: string;
51
- nonce?: string;
52
- state?: string;
53
- claims?: ClaimPayloadCommonOpts;
54
- }
55
- interface IGetAuthRequestStateArgs {
56
- correlationId: string;
57
- definitionId: string;
58
- errorOnNotFound?: boolean;
59
- }
60
- interface IGetAuthResponseStateArgs {
61
- correlationId: string;
62
- definitionId: string;
63
- errorOnNotFound?: boolean;
64
- progressRequestStateTo?: AuthorizationRequestStateStatus;
65
- includeVerifiedData?: VerifiedDataMode;
66
- }
67
- interface IUpdateRequestStateArgs {
68
- definitionId: string;
69
- correlationId: string;
70
- state: AuthorizationRequestStateStatus;
71
- error?: string;
72
- }
73
- interface IDeleteAuthStateArgs {
74
- correlationId: string;
75
- definitionId: string;
76
- }
77
- interface IVerifyAuthResponseStateArgs {
78
- authorizationResponse: string | AuthorizationResponsePayload;
79
- definitionId?: string;
80
- correlationId: string;
81
- audience?: string;
82
- presentationDefinitions?: PresentationDefinitionWithLocation | PresentationDefinitionWithLocation[];
83
- dcqlQuery?: DcqlQueryREST;
84
- }
85
- interface IDefinitionPair {
86
- definitionPayload: IPresentationDefinition;
87
- dcqlPayload?: DcqlQueryREST;
88
- }
89
- interface ImportDefinitionsArgs {
90
- definitions: Array<IDefinitionPair>;
91
- tenantId?: string;
92
- version?: string;
93
- versionControlMode?: VersionControlMode;
94
- }
95
- interface IGetRedirectUriArgs {
96
- correlationId: string;
97
- definitionId?: string;
98
- state?: string;
99
- }
100
- interface IAuthorizationRequestPayloads {
101
- authorizationRequest: AuthorizationRequestPayload;
102
- requestObject?: string;
103
- requestObjectDecoded?: RequestObjectPayload;
104
- }
105
- interface IPEXDefinitionPersistArgs extends IPEXInstanceOptions {
106
- definition: IPresentationDefinition;
107
- ttl?: number;
108
- }
109
- interface ISiopRPInstanceArgs {
110
- definitionId?: string;
111
- responseRedirectURI?: string;
112
- }
113
- interface IPEXInstanceOptions extends IPEXOptions {
114
- rpOpts?: IRPOptions;
115
- }
116
- interface IRPOptions {
117
- responseMode?: ResponseMode;
118
- supportedVersions?: SupportedVersion[];
119
- sessionManager?: IRPSessionManager;
120
- clientMetadataOpts?: ClientMetadataOpts;
121
- expiresIn?: number;
122
- eventEmitter?: EventEmitter;
123
- credentialOpts?: CredentialOpts;
124
- verificationPolicies?: VerificationPolicies;
125
- identifierOpts: ISIOPIdentifierOptions;
126
- verifyJwtCallback?: VerifyJwtCallback;
127
- responseRedirectUri?: string;
128
- }
129
- interface IPEXOptions {
130
- presentationVerifyCallback?: PresentationVerificationCallback;
131
- definitionId: string;
132
- version?: string;
133
- tenantId?: string;
134
- }
135
- type VerificationPolicies = {
136
- schemaValidation: SchemaValidation;
137
- };
138
- interface PerDidResolver {
139
- didMethod: string;
140
- resolver: Resolvable;
141
- }
142
- interface IAuthRequestDetails {
143
- rpDIDDocument?: DIDDocument;
144
- id: string;
145
- verifiablePresentationMatches: IPresentationWithDefinition[];
146
- alsoKnownAs?: string[];
147
- }
148
- interface IPresentationWithDefinition {
149
- location: VPTokenLocation;
150
- definition: PresentationDefinitionWithLocation;
151
- format: VerifiablePresentationTypeFormat;
152
- presentation: W3CVerifiablePresentation;
153
- }
154
- interface ISIOPIdentifierOptions extends Omit<IDIDOptions, 'idOpts'> {
155
- idOpts: ManagedIdentifierOptsOrResult;
156
- oidfOpts?: ExternalIdentifierOIDFEntityIdOpts;
157
- checkLinkedDomains?: CheckLinkedDomain;
158
- wellknownDIDVerifyCallback?: VerifyCallback;
159
- }
160
- type CredentialOpts = {
161
- hasher?: HasherSync;
162
- };
163
- interface AuthorizationResponseStateWithVerifiedData extends AuthorizationResponseState {
164
- verifiedData?: AdditionalClaims;
165
- }
166
- type IRequiredContext = IAgentContext<IResolver & IDIDManager & IKeyManager & IIdentifierResolution & ICredentialIssuer & ICredentialValidation & ICredentialVerifier & IPresentationExchange & IPDManager & ISDJwtPlugin & IJwtService & ImDLMdoc>;
167
-
168
- declare class RPInstance {
169
- private _rp;
170
- private readonly _pexOptions;
171
- private readonly _rpOptions;
172
- constructor({ rpOpts, pexOpts }: {
173
- rpOpts: IRPOptions;
174
- pexOpts?: IPEXOptions;
175
- });
176
- get(context: IRequiredContext): Promise<RP>;
177
- get rpOptions(): IRPOptions;
178
- get pexOptions(): IPEXOptions | undefined;
179
- hasDefinition(): boolean;
180
- get definitionId(): string | undefined;
181
- getPresentationDefinition(context: IRequiredContext): Promise<IPresentationDefinition | undefined>;
182
- createAuthorizationRequestURI(createArgs: Omit<ICreateAuthRequestArgs, 'definitionId'>, context: IRequiredContext): Promise<URI>;
183
- createAuthorizationRequest(createArgs: Omit<ICreateAuthRequestArgs, 'definitionId'>, context: IRequiredContext): Promise<AuthorizationRequest>;
184
- }
185
-
186
- declare class SIOPv2RP implements IAgentPlugin {
187
- private readonly opts;
188
- private static readonly _DEFAULT_OPTS_KEY;
189
- private readonly instances;
190
- readonly schema: any;
191
- readonly methods: ISIOPv2RP;
192
- constructor(opts: ISiopv2RPOpts);
193
- setDefaultOpts(rpDefaultOpts: IRPDefaultOpts, context: IRequiredContext): void;
194
- private createAuthorizationRequestURI;
195
- private createAuthorizationRequestPayloads;
196
- private siopGetRequestState;
197
- private siopGetResponseState;
198
- private presentationOrClaimsFrom;
199
- private siopUpdateRequestState;
200
- private siopDeleteState;
201
- private siopVerifyAuthResponse;
202
- private siopImportDefinitions;
203
- private siopGetRedirectURI;
204
- getRPInstance({ definitionId, responseRedirectURI }: ISiopRPInstanceArgs, context: IRequiredContext): Promise<RPInstance>;
205
- getRPOptions(context: IRequiredContext, opts: {
206
- definitionId?: string;
207
- responseRedirectURI?: string;
208
- }): Promise<IRPOptions>;
209
- getInstanceOpts(definitionId?: string): IPEXInstanceOptions | undefined;
210
- private getDefaultOptions;
211
- }
212
-
213
1
  /**
214
2
  * @public
215
3
  */
216
4
  declare const schema: any;
217
-
218
- export { type AuthorizationResponseStateWithVerifiedData, type CredentialOpts, type IAuthRequestDetails, type IAuthorizationRequestPayloads, type ICreateAuthRequestArgs, type IDefinitionPair, type IDeleteAuthStateArgs, type IGetAuthRequestStateArgs, type IGetAuthResponseStateArgs, type IGetRedirectUriArgs, type IPEXDefinitionPersistArgs, type IPEXInstanceOptions, type IPEXOptions, type IPresentationWithDefinition, type IRPDefaultOpts, type IRPOptions, type IRequiredContext, type ISIOPIdentifierOptions, type ISIOPv2RP, type ISiopRPInstanceArgs, type ISiopv2RPOpts, type IUpdateRequestStateArgs, type IVerifyAuthResponseStateArgs, type ImportDefinitionsArgs, type PerDidResolver, SIOPv2RP, type VerificationPolicies, VerifiedDataMode, schema };
5
+ export { schema };
6
+ export { SIOPv2RP } from './agent/SIOPv2RP';
7
+ export * from './types/ISIOPv2RP';
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,QAAA,MAAM,MAAM,KAAmC,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,CAAA;AACjB,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAC3C,cAAc,mBAAmB,CAAA"}