@sphereon/ssi-sdk.w3c-vc-api-verifier-rest-client 0.33.1-next.3 → 0.33.1-next.73

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 ADDED
@@ -0,0 +1,227 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
7
+ var __commonJS = (cb, mod) => function __require() {
8
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
9
+ };
10
+ var __export = (target, all) => {
11
+ for (var name in all)
12
+ __defProp(target, name, { get: all[name], enumerable: true });
13
+ };
14
+ var __copyProps = (to, from, except, desc) => {
15
+ if (from && typeof from === "object" || typeof from === "function") {
16
+ for (let key of __getOwnPropNames(from))
17
+ if (!__hasOwnProp.call(to, key) && key !== except)
18
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
19
+ }
20
+ return to;
21
+ };
22
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
23
+
24
+ // plugin.schema.json
25
+ var require_plugin_schema = __commonJS({
26
+ "plugin.schema.json"(exports, module2) {
27
+ module2.exports = {
28
+ IVcApiVerifierClient: {
29
+ components: {
30
+ schemas: {
31
+ IVerifyCredentialArgs: {
32
+ type: "object",
33
+ properties: {
34
+ credential: {
35
+ $ref: "#/components/schemas/CredentialPayload"
36
+ }
37
+ },
38
+ required: ["credential"],
39
+ additionalProperties: false
40
+ },
41
+ CredentialPayload: {
42
+ type: "object",
43
+ properties: {
44
+ issuer: {
45
+ $ref: "#/components/schemas/IssuerType"
46
+ },
47
+ credentialSubject: {
48
+ $ref: "#/components/schemas/CredentialSubject"
49
+ },
50
+ type: {
51
+ type: "array",
52
+ items: {
53
+ type: "string"
54
+ }
55
+ },
56
+ "@context": {
57
+ type: "array",
58
+ items: {
59
+ type: "string"
60
+ }
61
+ },
62
+ issuanceDate: {
63
+ $ref: "#/components/schemas/DateType"
64
+ },
65
+ expirationDate: {
66
+ $ref: "#/components/schemas/DateType"
67
+ },
68
+ credentialStatus: {
69
+ $ref: "#/components/schemas/CredentialStatusReference"
70
+ },
71
+ id: {
72
+ type: "string"
73
+ }
74
+ },
75
+ required: ["issuer"],
76
+ description: "Used as input when creating Verifiable Credentials"
77
+ },
78
+ IssuerType: {
79
+ anyOf: [
80
+ {
81
+ type: "object",
82
+ properties: {
83
+ id: {
84
+ type: "string"
85
+ }
86
+ },
87
+ required: ["id"]
88
+ },
89
+ {
90
+ type: "string"
91
+ }
92
+ ],
93
+ 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 }"
94
+ },
95
+ CredentialSubject: {
96
+ type: "object",
97
+ properties: {
98
+ id: {
99
+ type: "string"
100
+ }
101
+ },
102
+ 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 }"
103
+ },
104
+ DateType: {
105
+ anyOf: [
106
+ {
107
+ type: "string"
108
+ },
109
+ {
110
+ type: "string",
111
+ format: "date-time"
112
+ }
113
+ ],
114
+ description: "Represents an issuance or expiration date for Credentials / Presentations. This is used as input when creating them."
115
+ },
116
+ CredentialStatusReference: {
117
+ type: "object",
118
+ properties: {
119
+ id: {
120
+ type: "string"
121
+ },
122
+ type: {
123
+ type: "string"
124
+ }
125
+ },
126
+ required: ["id", "type"],
127
+ 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 }"
128
+ },
129
+ IVerifyCredentialResult: {
130
+ type: "object",
131
+ properties: {
132
+ checks: {
133
+ type: "array",
134
+ items: {
135
+ type: "string"
136
+ }
137
+ },
138
+ errors: {
139
+ type: "array",
140
+ items: {
141
+ type: "string"
142
+ }
143
+ },
144
+ warnings: {
145
+ type: "array",
146
+ items: {
147
+ type: "string"
148
+ }
149
+ }
150
+ },
151
+ required: ["checks", "errors", "warnings"],
152
+ additionalProperties: false
153
+ }
154
+ },
155
+ methods: {
156
+ vcApiClientVerifyCredential: {
157
+ description: "",
158
+ arguments: {
159
+ $ref: "#/components/schemas/IVerifyCredentialArgs"
160
+ },
161
+ returnType: {
162
+ $ref: "#/components/schemas/IVerifyCredentialResult"
163
+ }
164
+ }
165
+ }
166
+ }
167
+ }
168
+ };
169
+ }
170
+ });
171
+
172
+ // src/index.ts
173
+ var index_exports = {};
174
+ __export(index_exports, {
175
+ VcApiVerifierClient: () => VcApiVerifierClient,
176
+ events: () => events,
177
+ schema: () => schema
178
+ });
179
+ module.exports = __toCommonJS(index_exports);
180
+
181
+ // src/types/IVcApiVerifierClient.ts
182
+ var events = /* @__PURE__ */ function(events2) {
183
+ events2["CREDENTIAL_VERIFIED"] = "credentialVerified";
184
+ return events2;
185
+ }({});
186
+
187
+ // src/agent/VcApiVerifierClient.ts
188
+ var import_cross_fetch = require("cross-fetch");
189
+ var VcApiVerifierClient = class {
190
+ static {
191
+ __name(this, "VcApiVerifierClient");
192
+ }
193
+ schema = schema.IVcApiVerfierClientAgentPlugin;
194
+ methods = {
195
+ vcApiClientVerifyCredential: this.vcApiClientVerifyCredential.bind(this)
196
+ };
197
+ verifyUrl;
198
+ constructor(options) {
199
+ this.verifyUrl = options.verifyUrl;
200
+ }
201
+ /** {@inheritDoc IVcApiVerifier.vcApiClientVerifyCredential} */
202
+ async vcApiClientVerifyCredential(args, context) {
203
+ return await (0, import_cross_fetch.fetch)(this.verifyUrl, {
204
+ method: "post",
205
+ headers: {
206
+ Accept: "application/json",
207
+ "Content-Type": "application/json"
208
+ },
209
+ body: JSON.stringify({
210
+ verifiableCredential: args.credential
211
+ })
212
+ }).then(async (response) => {
213
+ if (response.status >= 400) {
214
+ throw new Error(await response.text());
215
+ } else {
216
+ return response.json();
217
+ }
218
+ }).then(async (verificationResult) => {
219
+ await context.agent.emit(events.CREDENTIAL_VERIFIED, verificationResult);
220
+ return verificationResult;
221
+ });
222
+ }
223
+ };
224
+
225
+ // src/index.ts
226
+ var schema = require_plugin_schema();
227
+ //# sourceMappingURL=index.cjs.map
@@ -0,0 +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\": [\"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;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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erfierClientAgentPlugin","methods","vcApiClientVerifyCredential","bind","verifyUrl","constructor","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"]}
@@ -0,0 +1,39 @@
1
+ import { IPluginMethodMap, CredentialPayload, IAgentContext, IAgentPlugin } from '@veramo/core';
2
+
3
+ interface IVcApiVerifierClient extends IPluginMethodMap {
4
+ vcApiClientVerifyCredential(args: IVerifyCredentialArgs, context: IRequiredContext): Promise<IVerifyCredentialResult>;
5
+ }
6
+ interface IVcApiVerifierArgs {
7
+ verifyUrl: string;
8
+ }
9
+ interface IVerifyCredentialArgs {
10
+ credential: CredentialPayload;
11
+ }
12
+ interface IVerifyCredentialResult {
13
+ checks: string[];
14
+ errors: string[];
15
+ warnings: string[];
16
+ }
17
+ declare enum events {
18
+ CREDENTIAL_VERIFIED = "credentialVerified"
19
+ }
20
+ type IRequiredContext = IAgentContext<Record<string, never>>;
21
+
22
+ /**
23
+ * {@inheritDoc IVcApiVerifier}
24
+ */
25
+ declare class VcApiVerifierClient implements IAgentPlugin {
26
+ readonly schema: any;
27
+ readonly methods: IVcApiVerifierClient;
28
+ private readonly verifyUrl;
29
+ constructor(options: IVcApiVerifierArgs);
30
+ /** {@inheritDoc IVcApiVerifier.vcApiClientVerifyCredential} */
31
+ private vcApiClientVerifyCredential;
32
+ }
33
+
34
+ /**
35
+ * @public
36
+ */
37
+ declare const schema: any;
38
+
39
+ export { type IRequiredContext, type IVcApiVerifierArgs, type IVcApiVerifierClient, type IVerifyCredentialArgs, type IVerifyCredentialResult, VcApiVerifierClient, events, schema };
package/dist/index.d.ts CHANGED
@@ -1,8 +1,39 @@
1
+ import { IPluginMethodMap, CredentialPayload, IAgentContext, IAgentPlugin } from '@veramo/core';
2
+
3
+ interface IVcApiVerifierClient extends IPluginMethodMap {
4
+ vcApiClientVerifyCredential(args: IVerifyCredentialArgs, context: IRequiredContext): Promise<IVerifyCredentialResult>;
5
+ }
6
+ interface IVcApiVerifierArgs {
7
+ verifyUrl: string;
8
+ }
9
+ interface IVerifyCredentialArgs {
10
+ credential: CredentialPayload;
11
+ }
12
+ interface IVerifyCredentialResult {
13
+ checks: string[];
14
+ errors: string[];
15
+ warnings: string[];
16
+ }
17
+ declare enum events {
18
+ CREDENTIAL_VERIFIED = "credentialVerified"
19
+ }
20
+ type IRequiredContext = IAgentContext<Record<string, never>>;
21
+
22
+ /**
23
+ * {@inheritDoc IVcApiVerifier}
24
+ */
25
+ declare class VcApiVerifierClient implements IAgentPlugin {
26
+ readonly schema: any;
27
+ readonly methods: IVcApiVerifierClient;
28
+ private readonly verifyUrl;
29
+ constructor(options: IVcApiVerifierArgs);
30
+ /** {@inheritDoc IVcApiVerifier.vcApiClientVerifyCredential} */
31
+ private vcApiClientVerifyCredential;
32
+ }
33
+
1
34
  /**
2
35
  * @public
3
36
  */
