@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth 0.34.1-fix.171 → 0.34.1-fix.182
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/dist/index.cjs +28 -69
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -10
- package/dist/index.d.ts +8 -10
- package/dist/index.js +29 -70
- package/dist/index.js.map +1 -1
- package/package.json +17 -17
- package/src/agent/SIOPv2RP.ts +41 -80
- package/src/functions.ts +8 -11
- package/src/types/ISIOPv2RP.ts +7 -12
package/dist/index.d.ts
CHANGED
|
@@ -9,12 +9,13 @@ import { IIdentifierResolution, ManagedIdentifierOptsOrResult, ExternalIdentifie
|
|
|
9
9
|
import { IJwtService } from '@sphereon/ssi-sdk-ext.jwt-service';
|
|
10
10
|
import { ICredentialValidation, SchemaValidation } from '@sphereon/ssi-sdk.credential-validation';
|
|
11
11
|
import { ImDLMdoc } from '@sphereon/ssi-sdk.mdl-mdoc';
|
|
12
|
-
import { IPDManager, VersionControlMode } from '@sphereon/ssi-sdk.pd-manager';
|
|
12
|
+
import { IPDManager, ImportDcqlQueryItem, VersionControlMode } from '@sphereon/ssi-sdk.pd-manager';
|
|
13
13
|
import { IPresentationExchange } from '@sphereon/ssi-sdk.presentation-exchange';
|
|
14
14
|
import { ISDJwtPlugin } from '@sphereon/ssi-sdk.sd-jwt';
|
|
15
15
|
import { AuthorizationRequestStateStatus } from '@sphereon/ssi-sdk.siopv2-oid4vp-common';
|
|
16
|
-
import {
|
|
16
|
+
import { HasherSync } from '@sphereon/ssi-types';
|
|
17
17
|
import { VerifyCallback } from '@sphereon/wellknown-dids-client';
|
|
18
|
+
import { DcqlQuery } from 'dcql';
|
|
18
19
|
import { Resolvable } from 'did-resolver';
|
|
19
20
|
import { EventEmitter } from 'events';
|
|
20
21
|
|
|
@@ -435,9 +436,10 @@ interface IGetAuthResponseStateArgs {
|
|
|
435
436
|
queryId?: string;
|
|
436
437
|
errorOnNotFound?: boolean;
|
|
437
438
|
progressRequestStateTo?: AuthorizationRequestStateStatus;
|
|
439
|
+
includeVerifiedData?: VerifiedDataMode;
|
|
438
440
|
}
|
|
439
441
|
interface IUpdateRequestStateArgs {
|
|
440
|
-
queryId
|
|
442
|
+
queryId: string;
|
|
441
443
|
correlationId: string;
|
|
442
444
|
state: AuthorizationRequestStateStatus;
|
|
443
445
|
error?: string;
|
|
@@ -451,14 +453,10 @@ interface IVerifyAuthResponseStateArgs {
|
|
|
451
453
|
queryId?: string;
|
|
452
454
|
correlationId: string;
|
|
453
455
|
audience?: string;
|
|
454
|
-
|
|
455
|
-
}
|
|
456
|
-
interface IDefinitionPair {
|
|
457
|
-
definitionPayload?: IPresentationDefinition;
|
|
458
|
-
dcqlPayload?: DcqlQueryPayload;
|
|
456
|
+
dcqlQuery?: DcqlQuery;
|
|
459
457
|
}
|
|
460
458
|
interface ImportDefinitionsArgs {
|
|
461
|
-
|
|
459
|
+
importItems: Array<ImportDcqlQueryItem>;
|
|
462
460
|
tenantId?: string;
|
|
463
461
|
version?: string;
|
|
464
462
|
versionControlMode?: VersionControlMode;
|
|
@@ -897,4 +895,4 @@ declare class SIOPv2RP implements IAgentPlugin {
|
|
|
897
895
|
private getDefaultOptions;
|
|
898
896
|
}
|
|
899
897
|
|
|
900
|
-
export { type CredentialOpts, type IAuthRequestDetails, type IAuthorizationRequestPayloads, type ICreateAuthRequestArgs, type
|
|
898
|
+
export { type CredentialOpts, type IAuthRequestDetails, type IAuthorizationRequestPayloads, type ICreateAuthRequestArgs, type IDeleteAuthStateArgs, type IGetAuthRequestStateArgs, type IGetAuthResponseStateArgs, type IGetRedirectUriArgs, type IPEXDefinitionPersistArgs, type IPEXInstanceOptions, type IPEXOptions, 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, plugin_schema as schema };
|
package/dist/index.js
CHANGED
|
@@ -337,7 +337,7 @@ import { AuthorizationResponseStateStatus, decodeUriAsJson } from "@sphereon/did
|
|
|
337
337
|
import { getAgentResolver as getAgentResolver2 } from "@sphereon/ssi-sdk-ext.did-utils";
|
|
338
338
|
import { shaHasher as defaultHasher2 } from "@sphereon/ssi-sdk.core";
|
|
339
339
|
import { CredentialMapper as CredentialMapper2 } from "@sphereon/ssi-types";
|
|
340
|
-
import {
|
|
340
|
+
import { DcqlQuery } from "dcql";
|
|
341
341
|
|
|
342
342
|
// src/functions.ts
|
|
343
343
|
import { ClientIdentifierPrefix, InMemoryRPSessionManager, PassBy, PropertyTarget, ResponseMode, ResponseType, RevocationVerification, RP, Scope, SubjectType, SupportedVersion } from "@sphereon/did-auth-siop";
|
|
@@ -413,7 +413,7 @@ async function createRPBuilder(args) {
|
|
|
413
413
|
const presentationDefinitionItems = await context.agent.pdmGetDefinitions({
|
|
414
414
|
filter: [
|
|
415
415
|
{
|
|
416
|
-
|
|
416
|
+
queryId: pexOpts.queryId,
|
|
417
417
|
version: pexOpts.version,
|
|
418
418
|
tenantId: pexOpts.tenantId
|
|
419
419
|
}
|
|
@@ -759,26 +759,23 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
759
759
|
return void 0;
|
|
760
760
|
}
|
|
761
761
|
const responseState = authorizationResponseState;
|
|
762
|
-
if (responseState.status === AuthorizationResponseStateStatus.VERIFIED) {
|
|
762
|
+
if (responseState.status === AuthorizationResponseStateStatus.VERIFIED && args.includeVerifiedData && args.includeVerifiedData !== VerifiedDataMode.NONE) {
|
|
763
763
|
let hasher;
|
|
764
764
|
if (CredentialMapper2.isSdJwtEncoded(responseState.response.payload.vp_token) && (!rpInstance.rpOptions.credentialOpts?.hasher || typeof rpInstance.rpOptions.credentialOpts?.hasher !== "function")) {
|
|
765
765
|
hasher = defaultHasher2;
|
|
766
766
|
}
|
|
767
|
-
const
|
|
768
|
-
|
|
769
|
-
|
|
770
|
-
|
|
771
|
-
|
|
772
|
-
|
|
773
|
-
|
|
774
|
-
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
const presentationOrClaims = this.presentationOrClaimsFrom(presentationDecoded);
|
|
780
|
-
if ("verifiableCredential" in presentationOrClaims) {
|
|
781
|
-
for (const credential of presentationOrClaims.verifiableCredential) {
|
|
767
|
+
const presentationDecoded = CredentialMapper2.decodeVerifiablePresentation(
|
|
768
|
+
responseState.response.payload.vp_token,
|
|
769
|
+
//todo: later we want to conditionally pass in options for mdl-mdoc here
|
|
770
|
+
hasher
|
|
771
|
+
);
|
|
772
|
+
switch (args.includeVerifiedData) {
|
|
773
|
+
case VerifiedDataMode.VERIFIED_PRESENTATION:
|
|
774
|
+
responseState.response.payload.verifiedData = this.presentationOrClaimsFrom(presentationDecoded);
|
|
775
|
+
break;
|
|
776
|
+
case VerifiedDataMode.CREDENTIAL_SUBJECT_FLATTENED:
|
|
777
|
+
const allClaims = {};
|
|
778
|
+
for (const credential of this.presentationOrClaimsFrom(presentationDecoded).verifiableCredential || []) {
|
|
782
779
|
const vc = credential;
|
|
783
780
|
const schemaValidationResult = await context.agent.cvVerifySchema({
|
|
784
781
|
credential,
|
|
@@ -794,41 +791,19 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
794
791
|
if (!("id" in allClaims)) {
|
|
795
792
|
allClaims["id"] = credentialSubject.id;
|
|
796
793
|
}
|
|
797
|
-
Object.entries(credentialSubject).forEach(([
|
|
798
|
-
if (!(
|
|
799
|
-
allClaims[
|
|
794
|
+
Object.entries(credentialSubject).forEach(([key, value]) => {
|
|
795
|
+
if (!(key in allClaims)) {
|
|
796
|
+
allClaims[key] = value;
|
|
800
797
|
}
|
|
801
798
|
});
|
|
802
|
-
claims.push({
|
|
803
|
-
id: key,
|
|
804
|
-
type: vc.type[0],
|
|
805
|
-
claims: allClaims
|
|
806
|
-
});
|
|
807
799
|
}
|
|
808
|
-
|
|
809
|
-
|
|
810
|
-
id: key,
|
|
811
|
-
type: presentationDecoded.decodedPayload.vct,
|
|
812
|
-
claims: presentationOrClaims
|
|
813
|
-
});
|
|
814
|
-
}
|
|
800
|
+
responseState.verifiedData = allClaims;
|
|
801
|
+
break;
|
|
815
802
|
}
|
|
816
|
-
responseState.verifiedData = {
|
|
817
|
-
...responseState.response.payload.vp_token && {
|
|
818
|
-
authorization_response: {
|
|
819
|
-
vp_token: typeof responseState.response.payload.vp_token === "string" ? JSON.parse(responseState.response.payload.vp_token) : responseState.response.payload.vp_token
|
|
820
|
-
}
|
|
821
|
-
},
|
|
822
|
-
...claims.length > 0 && {
|
|
823
|
-
credential_claims: claims
|
|
824
|
-
}
|
|
825
|
-
};
|
|
826
803
|
}
|
|
827
804
|
return responseState;
|
|
828
805
|
}
|
|
829
|
-
presentationOrClaimsFrom = /* @__PURE__ */ __name((presentationDecoded) =>
|
|
830
|
-
return CredentialMapper2.isSdJwtDecodedCredential(presentationDecoded) ? presentationDecoded.decodedPayload : CredentialMapper2.toUniformPresentation(presentationDecoded);
|
|
831
|
-
}, "presentationOrClaimsFrom");
|
|
806
|
+
presentationOrClaimsFrom = /* @__PURE__ */ __name((presentationDecoded) => CredentialMapper2.isSdJwtDecodedCredential(presentationDecoded) ? presentationDecoded.decodedPayload : CredentialMapper2.toUniformPresentation(presentationDecoded), "presentationOrClaimsFrom");
|
|
832
807
|
async siopUpdateRequestState(args, context) {
|
|
833
808
|
if (args.state !== "authorization_request_created") {
|
|
834
809
|
throw Error(`Only 'authorization_request_created' status is supported for this method at this point`);
|
|
@@ -857,39 +832,23 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
857
832
|
queryId: args.queryId
|
|
858
833
|
}, context).then((rp) => rp.get(context).then((rp2) => rp2.verifyAuthorizationResponse(authResponse, {
|
|
859
834
|
correlationId: args.correlationId,
|
|
860
|
-
...args.
|
|
861
|
-
dcqlQuery: args.
|
|
835
|
+
...args.dcqlQuery ? {
|
|
836
|
+
dcqlQuery: args.dcqlQuery
|
|
862
837
|
} : {},
|
|
863
838
|
audience: args.audience
|
|
864
839
|
})));
|
|
865
840
|
}
|
|
866
841
|
async siopImportDefinitions(args, context) {
|
|
867
|
-
const {
|
|
868
|
-
await Promise.all(
|
|
869
|
-
|
|
870
|
-
|
|
871
|
-
return Promise.reject(Error("Either dcqlPayload or definitionPayload must be suppplied"));
|
|
872
|
-
}
|
|
873
|
-
let definitionId;
|
|
874
|
-
if (definitionPair.dcqlPayload) {
|
|
875
|
-
DcqlQuery.validate(definitionPair.dcqlPayload.dcqlQuery);
|
|
876
|
-
console.log(`persisting DCQL definition ${definitionPair.dcqlPayload.queryId} with versionControlMode ${versionControlMode}`);
|
|
877
|
-
definitionId = definitionPair.dcqlPayload.queryId;
|
|
878
|
-
}
|
|
879
|
-
if (definitionPayload) {
|
|
880
|
-
await context.agent.pexValidateDefinition({
|
|
881
|
-
definition: definitionPayload
|
|
882
|
-
});
|
|
883
|
-
console.log(`persisting PEX definition ${definitionPayload.id} / ${definitionPayload.name} with versionControlMode ${versionControlMode}`);
|
|
884
|
-
definitionId = definitionPayload.id;
|
|
885
|
-
}
|
|
842
|
+
const { importItems, tenantId, version, versionControlMode } = args;
|
|
843
|
+
await Promise.all(importItems.map(async (importItem) => {
|
|
844
|
+
DcqlQuery.validate(importItem.query);
|
|
845
|
+
console.log(`persisting DCQL definition ${importItem.queryId} with versionControlMode ${versionControlMode}`);
|
|
886
846
|
return context.agent.pdmPersistDefinition({
|
|
887
847
|
definitionItem: {
|
|
888
|
-
|
|
848
|
+
queryId: importItem.queryId,
|
|
889
849
|
tenantId,
|
|
890
850
|
version,
|
|
891
|
-
|
|
892
|
-
dcqlPayload: definitionPair.dcqlPayload
|
|
851
|
+
query: importItem.query
|
|
893
852
|
},
|
|
894
853
|
opts: {
|
|
895
854
|
versionControlMode
|