Skip to content

Commit 731c11b

Browse files
authored
Merge pull request #68 from hypersign-protocol/develop
Develop
2 parents fa6818a + fc7f656 commit 731c11b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

79 files changed

+17987
-2082
lines changed

.eslintignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
node_modules
2+
dist

.eslintrc.json

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,21 @@
1+
{
2+
"env": {
3+
"browser": true,
4+
"es2021": true
5+
},
6+
"extends": [
7+
"eslint:recommended",
8+
"plugin:@typescript-eslint/recommended"
9+
],
10+
"parser": "@typescript-eslint/parser",
11+
"parserOptions": {
12+
"ecmaVersion": 12,
13+
"sourceType": "module"
14+
},
15+
"plugins": [
16+
"@typescript-eslint"
17+
],
18+
"rules": {
19+
"@typescript-eslint/no-var-requires": 0
20+
}
21+
}

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
11
node_modules
2+
libs
23
dist
3-
libs
4+
5+

.husky/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
_

.husky/pre-commit

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
#!/bin/sh
2+
. "$(dirname "$0")/_/husky.sh"
3+
4+
npm run build

.prettierignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
node_modules
2+
dist
3+
hypersign.json

.prettierrc.json

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
{
2+
"singleQuote": true,
3+
"arrowParens": "always",
4+
"printWidth": 120
5+
}

README.md

Lines changed: 87 additions & 39 deletions
Original file line numberDiff line numberDiff line change
@@ -1,81 +1,129 @@
1-
21
# Hypersign Self Soverign Identity (SSI) Js SDK
32

43
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/)
54

65
## Building
76

87
```sh
9-
git submodule update --init --recursive
10-
cd libs/vc-js && npm i && cd -
11-
npm i
8+
npm i
129
npm run build
1310
npm run test
1411
```
15-
## Usage
16-
17-
Install
1812

13+
## Install
1914

2015
```js
2116
npm i hs-ssi-sdk --save
2217
```
2318

24-
25-
Use
19+
## Usage
2620

2721
```js
28-
// import
29-
import HypersignSsiSDK from 'hs-ssi-sdk';
30-
31-
// initialise
22+
import HypersignSsiSDK from "hs-ssi-sdk";
3223
const hsSdk = new HypersignSsiSDK(
33-
{ nodeUrl: "http://localhost:5000" } // Hypersign node url
34-
);
35-
36-
const { did, schema, credential } = hsSdk;
24+
offlineSigner,
25+
"http://localhost:26657", // RPC
26+
"http://localhost:1317" // REST Endpoint
27+
);
28+
await hsSdk.init();
29+
const { did, schema, vc, vp } = hsSdk;
3730
```
3831

39-
4032
## APIs
4133

4234
### hsSdk.did
4335

4436
```js
45-
didUrl: string;
46-
generateKeys(): object;
47-
getDidDocAndKeys(user: object): Promise<any>;
48-
getDid(options: IDIDOptions): Promise<any>;
49-
register(didDoc: object): Promise<any>;
50-
resolve(did: string): Promise<any>;
51-
verify(params: IParams): Promise<any>;
52-
sign(params: IParams): Promise<any>;
37+
generateKeys(params: { seed:string }): Promise<{ privateKeyMultibase: string, publicKeyMultibase: string }>;
38+
generate(params: { publicKeyMultibase: string }): string;
39+
register(params: {
40+
didDocString: string ,
41+
privateKeyMultibase: string,
42+
verificationMethodId: string
43+
}): Promise<any>;
44+
resolve(params: { did: string }): Promise<any>;
45+
update(params: {
46+
didDocString: string
47+
privateKeyMultibase: string
48+
verificationMethodId: string
49+
versionId: string
50+
}): Promise<any>;
51+
deactivate(params: {
52+
didDocString: string
53+
privateKeyMultibase: string
54+
verificationMethodId: string
55+
versionId: string
56+
}): Promise<any>;
5357
```
5458

5559
### hsSdk.schema
5660