4
37
  declare const schema: any;
5
- export { schema };
6
- export { VcApiVerifierClient } from './agent/VcApiVerifierClient';
7
- export * from './types/IVcApiVerifierClient';
8
- //# sourceMappingURL=index.d.ts.map
38
+
39
+ export { type IRequiredContext, type IVcApiVerifierArgs, type IVcApiVerifierClient, type IVerifyCredentialArgs, type IVerifyCredentialResult, VcApiVerifierClient, events, schema };
package/dist/index.js CHANGED
@@ -1,26 +1,207 @@
1
- "use strict";
2
- var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
- if (k2 === undefined) k2 = k;
4
- var desc = Object.getOwnPropertyDescriptor(m, k);
5
- if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
- desc = { enumerable: true, get: function() { return m[k]; } };
7
- }
8
- Object.defineProperty(o, k2, desc);
9
- }) : (function(o, m, k, k2) {
10
- if (k2 === undefined) k2 = k;
11
- o[k2] = m[k];
12
- }));
13
- var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
- for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
1
+ var __defProp = Object.defineProperty;
2
+ var __getOwnPropNames = Object.getOwnPropertyNames;
3
+ var __name = (target, value) => __defProp(target, "name", { value, configurable: true });
4
+ var __commonJS = (cb, mod) => function __require() {
5
+ return mod || (0, cb[__getOwnPropNames(cb)[0]])((mod = { exports: {} }).exports, mod), mod.exports;
6
+ };
7
+
8
+ // plugin.schema.json
9
+ var require_plugin_schema = __commonJS({
10
+ "plugin.schema.json"(exports, module) {
11
+ module.exports = {
12
+ IVcApiVerifierClient: {
13
+ components: {
14
+ schemas: {
15
+ IVerifyCredentialArgs: {
16
+ type: "object",
17
+ properties: {
18
+ credential: {
19
+ $ref: "#/components/schemas/CredentialPayload"
20
+ }
21
+ },
22
+ required: ["credential"],
23
+ additionalProperties: false
24
+ },
25
+ CredentialPayload: {
26
+ type: "object",
27
+ properties: {
28
+ issuer: {
29
+ $ref: "#/components/schemas/IssuerType"
30
+ },
31
+ credentialSubject: {
32
+ $ref: "#/components/schemas/CredentialSubject"
33
+ },
34
+ type: {
35
+ type: "array",
36
+ items: {
37
+ type: "string"
38
+ }
39
+ },
40
+ "@context": {
41
+ type: "array",
42
+ items: {
43
+ type: "string"
44
+ }
45
+ },
46
+ issuanceDate: {
47
+ $ref: "#/components/schemas/DateType"
48
+ },
49
+ expirationDate: {
50
+ $ref: "#/components/schemas/DateType"
51
+ },
52
+ credentialStatus: {
53
+ $ref: "#/components/schemas/CredentialStatusReference"
54
+ },
55
+ id: {
56
+ type: "string"
57
+ }
58
+ },
59
+ required: ["issuer"],
60
+ description: "Used as input when creating Verifiable Credentials"
61
+ },
62
+ IssuerType: {
63
+ anyOf: [
64
+ {
65
+ type: "object",
66
+ properties: {
67
+ id: {
68
+ type: "string"
69
+ }
70
+ },
71
+ required: ["id"]
72
+ },
73
+ {
74
+ type: "string"
75
+ }
76
+ ],
77
+ 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 }"
78
+ },
79
+ CredentialSubject: {
80
+ type: "object",
81
+ properties: {
82
+ id: {
83
+ type: "string"
84
+ }
85
+ },
86
+ 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 }"
87
+ },
88
+ DateType: {
89
+ anyOf: [
90
+ {
91
+ type: "string"
92
+ },
93
+ {
94
+ type: "string",
95
+ format: "date-time"
96
+ }
97
+ ],
98
+ description: "Represents an issuance or expiration date for Credentials / Presentations. This is used as input when creating them."
99
+ },
100
+ CredentialStatusReference: {
101
+ type: "object",
102
+ properties: {
103
+ id: {
104
+ type: "string"
105
+ },
106
+ type: {
107
+ type: "string"
108
+ }
109
+ },
110
+ required: ["id", "type"],
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 }"
112
+ },
113
+ IVerifyCredentialResult: {
114
+ type: "object",
115
+ properties: {
116
+ checks: {
117
+ type: "array",
118
+ items: {
119
+ type: "string"
120
+ }
121
+ },
122
+ errors: {
123
+ type: "array",
124
+ items: {
125
+ type: "string"
126
+ }
127
+ },
128
+ warnings: {
129
+ type: "array",
130
+ items: {
131
+ type: "string"
132
+ }
133
+ }
134
+ },
135
+ required: ["checks", "errors", "warnings"],
136
+ additionalProperties: false
137
+ }
138
+ },
139
+ methods: {
140
+ vcApiClientVerifyCredential: {
141
+ description: "",
142
+ arguments: {
143
+ $ref: "#/components/schemas/IVerifyCredentialArgs"
144
+ },
145
+ returnType: {
146
+ $ref: "#/components/schemas/IVerifyCredentialResult"
147
+ }
148
+ }
149
+ }
150
+ }
151
+ }
152
+ };
153
+ }
154
+ });
155
+
156
+ // src/types/IVcApiVerifierClient.ts
157
+ var events = /* @__PURE__ */ function(events2) {
158
+ events2["CREDENTIAL_VERIFIED"] = "credentialVerified";
159
+ return events2;
160
+ }({});
161
+
162
+ // src/agent/VcApiVerifierClient.ts
163
+ import { fetch } from "cross-fetch";
164
+ var VcApiVerifierClient = class {
165
+ static {
166
+ __name(this, "VcApiVerifierClient");
167
+ }
168
+ schema = schema.IVcApiVerfierClientAgentPlugin;
169
+ methods = {
170
+ vcApiClientVerifyCredential: this.vcApiClientVerifyCredential.bind(this)
171
+ };
172
+ verifyUrl;
173
+ constructor(options) {
174
+ this.verifyUrl = options.verifyUrl;
175
+ }
176
+ /** {@inheritDoc IVcApiVerifier.vcApiClientVerifyCredential} */
177
+ async vcApiClientVerifyCredential(args, context) {
178
+ return await fetch(this.verifyUrl, {
179
+ method: "post",
180
+ headers: {
181
+ Accept: "application/json",
182
+ "Content-Type": "application/json"
183
+ },
184
+ body: JSON.stringify({
185
+ verifiableCredential: args.credential
186
+ })
187
+ }).then(async (response) => {
188
+ if (response.status >= 400) {
189
+ throw new Error(await response.text());
190
+ } else {
191
+ return response.json();
192
+ }
193
+ }).then(async (verificationResult) => {
194
+ await context.agent.emit(events.CREDENTIAL_VERIFIED, verificationResult);
195
+ return verificationResult;
196
+ });
197
+ }
198
+ };
199
+
200
+ // src/index.ts
201
+ var schema = require_plugin_schema();
202
+ export {
203
+ VcApiVerifierClient,
204
+ events,
205
+ schema
15
206
  };
