{"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;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,gBACV;AAAA,cACF;AAAA,cACA,UAAY;AAAA,gBACV;AAAA,cACF;AAAA,cACA,aAAe;AAAA,YACjB;AAAA,YACA,YAAc;AAAA,cACZ,OAAS;AAAA,gBACP;AAAA,kBACE,MAAQ;AAAA,kBACR,YAAc;AAAA,oBACZ,IAAM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AA,UACA,SAAW;AAAA,YACT,6BAA+B;AAAA,cAC7B,aAAe;AAAA,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;;;AC1JA;;;;;;;;;ACoBO,IAAKC,SAAAA,0BAAAA,SAAAA;;SAAAA;;;;ACRZ,yBAAkB;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,UAAMC,mBAAAA,SAAM,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"]}