-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from hypersign-protocol/issues#74
test case using chai and mocha
- Loading branch information
Showing
9 changed files
with
1,862 additions
and
96 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,47 +1,51 @@ | ||
{ | ||
"name": "hs-ssi-sdk", | ||
"version": "6.2.0", | ||
"description": "sdk is an implementation of proposed DID by W3C", | ||
"main": "build/src/index.js", | ||
"scripts": { | ||
"test": "cd test/ssi && node did.js && node private-did.js && node schema.js && cd credentials && node test1.js && node test2.js && node updateCredStatus.js", | ||
"start": "node build/index.js", | ||
"build": "npm run lint:fix && npm run prettier && rimraf build && tsc -p .", | ||
"prettier": "prettier --config .prettierrc.json --write src/**/*.ts", | ||
"prepublish": "npm run build", | ||
"lint": "eslint . --ext .ts", | ||
"lint:fix": "npm run lint -- --fix", | ||
"prepare": "husky install" | ||
}, | ||
"author": "Hypersign Team", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@cosmjs/proto-signing": "^0.27.0", | ||
"@cosmjs/stargate": "^0.27.0", | ||
"@digitalbazaar/ed25519-signature-2020": "^3.0.0", | ||
"@digitalbazaar/ed25519-verification-key-2018": "^3.1.2", | ||
"@digitalbazaar/ed25519-verification-key-2020": "^3.3.0", | ||
"@stablelib/ed25519": "^1.0.2", | ||
"axios": "^0.19.0", | ||
"crypto-ld": "^6.0.0", | ||
"jsonld": "^3.1.1", | ||
"jsonld-signatures": "^9.0.0", | ||
"node-fetch": "^2.6.1", | ||
"protobufjs": "^6.11.2", | ||
"uuid": "^8.3.0", | ||
"vc-js": "https://github.com/hypersign-protocol/vc-js" | ||
}, | ||
"devDependencies": { | ||
"@types/jest": "^27.5.1", | ||
"@types/node": "^14.11.2", | ||
"@typescript-eslint/eslint-plugin": "^5.4.0", | ||
"@typescript-eslint/parser": "^5.4.0", | ||
"eslint": "^7.32.0", | ||
"husky": "^7.0.4", | ||
"jest": "^28.1.0", | ||
"prettier": "^2.4.1", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^28.0.3", | ||
"typescript": "^4.5.5" | ||
} | ||
} | ||
"name": "hs-ssi-sdk", | ||
"version": "6.2.0", | ||
"description": "sdk is an implementation of proposed DID by W3C", | ||
"main": "build/src/index.js", | ||
"scripts": { | ||
"test": "cd test/ssi && node did.js && node private-did.js && node schema.js && cd credentials && node test1.js && node test2.js", | ||
"test_chai": "env TS_NODE_COMPILER_OPTIONS='{\"module\": \"commonjs\" }' mocha -r ts-node/register 'src/tests/*.ts' --exit --timeout 40000", | ||
"start": "node build/index.js", | ||
"build": "npm run lint:fix && npm run prettier && rimraf build && tsc -p .", | ||
"prettier": "prettier --config .prettierrc.json --write src/**/*.ts", | ||
"prepublish": "npm run build", | ||
"lint": "eslint . --ext .ts", | ||
"lint:fix": "npm run lint -- --fix", | ||
"prepare": "husky install" | ||
}, | ||
"author": "Hypersign Team", | ||
"license": "ISC", | ||
"dependencies": { | ||
"@cosmjs/proto-signing": "^0.27.0", | ||
"@cosmjs/stargate": "^0.27.0", | ||
"@digitalbazaar/ed25519-signature-2020": "^3.0.0", | ||
"@digitalbazaar/ed25519-verification-key-2018": "^3.1.2", | ||
"@digitalbazaar/ed25519-verification-key-2020": "^3.3.0", | ||
"@stablelib/ed25519": "^1.0.2", | ||
"axios": "^0.19.0", | ||
"crypto-ld": "^6.0.0", | ||
"jsonld": "^3.1.1", | ||
"jsonld-signatures": "^9.0.0", | ||
"node-fetch": "^2.6.1", | ||
"protobufjs": "^6.11.2", | ||
"uuid": "^8.3.0", | ||
"vc-js": "https://github.com/hypersign-protocol/vc-js" | ||
}, | ||
"devDependencies": { | ||
"@types/chai": "^4.3.4", | ||
"@types/mocha": "^10.0.1", | ||
"@types/node": "^14.11.2", | ||
"@typescript-eslint/eslint-plugin": "^5.4.0", | ||
"@typescript-eslint/parser": "^5.4.0", | ||
"chai": "^4.3.7", | ||
"eslint": "^7.32.0", | ||
"husky": "^7.0.4", | ||
"jest": "^28.1.0", | ||
"mocha": "^10.2.0", | ||
"prettier": "^2.4.1", | ||
"rimraf": "^3.0.2", | ||
"ts-jest": "^28.0.3", | ||
"ts-node": "^10.9.1", | ||
"typescript": "^4.5.5" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
const { DirectSecp256k1HdWallet } = require('@cosmjs/proto-signing'); | ||
const { HdPath, Slip10RawIndex } = require('@cosmjs/crypto'); | ||
|
||
export const mnemonic = | ||
'zero require alcohol swamp hover punch celery common merge embrace flock dumb unit capital problem future canal improve auto home apple avoid tragic mechanic'; | ||
|
||
export const hidNodeEp = { | ||
rpc: 'https://jagrat.hypersign.id/rpc', | ||
rest: 'https://jagrat.hypersign.id/rest', | ||
namespace: 'testnet', | ||
}; | ||
export function makeCosmoshubPath(a) { | ||
return [ | ||
Slip10RawIndex.hardened(44), | ||
Slip10RawIndex.hardened(118), | ||
Slip10RawIndex.hardened(0), | ||
Slip10RawIndex.normal(0), | ||
Slip10RawIndex.normal(a), | ||
]; | ||
} | ||
|
||
export const createWallet = async (mnemonic) => { | ||
let options; | ||
if (!mnemonic) { | ||
return await DirectSecp256k1HdWallet.generate( | ||
24, | ||
(options = { | ||
prefix: 'hid', | ||
hdPaths: [makeCosmoshubPath(0)], | ||
}) | ||
); | ||
} else { | ||
return await DirectSecp256k1HdWallet.fromMnemonic( | ||
mnemonic, | ||
(options = { | ||
prefix: 'hid', | ||
hdPaths: [makeCosmoshubPath(0)], | ||
}) | ||
); | ||
} | ||
}; |
Oops, something went wrong.