Browse Source

A touch of documenting process

pull/4/head
Matthew Aaron Raymer 2 years ago
parent
commit
39c931cde9
  1. 6
      src/views/NewEditProjectView.vue

6
src/views/NewEditProjectView.vue

@ -93,6 +93,7 @@ export default class NewEditProjectView extends Vue {
const accounts = await db.accounts.toArray(); const accounts = await db.accounts.toArray();
const identity = JSON.parse(accounts[0].identity); const identity = JSON.parse(accounts[0].identity);
const address = identity.did; const address = identity.did;
// Make a claim
const vcClaim = { const vcClaim = {
"@context": "https://schema.org", "@context": "https://schema.org",
"@type": "PlanAction", "@type": "PlanAction",
@ -100,6 +101,7 @@ export default class NewEditProjectView extends Vue {
name: this.projectName, name: this.projectName,
description: this.description, description: this.description,
}; };
// Make a payload for the claim
const vcPayload = { const vcPayload = {
sub: "PlanAction", sub: "PlanAction",
vc: { vc: {
@ -108,14 +110,18 @@ export default class NewEditProjectView extends Vue {
credentialSubject: vcClaim, credentialSubject: vcClaim,
}, },
}; };
// create a signature using private key of identity
const signer = await sign(identity.keys[0].privateKeyHex); const signer = await sign(identity.keys[0].privateKeyHex);
const alg = undefined; const alg = undefined;
// create a JWT for the request
const vcJwt: string = await didJwt.createJWT(vcPayload, { const vcJwt: string = await didJwt.createJWT(vcPayload, {
alg, alg,
issuer: identity, issuer: identity,
signer, signer,
}); });
// Make the xhr request payload
const payload = JSON.stringify({ jwtEncoded: vcJwt }); const payload = JSON.stringify({ jwtEncoded: vcJwt });
const endorserApiServer = AppString.DEFAULT_ENDORSER_API_SERVER; const endorserApiServer = AppString.DEFAULT_ENDORSER_API_SERVER;
const url = endorserApiServer + "/api/claim"; const url = endorserApiServer + "/api/claim";

Loading…
Cancel
Save