|
@ -74,8 +74,9 @@ |
|
|
import { Options, Vue } from "vue-class-component"; |
|
|
import { Options, Vue } from "vue-class-component"; |
|
|
import { AppString } from "@/constants/app"; |
|
|
import { AppString } from "@/constants/app"; |
|
|
import { db } from "../db"; |
|
|
import { db } from "../db"; |
|
|
import { accessToken, sign } from "@/libs/crypto"; |
|
|
import { accessToken, SimpleSigner } from "@/libs/crypto"; |
|
|
import * as didJwt from "did-jwt"; |
|
|
import * as didJwt from "did-jwt"; |
|
|
|
|
|
import { IIdentifier } from "@veramo/core"; |
|
|
|
|
|
|
|
|
@Options({ |
|
|
@Options({ |
|
|
components: {}, |
|
|
components: {}, |
|
@ -84,14 +85,7 @@ export default class NewEditProjectView extends Vue { |
|
|
projectName = ""; |
|
|
projectName = ""; |
|
|
description = ""; |
|
|
description = ""; |
|
|
|
|
|
|
|
|
public async onSaveProjectClick() { |
|
|
private async SaveProject(identity: IIdentifier) { |
|
|
await db.open(); |
|
|
|
|
|
const num_accounts = await db.accounts.count(); |
|
|
|
|
|
if (num_accounts === 0) { |
|
|
|
|
|
console.log("Problem! Should have a profile!"); |
|
|
|
|
|
} else { |
|
|
|
|
|
const accounts = await db.accounts.toArray(); |
|
|
|
|
|
const identity = JSON.parse(accounts[0].identity); |
|
|
|
|
|
const address = identity.did; |
|
|
const address = identity.did; |
|
|
// Make a claim |
|
|
// Make a claim |
|
|
const vcClaim = { |
|
|
const vcClaim = { |
|
@ -111,13 +105,19 @@ export default class NewEditProjectView extends Vue { |
|
|
}, |
|
|
}, |
|
|
}; |
|
|
}; |
|
|
// create a signature using private key of identity |
|
|
// create a signature using private key of identity |
|
|
const signer = await sign(identity.keys[0].privateKeyHex); |
|
|
if ( |
|
|
|
|
|
identity.keys[0].privateKeyHex !== "undefined" && |
|
|
|
|
|
identity.keys[0].privateKeyHex !== null |
|
|
|
|
|
) { |
|
|
|
|
|
// eslint-disable-next-line |
|
|
|
|
|
const privateKeyHex: string = identity.keys[0].privateKeyHex!; |
|
|
|
|
|
const signer = await SimpleSigner(privateKeyHex); |
|
|
const alg = undefined; |
|
|
const alg = undefined; |
|
|
// create a JWT for the request |
|
|
// create a JWT for the request |
|
|
const vcJwt: string = await didJwt.createJWT(vcPayload, { |
|
|
const vcJwt: string = await didJwt.createJWT(vcPayload, { |
|
|
alg, |
|
|
alg: alg, |
|
|
issuer: identity, |
|
|
issuer: identity.did, |
|
|
signer, |
|
|
signer: signer, |
|
|
}); |
|
|
}); |
|
|
|
|
|
|
|
|
// Make the xhr request payload |
|
|
// Make the xhr request payload |
|
@ -140,6 +140,18 @@ export default class NewEditProjectView extends Vue { |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
public async onSaveProjectClick() { |
|
|
|
|
|
await db.open(); |
|
|
|
|
|
const num_accounts = await db.accounts.count(); |
|
|
|
|
|
if (num_accounts === 0) { |
|
|
|
|
|
console.log("Problem! Should have a profile!"); |
|
|
|
|
|
} else { |
|
|
|
|
|
const accounts = await db.accounts.toArray(); |
|
|
|
|
|
const identity = JSON.parse(accounts[0].identity); |
|
|
|
|
|
this.SaveProject(identity); |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
public onCancelClick() { |
|
|
public onCancelClick() { |
|
|
this.$router.back(); |
|
|
this.$router.back(); |
|
|
} |
|
|
} |
|
|