Closed skradha26 closed 4 years ago
Hello, is there a stack trace that goes along with your error at the very top?
Also, make sure to use the DID context: https://w3id.org/did/v0.11 -- the one you're using is unstable and out-of-date.
The context referenced by @dlongley is available here: https://github.com/digitalbazaar/did-context
Thank you. I think it worked. But, when I try to issue credential, I get the below error,
(node:1984) UnhandledPromiseRejectionWarning: jsonld.InvalidUrl: Dereferencing a URL did not result in a valid JSON-LD object. Possible causes are an inaccessible URL perhaps due to a same-origin policy (ensure the server uses CORS if you are using client-side JavaScript), too many redirects, a non-JSON response, or more than one HTTP Link Header was provided for a remote context.
at ContextResolver._fetchContext (/Users/sradha/PhD_Research_2020/digitalbazaar_experiments/vc-js/node_modules/jsonld/lib/ContextResolver.js:159:13)
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:229:7)
at Function.Module.runMain (module.js:696:11)
at startup (bootstrap_node.js:204:16)
at bootstrap_node.js:625:3
(node:1984) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). (rejection id: 7)
(node:1984) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.
This is my issueCredential code:
async function issueCredential () {
console.log("Credential issuing service...\n");
const credentialString = fs.readFileSync("./credential.json").toString();
console.log(credentialString);
const credential = JSON.parse(credentialString);
credential.issuer.id = issuerKeyDid.id;
credential.credentialSubject.id = subjectKeyDid.id
credential.issuanceDate = (new Date()).toISOString()
const signingSuite = new Ed25519Signature2018({
purpose: new AssertionProofPurpose(),
key: issuerKeyPair
});
let issuedCred = await vc.issue({credential, suite: signingSuite, documentLoader: documentLoader, });
console.log("Issued Credential:\n", JSON.stringify(issuedCred), "\n")
fs.writeFile("./issuedCredential.json", JSON.stringify(issuedCred, null, 4), (err) => {
if (err) {
console.error(err);
return;
}});
};
And below is credential.json
{
"@context": [
"https://www.w3.org/2018/credentials/v1",
"www.craftofscience.xyz/custContext.jsonld"
],
"id": "www.craftofscience.xyz/custContext.jsonld",
"type": [
"VerifiableCredential",
"TaleData"
],
"issuer": {
"id": "did:web:craftofscience.xyz"
},
"issuanceDate": "2020-03-06T16:24:58.160Z",
"credentialSubject": {
"id": "did:web:craftofscience.xyz",
"type": "TaleData",
"version": "1"
}
}
Hello, the error you're getting now is because you'll need a document loader. Please see:
https://github.com/digitalbazaar/vc-js#custom-documentLoader
Thank you. That helped. Apologies for posting multiple questions in the same issue. When I try to issue the credential, I get this error: (node:2223) UnhandledPromiseRejectionWarning: TypeError: "suite.verificationMethod" property is required.
But I do see the verification method in the signing suite:
signing suite Ed25519Signature2018 {
type: 'Ed25519Signature2018',
creator: undefined,
verificationMethod: 'did:web:craftofscience.xyz#z6MkpTSqkUdN66k37jCVDKqKKmZJ5Dq7aZGZCsFUCGbrpNr6',
proof: undefined,
useNativeCanonize: undefined,
alg: 'EdDSA',
LDKeyClass: [Function: Ed25519KeyPair],
signer: { sign: [AsyncFunction: sign] },
key:
Ed25519KeyPair {
passphrase: null,
id: 'did:web:craftofscience.xyz#z6MkpTSqkUdN66k37jCVDKqKKmZJ5Dq7aZGZCsFUCGbrpNr6',
controller: undefined,
owner: undefined,
type: 'Ed25519VerificationKey2018',
privateKeyBase58: '',
publicKeyBase58: 'B1BoAENvkZFa1EMnXksUUg1JFeZGAg2CWrLYMzdquA4i' },
verifier: { verify: [AsyncFunction: verify] },
requiredKeyType: 'Ed25519VerificationKey2018' }
(node:22207) UnhandledPromiseRejectionWarning: TypeError: Cannot read property '0' of undefined.
I suspect some issue with the did.json file I published in the URL given in the code. Can someone help me here?