Skip to content

Commit

Permalink
update
Browse files Browse the repository at this point in the history
  • Loading branch information
Pratap2018 committed Jan 8, 2024
1 parent d71ba40 commit 8c87e2b
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 26 deletions.
28 changes: 14 additions & 14 deletions src/popup/router/pages/SignDid.vue
Original file line number Diff line number Diff line change
Expand Up @@ -91,12 +91,13 @@ export default {
this.didRaw = this.hypersign.requestingAppInfo.data;
await hidWalletInstance.generateWallet(this.mnemonic);
this.hsSDK = new HypersignSSISdk(
hidWalletInstance.offlineSigner,
HIDNODE_RPC,
HIDNODE_REST,
HIDNODE_NAMESPACE,
);
this.hsSDK = new HypersignSSISdk({
offlineSigner: hidWalletInstance.offlineSigner,
nodeRpcEndpoint: HIDNODE_RPC,
nodeRestEndpoint: HIDNODE_REST,
namespace: HIDNODE_NAMESPACE,
});
await this.hsSDK.init();
// await this.signAndSendToBlockchain();
},
Expand All @@ -115,6 +116,7 @@ export default {
const didDoc = await this.hsSDK.did.generate({ publicKeyMultibase: kp.publicKeyMultibase });
didDoc.keyAgreement = [];
// let didDoc = JSON.parse(didDocString);
console.log(this.didRaw);
const { controllers, alsoKnownAs, serviceEndpoint } = this.didRaw;
if (!Array.isArray(controllers)) {
Expand Down Expand Up @@ -154,8 +156,6 @@ export default {
didDoc.verificationMethod.push(didDocument.verificationMethod[0]);
didDoc.authentication.push(didDocument.authentication[0]);
didDoc.assertionMethod.push(didDocument.assertionMethod[0]);
didDoc.capabilityInvocation.push(didDocument.capabilityInvocation[0]);
didDoc.capabilityDelegation.push(didDocument.capabilityDelegation[0]);
}
}
Expand All @@ -165,20 +165,20 @@ export default {
}
if (serviceEndpoint) {
didDoc.service.push({
id: `${didDoc.id}#linked-domain`,
type: 'LinkedDomains',
serviceEndpoint: serviceEndpoint + didDoc.id,
});
// didDoc.service.push({
// id: `${didDoc.id}#ld-1`,
// type: 'LinkedDomains',
// serviceEndpoint: serviceEndpoint +'/'+ didDoc.id,
// });
}
const verificationMethodId = this.hypersign.didDoc.verificationMethod[0].id;
console.log(this.hypersign.keys);
const result = await this.hsSDK.did.register({
didDocument: didDoc,
privateKeyMultibase: this.hypersign.keys.privateKeyMultibase,
verificationMethodId,
});
if (!result) {
throw new Error('Could not register the did');
}
Expand Down
22 changes: 12 additions & 10 deletions src/popup/router/pages/SignSchema.vue
Original file line number Diff line number Diff line change
Expand Up @@ -74,12 +74,12 @@ export default {
this.schemaRaw = this.hypersign.requestingAppInfo.data;
// console.log(JSON.stringify(this.schemaRaw))
await hidWalletInstance.generateWallet(this.mnemonic);
this.hsSDK = new HypersignSSISdk(
hidWalletInstance.offlineSigner,
HIDNODE_RPC,
HIDNODE_REST,
HIDNODE_NAMESPACE,
);
this.hsSDK = new HypersignSSISdk({
offlineSigner: hidWalletInstance.offlineSigner,
nodeRpcEndpoint: HIDNODE_RPC,
nodeRestEndpoint: HIDNODE_REST,
namespace: HIDNODE_NAMESPACE,
});
await this.hsSDK.init();
// await this.signAndSendToBlockchain();
},
Expand All @@ -91,7 +91,7 @@ export default {
async prepareSchema() {
// using hs-ssi-sdk to g
const schemaOptions = this.schemaRaw; // JSON.parse(this.schemaRaw)
return await this.hsSDK.schema.getSchema({
return await this.hsSDK.schema.generate({
name: schemaOptions.name,
description: schemaOptions.description,
author: schemaOptions.author, //orgDid
Expand All @@ -104,12 +104,14 @@ export default {
this.loading = true;
const schemaToSign = await this.prepareSchema();
// console.log(schemaToSign);
const signature = await this.hsSDK.schema.signSchema({
privateKey: this.hypersign.keys.privateKeyMultibase,
const signature = await this.hsSDK.schema.sign({
privateKeyMultibase: this.hypersign.keys.privateKeyMultibase,
schema: schemaToSign,
verificationMethodId:this.hypersign.didDoc.verificationMethod[0].id
});
const { assertionMethod } = this.hypersign.didDoc;
// TODO: This should go into hs-ssi-sdk
console.log(signature, assertionMethod);
let proof = {
type: 'Ed25519Signature2020',
created: schemaToSign.authored,
Expand All @@ -118,7 +120,7 @@ export default {
proofPurpose: 'assertion',
};
const result = await this.hsSDK.schema.registerSchema({ schema: schemaToSign, proof });
const result = await this.hsSDK.schema.register({ schema: signature });
if (result) {
this.$store.dispatch('modals/open', { name: 'default', msg: result.transactionHash });
/// call the sutatus API of the studio/dappp server to for updating the status in db.
Expand Down
4 changes: 2 additions & 2 deletions src/popup/utils/hsConstants.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,8 +21,8 @@ export const HYPERSIGN_AUTH_PROVIDER = {
TWITTER: 'twitter',
FACEBOOK: 'facebook',
};
export const HIDNODE_RPC = 'https://rpc.prajna.hypersign.id';
export const HIDNODE_REST = 'https://api.prajna.hypersign.id';
export const HIDNODE_RPC = 'https://rpc.prajna.hypersign.id/';
export const HIDNODE_REST = 'https://api.prajna.hypersign.id/';

// export const HIDNODE_RPC = 'http://127.0.0.1:26657/'
// export const HIDNODE_REST = "http://127.0.0.1:1317/"
Expand Down

0 comments on commit 8c87e2b

Please sign in to comment.