-
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 #68 from hypersign-protocol/develop
Develop
- Loading branch information
Showing
79 changed files
with
17,987 additions
and
2,082 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 |
---|---|---|
@@ -0,0 +1,2 @@ | ||
node_modules | ||
dist |
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,21 @@ | ||
{ | ||
"env": { | ||
"browser": true, | ||
"es2021": true | ||
}, | ||
"extends": [ | ||
"eslint:recommended", | ||
"plugin:@typescript-eslint/recommended" | ||
], | ||
"parser": "@typescript-eslint/parser", | ||
"parserOptions": { | ||
"ecmaVersion": 12, | ||
"sourceType": "module" | ||
}, | ||
"plugins": [ | ||
"@typescript-eslint" | ||
], | ||
"rules": { | ||
"@typescript-eslint/no-var-requires": 0 | ||
} | ||
} |
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,3 +1,5 @@ | ||
node_modules | ||
libs | ||
dist | ||
libs | ||
|
||
|
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 @@ | ||
_ |
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,4 @@ | ||
#!/bin/sh | ||
. "$(dirname "$0")/_/husky.sh" | ||
|
||
npm run build |
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,3 @@ | ||
node_modules | ||
dist | ||
hypersign.json |
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,5 @@ | ||
{ | ||
"singleQuote": true, | ||
"arrowParens": "always", | ||
"printWidth": 120 | ||
} |
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,81 +1,129 @@ | ||
|
||
# Hypersign Self Soverign Identity (SSI) Js SDK | ||
|
||
This sdk is an implementation of proposed [DID](https://www.w3.org/TR/did-core/) framework by the [W3C Credential Community Group](https://w3c-ccg.github.io/) | ||
|
||
## Building | ||
|
||
```sh | ||
git submodule update --init --recursive | ||
cd libs/vc-js && npm i && cd - | ||
npm i | ||
npm i | ||
npm run build | ||
npm run test | ||
``` | ||
## Usage | ||
|
||
Install | ||
|
||
## Install | ||
|
||
```js | ||
npm i hs-ssi-sdk --save | ||
``` | ||
|
||
|
||
Use | ||
## Usage | ||
|
||
```js | ||
// import | ||
import HypersignSsiSDK from 'hs-ssi-sdk'; | ||
|
||
// initialise | ||
import HypersignSsiSDK from "hs-ssi-sdk"; | ||
const hsSdk = new HypersignSsiSDK( | ||
{ nodeUrl: "http://localhost:5000" } // Hypersign node url | ||
); | ||
|
||
const { did, schema, credential } = hsSdk; | ||
offlineSigner, | ||
"http://localhost:26657", // RPC | ||
"http://localhost:1317" // REST Endpoint | ||
); | ||
await hsSdk.init(); | ||
const { did, schema, vc, vp } = hsSdk; | ||
``` | ||
|
||
|
||
## APIs | ||
|
||
### hsSdk.did | ||
|
||
```js | ||
didUrl: string; | ||
generateKeys(): object; | ||
getDidDocAndKeys(user: object): Promise<any>; | ||
getDid(options: IDIDOptions): Promise<any>; | ||
register(didDoc: object): Promise<any>; | ||
resolve(did: string): Promise<any>; | ||
verify(params: IParams): Promise<any>; | ||
sign(params: IParams): Promise<any>; | ||
generateKeys(params: { seed:string }): Promise<{ privateKeyMultibase: string, publicKeyMultibase: string }>; | ||
generate(params: { publicKeyMultibase: string }): string; | ||
register(params: { | ||
didDocString: string , | ||
privateKeyMultibase: string, | ||
verificationMethodId: string | ||
}): Promise<any>; | ||
resolve(params: { did: string }): Promise<any>; | ||
update(params: { | ||
didDocString: string | ||
privateKeyMultibase: string | ||
verificationMethodId: string | ||
versionId: string | ||
}): Promise<any>; | ||
deactivate(params: { | ||
didDocString: string | ||
privateKeyMultibase: string | ||
verificationMethodId: string | ||
versionId: string | ||
}): Promise<any>; | ||
``` | ||
|
||
### hsSdk.schema | ||
|
||
```js | ||
schemaUrl: string; | ||
generateSchema({ name, author, description, properties }: ISchema): Promise<ISchemaTemplate>; | ||
registerSchema(schema: ISchemaTemplate): Promise<any>; | ||
getSchema(options: {schemaId?: string, author?: string}): Promise<any>; | ||
getSchema(params: { | ||
name: string; | ||
description?: string; | ||
author: string; | ||
fields?: Array<ISchemaFields>; | ||
additionalProperties: boolean; | ||
}): Schema; | ||
|
||
signSchema(params: { | ||
privateKey: string; | ||
schema: ISchemaProto; | ||
}): Promise<any>; | ||
|
||
registerSchema(params: { | ||
schema: Schema; | ||
signature: string; | ||
verificationMethodId: string; | ||
}): Promise<any>; | ||
|
||
``` | ||
|
||
### hsSdk.credential | ||
### hsSdk.vc | ||
|
||
```js | ||
generateCredential(schemaUrl, params: { subjectDid, issuerDid, expirationDate, attributesMap: Object }): Promise<any>; | ||
signCredential(credential, issuerDid, privateKey): Promise<any>; | ||
verifyCredential(credential: object, issuerDid: string): Promise<any>; | ||
generatePresentation(verifiableCredential, holderDid): Promise<any> ; | ||
signPresentation(presentation, holderDid, privateKey, challenge): Promise<any> | ||
verifyPresentation({ presentation, challenge, domain, issuerDid, holderDid }) : Promise<any> | ||
getCredential(params: { | ||
schemaId: string; | ||
subjectDid: string; | ||
issuerDid: string; | ||
expirationDate: string; | ||
fields: Object; | ||
}): Promise<IVerifiableCredential>; | ||
signCredential(params: { | ||
credential: IVerifiableCredential; | ||
issuerDid: string; | ||
privateKey: string; | ||
}): Promise<any>; | ||
verifyCredential(params: { | ||
credential: IVerifiableCredential, | ||
issuerDid: string | ||
}): Promise<any>; | ||
``` | ||
|
||
## Issue | ||
### hsSdk.vp | ||
|
||
This sdk is in highly under development. In case you find any bug, kindly report it ASAP. Thank You! | ||
```js | ||
getPresentation(params: { | ||
verifiableCredential: IVerifiableCredential; | ||
holderDid: string; | ||
}): Promise<any>; | ||
signPresentation(params: { | ||
presentation: IVerifiablePresentation; | ||
holderDid: string; | ||
privateKey: string; | ||
challenge: string; | ||
}): Promise<any>; | ||
verifyPresentation(params: { | ||
signedPresentation: IVerifiablePresentation , | ||
challenge: string, | ||
domain?: string, | ||
issuerDid: string, | ||
holderDid: string, | ||
}): Promise<any>; | ||
|
||
``` | ||
|
||
## Issue | ||
|
||
This sdk is in highly under development. In case you find any bug, kindly report it ASAP. Thank You! |
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,75 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); | ||
exports.HID_MIN_FEE = exports.HID_MIN_GAS = exports.HID_DNOMINATION = exports.HID_DECIMAL = exports.GAS_PRICE = exports.KEY_HEADERS = exports.SCHEMA = exports.VP = exports.VC = exports.DID = exports.CredentialStatusEnums = exports.HIDRpcEnums = exports.HYPERSIGN_NETWORK_BANK_BALANCE_PATH = exports.HYPERSIGN_NETWORK_CREDENTIALSTATUS_PATH = exports.HYPERSIGN_NETWORK_SCHEMA_PATH = exports.HYPERSIGN_NETWORK_DID_PATH = exports.HID_COSMOS_MODULE = exports.HYPERSIGN_MAINNET_REST = exports.HYPERSIGN_MAINNET_RPC = exports.HYPERSIGN_TESTNET_REST = exports.HYPERSIGN_TESTNET_RPC = exports.compactProof = void 0; | ||
exports.compactProof = false; | ||
exports.HYPERSIGN_TESTNET_RPC = "http://localhost:26657"; | ||
exports.HYPERSIGN_TESTNET_REST = "http://localhost:1317"; | ||
exports.HYPERSIGN_MAINNET_RPC = "http://localhost:26657"; | ||
exports.HYPERSIGN_MAINNET_REST = "http://localhost:1317"; | ||
exports.HID_COSMOS_MODULE = '/hypersignprotocol.hidnode.ssi'; | ||
exports.HYPERSIGN_NETWORK_DID_PATH = "hypersign-protocol/hidnode/ssi/did"; | ||
exports.HYPERSIGN_NETWORK_SCHEMA_PATH = "hypersign-protocol/hidnode/ssi/schema"; | ||
exports.HYPERSIGN_NETWORK_CREDENTIALSTATUS_PATH = "hypersign-protocol/hidnode/ssi/credential"; | ||
exports.HYPERSIGN_NETWORK_BANK_BALANCE_PATH = "/bank/balances/"; | ||
var HIDRpcEnums; | ||
(function (HIDRpcEnums) { | ||
HIDRpcEnums["MsgCreateDID"] = "MsgCreateDID"; | ||
HIDRpcEnums["MsgUpdateDID"] = "MsgUpdateDID"; | ||
HIDRpcEnums["MsgDeactivateDID"] = "MsgDeactivateDID"; | ||
HIDRpcEnums["MsgCreateSchema"] = "MsgCreateSchema"; | ||
HIDRpcEnums["MsgRegisterCredentialStatus"] = "MsgRegisterCredentialStatus"; | ||
})(HIDRpcEnums = exports.HIDRpcEnums || (exports.HIDRpcEnums = {})); | ||
Object.freeze(HIDRpcEnums); | ||
var CredentialStatusEnums; | ||
(function (CredentialStatusEnums) { | ||
CredentialStatusEnums["LIVE"] = "Live"; | ||
})(CredentialStatusEnums = exports.CredentialStatusEnums || (exports.CredentialStatusEnums = {})); | ||
exports.DID = { | ||
CONTROLLER_CONTEXT: "https://w3id.org/security/v2", | ||
SCHEME: "did", | ||
METHOD: "hid", | ||
NAMESPACE: "devnet", | ||
DID_BASE_CONTEXT: "https://www.w3.org/ns/did/v1", | ||
VERIFICATION_METHOD_TYPE: "Ed25519VerificationKey2020" | ||
}; | ||
Object.freeze(exports.DID); | ||
exports.VC = { | ||
SCHEME: "vc", | ||
METHOD: "hid", | ||
NAMESPACE: "devnet", | ||
PREFIX: "vc:" + exports.DID.METHOD + ":" + exports.DID.NAMESPACE + ":", | ||
CREDENTAIL_SCHEMA_VALIDATOR_TYPE: "JsonSchemaValidator2018", | ||
CREDENTAIL_STATUS_TYPE: "CredentialStatusList2017", | ||
CREDENTAIL_BASE_CONTEXT: "https://www.w3.org/2018/credentials/v1", | ||
CREDENTAIL_SECURITY_CONTEXT_V2: "https://w3id.org/security/v2", | ||
CREDENTAIL_SECURITY_SUITE: "https://w3id.org/security/suites/ed25519-2020/v1", | ||
PROOF_PURPOSE: "assertion", | ||
VERIFICATION_METHOD_TYPE: "Ed25519VerificationKey2020", | ||
CRED_STATUS_TYPES: CredentialStatusEnums | ||
}; | ||
Object.freeze(exports.VC); | ||
exports.VP = { | ||
PREFIX: "vp:", | ||
SCHEME: "vp", | ||
METHOD: "hid", | ||
NAMESPACE: "devnet", | ||
}; | ||
Object.freeze(exports.VP); | ||
exports.SCHEMA = { | ||
SCHEME: "sch", | ||
METHOD: "hid", | ||
NAMESPACE: "devnet", | ||
SCHEMA_JSON: 'http://json-schema.org/draft-07/schema', | ||
SCHEMA_TYPE: 'https://w3c-ccg.github.io/vc-json-schemas/v1/schema/1.0/schema.json' | ||
}; | ||
Object.freeze(exports.SCHEMA); | ||
exports.KEY_HEADERS = { | ||
MULTICODEC_ED25519_PUB_HEADER: new Uint8Array([0xed, 0x01]), | ||
MULTICODEC_ED25519_PRIV_HEADER: new Uint8Array([0x80, 0x26]) | ||
}; | ||
Object.freeze(exports.KEY_HEADERS); | ||
exports.GAS_PRICE = '0.1'; | ||
exports.HID_DECIMAL = 6; | ||
exports.HID_DNOMINATION = 'uhid'; | ||
exports.HID_MIN_GAS = '200000'; | ||
exports.HID_MIN_FEE = '5000'; |
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,2 @@ | ||
"use strict"; | ||
Object.defineProperty(exports, "__esModule", { value: true }); |
Oops, something went wrong.