5761
```js
58-
schemaUrl: string;
59-
generateSchema({ name, author, description, properties }: ISchema): Promise<ISchemaTemplate>;
60-
registerSchema(schema: ISchemaTemplate): Promise<any>;
61-
getSchema(options: {schemaId?: string, author?: string}): Promise<any>;
62+
getSchema(params: {
63+
name: string;
64+
description?: string;
65+
author: string;
66+
fields?: Array<ISchemaFields>;
67+
additionalProperties: boolean;
68+
}): Schema;
69+
70+
signSchema(params: {
71+
privateKey: string;
72+
schema: ISchemaProto;
73+
}): Promise<any>;
74+
75+
registerSchema(params: {
76+
schema: Schema;
77+
signature: string;
78+
verificationMethodId: string;
79+
}): Promise<any>;
6280

6381
```
6482

65-
### hsSdk.credential
83+
### hsSdk.vc
6684

6785
```js
68-
generateCredential(schemaUrl, params: { subjectDid, issuerDid, expirationDate, attributesMap: Object }): Promise<any>;
69-
signCredential(credential, issuerDid, privateKey): Promise<any>;
70-
verifyCredential(credential: object, issuerDid: string): Promise<any>;
71-
generatePresentation(verifiableCredential, holderDid): Promise<any> ;
72-
signPresentation(presentation, holderDid, privateKey, challenge): Promise<any>
73-
verifyPresentation({ presentation, challenge, domain, issuerDid, holderDid }) : Promise<any>
86+
getCredential(params: {
87+
schemaId: string;
88+
subjectDid: string;
89+
issuerDid: string;
90+
expirationDate: string;
91+
fields: Object;
92+
}): Promise<IVerifiableCredential>;
93+
signCredential(params: {
94+
credential: IVerifiableCredential;
95+
issuerDid: string;
96+
privateKey: string;
97+
}): Promise<any>;
98+
verifyCredential(params: {
99+
credential: IVerifiableCredential,
100+
issuerDid: string
101+
}): Promise<any>;
74102
```
75103

76-
## Issue
104+
### hsSdk.vp
77105

78-
This sdk is in highly under development. In case you find any bug, kindly report it ASAP. Thank You!
106+
```js
107+
getPresentation(params: {
108+
verifiableCredential: IVerifiableCredential;
109+
holderDid: string;
110+
}): Promise<any>;
111+
signPresentation(params: {
112+
presentation: IVerifiablePresentation;
113+
holderDid: string;
114+
privateKey: string;
115+
challenge: string;
116+
}): Promise<any>;
117+
verifyPresentation(params: {
118+
signedPresentation: IVerifiablePresentation ,
119+
challenge: string,
120+
domain?: string,
121+
issuerDid: string,
122+
holderDid: string,
123+
}): Promise<any>;
79124

125+
```
80126

127+
## Issue
81128

129+
This sdk is in highly under development. In case you find any bug, kindly report it ASAP. Thank You!

