@sphereon/ssi-sdk.siopv2-oid4vp-rp-rest-client 0.34.1-fix.182 → 0.34.1-fix.223
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 +11 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +6 -12
- package/dist/index.d.ts +6 -12
- package/dist/index.js +11 -26
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/agent/SIOPv2OID4VPRPRestClient.ts +17 -28
- package/src/types/ISIOPv2OID4VPRPRestClient.ts +4 -9
package/dist/index.cjs
CHANGED
|
@@ -26,8 +26,9 @@ __export(index_exports, {
|
|
|
26
26
|
module.exports = __toCommonJS(index_exports);
|
|
27
27
|
|
|
28
28
|
// src/agent/SIOPv2OID4VPRPRestClient.ts
|
|
29
|
-
var
|
|
29
|
+
var import_ssi_sdk = require("@sphereon/ssi-sdk.siopv2-oid4vp-common");
|
|
30
30
|
var import_ssi_types = require("@sphereon/ssi-types");
|
|
31
|
+
var import_cross_fetch = require("cross-fetch");
|
|
31
32
|
var logger = import_ssi_types.Loggers.DEFAULT.get("sphereon:ssi-sdk-siopv2-oid4vp-rp-rest-client");
|
|
32
33
|
var SIOPv2OID4VPRPRestClient = class {
|
|
33
34
|
static {
|
|
@@ -39,11 +40,9 @@ var SIOPv2OID4VPRPRestClient = class {
|
|
|
39
40
|
siopClientGetAuthStatus: this.siopClientGetAuthStatus.bind(this)
|
|
40
41
|
};
|
|
41
42
|
baseUrl;
|
|
42
|
-
definitionId;
|
|
43
43
|
authOpts;
|
|
44
44
|
constructor(args) {
|
|
45
45
|
this.baseUrl = args?.baseUrl;
|
|
46
|
-
this.definitionId = args?.definitionId;
|
|
47
46
|
this.authOpts = args?.authentication;
|
|
48
47
|
}
|
|
49
48
|
async createHeaders(existing) {
|
|
@@ -61,8 +60,7 @@ var SIOPv2OID4VPRPRestClient = class {
|
|
|
61
60
|
}
|
|
62
61
|
async siopClientRemoveAuthRequestState(args) {
|
|
63
62
|
const baseUrl = this.checkBaseUrlParameter(args.baseUrl);
|
|
64
|
-
|
|
65
|
-
await (0, import_cross_fetch.fetch)(this.uriWithBase(`/webapp/definitions/${definitionId}/auth-requests/${args.correlationId}`, baseUrl), {
|
|
63
|
+
await (0, import_cross_fetch.fetch)(this.uriWithBase(`/backend/auth/requests/${args.correlationId}`, baseUrl), {
|
|
66
64
|
headers: await this.createHeaders(),
|
|
67
65
|
method: "DELETE"
|
|
68
66
|
});
|
|
@@ -70,16 +68,11 @@ var SIOPv2OID4VPRPRestClient = class {
|
|
|
70
68
|
}
|
|
71
69
|
async siopClientGetAuthStatus(args) {
|
|
72
70
|
const baseUrl = this.checkBaseUrlParameter(args.baseUrl);
|
|
73
|
-
const url = this.uriWithBase(
|
|
74
|
-
const definitionId = this.checkDefinitionIdParameter(args.definitionId);
|
|
71
|
+
const url = this.uriWithBase(`/backend/auth/status/${args.correlationId}`, baseUrl);
|
|
75
72
|
const statusResponse = await (0, import_cross_fetch.fetch)(url, {
|
|
76
|
-
method: "
|
|
73
|
+
method: "GET",
|
|
77
74
|
headers: await this.createHeaders({
|
|
78
75
|
"Content-Type": "application/json"
|
|
79
|
-
}),
|
|
80
|
-
body: JSON.stringify({
|
|
81
|
-
correlationId: args.correlationId,
|
|
82
|
-
definitionId
|
|
83
76
|
})
|
|
84
77
|
});
|
|
85
78
|
logger.debug(`auth status response: ${statusResponse}`);
|
|
@@ -91,20 +84,18 @@ var SIOPv2OID4VPRPRestClient = class {
|
|
|
91
84
|
}
|
|
92
85
|
async siopClientCreateAuthRequest(args) {
|
|
93
86
|
const baseUrl = this.checkBaseUrlParameter(args.baseUrl);
|
|
94
|
-
const
|
|
95
|
-
const url = this.uriWithBase(`/webapp/definitions/${definitionId}/auth-requests`, baseUrl);
|
|
87
|
+
const url = this.uriWithBase(`/backend/auth/requests`, baseUrl);
|
|
96
88
|
const origResponse = await (0, import_cross_fetch.fetch)(url, {
|
|
97
89
|
method: "POST",
|
|
98
90
|
headers: await this.createHeaders({
|
|
99
91
|
"Content-Type": "application/json"
|
|
100
92
|
}),
|
|
101
|
-
body: JSON.stringify({
|
|
102
|
-
...args
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
})
|
|
93
|
+
body: JSON.stringify((0, import_ssi_sdk.createAuthorizationRequestToPayload)({
|
|
94
|
+
...args,
|
|
95
|
+
requestUriMethod: "get"
|
|
96
|
+
}))
|
|
106
97
|
});
|
|
107
|
-
return await origResponse.json();
|
|
98
|
+
return (0, import_ssi_sdk.createAuthorizationResponseFromPayload)(await origResponse.json());
|
|
108
99
|
}
|
|
109
100
|
uriWithBase(path, baseUrl) {
|
|
110
101
|
if (!this.baseUrl && !baseUrl) {
|
|
@@ -118,11 +109,5 @@ var SIOPv2OID4VPRPRestClient = class {
|
|
|
118
109
|
}
|
|
119
110
|
return baseUrl ? baseUrl : this.baseUrl;
|
|
120
111
|
}
|
|
121
|
-
checkDefinitionIdParameter(definitionId) {
|
|
122
|
-
if (!definitionId && !this.definitionId) {
|
|
123
|
-
throw new Error("No definition id has been provided");
|
|
124
|
-
}
|
|
125
|
-
return definitionId ? definitionId : this.definitionId;
|
|
126
|
-
}
|
|
127
112
|
};
|
|
128
113
|
//# sourceMappingURL=index.cjs.map
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/index.ts","../src/agent/SIOPv2OID4VPRPRestClient.ts"],"sourcesContent":["export { SIOPv2OID4VPRPRestClient } from './agent/SIOPv2OID4VPRPRestClient'\nexport * from './types/ISIOPv2OID4VPRPRestClient'\n","import {
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/agent/SIOPv2OID4VPRPRestClient.ts"],"sourcesContent":["export { SIOPv2OID4VPRPRestClient } from './agent/SIOPv2OID4VPRPRestClient'\nexport * from './types/ISIOPv2OID4VPRPRestClient'\n","import {\n type AuthStatusResponse,\n type CreateAuthorizationRequest,\n createAuthorizationRequestToPayload,\n type CreateAuthorizationResponse,\n createAuthorizationResponseFromPayload,\n} from '@sphereon/ssi-sdk.siopv2-oid4vp-common'\nimport { Loggers } from '@sphereon/ssi-types'\nimport { IAgentPlugin } from '@veramo/core'\nimport { fetch } from 'cross-fetch'\nimport {\n ISiopClientGenerateAuthRequestArgs,\n ISiopClientGetAuthStatusArgs,\n ISiopClientRemoveAuthRequestSessionArgs,\n ISIOPv2OID4VPRPRestClient,\n Siopv2RestClientAuthenticationOpts,\n Siopv2RestClientOpts,\n} from '../types/ISIOPv2OID4VPRPRestClient'\n\nconst logger = Loggers.DEFAULT.get('sphereon:ssi-sdk-siopv2-oid4vp-rp-rest-client')\n\n/**\n * @beta\n */\nexport class SIOPv2OID4VPRPRestClient implements IAgentPlugin {\n readonly methods: ISIOPv2OID4VPRPRestClient = {\n siopClientRemoveAuthRequestState: this.siopClientRemoveAuthRequestState.bind(this),\n siopClientCreateAuthRequest: this.siopClientCreateAuthRequest.bind(this),\n siopClientGetAuthStatus: this.siopClientGetAuthStatus.bind(this),\n }\n\n private readonly baseUrl?: string\n private readonly authOpts?: Siopv2RestClientAuthenticationOpts\n\n constructor(args?: Siopv2RestClientOpts) {\n this.baseUrl = args?.baseUrl\n this.authOpts = args?.authentication\n }\n\n private async createHeaders(existing?: Record<string, any>): Promise<HeadersInit> {\n const headers: HeadersInit = {\n ...existing,\n Accept: 'application/json',\n }\n if (this.authOpts?.enabled === true) {\n if (!this.authOpts.bearerToken) {\n throw Error(`Cannot have authentication enabled, whilst not enabling static bearer tokens at this point`)\n }\n headers.Authorization = `Bearer ${\n typeof this.authOpts.bearerToken === 'string' ? this.authOpts.bearerToken : await this.authOpts.bearerToken()\n }`\n }\n return headers\n }\n\n private async siopClientRemoveAuthRequestState(args: ISiopClientRemoveAuthRequestSessionArgs): Promise<boolean> {\n const baseUrl = this.checkBaseUrlParameter(args.baseUrl)\n await fetch(this.uriWithBase(`/backend/auth/requests/${args.correlationId}`, baseUrl), {\n headers: await this.createHeaders(),\n method: 'DELETE',\n })\n return true\n }\n\n private async siopClientGetAuthStatus(args: ISiopClientGetAuthStatusArgs): Promise<AuthStatusResponse> {\n const baseUrl = this.checkBaseUrlParameter(args.baseUrl)\n const url = this.uriWithBase(`/backend/auth/status/${args.correlationId}`, baseUrl)\n const statusResponse = await fetch(url, {\n method: 'GET',\n headers: await this.createHeaders({ 'Content-Type': 'application/json' }),\n })\n logger.debug(`auth status response: ${statusResponse}`)\n try {\n return await statusResponse.json()\n } catch (err) {\n throw Error(`Status has returned ${statusResponse.status}`)\n }\n }\n\n private async siopClientCreateAuthRequest(args: ISiopClientGenerateAuthRequestArgs): Promise<CreateAuthorizationResponse> {\n const baseUrl = this.checkBaseUrlParameter(args.baseUrl)\n const url = this.uriWithBase(`/backend/auth/requests`, baseUrl)\n\n const origResponse = await fetch(url, {\n method: 'POST',\n headers: await this.createHeaders({ 'Content-Type': 'application/json' }),\n body: JSON.stringify(createAuthorizationRequestToPayload({ ...args, requestUriMethod: 'get' } satisfies CreateAuthorizationRequest)),\n })\n return createAuthorizationResponseFromPayload(await origResponse.json())\n }\n\n private uriWithBase(path: string, baseUrl?: string): string {\n if (!this.baseUrl && !baseUrl) {\n throw new Error('You have to provide baseUrl')\n }\n return baseUrl ? `${baseUrl}${path.startsWith('/') ? path : '/' + path}` : `${this.baseUrl}${path.startsWith('/') ? path : '/' + path}`\n }\n\n private checkBaseUrlParameter(baseUrl?: string): string {\n if (!baseUrl && !this.baseUrl) {\n throw new Error('No base url has been provided')\n }\n return baseUrl ? baseUrl : (this.baseUrl as string)\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;AAAA;;;;;;;ACAA,qBAMO;AACP,uBAAwB;AAExB,yBAAsB;AAUtB,IAAMA,SAASC,yBAAQC,QAAQC,IAAI,+CAAA;AAK5B,IAAMC,2BAAN,MAAMA;EAxBb,OAwBaA;;;EACFC,UAAqC;IAC5CC,kCAAkC,KAAKA,iCAAiCC,KAAK,IAAI;IACjFC,6BAA6B,KAAKA,4BAA4BD,KAAK,IAAI;IACvEE,yBAAyB,KAAKA,wBAAwBF,KAAK,IAAI;EACjE;EAEiBG;EACAC;EAEjB,YAAYC,MAA6B;AACvC,SAAKF,UAAUE,MAAMF;AACrB,SAAKC,WAAWC,MAAMC;EACxB;EAEA,MAAcC,cAAcC,UAAsD;AAChF,UAAMC,UAAuB;MAC3B,GAAGD;MACHE,QAAQ;IACV;AACA,QAAI,KAAKN,UAAUO,YAAY,MAAM;AACnC,UAAI,CAAC,KAAKP,SAASQ,aAAa;AAC9B,cAAMC,MAAM,4FAA4F;MAC1G;AACAJ,cAAQK,gBAAgB,UACtB,OAAO,KAAKV,SAASQ,gBAAgB,WAAW,KAAKR,SAASQ,cAAc,MAAM,KAAKR,SAASQ,YAAW,CAAA;IAE/G;AACA,WAAOH;EACT;EAEA,MAAcV,iCAAiCM,MAAiE;AAC9G,UAAMF,UAAU,KAAKY,sBAAsBV,KAAKF,OAAO;AACvD,cAAMa,0BAAM,KAAKC,YAAY,0BAA0BZ,KAAKa,aAAa,IAAIf,OAAAA,GAAU;MACrFM,SAAS,MAAM,KAAKF,cAAa;MACjCY,QAAQ;IACV,CAAA;AACA,WAAO;EACT;EAEA,MAAcjB,wBAAwBG,MAAiE;AACrG,UAAMF,UAAU,KAAKY,sBAAsBV,KAAKF,OAAO;AACvD,UAAMiB,MAAM,KAAKH,YAAY,wBAAwBZ,KAAKa,aAAa,IAAIf,OAAAA;AAC3E,UAAMkB,iBAAiB,UAAML,0BAAMI,KAAK;MACtCD,QAAQ;MACRV,SAAS,MAAM,KAAKF,cAAc;QAAE,gBAAgB;MAAmB,CAAA;IACzE,CAAA;AACAd,WAAO6B,MAAM,yBAAyBD,cAAAA,EAAgB;AACtD,QAAI;AACF,aAAO,MAAMA,eAAeE,KAAI;IAClC,SAASC,KAAK;AACZ,YAAMX,MAAM,uBAAuBQ,eAAeI,MAAM,EAAE;IAC5D;EACF;EAEA,MAAcxB,4BAA4BI,MAAgF;AACxH,UAAMF,UAAU,KAAKY,sBAAsBV,KAAKF,OAAO;AACvD,UAAMiB,MAAM,KAAKH,YAAY,0BAA0Bd,OAAAA;AAEvD,UAAMuB,eAAe,UAAMV,0BAAMI,KAAK;MACpCD,QAAQ;MACRV,SAAS,MAAM,KAAKF,cAAc;QAAE,gBAAgB;MAAmB,CAAA;MACvEoB,MAAMC,KAAKC,cAAUC,oDAAoC;QAAE,GAAGzB;QAAM0B,kBAAkB;MAAM,CAAA,CAAA;IAC9F,CAAA;AACA,eAAOC,uDAAuC,MAAMN,aAAaH,KAAI,CAAA;EACvE;EAEQN,YAAYgB,MAAc9B,SAA0B;AAC1D,QAAI,CAAC,KAAKA,WAAW,CAACA,SAAS;AAC7B,YAAM,IAAIU,MAAM,6BAAA;IAClB;AACA,WAAOV,UAAU,GAAGA,OAAAA,GAAU8B,KAAKC,WAAW,GAAA,IAAOD,OAAO,MAAMA,IAAAA,KAAS,GAAG,KAAK9B,OAAO,GAAG8B,KAAKC,WAAW,GAAA,IAAOD,OAAO,MAAMA,IAAAA;EACnI;EAEQlB,sBAAsBZ,SAA0B;AACtD,QAAI,CAACA,WAAW,CAAC,KAAKA,SAAS;AAC7B,YAAM,IAAIU,MAAM,+BAAA;IAClB;AACA,WAAOV,UAAUA,UAAW,KAAKA;EACnC;AACF;","names":["logger","Loggers","DEFAULT","get","SIOPv2OID4VPRPRestClient","methods","siopClientRemoveAuthRequestState","bind","siopClientCreateAuthRequest","siopClientGetAuthStatus","baseUrl","authOpts","args","authentication","createHeaders","existing","headers","Accept","enabled","bearerToken","Error","Authorization","checkBaseUrlParameter","fetch","uriWithBase","correlationId","method","url","statusResponse","debug","json","err","status","origResponse","body","JSON","stringify","createAuthorizationRequestToPayload","requestUriMethod","createAuthorizationResponseFromPayload","path","startsWith"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
import { BearerTokenArg } from '@sphereon/ssi-types';
|
|
2
1
|
import { IPluginMethodMap, IAgentContext, IAgentPlugin } from '@veramo/core';
|
|
3
|
-
import {
|
|
2
|
+
import { CreateAuthorizationRequest, CreateAuthorizationResponse, AuthStatusResponse } from '@sphereon/ssi-sdk.siopv2-oid4vp-common';
|
|
3
|
+
import { BearerTokenArg } from '@sphereon/ssi-types';
|
|
4
4
|
|
|
5
5
|
interface ISIOPv2OID4VPRPRestClient extends IPluginMethodMap {
|
|
6
6
|
siopClientRemoveAuthRequestState(args: ISiopClientRemoveAuthRequestSessionArgs, context: IRequiredContext): Promise<boolean>;
|
|
7
|
-
siopClientCreateAuthRequest(args: ISiopClientGenerateAuthRequestArgs, context: IRequiredContext): Promise<
|
|
7
|
+
siopClientCreateAuthRequest(args: ISiopClientGenerateAuthRequestArgs, context: IRequiredContext): Promise<CreateAuthorizationResponse>;
|
|
8
8
|
siopClientGetAuthStatus(args: ISiopClientGetAuthStatusArgs, context: IRequiredContext): Promise<AuthStatusResponse>;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
definitionId?: string;
|
|
10
|
+
type ISiopClientGenerateAuthRequestArgs = Omit<CreateAuthorizationRequest, 'requestUriMethod'> & {
|
|
12
11
|
baseUrl?: string;
|
|
13
|
-
|
|
14
|
-
}
|
|
12
|
+
};
|
|
15
13
|
interface ISiopClientRemoveAuthRequestSessionArgs {
|
|
16
14
|
correlationId: string;
|
|
17
15
|
baseUrl?: string;
|
|
18
|
-
|
|
16
|
+
queryId?: string;
|
|
19
17
|
}
|
|
20
18
|
interface ISiopClientGetAuthStatusArgs {
|
|
21
19
|
correlationId: string;
|
|
22
20
|
baseUrl?: string;
|
|
23
|
-
definitionId?: string;
|
|
24
21
|
}
|
|
25
22
|
interface Siopv2RestClientAuthenticationOpts {
|
|
26
23
|
enabled?: boolean;
|
|
@@ -28,7 +25,6 @@ interface Siopv2RestClientAuthenticationOpts {
|
|
|
28
25
|
}
|
|
29
26
|
interface Siopv2RestClientOpts {
|
|
30
27
|
baseUrl?: string;
|
|
31
|
-
definitionId?: string;
|
|
32
28
|
authentication?: Siopv2RestClientAuthenticationOpts;
|
|
33
29
|
}
|
|
34
30
|
type IRequiredContext = IAgentContext<any>;
|
|
@@ -39,7 +35,6 @@ type IRequiredContext = IAgentContext<any>;
|
|
|
39
35
|
declare class SIOPv2OID4VPRPRestClient implements IAgentPlugin {
|
|
40
36
|
readonly methods: ISIOPv2OID4VPRPRestClient;
|
|
41
37
|
private readonly baseUrl?;
|
|
42
|
-
private readonly definitionId?;
|
|
43
38
|
private readonly authOpts?;
|
|
44
39
|
constructor(args?: Siopv2RestClientOpts);
|
|
45
40
|
private createHeaders;
|
|
@@ -48,7 +43,6 @@ declare class SIOPv2OID4VPRPRestClient implements IAgentPlugin {
|
|
|
48
43
|
private siopClientCreateAuthRequest;
|
|
49
44
|
private uriWithBase;
|
|
50
45
|
private checkBaseUrlParameter;
|
|
51
|
-
private checkDefinitionIdParameter;
|
|
52
46
|
}
|
|
53
47
|
|
|
54
48
|
export { type IRequiredContext, type ISIOPv2OID4VPRPRestClient, type ISiopClientGenerateAuthRequestArgs, type ISiopClientGetAuthStatusArgs, type ISiopClientRemoveAuthRequestSessionArgs, SIOPv2OID4VPRPRestClient, type Siopv2RestClientAuthenticationOpts, type Siopv2RestClientOpts };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,26 +1,23 @@
|
|
|
1
|
-
import { BearerTokenArg } from '@sphereon/ssi-types';
|
|
2
1
|
import { IPluginMethodMap, IAgentContext, IAgentPlugin } from '@veramo/core';
|
|
3
|
-
import {
|
|
2
|
+
import { CreateAuthorizationRequest, CreateAuthorizationResponse, AuthStatusResponse } from '@sphereon/ssi-sdk.siopv2-oid4vp-common';
|
|
3
|
+
import { BearerTokenArg } from '@sphereon/ssi-types';
|
|
4
4
|
|
|
5
5
|
interface ISIOPv2OID4VPRPRestClient extends IPluginMethodMap {
|
|
6
6
|
siopClientRemoveAuthRequestState(args: ISiopClientRemoveAuthRequestSessionArgs, context: IRequiredContext): Promise<boolean>;
|
|
7
|
-
siopClientCreateAuthRequest(args: ISiopClientGenerateAuthRequestArgs, context: IRequiredContext): Promise<
|
|
7
|
+
siopClientCreateAuthRequest(args: ISiopClientGenerateAuthRequestArgs, context: IRequiredContext): Promise<CreateAuthorizationResponse>;
|
|
8
8
|
siopClientGetAuthStatus(args: ISiopClientGetAuthStatusArgs, context: IRequiredContext): Promise<AuthStatusResponse>;
|
|
9
9
|
}
|
|
10
|
-
|
|
11
|
-
definitionId?: string;
|
|
10
|
+
type ISiopClientGenerateAuthRequestArgs = Omit<CreateAuthorizationRequest, 'requestUriMethod'> & {
|
|
12
11
|
baseUrl?: string;
|
|
13
|
-
|
|
14
|
-
}
|
|
12
|
+
};
|
|
15
13
|
interface ISiopClientRemoveAuthRequestSessionArgs {
|
|
16
14
|
correlationId: string;
|
|
17
15
|
baseUrl?: string;
|
|
18
|
-
|
|
16
|
+
queryId?: string;
|
|
19
17
|
}
|
|
20
18
|
interface ISiopClientGetAuthStatusArgs {
|
|
21
19
|
correlationId: string;
|
|
22
20
|
baseUrl?: string;
|
|
23
|
-
definitionId?: string;
|
|
24
21
|
}
|
|
25
22
|
interface Siopv2RestClientAuthenticationOpts {
|
|
26
23
|
enabled?: boolean;
|
|
@@ -28,7 +25,6 @@ interface Siopv2RestClientAuthenticationOpts {
|
|
|
28
25
|
}
|
|
29
26
|
interface Siopv2RestClientOpts {
|
|
30
27
|
baseUrl?: string;
|
|
31
|
-
definitionId?: string;
|
|
32
28
|
authentication?: Siopv2RestClientAuthenticationOpts;
|
|
33
29
|
}
|
|
34
30
|
type IRequiredContext = IAgentContext<any>;
|
|
@@ -39,7 +35,6 @@ type IRequiredContext = IAgentContext<any>;
|
|
|
39
35
|
declare class SIOPv2OID4VPRPRestClient implements IAgentPlugin {
|
|
40
36
|
readonly methods: ISIOPv2OID4VPRPRestClient;
|
|
41
37
|
private readonly baseUrl?;
|
|
42
|
-
private readonly definitionId?;
|
|
43
38
|
private readonly authOpts?;
|
|
44
39
|
constructor(args?: Siopv2RestClientOpts);
|
|
45
40
|
private createHeaders;
|
|
@@ -48,7 +43,6 @@ declare class SIOPv2OID4VPRPRestClient implements IAgentPlugin {
|
|
|
48
43
|
private siopClientCreateAuthRequest;
|
|
49
44
|
private uriWithBase;
|
|
50
45
|
private checkBaseUrlParameter;
|
|
51
|
-
private checkDefinitionIdParameter;
|
|
52
46
|
}
|
|
53
47
|
|
|
54
48
|
export { type IRequiredContext, type ISIOPv2OID4VPRPRestClient, type ISiopClientGenerateAuthRequestArgs, type ISiopClientGetAuthStatusArgs, type ISiopClientRemoveAuthRequestSessionArgs, SIOPv2OID4VPRPRestClient, type Siopv2RestClientAuthenticationOpts, type Siopv2RestClientOpts };
|
package/dist/index.js
CHANGED
|
@@ -2,8 +2,9 @@ var __defProp = Object.defineProperty;
|
|
|
2
2
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
3
3
|
|
|
4
4
|
// src/agent/SIOPv2OID4VPRPRestClient.ts
|
|
5
|
-
import {
|
|
5
|
+
import { createAuthorizationRequestToPayload, createAuthorizationResponseFromPayload } from "@sphereon/ssi-sdk.siopv2-oid4vp-common";
|
|
6
6
|
import { Loggers } from "@sphereon/ssi-types";
|
|
7
|
+
import { fetch } from "cross-fetch";
|
|
7
8
|
var logger = Loggers.DEFAULT.get("sphereon:ssi-sdk-siopv2-oid4vp-rp-rest-client");
|
|
8
9
|
var SIOPv2OID4VPRPRestClient = class {
|
|
9
10
|
static {
|
|
@@ -15,11 +16,9 @@ var SIOPv2OID4VPRPRestClient = class {
|
|
|
15
16
|
siopClientGetAuthStatus: this.siopClientGetAuthStatus.bind(this)
|
|
16
17
|
};
|
|
17
18
|
baseUrl;
|
|
18
|
-
definitionId;
|
|
19
19
|
authOpts;
|
|
20
20
|
constructor(args) {
|
|
21
21
|
this.baseUrl = args?.baseUrl;
|
|
22
|
-
this.definitionId = args?.definitionId;
|
|
23
22
|
this.authOpts = args?.authentication;
|
|
24
23
|
}
|
|
25
24
|
async createHeaders(existing) {
|
|
@@ -37,8 +36,7 @@ var SIOPv2OID4VPRPRestClient = class {
|
|
|
37
36
|
}
|
|
38
37
|
async siopClientRemoveAuthRequestState(args) {
|
|
39
38
|
const baseUrl = this.checkBaseUrlParameter(args.baseUrl);
|
|
40
|
-
|
|
41
|
-
await fetch(this.uriWithBase(`/webapp/definitions/${definitionId}/auth-requests/${args.correlationId}`, baseUrl), {
|
|
39
|
+
await fetch(this.uriWithBase(`/backend/auth/requests/${args.correlationId}`, baseUrl), {
|
|
42
40
|
headers: await this.createHeaders(),
|
|
43
41
|
method: "DELETE"
|
|
44
42
|
});
|
|
@@ -46,16 +44,11 @@ var SIOPv2OID4VPRPRestClient = class {
|
|
|
46
44
|
}
|
|
47
45
|
async siopClientGetAuthStatus(args) {
|
|
48
46
|
const baseUrl = this.checkBaseUrlParameter(args.baseUrl);
|
|
49
|
-
const url = this.uriWithBase(
|
|
50
|
-
const definitionId = this.checkDefinitionIdParameter(args.definitionId);
|
|
47
|
+
const url = this.uriWithBase(`/backend/auth/status/${args.correlationId}`, baseUrl);
|
|
51
48
|
const statusResponse = await fetch(url, {
|
|
52
|
-
method: "
|
|
49
|
+
method: "GET",
|
|
53
50
|
headers: await this.createHeaders({
|
|
54
51
|
"Content-Type": "application/json"
|
|
55
|
-
}),
|
|
56
|
-
body: JSON.stringify({
|
|
57
|
-
correlationId: args.correlationId,
|
|
58
|
-
definitionId
|
|
59
52
|
})
|
|
60
53
|
});
|
|
61
54
|
logger.debug(`auth status response: ${statusResponse}`);
|
|
@@ -67,20 +60,18 @@ var SIOPv2OID4VPRPRestClient = class {
|
|
|
67
60
|
}
|
|
68
61
|
async siopClientCreateAuthRequest(args) {
|
|
69
62
|
const baseUrl = this.checkBaseUrlParameter(args.baseUrl);
|
|
70
|
-
const
|
|
71
|
-
const url = this.uriWithBase(`/webapp/definitions/${definitionId}/auth-requests`, baseUrl);
|
|
63
|
+
const url = this.uriWithBase(`/backend/auth/requests`, baseUrl);
|
|
72
64
|
const origResponse = await fetch(url, {
|
|
73
65
|
method: "POST",
|
|
74
66
|
headers: await this.createHeaders({
|
|
75
67
|
"Content-Type": "application/json"
|
|
76
68
|
}),
|
|
77
|
-
body: JSON.stringify({
|
|
78
|
-
...args
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
})
|
|
69
|
+
body: JSON.stringify(createAuthorizationRequestToPayload({
|
|
70
|
+
...args,
|
|
71
|
+
requestUriMethod: "get"
|
|
72
|
+
}))
|
|
82
73
|
});
|
|
83
|
-
return await origResponse.json();
|
|
74
|
+
return createAuthorizationResponseFromPayload(await origResponse.json());
|
|
84
75
|
}
|
|
85
76
|
uriWithBase(path, baseUrl) {
|
|
86
77
|
if (!this.baseUrl && !baseUrl) {
|
|
@@ -94,12 +85,6 @@ var SIOPv2OID4VPRPRestClient = class {
|
|
|
94
85
|
}
|
|
95
86
|
return baseUrl ? baseUrl : this.baseUrl;
|
|
96
87
|
}
|
|
97
|
-
checkDefinitionIdParameter(definitionId) {
|
|
98
|
-
if (!definitionId && !this.definitionId) {
|
|
99
|
-
throw new Error("No definition id has been provided");
|
|
100
|
-
}
|
|
101
|
-
return definitionId ? definitionId : this.definitionId;
|
|
102
|
-
}
|
|
103
88
|
};
|
|
104
89
|
export {
|
|
105
90
|
SIOPv2OID4VPRPRestClient
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../src/agent/SIOPv2OID4VPRPRestClient.ts"],"sourcesContent":["import {
|
|
1
|
+
{"version":3,"sources":["../src/agent/SIOPv2OID4VPRPRestClient.ts"],"sourcesContent":["import {\n type AuthStatusResponse,\n type CreateAuthorizationRequest,\n createAuthorizationRequestToPayload,\n type CreateAuthorizationResponse,\n createAuthorizationResponseFromPayload,\n} from '@sphereon/ssi-sdk.siopv2-oid4vp-common'\nimport { Loggers } from '@sphereon/ssi-types'\nimport { IAgentPlugin } from '@veramo/core'\nimport { fetch } from 'cross-fetch'\nimport {\n ISiopClientGenerateAuthRequestArgs,\n ISiopClientGetAuthStatusArgs,\n ISiopClientRemoveAuthRequestSessionArgs,\n ISIOPv2OID4VPRPRestClient,\n Siopv2RestClientAuthenticationOpts,\n Siopv2RestClientOpts,\n} from '../types/ISIOPv2OID4VPRPRestClient'\n\nconst logger = Loggers.DEFAULT.get('sphereon:ssi-sdk-siopv2-oid4vp-rp-rest-client')\n\n/**\n * @beta\n */\nexport class SIOPv2OID4VPRPRestClient implements IAgentPlugin {\n readonly methods: ISIOPv2OID4VPRPRestClient = {\n siopClientRemoveAuthRequestState: this.siopClientRemoveAuthRequestState.bind(this),\n siopClientCreateAuthRequest: this.siopClientCreateAuthRequest.bind(this),\n siopClientGetAuthStatus: this.siopClientGetAuthStatus.bind(this),\n }\n\n private readonly baseUrl?: string\n private readonly authOpts?: Siopv2RestClientAuthenticationOpts\n\n constructor(args?: Siopv2RestClientOpts) {\n this.baseUrl = args?.baseUrl\n this.authOpts = args?.authentication\n }\n\n private async createHeaders(existing?: Record<string, any>): Promise<HeadersInit> {\n const headers: HeadersInit = {\n ...existing,\n Accept: 'application/json',\n }\n if (this.authOpts?.enabled === true) {\n if (!this.authOpts.bearerToken) {\n throw Error(`Cannot have authentication enabled, whilst not enabling static bearer tokens at this point`)\n }\n headers.Authorization = `Bearer ${\n typeof this.authOpts.bearerToken === 'string' ? this.authOpts.bearerToken : await this.authOpts.bearerToken()\n }`\n }\n return headers\n }\n\n private async siopClientRemoveAuthRequestState(args: ISiopClientRemoveAuthRequestSessionArgs): Promise<boolean> {\n const baseUrl = this.checkBaseUrlParameter(args.baseUrl)\n await fetch(this.uriWithBase(`/backend/auth/requests/${args.correlationId}`, baseUrl), {\n headers: await this.createHeaders(),\n method: 'DELETE',\n })\n return true\n }\n\n private async siopClientGetAuthStatus(args: ISiopClientGetAuthStatusArgs): Promise<AuthStatusResponse> {\n const baseUrl = this.checkBaseUrlParameter(args.baseUrl)\n const url = this.uriWithBase(`/backend/auth/status/${args.correlationId}`, baseUrl)\n const statusResponse = await fetch(url, {\n method: 'GET',\n headers: await this.createHeaders({ 'Content-Type': 'application/json' }),\n })\n logger.debug(`auth status response: ${statusResponse}`)\n try {\n return await statusResponse.json()\n } catch (err) {\n throw Error(`Status has returned ${statusResponse.status}`)\n }\n }\n\n private async siopClientCreateAuthRequest(args: ISiopClientGenerateAuthRequestArgs): Promise<CreateAuthorizationResponse> {\n const baseUrl = this.checkBaseUrlParameter(args.baseUrl)\n const url = this.uriWithBase(`/backend/auth/requests`, baseUrl)\n\n const origResponse = await fetch(url, {\n method: 'POST',\n headers: await this.createHeaders({ 'Content-Type': 'application/json' }),\n body: JSON.stringify(createAuthorizationRequestToPayload({ ...args, requestUriMethod: 'get' } satisfies CreateAuthorizationRequest)),\n })\n return createAuthorizationResponseFromPayload(await origResponse.json())\n }\n\n private uriWithBase(path: string, baseUrl?: string): string {\n if (!this.baseUrl && !baseUrl) {\n throw new Error('You have to provide baseUrl')\n }\n return baseUrl ? `${baseUrl}${path.startsWith('/') ? path : '/' + path}` : `${this.baseUrl}${path.startsWith('/') ? path : '/' + path}`\n }\n\n private checkBaseUrlParameter(baseUrl?: string): string {\n if (!baseUrl && !this.baseUrl) {\n throw new Error('No base url has been provided')\n }\n return baseUrl ? baseUrl : (this.baseUrl as string)\n }\n}\n"],"mappings":";;;;AAAA,SAGEA,qCAEAC,8CACK;AACP,SAASC,eAAe;AAExB,SAASC,aAAa;AAUtB,IAAMC,SAASC,QAAQC,QAAQC,IAAI,+CAAA;AAK5B,IAAMC,2BAAN,MAAMA;EAxBb,OAwBaA;;;EACFC,UAAqC;IAC5CC,kCAAkC,KAAKA,iCAAiCC,KAAK,IAAI;IACjFC,6BAA6B,KAAKA,4BAA4BD,KAAK,IAAI;IACvEE,yBAAyB,KAAKA,wBAAwBF,KAAK,IAAI;EACjE;EAEiBG;EACAC;EAEjB,YAAYC,MAA6B;AACvC,SAAKF,UAAUE,MAAMF;AACrB,SAAKC,WAAWC,MAAMC;EACxB;EAEA,MAAcC,cAAcC,UAAsD;AAChF,UAAMC,UAAuB;MAC3B,GAAGD;MACHE,QAAQ;IACV;AACA,QAAI,KAAKN,UAAUO,YAAY,MAAM;AACnC,UAAI,CAAC,KAAKP,SAASQ,aAAa;AAC9B,cAAMC,MAAM,4FAA4F;MAC1G;AACAJ,cAAQK,gBAAgB,UACtB,OAAO,KAAKV,SAASQ,gBAAgB,WAAW,KAAKR,SAASQ,cAAc,MAAM,KAAKR,SAASQ,YAAW,CAAA;IAE/G;AACA,WAAOH;EACT;EAEA,MAAcV,iCAAiCM,MAAiE;AAC9G,UAAMF,UAAU,KAAKY,sBAAsBV,KAAKF,OAAO;AACvD,UAAMa,MAAM,KAAKC,YAAY,0BAA0BZ,KAAKa,aAAa,IAAIf,OAAAA,GAAU;MACrFM,SAAS,MAAM,KAAKF,cAAa;MACjCY,QAAQ;IACV,CAAA;AACA,WAAO;EACT;EAEA,MAAcjB,wBAAwBG,MAAiE;AACrG,UAAMF,UAAU,KAAKY,sBAAsBV,KAAKF,OAAO;AACvD,UAAMiB,MAAM,KAAKH,YAAY,wBAAwBZ,KAAKa,aAAa,IAAIf,OAAAA;AAC3E,UAAMkB,iBAAiB,MAAML,MAAMI,KAAK;MACtCD,QAAQ;MACRV,SAAS,MAAM,KAAKF,cAAc;QAAE,gBAAgB;MAAmB,CAAA;IACzE,CAAA;AACAd,WAAO6B,MAAM,yBAAyBD,cAAAA,EAAgB;AACtD,QAAI;AACF,aAAO,MAAMA,eAAeE,KAAI;IAClC,SAASC,KAAK;AACZ,YAAMX,MAAM,uBAAuBQ,eAAeI,MAAM,EAAE;IAC5D;EACF;EAEA,MAAcxB,4BAA4BI,MAAgF;AACxH,UAAMF,UAAU,KAAKY,sBAAsBV,KAAKF,OAAO;AACvD,UAAMiB,MAAM,KAAKH,YAAY,0BAA0Bd,OAAAA;AAEvD,UAAMuB,eAAe,MAAMV,MAAMI,KAAK;MACpCD,QAAQ;MACRV,SAAS,MAAM,KAAKF,cAAc;QAAE,gBAAgB;MAAmB,CAAA;MACvEoB,MAAMC,KAAKC,UAAUC,oCAAoC;QAAE,GAAGzB;QAAM0B,kBAAkB;MAAM,CAAA,CAAA;IAC9F,CAAA;AACA,WAAOC,uCAAuC,MAAMN,aAAaH,KAAI,CAAA;EACvE;EAEQN,YAAYgB,MAAc9B,SAA0B;AAC1D,QAAI,CAAC,KAAKA,WAAW,CAACA,SAAS;AAC7B,YAAM,IAAIU,MAAM,6BAAA;IAClB;AACA,WAAOV,UAAU,GAAGA,OAAAA,GAAU8B,KAAKC,WAAW,GAAA,IAAOD,OAAO,MAAMA,IAAAA,KAAS,GAAG,KAAK9B,OAAO,GAAG8B,KAAKC,WAAW,GAAA,IAAOD,OAAO,MAAMA,IAAAA;EACnI;EAEQlB,sBAAsBZ,SAA0B;AACtD,QAAI,CAACA,WAAW,CAAC,KAAKA,SAAS;AAC7B,YAAM,IAAIU,MAAM,+BAAA;IAClB;AACA,WAAOV,UAAUA,UAAW,KAAKA;EACnC;AACF;","names":["createAuthorizationRequestToPayload","createAuthorizationResponseFromPayload","Loggers","fetch","logger","Loggers","DEFAULT","get","SIOPv2OID4VPRPRestClient","methods","siopClientRemoveAuthRequestState","bind","siopClientCreateAuthRequest","siopClientGetAuthStatus","baseUrl","authOpts","args","authentication","createHeaders","existing","headers","Accept","enabled","bearerToken","Error","Authorization","checkBaseUrlParameter","fetch","uriWithBase","correlationId","method","url","statusResponse","debug","json","err","status","origResponse","body","JSON","stringify","createAuthorizationRequestToPayload","requestUriMethod","createAuthorizationResponseFromPayload","path","startsWith"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.siopv2-oid4vp-rp-rest-client",
|
|
3
3
|
"description": "contains the client side to call REST endpoints of relying party",
|
|
4
|
-
"version": "0.34.1-fix.
|
|
4
|
+
"version": "0.34.1-fix.223+9c86d039",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
@@ -27,8 +27,8 @@
|
|
|
27
27
|
"build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json"
|
|
28
28
|
},
|
|
29
29
|
"dependencies": {
|
|
30
|
-
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.34.1-fix.
|
|
31
|
-
"@sphereon/ssi-types": "0.34.1-fix.
|
|
30
|
+
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.34.1-fix.223+9c86d039",
|
|
31
|
+
"@sphereon/ssi-types": "0.34.1-fix.223+9c86d039",
|
|
32
32
|
"@veramo/core": "4.2.0",
|
|
33
33
|
"cross-fetch": "^4.1.0"
|
|
34
34
|
},
|
|
@@ -53,5 +53,5 @@
|
|
|
53
53
|
"author": "Sphereon <dev@sphereon.com>",
|
|
54
54
|
"license": "Apache-2.0",
|
|
55
55
|
"keywords": [],
|
|
56
|
-
"gitHead": "
|
|
56
|
+
"gitHead": "9c86d03951f1267495e456d1fbfd9eb380f27e78"
|
|
57
57
|
}
|
|
@@ -1,3 +1,12 @@
|
|
|
1
|
+
import {
|
|
2
|
+
type AuthStatusResponse,
|
|
3
|
+
type CreateAuthorizationRequest,
|
|
4
|
+
createAuthorizationRequestToPayload,
|
|
5
|
+
type CreateAuthorizationResponse,
|
|
6
|
+
createAuthorizationResponseFromPayload,
|
|
7
|
+
} from '@sphereon/ssi-sdk.siopv2-oid4vp-common'
|
|
8
|
+
import { Loggers } from '@sphereon/ssi-types'
|
|
9
|
+
import { IAgentPlugin } from '@veramo/core'
|
|
1
10
|
import { fetch } from 'cross-fetch'
|
|
2
11
|
import {
|
|
3
12
|
ISiopClientGenerateAuthRequestArgs,
|
|
@@ -7,9 +16,6 @@ import {
|
|
|
7
16
|
Siopv2RestClientAuthenticationOpts,
|
|
8
17
|
Siopv2RestClientOpts,
|
|
9
18
|
} from '../types/ISIOPv2OID4VPRPRestClient'
|
|
10
|
-
import { IAgentPlugin } from '@veramo/core'
|
|
11
|
-
import { AuthStatusResponse, GenerateAuthRequestURIResponse } from '@sphereon/ssi-sdk.siopv2-oid4vp-common'
|
|
12
|
-
import { Loggers } from '@sphereon/ssi-types'
|
|
13
19
|
|
|
14
20
|
const logger = Loggers.DEFAULT.get('sphereon:ssi-sdk-siopv2-oid4vp-rp-rest-client')
|
|
15
21
|
|
|
@@ -24,12 +30,10 @@ export class SIOPv2OID4VPRPRestClient implements IAgentPlugin {
|
|
|
24
30
|
}
|
|
25
31
|
|
|
26
32
|
private readonly baseUrl?: string
|
|
27
|
-
private readonly definitionId?: string
|
|
28
33
|
private readonly authOpts?: Siopv2RestClientAuthenticationOpts
|
|
29
34
|
|
|
30
35
|
constructor(args?: Siopv2RestClientOpts) {
|
|
31
36
|
this.baseUrl = args?.baseUrl
|
|
32
|
-
this.definitionId = args?.definitionId
|
|
33
37
|
this.authOpts = args?.authentication
|
|
34
38
|
}
|
|
35
39
|
|
|
@@ -51,8 +55,7 @@ export class SIOPv2OID4VPRPRestClient implements IAgentPlugin {
|
|
|
51
55
|
|
|
52
56
|
private async siopClientRemoveAuthRequestState(args: ISiopClientRemoveAuthRequestSessionArgs): Promise<boolean> {
|
|
53
57
|
const baseUrl = this.checkBaseUrlParameter(args.baseUrl)
|
|
54
|
-
|
|
55
|
-
await fetch(this.uriWithBase(`/webapp/definitions/${definitionId}/auth-requests/${args.correlationId}`, baseUrl), {
|
|
58
|
+
await fetch(this.uriWithBase(`/backend/auth/requests/${args.correlationId}`, baseUrl), {
|
|
56
59
|
headers: await this.createHeaders(),
|
|
57
60
|
method: 'DELETE',
|
|
58
61
|
})
|
|
@@ -61,15 +64,10 @@ export class SIOPv2OID4VPRPRestClient implements IAgentPlugin {
|
|
|
61
64
|
|
|
62
65
|
private async siopClientGetAuthStatus(args: ISiopClientGetAuthStatusArgs): Promise<AuthStatusResponse> {
|
|
63
66
|
const baseUrl = this.checkBaseUrlParameter(args.baseUrl)
|
|
64
|
-
const url = this.uriWithBase(
|
|
65
|
-
const definitionId = this.checkDefinitionIdParameter(args.definitionId)
|
|
67
|
+
const url = this.uriWithBase(`/backend/auth/status/${args.correlationId}`, baseUrl)
|
|
66
68
|
const statusResponse = await fetch(url, {
|
|
67
|
-
method: '
|
|
69
|
+
method: 'GET',
|
|
68
70
|
headers: await this.createHeaders({ 'Content-Type': 'application/json' }),
|
|
69
|
-
body: JSON.stringify({
|
|
70
|
-
correlationId: args.correlationId,
|
|
71
|
-
definitionId,
|
|
72
|
-
}),
|
|
73
71
|
})
|
|
74
72
|
logger.debug(`auth status response: ${statusResponse}`)
|
|
75
73
|
try {
|
|
@@ -79,18 +77,16 @@ export class SIOPv2OID4VPRPRestClient implements IAgentPlugin {
|
|
|
79
77
|
}
|
|
80
78
|
}
|
|
81
79
|
|
|
82
|
-
private async siopClientCreateAuthRequest(args: ISiopClientGenerateAuthRequestArgs): Promise<
|
|
80
|
+
private async siopClientCreateAuthRequest(args: ISiopClientGenerateAuthRequestArgs): Promise<CreateAuthorizationResponse> {
|
|
83
81
|
const baseUrl = this.checkBaseUrlParameter(args.baseUrl)
|
|
84
|
-
const
|
|
85
|
-
|
|
82
|
+
const url = this.uriWithBase(`/backend/auth/requests`, baseUrl)
|
|
83
|
+
|
|
86
84
|
const origResponse = await fetch(url, {
|
|
87
85
|
method: 'POST',
|
|
88
86
|
headers: await this.createHeaders({ 'Content-Type': 'application/json' }),
|
|
89
|
-
body: JSON.stringify({
|
|
90
|
-
...(args.responseRedirectURI && { response_redirect_uri: args.responseRedirectURI }),
|
|
91
|
-
}),
|
|
87
|
+
body: JSON.stringify(createAuthorizationRequestToPayload({ ...args, requestUriMethod: 'get' } satisfies CreateAuthorizationRequest)),
|
|
92
88
|
})
|
|
93
|
-
return await origResponse.json()
|
|
89
|
+
return createAuthorizationResponseFromPayload(await origResponse.json())
|
|
94
90
|
}
|
|
95
91
|
|
|
96
92
|
private uriWithBase(path: string, baseUrl?: string): string {
|
|
@@ -106,11 +102,4 @@ export class SIOPv2OID4VPRPRestClient implements IAgentPlugin {
|
|
|
106
102
|
}
|
|
107
103
|
return baseUrl ? baseUrl : (this.baseUrl as string)
|
|
108
104
|
}
|
|
109
|
-
|
|
110
|
-
private checkDefinitionIdParameter(definitionId?: string): string {
|
|
111
|
-
if (!definitionId && !this.definitionId) {
|
|
112
|
-
throw new Error('No definition id has been provided')
|
|
113
|
-
}
|
|
114
|
-
return definitionId ? definitionId : (this.definitionId as string)
|
|
115
|
-
}
|
|
116
105
|
}
|
|
@@ -1,32 +1,28 @@
|
|
|
1
|
+
import { AuthStatusResponse, type CreateAuthorizationRequest, type CreateAuthorizationResponse } from '@sphereon/ssi-sdk.siopv2-oid4vp-common'
|
|
1
2
|
import { BearerTokenArg } from '@sphereon/ssi-types'
|
|
2
3
|
import { IAgentContext, IPluginMethodMap } from '@veramo/core'
|
|
3
4
|
|
|
4
|
-
import { AuthStatusResponse, GenerateAuthRequestURIResponse } from '@sphereon/ssi-sdk.siopv2-oid4vp-common'
|
|
5
|
-
|
|
6
5
|
export interface ISIOPv2OID4VPRPRestClient extends IPluginMethodMap {
|
|
7
6
|
siopClientRemoveAuthRequestState(args: ISiopClientRemoveAuthRequestSessionArgs, context: IRequiredContext): Promise<boolean>
|
|
8
7
|
|
|
9
|
-
siopClientCreateAuthRequest(args: ISiopClientGenerateAuthRequestArgs, context: IRequiredContext): Promise<
|
|
8
|
+
siopClientCreateAuthRequest(args: ISiopClientGenerateAuthRequestArgs, context: IRequiredContext): Promise<CreateAuthorizationResponse>
|
|
10
9
|
|
|
11
10
|
siopClientGetAuthStatus(args: ISiopClientGetAuthStatusArgs, context: IRequiredContext): Promise<AuthStatusResponse>
|
|
12
11
|
}
|
|
13
12
|
|
|
14
|
-
export
|
|
15
|
-
definitionId?: string
|
|
13
|
+
export type ISiopClientGenerateAuthRequestArgs = Omit<CreateAuthorizationRequest, 'requestUriMethod'> & {
|
|
16
14
|
baseUrl?: string
|
|
17
|
-
responseRedirectURI?: string
|
|
18
15
|
}
|
|
19
16
|
|
|
20
17
|
export interface ISiopClientRemoveAuthRequestSessionArgs {
|
|
21
18
|
correlationId: string
|
|
22
19
|
baseUrl?: string
|
|
23
|
-
|
|
20
|
+
queryId?: string
|
|
24
21
|
}
|
|
25
22
|
|
|
26
23
|
export interface ISiopClientGetAuthStatusArgs {
|
|
27
24
|
correlationId: string
|
|
28
25
|
baseUrl?: string
|
|
29
|
-
definitionId?: string
|
|
30
26
|
}
|
|
31
27
|
|
|
32
28
|
export interface Siopv2RestClientAuthenticationOpts {
|
|
@@ -36,7 +32,6 @@ export interface Siopv2RestClientAuthenticationOpts {
|
|
|
36
32
|
|
|
37
33
|
export interface Siopv2RestClientOpts {
|
|
38
34
|
baseUrl?: string
|
|
39
|
-
definitionId?: string
|
|
40
35
|
authentication?: Siopv2RestClientAuthenticationOpts
|
|
41
36
|
}
|
|
42
37
|
|