@sphereon/ssi-sdk.w3c-vc-api-verifier-rest-client 0.34.1-next.88 → 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 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
@@ -35,9 +45,7 @@ var require_plugin_schema = __commonJS({
35
45
  $ref: "#/components/schemas/CredentialPayload"
36
46
  }
37
47
  },
38
- required: [
39
- "credential"
40
- ],
48
+ required: ["credential"],
41
49
  additionalProperties: false
42
50
  },
43
51
  CredentialPayload: {
@@ -74,9 +82,7 @@ var require_plugin_schema = __commonJS({
74
82
  type: "string"
75
83
  }
76
84
  },
77
- required: [
78
- "issuer"
79
- ],
85
+ required: ["issuer"],
80
86
  description: "Used as input when creating Verifiable Credentials"
81
87
  },
82
88
  IssuerType: {
@@ -88,9 +94,7 @@ var require_plugin_schema = __commonJS({
88
94
  type: "string"
89
95
  }
90
96
  },
91
- required: [
92
- "id"
93
- ]
97
+ required: ["id"]
94
98
  },
95
99
  {
96
100
  type: "string"
@@ -129,10 +133,7 @@ var require_plugin_schema = __commonJS({
129
133
  type: "string"
130
134
  }
131
135
  },
132
- required: [
133
- "id",
134
- "type"
135
- ],
136
+ required: ["id", "type"],
136
137
  description: "Used for the discovery of information about the current status of a verifiable credential, such as whether it is suspended or revoked. The precise contents of the credential status information is determined by the specific `credentialStatus` type definition, and varies depending on factors such as whether it is simple to implement or if it is privacy-enhancing.\n\nSee {@link https://www.w3.org/TR/vc-data-model/#status | Credential Status }"
137
138
  },
138
139
  IVerifyCredentialResult: {
@@ -157,11 +158,7 @@ var require_plugin_schema = __commonJS({
157
158
  }
158
159
  }
159
160
  },
160
- required: [
161
- "checks",
162
- "errors",
163
- "warnings"
164
- ],
161
+ required: ["checks", "errors", "warnings"],
165
162
  additionalProperties: false
166
163
  }
167
164
  },
@@ -198,7 +195,7 @@ var events = /* @__PURE__ */ (function(events2) {
198
195
  })({});
199
196
 
200
197
  // src/agent/VcApiVerifierClient.ts
