@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth 0.34.1-feature.SSISDK.46.41 → 0.34.1-feature.SSISDK.50.98
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 +50 -41
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +31 -40
- package/dist/index.d.ts +31 -40
- package/dist/index.js +50 -41
- package/dist/index.js.map +1 -1
- package/package.json +19 -19
- package/src/RPInstance.ts +3 -3
- package/src/agent/SIOPv2RP.ts +45 -33
- package/src/functions.ts +2 -2
- package/src/types/ISIOPv2RP.ts +27 -40
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");
|
|
@@ -441,11 +442,11 @@ async function createRPBuilder(args) {
|
|
|
441
442
|
const { identifierOpts } = rpOpts;
|
|
442
443
|
let definition = args.definition;
|
|
443
444
|
let dcqlQuery = args.dcql;
|
|
444
|
-
if (!definition && pexOpts && pexOpts.
|
|
445
|
+
if (!definition && pexOpts && pexOpts.definitionId) {
|
|
445
446
|
const presentationDefinitionItems = await context.agent.pdmGetDefinitions({
|
|
446
447
|
filter: [
|
|
447
448
|
{
|
|
448
|
-
definitionId: pexOpts.
|
|
449
|
+
definitionId: pexOpts.definitionId,
|
|
449
450
|
version: pexOpts.version,
|
|
450
451
|
tenantId: pexOpts.tenantId
|
|
451
452
|
}
|
|
@@ -633,7 +634,7 @@ var RPInstance = class {
|
|
|
633
634
|
return this.definitionId !== void 0;
|
|
634
635
|
}
|
|
635
636
|
get definitionId() {
|
|
636
|
-
return this.pexOptions?.
|
|
637
|
+
return this.pexOptions?.definitionId;
|
|
637
638
|
}
|
|
638
639
|
async getPresentationDefinition(context) {
|
|
639
640
|
return this.definitionId ? await context.agent.pexStoreGetDefinition({
|
|
@@ -755,32 +756,30 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
755
756
|
}
|
|
756
757
|
async createAuthorizationRequestURI(createArgs, context) {
|
|
757
758
|
return await this.getRPInstance({
|
|
758
|
-
|
|
759
|
-
|
|
760
|
-
queryId: createArgs.queryId
|
|
761
|
-
}
|
|
759
|
+
definitionId: createArgs.definitionId,
|
|
760
|
+
responseRedirectURI: createArgs.responseRedirectURI
|
|
762
761
|
}, context).then((rp) => rp.createAuthorizationRequestURI(createArgs, context)).then((URI) => URI.encodedUri);
|
|
763
762
|
}
|
|
764
763
|
async createAuthorizationRequestPayloads(createArgs, context) {
|
|
765
764
|
return await this.getRPInstance({
|
|
766
|
-
|
|
765
|
+
definitionId: createArgs.definitionId
|
|
767
766
|
}, context).then((rp) => rp.createAuthorizationRequest(createArgs, context)).then(async (request) => {
|
|
768
767
|
const authRequest = {
|
|
769
768
|
authorizationRequest: request.payload,
|
|
770
769
|
requestObject: await request.requestObjectJwt(),
|
|
771
|
-
requestObjectDecoded: request.requestObject?.getPayload()
|
|
770
|
+
requestObjectDecoded: await request.requestObject?.getPayload()
|
|
772
771
|
};
|
|
773
772
|
return authRequest;
|
|
774
773
|
});
|
|
775
774
|
}
|
|
776
775
|
async siopGetRequestState(args, context) {
|
|
777
776
|
return await this.getRPInstance({
|
|
778
|
-
|
|
777
|
+
definitionId: args.definitionId
|
|
779
778
|
}, context).then((rp) => rp.get(context).then((rp2) => rp2.sessionManager.getRequestStateByCorrelationId(args.correlationId, args.errorOnNotFound)));
|
|
780
779
|
}
|
|
781
780
|
async siopGetResponseState(args, context) {
|
|
782
781
|
const rpInstance = await this.getRPInstance({
|
|
783
|
-
|
|
782
|
+
definitionId: args.definitionId
|
|
784
783
|
}, context);
|
|
785
784
|
const authorizationResponseState = await rpInstance.get(context).then((rp) => rp.sessionManager.getResponseStateByCorrelationId(args.correlationId, args.errorOnNotFound));
|
|
786
785
|
if (authorizationResponseState === void 0) {
|
|
@@ -833,11 +832,11 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
833
832
|
}
|
|
834
833
|
presentationOrClaimsFrom = /* @__PURE__ */ __name((presentationDecoded) => import_ssi_types2.CredentialMapper.isSdJwtDecodedCredential(presentationDecoded) ? presentationDecoded.decodedPayload : import_ssi_types2.CredentialMapper.toUniformPresentation(presentationDecoded), "presentationOrClaimsFrom");
|
|
835
834
|
async siopUpdateRequestState(args, context) {
|
|
836
|
-
if (args.state !== "
|
|
837
|
-
throw Error(`Only '
|
|
835
|
+
if (args.state !== "sent") {
|
|
836
|
+
throw Error(`Only 'sent' status is supported for this method at this point`);
|
|
838
837
|
}
|
|
839
838
|
return await this.getRPInstance({
|
|
840
|
-
|
|
839
|
+
definitionId: args.definitionId
|
|
841
840
|
}, context).then((rp) => rp.get(context).then(async (rp2) => {
|
|
842
841
|
await rp2.signalAuthRequestRetrieved({
|
|
843
842
|
correlationId: args.correlationId,
|
|
@@ -848,7 +847,7 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
848
847
|
}
|
|
849
848
|
async siopDeleteState(args, context) {
|
|
850
849
|
return await this.getRPInstance({
|
|
851
|
-
|
|
850
|
+
definitionId: args.definitionId
|
|
852
851
|
}, context).then((rp) => rp.get(context).then((rp2) => rp2.sessionManager.deleteStateForCorrelationId(args.correlationId))).then(() => true);
|
|
853
852
|
}
|
|
854
853
|
async siopVerifyAuthResponse(args, context) {
|
|
@@ -857,28 +856,38 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
857
856
|
}
|
|
858
857
|
const authResponse = typeof args.authorizationResponse === "string" ? (0, import_did_auth_siop2.decodeUriAsJson)(args.authorizationResponse) : args.authorizationResponse;
|
|
859
858
|
return await this.getRPInstance({
|
|
860
|
-
|
|
859
|
+
definitionId: args.definitionId
|
|
861
860
|
}, context).then((rp) => rp.get(context).then((rp2) => rp2.verifyAuthorizationResponse(authResponse, {
|
|
862
861
|
correlationId: args.correlationId,
|
|
863
|
-
...args.
|
|
864
|
-
|
|
865
|
-
} : {},
|
|
866
|
-
...args.dcqlQuery ? {
|
|
867
|
-
dcqlQuery: args.dcqlQuery
|
|
862
|
+
...args.dcqlQueryPayload ? {
|
|
863
|
+
dcqlQuery: args.dcqlQueryPayload.dcqlQuery
|
|
868
864
|
} : {},
|
|
869
865
|
audience: args.audience
|
|
870
866
|
})));
|
|
871
867
|
}
|
|
872
868
|
async siopImportDefinitions(args, context) {
|
|
873
|
-
const {
|
|
874
|
-
await Promise.all(
|
|
869
|
+
const { definitions, tenantId, version, versionControlMode } = args;
|
|
870
|
+
await Promise.all(definitions.map(async (definitionPair) => {
|
|
875
871
|
const definitionPayload = definitionPair.definitionPayload;
|
|
876
|
-
|
|
877
|
-
|
|
878
|
-
}
|
|
879
|
-
|
|
872
|
+
if (!definitionPayload && !definitionPair.dcqlPayload) {
|
|
873
|
+
return Promise.reject(Error("Either dcqlPayload or definitionPayload must be suppplied"));
|
|
874
|
+
}
|
|
875
|
+
let definitionId;
|
|
876
|
+
if (definitionPair.dcqlPayload) {
|
|
877
|
+
import_dcql.DcqlQuery.validate(definitionPair.dcqlPayload.dcqlQuery);
|
|
878
|
+
console.log(`persisting DCQL definition ${definitionPair.dcqlPayload.queryId} with versionControlMode ${versionControlMode}`);
|
|
879
|
+
definitionId = definitionPair.dcqlPayload.queryId;
|
|
880
|
+
}
|
|
881
|
+
if (definitionPayload) {
|
|
882
|
+
await context.agent.pexValidateDefinition({
|
|
883
|
+
definition: definitionPayload
|
|
884
|
+
});
|
|
885
|
+
console.log(`persisting PEX definition ${definitionPayload.id} / ${definitionPayload.name} with versionControlMode ${versionControlMode}`);
|
|
886
|
+
definitionId = definitionPayload.id;
|
|
887
|
+
}
|
|
880
888
|
return context.agent.pdmPersistDefinition({
|
|
881
889
|
definitionItem: {
|
|
890
|
+
definitionId,
|
|
882
891
|
tenantId,
|
|
883
892
|
version,
|
|
884
893
|
definitionPayload,
|
|
@@ -891,7 +900,7 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
891
900
|
}));
|
|
892
901
|
}
|
|
893
902
|
async siopGetRedirectURI(args, context) {
|
|
894
|
-
const instanceId = args.
|
|
903
|
+
const instanceId = args.definitionId ?? _SIOPv2RP._DEFAULT_OPTS_KEY;
|
|
895
904
|
if (this.instances.has(instanceId)) {
|
|
896
905
|
const rpInstance = this.instances.get(instanceId);
|
|
897
906
|
if (rpInstance !== void 0) {
|
|
@@ -907,12 +916,12 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
907
916
|
}
|
|
908
917
|
return void 0;
|
|
909
918
|
}
|
|
910
|
-
async getRPInstance({
|
|
911
|
-
const instanceId =
|
|
919
|
+
async getRPInstance({ definitionId, responseRedirectURI }, context) {
|
|
920
|
+
const instanceId = definitionId ?? _SIOPv2RP._DEFAULT_OPTS_KEY;
|
|
912
921
|
if (!this.instances.has(instanceId)) {
|
|
913
|
-
const instanceOpts = this.getInstanceOpts(
|
|
922
|
+
const instanceOpts = this.getInstanceOpts(definitionId);
|
|
914
923
|
const rpOpts = await this.getRPOptions(context, {
|
|
915
|
-
|
|
924
|
+
definitionId,
|
|
916
925
|
responseRedirectURI
|
|
917
926
|
});
|
|
918
927
|
if (!rpOpts.identifierOpts.resolveOpts?.resolver || typeof rpOpts.identifierOpts.resolveOpts.resolver.resolve !== "function") {
|
|
@@ -924,7 +933,7 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
924
933
|
...rpOpts.identifierOpts.resolveOpts
|
|
925
934
|
};
|
|
926
935
|
}
|
|
927
|
-
console.log("Using agent DID resolver for RP instance with definition id " +
|
|
936
|
+
console.log("Using agent DID resolver for RP instance with definition id " + definitionId);
|
|
928
937
|
rpOpts.identifierOpts.resolveOpts.resolver = (0, import_ssi_sdk_ext4.getAgentResolver)(context, {
|
|
929
938
|
uniresolverResolution: true,
|
|
930
939
|
localResolution: true,
|
|
@@ -943,10 +952,10 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
943
952
|
return rpInstance;
|
|
944
953
|
}
|
|
945
954
|
async getRPOptions(context, opts) {
|
|
946
|
-
const {
|
|
947
|
-
const options = this.getInstanceOpts(
|
|
955
|
+
const { definitionId, responseRedirectURI } = opts;
|
|
956
|
+
const options = this.getInstanceOpts(definitionId)?.rpOpts ?? this.opts.defaultOpts;
|
|
948
957
|
if (!options) {
|
|
949
|
-
throw Error(`Could not get specific nor default options for definition ${
|
|
958
|
+
throw Error(`Could not get specific nor default options for definition ${definitionId}`);
|
|
950
959
|
}
|
|
951
960
|
if (this.opts.defaultOpts) {
|
|
952
961
|
if (!options.identifierOpts) {
|
|
@@ -980,18 +989,18 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
980
989
|
}
|
|
981
990
|
getInstanceOpts(definitionId) {
|
|
982
991
|
if (!this.opts.instanceOpts) return void 0;
|
|
983
|
-
const instanceOpt = definitionId ? this.opts.instanceOpts.find((i) => i.
|
|
992
|
+
const instanceOpt = definitionId ? this.opts.instanceOpts.find((i) => i.definitionId === definitionId) : void 0;
|
|
984
993
|
return instanceOpt ?? this.getDefaultOptions(definitionId);
|
|
985
994
|
}
|
|
986
995
|
getDefaultOptions(definitionId) {
|
|
987
996
|
if (!this.opts.instanceOpts) return void 0;
|
|
988
|
-
const defaultOptions = this.opts.instanceOpts.find((i) => i.
|
|
997
|
+
const defaultOptions = this.opts.instanceOpts.find((i) => i.definitionId === "default");
|
|
989
998
|
if (defaultOptions) {
|
|
990
999
|
const clonedOptions = {
|
|
991
1000
|
...defaultOptions
|
|
992
1001
|
};
|
|
993
1002
|
if (definitionId !== void 0) {
|
|
994
|
-
clonedOptions.
|
|
1003
|
+
clonedOptions.definitionId = definitionId;
|
|
995
1004
|
}
|
|
996
1005
|
return clonedOptions;
|
|
997
1006
|
}
|
|
@@ -1000,12 +1009,12 @@ var SIOPv2RP = class _SIOPv2RP {
|
|
|
1000
1009
|
};
|
|
1001
1010
|
|
|
1002
1011
|
// src/types/ISIOPv2RP.ts
|
|
1003
|
-
var VerifiedDataMode = /* @__PURE__ */
|
|
1012
|
+
var VerifiedDataMode = /* @__PURE__ */ function(VerifiedDataMode2) {
|
|
1004
1013
|
VerifiedDataMode2["NONE"] = "none";
|
|
1005
1014
|
VerifiedDataMode2["VERIFIED_PRESENTATION"] = "vp";
|
|
1006
1015
|
VerifiedDataMode2["CREDENTIAL_SUBJECT_FLATTENED"] = "cs-flat";
|
|
1007
1016
|
return VerifiedDataMode2;
|
|
1008
|
-
}
|
|
1017
|
+
}({});
|
|
1009
1018
|
|
|
1010
1019
|
// src/index.ts
|
|
1011
1020
|
var schema = require_plugin_schema();
|