@sphereon/ssi-sdk.siopv2-oid4vp-rp-rest-client 0.34.1-feature.SSISDK.57.uni.client.167 → 0.34.1-feature.SSISDK.57.uni.client.169
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 +4 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +0 -2
- package/dist/index.d.ts +0 -2
- package/dist/index.js +5 -2
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
- package/src/agent/SIOPv2OID4VPRPRestClient.ts +4 -1
- package/src/types/ISIOPv2OID4VPRPRestClient.ts +0 -2
package/dist/index.cjs
CHANGED
|
@@ -90,7 +90,10 @@ var SIOPv2OID4VPRPRestClient = class {
|
|
|
90
90
|
headers: await this.createHeaders({
|
|
91
91
|
"Content-Type": "application/json"
|
|
92
92
|
}),
|
|
93
|
-
body: JSON.stringify((0, import_ssi_sdk.createAuthorizationRequestToPayload)(
|
|
93
|
+
body: JSON.stringify((0, import_ssi_sdk.createAuthorizationRequestToPayload)({
|
|
94
|
+
...args,
|
|
95
|
+
requestUriMethod: import_ssi_sdk.RequestUriMethod.GET
|
|
96
|
+
}))
|
|
94
97
|
});
|
|
95
98
|
return (0, import_ssi_sdk.createAuthorizationResponseFromPayload)(await origResponse.json());
|
|
96
99
|
}
|
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 {\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
|
|
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 RequestUriMethod,\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(\n createAuthorizationRequestToPayload({ ...args, requestUriMethod: RequestUriMethod.GET } satisfies CreateAuthorizationRequest),\n ),\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,qBAOO;AACP,uBAAwB;AAExB,yBAAsB;AAUtB,IAAMA,SAASC,yBAAQC,QAAQC,IAAI,+CAAA;AAK5B,IAAMC,2BAAN,MAAMA;EAzBb,OAyBaA;;;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;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A,OAAAA,GAAUgC,KAAKC,WAAW,GAAA,IAAOD,OAAO,MAAMA,IAAAA,KAAS,GAAG,KAAKhC,OAAO,GAAGgC,KAAKC,WAAW,GAAA,IAAOD,OAAO,MAAMA,IAAAA;EACnI;EAEQpB,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","RequestUriMethod","GET","createAuthorizationResponseFromPayload","path","startsWith"]}
|
package/dist/index.d.cts
CHANGED
|
@@ -9,7 +9,6 @@ interface ISIOPv2OID4VPRPRestClient extends IPluginMethodMap {
|
|
|
9
9
|
}
|
|
10
10
|
type ISiopClientGenerateAuthRequestArgs = Omit<CreateAuthorizationRequest, 'requestUriMethod'> & {
|
|
11
11
|
baseUrl?: string;
|
|
12
|
-
requestUriMethod: 'get';
|
|
13
12
|
};
|
|
14
13
|
interface ISiopClientRemoveAuthRequestSessionArgs {
|
|
15
14
|
correlationId: string;
|
|
@@ -26,7 +25,6 @@ interface Siopv2RestClientAuthenticationOpts {
|
|
|
26
25
|
}
|
|
27
26
|
interface Siopv2RestClientOpts {
|
|
28
27
|
baseUrl?: string;
|
|
29
|
-
queryId?: string;
|
|
30
28
|
authentication?: Siopv2RestClientAuthenticationOpts;
|
|
31
29
|
}
|
|
32
30
|
type IRequiredContext = IAgentContext<any>;
|
package/dist/index.d.ts
CHANGED
|
@@ -9,7 +9,6 @@ interface ISIOPv2OID4VPRPRestClient extends IPluginMethodMap {
|
|
|
9
9
|
}
|
|
10
10
|
type ISiopClientGenerateAuthRequestArgs = Omit<CreateAuthorizationRequest, 'requestUriMethod'> & {
|
|
11
11
|
baseUrl?: string;
|
|
12
|
-
requestUriMethod: 'get';
|
|
13
12
|
};
|
|
14
13
|
interface ISiopClientRemoveAuthRequestSessionArgs {
|
|
15
14
|
correlationId: string;
|
|
@@ -26,7 +25,6 @@ interface Siopv2RestClientAuthenticationOpts {
|
|
|
26
25
|
}
|
|
27
26
|
interface Siopv2RestClientOpts {
|
|
28
27
|
baseUrl?: string;
|
|
29
|
-
queryId?: string;
|
|
30
28
|
authentication?: Siopv2RestClientAuthenticationOpts;
|
|
31
29
|
}
|
|
32
30
|
type IRequiredContext = IAgentContext<any>;
|
package/dist/index.js
CHANGED
|
@@ -2,7 +2,7 @@ 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 { createAuthorizationRequestToPayload, createAuthorizationResponseFromPayload } from "@sphereon/ssi-sdk.siopv2-oid4vp-common";
|
|
5
|
+
import { createAuthorizationRequestToPayload, createAuthorizationResponseFromPayload, RequestUriMethod } from "@sphereon/ssi-sdk.siopv2-oid4vp-common";
|
|
6
6
|
import { Loggers } from "@sphereon/ssi-types";
|
|
7
7
|
import { fetch } from "cross-fetch";
|
|
8
8
|
var logger = Loggers.DEFAULT.get("sphereon:ssi-sdk-siopv2-oid4vp-rp-rest-client");
|
|
@@ -66,7 +66,10 @@ var SIOPv2OID4VPRPRestClient = class {
|
|
|
66
66
|
headers: await this.createHeaders({
|
|
67
67
|
"Content-Type": "application/json"
|
|
68
68
|
}),
|
|
69
|
-
body: JSON.stringify(createAuthorizationRequestToPayload(
|
|
69
|
+
body: JSON.stringify(createAuthorizationRequestToPayload({
|
|
70
|
+
...args,
|
|
71
|
+
requestUriMethod: RequestUriMethod.GET
|
|
72
|
+
}))
|
|
70
73
|
});
|
|
71
74
|
return createAuthorizationResponseFromPayload(await origResponse.json());
|
|
72
75
|
}
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
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
|
|
1
|
+
{"version":3,"sources":["../src/agent/SIOPv2OID4VPRPRestClient.ts"],"sourcesContent":["import {\n type AuthStatusResponse,\n type CreateAuthorizationRequest,\n createAuthorizationRequestToPayload,\n type CreateAuthorizationResponse,\n createAuthorizationResponseFromPayload,\n RequestUriMethod,\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(\n createAuthorizationRequestToPayload({ ...args, requestUriMethod: RequestUriMethod.GET } satisfies CreateAuthorizationRequest),\n ),\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,wCACAC,wBACK;AACP,SAASC,eAAe;AAExB,SAASC,aAAa;AAUtB,IAAMC,SAASC,QAAQC,QAAQC,IAAI,+CAAA;AAK5B,IAAMC,2BAAN,MAAMA;EAzBb,OAyBaA;;;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,UAA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KAAKC,UACTC,oCAAoC;QAAE,GAAGzB;QAAM0B,kBAAkBC,iBAAiBC;MAAI,CAAA,CAAA;IAE1F,CAAA;AACA,WAAOC,uCAAuC,MAAMR,aAAaH,KAAI,CAAA;EACvE;EAEQN,YAAYkB,MAAchC,SAA0B;AAC1D,QAAI,CAAC,KAAKA,WAAW,CAACA,SAAS;AAC7B,YAAM,IAAIU,MAAM,6BAAA;IAClB;AACA,WAAOV,UAAU,GAAGA,OAAAA,GAAUgC,KAAKC,WAAW,GAAA,IAAOD,OAAO,MAAMA,IAAAA,KAAS,GAAG,KAAKhC,OAAO,GAAGgC,KAAKC,WAAW,GAAA,IAAOD,OAAO,MAAMA,IAAAA;EACnI;EAEQpB,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","RequestUriMethod","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","RequestUriMethod","GET","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-feature.SSISDK.57.uni.client.
|
|
4
|
+
"version": "0.34.1-feature.SSISDK.57.uni.client.169+6401d3e9",
|
|
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-feature.SSISDK.57.uni.client.
|
|
31
|
-
"@sphereon/ssi-types": "0.34.1-feature.SSISDK.57.uni.client.
|
|
30
|
+
"@sphereon/ssi-sdk.siopv2-oid4vp-common": "0.34.1-feature.SSISDK.57.uni.client.169+6401d3e9",
|
|
31
|
+
"@sphereon/ssi-types": "0.34.1-feature.SSISDK.57.uni.client.169+6401d3e9",
|
|
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": "6401d3e9674ee70ca653677f51449e75b1dde671"
|
|
57
57
|
}
|
|
@@ -4,6 +4,7 @@ import {
|
|
|
4
4
|
createAuthorizationRequestToPayload,
|
|
5
5
|
type CreateAuthorizationResponse,
|
|
6
6
|
createAuthorizationResponseFromPayload,
|
|
7
|
+
RequestUriMethod,
|
|
7
8
|
} from '@sphereon/ssi-sdk.siopv2-oid4vp-common'
|
|
8
9
|
import { Loggers } from '@sphereon/ssi-types'
|
|
9
10
|
import { IAgentPlugin } from '@veramo/core'
|
|
@@ -84,7 +85,9 @@ export class SIOPv2OID4VPRPRestClient implements IAgentPlugin {
|
|
|
84
85
|
const origResponse = await fetch(url, {
|
|
85
86
|
method: 'POST',
|
|
86
87
|
headers: await this.createHeaders({ 'Content-Type': 'application/json' }),
|
|
87
|
-
body: JSON.stringify(
|
|
88
|
+
body: JSON.stringify(
|
|
89
|
+
createAuthorizationRequestToPayload({ ...args, requestUriMethod: RequestUriMethod.GET } satisfies CreateAuthorizationRequest),
|
|
90
|
+
),
|
|
88
91
|
})
|
|
89
92
|
return createAuthorizationResponseFromPayload(await origResponse.json())
|
|
90
93
|
}
|
|
@@ -12,7 +12,6 @@ export interface ISIOPv2OID4VPRPRestClient extends IPluginMethodMap {
|
|
|
12
12
|
|
|
13
13
|
export type ISiopClientGenerateAuthRequestArgs = Omit<CreateAuthorizationRequest, 'requestUriMethod'> & {
|
|
14
14
|
baseUrl?: string
|
|
15
|
-
requestUriMethod: 'get'
|
|
16
15
|
}
|
|
17
16
|
|
|
18
17
|
export interface ISiopClientRemoveAuthRequestSessionArgs {
|
|
@@ -33,7 +32,6 @@ export interface Siopv2RestClientAuthenticationOpts {
|
|
|
33
32
|
|
|
34
33
|
export interface Siopv2RestClientOpts {
|
|
35
34
|
baseUrl?: string
|
|
36
|
-
queryId?: string
|
|
37
35
|
authentication?: Siopv2RestClientAuthenticationOpts
|
|
38
36
|
}
|
|
39
37
|
|