16
- Object.defineProperty(exports, "__esModule", { value: true });
17
- exports.VcApiVerifierClient = exports.schema = void 0;
18
- /**
19
- * @public
20
- */
21
- const schema = require('../plugin.schema.json');
22
- exports.schema = schema;
23
- var VcApiVerifierClient_1 = require("./agent/VcApiVerifierClient");
24
- Object.defineProperty(exports, "VcApiVerifierClient", { enumerable: true, get: function () { return VcApiVerifierClient_1.VcApiVerifierClient; } });
25
- __exportStar(require("./types/IVcApiVerifierClient"), exports);
26
207
  //# sourceMappingURL=index.js.map
package/dist/index.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;AAAA;;GAEG;AACH,MAAM,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;AACtC,wBAAM;AACf,mEAAiE;AAAxD,0HAAA,mBAAmB,OAAA;AAC5B,+DAA4C"}
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 './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,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;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,gBACV;AAAA,cACF;AAAA,cACA,UAAY,CAAC,QAAQ;AAAA,cACrB,aAAe;AAAA,YACjB;AAAA,YACA,YAAc;AAAA,cACZ,OAAS;AAAA,gBACP;AAAA,kBACE,MAAQ;AAAA,kBACR,YAAc;AAAA,oBACZ,IAAM;AAAA,s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AA,cACf,WAAa;AAAA,gBACX,MAAQ;AAAA,cACV;AAAA,cACA,YAAc;AAAA,gBACZ,MAAQ;AAAA,cACV;AAAA,YACF;AAAA,UACF;AAAA,QACF;AAAA,MACF;AAAA,IACF;AAAA;AAAA;;;ACzHO,IAAKA,SAAAA,yBAAAA,SAAAA;;SAAAA;;;;ACRZ,SAASC,aAAa;AAKf,IAAMC,sBAAN,MAAMA;EAfb,OAeaA;;;EACFC,SAASA,OAAOC;EAChBC,UAAgC;IACvCC,6BAA6B,KAAKA,4BAA4BC,KAAK,IAAI;EACzE;EACiBC;EAEjBC,YAAYC,SAA6B;AACvC,SAAKF,YAAYE,QAAQF;EAC3B;;EAGA,MAAcF,4BAA4BK,MAA6BC,SAA6D;AAClI,WAAO,MAAMC,MAAM,KAAKL,WAAW;MACjCM,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","constructor","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,17 +1,29 @@
1
1
  {
2
2
  "name": "@sphereon/ssi-sdk.w3c-vc-api-verifier-rest-client",
3
- "version": "0.33.1-next.3+fd1a6fba",
3
+ "version": "0.33.1-next.73+be17b2cb",
4
4
  "source": "src/index.ts",
5
- "main": "dist/index.js",
6
- "types": "dist/index.d.ts",
5
+ "type": "module",
6
+ "main": "./dist/index.cjs",
7
+ "module": "./dist/index.js",
8
+ "types": "./dist/index.d.ts",
9
+ "exports": {
10
+ "react-native": "./dist/index.js",
11
+ "import": {
12
+ "types": "./dist/index.d.ts",
13
+ "import": "./dist/index.js"
14
+ },
15
+ "require": {
16
+ "types": "./dist/index.d.cts",
17
+ "require": "./dist/index.cjs"
18
+ }
19
+ },
7
20
  "veramo": {
8
21
  "pluginInterfaces": {
9
22
  "IVcApiVerifierClient": "./src/types/IVcApiVerifierClient.ts"
10
23
  }
11
24
  },
12
25
  "scripts": {
13
- "build": "tsc --build",
14
- "build:clean": "tsc --build --clean && tsc --build",
26
+ "build": "tsup --config ../../tsup.config.ts --tsconfig ../../tsconfig.tsup.json",
15
27
  "generate-plugin-schema": "ts-node ../../packages/dev/bin/sphereon.js dev generate-plugin-schema"
16
28
  },
17
29
  "dependencies": {
@@ -19,14 +31,14 @@
19
31
  "cross-fetch": "^3.1.8"
20
32
  },
21
33
  "devDependencies": {
22
- "@sphereon/ssi-sdk.dev": "0.33.1-next.3+fd1a6fba",
34
+ "@sphereon/ssi-sdk.dev": "0.33.1-next.73+be17b2cb",
23
35
  "@veramo/cli": "4.2.0",
24
36
  "@veramo/remote-client": "4.2.0",
25
37
  "@veramo/remote-server": "4.2.0"
26
38
  },
27
39
  "files": [
28
- "dist/**/*",
29
- "src/**/*",
40
+ "dist",
41
+ "src",
30
42
  "README.md",
31
43
  "plugin.schema.json",
32
44
  "LICENSE"
@@ -46,6 +58,5 @@
46
58
  "API",
47
59
  "Verifier"
48
60
  ],
49
- "nx": {},
50
- "gitHead": "fd1a6fba306a83a73ff7c531db87fa207dbf436d"
61
+ "gitHead": "be17b2cb752a6e5368119259e89a1f2a99f56848"
51
62
  }
