@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth 0.34.1-feature.SSISDK.45.94 → 0.34.1-feature.SSISDK.46.151
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 +58 -48
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +19 -18
- package/dist/index.d.ts +19 -18
- package/dist/index.js +58 -48
- package/dist/index.js.map +1 -1
- package/package.json +18 -18
- package/src/RPInstance.ts +5 -4
- package/src/agent/SIOPv2RP.ts +46 -31
- package/src/functions.ts +12 -17
- package/src/types/ISIOPv2RP.ts +15 -15
package/dist/index.cjs
CHANGED
|
@@ -369,6 +369,7 @@ module.exports = __toCommonJS(index_exports);
|
|
|
369
369
|
var import_did_auth_siop2 = require("@sphereon/did-auth-siop");
|
|
370
370
|
var import_ssi_sdk_ext4 = require("@sphereon/ssi-sdk-ext.did-utils");
|
|
371
371
|
var import_ssi_types2 = require("@sphereon/ssi-types");
|
|
372
|
+
var import_dcql = require("dcql");
|
|
372
373
|
|
|
373
374
|
// src/functions.ts
|
|
374
375
|
var import_did_auth_siop = require("@sphereon/did-auth-siop");
|
|
@@ -401,8 +402,7 @@ function getPresentationVerificationCallback(idOpts, context) {
|
|
|
401
402
|
async function presentationVerificationCallback(args, presentationSubmission) {
|
|
402
403
|
if (import_ssi_types.CredentialMapper.isSdJwtEncoded(args)) {
|
|
403
404
|
const result2 = await context.agent.verifySdJwtPresentation({
|
|
404
|
-
presentation: args
|
|
405
|
-
kb: true
|
|
405
|
+
presentation: args
|
|
406
406
|
});
|
|
407
407
|
return {
|
|
408
408
|
verified: !!result2.payload
|
|
@@ -441,11 +441,11 @@ async function createRPBuilder(args) {
|
|
|
441
441
|
const { identifierOpts } = rpOpts;
|
|
442
442
|
let definition = args.definition;
|
|
443
443
|
let dcqlQuery = args.dcql;
|
|
444
|
-
if (!definition && pexOpts && pexOpts.
|
|
444
|
+
if (!definition && pexOpts && pexOpts.queryId) {
|
|
445
445
|
const presentationDefinitionItems = await context.agent.pdmGetDefinitions({
|
|
446
446
|
filter: [
|
|
447
447
|
{
|
|
448
|
-
definitionId: pexOpts.
|
|
448
|
+
definitionId: pexOpts.queryId,
|
|
449
449
|
version: pexOpts.version,
|
|
450
450
|
tenantId: pexOpts.tenantId
|
|
451
451
|
}
|
|
@@ -453,9 +453,8 @@ async function createRPBuilder(args) {
|
|
|
453
453
|
});
|
|
454
454
|
if (presentationDefinitionItems.length > 0) {
|
|
455
455
|
const presentationDefinitionItem = presentationDefinitionItems[0];
|
|
456
|
-
definition = presentationDefinitionItem.definitionPayload;
|
|
457
456
|
if (!dcqlQuery && presentationDefinitionItem.dcqlPayload) {
|
|
458
|
-
dcqlQuery = presentationDefinitionItem.dcqlPayload;
|
|
457
|
+
dcqlQuery = presentationDefinitionItem.dcqlPayload.dcqlQuery;
|
|
459
458
|
}
|
|
460
459
|
}
|
|
461
460
|
}
|
|
@@ -525,19 +524,14 @@ async function createRPBuilder(args) {
|
|
|
525
524
|
}, context)).withRevocationVerification(import_did_auth_siop.RevocationVerification.NEVER).withPresentationVerification(getPresentationVerificationCallback(identifierOpts.idOpts, context));
|
|
526
525
|
const oidfOpts = identifierOpts.oidfOpts;
|
|
527
526
|
if (oidfOpts && (0, import_ssi_sdk_ext2.isExternalIdentifierOIDFEntityIdOpts)(oidfOpts)) {
|
|
528
|
-
builder.withEntityId(oidfOpts.identifier, import_did_auth_siop.PropertyTarget.REQUEST_OBJECT)
|
|
527
|
+
builder.withEntityId(oidfOpts.identifier, import_did_auth_siop.PropertyTarget.REQUEST_OBJECT);
|
|
529
528
|
} else {
|
|
530
529
|
const resolution = await context.agent.identifierManagedGet(identifierOpts.idOpts);
|
|
531
|
-
builder.withClientId(resolution.issuer ?? ((0, import_ssi_sdk_ext2.isManagedIdentifierDidResult)(resolution) ? resolution.did : resolution.jwkThumbprint), import_did_auth_siop.PropertyTarget.REQUEST_OBJECT)
|
|
530
|
+
builder.withClientId(resolution.issuer ?? ((0, import_ssi_sdk_ext2.isManagedIdentifierDidResult)(resolution) ? resolution.did : resolution.jwkThumbprint), import_did_auth_siop.PropertyTarget.REQUEST_OBJECT);
|
|
532
531
|
}
|
|
533
532
|
if (hasher) {
|
|
534
533
|
builder.withHasher(hasher);
|
|
535
534
|
}
|
|
536
|
-
if (definition) {
|
|
537
|
-
builder.withPresentationDefinition({
|
|
538
|
-
definition
|
|
539
|
-
}, import_did_auth_siop.PropertyTarget.REQUEST_OBJECT);
|
|
540
|
-
}
|
|
541
535
|
if (dcqlQuery) {
|
|
542
536
|
builder.withDcqlQuery(dcqlQuery);
|
|
543
537
|
}
|
|
@@ -633,7 +627,7 @@ var RPInstance = class {
|
|
|
633
627
|
return this.definitionId !== void 0;
|
|
634
628
|
}
|
|
635
629
|
get definitionId() {
|
|
636
|
-
return this.pexOptions?.
|
|
630
|
+
return this.pexOptions?.queryId;
|
|
637
631
|
}
|
|
638
632
|
async getPresentationDefinition(context) {
|
|
639
633
|
return this.definitionId ? await context.agent.pexStoreGetDefinition({
|
|
@@ -642,7 +636,7 @@ var RPInstance = class {
|
|
|
642
636
|
}) : void 0;
|
|
643
637
|
}
|
|
644
638
|
async createAuthorizationRequestURI(createArgs, context) {
|
|
645
|
-
const { correlationId, claims, requestByReferenceURI, responseURI, responseURIType } = createArgs;
|
|
639
|
+
const { correlationId, queryId, claims, requestByReferenceURI, responseURI, responseURIType } = createArgs;
|
|
646
640
|
const nonce = createArgs.nonce ?? (0, import_uuid.v4)();
|
|
647
641
|
const state = createArgs.state ?? correlationId;
|
|
648
642
|
let jwtIssuer;
|
|
@@ -670,6 +664,7 @@ var RPInstance = class {
|
|
|
670
664
|
return await this.get(context).then((rp) => rp.createAuthorizationRequestURI({
|
|
671
665
|
version: getRequestVersion(this.rpOptions),
|
|
672
666
|
correlationId,
|
|
667
|
+
queryId,
|
|
673
668
|
nonce,
|
|
674
669
|
state,
|
|
675
670
|
claims,
|
|
@@ -755,30 +750,32 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
755
750
|
}
|
|
756
751
|
async createAuthorizationRequestURI(createArgs, context) {
|
|
757
752
|
return await this.getRPInstance({
|
|
758
|
-
|
|
759
|
-
|
|
753
|
+
responseRedirectURI: createArgs.responseRedirectURI,
|
|
754
|
+
...createArgs.useQueryIdInstance === true && {
|
|
755
|
+
queryId: createArgs.queryId
|
|
756
|
+
}
|
|
760
757
|
}, context).then((rp) => rp.createAuthorizationRequestURI(createArgs, context)).then((URI) => URI.encodedUri);
|
|
761
758
|
}
|
|
762
759
|
async createAuthorizationRequestPayloads(createArgs, context) {
|
|
763
760
|
return await this.getRPInstance({
|
|
764
|
-
|
|
761
|
+
queryId: createArgs.queryId
|
|
765
762
|
}, context).then((rp) => rp.createAuthorizationRequest(createArgs, context)).then(async (request) => {
|
|
766
763
|
const authRequest = {
|
|
767
764
|
authorizationRequest: request.payload,
|
|
768
765
|
requestObject: await request.requestObjectJwt(),
|
|
769
|
-
requestObjectDecoded:
|
|
766
|
+
requestObjectDecoded: request.requestObject?.getPayload()
|
|
770
767
|
};
|
|
771
768
|
return authRequest;
|
|
772
769
|
});
|
|
773
770
|
}
|
|
774
771
|
async siopGetRequestState(args, context) {
|
|
775
772
|
return await this.getRPInstance({
|
|
776
|
-
|
|
773
|
+
queryId: args.queryId
|
|
777
774
|
}, context).then((rp) => rp.get(context).then((rp2) => rp2.sessionManager.getRequestStateByCorrelationId(args.correlationId, args.errorOnNotFound)));
|
|
778
775
|
}
|
|
779
776
|
async siopGetResponseState(args, context) {
|
|
780
777
|
const rpInstance = await this.getRPInstance({
|
|
781
|
-
|
|
778
|
+
queryId: args.queryId
|
|
782
779
|
}, context);
|
|
783
780
|
const authorizationResponseState = await rpInstance.get(context).then((rp) => rp.sessionManager.getResponseStateByCorrelationId(args.correlationId, args.errorOnNotFound));
|
|
784
781
|
if (authorizationResponseState === void 0) {
|
|
@@ -831,11 +828,11 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
831
828
|
}
|
|
832
829
|
presentationOrClaimsFrom = /* @__PURE__ */ __name((presentationDecoded) => import_ssi_types2.CredentialMapper.isSdJwtDecodedCredential(presentationDecoded) ? presentationDecoded.decodedPayload : import_ssi_types2.CredentialMapper.toUniformPresentation(presentationDecoded), "presentationOrClaimsFrom");
|
|
833
830
|
async siopUpdateRequestState(args, context) {
|
|
834
|
-
if (args.state !== "
|
|
835
|
-
throw Error(`Only '
|
|
831
|
+
if (args.state !== "authorization_request_created") {
|
|
832
|
+
throw Error(`Only 'authorization_request_created' status is supported for this method at this point`);
|
|
836
833
|
}
|
|
837
834
|
return await this.getRPInstance({
|
|
838
|
-
|
|
835
|
+
queryId: args.queryId
|
|
839
836
|
}, context).then((rp) => rp.get(context).then(async (rp2) => {
|
|
840
837
|
await rp2.signalAuthRequestRetrieved({
|
|
841
838
|
correlationId: args.correlationId,
|
|
@@ -846,7 +843,7 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
846
843
|
}
|
|
847
844
|
async siopDeleteState(args, context) {
|
|
848
845
|
return await this.getRPInstance({
|
|
849
|
-
|
|
846
|
+
queryId: args.queryId
|
|
850
847
|
}, context).then((rp) => rp.get(context).then((rp2) => rp2.sessionManager.deleteStateForCorrelationId(args.correlationId))).then(() => true);
|
|
851
848
|
}
|
|
852
849
|
async siopVerifyAuthResponse(args, context) {
|
|
@@ -855,25 +852,38 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
855
852
|
}
|
|
856
853
|
const authResponse = typeof args.authorizationResponse === "string" ? (0, import_did_auth_siop2.decodeUriAsJson)(args.authorizationResponse) : args.authorizationResponse;
|
|
857
854
|
return await this.getRPInstance({
|
|
858
|
-
|
|
855
|
+
queryId: args.queryId
|
|
859
856
|
}, context).then((rp) => rp.get(context).then((rp2) => rp2.verifyAuthorizationResponse(authResponse, {
|
|
860
857
|
correlationId: args.correlationId,
|
|
861
|
-
...args.
|
|
862
|
-
dcqlQuery: args.dcqlQuery
|
|
858
|
+
...args.dcqlQueryPayload ? {
|
|
859
|
+
dcqlQuery: args.dcqlQueryPayload.dcqlQuery
|
|
863
860
|
} : {},
|
|
864
861
|
audience: args.audience
|
|
865
862
|
})));
|
|
866
863
|
}
|
|
867
864
|
async siopImportDefinitions(args, context) {
|
|
868
|
-
const {
|
|
869
|
-
await Promise.all(
|
|
865
|
+
const { queries, tenantId, version, versionControlMode } = args;
|
|
866
|
+
await Promise.all(queries.map(async (definitionPair) => {
|
|
870
867
|
const definitionPayload = definitionPair.definitionPayload;
|
|
871
|
-
|
|
872
|
-
|
|
873
|
-
}
|
|
874
|
-
|
|
868
|
+
if (!definitionPayload && !definitionPair.dcqlPayload) {
|
|
869
|
+
return Promise.reject(Error("Either dcqlPayload or definitionPayload must be suppplied"));
|
|
870
|
+
}
|
|
871
|
+
let definitionId;
|
|
872
|
+
if (definitionPair.dcqlPayload) {
|
|
873
|
+
import_dcql.DcqlQuery.validate(definitionPair.dcqlPayload.dcqlQuery);
|
|
874
|
+
console.log(`persisting DCQL definition ${definitionPair.dcqlPayload.queryId} with versionControlMode ${versionControlMode}`);
|
|
875
|
+
definitionId = definitionPair.dcqlPayload.queryId;
|
|
876
|
+
}
|
|
877
|
+
if (definitionPayload) {
|
|
878
|
+
await context.agent.pexValidateDefinition({
|
|
879
|
+
definition: definitionPayload
|
|
880
|
+
});
|
|
881
|
+
console.log(`persisting PEX definition ${definitionPayload.id} / ${definitionPayload.name} with versionControlMode ${versionControlMode}`);
|
|
882
|
+
definitionId = definitionPayload.id;
|
|
883
|
+
}
|
|
875
884
|
return context.agent.pdmPersistDefinition({
|
|
876
885
|
definitionItem: {
|
|
886
|
+
definitionId,
|
|
877
887
|
tenantId,
|
|
878
888
|
version,
|
|
879
889
|
definitionPayload,
|
|
@@ -886,7 +896,7 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
886
896
|
}));
|
|
887
897
|
}
|
|
888
898
|
async siopGetRedirectURI(args, context) {
|
|
889
|
-
const instanceId = args.
|
|
899
|
+
const instanceId = args.queryId ?? _SIOPv2RP._DEFAULT_OPTS_KEY;
|
|
890
900
|
if (this.instances.has(instanceId)) {
|
|
891
901
|
const rpInstance = this.instances.get(instanceId);
|
|
892
902
|
if (rpInstance !== void 0) {
|
|
@@ -902,12 +912,12 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
902
912
|
}
|
|
903
913
|
return void 0;
|
|
904
914
|
}
|
|
905
|
-
async getRPInstance({
|
|
906
|
-
const instanceId =
|
|
915
|
+
async getRPInstance({ queryId, responseRedirectURI }, context) {
|
|
916
|
+
const instanceId = queryId ?? _SIOPv2RP._DEFAULT_OPTS_KEY;
|
|
907
917
|
if (!this.instances.has(instanceId)) {
|
|
908
|
-
const instanceOpts = this.getInstanceOpts(
|
|
918
|
+
const instanceOpts = this.getInstanceOpts(queryId);
|
|
909
919
|
const rpOpts = await this.getRPOptions(context, {
|
|
910
|
-
|
|
920
|
+
queryId,
|
|
911
921
|
responseRedirectURI
|
|
912
922
|
});
|
|
913
923
|
if (!rpOpts.identifierOpts.resolveOpts?.resolver || typeof rpOpts.identifierOpts.resolveOpts.resolver.resolve !== "function") {
|
|
@@ -919,7 +929,7 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
919
929
|
...rpOpts.identifierOpts.resolveOpts
|
|
920
930
|
};
|
|
921
931
|
}
|
|
922
|
-
console.log("Using agent DID resolver for RP instance with definition id " +
|
|
932
|
+
console.log("Using agent DID resolver for RP instance with definition id " + queryId);
|
|
923
933
|
rpOpts.identifierOpts.resolveOpts.resolver = (0, import_ssi_sdk_ext4.getAgentResolver)(context, {
|
|
924
934
|
uniresolverResolution: true,
|
|
925
935
|
localResolution: true,
|
|
@@ -938,10 +948,10 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
938
948
|
return rpInstance;
|
|
939
949
|
}
|
|
940
950
|
async getRPOptions(context, opts) {
|
|
941
|
-
const {
|
|
942
|
-
const options = this.getInstanceOpts(
|
|
951
|
+
const { queryId, responseRedirectURI } = opts;
|
|
952
|
+
const options = this.getInstanceOpts(queryId)?.rpOpts ?? this.opts.defaultOpts;
|
|
943
953
|
if (!options) {
|
|
944
|
-
throw Error(`Could not get specific nor default options for definition ${
|
|
954
|
+
throw Error(`Could not get specific nor default options for definition ${queryId}`);
|
|
945
955
|
}
|
|
946
956
|
if (this.opts.defaultOpts) {
|
|
947
957
|
if (!options.identifierOpts) {
|
|
@@ -975,18 +985,18 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
975
985
|
}
|
|
976
986
|
getInstanceOpts(definitionId) {
|
|
977
987
|
if (!this.opts.instanceOpts) return void 0;
|
|
978
|
-
const instanceOpt = definitionId ? this.opts.instanceOpts.find((i) => i.
|
|
988
|
+
const instanceOpt = definitionId ? this.opts.instanceOpts.find((i) => i.queryId === definitionId) : void 0;
|
|
979
989
|
return instanceOpt ?? this.getDefaultOptions(definitionId);
|
|
980
990
|
}
|
|
981
991
|
getDefaultOptions(definitionId) {
|
|
982
992
|
if (!this.opts.instanceOpts) return void 0;
|
|
983
|
-
const defaultOptions = this.opts.instanceOpts.find((i) => i.
|
|
993
|
+
const defaultOptions = this.opts.instanceOpts.find((i) => i.queryId === "default");
|
|
984
994
|
if (defaultOptions) {
|
|
985
995
|
const clonedOptions = {
|
|
986
996
|
...defaultOptions
|
|
987
997
|
};
|
|
988
998
|
if (definitionId !== void 0) {
|
|
989
|
-
clonedOptions.
|
|
999
|
+
clonedOptions.queryId = definitionId;
|
|
990
1000
|
}
|
|
991
1001
|
return clonedOptions;
|
|
992
1002
|
}
|
|
@@ -995,12 +1005,12 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
995
1005
|
};
|
|
996
1006
|
|
|
997
1007
|
// src/types/ISIOPv2RP.ts
|
|
998
|
-
var VerifiedDataMode = /* @__PURE__ */ function(VerifiedDataMode2) {
|
|
1008
|
+
var VerifiedDataMode = /* @__PURE__ */ (function(VerifiedDataMode2) {
|
|
999
1009
|
VerifiedDataMode2["NONE"] = "none";
|
|
1000
1010
|
VerifiedDataMode2["VERIFIED_PRESENTATION"] = "vp";
|
|
1001
1011
|
VerifiedDataMode2["CREDENTIAL_SUBJECT_FLATTENED"] = "cs-flat";
|
|
1002
1012
|
return VerifiedDataMode2;
|
|
1003
|
-
}({});
|
|
1013
|
+
})({});
|
|
1004
1014
|
|
|
1005
1015
|
// src/index.ts
|
|
1006
1016
|
var schema = require_plugin_schema();
|