201
- var import_cross_fetch = require("cross-fetch");
198
+ var import_cross_fetch = __toESM(require("cross-fetch"), 1);
202
199
  var VcApiVerifierClient = class {
203
200
  static {
204
201
  __name(this, "VcApiVerifierClient");
@@ -213,7 +210,7 @@ var VcApiVerifierClient = class {
213
210
  }
214
211
  /** {@inheritDoc IVcApiVerifier.vcApiClientVerifyCredential} */
215
212
  async vcApiClientVerifyCredential(args, context) {
216
- return await (0, import_cross_fetch.fetch)(this.verifyUrl, {
213
+ return await (0, import_cross_fetch.default)(this.verifyUrl, {
217
214
  method: "post",
218
215
  headers: {
219
216
  Accept: "application/json",
@@ -1 +1 @@
1
- {"version":3,"sources":["../plugin.schema.json","../src/index.ts","../src/types/IVcApiVerifierClient.ts","../src/agent/VcApiVerifierClient.ts"],"sourcesContent":["{\n \"IVcApiVerifierClient\": {\n \"components\": {\n \"schemas\": {\n \"IVerifyCredentialArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"credential\": {\n \"$ref\": \"#/components/schemas/CredentialPayload\"\n }\n },\n \"required\": [\n \"credential\"\n ],\n \"additionalProperties\": false\n },\n \"CredentialPayload\": {\n \"type\": \"object\",\n \"properties\": {\n \"issuer\": {\n \"$ref\": \"#/components/schemas/IssuerType\"\n },\n \"credentialSubject\": {\n \"$ref\": \"#/components/schemas/CredentialSubject\"\n },\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"@context\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"issuanceDate\": {\n \"$ref\": \"#/components/schemas/DateType\"\n },\n \"expirationDate\": {\n \"$ref\": \"#/components/schemas/DateType\"\n },\n \"credentialStatus\": {\n \"$ref\": \"#/components/schemas/CredentialStatusReference\"\n },\n \"id\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"issuer\"\n ],\n \"description\": \"Used as input when creating Verifiable Credentials\"\n },\n \"IssuerType\": {\n \"anyOf\": [\n {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"id\"\n ]\n },\n {\n \"type\": \"string\"\n }\n ],\n \"description\": \"The issuer of a {@link VerifiableCredential } or the holder of a {@link VerifiablePresentation } .\\n\\nThe value of the issuer property MUST be either a URI or an object containing an id property. It is RECOMMENDED that the URI in the issuer or its id be one which, if de-referenced, results in a document containing machine-readable information about the issuer that can be used to verify the information expressed in the credential.\\n\\nSee {@link https://www.w3.org/TR/vc-data-model/#issuer | Issuer data model }\"\n },\n \"CredentialSubject\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n }\n },\n \"description\": \"The value of the credentialSubject property is defined as a set of objects that contain one or more properties that are each related to a subject of the verifiable credential. Each object MAY contain an id.\\n\\nSee {@link https://www.w3.org/TR/vc-data-model/#credential-subject | Credential Subject }\"\n },\n \"DateType\": {\n \"anyOf\": [\n {\n \"type\": \"string\"\n },\n {\n \"type\": \"string\",\n \"format\": \"date-time\"\n }\n ],\n \"description\": \"Represents an issuance or expiration date for Credentials / Presentations. This is used as input when creating them.\"\n },\n \"CredentialStatusReference\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"type\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"id\",\n \"type\"\n ],\n \"description\": \"Used for the discovery of information about the current status of a verifiable credential, such as whether it is suspended or revoked. The precise contents of the credential status information is determined by the specific `credentialStatus` type definition, and varies depending on factors such as whether it is simple to implement or if it is privacy-enhancing.\\n\\nSee {@link https://www.w3.org/TR/vc-data-model/#status | Credential Status }\"\n },\n \"IVerifyCredentialResult\": {\n \"type\": \"object\",\n \"properties\": {\n \"checks\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"errors\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"warnings\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\n \"checks\",\n \"errors\",\n \"warnings\"\n ],\n \"additionalProperties\": false\n }\n },\n \"methods\": {\n \"vcApiClientVerifyCredential\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IVerifyCredentialArgs\"\n },\n \"returnType\": {\n \"$ref\": \"#/components/schemas/IVerifyCredentialResult\"\n }\n }\n }\n }\n }\n}","/**\n * @public\n */\nconst schema = require('../plugin.schema.json')\nexport { schema }\nexport { VcApiVerifierClient } from './agent/VcApiVerifierClient'\nexport * from './types/IVcApiVerifierClient'\n","import { CredentialPayload, IAgentContext, IPluginMethodMap } from '@veramo/core'\n\nexport interface IVcApiVerifierClient extends IPluginMethodMap {\n vcApiClientVerifyCredential(args: IVerifyCredentialArgs, context: IRequiredContext): Promise<IVerifyCredentialResult>\n}\n\nexport interface IVcApiVerifierArgs {\n verifyUrl: string\n}\n\nexport interface IVerifyCredentialArgs {\n credential: CredentialPayload\n}\n\nexport interface IVerifyCredentialResult {\n checks: string[]\n errors: string[]\n warnings: string[]\n}\n\nexport enum events {\n CREDENTIAL_VERIFIED = 'credentialVerified',\n}\n\nexport type IRequiredContext = IAgentContext<Record<string, never>>\n","import { IAgentPlugin } from '@veramo/core'\n\nimport { schema } from '../index'\nimport {\n events,\n IRequiredContext,\n IVcApiVerifierClient,\n IVcApiVerifierArgs,\n IVerifyCredentialArgs,\n IVerifyCredentialResult,\n} from '../types/IVcApiVerifierClient'\n\nimport { fetch } from 'cross-fetch'\n\n/**\n * {@inheritDoc IVcApiVerifier}\n */\nexport class VcApiVerifierClient implements IAgentPlugin {\n readonly schema = schema.IVcApiVerfierClientAgentPlugin\n readonly methods: IVcApiVerifierClient = {\n vcApiClientVerifyCredential: this.vcApiClientVerifyCredential.bind(this),\n }\n private readonly verifyUrl: string\n\n constructor(options: IVcApiVerifierArgs) {\n this.verifyUrl = options.verifyUrl\n }\n\n /** {@inheritDoc IVcApiVerifier.vcApiClientVerifyCredential} */\n private async vcApiClientVerifyCredential(args: IVerifyCredentialArgs, context: IRequiredContext): Promise<IVerifyCredentialResult> {\n return await fetch(this.verifyUrl, {\n method: 'post',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ verifiableCredential: args.credential }),\n })\n .then(async (response) => {\n if (response.status >= 400) {\n throw new Error(await response.text())\n } else {\n return response.json()\n }\n })\n .then(async (verificationResult) => {\n await context.agent.emit(events.CREDENTIAL_VERIFIED, verificationResult)\n return verificationResult\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,gCAAAA,SAAA;AAAA,IAAAA,QAAA;AAAA,MACE,sBAAwB;AAAA,QACtB,YAAc;AAAA,UACZ,SAAW;AAAA,YACT,uBAAyB;AAAA,cACvB,MAAQ;AAAA,cACR,YAAc;AAA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AAOC;EAChBC,UAAgC;IACvCC,6BAA6B,KAAKA,4BAA4BC,KAAK,IAAI;EACzE;EACiBC;EAEjB,YAAYC,SAA6B;AACvC,SAAKD,YAAYC,QAAQD;EAC3B;;EAGA,MAAcF,4BAA4BI,MAA6BC,SAA6D;AAClI,WAAO,UAAMC,0BAAM,KAAKJ,WAAW;MACjCK,QAAQ;MACRC,SAAS;QACPC,QAAQ;QACR,gBAAgB;MAClB;MACAC,MAAMC,KAAKC,UAAU;QAAEC,sBAAsBT,KAAKU;MAAW,CAAA;IAC/D,CAAA,EACGC,KAAK,OAAOC,aAAAA;AACX,UAAIA,SAASC,UAAU,KAAK;AAC1B,cAAM,IAAIC,MAAM,MAAMF,SAASG,KAAI,CAAA;MACrC,OAAO;AACL,eAAOH,SAASI,KAAI;MACtB;IACF,CAAA,EACCL,KAAK,OAAOM,uBAAAA;AACX,YAAMhB,QAAQiB,MAAMC,KAAKC,OAAOC,qBAAqBJ,kBAAAA;AACrD,aAAOA;IACT,CAAA;EACJ;AACF;;;AF/CA,IAAMK,SAASC;","names":["module","events","VcApiVerifierClient","schema","IVcApiVerfierClientAgentPlugin","methods","vcApiClientVerifyCredential","bind","verifyUrl","options","args","context","fetch","method","headers","Accept","body","JSON","stringify","verifiableCredential","credential","then","response","status","Error","text","json","verificationResult","agent","emit","events","CREDENTIAL_VERIFIED","schema","require"]}
1
+ {"version":3,"sources":["../plugin.schema.json","../src/index.ts","../src/types/IVcApiVerifierClient.ts","../src/agent/VcApiVerifierClient.ts"],"sourcesContent":["{\n \"IVcApiVerifierClient\": {\n \"components\": {\n \"schemas\": {\n \"IVerifyCredentialArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"credential\": {\n \"$ref\": \"#/components/schemas/CredentialPayload\"\n }\n },\n \"required\": [\"credential\"],\n \"additionalProperties\": false\n },\n \"CredentialPayload\": {\n \"type\": \"object\",\n \"properties\": {\n \"issuer\": {\n \"$ref\": \"#/components/schemas/IssuerType\"\n },\n \"credentialSubject\": {\n \"$ref\": \"#/components/schemas/CredentialSubject\"\n },\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"@context\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"issuanceDate\": {\n \"$ref\": \"#/components/schemas/DateType\"\n },\n \"expirationDate\": {\n \"$ref\": \"#/components/schemas/DateType\"\n },\n \"credentialStatus\": {\n \"$ref\": \"#/components/schemas/CredentialStatusReference\"\n },\n \"id\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\"issuer\"],\n \"description\": \"Used as input when creating Verifiable Credentials\"\n },\n \"IssuerType\": {\n \"anyOf\": [\n {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\"id\"]\n },\n {\n \"type\": \"string\"\n }\n ],\n \"description\": \"The issuer of a {@link VerifiableCredential } or the holder of a {@link VerifiablePresentation } .\\n\\nThe value of the issuer property MUST be either a URI or an object containing an id property. It is RECOMMENDED that the URI in the issuer or its id be one which, if de-referenced, results in a document containing machine-readable information about the issuer that can be used to verify the information expressed in the credential.\\n\\nSee {@link https://www.w3.org/TR/vc-data-model/#issuer | Issuer data model }\"\n },\n \"CredentialSubject\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n }\n },\n \"description\": \"The value of the credentialSubject property is defined as a set of objects that contain one or more properties that are each related to a subject of the verifiable credential. Each object MAY contain an id.\\n\\nSee {@link https://www.w3.org/TR/vc-data-model/#credential-subject | Credential Subject }\"\n },\n \"DateType\": {\n \"anyOf\": [\n {\n \"type\": \"string\"\n },\n {\n \"type\": \"string\",\n \"format\": \"date-time\"\n }\n ],\n \"description\": \"Represents an issuance or expiration date for Credentials / Presentations. This is used as input when creating them.\"\n },\n \"CredentialStatusReference\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"type\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\"id\", \"type\"],\n \"description\": \"Used for the discovery of information about the current status of a verifiable credential, such as whether it is suspended or revoked. The precise contents of the credential status information is determined by the specific `credentialStatus` type definition, and varies depending on factors such as whether it is simple to implement or if it is privacy-enhancing.\\n\\nSee {@link https://www.w3.org/TR/vc-data-model/#status | Credential Status }\"\n },\n \"IVerifyCredentialResult\": {\n \"type\": \"object\",\n \"properties\": {\n \"checks\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"errors\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"warnings\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\"checks\", \"errors\", \"warnings\"],\n \"additionalProperties\": false\n }\n },\n \"methods\": {\n \"vcApiClientVerifyCredential\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IVerifyCredentialArgs\"\n },\n \"returnType\": {\n \"$ref\": \"#/components/schemas/IVerifyCredentialResult\"\n }\n }\n }\n }\n }\n}\n","/**\n * @public\n */\nconst schema = require('../plugin.schema.json')\nexport { schema }\nexport { VcApiVerifierClient } from './agent/VcApiVerifierClient'\nexport * from './types/IVcApiVerifierClient'\n","import { CredentialPayload, IAgentContext, IPluginMethodMap } from '@veramo/core'\n\nexport interface IVcApiVerifierClient extends IPluginMethodMap {\n vcApiClientVerifyCredential(args: IVerifyCredentialArgs, context: IRequiredContext): Promise<IVerifyCredentialResult>\n}\n\nexport interface IVcApiVerifierArgs {\n verifyUrl: string\n}\n\nexport interface IVerifyCredentialArgs {\n credential: CredentialPayload\n}\n\nexport interface IVerifyCredentialResult {\n checks: string[]\n errors: string[]\n warnings: string[]\n}\n\nexport enum events {\n CREDENTIAL_VERIFIED = 'credentialVerified',\n}\n\nexport type IRequiredContext = IAgentContext<Record<string, never>>\n","import { IAgentPlugin } from '@veramo/core'\n\nimport { schema } from '../index'\nimport {\n events,\n IRequiredContext,\n IVcApiVerifierClient,\n IVcApiVerifierArgs,\n IVerifyCredentialArgs,\n IVerifyCredentialResult,\n} from '../types/IVcApiVerifierClient'\n\nimport fetch from 'cross-fetch'\n\n/**\n * {@inheritDoc IVcApiVerifier}\n */\nexport class VcApiVerifierClient implements IAgentPlugin {\n readonly schema = schema.IVcApiVerfierClientAgentPlugin\n readonly methods: IVcApiVerifierClient = {\n vcApiClientVerifyCredential: this.vcApiClientVerifyCredential.bind(this),\n }\n private readonly verifyUrl: string\n\n constructor(options: IVcApiVerifierArgs) {\n this.verifyUrl = options.verifyUrl\n }\n\n /** {@inheritDoc IVcApiVerifier.vcApiClientVerifyCredential} */\n private async vcApiClientVerifyCredential(args: IVerifyCredentialArgs, context: IRequiredContext): Promise<IVerifyCredentialResult> {\n return await fetch(this.verifyUrl, {\n method: 'post',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ verifiableCredential: args.credential }),\n })\n .then(async (response) => {\n if (response.status >= 400) {\n throw new Error(await response.text())\n } else {\n return response.json()\n }\n })\n .then(async (verificationResult) => {\n await context.agent.emit(events.CREDENTIAL_VERIFIED, verificationResult)\n return verificationResult\n })\n }\n}\n"],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA;AAAA,gCAAAA,SAAA;AAAA,IAAAA,QAAA;AAAA,MACE,sBAAwB;AAAA,QACtB,YAAc;AAAA,UACZ,SAAW;AAAA,YACT,uBAAyB;AAAA,cACvB,MAAQ;AAAA,cACR,YAAc;AAAA,gBACZ,YAAc;AAAA,kBACZ,MAAQ;AAAA,gBACV;AAAA,cACF;AAAA,cACA,UAAY,CAAC,YAAY;AAAA,cACzB,sBAAwB;AAAA,YAC1B;AAAA,YACA,mBAAqB;AAAA,cACnB,MAAQ;AAAA,cACR,YAAc;AAAA,gBACZ,QAAU;AAAA,kBACR,MAAQ;AAAA,gBACV;AAAA,gBACA,mBAAqB;AAAA,kBACnB,MAAQ;AAAA,gBACV;AAAA,gBACA,MAAQ;AA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K,OAAOC,aAAAA;AACX,UAAIA,SAASC,UAAU,KAAK;AAC1B,cAAM,IAAIC,MAAM,MAAMF,SAASG,KAAI,CAAA;MACrC,OAAO;AACL,eAAOH,SAASI,KAAI;MACtB;IACF,CAAA,EACCL,KAAK,OAAOM,uBAAAA;AACX,YAAMhB,QAAQiB,MAAMC,KAAKC,OAAOC,qBAAqBJ,kBAAAA;AACrD,aAAOA;IACT,CAAA;EACJ;AACF;;;AF/CA,IAAMK,SAASC;","names":["module","events","VcApiVerifierClient","schema","IVcApiVerfierClientAgentPlugin","methods","vcApiClientVerifyCredential","bind","verifyUrl","options","args","context","fetch","method","headers","Accept","body","JSON","stringify","verifiableCredential","credential","then","response","status","Error","text","json","verificationResult","agent","emit","events","CREDENTIAL_VERIFIED","schema","require"]}
package/dist/index.js CHANGED
@@ -19,9 +19,7 @@ var require_plugin_schema = __commonJS({
19
19
  $ref: "#/components/schemas/CredentialPayload"
20
20
  }
21
21
  },
22
- required: [
23
- "credential"
24
- ],
22
+ required: ["credential"],
25
23
  additionalProperties: false
26
24
  },
27
25
  CredentialPayload: {
@@ -58,9 +56,7 @@ var require_plugin_schema = __commonJS({
58
56
  type: "string"
59
57
  }
60
58
  },
61
- required: [
62
- "issuer"
63
- ],
59
+ required: ["issuer"],
64
60
  description: "Used as input when creating Verifiable Credentials"
65
61
  },
66
62
  IssuerType: {
@@ -72,9 +68,7 @@ var require_plugin_schema = __commonJS({
72
68
  type: "string"
73
69
  }
74
70
  },
75
- required: [
76
- "id"
77
- ]
71
+ required: ["id"]
78
72
  },
79
73
  {
80
74
  type: "string"
@@ -113,10 +107,7 @@ var require_plugin_schema = __commonJS({
113
107
  type: "string"
114
108
  }
115
109
  },
116
- required: [
117
- "id",
118
- "type"
119
- ],
110
+ required: ["id", "type"],
120
111
  description: "Used for the discovery of information about the current status of a verifiable credential, such as whether it is suspended or revoked. The precise contents of the credential status information is determined by the specific `credentialStatus` type definition, and varies depending on factors such as whether it is simple to implement or if it is privacy-enhancing.\n\nSee {@link https://www.w3.org/TR/vc-data-model/#status | Credential Status }"
121
112
  },
122
113
  IVerifyCredentialResult: {
@@ -141,11 +132,7 @@ var require_plugin_schema = __commonJS({
141
132
  }
142
133
  }
143
134
  },
144
- required: [
145
- "checks",
146
- "errors",
147
- "warnings"
148
- ],
135
+ required: ["checks", "errors", "warnings"],
149
136
  additionalProperties: false
150
137
  }
151
138
  },
@@ -173,7 +160,7 @@ var events = /* @__PURE__ */ (function(events2) {
173
160
  })({});
174
161
 
175
162
  // src/agent/VcApiVerifierClient.ts
176
- import { fetch } from "cross-fetch";
163
+ import fetch from "cross-fetch";
177
164
  var VcApiVerifierClient = class {
178
165
  static {
179
166
  __name(this, "VcApiVerifierClient");
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"sources":["../plugin.schema.json","../src/types/IVcApiVerifierClient.ts","../src/agent/VcApiVerifierClient.ts","../src/index.ts"],"sourcesContent":["{\n \"IVcApiVerifierClient\": {\n \"components\": {\n \"schemas\": {\n \"IVerifyCredentialArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"credential\": {\n \"$ref\": \"#/components/schemas/CredentialPayload\"\n }\n },\n \"required\": [\n \"credential\"\n ],\n \"additionalProperties\": false\n },\n \"CredentialPayload\": {\n \"type\": \"object\",\n \"properties\": {\n \"issuer\": {\n \"$ref\": \"#/components/schemas/IssuerType\"\n },\n \"credentialSubject\": {\n \"$ref\": \"#/components/schemas/CredentialSubject\"\n },\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"@context\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"issuanceDate\": {\n \"$ref\": \"#/components/schemas/DateType\"\n },\n \"expirationDate\": {\n \"$ref\": \"#/components/schemas/DateType\"\n },\n \"credentialStatus\": {\n \"$ref\": \"#/components/schemas/CredentialStatusReference\"\n },\n \"id\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"issuer\"\n ],\n \"description\": \"Used as input when creating Verifiable Credentials\"\n },\n \"IssuerType\": {\n \"anyOf\": [\n {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"id\"\n ]\n },\n {\n \"type\": \"string\"\n }\n ],\n \"description\": \"The issuer of a {@link VerifiableCredential } or the holder of a {@link VerifiablePresentation } .\\n\\nThe value of the issuer property MUST be either a URI or an object containing an id property. It is RECOMMENDED that the URI in the issuer or its id be one which, if de-referenced, results in a document containing machine-readable information about the issuer that can be used to verify the information expressed in the credential.\\n\\nSee {@link https://www.w3.org/TR/vc-data-model/#issuer | Issuer data model }\"\n },\n \"CredentialSubject\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n }\n },\n \"description\": \"The value of the credentialSubject property is defined as a set of objects that contain one or more properties that are each related to a subject of the verifiable credential. Each object MAY contain an id.\\n\\nSee {@link https://www.w3.org/TR/vc-data-model/#credential-subject | Credential Subject }\"\n },\n \"DateType\": {\n \"anyOf\": [\n {\n \"type\": \"string\"\n },\n {\n \"type\": \"string\",\n \"format\": \"date-time\"\n }\n ],\n \"description\": \"Represents an issuance or expiration date for Credentials / Presentations. This is used as input when creating them.\"\n },\n \"CredentialStatusReference\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"type\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\n \"id\",\n \"type\"\n ],\n \"description\": \"Used for the discovery of information about the current status of a verifiable credential, such as whether it is suspended or revoked. The precise contents of the credential status information is determined by the specific `credentialStatus` type definition, and varies depending on factors such as whether it is simple to implement or if it is privacy-enhancing.\\n\\nSee {@link https://www.w3.org/TR/vc-data-model/#status | Credential Status }\"\n },\n \"IVerifyCredentialResult\": {\n \"type\": \"object\",\n \"properties\": {\n \"checks\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"errors\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"warnings\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\n \"checks\",\n \"errors\",\n \"warnings\"\n ],\n \"additionalProperties\": false\n }\n },\n \"methods\": {\n \"vcApiClientVerifyCredential\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IVerifyCredentialArgs\"\n },\n \"returnType\": {\n \"$ref\": \"#/components/schemas/IVerifyCredentialResult\"\n }\n }\n }\n }\n }\n}","import { CredentialPayload, IAgentContext, IPluginMethodMap } from '@veramo/core'\n\nexport interface IVcApiVerifierClient extends IPluginMethodMap {\n vcApiClientVerifyCredential(args: IVerifyCredentialArgs, context: IRequiredContext): Promise<IVerifyCredentialResult>\n}\n\nexport interface IVcApiVerifierArgs {\n verifyUrl: string\n}\n\nexport interface IVerifyCredentialArgs {\n credential: CredentialPayload\n}\n\nexport interface IVerifyCredentialResult {\n checks: string[]\n errors: string[]\n warnings: string[]\n}\n\nexport enum events {\n CREDENTIAL_VERIFIED = 'credentialVerified',\n}\n\nexport type IRequiredContext = IAgentContext<Record<string, never>>\n","import { IAgentPlugin } from '@veramo/core'\n\nimport { schema } from '../index'\nimport {\n events,\n IRequiredContext,\n IVcApiVerifierClient,\n IVcApiVerifierArgs,\n IVerifyCredentialArgs,\n IVerifyCredentialResult,\n} from '../types/IVcApiVerifierClient'\n\nimport { fetch } from 'cross-fetch'\n\n/**\n * {@inheritDoc IVcApiVerifier}\n */\nexport class VcApiVerifierClient implements IAgentPlugin {\n readonly schema = schema.IVcApiVerfierClientAgentPlugin\n readonly methods: IVcApiVerifierClient = {\n vcApiClientVerifyCredential: this.vcApiClientVerifyCredential.bind(this),\n }\n private readonly verifyUrl: string\n\n constructor(options: IVcApiVerifierArgs) {\n this.verifyUrl = options.verifyUrl\n }\n\n /** {@inheritDoc IVcApiVerifier.vcApiClientVerifyCredential} */\n private async vcApiClientVerifyCredential(args: IVerifyCredentialArgs, context: IRequiredContext): Promise<IVerifyCredentialResult> {\n return await fetch(this.verifyUrl, {\n method: 'post',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ verifiableCredential: args.credential }),\n })\n .then(async (response) => {\n if (response.status >= 400) {\n throw new Error(await response.text())\n } else {\n return response.json()\n }\n })\n .then(async (verificationResult) => {\n await context.agent.emit(events.CREDENTIAL_VERIFIED, verificationResult)\n return verificationResult\n })\n }\n}\n","/**\n * @public\n */\nconst schema = require('../plugin.schema.json')\nexport { schema }\nexport { VcApiVerifierClient } from './agent/VcApiVerifierClient'\nexport * from './types/IVcApiVerifierClient'\n"],"mappings":";;;;;;;;AAAA;AAAA;AAAA;AAAA,MACE,sBAAwB;AAAA,QACtB,YAAc;AAAA,UACZ,SAAW;AAAA,YACT,uBAAyB;AAAA,cACvB,MAAQ;AAAA,cACR,YAAc;AAAA,gBACZ,YAAc;AAAA,kBACZ,MAAQ;AAAA,gBACV;AAAA,cACF;AAAA,cACA,UAAY;AAAA,gBACV;AAAA,cACF;AAAA,cACA,sBAAwB;AAAA,YAC1B;AAAA,YACA,mBAAqB;AAAA,cACnB,MAAQ;AAAA,cACR,YAAc;AAAA,gBACZ,QAAU;AAAA,kBACR,MAAQ;AAAA,gBACV;AAAA,gBACA,mBAAqB;AAAA,kBACnB,MAAQ;AAAA,gBACV;AAAA,gBACA,MAAQ;AAAA,kBACN,MAAQ;AAAA,kBACR,OAAS;AAAA,oBACP,MAAQ;AAAA,kBACV;AAAA,gBACF;AAAA,gBACA,YAAY;AAAA,kBACV,MAAQ;AAAA,kBACR,OAAS;AAAA,oBACP,MAAQ;AAAA,kBACV;AAAA,gBACF;AAAA,gBACA,cAAgB;AAAA,kBACd,MAAQ;AAAA,gBACV;AAAA,gBACA,gBAAkB;AAAA,kBAChB,MAAQ;AAAA,gBACV;AAAA,gBACA,kBAAoB;AAAA,kBAClB,MAAQ;AAAA,gBACV;AAAA,gBACA,IAAM;AAAA,kBACJ,MAAQ;AAAA,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entPlugin","methods","vcApiClientVerifyCredential","bind","verifyUrl","options","args","context","fetch","method","headers","Accept","body","JSON","stringify","verifiableCredential","credential","then","response","status","Error","text","json","verificationResult","agent","emit","events","CREDENTIAL_VERIFIED","schema","require"]}
1
+ {"version":3,"sources":["../plugin.schema.json","../src/types/IVcApiVerifierClient.ts","../src/agent/VcApiVerifierClient.ts","../src/index.ts"],"sourcesContent":["{\n \"IVcApiVerifierClient\": {\n \"components\": {\n \"schemas\": {\n \"IVerifyCredentialArgs\": {\n \"type\": \"object\",\n \"properties\": {\n \"credential\": {\n \"$ref\": \"#/components/schemas/CredentialPayload\"\n }\n },\n \"required\": [\"credential\"],\n \"additionalProperties\": false\n },\n \"CredentialPayload\": {\n \"type\": \"object\",\n \"properties\": {\n \"issuer\": {\n \"$ref\": \"#/components/schemas/IssuerType\"\n },\n \"credentialSubject\": {\n \"$ref\": \"#/components/schemas/CredentialSubject\"\n },\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"@context\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"issuanceDate\": {\n \"$ref\": \"#/components/schemas/DateType\"\n },\n \"expirationDate\": {\n \"$ref\": \"#/components/schemas/DateType\"\n },\n \"credentialStatus\": {\n \"$ref\": \"#/components/schemas/CredentialStatusReference\"\n },\n \"id\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\"issuer\"],\n \"description\": \"Used as input when creating Verifiable Credentials\"\n },\n \"IssuerType\": {\n \"anyOf\": [\n {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\"id\"]\n },\n {\n \"type\": \"string\"\n }\n ],\n \"description\": \"The issuer of a {@link VerifiableCredential } or the holder of a {@link VerifiablePresentation } .\\n\\nThe value of the issuer property MUST be either a URI or an object containing an id property. It is RECOMMENDED that the URI in the issuer or its id be one which, if de-referenced, results in a document containing machine-readable information about the issuer that can be used to verify the information expressed in the credential.\\n\\nSee {@link https://www.w3.org/TR/vc-data-model/#issuer | Issuer data model }\"\n },\n \"CredentialSubject\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n }\n },\n \"description\": \"The value of the credentialSubject property is defined as a set of objects that contain one or more properties that are each related to a subject of the verifiable credential. Each object MAY contain an id.\\n\\nSee {@link https://www.w3.org/TR/vc-data-model/#credential-subject | Credential Subject }\"\n },\n \"DateType\": {\n \"anyOf\": [\n {\n \"type\": \"string\"\n },\n {\n \"type\": \"string\",\n \"format\": \"date-time\"\n }\n ],\n \"description\": \"Represents an issuance or expiration date for Credentials / Presentations. This is used as input when creating them.\"\n },\n \"CredentialStatusReference\": {\n \"type\": \"object\",\n \"properties\": {\n \"id\": {\n \"type\": \"string\"\n },\n \"type\": {\n \"type\": \"string\"\n }\n },\n \"required\": [\"id\", \"type\"],\n \"description\": \"Used for the discovery of information about the current status of a verifiable credential, such as whether it is suspended or revoked. The precise contents of the credential status information is determined by the specific `credentialStatus` type definition, and varies depending on factors such as whether it is simple to implement or if it is privacy-enhancing.\\n\\nSee {@link https://www.w3.org/TR/vc-data-model/#status | Credential Status }\"\n },\n \"IVerifyCredentialResult\": {\n \"type\": \"object\",\n \"properties\": {\n \"checks\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"errors\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n },\n \"warnings\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"string\"\n }\n }\n },\n \"required\": [\"checks\", \"errors\", \"warnings\"],\n \"additionalProperties\": false\n }\n },\n \"methods\": {\n \"vcApiClientVerifyCredential\": {\n \"description\": \"\",\n \"arguments\": {\n \"$ref\": \"#/components/schemas/IVerifyCredentialArgs\"\n },\n \"returnType\": {\n \"$ref\": \"#/components/schemas/IVerifyCredentialResult\"\n }\n }\n }\n }\n }\n}\n","import { CredentialPayload, IAgentContext, IPluginMethodMap } from '@veramo/core'\n\nexport interface IVcApiVerifierClient extends IPluginMethodMap {\n vcApiClientVerifyCredential(args: IVerifyCredentialArgs, context: IRequiredContext): Promise<IVerifyCredentialResult>\n}\n\nexport interface IVcApiVerifierArgs {\n verifyUrl: string\n}\n\nexport interface IVerifyCredentialArgs {\n credential: CredentialPayload\n}\n\nexport interface IVerifyCredentialResult {\n checks: string[]\n errors: string[]\n warnings: string[]\n}\n\nexport enum events {\n CREDENTIAL_VERIFIED = 'credentialVerified',\n}\n\nexport type IRequiredContext = IAgentContext<Record<string, never>>\n","import { IAgentPlugin } from '@veramo/core'\n\nimport { schema } from '../index'\nimport {\n events,\n IRequiredContext,\n IVcApiVerifierClient,\n IVcApiVerifierArgs,\n IVerifyCredentialArgs,\n IVerifyCredentialResult,\n} from '../types/IVcApiVerifierClient'\n\nimport fetch from 'cross-fetch'\n\n/**\n * {@inheritDoc IVcApiVerifier}\n */\nexport class VcApiVerifierClient implements IAgentPlugin {\n readonly schema = schema.IVcApiVerfierClientAgentPlugin\n readonly methods: IVcApiVerifierClient = {\n vcApiClientVerifyCredential: this.vcApiClientVerifyCredential.bind(this),\n }\n private readonly verifyUrl: string\n\n constructor(options: IVcApiVerifierArgs) {\n this.verifyUrl = options.verifyUrl\n }\n\n /** {@inheritDoc IVcApiVerifier.vcApiClientVerifyCredential} */\n private async vcApiClientVerifyCredential(args: IVerifyCredentialArgs, context: IRequiredContext): Promise<IVerifyCredentialResult> {\n return await fetch(this.verifyUrl, {\n method: 'post',\n headers: {\n Accept: 'application/json',\n 'Content-Type': 'application/json',\n },\n body: JSON.stringify({ verifiableCredential: args.credential }),\n })\n .then(async (response) => {\n if (response.status >= 400) {\n throw new Error(await response.text())\n } else {\n return response.json()\n }\n })\n .then(async (verificationResult) => {\n await context.agent.emit(events.CREDENTIAL_VERIFIED, verificationResult)\n return verificationResult\n })\n }\n}\n","/**\n * @public\n */\nconst schema = require('../plugin.schema.json')\nexport { schema }\nexport { VcApiVerifierClient } from './agent/VcApiVerifierClient'\nexport * from './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AA;;SAAAA;;;;ACRZ,OAAOC,WAAW;AAKX,IAAMC,sBAAN,MAAMA;EAfb,OAeaA;;;EACFC,SAASA,OAAOC;EAChBC,UAAgC;IACvCC,6BAA6B,KAAKA,4BAA4BC,KAAK,IAAI;EACzE;EACiBC;EAEjB,YAAYC,SAA6B;AACvC,SAAKD,YAAYC,QAAQD;EAC3B;;EAGA,MAAcF,4BAA4BI,MAA6BC,SAA6D;AAClI,WAAO,MAAMC,MAAM,KAAKJ,WAAW;MACjCK,QAAQ;MACRC,SAAS;QACPC,QAAQ;QACR,gBAAgB;MAClB;MACAC,MAAMC,KAAKC,UAAU;QAAEC,sBAAsBT,KAAKU;MAAW,CAAA;IAC/D,CAAA,EACGC,KAAK,OAAOC,aAAAA;AACX,UAAIA,SAASC,UAAU,KAAK;AAC1B,cAAM,IAAIC,MAAM,MAAMF,SAASG,KAAI,CAAA;MACrC,OAAO;AACL,eAAOH,SAASI,KAAI;MACtB;IACF,CAAA,EACCL,KAAK,OAAOM,uBAAAA;AACX,YAAMhB,QAAQiB,MAAMC,KAAKC,OAAOC,qBAAqBJ,kBAAAA;AACrD,aAAOA;IACT,CAAA;EACJ;AACF;;;AC/CA,IAAMK,SAASC;","names":["events","fetch","VcApiVerifierClient","schema","IVcApiVerfierClientAgentPlugin","methods","vcApiClientVerifyCredential","bind","verifyUrl","options","args","context","fetch","method","headers","Accept","body","JSON","stringify","verifiableCredential","credential","then","response","status","Error","text","json","verificationResult","agent","emit","events","CREDENTIAL_VERIFIED","schema","require"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sphereon/ssi-sdk.w3c-vc-api-verifier-rest-client",
3
- "version": "0.34.1-next.88+7d5f01ed",
3
+ "version": "0.36.0",
4
4
  "source": "src/index.ts",
5
5
  "type": "module",
6
6
  "main": "./dist/index.cjs",
@@ -31,7 +31,7 @@
31
31
  "cross-fetch": "^4.1.0"
32
32
  },
33
33
  "devDependencies": {
34
- "@sphereon/ssi-sdk.dev": "0.34.1-next.88+7d5f01ed",
34
+ "@sphereon/ssi-sdk.dev": "0.36.0",
35
35
  "@veramo/cli": "4.2.0",
36
36
  "@veramo/remote-client": "4.2.0",
37
37
  "@veramo/remote-server": "4.2.0"
@@ -58,5 +58,5 @@
58
58
  "API",
59
59
  "Verifier"
60
60
  ],
61
- "gitHead": "7d5f01eddab106d7ef084dcef21191ab8dd5f20f"
61
+ "gitHead": "f713d3a83948ef69aaa7d435700b16d5655ac863"
62
62
  }
@@ -9,9 +9,7 @@
9
9
  "$ref": "#/components/schemas/CredentialPayload"
10
10
  }
11
11
  },
12
- "required": [
13
- "credential"
14
- ],
12
+ "required": ["credential"],
15
13
  "additionalProperties": false
16
14
  },
17
15
  "CredentialPayload": {
@@ -48,9 +46,7 @@
48
46
  "type": "string"
49
47
  }
50
48
  },
51
- "required": [
52
- "issuer"
53
- ],
49
+ "required": ["issuer"],
54
50
  "description": "Used as input when creating Verifiable Credentials"
55
51
  },
56
52
  "IssuerType": {
@@ -62,9 +58,7 @@
62
58
  "type": "string"
63
59
  }
64
60
  },
65
- "required": [
66
- "id"
67
- ]
61
+ "required": ["id"]
68
62
  },