@@ -9,9 +9,8 @@
9
9
  "$ref": "#/components/schemas/CredentialPayload"
10
10
  }
11
11
  },
12
- "required": [
13
- "credential"
14
- ]
12
+ "required": ["credential"],
13
+ "additionalProperties": false
15
14
  },
16
15
  "CredentialPayload": {
17
16
  "type": "object",
@@ -47,9 +46,7 @@
47
46
  "type": "string"
48
47
  }
49
48
  },
50
- "required": [
51
- "issuer"
52
- ],
49
+ "required": ["issuer"],
53
50
  "description": "Used as input when creating Verifiable Credentials"
54
51
  },
55
52
  "IssuerType": {
@@ -61,9 +58,7 @@
61
58
  "type": "string"
62
59
  }
63
60
  },
64
- "required": [
65
- "id"
66
- ]
61
+ "required": ["id"]
67
62
  },
68
63
  {
69
64
  "type": "string"
@@ -102,10 +97,7 @@
102
97
  "type": "string"
103
98
  }
104
99
  },
105
- "required": [
106
- "id",
107
- "type"
108
- ],
100
+ "required": ["id", "type"],
109
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 }"
110
102
  },
111
103
  "IVerifyCredentialResult": {
@@ -130,11 +122,8 @@
130
122
  }
