@sphereon/ssi-sdk.siopv2-oid4vp-rp-auth 0.34.1-feature.DIIPv4.142 → 0.34.1-feature.DIIPv4.152

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.d.cts CHANGED
@@ -41,8 +41,9 @@ interface ISiopv2RPOpts {
41
41
  interface IRPDefaultOpts extends IRPOptions {
42
42
  }
43
43
  interface ICreateAuthRequestArgs {
44
- definitionId: string;
44
+ queryId: string;
45
45
  correlationId: string;
46
+ useQueryIdInstance?: boolean;
46
47
  responseURIType: ResponseURIType;
47
48
  responseURI: string;
48
49
  responseRedirectURI?: string;
@@ -54,29 +55,29 @@ interface ICreateAuthRequestArgs {
54
55
  }
55
56
  interface IGetAuthRequestStateArgs {
56
57
  correlationId: string;
57
- definitionId: string;
58
+ queryId?: string;
58
59
  errorOnNotFound?: boolean;
59
60
  }
60
61
  interface IGetAuthResponseStateArgs {
61
62
  correlationId: string;
62
- definitionId: string;
63
+ queryId?: string;
63
64
  errorOnNotFound?: boolean;
64
65
  progressRequestStateTo?: AuthorizationRequestStateStatus;
65
66
  includeVerifiedData?: VerifiedDataMode;
66
67
  }
67
68
  interface IUpdateRequestStateArgs {
68
- definitionId: string;
69
+ queryId: string;
69
70
  correlationId: string;
70
71
  state: AuthorizationRequestStateStatus;
71
72
  error?: string;
72
73
  }
73
74
  interface IDeleteAuthStateArgs {
74
75
  correlationId: string;
75
- definitionId: string;
76
+ queryId?: string;
76
77
  }
77
78
  interface IVerifyAuthResponseStateArgs {
78
79
  authorizationResponse: string | AuthorizationResponsePayload;
79
- definitionId?: string;
80
+ queryId?: string;
80
81
  correlationId: string;
81
82
  audience?: string;
82
83
  dcqlQueryPayload?: DcqlQueryPayload;
@@ -86,14 +87,14 @@ interface IDefinitionPair {
86
87
  dcqlPayload?: DcqlQueryPayload;
87
88
  }
88
89
  interface ImportDefinitionsArgs {
89
- definitions: Array<IDefinitionPair>;
90
+ queries: Array<IDefinitionPair>;
90
91
  tenantId?: string;
91
92
  version?: string;
92
93
  versionControlMode?: VersionControlMode;
93
94
  }
94
95
  interface IGetRedirectUriArgs {
95
96
  correlationId: string;
96
- definitionId?: string;
97
+ queryId?: string;
97
98
  state?: string;
98
99
  }
99
100
  interface IAuthorizationRequestPayloads {
@@ -106,7 +107,7 @@ interface IPEXDefinitionPersistArgs extends IPEXInstanceOptions {
106
107
  ttl?: number;
107
108
  }
108
109
  interface ISiopRPInstanceArgs {
109
- definitionId?: string;
110
+ queryId?: string;
110
111
  responseRedirectURI?: string;
111
112
  }
112
113
  interface IPEXInstanceOptions extends IPEXOptions {
@@ -127,7 +128,7 @@ interface IRPOptions {
127
128
  }
128
129
  interface IPEXOptions {
129
130
  presentationVerifyCallback?: PresentationVerificationCallback;
130
- definitionId: string;
131
+ queryId: string;
131
132
  version?: string;
132
133
  tenantId?: string;
133
134
  }
@@ -171,8 +172,8 @@ declare class RPInstance {
171
172
  hasDefinition(): boolean;
172
173
  get definitionId(): string | undefined;
173
174
  getPresentationDefinition(context: IRequiredContext): Promise<IPresentationDefinition | undefined>;
174
- createAuthorizationRequestURI(createArgs: Omit<ICreateAuthRequestArgs, 'definitionId'>, context: IRequiredContext): Promise<URI>;
175
- createAuthorizationRequest(createArgs: Omit<ICreateAuthRequestArgs, 'definitionId'>, context: IRequiredContext): Promise<AuthorizationRequest>;
175
+ createAuthorizationRequestURI(createArgs: ICreateAuthRequestArgs, context: IRequiredContext): Promise<URI>;
176
+ createAuthorizationRequest(createArgs: Omit<ICreateAuthRequestArgs, 'queryId'>, context: IRequiredContext): Promise<AuthorizationRequest>;
176
177
  }
177
178
 
178
179
  declare class SIOPv2RP implements IAgentPlugin {
@@ -193,9 +194,9 @@ declare class SIOPv2RP implements IAgentPlugin {
193
194
  private siopVerifyAuthResponse;
194
195
  private siopImportDefinitions;
195
196
  private siopGetRedirectURI;
196
- getRPInstance({ definitionId, responseRedirectURI }: ISiopRPInstanceArgs, context: IRequiredContext): Promise<RPInstance>;
197
+ getRPInstance({ queryId, responseRedirectURI }: ISiopRPInstanceArgs, context: IRequiredContext): Promise<RPInstance>;
197
198
  getRPOptions(context: IRequiredContext, opts: {
198
- definitionId?: string;
199
+ queryId?: string;
199
200
  responseRedirectURI?: string;
200
201
  }): Promise<IRPOptions>;
201
202
  getInstanceOpts(definitionId?: string): IPEXInstanceOptions | undefined;
package/dist/index.d.ts CHANGED
@@ -41,8 +41,9 @@ interface ISiopv2RPOpts {
41
41
  interface IRPDefaultOpts extends IRPOptions {
42
42
  }
43
43
  interface ICreateAuthRequestArgs {
44
- definitionId: string;
44
+ queryId: string;
45
45
  correlationId: string;
46
+ useQueryIdInstance?: boolean;
46
47
  responseURIType: ResponseURIType;
47
48
  responseURI: string;
48
49
  responseRedirectURI?: string;
@@ -54,29 +55,29 @@ interface ICreateAuthRequestArgs {
54
55
  }
55
56
  interface IGetAuthRequestStateArgs {
56
57
  correlationId: string;
57
- definitionId: string;
58
+ queryId?: string;
58
59
  errorOnNotFound?: boolean;
59
60
  }
60
61
  interface IGetAuthResponseStateArgs {
61
62
  correlationId: string;
62
- definitionId: string;
63
+ queryId?: string;
63
64
  errorOnNotFound?: boolean;
64
65
  progressRequestStateTo?: AuthorizationRequestStateStatus;
65
66
  includeVerifiedData?: VerifiedDataMode;
66
67
  }
67
68
  interface IUpdateRequestStateArgs {
68
- definitionId: string;
69
+ queryId: string;
69
70
  correlationId: string;
70
71
  state: AuthorizationRequestStateStatus;
71
72
  error?: string;
72
73
  }
73
74
  interface IDeleteAuthStateArgs {
74
75
  correlationId: string;
75
- definitionId: string;
76
+ queryId?: string;
76
77
  }
77
78
  interface IVerifyAuthResponseStateArgs {
78
79
  authorizationResponse: string | AuthorizationResponsePayload;
79
- definitionId?: string;
80
+ queryId?: string;
80
81
  correlationId: string;
81
82
  audience?: string;
82
83
  dcqlQueryPayload?: DcqlQueryPayload;
@@ -86,14 +87,14 @@ interface IDefinitionPair {
86
87
  dcqlPayload?: DcqlQueryPayload;
87
88
  }
88
89
  interface ImportDefinitionsArgs {
89
- definitions: Array<IDefinitionPair>;
90
+ queries: Array<IDefinitionPair>;
90
91
  tenantId?: string;
91
92
  version?: string;
92
93
  versionControlMode?: VersionControlMode;
93
94
  }
94
95
  interface IGetRedirectUriArgs {
95
96
  correlationId: string;
96
- definitionId?: string;
97
+ queryId?: string;
97
98
  state?: string;
98
99
  }
99
100
  interface IAuthorizationRequestPayloads {
@@ -106,7 +107,7 @@ interface IPEXDefinitionPersistArgs extends IPEXInstanceOptions {
106
107
  ttl?: number;
107
108
  }
108
109
  interface ISiopRPInstanceArgs {
109
- definitionId?: string;
110
+ queryId?: string;
110
111
  responseRedirectURI?: string;
111
112
  }
112
113
  interface IPEXInstanceOptions extends IPEXOptions {
@@ -127,7 +128,7 @@ interface IRPOptions {
127
128
  }
128
129
  interface IPEXOptions {
129
130
  presentationVerifyCallback?: PresentationVerificationCallback;
130
- definitionId: string;
131
+ queryId: string;
131
132
  version?: string;
132
133
  tenantId?: string;
133
134
  }
@@ -171,8 +172,8 @@ declare class RPInstance {
171
172
  hasDefinition(): boolean;
172
173
  get definitionId(): string | undefined;
173
174
  getPresentationDefinition(context: IRequiredContext): Promise<IPresentationDefinition | undefined>;
174
- createAuthorizationRequestURI(createArgs: Omit<ICreateAuthRequestArgs, 'definitionId'>, context: IRequiredContext): Promise<URI>;
175
- createAuthorizationRequest(createArgs: Omit<ICreateAuthRequestArgs, 'definitionId'>, context: IRequiredContext): Promise<AuthorizationRequest>;
175
+ createAuthorizationRequestURI(createArgs: ICreateAuthRequestArgs, context: IRequiredContext): Promise<URI>;
176
+ createAuthorizationRequest(createArgs: Omit<ICreateAuthRequestArgs, 'queryId'>, context: IRequiredContext): Promise<AuthorizationRequest>;
176
177
  }
177
178
 
178
179
  declare class SIOPv2RP implements IAgentPlugin {
@@ -193,9 +194,9 @@ declare class SIOPv2RP implements IAgentPlugin {
193
194
  private siopVerifyAuthResponse;
194
195
  private siopImportDefinitions;
195
196
  private siopGetRedirectURI;
196
- getRPInstance({ definitionId, responseRedirectURI }: ISiopRPInstanceArgs, context: IRequiredContext): Promise<RPInstance>;
197
+ getRPInstance({ queryId, responseRedirectURI }: ISiopRPInstanceArgs, context: IRequiredContext): Promise<RPInstance>;
197
198
  getRPOptions(context: IRequiredContext, opts: {
198
- definitionId?: string;
199
+ queryId?: string;
199
200
  responseRedirectURI?: string;
200
201
  }): Promise<IRPOptions>;
201
202
  getInstanceOpts(definitionId?: string): IPEXInstanceOptions | undefined;
package/dist/index.js CHANGED
@@ -416,11 +416,11 @@ async function createRPBuilder(args) {
416
416
  const { identifierOpts } = rpOpts;
417
417
  let definition = args.definition;
418
418
  let dcqlQuery = args.dcql;
419
- if (!definition && pexOpts && pexOpts.definitionId) {
419
+ if (!definition && pexOpts && pexOpts.queryId) {
420
420
  const presentationDefinitionItems = await context.agent.pdmGetDefinitions({
421
421
  filter: [
422
422
  {
423
- definitionId: pexOpts.definitionId,
423
+ definitionId: pexOpts.queryId,
424
424
  version: pexOpts.version,
425
425
  tenantId: pexOpts.tenantId
426
426
  }
@@ -602,7 +602,7 @@ var RPInstance = class {
602
602
  return this.definitionId !== void 0;
603
603
  }
604
604
  get definitionId() {
605
- return this.pexOptions?.definitionId;
605
+ return this.pexOptions?.queryId;
606
606
  }
607
607
  async getPresentationDefinition(context) {
608
608
  return this.definitionId ? await context.agent.pexStoreGetDefinition({
@@ -611,7 +611,7 @@ var RPInstance = class {
611
611
  }) : void 0;
612
612
  }
613
613
  async createAuthorizationRequestURI(createArgs, context) {
614
- const { correlationId, claims, requestByReferenceURI, responseURI, responseURIType } = createArgs;
614
+ const { correlationId, queryId, claims, requestByReferenceURI, responseURI, responseURIType } = createArgs;
615
615
  const nonce = createArgs.nonce ?? uuidv4();
616
616
  const state = createArgs.state ?? correlationId;
617
617
  let jwtIssuer;
@@ -639,6 +639,7 @@ var RPInstance = class {
639
639
  return await this.get(context).then((rp) => rp.createAuthorizationRequestURI({
640
640
  version: getRequestVersion(this.rpOptions),
641
641
  correlationId,
642
+ queryId,
642
643
  nonce,
643
644
  state,
644
645
  claims,
@@ -724,30 +725,32 @@ var SIOPv2RP = class _SIOPv2RP {
724
725
  }
725
726
  async createAuthorizationRequestURI(createArgs, context) {
726
727
  return await this.getRPInstance({
727
- definitionId: createArgs.definitionId,
728
- responseRedirectURI: createArgs.responseRedirectURI
728
+ responseRedirectURI: createArgs.responseRedirectURI,
729
+ ...createArgs.useQueryIdInstance === true && {
730
+ queryId: createArgs.queryId
731
+ }
729
732
  }, context).then((rp) => rp.createAuthorizationRequestURI(createArgs, context)).then((URI) => URI.encodedUri);
730
733
  }
731
734
  async createAuthorizationRequestPayloads(createArgs, context) {
732
735
  return await this.getRPInstance({
733
- definitionId: createArgs.definitionId
736
+ queryId: createArgs.queryId
734
737
  }, context).then((rp) => rp.createAuthorizationRequest(createArgs, context)).then(async (request) => {
735
738
  const authRequest = {
736
739
  authorizationRequest: request.payload,
737
740
  requestObject: await request.requestObjectJwt(),
738
- requestObjectDecoded: await request.requestObject?.getPayload()
741
+ requestObjectDecoded: request.requestObject?.getPayload()
739
742
  };
740
743
  return authRequest;
741
744
  });
742
745
  }
743
746
  async siopGetRequestState(args, context) {
744
747
  return await this.getRPInstance({
745
- definitionId: args.definitionId
748
+ queryId: args.queryId
746
749
  }, context).then((rp) => rp.get(context).then((rp2) => rp2.sessionManager.getRequestStateByCorrelationId(args.correlationId, args.errorOnNotFound)));
747
750
  }
748
751
  async siopGetResponseState(args, context) {
749
752
  const rpInstance = await this.getRPInstance({
750
- definitionId: args.definitionId
753
+ queryId: args.queryId
751
754
  }, context);
752
755
  const authorizationResponseState = await rpInstance.get(context).then((rp) => rp.sessionManager.getResponseStateByCorrelationId(args.correlationId, args.errorOnNotFound));
753
756
  if (authorizationResponseState === void 0) {
@@ -800,11 +803,11 @@ var SIOPv2RP = class _SIOPv2RP {
800
803
  }
801
804
  presentationOrClaimsFrom = /* @__PURE__ */ __name((presentationDecoded) => CredentialMapper2.isSdJwtDecodedCredential(presentationDecoded) ? presentationDecoded.decodedPayload : CredentialMapper2.toUniformPresentation(presentationDecoded), "presentationOrClaimsFrom");
802
805
  async siopUpdateRequestState(args, context) {
803
- if (args.state !== "sent") {
804
- throw Error(`Only 'sent' status is supported for this method at this point`);
806
+ if (args.state !== "authorization_request_created") {
807
+ throw Error(`Only 'authorization_request_created' status is supported for this method at this point`);
805
808
  }
806
809
  return await this.getRPInstance({
807
- definitionId: args.definitionId
810
+ queryId: args.queryId
808
811
  }, context).then((rp) => rp.get(context).then(async (rp2) => {
809
812
  await rp2.signalAuthRequestRetrieved({
810
813
  correlationId: args.correlationId,
@@ -815,7 +818,7 @@ var SIOPv2RP = class _SIOPv2RP {
815
818
  }
816
819
  async siopDeleteState(args, context) {
817
820
  return await this.getRPInstance({
818
- definitionId: args.definitionId
821
+ queryId: args.queryId
819
822
  }, context).then((rp) => rp.get(context).then((rp2) => rp2.sessionManager.deleteStateForCorrelationId(args.correlationId))).then(() => true);
820
823
  }
821
824
  async siopVerifyAuthResponse(args, context) {
@@ -824,7 +827,7 @@ var SIOPv2RP = class _SIOPv2RP {
824
827
  }
825
828
  const authResponse = typeof args.authorizationResponse === "string" ? decodeUriAsJson(args.authorizationResponse) : args.authorizationResponse;
826
829
  return await this.getRPInstance({
827
- definitionId: args.definitionId
830
+ queryId: args.queryId
828
831
  }, context).then((rp) => rp.get(context).then((rp2) => rp2.verifyAuthorizationResponse(authResponse, {
829
832
  correlationId: args.correlationId,
830
833
  ...args.dcqlQueryPayload ? {
@@ -834,8 +837,8 @@ var SIOPv2RP = class _SIOPv2RP {
834
837
  })));
835
838
  }
836
839
  async siopImportDefinitions(args, context) {
837
- const { definitions, tenantId, version, versionControlMode } = args;
838
- await Promise.all(definitions.map(async (definitionPair) => {
840
+ const { queries, tenantId, version, versionControlMode } = args;
841
+ await Promise.all(queries.map(async (definitionPair) => {
839
842
  const definitionPayload = definitionPair.definitionPayload;
840
843
  if (!definitionPayload && !definitionPair.dcqlPayload) {
841
844
  return Promise.reject(Error("Either dcqlPayload or definitionPayload must be suppplied"));
@@ -868,7 +871,7 @@ var SIOPv2RP = class _SIOPv2RP {
868
871
  }));
869
872
  }
870
873
  async siopGetRedirectURI(args, context) {
871
- const instanceId = args.definitionId ?? _SIOPv2RP._DEFAULT_OPTS_KEY;
874
+ const instanceId = args.queryId ?? _SIOPv2RP._DEFAULT_OPTS_KEY;
872
875
  if (this.instances.has(instanceId)) {
873
876
  const rpInstance = this.instances.get(instanceId);
874
877
  if (rpInstance !== void 0) {
@@ -884,12 +887,12 @@ var SIOPv2RP = class _SIOPv2RP {
884
887
  }
885
888
  return void 0;
886
889
  }
887
- async getRPInstance({ definitionId, responseRedirectURI }, context) {
888
- const instanceId = definitionId ?? _SIOPv2RP._DEFAULT_OPTS_KEY;
890
+ async getRPInstance({ queryId, responseRedirectURI }, context) {
891
+ const instanceId = queryId ?? _SIOPv2RP._DEFAULT_OPTS_KEY;
889
892
  if (!this.instances.has(instanceId)) {
890
- const instanceOpts = this.getInstanceOpts(definitionId);
893
+ const instanceOpts = this.getInstanceOpts(queryId);
891
894
  const rpOpts = await this.getRPOptions(context, {
892
- definitionId,
895
+ queryId,
893
896
  responseRedirectURI
894
897
  });
895
898
  if (!rpOpts.identifierOpts.resolveOpts?.resolver || typeof rpOpts.identifierOpts.resolveOpts.resolver.resolve !== "function") {
@@ -901,7 +904,7 @@ var SIOPv2RP = class _SIOPv2RP {
901
904
  ...rpOpts.identifierOpts.resolveOpts
902
905
  };
903
906
  }
904
- console.log("Using agent DID resolver for RP instance with definition id " + definitionId);
907
+ console.log("Using agent DID resolver for RP instance with definition id " + queryId);
905
908
  rpOpts.identifierOpts.resolveOpts.resolver = getAgentResolver2(context, {
906
909
  uniresolverResolution: true,
907
910
  localResolution: true,
@@ -920,10 +923,10 @@ var SIOPv2RP = class _SIOPv2RP {
920
923
  return rpInstance;
921
924
  }
922
925
  async getRPOptions(context, opts) {
923
- const { definitionId, responseRedirectURI } = opts;
924
- const options = this.getInstanceOpts(definitionId)?.rpOpts ?? this.opts.defaultOpts;
926
+ const { queryId, responseRedirectURI } = opts;
927
+ const options = this.getInstanceOpts(queryId)?.rpOpts ?? this.opts.defaultOpts;
925
928
  if (!options) {
926
- throw Error(`Could not get specific nor default options for definition ${definitionId}`);
929
+ throw Error(`Could not get specific nor default options for definition ${queryId}`);
927
930
  }
928
931
  if (this.opts.defaultOpts) {
929
932
  if (!options.identifierOpts) {
@@ -957,18 +960,18 @@ var SIOPv2RP = class _SIOPv2RP {
957
960
  }
958
961
  getInstanceOpts(definitionId) {
959
962
  if (!this.opts.instanceOpts) return void 0;
960
- const instanceOpt = definitionId ? this.opts.instanceOpts.find((i) => i.definitionId === definitionId) : void 0;
963
+ const instanceOpt = definitionId ? this.opts.instanceOpts.find((i) => i.queryId === definitionId) : void 0;
961
964
  return instanceOpt ?? this.getDefaultOptions(definitionId);
962
965
  }
963
966
  getDefaultOptions(definitionId) {
964
967
  if (!this.opts.instanceOpts) return void 0;
965
- const defaultOptions = this.opts.instanceOpts.find((i) => i.definitionId === "default");
968
+ const defaultOptions = this.opts.instanceOpts.find((i) => i.queryId === "default");
966
969
  if (defaultOptions) {
967
970
  const clonedOptions = {
968
971
  ...defaultOptions
969
972
  };
970
973
  if (definitionId !== void 0) {
971
- clonedOptions.definitionId = definitionId;
974
+ clonedOptions.queryId = definitionId;
972
975
  }
973
976
  return clonedOptions;
974
977
  }