69
63
  {
70
64
  "type": "string"
@@ -103,10 +97,7 @@
103
97
  "type": "string"
104
98
  }
105
99
  },
106
- "required": [
107
- "id",
108
- "type"
109
- ],
100
+ "required": ["id", "type"],
110
101
  "description": "Used for the discovery of information about the current status of a verifiable credential, such as whether it is suspended or revoked. The precise contents of the credential status information is determined by the specific `credentialStatus` type definition, and varies depending on factors such as whether it is simple to implement or if it is privacy-enhancing.\n\nSee {@link https://www.w3.org/TR/vc-data-model/#status | Credential Status }"
111
102
  },
112
103
  "IVerifyCredentialResult": {
@@ -131,11 +122,7 @@
131
122
  }
132
123
  }
133
124
  },
134
- "required": [
135
- "checks",
136
- "errors",
137
- "warnings"
138
- ],
125
+ "required": ["checks", "errors", "warnings"],
139
126
  "additionalProperties": false
140
127
  }
141
128
  },
@@ -152,4 +139,4 @@
152
139
  }
153
140
  }
154
141
  }
155
- }
142
+ }
@@ -10,7 +10,7 @@ import {
10
10
  IVerifyCredentialResult,
11
11
  } from '../types/IVcApiVerifierClient'
12
12
 
13
- import { fetch } from 'cross-fetch'
13
+ import fetch from 'cross-fetch'
14
14
 
15
15
  /**
16
16
  * {@inheritDoc IVcApiVerifier}