131
123
  }
132
124
  },
133
- "required": [
134
- "checks",
135
- "errors",
136
- "warnings"
137
- ]
125
+ "required": ["checks", "errors", "warnings"],
126
+ "additionalProperties": false
138
127
  }
139
128
  },
140
129
  "methods": {
@@ -150,4 +139,4 @@
150
139
  }
151
140
  }
152
141
  }
153
- }
142
+ }
@@ -1,14 +0,0 @@
1
- import { IAgentPlugin } from '@veramo/core';
2
- import { IVcApiVerifierClient, IVcApiVerifierArgs } from '../types/IVcApiVerifierClient';
3
- /**
4
- * {@inheritDoc IVcApiVerifier}
5
- */
6
- export declare class VcApiVerifierClient implements IAgentPlugin {
7
- readonly schema: any;
8
- readonly methods: IVcApiVerifierClient;
9
- private readonly verifyUrl;
10
- constructor(options: IVcApiVerifierArgs);
11
- /** {@inheritDoc IVcApiVerifier.vcApiClientVerifyCredential} */
12
- private vcApiClientVerifyCredential;
13
- }
14
- //# sourceMappingURL=VcApiVerifierClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VcApiVerifierClient.d.ts","sourceRoot":"","sources":["../../src/agent/VcApiVerifierClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,MAAM,cAAc,CAAA;AAG3C,OAAO,EAGL,oBAAoB,EACpB,kBAAkB,EAGnB,MAAM,+BAA+B,CAAA;AAItC;;GAEG;AACH,qBAAa,mBAAoB,YAAW,YAAY;IACtD,QAAQ,CAAC,MAAM,MAAwC;IACvD,QAAQ,CAAC,OAAO,EAAE,oBAAoB,CAErC;IACD,OAAO,CAAC,QAAQ,CAAC,SAAS,CAAQ;gBAEtB,OAAO,EAAE,kBAAkB;IAIvC,+DAA+D;YACjD,2BAA2B;CAqB1C"}
@@ -1,54 +0,0 @@
1
- "use strict";
2
- var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
- function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
- return new (P || (P = Promise))(function (resolve, reject) {
5
- function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
6
- function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
7
- function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
8
- step((generator = generator.apply(thisArg, _arguments || [])).next());
9
- });
10
- };
11
- Object.defineProperty(exports, "__esModule", { value: true });
12
- exports.VcApiVerifierClient = void 0;
13
- const index_1 = require("../index");
14
- const IVcApiVerifierClient_1 = require("../types/IVcApiVerifierClient");
15
- const cross_fetch_1 = require("cross-fetch");
16
- /**
17
- * {@inheritDoc IVcApiVerifier}
18
- */
19
- class VcApiVerifierClient {
20
- constructor(options) {
21
- this.schema = index_1.schema.IVcApiVerfierClientAgentPlugin;
22
- this.methods = {
23
- vcApiClientVerifyCredential: this.vcApiClientVerifyCredential.bind(this),
24
- };
25
- this.verifyUrl = options.verifyUrl;
26
- }
27
- /** {@inheritDoc IVcApiVerifier.vcApiClientVerifyCredential} */
28
- vcApiClientVerifyCredential(args, context) {
29
- return __awaiter(this, void 0, void 0, function* () {
30
- return yield (0, cross_fetch_1.fetch)(this.verifyUrl, {
31
- method: 'post',
32
- headers: {
33
- Accept: 'application/json',
34
- 'Content-Type': 'application/json',
35
- },
36
- body: JSON.stringify({ verifiableCredential: args.credential }),
37
- })
38
- .then((response) => __awaiter(this, void 0, void 0, function* () {
39
- if (response.status >= 400) {
40
- throw new Error(yield response.text());
41
- }
42
- else {
43
- return response.json();
44
- }
45
- }))
46
- .then((verificationResult) => __awaiter(this, void 0, void 0, function* () {
47
- yield context.agent.emit(IVcApiVerifierClient_1.events.CREDENTIAL_VERIFIED, verificationResult);
48
- return verificationResult;
49
- }));
50
- });
51
- }
52
- }
53
- exports.VcApiVerifierClient = VcApiVerifierClient;
54
- //# sourceMappingURL=VcApiVerifierClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"VcApiVerifierClient.js","sourceRoot":"","sources":["../../src/agent/VcApiVerifierClient.ts"],"names":[],"mappings":";;;;;;;;;;;;AAEA,oCAAiC;AACjC,wEAOsC;AAEtC,6CAAmC;AAEnC;;GAEG;AACH,MAAa,mBAAmB;IAO9B,YAAY,OAA2B;QAN9B,WAAM,GAAG,cAAM,CAAC,8BAA8B,CAAA;QAC9C,YAAO,GAAyB;YACvC,2BAA2B,EAAE,IAAI,CAAC,2BAA2B,CAAC,IAAI,CAAC,IAAI,CAAC;SACzE,CAAA;QAIC,IAAI,CAAC,SAAS,GAAG,OAAO,CAAC,SAAS,CAAA;IACpC,CAAC;IAED,+DAA+D;IACjD,2BAA2B,CAAC,IAA2B,EAAE,OAAyB;;YAC9F,OAAO,MAAM,IAAA,mBAAK,EAAC,IAAI,CAAC,SAAS,EAAE;gBACjC,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,MAAM,EAAE,kBAAkB;oBAC1B,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC,EAAE,oBAAoB,EAAE,IAAI,CAAC,UAAU,EAAE,CAAC;aAChE,CAAC;iBACC,IAAI,CAAC,CAAO,QAAQ,EAAE,EAAE;gBACvB,IAAI,QAAQ,CAAC,MAAM,IAAI,GAAG,EAAE,CAAC;oBAC3B,MAAM,IAAI,KAAK,CAAC,MAAM,QAAQ,CAAC,IAAI,EAAE,CAAC,CAAA;gBACxC,CAAC;qBAAM,CAAC;oBACN,OAAO,QAAQ,CAAC,IAAI,EAAE,CAAA;gBACxB,CAAC;YACH,CAAC,CAAA,CAAC;iBACD,IAAI,CAAC,CAAO,kBAAkB,EAAE,EAAE;gBACjC,MAAM,OAAO,CAAC,KAAK,CAAC,IAAI,CAAC,6BAAM,CAAC,mBAAmB,EAAE,kBAAkB,CAAC,CAAA;gBACxE,OAAO,kBAAkB,CAAA;YAC3B,CAAC,CAAA,CAAC,CAAA;QACN,CAAC;KAAA;CACF;AAjCD,kDAiCC"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AACH,QAAA,MAAM,MAAM,KAAmC,CAAA;AAC/C,OAAO,EAAE,MAAM,EAAE,CAAA;AACjB,OAAO,EAAE,mBAAmB,EAAE,MAAM,6BAA6B,CAAA;AACjE,cAAc,8BAA8B,CAAA"}
@@ -1,47 +0,0 @@
1
- import { CredentialPayload } from '@veramo/core';
2
- import { IAgentContext } from '@veramo/core';
3
- import { IAgentPlugin } from '@veramo/core';
4
- import { IPluginMethodMap } from '@veramo/core';
5
-
6
- export declare enum events {
7
- CREDENTIAL_VERIFIED = "credentialVerified"
8
- }
9
-
10
- export declare type IRequiredContext = IAgentContext<Record<string, never>>;
11
-
12
- export declare interface IVcApiVerifierArgs {
13
- verifyUrl: string;
14
- }
15
-
16
- export declare interface IVcApiVerifierClient extends IPluginMethodMap {
17
- vcApiClientVerifyCredential(args: IVerifyCredentialArgs, context: IRequiredContext): Promise<IVerifyCredentialResult>;
18
- }
19
-
20
- export declare interface IVerifyCredentialArgs {
21
- credential: CredentialPayload;
22
- }
23
-
24
- export declare interface IVerifyCredentialResult {
25
- checks: string[];
26
- errors: string[];
27
- warnings: string[];
28
- }
29
-
30
- /**
31
- * @public
32
- */
33
- export declare const schema: any;
34
-
35
- /**
36
- * {@inheritDoc IVcApiVerifier}
37
- */
38
- export declare class VcApiVerifierClient implements IAgentPlugin {
39
- readonly schema: any;
40
- readonly methods: IVcApiVerifierClient;
41
- private readonly verifyUrl;
42
- constructor(options: IVcApiVerifierArgs);
43
- /** {@inheritDoc IVcApiVerifier.vcApiClientVerifyCredential} */
44
- private vcApiClientVerifyCredential;
45
- }
46
-
47
- export { }
@@ -1,11 +0,0 @@
1
- // This file is read by tools that parse documentation comments conforming to the TSDoc standard.
2
- // It should be published with your NPM package. It should not be tracked by Git.
3
- {
4
- "tsdocVersion": "0.12",
5
- "toolPackages": [
6
- {
7
- "packageName": "@microsoft/api-extractor",
8
- "packageVersion": "7.52.5"
9
- }
10
- ]
11
- }
@@ -1,20 +0,0 @@
1
- import { CredentialPayload, IAgentContext, IPluginMethodMap } from '@veramo/core';
2
- export interface IVcApiVerifierClient extends IPluginMethodMap {
3
- vcApiClientVerifyCredential(args: IVerifyCredentialArgs, context: IRequiredContext): Promise<IVerifyCredentialResult>;
4
- }
5
- export interface IVcApiVerifierArgs {
6
- verifyUrl: string;
7
- }
8
- export interface IVerifyCredentialArgs {
9
- credential: CredentialPayload;
10
- }
11
- export interface IVerifyCredentialResult {
12
- checks: string[];
13
- errors: string[];
14
- warnings: string[];
15
- }
16
- export declare enum events {
17
- CREDENTIAL_VERIFIED = "credentialVerified"
18
- }
19
- export type IRequiredContext = IAgentContext<Record<string, never>>;
20
- //# sourceMappingURL=IVcApiVerifierClient.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IVcApiVerifierClient.d.ts","sourceRoot":"","sources":["../../src/types/IVcApiVerifierClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,iBAAiB,EAAE,aAAa,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAA;AAEjF,MAAM,WAAW,oBAAqB,SAAQ,gBAAgB;IAC5D,2BAA2B,CAAC,IAAI,EAAE,qBAAqB,EAAE,OAAO,EAAE,gBAAgB,GAAG,OAAO,CAAC,uBAAuB,CAAC,CAAA;CACtH;AAED,MAAM,WAAW,kBAAkB;IACjC,SAAS,EAAE,MAAM,CAAA;CAClB;AAED,MAAM,WAAW,qBAAqB;IACpC,UAAU,EAAE,iBAAiB,CAAA;CAC9B;AAED,MAAM,WAAW,uBAAuB;IACtC,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,MAAM,EAAE,MAAM,EAAE,CAAA;IAChB,QAAQ,EAAE,MAAM,EAAE,CAAA;CACnB;AAED,oBAAY,MAAM;IAChB,mBAAmB,uBAAuB;CAC3C;AAED,MAAM,MAAM,gBAAgB,GAAG,aAAa,CAAC,MAAM,CAAC,MAAM,EAAE,KAAK,CAAC,CAAC,CAAA"}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.events = void 0;
4
- var events;
5
- (function (events) {
6
- events["CREDENTIAL_VERIFIED"] = "credentialVerified";
7
- })(events || (exports.events = events = {}));
8
- //# sourceMappingURL=IVcApiVerifierClient.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"IVcApiVerifierClient.js","sourceRoot":"","sources":["../../src/types/IVcApiVerifierClient.ts"],"names":[],"mappings":";;;AAoBA,IAAY,MAEX;AAFD,WAAY,MAAM;IAChB,oDAA0C,CAAA;AAC5C,CAAC,EAFW,MAAM,sBAAN,MAAM,QAEjB"}