build/src/constants.js

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
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;
4+
exports.compactProof = false;
5+
exports.HYPERSIGN_TESTNET_RPC = "http://localhost:26657";
6+
exports.HYPERSIGN_TESTNET_REST = "http://localhost:1317";
7+
exports.HYPERSIGN_MAINNET_RPC = "http://localhost:26657";
8+
exports.HYPERSIGN_MAINNET_REST = "http://localhost:1317";
9+
exports.HID_COSMOS_MODULE = '/hypersignprotocol.hidnode.ssi';
10+
exports.HYPERSIGN_NETWORK_DID_PATH = "hypersign-protocol/hidnode/ssi/did";
11+
exports.HYPERSIGN_NETWORK_SCHEMA_PATH = "hypersign-protocol/hidnode/ssi/schema";
12+
exports.HYPERSIGN_NETWORK_CREDENTIALSTATUS_PATH = "hypersign-protocol/hidnode/ssi/credential";
13+
exports.HYPERSIGN_NETWORK_BANK_BALANCE_PATH = "/bank/balances/";
14+
var HIDRpcEnums;
15+
(function (HIDRpcEnums) {
16+
HIDRpcEnums["MsgCreateDID"] = "MsgCreateDID";
17+
HIDRpcEnums["MsgUpdateDID"] = "MsgUpdateDID";
18+
HIDRpcEnums["MsgDeactivateDID"] = "MsgDeactivateDID";
19+
HIDRpcEnums["MsgCreateSchema"] = "MsgCreateSchema";
20+
HIDRpcEnums["MsgRegisterCredentialStatus"] = "MsgRegisterCredentialStatus";
21+
})(HIDRpcEnums = exports.HIDRpcEnums || (exports.HIDRpcEnums = {}));
22+
Object.freeze(HIDRpcEnums);
23+
var CredentialStatusEnums;
24+
(function (CredentialStatusEnums) {
25+
CredentialStatusEnums["LIVE"] = "Live";
26+
})(CredentialStatusEnums = exports.CredentialStatusEnums || (exports.CredentialStatusEnums = {}));
27+
exports.DID = {
28+
CONTROLLER_CONTEXT: "https://w3id.org/security/v2",
29+
SCHEME: "did",
30+
METHOD: "hid",
31+
NAMESPACE: "devnet",
32+
DID_BASE_CONTEXT: "https://www.w3.org/ns/did/v1",
33+
VERIFICATION_METHOD_TYPE: "Ed25519VerificationKey2020"
34+
};
35+
Object.freeze(exports.DID);
36+
exports.VC = {
37+
SCHEME: "vc",
38+
METHOD: "hid",
39+
NAMESPACE: "devnet",
40+
PREFIX: "vc:" + exports.DID.METHOD + ":" + exports.DID.NAMESPACE + ":",
41+
CREDENTAIL_SCHEMA_VALIDATOR_TYPE: "JsonSchemaValidator2018",
42+
CREDENTAIL_STATUS_TYPE: "CredentialStatusList2017",
43+
CREDENTAIL_BASE_CONTEXT: "https://www.w3.org/2018/credentials/v1",
44+
CREDENTAIL_SECURITY_CONTEXT_V2: "https://w3id.org/security/v2",
45+
CREDENTAIL_SECURITY_SUITE: "https://w3id.org/security/suites/ed25519-2020/v1",
46+
PROOF_PURPOSE: "assertion",
47+
VERIFICATION_METHOD_TYPE: "Ed25519VerificationKey2020",
48+
CRED_STATUS_TYPES: CredentialStatusEnums
49+
};
50+
Object.freeze(exports.VC);
51+
exports.VP = {
52+
PREFIX: "vp:",
53+
SCHEME: "vp",
54+
METHOD: "hid",
55+
NAMESPACE: "devnet",
56+
};
57+
Object.freeze(exports.VP);
58+
exports.SCHEMA = {
59+
SCHEME: "sch",
60+
METHOD: "hid",
61+
NAMESPACE: "devnet",
62+
SCHEMA_JSON: 'http://json-schema.org/draft-07/schema',
63+
SCHEMA_TYPE: 'https://w3c-ccg.github.io/vc-json-schemas/v1/schema/1.0/schema.json'
64+
};
65+
Object.freeze(exports.SCHEMA);
66+
exports.KEY_HEADERS = {
67+
MULTICODEC_ED25519_PUB_HEADER: new Uint8Array([0xed, 0x01]),
68+
MULTICODEC_ED25519_PRIV_HEADER: new Uint8Array([0x80, 0x26])
69+
};
70+
Object.freeze(exports.KEY_HEADERS);
71+
exports.GAS_PRICE = '0.1';
72+
exports.HID_DECIMAL = 6;
73+
exports.HID_DNOMINATION = 'uhid';
74+
exports.HID_MIN_GAS = '200000';
75+
exports.HID_MIN_FEE = '5000';

build/src/credential/ICredential.js

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });

0 commit comments

Comments
 (0)