@sphereon/ssi-sdk.oid4vci-issuer-rest-client 0.34.1-next.91 → 0.36.0
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 +19 -26
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +7 -24
- package/dist/index.js.map +1 -1
- package/package.json +5 -5
- package/plugin.schema.json +7 -24
- package/src/agent/OID4VCIRestClient.ts +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __create = Object.create;
|
|
2
3
|
var __defProp = Object.defineProperty;
|
|
3
4
|
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
5
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
6
|
+
var __getProtoOf = Object.getPrototypeOf;
|
|
5
7
|
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
8
|
var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
|
|
7
9
|
var __commonJS = (cb, mod) => function __require() {
|
|
@@ -19,6 +21,14 @@ var __copyProps = (to, from, except, desc) => {
|
|
|
19
21
|
}
|
|
20
22
|
return to;
|
|
21
23
|
};
|
|
24
|
+
var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
|
|
25
|
+
// If the importer is in node compatibility mode or this is not an ESM
|
|
26
|
+
// file that has been converted to a CommonJS file using a Babel-
|
|
27
|
+
// compatible transform (i.e. "__esModule" has not been set), then set
|
|
28
|
+
// "default" to the CommonJS "module.exports" for node compatibility.
|
|
29
|
+
isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
|
|
30
|
+
mod
|
|
31
|
+
));
|
|
22
32
|
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
23
33
|
|
|
24
34
|
// plugin.schema.json
|
|
@@ -58,10 +68,7 @@ var require_plugin_schema = __commonJS({
|
|
|
58
68
|
}
|
|
59
69
|
},
|
|
60
70
|
additionalProperties: false,
|
|
61
|
-
required: [
|
|
62
|
-
"credential_configuration_ids",
|
|
63
|
-
"credential_issuer"
|
|
64
|
-
]
|
|
71
|
+
required: ["credential_configuration_ids", "credential_issuer"]
|
|
65
72
|
},
|
|
66
73
|
Grant: {
|
|
67
74
|
type: "object",
|
|
@@ -113,9 +120,7 @@ var require_plugin_schema = __commonJS({
|
|
|
113
120
|
description: "OPTIONAL. Boolean value specifying whether the AS expects presentation of the End-User PIN along with the Token Request in a Pre-Authorized Code Flow. Default is false. This PIN is intended to bind the Pre-Authorized Code to a certain transaction to prevent replay of this code by an attacker that, for example, scanned the QR code while standing behind the legitimate End-User. It is RECOMMENDED to send a PIN via a separate channel. If the Wallet decides to use the Pre-Authorized Code Flow, a PIN value MUST be sent in the user_pin parameter with the respective Token Request."
|
|
114
121
|
}
|
|
115
122
|
},
|
|
116
|
-
required: [
|
|
117
|
-
"pre-authorized_code"
|
|
118
|
-
],
|
|
123
|
+
required: ["pre-authorized_code"],
|
|
119
124
|
additionalProperties: false
|
|
120
125
|
},
|
|
121
126
|
TxCode: {
|
|
@@ -138,10 +143,7 @@ var require_plugin_schema = __commonJS({
|
|
|
138
143
|
},
|
|
139
144
|
InputCharSet: {
|
|
140
145
|
type: "string",
|
|
141
|
-
enum: [
|
|
142
|
-
"numeric",
|
|
143
|
-
"text"
|
|
144
|
-
]
|
|
146
|
+
enum: ["numeric", "text"]
|
|
145
147
|
},
|
|
146
148
|
CredentialDataSupplierInput: {
|
|
147
149
|
description: "Optional storage that can help the credential Data Supplier. For instance to store credential input data during offer creation, if no additional data can be supplied later on"
|
|
@@ -171,10 +173,7 @@ var require_plugin_schema = __commonJS({
|
|
|
171
173
|
$ref: "#/components/schemas/TxCode"
|
|
172
174
|
}
|
|
173
175
|
},
|
|
174
|
-
required: [
|
|
175
|
-
"uri",
|
|
176
|
-
"correlationId"
|
|
177
|
-
],
|
|
176
|
+
required: ["uri", "correlationId"],
|
|
178
177
|
additionalProperties: false
|
|
179
178
|
},
|
|
180
179
|
IOID4VCIClientGetIssueStatusArgs: {
|
|
@@ -187,9 +186,7 @@ var require_plugin_schema = __commonJS({
|
|
|
187
186
|
type: "string"
|
|
188
187
|
}
|
|
189
188
|
},
|
|
190
|
-
required: [
|
|
191
|
-
"id"
|
|
192
|
-
],
|
|
189
|
+
required: ["id"],
|
|
193
190
|
additionalProperties: false
|
|
194
191
|
},
|
|
195
192
|
IssueStatusResponse: {
|
|
@@ -220,11 +217,7 @@ var require_plugin_schema = __commonJS({
|
|
|
220
217
|
}
|
|
221
218
|
}
|
|
222
219
|
},
|
|
223
|
-
required: [
|
|
224
|
-
"createdAt",
|
|
225
|
-
"lastUpdatedAt",
|
|
226
|
-
"status"
|
|
227
|
-
],
|
|
220
|
+
required: ["createdAt", "lastUpdatedAt", "status"],
|
|
228
221
|
additionalProperties: false
|
|
229
222
|
},
|
|
230
223
|
IssueStatus: {
|
|
@@ -295,7 +288,7 @@ __export(index_exports, {
|
|
|
295
288
|
module.exports = __toCommonJS(index_exports);
|
|
296
289
|
|
|
297
290
|
// src/agent/OID4VCIRestClient.ts
|
|
298
|
-
var import_cross_fetch = require("cross-fetch");
|
|
291
|
+
var import_cross_fetch = __toESM(require("cross-fetch"), 1);
|
|
299
292
|
var import_ssi_types = require("@sphereon/ssi-types");
|
|
300
293
|
var logger = import_ssi_types.Loggers.DEFAULT.get("sphereon:ssi-sdk:oid4vci:issuer:rest-client");
|
|
301
294
|
var OID4VCIRestClient = class _OID4VCIRestClient {
|
|
@@ -343,7 +336,7 @@ var OID4VCIRestClient = class _OID4VCIRestClient {
|
|
|
343
336
|
const url = _OID4VCIRestClient.urlWithBase(`webapp/credential-offers`, baseUrl);
|
|
344
337
|
logger.debug(`OID4VCIRestClient is going to send request: ${JSON.stringify(request)} to ${url}`);
|
|
345
338
|
try {
|
|
346
|
-
const origResponse = await (0, import_cross_fetch.
|
|
339
|
+
const origResponse = await (0, import_cross_fetch.default)(url, {
|
|
347
340
|
method: "POST",
|
|
348
341
|
headers: await this.createHeaders({
|
|
349
342
|
"Content-Type": "application/json"
|
|
@@ -362,7 +355,7 @@ var OID4VCIRestClient = class _OID4VCIRestClient {
|
|
|
362
355
|
async oid4vciClientGetIssueStatus(args) {
|
|
363
356
|
const baseUrl = this.assertedAgentBaseUrl(args.baseUrl);
|
|
364
357
|
const url = _OID4VCIRestClient.urlWithBase("/webapp/credential-offer-status", baseUrl);
|
|
365
|
-
const statusResponse = await (0, import_cross_fetch.
|
|
358
|
+
const statusResponse = await (0, import_cross_fetch.default)(url, {
|
|
366
359
|
method: "POST",
|
|
367
360
|
headers: await this.createHeaders({
|
|
368
361
|
"Content-Type": "application/json"
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../plugin.schema.json","../src/index.ts","../src/agent/OID4VCIRestClient.ts"],"sourcesContent":["{\n \"IOID4VCIRestClient\": {\n \"components\": {\n \"schemas\": {\n \"IOID4VCIClientCreateOfferUriRequestArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"credential_issuer\": {\n \"type\": \"string\",\n \"description\": \"REQUIRED. The URL of the Credential Issuer, as defined in Section 11.2.1, from which the Wallet is requested to obtain one or more Credentials. The Wallet uses it to obtain the Credential Issuer's Metadata following the steps defined in Section 11.2.2.\"\n },\n \"credential_configuration_ids\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n },\n \"description\": \"REQUIRED. Array of unique strings that each identify one of the keys in the name/value pairs stored in the credential_configurations_supported Credential Issuer metadata. The Wallet uses these string values to obtain the respective object that contains information about the Credential being offered as defined in Section 11.2.3. For example, these string values can be used to obtain scope values to be used in the Authorization Request.\"\n },\n \"grants\": {\n \"$ref\": \"#/components/schemas/Grant\",\n \"description\": \"OPTIONAL. Object indicating to the Wallet the Grant Types the Credential Issuer's Authorization Server is prepared to process for this Credential Offer. Every grant is represented by a name/value pair. The name is the Grant Type identifier; the value is an object that contains parameters either determining the way the Wallet MUST use the particular grant and/or parameters the Wallet MUST send with the respective request(s). If grants is not present or is empty, the Wallet MUST determine the Grant Types the Credential Issuer's Authorization Server supports using the respective metadata. When multiple grants are present, it is at the Wallet's discretion which one to use.\"\n },\n \"client_id\": {\n \"type\": \"string\",\n \"description\": \"OPTIONAL. Some implementations might include a client_id in the offer. For instance EBSI in a same-device flow. (Cross-device tucks it in the state JWT)\"\n },\n \"credentialDataSupplierInput\": {\n \"$ref\": \"#/components/schemas/CredentialDataSupplierInput\"\n },\n \"agentBaseUrl\": {\n \"type\": \"string\"\n }\n },\n \"additionalProperties\": false,\n \"required\": [\n \"credential_configuration_ids\",\n \"credential_issuer\"\n ]\n },\n \"Grant\": {\n \"type\": \"object\",\n \"properties\": {\n \"authorization_code\": {\n \"$ref\": \"#/components/schemas/GrantAuthorizationCode\"\n },\n \"urn:ietf:params:oauth:grant-type:pre-authorized_code\": {\n \"$ref\": \"#/components/schemas/GrantUrnIetf\"\n }\n },\n \"additionalProperties\": false\n },\n \"GrantAuthorizationCode\": {\n \"type\": \"object\",\n \"properties\": {\n \"issuer_state\": {\n \"type\": \"string\",\n \"description\": \"OPTIONAL. String value created by the Credential Issuer and opaque to the Wallet that is used to bind the subsequent Authorization Request with the Credential Issuer to a context set up during previous steps.\"\n },\n \"authorization_server\": {\n \"type\": \"string\",\n \"description\": \"OPTIONAL string that the Wallet can use to identify the Authorization Server to use with this grant type when authorization_servers parameter in the Credential Issuer metadata has multiple entries. MUST NOT be used otherwise. The value of this parameter MUST match with one of the values in the authorization_servers array obtained from the Credential Issuer metadata\"\n }\n },\n \"additionalProperties\": false\n },\n \"GrantUrnIetf\": {\n \"type\": \"object\",\n \"properties\": {\n \"pre-authorized_code\": {\n \"type\": \"string\",\n \"description\": \"REQUIRED. The code representing the Credential Issuer's authorization for the Wallet to obtain Credentials of a certain type.\"\n },\n \"tx_code\": {\n \"$ref\": \"#/components/schemas/TxCode\",\n \"description\": \"OPTIONAL. Object specifying whether the Authorization Server expects presentation of a Transaction Code by the End-User along with the Token Request in a Pre-Authorized Code Flow. If the Authorization Server does not expect a Transaction Code, this object is absent; this is the default. The Transaction Code is intended to bind the Pre-Authorized Code to a certain transaction to prevent replay of this code by an attacker that, for example, scanned the QR code while standing behind the legitimate End-User. It is RECOMMENDED to send the Transaction Code via a separate channel. If the Wallet decides to use the Pre-Authorized Code Flow, the Transaction Code value MUST be sent in the tx_code parameter with the respective Token Request as defined in Section 6.1. If no length or description is given, this object may be empty, indicating that a Transaction Code is required.\"\n },\n \"interval\": {\n \"type\": \"number\",\n \"description\": \"OPTIONAL. The minimum amount of time in seconds that the Wallet SHOULD wait between polling requests to the token endpoint (in case the Authorization Server responds with error code authorization_pending - see Section 6.3). If no value is provided, Wallets MUST use 5 as the default.\"\n },\n \"authorization_server\": {\n \"type\": \"string\",\n \"description\": \"OPTIONAL string that the Wallet can use to identify the Authorization Server to use with this grant type when authorization_servers parameter in the Credential Issuer metadata has multiple entries. MUST NOT be used otherwise. The value of this parameter MUST match with one of the values in the authorization_servers array obtained from the Credential Issuer metadata\"\n },\n \"user_pin_required\": {\n \"type\": \"boolean\",\n \"description\": \"OPTIONAL. Boolean value specifying whether the AS expects presentation of the End-User PIN along with the Token Request in a Pre-Authorized Code Flow. Default is false. This PIN is intended to bind the Pre-Authorized Code to a certain transaction to prevent replay of this code by an attacker that, for example, scanned the QR code while standing behind the legitimate End-User. It is RECOMMENDED to send a PIN via a separate channel. If the Wallet decides to use the Pre-Authorized Code Flow, a PIN value MUST be sent in the user_pin parameter with the respective Token Request.\"\n }\n },\n \"required\": [\n \"pre-authorized_code\"\n ],\n \"additionalProperties\": false\n },\n \"TxCode\": {\n \"type\": \"object\",\n \"properties\": {\n \"input_mode\": {\n \"$ref\": \"#/components/schemas/InputCharSet\",\n \"description\": \"OPTIONAL. String specifying the input character set. Possible values are numeric (only digits) and text (any characters). The default is numeric.\"\n },\n \"length\": {\n \"type\": \"number\",\n \"description\": \"OPTIONAL. Integer specifying the length of the Transaction Code. This helps the Wallet to render the input screen and improve the user experience.\"\n },\n \"description\": {\n \"type\": \"string\",\n \"description\": \"OPTIONAL. String containing guidance for the Holder of the Wallet on how to obtain the Transaction Code, e.g., describing over which communication channel it is delivered. The Wallet is RECOMMENDED to display this description next to the Transaction Code input screen to improve the user experience. The length of the string MUST NOT exceed 300 characters. The description does not support internationalization, however the Issuer MAY detect the Holder's language by previous communication or an HTTP Accept-Language header within an HTTP GET request for a Credential Offer URI.\"\n }\n },\n \"additionalProperties\": false\n },\n \"InputCharSet\": {\n \"type\": \"string\",\n \"enum\": [\n \"numeric\",\n \"text\"\n ]\n },\n \"CredentialDataSupplierInput\": {\n \"description\": \"Optional storage that can help the credential Data Supplier. For instance to store credential input data during offer creation, if no additional data can be supplied later on\"\n },\n \"IOID4VCIClientCreateOfferUriResponse\": {\n \"$ref\": \"#/components/schemas/Omit<CreateCredentialOfferURIResult,\\\"session\\\">\"\n },\n \"Omit<CreateCredentialOfferURIResult,\\\"session\\\">\": {\n \"$ref\": \"#/components/schemas/Pick<CreateCredentialOfferURIResult,Exclude<(\\\"uri\\\"|\\\"correlationId\\\"|\\\"qrCodeDataUri\\\"|\\\"session\\\"|\\\"userPin\\\"|\\\"txCode\\\"),\\\"session\\\">>\"\n },\n \"Pick<CreateCredentialOfferURIResult,Exclude<(\\\"uri\\\"|\\\"correlationId\\\"|\\\"qrCodeDataUri\\\"|\\\"session\\\"|\\\"userPin\\\"|\\\"txCode\\\"),\\\"session\\\">>\": {\n \"type\": \"object\",\n \"properties\": {\n \"uri\": {\n \"type\": \"string\"\n },\n \"correlationId\": {\n \"type\": \"string\"\n },\n \"qrCodeDataUri\": {\n \"type\": \"string\"\n },\n \"userPin\": {\n \"type\": \"string\"\n },\n \"txCode\": {\n \"$ref\": \"#/components/schemas/TxCode\"\n }\n },\n \"required\": [\n \"uri\",\n \"correlationId\"\n ],\n \"additionalProperties\": false\n },\n \"IOID4VCIClientGetIssueStatusArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"baseUrl\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"id\"\n ],\n \"additionalProperties\": false\n },\n \"IssueStatusResponse\": {\n \"type\": \"object\",\n \"properties\": {\n \"createdAt\": {\n \"type\": \"number\"\n },\n \"lastUpdatedAt\": {\n \"type\": \"number\"\n },\n \"expiresAt\": {\n \"type\": \"number\"\n },\n \"status\": {\n \"$ref\": \"#/components/schemas/IssueStatus\"\n },\n \"error\": {\n \"type\": \"string\"\n },\n \"clientId\": {\n \"type\": \"string\"\n },\n \"statusLists\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/StatusListOpts\"\n }\n }\n },\n \"required\": [\n \"createdAt\",\n \"lastUpdatedAt\",\n \"status\"\n ],\n \"additionalProperties\": false\n },\n \"IssueStatus\": {\n \"type\": \"string\",\n \"enum\": [\n \"OFFER_CREATED\",\n \"ACCESS_TOKEN_REQUESTED\",\n \"ACCESS_TOKEN_CREATED\",\n \"CREDENTIAL_REQUEST_RECEIVED\",\n \"CREDENTIAL_ISSUED\",\n \"NOTIFICATION_CREDENTIAL_ACCEPTED\",\n \"NOTIFICATION_CREDENTIAL_DELETED\",\n \"NOTIFICATION_CREDENTIAL_FAILURE\",\n \"ERROR\"\n ]\n },\n \"StatusListOpts\": {\n \"type\": \"object\",\n \"properties\": {\n \"statusListId\": {\n \"type\": \"string\"\n },\n \"statusListCorrelationId\": {\n \"type\": \"string\"\n },\n \"statusListIndex\": {\n \"type\": \"number\"\n },\n \"statusEntryCorrelationId\": {\n \"type\": \"string\"\n }\n },\n \"additionalProperties\": false\n }\n },\n \"methods\": {\n \"oid4vciClientCreateOfferUri\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IOID4VCIClientCreateOfferUriRequestArgs\"\n },\n \"returnType\": {\n \"$ref\": \"#/components/schemas/IOID4VCIClientCreateOfferUriResponse\"\n }\n },\n \"oid4vciClientGetIssueStatus\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IOID4VCIClientGetIssueStatusArgs\"\n },\n \"returnType\": {\n \"$ref\": \"#/components/schemas/IssueStatusResponse\"\n }\n }\n }\n }\n }\n}","/**\n * @public\n */\nconst schema = require('../plugin.schema.json')\nexport { schema }\nexport { OID4VCIRestClient } from './agent/OID4VCIRestClient'\nexport type * from './types/IOID4VCIRestClient'\n","import { fetch } from 'cross-fetch'\nimport {\n IOID4VCIRestClient,\n IOID4VCIClientCreateOfferUriRequest,\n IOID4VCIClientCreateOfferUriRequestArgs,\n IOID4VCIClientCreateOfferUriResponse,\n IOID4VCIClientGetIssueStatusArgs,\n IRestClientAuthenticationOpts,\n} from '../types/IOID4VCIRestClient'\nimport { IssueStatusResponse } from '@sphereon/oid4vci-common'\nimport { IAgentPlugin } from '@veramo/core'\nimport { Loggers } from '@sphereon/ssi-types'\n\nconst logger = Loggers.DEFAULT.get('sphereon:ssi-sdk:oid4vci:issuer:rest-client')\n\n/**\n * {@inheritDoc IOID4VCIRestClient}\n */\nexport class OID4VCIRestClient implements IAgentPlugin {\n readonly methods: IOID4VCIRestClient = {\n oid4vciClientCreateOfferUri: this.oid4vciClientCreateOfferUri.bind(this),\n oid4vciClientGetIssueStatus: this.oid4vciClientGetIssueStatus.bind(this),\n }\n\n private readonly agentBaseUrl?: string\n private readonly authOpts?: IRestClientAuthenticationOpts\n\n constructor(args?: { baseUrl?: string; authentication?: IRestClientAuthenticationOpts }) {\n if (args?.baseUrl) {\n this.agentBaseUrl = args.baseUrl\n }\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 /** {@inheritDoc IOID4VCIRestClient.vciClientCreateOfferUri} */\n private async oid4vciClientCreateOfferUri(args: IOID4VCIClientCreateOfferUriRequestArgs): Promise<IOID4VCIClientCreateOfferUriResponse> {\n if (!args.credential_configuration_ids || !args.grants) {\n return Promise.reject(Error(\"Can't generate the credential offer url without credentials and grants params present.\"))\n }\n const baseUrl = this.assertedAgentBaseUrl(args.agentBaseUrl)\n const request: IOID4VCIClientCreateOfferUriRequest = {\n credential_configuration_ids: args.credential_configuration_ids,\n grants: args.grants,\n ...(args.credentialDataSupplierInput && { credentialDataSupplierInput: args.credentialDataSupplierInput }),\n }\n const url = OID4VCIRestClient.urlWithBase(`webapp/credential-offers`, baseUrl)\n logger.debug(`OID4VCIRestClient is going to send request: ${JSON.stringify(request)} to ${url}`)\n try {\n const origResponse = await fetch(url, {\n method: 'POST',\n headers: await this.createHeaders({ 'Content-Type': 'application/json' }),\n body: JSON.stringify(request),\n })\n if (!origResponse.ok) {\n return Promise.reject(Error(`request to ${url} returned ${origResponse.status}`))\n }\n return await origResponse.json()\n } catch (e) {\n logger.debug(`Error on posting to url ${url}: ${e}`)\n return Promise.reject(Error(`request to ${url} returned ${e}`))\n }\n }\n\n private async oid4vciClientGetIssueStatus(args: IOID4VCIClientGetIssueStatusArgs): Promise<IssueStatusResponse> {\n const baseUrl = this.assertedAgentBaseUrl(args.baseUrl)\n const url = OID4VCIRestClient.urlWithBase('/webapp/credential-offer-status', baseUrl)\n const statusResponse = await fetch(url, {\n method: 'POST',\n headers: await this.createHeaders({ 'Content-Type': 'application/json' }),\n body: JSON.stringify({\n id: args.id,\n }),\n })\n logger.debug(`issue 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 assertedAgentBaseUrl(baseUrl?: string): string {\n if (baseUrl) {\n return baseUrl\n } else if (this.agentBaseUrl) {\n return this.agentBaseUrl\n }\n throw new Error('No base url has been provided')\n }\n\n private static urlWithBase(path: string, baseUrl: string): string {\n return `${baseUrl}${path.startsWith('/') ? path : `/${path}`}`\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,gCAAAA,SAAA;AAAA,IAAAA,QAAA;AAAA,MACE,oBAAsB;AAAA,QACpB,YAAc;AAAA,UACZ,SAAW;AAAA,YACT,yCAA2C;AAAA,cACzC,MAAQ;AAAA,cACR,YAAc;AAAA,gBACZ,mBAAqB;AAAA,kBACnB,MAAQ;AAAA,kBACR,aAAe;AAAA,gBACjB;AAAA,gBACA,8BAAgC;AAAA,kBAC9B,MAAQ;AAAA,kBACR,OAAS;AAAA,oBACP,MAAQ;AAAA,kBACV;AAAA,kBACA,aAAe;AAAA,gBACjB;AAAA,gBACA,QAAU;AAAA,kBACR,MAAQ;AAAA,kBACR,aAAe;AAAA,gBACjB;AAAA,gBACA,WAAa;AAAA,kBACX,MAAQ;AAAA,kBACR,aAAe;AAAA,gBACjB;AAAA,gBACA,6BAA+B;AAAA,kBAC7B,MAAQ;AAAA,gBACV;AAAA,gBACA,cAAgB;AAAA,kBACd,MAAQ;AAAA,gBACV;AAAA,cACF;AAAA,cACA,sBAAwB;AAAA,cACxB,UAAY;AAAA,gBACV;AAAA,gBACA;AAAA,cACF;AAAA,YACF;AAAA,YACA,OAAS;AAAA,cACP,MAAQ;AAAA,cACR,YAAc;AAAA,gBACZ,oBAAsB;AAAA,kBACpB,MAAQ;AAAA,gBACV;AAAA,gBACA,wDAAwD;AAAA,kBACtD,MAAQ;AAAA,gBACV;AAAA,cACF;AAAA,cACA,sBAAwB;AAAA,YAC1B;AAAA,YACA,wBAA0B;AAAA,cACxB,MAAQ;AAAA,cACR,YAAc;AAAA,gBACZ,cAAgB;AAAA,kBACd,MAAQ;AAAA,kBACR,aAAe;AAAA,gBACjB;AAAA,gBACA,sBAAwB;A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AAKc,qBAAqBf,KAAKC,OAAO;AACtD,UAAMiB,MAAMzB,mBAAkB0B,YAAY,mCAAmClB,OAAAA;AAC7E,UAAM8B,iBAAiB,UAAMP,0BAAMN,KAAK;MACtCO,QAAQ;MACRpB,SAAS,MAAM,KAAKF,cAAc;QAAE,gBAAgB;MAAmB,CAAA;MACvEuB,MAAML,KAAKC,UAAU;QACnBU,IAAIhC,KAAKgC;MACX,CAAA;IACF,CAAA;AACA3C,WAAO+B,MAAM,0BAA0BW,cAAAA,EAAgB;AACvD,QAAI;AACF,aAAO,MAAMA,eAAeF,KAAI;IAClC,SAASI,KAAK;AACZ,YAAMxB,MAAM,uBAAuBsB,eAAeH,MAAM,EAAE;IAC5D;EACF;EAEQb,qBAAqBd,SAA0B;AACrD,QAAIA,SAAS;AACX,aAAOA;IACT,WAAW,KAAKH,cAAc;AAC5B,aAAO,KAAKA;IACd;AACA,UAAM,IAAIW,MAAM,+BAAA;EAClB;EAEA,OAAeU,YAAYe,MAAcjC,SAAyB;AAChE,WAAO,GAAGA,OAAAA,GAAUiC,KAAKC,WAAW,GAAA,IAAOD,OAAO,IAAIA,IAAAA,EAAM;EAC9D;AACF;;;AD1GA,IAAME,SAASC;","names":["module","logger","Loggers","DEFAULT","get","OID4VCIRestClient","methods","oid4vciClientCreateOfferUri","bind","oid4vciClientGetIssueStatus","agentBaseUrl","authOpts","args","baseUrl","authentication","createHeaders","existing","headers","Accept","enabled","bearerToken","Error","Authorization","credential_configuration_ids","grants","Promise","reject","assertedAgentBaseUrl","request","credentialDataSupplierInput","url","urlWithBase","debug","JSON","stringify","origResponse","fetch","method","body","ok","status","json","e","statusResponse","id","err","path","startsWith","schema","require"]}
|
|
1
|
+
{"version":3,"sources":["../plugin.schema.json","../src/index.ts","../src/agent/OID4VCIRestClient.ts"],"sourcesContent":["{\n \"IOID4VCIRestClient\": {\n \"components\": {\n \"schemas\": {\n \"IOID4VCIClientCreateOfferUriRequestArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"credential_issuer\": {\n \"type\": \"string\",\n \"description\": \"REQUIRED. The URL of the Credential Issuer, as defined in Section 11.2.1, from which the Wallet is requested to obtain one or more Credentials. The Wallet uses it to obtain the Credential Issuer's Metadata following the steps defined in Section 11.2.2.\"\n },\n \"credential_configuration_ids\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n },\n \"description\": \"REQUIRED. Array of unique strings that each identify one of the keys in the name/value pairs stored in the credential_configurations_supported Credential Issuer metadata. The Wallet uses these string values to obtain the respective object that contains information about the Credential being offered as defined in Section 11.2.3. For example, these string values can be used to obtain scope values to be used in the Authorization Request.\"\n },\n \"grants\": {\n \"$ref\": \"#/components/schemas/Grant\",\n \"description\": \"OPTIONAL. Object indicating to the Wallet the Grant Types the Credential Issuer's Authorization Server is prepared to process for this Credential Offer. Every grant is represented by a name/value pair. The name is the Grant Type identifier; the value is an object that contains parameters either determining the way the Wallet MUST use the particular grant and/or parameters the Wallet MUST send with the respective request(s). If grants is not present or is empty, the Wallet MUST determine the Grant Types the Credential Issuer's Authorization Server supports using the respective metadata. When multiple grants are present, it is at the Wallet's discretion which one to use.\"\n },\n \"client_id\": {\n \"type\": \"string\",\n \"description\": \"OPTIONAL. Some implementations might include a client_id in the offer. For instance EBSI in a same-device flow. (Cross-device tucks it in the state JWT)\"\n },\n \"credentialDataSupplierInput\": {\n \"$ref\": \"#/components/schemas/CredentialDataSupplierInput\"\n },\n \"agentBaseUrl\": {\n \"type\": \"string\"\n }\n },\n \"additionalProperties\": false,\n \"required\": [\"credential_configuration_ids\", \"credential_issuer\"]\n },\n \"Grant\": {\n \"type\": \"object\",\n \"properties\": {\n \"authorization_code\": {\n \"$ref\": \"#/components/schemas/GrantAuthorizationCode\"\n },\n \"urn:ietf:params:oauth:grant-type:pre-authorized_code\": {\n \"$ref\": \"#/components/schemas/GrantUrnIetf\"\n }\n },\n \"additionalProperties\": false\n },\n \"GrantAuthorizationCode\": {\n \"type\": \"object\",\n \"properties\": {\n \"issuer_state\": {\n \"type\": \"string\",\n \"description\": \"OPTIONAL. String value created by the Credential Issuer and opaque to the Wallet that is used to bind the subsequent Authorization Request with the Credential Issuer to a context set up during previous steps.\"\n },\n \"authorization_server\": {\n \"type\": \"string\",\n \"description\": \"OPTIONAL string that the Wallet can use to identify the Authorization Server to use with this grant type when authorization_servers parameter in the Credential Issuer metadata has multiple entries. MUST NOT be used otherwise. The value of this parameter MUST match with one of the values in the authorization_servers array obtained from the Credential Issuer metadata\"\n }\n },\n \"additionalProperties\": false\n },\n \"GrantUrnIetf\": {\n \"type\": \"object\",\n \"properties\": {\n \"pre-authorized_code\": {\n \"type\": \"string\",\n \"description\": \"REQUIRED. The code representing the Credential Issuer's authorization for the Wallet to obtain Credentials of a certain type.\"\n },\n \"tx_code\": {\n \"$ref\": \"#/components/schemas/TxCode\",\n \"description\": \"OPTIONAL. Object specifying whether the Authorization Server expects presentation of a Transaction Code by the End-User along with the Token Request in a Pre-Authorized Code Flow. If the Authorization Server does not expect a Transaction Code, this object is absent; this is the default. The Transaction Code is intended to bind the Pre-Authorized Code to a certain transaction to prevent replay of this code by an attacker that, for example, scanned the QR code while standing behind the legitimate End-User. It is RECOMMENDED to send the Transaction Code via a separate channel. If the Wallet decides to use the Pre-Authorized Code Flow, the Transaction Code value MUST be sent in the tx_code parameter with the respective Token Request as defined in Section 6.1. If no length or description is given, this object may be empty, indicating that a Transaction Code is required.\"\n },\n \"interval\": {\n \"type\": \"number\",\n \"description\": \"OPTIONAL. The minimum amount of time in seconds that the Wallet SHOULD wait between polling requests to the token endpoint (in case the Authorization Server responds with error code authorization_pending - see Section 6.3). If no value is provided, Wallets MUST use 5 as the default.\"\n },\n \"authorization_server\": {\n \"type\": \"string\",\n \"description\": \"OPTIONAL string that the Wallet can use to identify the Authorization Server to use with this grant type when authorization_servers parameter in the Credential Issuer metadata has multiple entries. MUST NOT be used otherwise. The value of this parameter MUST match with one of the values in the authorization_servers array obtained from the Credential Issuer metadata\"\n },\n \"user_pin_required\": {\n \"type\": \"boolean\",\n \"description\": \"OPTIONAL. Boolean value specifying whether the AS expects presentation of the End-User PIN along with the Token Request in a Pre-Authorized Code Flow. Default is false. This PIN is intended to bind the Pre-Authorized Code to a certain transaction to prevent replay of this code by an attacker that, for example, scanned the QR code while standing behind the legitimate End-User. It is RECOMMENDED to send a PIN via a separate channel. If the Wallet decides to use the Pre-Authorized Code Flow, a PIN value MUST be sent in the user_pin parameter with the respective Token Request.\"\n }\n },\n \"required\": [\"pre-authorized_code\"],\n \"additionalProperties\": false\n },\n \"TxCode\": {\n \"type\": \"object\",\n \"properties\": {\n \"input_mode\": {\n \"$ref\": \"#/components/schemas/InputCharSet\",\n \"description\": \"OPTIONAL. String specifying the input character set. Possible values are numeric (only digits) and text (any characters). The default is numeric.\"\n },\n \"length\": {\n \"type\": \"number\",\n \"description\": \"OPTIONAL. Integer specifying the length of the Transaction Code. This helps the Wallet to render the input screen and improve the user experience.\"\n },\n \"description\": {\n \"type\": \"string\",\n \"description\": \"OPTIONAL. String containing guidance for the Holder of the Wallet on how to obtain the Transaction Code, e.g., describing over which communication channel it is delivered. The Wallet is RECOMMENDED to display this description next to the Transaction Code input screen to improve the user experience. The length of the string MUST NOT exceed 300 characters. The description does not support internationalization, however the Issuer MAY detect the Holder's language by previous communication or an HTTP Accept-Language header within an HTTP GET request for a Credential Offer URI.\"\n }\n },\n \"additionalProperties\": false\n },\n \"InputCharSet\": {\n \"type\": \"string\",\n \"enum\": [\"numeric\", \"text\"]\n },\n \"CredentialDataSupplierInput\": {\n \"description\": \"Optional storage that can help the credential Data Supplier. For instance to store credential input data during offer creation, if no additional data can be supplied later on\"\n },\n \"IOID4VCIClientCreateOfferUriResponse\": {\n \"$ref\": \"#/components/schemas/Omit<CreateCredentialOfferURIResult,\\\"session\\\">\"\n },\n \"Omit<CreateCredentialOfferURIResult,\\\"session\\\">\": {\n \"$ref\": \"#/components/schemas/Pick<CreateCredentialOfferURIResult,Exclude<(\\\"uri\\\"|\\\"correlationId\\\"|\\\"qrCodeDataUri\\\"|\\\"session\\\"|\\\"userPin\\\"|\\\"txCode\\\"),\\\"session\\\">>\"\n },\n \"Pick<CreateCredentialOfferURIResult,Exclude<(\\\"uri\\\"|\\\"correlationId\\\"|\\\"qrCodeDataUri\\\"|\\\"session\\\"|\\\"userPin\\\"|\\\"txCode\\\"),\\\"session\\\">>\": {\n \"type\": \"object\",\n \"properties\": {\n \"uri\": {\n \"type\": \"string\"\n },\n \"correlationId\": {\n \"type\": \"string\"\n },\n \"qrCodeDataUri\": {\n \"type\": \"string\"\n },\n \"userPin\": {\n \"type\": \"string\"\n },\n \"txCode\": {\n \"$ref\": \"#/components/schemas/TxCode\"\n }\n },\n \"required\": [\"uri\", \"correlationId\"],\n \"additionalProperties\": false\n },\n \"IOID4VCIClientGetIssueStatusArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"baseUrl\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\"id\"],\n \"additionalProperties\": false\n },\n \"IssueStatusResponse\": {\n \"type\": \"object\",\n \"properties\": {\n \"createdAt\": {\n \"type\": \"number\"\n },\n \"lastUpdatedAt\": {\n \"type\": \"number\"\n },\n \"expiresAt\": {\n \"type\": \"number\"\n },\n \"status\": {\n \"$ref\": \"#/components/schemas/IssueStatus\"\n },\n \"error\": {\n \"type\": \"string\"\n },\n \"clientId\": {\n \"type\": \"string\"\n },\n \"statusLists\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/StatusListOpts\"\n }\n }\n },\n \"required\": [\"createdAt\", \"lastUpdatedAt\", \"status\"],\n \"additionalProperties\": false\n },\n \"IssueStatus\": {\n \"type\": \"string\",\n \"enum\": [\n \"OFFER_CREATED\",\n \"ACCESS_TOKEN_REQUESTED\",\n \"ACCESS_TOKEN_CREATED\",\n \"CREDENTIAL_REQUEST_RECEIVED\",\n \"CREDENTIAL_ISSUED\",\n \"NOTIFICATION_CREDENTIAL_ACCEPTED\",\n \"NOTIFICATION_CREDENTIAL_DELETED\",\n \"NOTIFICATION_CREDENTIAL_FAILURE\",\n \"ERROR\"\n ]\n },\n \"StatusListOpts\": {\n \"type\": \"object\",\n \"properties\": {\n \"statusListId\": {\n \"type\": \"string\"\n },\n \"statusListCorrelationId\": {\n \"type\": \"string\"\n },\n \"statusListIndex\": {\n \"type\": \"number\"\n },\n \"statusEntryCorrelationId\": {\n \"type\": \"string\"\n }\n },\n \"additionalProperties\": false\n }\n },\n \"methods\": {\n \"oid4vciClientCreateOfferUri\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IOID4VCIClientCreateOfferUriRequestArgs\"\n },\n \"returnType\": {\n \"$ref\": \"#/components/schemas/IOID4VCIClientCreateOfferUriResponse\"\n }\n },\n \"oid4vciClientGetIssueStatus\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IOID4VCIClientGetIssueStatusArgs\"\n },\n \"returnType\": {\n \"$ref\": \"#/components/schemas/IssueStatusResponse\"\n }\n }\n }\n }\n }\n}\n","/**\n * @public\n */\nconst schema = require('../plugin.schema.json')\nexport { schema }\nexport { OID4VCIRestClient } from './agent/OID4VCIRestClient'\nexport type * from './types/IOID4VCIRestClient'\n","import fetch from 'cross-fetch'\nimport {\n IOID4VCIRestClient,\n IOID4VCIClientCreateOfferUriRequest,\n IOID4VCIClientCreateOfferUriRequestArgs,\n IOID4VCIClientCreateOfferUriResponse,\n IOID4VCIClientGetIssueStatusArgs,\n IRestClientAuthenticationOpts,\n} from '../types/IOID4VCIRestClient'\nimport { IssueStatusResponse } from '@sphereon/oid4vci-common'\nimport { IAgentPlugin } from '@veramo/core'\nimport { Loggers } from '@sphereon/ssi-types'\n\nconst logger = Loggers.DEFAULT.get('sphereon:ssi-sdk:oid4vci:issuer:rest-client')\n\n/**\n * {@inheritDoc IOID4VCIRestClient}\n */\nexport class OID4VCIRestClient implements IAgentPlugin {\n readonly methods: IOID4VCIRestClient = {\n oid4vciClientCreateOfferUri: this.oid4vciClientCreateOfferUri.bind(this),\n oid4vciClientGetIssueStatus: this.oid4vciClientGetIssueStatus.bind(this),\n }\n\n private readonly agentBaseUrl?: string\n private readonly authOpts?: IRestClientAuthenticationOpts\n\n constructor(args?: { baseUrl?: string; authentication?: IRestClientAuthenticationOpts }) {\n if (args?.baseUrl) {\n this.agentBaseUrl = args.baseUrl\n }\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 /** {@inheritDoc IOID4VCIRestClient.vciClientCreateOfferUri} */\n private async oid4vciClientCreateOfferUri(args: IOID4VCIClientCreateOfferUriRequestArgs): Promise<IOID4VCIClientCreateOfferUriResponse> {\n if (!args.credential_configuration_ids || !args.grants) {\n return Promise.reject(Error(\"Can't generate the credential offer url without credentials and grants params present.\"))\n }\n const baseUrl = this.assertedAgentBaseUrl(args.agentBaseUrl)\n const request: IOID4VCIClientCreateOfferUriRequest = {\n credential_configuration_ids: args.credential_configuration_ids,\n grants: args.grants,\n ...(args.credentialDataSupplierInput && { credentialDataSupplierInput: args.credentialDataSupplierInput }),\n }\n const url = OID4VCIRestClient.urlWithBase(`webapp/credential-offers`, baseUrl)\n logger.debug(`OID4VCIRestClient is going to send request: ${JSON.stringify(request)} to ${url}`)\n try {\n const origResponse = await fetch(url, {\n method: 'POST',\n headers: await this.createHeaders({ 'Content-Type': 'application/json' }),\n body: JSON.stringify(request),\n })\n if (!origResponse.ok) {\n return Promise.reject(Error(`request to ${url} returned ${origResponse.status}`))\n }\n return await origResponse.json()\n } catch (e) {\n logger.debug(`Error on posting to url ${url}: ${e}`)\n return Promise.reject(Error(`request to ${url} returned ${e}`))\n }\n }\n\n private async oid4vciClientGetIssueStatus(args: IOID4VCIClientGetIssueStatusArgs): Promise<IssueStatusResponse> {\n const baseUrl = this.assertedAgentBaseUrl(args.baseUrl)\n const url = OID4VCIRestClient.urlWithBase('/webapp/credential-offer-status', baseUrl)\n const statusResponse = await fetch(url, {\n method: 'POST',\n headers: await this.createHeaders({ 'Content-Type': 'application/json' }),\n body: JSON.stringify({\n id: args.id,\n }),\n })\n logger.debug(`issue 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 assertedAgentBaseUrl(baseUrl?: string): string {\n if (baseUrl) {\n return baseUrl\n } else if (this.agentBaseUrl) {\n return this.agentBaseUrl\n }\n throw new Error('No base url has been provided')\n }\n\n private static urlWithBase(path: string, baseUrl: string): string {\n return `${baseUrl}${path.startsWith('/') ? path : `/${path}`}`\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,gCAAAA,SAAA;AAAA,IAAAA,QAAA;AAAA,MACE,oBAAsB;AAAA,QACpB,YAAc;AAAA,UACZ,SAAW;AAAA,YACT,yCAA2C;AAAA,cACzC,MAAQ;AAAA,cACR,YAAc;AAAA,gBACZ,mBAAqB;AAAA,kBACnB,MAAQ;AAAA,kBACR,aAAe;AAAA,gBACjB;AAAA,gBACA,8BAAgC;AAAA,kBAC9B,MAAQ;AAAA,kBACR,OAAS;AAAA,oBACP,MAAQ;AAAA,kBACV;AAAA,kBACA,aAAe;AAAA,gBACjB;AAAA,gBACA,QAAU;AAAA,kBACR,MAAQ;AAAA,kBACR,aAAe;AAAA,gBACjB;AAAA,gBACA,WAAa;AAAA,kBACX,MAAQ;AAAA,kBACR,aAAe;AAAA,gBACjB;AAAA,gBACA,6BAA+B;AAAA,kBAC7B,MAAQ;AAAA,gBACV;AAAA,gB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fferUri","bind","oid4vciClientGetIssueStatus","agentBaseUrl","authOpts","args","baseUrl","authentication","createHeaders","existing","headers","Accept","enabled","bearerToken","Error","Authorization","credential_configuration_ids","grants","Promise","reject","assertedAgentBaseUrl","request","credentialDataSupplierInput","url","urlWithBase","debug","JSON","stringify","origResponse","fetch","method","body","ok","status","json","e","statusResponse","id","err","path","startsWith","schema","require"]}
|
package/dist/index.js
CHANGED
|
@@ -42,10 +42,7 @@ var require_plugin_schema = __commonJS({
|
|
|
42
42
|
}
|
|
43
43
|
},
|
|
44
44
|
additionalProperties: false,
|
|
45
|
-
required: [
|
|
46
|
-
"credential_configuration_ids",
|
|
47
|
-
"credential_issuer"
|
|
48
|
-
]
|
|
45
|
+
required: ["credential_configuration_ids", "credential_issuer"]
|
|
49
46
|
},
|
|
50
47
|
Grant: {
|
|
51
48
|
type: "object",
|
|
@@ -97,9 +94,7 @@ var require_plugin_schema = __commonJS({
|
|
|
97
94
|
description: "OPTIONAL. Boolean value specifying whether the AS expects presentation of the End-User PIN along with the Token Request in a Pre-Authorized Code Flow. Default is false. This PIN is intended to bind the Pre-Authorized Code to a certain transaction to prevent replay of this code by an attacker that, for example, scanned the QR code while standing behind the legitimate End-User. It is RECOMMENDED to send a PIN via a separate channel. If the Wallet decides to use the Pre-Authorized Code Flow, a PIN value MUST be sent in the user_pin parameter with the respective Token Request."
|
|
98
95
|
}
|
|
99
96
|
},
|
|
100
|
-
required: [
|
|
101
|
-
"pre-authorized_code"
|
|
102
|
-
],
|
|
97
|
+
required: ["pre-authorized_code"],
|
|
103
98
|
additionalProperties: false
|
|
104
99
|
},
|
|
105
100
|
TxCode: {
|
|
@@ -122,10 +117,7 @@ var require_plugin_schema = __commonJS({
|
|
|
122
117
|
},
|
|
123
118
|
InputCharSet: {
|
|
124
119
|
type: "string",
|
|
125
|
-
enum: [
|
|
126
|
-
"numeric",
|
|
127
|
-
"text"
|
|
128
|
-
]
|
|
120
|
+
enum: ["numeric", "text"]
|
|
129
121
|
},
|
|
130
122
|
CredentialDataSupplierInput: {
|
|
131
123
|
description: "Optional storage that can help the credential Data Supplier. For instance to store credential input data during offer creation, if no additional data can be supplied later on"
|
|
@@ -155,10 +147,7 @@ var require_plugin_schema = __commonJS({
|
|
|
155
147
|
$ref: "#/components/schemas/TxCode"
|
|
156
148
|
}
|
|
157
149
|
},
|
|
158
|
-
required: [
|
|
159
|
-
"uri",
|
|
160
|
-
"correlationId"
|
|
161
|
-
],
|
|
150
|
+
required: ["uri", "correlationId"],
|
|
162
151
|
additionalProperties: false
|
|
163
152
|
},
|
|
164
153
|
IOID4VCIClientGetIssueStatusArgs: {
|
|
@@ -171,9 +160,7 @@ var require_plugin_schema = __commonJS({
|
|
|
171
160
|
type: "string"
|
|
172
161
|
}
|
|
173
162
|
},
|
|
174
|
-
required: [
|
|
175
|
-
"id"
|
|
176
|
-
],
|
|
163
|
+
required: ["id"],
|
|
177
164
|
additionalProperties: false
|
|
178
165
|
},
|
|
179
166
|
IssueStatusResponse: {
|
|
@@ -204,11 +191,7 @@ var require_plugin_schema = __commonJS({
|
|
|
204
191
|
}
|
|
205
192
|
}
|
|
206
193
|
},
|
|
207
|
-
required: [
|
|
208
|
-
"createdAt",
|
|
209
|
-
"lastUpdatedAt",
|
|
210
|
-
"status"
|
|
211
|
-
],
|
|
194
|
+
required: ["createdAt", "lastUpdatedAt", "status"],
|
|
212
195
|
additionalProperties: false
|
|
213
196
|
},
|
|
214
197
|
IssueStatus: {
|
|
@@ -271,7 +254,7 @@ var require_plugin_schema = __commonJS({
|
|
|
271
254
|
});
|
|
272
255
|
|
|
273
256
|
// src/agent/OID4VCIRestClient.ts
|
|
274
|
-
import
|
|
257
|
+
import fetch from "cross-fetch";
|
|
275
258
|
import { Loggers } from "@sphereon/ssi-types";
|
|
276
259
|
var logger = Loggers.DEFAULT.get("sphereon:ssi-sdk:oid4vci:issuer:rest-client");
|
|
277
260
|
var OID4VCIRestClient = class _OID4VCIRestClient {
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"sources":["../plugin.schema.json","../src/agent/OID4VCIRestClient.ts","../src/index.ts"],"sourcesContent":["{\n \"IOID4VCIRestClient\": {\n \"components\": {\n \"schemas\": {\n \"IOID4VCIClientCreateOfferUriRequestArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"credential_issuer\": {\n \"type\": \"string\",\n \"description\": \"REQUIRED. The URL of the Credential Issuer, as defined in Section 11.2.1, from which the Wallet is requested to obtain one or more Credentials. The Wallet uses it to obtain the Credential Issuer's Metadata following the steps defined in Section 11.2.2.\"\n },\n \"credential_configuration_ids\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n },\n \"description\": \"REQUIRED. Array of unique strings that each identify one of the keys in the name/value pairs stored in the credential_configurations_supported Credential Issuer metadata. The Wallet uses these string values to obtain the respective object that contains information about the Credential being offered as defined in Section 11.2.3. For example, these string values can be used to obtain scope values to be used in the Authorization Request.\"\n },\n \"grants\": {\n \"$ref\": \"#/components/schemas/Grant\",\n \"description\": \"OPTIONAL. Object indicating to the Wallet the Grant Types the Credential Issuer's Authorization Server is prepared to process for this Credential Offer. Every grant is represented by a name/value pair. The name is the Grant Type identifier; the value is an object that contains parameters either determining the way the Wallet MUST use the particular grant and/or parameters the Wallet MUST send with the respective request(s). If grants is not present or is empty, the Wallet MUST determine the Grant Types the Credential Issuer's Authorization Server supports using the respective metadata. When multiple grants are present, it is at the Wallet's discretion which one to use.\"\n },\n \"client_id\": {\n \"type\": \"string\",\n \"description\": \"OPTIONAL. Some implementations might include a client_id in the offer. For instance EBSI in a same-device flow. (Cross-device tucks it in the state JWT)\"\n },\n \"credentialDataSupplierInput\": {\n \"$ref\": \"#/components/schemas/CredentialDataSupplierInput\"\n },\n \"agentBaseUrl\": {\n \"type\": \"string\"\n }\n },\n \"additionalProperties\": false,\n \"required\": [\n \"credential_configuration_ids\",\n \"credential_issuer\"\n ]\n },\n \"Grant\": {\n \"type\": \"object\",\n \"properties\": {\n \"authorization_code\": {\n \"$ref\": \"#/components/schemas/GrantAuthorizationCode\"\n },\n \"urn:ietf:params:oauth:grant-type:pre-authorized_code\": {\n \"$ref\": \"#/components/schemas/GrantUrnIetf\"\n }\n },\n \"additionalProperties\": false\n },\n \"GrantAuthorizationCode\": {\n \"type\": \"object\",\n \"properties\": {\n \"issuer_state\": {\n \"type\": \"string\",\n \"description\": \"OPTIONAL. String value created by the Credential Issuer and opaque to the Wallet that is used to bind the subsequent Authorization Request with the Credential Issuer to a context set up during previous steps.\"\n },\n \"authorization_server\": {\n \"type\": \"string\",\n \"description\": \"OPTIONAL string that the Wallet can use to identify the Authorization Server to use with this grant type when authorization_servers parameter in the Credential Issuer metadata has multiple entries. MUST NOT be used otherwise. The value of this parameter MUST match with one of the values in the authorization_servers array obtained from the Credential Issuer metadata\"\n }\n },\n \"additionalProperties\": false\n },\n \"GrantUrnIetf\": {\n \"type\": \"object\",\n \"properties\": {\n \"pre-authorized_code\": {\n \"type\": \"string\",\n \"description\": \"REQUIRED. The code representing the Credential Issuer's authorization for the Wallet to obtain Credentials of a certain type.\"\n },\n \"tx_code\": {\n \"$ref\": \"#/components/schemas/TxCode\",\n \"description\": \"OPTIONAL. Object specifying whether the Authorization Server expects presentation of a Transaction Code by the End-User along with the Token Request in a Pre-Authorized Code Flow. If the Authorization Server does not expect a Transaction Code, this object is absent; this is the default. The Transaction Code is intended to bind the Pre-Authorized Code to a certain transaction to prevent replay of this code by an attacker that, for example, scanned the QR code while standing behind the legitimate End-User. It is RECOMMENDED to send the Transaction Code via a separate channel. If the Wallet decides to use the Pre-Authorized Code Flow, the Transaction Code value MUST be sent in the tx_code parameter with the respective Token Request as defined in Section 6.1. If no length or description is given, this object may be empty, indicating that a Transaction Code is required.\"\n },\n \"interval\": {\n \"type\": \"number\",\n \"description\": \"OPTIONAL. The minimum amount of time in seconds that the Wallet SHOULD wait between polling requests to the token endpoint (in case the Authorization Server responds with error code authorization_pending - see Section 6.3). If no value is provided, Wallets MUST use 5 as the default.\"\n },\n \"authorization_server\": {\n \"type\": \"string\",\n \"description\": \"OPTIONAL string that the Wallet can use to identify the Authorization Server to use with this grant type when authorization_servers parameter in the Credential Issuer metadata has multiple entries. MUST NOT be used otherwise. The value of this parameter MUST match with one of the values in the authorization_servers array obtained from the Credential Issuer metadata\"\n },\n \"user_pin_required\": {\n \"type\": \"boolean\",\n \"description\": \"OPTIONAL. Boolean value specifying whether the AS expects presentation of the End-User PIN along with the Token Request in a Pre-Authorized Code Flow. Default is false. This PIN is intended to bind the Pre-Authorized Code to a certain transaction to prevent replay of this code by an attacker that, for example, scanned the QR code while standing behind the legitimate End-User. It is RECOMMENDED to send a PIN via a separate channel. If the Wallet decides to use the Pre-Authorized Code Flow, a PIN value MUST be sent in the user_pin parameter with the respective Token Request.\"\n }\n },\n \"required\": [\n \"pre-authorized_code\"\n ],\n \"additionalProperties\": false\n },\n \"TxCode\": {\n \"type\": \"object\",\n \"properties\": {\n \"input_mode\": {\n \"$ref\": \"#/components/schemas/InputCharSet\",\n \"description\": \"OPTIONAL. String specifying the input character set. Possible values are numeric (only digits) and text (any characters). The default is numeric.\"\n },\n \"length\": {\n \"type\": \"number\",\n \"description\": \"OPTIONAL. Integer specifying the length of the Transaction Code. This helps the Wallet to render the input screen and improve the user experience.\"\n },\n \"description\": {\n \"type\": \"string\",\n \"description\": \"OPTIONAL. String containing guidance for the Holder of the Wallet on how to obtain the Transaction Code, e.g., describing over which communication channel it is delivered. The Wallet is RECOMMENDED to display this description next to the Transaction Code input screen to improve the user experience. The length of the string MUST NOT exceed 300 characters. The description does not support internationalization, however the Issuer MAY detect the Holder's language by previous communication or an HTTP Accept-Language header within an HTTP GET request for a Credential Offer URI.\"\n }\n },\n \"additionalProperties\": false\n },\n \"InputCharSet\": {\n \"type\": \"string\",\n \"enum\": [\n \"numeric\",\n \"text\"\n ]\n },\n \"CredentialDataSupplierInput\": {\n \"description\": \"Optional storage that can help the credential Data Supplier. For instance to store credential input data during offer creation, if no additional data can be supplied later on\"\n },\n \"IOID4VCIClientCreateOfferUriResponse\": {\n \"$ref\": \"#/components/schemas/Omit<CreateCredentialOfferURIResult,\\\"session\\\">\"\n },\n \"Omit<CreateCredentialOfferURIResult,\\\"session\\\">\": {\n \"$ref\": \"#/components/schemas/Pick<CreateCredentialOfferURIResult,Exclude<(\\\"uri\\\"|\\\"correlationId\\\"|\\\"qrCodeDataUri\\\"|\\\"session\\\"|\\\"userPin\\\"|\\\"txCode\\\"),\\\"session\\\">>\"\n },\n \"Pick<CreateCredentialOfferURIResult,Exclude<(\\\"uri\\\"|\\\"correlationId\\\"|\\\"qrCodeDataUri\\\"|\\\"session\\\"|\\\"userPin\\\"|\\\"txCode\\\"),\\\"session\\\">>\": {\n \"type\": \"object\",\n \"properties\": {\n \"uri\": {\n \"type\": \"string\"\n },\n \"correlationId\": {\n \"type\": \"string\"\n },\n \"qrCodeDataUri\": {\n \"type\": \"string\"\n },\n \"userPin\": {\n \"type\": \"string\"\n },\n \"txCode\": {\n \"$ref\": \"#/components/schemas/TxCode\"\n }\n },\n \"required\": [\n \"uri\",\n \"correlationId\"\n ],\n \"additionalProperties\": false\n },\n \"IOID4VCIClientGetIssueStatusArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"baseUrl\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"id\"\n ],\n \"additionalProperties\": false\n },\n \"IssueStatusResponse\": {\n \"type\": \"object\",\n \"properties\": {\n \"createdAt\": {\n \"type\": \"number\"\n },\n \"lastUpdatedAt\": {\n \"type\": \"number\"\n },\n \"expiresAt\": {\n \"type\": \"number\"\n },\n \"status\": {\n \"$ref\": \"#/components/schemas/IssueStatus\"\n },\n \"error\": {\n \"type\": \"string\"\n },\n \"clientId\": {\n \"type\": \"string\"\n },\n \"statusLists\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/StatusListOpts\"\n }\n }\n },\n \"required\": [\n \"createdAt\",\n \"lastUpdatedAt\",\n \"status\"\n ],\n \"additionalProperties\": false\n },\n \"IssueStatus\": {\n \"type\": \"string\",\n \"enum\": [\n \"OFFER_CREATED\",\n \"ACCESS_TOKEN_REQUESTED\",\n \"ACCESS_TOKEN_CREATED\",\n \"CREDENTIAL_REQUEST_RECEIVED\",\n \"CREDENTIAL_ISSUED\",\n \"NOTIFICATION_CREDENTIAL_ACCEPTED\",\n \"NOTIFICATION_CREDENTIAL_DELETED\",\n \"NOTIFICATION_CREDENTIAL_FAILURE\",\n \"ERROR\"\n ]\n },\n \"StatusListOpts\": {\n \"type\": \"object\",\n \"properties\": {\n \"statusListId\": {\n \"type\": \"string\"\n },\n \"statusListCorrelationId\": {\n \"type\": \"string\"\n },\n \"statusListIndex\": {\n \"type\": \"number\"\n },\n \"statusEntryCorrelationId\": {\n \"type\": \"string\"\n }\n },\n \"additionalProperties\": false\n }\n },\n \"methods\": {\n \"oid4vciClientCreateOfferUri\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IOID4VCIClientCreateOfferUriRequestArgs\"\n },\n \"returnType\": {\n \"$ref\": \"#/components/schemas/IOID4VCIClientCreateOfferUriResponse\"\n }\n },\n \"oid4vciClientGetIssueStatus\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IOID4VCIClientGetIssueStatusArgs\"\n },\n \"returnType\": {\n \"$ref\": \"#/components/schemas/IssueStatusResponse\"\n }\n }\n }\n }\n }\n}","import { fetch } from 'cross-fetch'\nimport {\n IOID4VCIRestClient,\n IOID4VCIClientCreateOfferUriRequest,\n IOID4VCIClientCreateOfferUriRequestArgs,\n IOID4VCIClientCreateOfferUriResponse,\n IOID4VCIClientGetIssueStatusArgs,\n IRestClientAuthenticationOpts,\n} from '../types/IOID4VCIRestClient'\nimport { IssueStatusResponse } from '@sphereon/oid4vci-common'\nimport { IAgentPlugin } from '@veramo/core'\nimport { Loggers } from '@sphereon/ssi-types'\n\nconst logger = Loggers.DEFAULT.get('sphereon:ssi-sdk:oid4vci:issuer:rest-client')\n\n/**\n * {@inheritDoc IOID4VCIRestClient}\n */\nexport class OID4VCIRestClient implements IAgentPlugin {\n readonly methods: IOID4VCIRestClient = {\n oid4vciClientCreateOfferUri: this.oid4vciClientCreateOfferUri.bind(this),\n oid4vciClientGetIssueStatus: this.oid4vciClientGetIssueStatus.bind(this),\n }\n\n private readonly agentBaseUrl?: string\n private readonly authOpts?: IRestClientAuthenticationOpts\n\n constructor(args?: { baseUrl?: string; authentication?: IRestClientAuthenticationOpts }) {\n if (args?.baseUrl) {\n this.agentBaseUrl = args.baseUrl\n }\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 /** {@inheritDoc IOID4VCIRestClient.vciClientCreateOfferUri} */\n private async oid4vciClientCreateOfferUri(args: IOID4VCIClientCreateOfferUriRequestArgs): Promise<IOID4VCIClientCreateOfferUriResponse> {\n if (!args.credential_configuration_ids || !args.grants) {\n return Promise.reject(Error(\"Can't generate the credential offer url without credentials and grants params present.\"))\n }\n const baseUrl = this.assertedAgentBaseUrl(args.agentBaseUrl)\n const request: IOID4VCIClientCreateOfferUriRequest = {\n credential_configuration_ids: args.credential_configuration_ids,\n grants: args.grants,\n ...(args.credentialDataSupplierInput && { credentialDataSupplierInput: args.credentialDataSupplierInput }),\n }\n const url = OID4VCIRestClient.urlWithBase(`webapp/credential-offers`, baseUrl)\n logger.debug(`OID4VCIRestClient is going to send request: ${JSON.stringify(request)} to ${url}`)\n try {\n const origResponse = await fetch(url, {\n method: 'POST',\n headers: await this.createHeaders({ 'Content-Type': 'application/json' }),\n body: JSON.stringify(request),\n })\n if (!origResponse.ok) {\n return Promise.reject(Error(`request to ${url} returned ${origResponse.status}`))\n }\n return await origResponse.json()\n } catch (e) {\n logger.debug(`Error on posting to url ${url}: ${e}`)\n return Promise.reject(Error(`request to ${url} returned ${e}`))\n }\n }\n\n private async oid4vciClientGetIssueStatus(args: IOID4VCIClientGetIssueStatusArgs): Promise<IssueStatusResponse> {\n const baseUrl = this.assertedAgentBaseUrl(args.baseUrl)\n const url = OID4VCIRestClient.urlWithBase('/webapp/credential-offer-status', baseUrl)\n const statusResponse = await fetch(url, {\n method: 'POST',\n headers: await this.createHeaders({ 'Content-Type': 'application/json' }),\n body: JSON.stringify({\n id: args.id,\n }),\n })\n logger.debug(`issue 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 assertedAgentBaseUrl(baseUrl?: string): string {\n if (baseUrl) {\n return baseUrl\n } else if (this.agentBaseUrl) {\n return this.agentBaseUrl\n }\n throw new Error('No base url has been provided')\n }\n\n private static urlWithBase(path: string, baseUrl: string): string {\n return `${baseUrl}${path.startsWith('/') ? path : `/${path}`}`\n }\n}\n","/**\n * @public\n */\nconst schema = require('../plugin.schema.json')\nexport { schema }\nexport { OID4VCIRestClient } from './agent/OID4VCIRestClient'\nexport type * from './types/IOID4VCIRestClient'\n"],"mappings":";;;;;;;;AAAA;AAAA;AAAA;AAAA,MACE,oBAAsB;AAAA,QACpB,YAAc;AAAA,UACZ,SAAW;AAAA,YACT,yCAA2C;AAAA,cACzC,MAAQ;AAAA,cACR,YAAc;AAAA,gBACZ,mBAAqB;AAAA,kBACnB,MAAQ;AAAA,kBACR,aAAe;AAAA,gBACjB;AAAA,gBACA,8BAAgC;AAAA,kBAC9B,MAAQ;AAAA,kBACR,OAAS;AAAA,oBACP,MAAQ;AAAA,kBACV;AAAA,kBACA,aAAe;AAAA,gBACjB;AAA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AM,IAAIW,MAAM,+BAAA;EAClB;EAEA,OAAeU,YAAYe,MAAcjC,SAAyB;AAChE,WAAO,GAAGA,OAAAA,GAAUiC,KAAKC,WAAW,GAAA,IAAOD,OAAO,IAAIA,IAAAA,EAAM;EAC9D;AACF;;;AC1GA,IAAME,SAASC;","names":["fetch","Loggers","logger","Loggers","DEFAULT","get","OID4VCIRestClient","methods","oid4vciClientCreateOfferUri","bind","oid4vciClientGetIssueStatus","agentBaseUrl","authOpts","args","baseUrl","authentication","createHeaders","existing","headers","Accept","enabled","bearerToken","Error","Authorization","credential_configuration_ids","grants","Promise","reject","assertedAgentBaseUrl","request","credentialDataSupplierInput","url","urlWithBase","debug","JSON","stringify","origResponse","fetch","method","body","ok","status","json","e","statusResponse","id","err","path","startsWith","schema","require"]}
|
|
1
|
+
{"version":3,"sources":["../plugin.schema.json","../src/agent/OID4VCIRestClient.ts","../src/index.ts"],"sourcesContent":["{\n \"IOID4VCIRestClient\": {\n \"components\": {\n \"schemas\": {\n \"IOID4VCIClientCreateOfferUriRequestArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"credential_issuer\": {\n \"type\": \"string\",\n \"description\": \"REQUIRED. The URL of the Credential Issuer, as defined in Section 11.2.1, from which the Wallet is requested to obtain one or more Credentials. The Wallet uses it to obtain the Credential Issuer's Metadata following the steps defined in Section 11.2.2.\"\n },\n \"credential_configuration_ids\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n },\n \"description\": \"REQUIRED. Array of unique strings that each identify one of the keys in the name/value pairs stored in the credential_configurations_supported Credential Issuer metadata. The Wallet uses these string values to obtain the respective object that contains information about the Credential being offered as defined in Section 11.2.3. For example, these string values can be used to obtain scope values to be used in the Authorization Request.\"\n },\n \"grants\": {\n \"$ref\": \"#/components/schemas/Grant\",\n \"description\": \"OPTIONAL. Object indicating to the Wallet the Grant Types the Credential Issuer's Authorization Server is prepared to process for this Credential Offer. Every grant is represented by a name/value pair. The name is the Grant Type identifier; the value is an object that contains parameters either determining the way the Wallet MUST use the particular grant and/or parameters the Wallet MUST send with the respective request(s). If grants is not present or is empty, the Wallet MUST determine the Grant Types the Credential Issuer's Authorization Server supports using the respective metadata. When multiple grants are present, it is at the Wallet's discretion which one to use.\"\n },\n \"client_id\": {\n \"type\": \"string\",\n \"description\": \"OPTIONAL. Some implementations might include a client_id in the offer. For instance EBSI in a same-device flow. (Cross-device tucks it in the state JWT)\"\n },\n \"credentialDataSupplierInput\": {\n \"$ref\": \"#/components/schemas/CredentialDataSupplierInput\"\n },\n \"agentBaseUrl\": {\n \"type\": \"string\"\n }\n },\n \"additionalProperties\": false,\n \"required\": [\"credential_configuration_ids\", \"credential_issuer\"]\n },\n \"Grant\": {\n \"type\": \"object\",\n \"properties\": {\n \"authorization_code\": {\n \"$ref\": \"#/components/schemas/GrantAuthorizationCode\"\n },\n \"urn:ietf:params:oauth:grant-type:pre-authorized_code\": {\n \"$ref\": \"#/components/schemas/GrantUrnIetf\"\n }\n },\n \"additionalProperties\": false\n },\n \"GrantAuthorizationCode\": {\n \"type\": \"object\",\n \"properties\": {\n \"issuer_state\": {\n \"type\": \"string\",\n \"description\": \"OPTIONAL. String value created by the Credential Issuer and opaque to the Wallet that is used to bind the subsequent Authorization Request with the Credential Issuer to a context set up during previous steps.\"\n },\n \"authorization_server\": {\n \"type\": \"string\",\n \"description\": \"OPTIONAL string that the Wallet can use to identify the Authorization Server to use with this grant type when authorization_servers parameter in the Credential Issuer metadata has multiple entries. MUST NOT be used otherwise. The value of this parameter MUST match with one of the values in the authorization_servers array obtained from the Credential Issuer metadata\"\n }\n },\n \"additionalProperties\": false\n },\n \"GrantUrnIetf\": {\n \"type\": \"object\",\n \"properties\": {\n \"pre-authorized_code\": {\n \"type\": \"string\",\n \"description\": \"REQUIRED. The code representing the Credential Issuer's authorization for the Wallet to obtain Credentials of a certain type.\"\n },\n \"tx_code\": {\n \"$ref\": \"#/components/schemas/TxCode\",\n \"description\": \"OPTIONAL. Object specifying whether the Authorization Server expects presentation of a Transaction Code by the End-User along with the Token Request in a Pre-Authorized Code Flow. If the Authorization Server does not expect a Transaction Code, this object is absent; this is the default. The Transaction Code is intended to bind the Pre-Authorized Code to a certain transaction to prevent replay of this code by an attacker that, for example, scanned the QR code while standing behind the legitimate End-User. It is RECOMMENDED to send the Transaction Code via a separate channel. If the Wallet decides to use the Pre-Authorized Code Flow, the Transaction Code value MUST be sent in the tx_code parameter with the respective Token Request as defined in Section 6.1. If no length or description is given, this object may be empty, indicating that a Transaction Code is required.\"\n },\n \"interval\": {\n \"type\": \"number\",\n \"description\": \"OPTIONAL. The minimum amount of time in seconds that the Wallet SHOULD wait between polling requests to the token endpoint (in case the Authorization Server responds with error code authorization_pending - see Section 6.3). If no value is provided, Wallets MUST use 5 as the default.\"\n },\n \"authorization_server\": {\n \"type\": \"string\",\n \"description\": \"OPTIONAL string that the Wallet can use to identify the Authorization Server to use with this grant type when authorization_servers parameter in the Credential Issuer metadata has multiple entries. MUST NOT be used otherwise. The value of this parameter MUST match with one of the values in the authorization_servers array obtained from the Credential Issuer metadata\"\n },\n \"user_pin_required\": {\n \"type\": \"boolean\",\n \"description\": \"OPTIONAL. Boolean value specifying whether the AS expects presentation of the End-User PIN along with the Token Request in a Pre-Authorized Code Flow. Default is false. This PIN is intended to bind the Pre-Authorized Code to a certain transaction to prevent replay of this code by an attacker that, for example, scanned the QR code while standing behind the legitimate End-User. It is RECOMMENDED to send a PIN via a separate channel. If the Wallet decides to use the Pre-Authorized Code Flow, a PIN value MUST be sent in the user_pin parameter with the respective Token Request.\"\n }\n },\n \"required\": [\"pre-authorized_code\"],\n \"additionalProperties\": false\n },\n \"TxCode\": {\n \"type\": \"object\",\n \"properties\": {\n \"input_mode\": {\n \"$ref\": \"#/components/schemas/InputCharSet\",\n \"description\": \"OPTIONAL. String specifying the input character set. Possible values are numeric (only digits) and text (any characters). The default is numeric.\"\n },\n \"length\": {\n \"type\": \"number\",\n \"description\": \"OPTIONAL. Integer specifying the length of the Transaction Code. This helps the Wallet to render the input screen and improve the user experience.\"\n },\n \"description\": {\n \"type\": \"string\",\n \"description\": \"OPTIONAL. String containing guidance for the Holder of the Wallet on how to obtain the Transaction Code, e.g., describing over which communication channel it is delivered. The Wallet is RECOMMENDED to display this description next to the Transaction Code input screen to improve the user experience. The length of the string MUST NOT exceed 300 characters. The description does not support internationalization, however the Issuer MAY detect the Holder's language by previous communication or an HTTP Accept-Language header within an HTTP GET request for a Credential Offer URI.\"\n }\n },\n \"additionalProperties\": false\n },\n \"InputCharSet\": {\n \"type\": \"string\",\n \"enum\": [\"numeric\", \"text\"]\n },\n \"CredentialDataSupplierInput\": {\n \"description\": \"Optional storage that can help the credential Data Supplier. For instance to store credential input data during offer creation, if no additional data can be supplied later on\"\n },\n \"IOID4VCIClientCreateOfferUriResponse\": {\n \"$ref\": \"#/components/schemas/Omit<CreateCredentialOfferURIResult,\\\"session\\\">\"\n },\n \"Omit<CreateCredentialOfferURIResult,\\\"session\\\">\": {\n \"$ref\": \"#/components/schemas/Pick<CreateCredentialOfferURIResult,Exclude<(\\\"uri\\\"|\\\"correlationId\\\"|\\\"qrCodeDataUri\\\"|\\\"session\\\"|\\\"userPin\\\"|\\\"txCode\\\"),\\\"session\\\">>\"\n },\n \"Pick<CreateCredentialOfferURIResult,Exclude<(\\\"uri\\\"|\\\"correlationId\\\"|\\\"qrCodeDataUri\\\"|\\\"session\\\"|\\\"userPin\\\"|\\\"txCode\\\"),\\\"session\\\">>\": {\n \"type\": \"object\",\n \"properties\": {\n \"uri\": {\n \"type\": \"string\"\n },\n \"correlationId\": {\n \"type\": \"string\"\n },\n \"qrCodeDataUri\": {\n \"type\": \"string\"\n },\n \"userPin\": {\n \"type\": \"string\"\n },\n \"txCode\": {\n \"$ref\": \"#/components/schemas/TxCode\"\n }\n },\n \"required\": [\"uri\", \"correlationId\"],\n \"additionalProperties\": false\n },\n \"IOID4VCIClientGetIssueStatusArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"baseUrl\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\"id\"],\n \"additionalProperties\": false\n },\n \"IssueStatusResponse\": {\n \"type\": \"object\",\n \"properties\": {\n \"createdAt\": {\n \"type\": \"number\"\n },\n \"lastUpdatedAt\": {\n \"type\": \"number\"\n },\n \"expiresAt\": {\n \"type\": \"number\"\n },\n \"status\": {\n \"$ref\": \"#/components/schemas/IssueStatus\"\n },\n \"error\": {\n \"type\": \"string\"\n },\n \"clientId\": {\n \"type\": \"string\"\n },\n \"statusLists\": {\n \"type\": \"array\",\n \"items\": {\n \"$ref\": \"#/components/schemas/StatusListOpts\"\n }\n }\n },\n \"required\": [\"createdAt\", \"lastUpdatedAt\", \"status\"],\n \"additionalProperties\": false\n },\n \"IssueStatus\": {\n \"type\": \"string\",\n \"enum\": [\n \"OFFER_CREATED\",\n \"ACCESS_TOKEN_REQUESTED\",\n \"ACCESS_TOKEN_CREATED\",\n \"CREDENTIAL_REQUEST_RECEIVED\",\n \"CREDENTIAL_ISSUED\",\n \"NOTIFICATION_CREDENTIAL_ACCEPTED\",\n \"NOTIFICATION_CREDENTIAL_DELETED\",\n \"NOTIFICATION_CREDENTIAL_FAILURE\",\n \"ERROR\"\n ]\n },\n \"StatusListOpts\": {\n \"type\": \"object\",\n \"properties\": {\n \"statusListId\": {\n \"type\": \"string\"\n },\n \"statusListCorrelationId\": {\n \"type\": \"string\"\n },\n \"statusListIndex\": {\n \"type\": \"number\"\n },\n \"statusEntryCorrelationId\": {\n \"type\": \"string\"\n }\n },\n \"additionalProperties\": false\n }\n },\n \"methods\": {\n \"oid4vciClientCreateOfferUri\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IOID4VCIClientCreateOfferUriRequestArgs\"\n },\n \"returnType\": {\n \"$ref\": \"#/components/schemas/IOID4VCIClientCreateOfferUriResponse\"\n }\n },\n \"oid4vciClientGetIssueStatus\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IOID4VCIClientGetIssueStatusArgs\"\n },\n \"returnType\": {\n \"$ref\": \"#/components/schemas/IssueStatusResponse\"\n }\n }\n }\n }\n }\n}\n","import fetch from 'cross-fetch'\nimport {\n IOID4VCIRestClient,\n IOID4VCIClientCreateOfferUriRequest,\n IOID4VCIClientCreateOfferUriRequestArgs,\n IOID4VCIClientCreateOfferUriResponse,\n IOID4VCIClientGetIssueStatusArgs,\n IRestClientAuthenticationOpts,\n} from '../types/IOID4VCIRestClient'\nimport { IssueStatusResponse } from '@sphereon/oid4vci-common'\nimport { IAgentPlugin } from '@veramo/core'\nimport { Loggers } from '@sphereon/ssi-types'\n\nconst logger = Loggers.DEFAULT.get('sphereon:ssi-sdk:oid4vci:issuer:rest-client')\n\n/**\n * {@inheritDoc IOID4VCIRestClient}\n */\nexport class OID4VCIRestClient implements IAgentPlugin {\n readonly methods: IOID4VCIRestClient = {\n oid4vciClientCreateOfferUri: this.oid4vciClientCreateOfferUri.bind(this),\n oid4vciClientGetIssueStatus: this.oid4vciClientGetIssueStatus.bind(this),\n }\n\n private readonly agentBaseUrl?: string\n private readonly authOpts?: IRestClientAuthenticationOpts\n\n constructor(args?: { baseUrl?: string; authentication?: IRestClientAuthenticationOpts }) {\n if (args?.baseUrl) {\n this.agentBaseUrl = args.baseUrl\n }\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 /** {@inheritDoc IOID4VCIRestClient.vciClientCreateOfferUri} */\n private async oid4vciClientCreateOfferUri(args: IOID4VCIClientCreateOfferUriRequestArgs): Promise<IOID4VCIClientCreateOfferUriResponse> {\n if (!args.credential_configuration_ids || !args.grants) {\n return Promise.reject(Error(\"Can't generate the credential offer url without credentials and grants params present.\"))\n }\n const baseUrl = this.assertedAgentBaseUrl(args.agentBaseUrl)\n const request: IOID4VCIClientCreateOfferUriRequest = {\n credential_configuration_ids: args.credential_configuration_ids,\n grants: args.grants,\n ...(args.credentialDataSupplierInput && { credentialDataSupplierInput: args.credentialDataSupplierInput }),\n }\n const url = OID4VCIRestClient.urlWithBase(`webapp/credential-offers`, baseUrl)\n logger.debug(`OID4VCIRestClient is going to send request: ${JSON.stringify(request)} to ${url}`)\n try {\n const origResponse = await fetch(url, {\n method: 'POST',\n headers: await this.createHeaders({ 'Content-Type': 'application/json' }),\n body: JSON.stringify(request),\n })\n if (!origResponse.ok) {\n return Promise.reject(Error(`request to ${url} returned ${origResponse.status}`))\n }\n return await origResponse.json()\n } catch (e) {\n logger.debug(`Error on posting to url ${url}: ${e}`)\n return Promise.reject(Error(`request to ${url} returned ${e}`))\n }\n }\n\n private async oid4vciClientGetIssueStatus(args: IOID4VCIClientGetIssueStatusArgs): Promise<IssueStatusResponse> {\n const baseUrl = this.assertedAgentBaseUrl(args.baseUrl)\n const url = OID4VCIRestClient.urlWithBase('/webapp/credential-offer-status', baseUrl)\n const statusResponse = await fetch(url, {\n method: 'POST',\n headers: await this.createHeaders({ 'Content-Type': 'application/json' }),\n body: JSON.stringify({\n id: args.id,\n }),\n })\n logger.debug(`issue 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 assertedAgentBaseUrl(baseUrl?: string): string {\n if (baseUrl) {\n return baseUrl\n } else if (this.agentBaseUrl) {\n return this.agentBaseUrl\n }\n throw new Error('No base url has been provided')\n }\n\n private static urlWithBase(path: string, baseUrl: string): string {\n return `${baseUrl}${path.startsWith('/') ? path : `/${path}`}`\n }\n}\n","/**\n * @public\n */\nconst schema = require('../plugin.schema.json')\nexport { schema }\nexport { OID4VCIRestClient } from './agent/OID4VCIRestClient'\nexport type * from './types/IOID4VCIRestClient'\n"],"mappings":";;;;;;;;AAAA;AAAA;AAAA;AAAA,MACE,oBAAsB;AAAA,QACpB,YAAc;AAAA,UACZ,SAAW;AAAA,YACT,yCAA2C;AAAA,cACzC,MAAQ;AAAA,cACR,YAAc;AAAA,gBACZ,mBAAqB;AAAA,kBACnB,MAAQ;AAAA,kBACR,aAAe;AAAA,gBACjB;AAAA,gBACA,8BAAgC;AAAA,kBAC9B,MAAQ;AAAA,kBACR,OAAS;AAAA,oBACP,MAAQ;AAAA,kBACV;AAAA,kBACA,aAAe;AAAA,gBACjB;AAAA,gBACA,QAAU;AAAA,kBACR,MAAQ;AAAA,kBACR,aAAe;AAAA,gBACjB;AAAA,gBACA,WAAa;AAAA,kBACX,MAAQ;AAAA,kBACR,aAAe;AAAA,gBACjB;AAAA,gBACA,6BAA+B;AAAA,kBAC7B,MAAQ;AAAA,gBACV;AAAA,gBACA,cAAgB;AAAA,kBACd,MAAQ;AAAA,gBACV;AAAA,cACF;AAAA,cACA,sBAAwB;AAAA,cACxB,UAAY,CAAC,gCAAgC,mBAAmB;AAAA,YAClE;AAAA,YACA,OAAS;AAAA,cACP,MAAQ;AAAA,cACR,YAAc;AAAA,gBACZ,oBAAsB;AAAA,kBACpB,MAAQ;AAAA,gBACV;AAAA,gBACA,wDAAwD;AAAA,kBACtD,MAAQ;AAAA,gBACV;AAAA,cACF;AAAA,cACA,sBAAwB;AAAA,YAC1B;AAAA,YACA,wBAA0B;AAAA,cACxB,MAAQ;AAAA,cACR,YAAc;AAAA,gBACZ,cAAgB;AAAA,kBACd,MAAQ;AAAA,kBACR,aAAe;AAAA,gBACjB;AAAA,gBACA,sBAAwB;AAAA,kBACtB,MAAQ;AAAA,kBACR,aAAe;AAAA,gBACjB;AAAA,cACF;AAAA,cACA,sBAAwB;AAAA,YAC1B;AAAA,YACA,cAAgB;AAAA,cACd,MAAQ;AAAA,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EuB,MAAML,KAAKC,UAAU;QACnBU,IAAIhC,KAAKgC;MACX,CAAA;IACF,CAAA;AACA3C,WAAO+B,MAAM,0BAA0BW,cAAAA,EAAgB;AACvD,QAAI;AACF,aAAO,MAAMA,eAAeF,KAAI;IAClC,SAASI,KAAK;AACZ,YAAMxB,MAAM,uBAAuBsB,eAAeH,MAAM,EAAE;IAC5D;EACF;EAEQb,qBAAqBd,SAA0B;AACrD,QAAIA,SAAS;AACX,aAAOA;IACT,WAAW,KAAKH,cAAc;AAC5B,aAAO,KAAKA;IACd;AACA,UAAM,IAAIW,MAAM,+BAAA;EAClB;EAEA,OAAeU,YAAYe,MAAcjC,SAAyB;AAChE,WAAO,GAAGA,OAAAA,GAAUiC,KAAKC,WAAW,GAAA,IAAOD,OAAO,IAAIA,IAAAA,EAAM;EAC9D;AACF;;;AC1GA,IAAME,SAASC;","names":["fetch","Loggers","logger","Loggers","DEFAULT","get","OID4VCIRestClient","methods","oid4vciClientCreateOfferUri","bind","oid4vciClientGetIssueStatus","agentBaseUrl","authOpts","args","baseUrl","authentication","createHeaders","existing","headers","Accept","enabled","bearerToken","Error","Authorization","credential_configuration_ids","grants","Promise","reject","assertedAgentBaseUrl","request","credentialDataSupplierInput","url","urlWithBase","debug","JSON","stringify","origResponse","fetch","method","body","ok","status","json","e","statusResponse","id","err","path","startsWith","schema","require"]}
|
package/package.json
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.oid4vci-issuer-rest-client",
|
|
3
3
|
"description": "contains the client side to call REST endpoints of a Verifiable Credential Issuer",
|
|
4
|
-
"version": "0.
|
|
4
|
+
"version": "0.36.0",
|
|
5
5
|
"source": "src/index.ts",
|
|
6
6
|
"type": "module",
|
|
7
7
|
"main": "./dist/index.cjs",
|
|
@@ -28,13 +28,13 @@
|
|
|
28
28
|
"generate-plugin-schema": "tsx ../../packages/dev/bin/sphereon.js dev generate-plugin-schema"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@sphereon/oid4vci-common": "0.
|
|
32
|
-
"@sphereon/ssi-types": "0.
|
|
31
|
+
"@sphereon/oid4vci-common": "0.20.0",
|
|
32
|
+
"@sphereon/ssi-types": "0.36.0",
|
|
33
33
|
"@veramo/core": "4.2.0",
|
|
34
34
|
"cross-fetch": "^4.1.0"
|
|
35
35
|
},
|
|
36
36
|
"devDependencies": {
|
|
37
|
-
"@sphereon/ssi-sdk.dev": "0.
|
|
37
|
+
"@sphereon/ssi-sdk.dev": "0.36.0",
|
|
38
38
|
"@types/node": "^20.17.1",
|
|
39
39
|
"@veramo/remote-client": "4.2.0",
|
|
40
40
|
"@veramo/remote-server": "4.2.0",
|
|
@@ -63,5 +63,5 @@
|
|
|
63
63
|
"Verifiable Credentials",
|
|
64
64
|
"SSI"
|
|
65
65
|
],
|
|
66
|
-
"gitHead": "
|
|
66
|
+
"gitHead": "f713d3a83948ef69aaa7d435700b16d5655ac863"
|
|
67
67
|
}
|
package/plugin.schema.json
CHANGED
|
@@ -32,10 +32,7 @@
|
|
|
32
32
|
}
|
|
33
33
|
},
|
|
34
34
|
"additionalProperties": false,
|
|
35
|
-
"required": [
|
|
36
|
-
"credential_configuration_ids",
|
|
37
|
-
"credential_issuer"
|
|
38
|
-
]
|
|
35
|
+
"required": ["credential_configuration_ids", "credential_issuer"]
|
|
39
36
|
},
|
|
40
37
|
"Grant": {
|
|
41
38
|
"type": "object",
|
|
@@ -87,9 +84,7 @@
|
|
|
87
84
|
"description": "OPTIONAL. Boolean value specifying whether the AS expects presentation of the End-User PIN along with the Token Request in a Pre-Authorized Code Flow. Default is false. This PIN is intended to bind the Pre-Authorized Code to a certain transaction to prevent replay of this code by an attacker that, for example, scanned the QR code while standing behind the legitimate End-User. It is RECOMMENDED to send a PIN via a separate channel. If the Wallet decides to use the Pre-Authorized Code Flow, a PIN value MUST be sent in the user_pin parameter with the respective Token Request."
|
|
88
85
|
}
|
|
89
86
|
},
|
|
90
|
-
"required": [
|
|
91
|
-
"pre-authorized_code"
|
|
92
|
-
],
|
|
87
|
+
"required": ["pre-authorized_code"],
|
|
93
88
|
"additionalProperties": false
|
|
94
89
|
},
|
|
95
90
|
"TxCode": {
|
|
@@ -112,10 +107,7 @@
|
|
|
112
107
|
},
|
|
113
108
|
"InputCharSet": {
|
|
114
109
|
"type": "string",
|
|
115
|
-
"enum": [
|
|
116
|
-
"numeric",
|
|
117
|
-
"text"
|
|
118
|
-
]
|
|
110
|
+
"enum": ["numeric", "text"]
|
|
119
111
|
},
|
|
120
112
|
"CredentialDataSupplierInput": {
|
|
121
113
|
"description": "Optional storage that can help the credential Data Supplier. For instance to store credential input data during offer creation, if no additional data can be supplied later on"
|
|
@@ -145,10 +137,7 @@
|
|
|
145
137
|
"$ref": "#/components/schemas/TxCode"
|
|
146
138
|
}
|
|
147
139
|
},
|
|
148
|
-
"required": [
|
|
149
|
-
"uri",
|
|
150
|
-
"correlationId"
|
|
151
|
-
],
|
|
140
|
+
"required": ["uri", "correlationId"],
|
|
152
141
|
"additionalProperties": false
|
|
153
142
|
},
|
|
154
143
|
"IOID4VCIClientGetIssueStatusArgs": {
|
|
@@ -161,9 +150,7 @@
|
|
|
161
150
|
"type": "string"
|
|
162
151
|
}
|
|
163
152
|
},
|
|
164
|
-
"required": [
|
|
165
|
-
"id"
|
|
166
|
-
],
|
|
153
|
+
"required": ["id"],
|
|
167
154
|
"additionalProperties": false
|
|
168
155
|
},
|
|
169
156
|
"IssueStatusResponse": {
|
|
@@ -194,11 +181,7 @@
|
|
|
194
181
|
}
|
|
195
182
|
}
|
|
196
183
|
},
|
|
197
|
-
"required": [
|
|
198
|
-
"createdAt",
|
|
199
|
-
"lastUpdatedAt",
|
|
200
|
-
"status"
|
|
201
|
-
],
|
|
184
|
+
"required": ["createdAt", "lastUpdatedAt", "status"],
|
|
202
185
|
"additionalProperties": false
|
|
203
186
|
},
|
|
204
187
|
"IssueStatus": {
|
|
@@ -256,4 +239,4 @@
|
|
|
256
239
|
}
|
|
257
240
|
}
|
|
258
241
|
}
|
|
259
|
-
}
|
|
242
|
+
}
|