Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Develop #68

Merged
merged 122 commits into from
Oct 14, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
122 commits
Select commit Hold shift + click to select a range
3443428
added typescript package
Vishwas1 Jan 25, 2022
aca23e8
we need not to handle the error in library
Vishwas1 Jan 25, 2022
2ca38df
sent tokens using cosmos wallet
Vishwas1 Jan 25, 2022
4484c95
call RPC - not working yet
Vishwas1 Jan 25, 2022
3565938
custom rpc all worked
Vishwas1 Jan 25, 2022
7bbbff0
implmented did resolve
Vishwas1 Jan 25, 2022
9c22ae1
integrated did_create and did_resolve with cosmos
Vishwas1 Jan 26, 2022
167f4fb
Implemented CreateSchema and GetSchema RPC
Vishwas1 Jan 27, 2022
e778d28
Implemented CreateSchema and GetSchema RPC
Vishwas1 Jan 27, 2022
cdb86c5
Making credential compatible with hid-ndoe
Vishwas1 Jan 27, 2022
4371a15
Making credential compatible with hid-ndoe
Vishwas1 Jan 27, 2022
2acfee1
fixed a spelling mistake
Vishwas1 Jan 27, 2022
dfe9bed
keys.json and schema.json as generated files. so no need to checkin
Vishwas1 Jan 27, 2022
78aa30d
added basic wallet features like encrypt wallet, decrypt wallet, bala…
Vishwas1 Jan 27, 2022
7acd857
modularized the project. Separated out the wallet from sdk
Vishwas1 May 9, 2022
2c641ea
Signature scheme is update to Ed25519VerficationKey2020; key lengths …
arnabghose997 May 9, 2022
9d8a3c4
fixed minor bug
Vishwas1 May 10, 2022
5682a48
temporary fixes
Vishwas1 May 11, 2022
91990c6
made codes compatible with genenrated did interface
Vishwas1 May 12, 2022
da04c5a
Temporary fix for Unmarshalling didDoc
arnabghose997 May 12, 2022
7e2f0a5
Fixed DID Resolve
arnabghose997 May 12, 2022
8b0b6b4
added condition to check for window.crypto object
arnabghose997 May 13, 2022
e80f10b
implemented protobufjs serialization to marshal DID data
arnabghose997 May 14, 2022
73accff
Refactored Create Schema Tx
arnabghose997 May 16, 2022
fc4e5ea
refactored resolve schema
arnabghose997 May 16, 2022
c32641e
The field author is being set by the method setFields() of Schema class
arnabghose997 May 17, 2022
3a389cb
encode() method is used for Did Document encoding
arnabghose997 May 17, 2022
f18c6dd
refactored code for did update
arnabghose997 May 17, 2022
d2a1065
refactored code for did deactivate
arnabghose997 May 17, 2022
c16327f
added function to update didDoc fields
arnabghose997 May 18, 2022
2b54ff8
restructured schema classs
Vishwas1 May 18, 2022
7bd4d8d
fixed random id
Vishwas1 May 18, 2022
c49d1a3
structured schema
Vishwas1 May 18, 2022
e568d08
implemented verificable credential feature
Vishwas1 May 19, 2022
f8b19cf
code cleanup
Vishwas1 May 19, 2022
95cfec8
implemented vp
Vishwas1 May 19, 2022
58b157d
code cleanup
Vishwas1 May 19, 2022
0b3d061
code clean up for vc
Vishwas1 May 20, 2022
8a652c3
code cleanup for vp
Vishwas1 May 20, 2022
af62d69
updated the folder structure
Vishwas1 May 20, 2022
7534350
fixed the key type ; using digital bazar now
Vishwas1 May 20, 2022
037575d
udpated the interfact
Vishwas1 May 20, 2022
56887f0
updated interface
Vishwas1 May 20, 2022
e55ce44
updated the test folder st
Vishwas1 May 20, 2022
de9e5c4
structure code a bit
Vishwas1 May 20, 2022
165522a
code cleanup
Vishwas1 May 20, 2022
52a3069
updated the readme
Vishwas1 May 20, 2022
e306e85
added prettier
Vishwas1 May 24, 2022
24bb958
prettified
Vishwas1 May 24, 2022
701b104
removed schema hardcoding
Vishwas1 May 24, 2022
0f48a41
added eslinter
Vishwas1 May 24, 2022
56e2314
fixed es lint issues
Vishwas1 May 24, 2022
4089003
added husky. now will check if this work
Vishwas1 May 24, 2022
695d826
udpated readme; husky should work
Vishwas1 May 24, 2022
4790487
added Jest - testing framework
Vishwas1 May 24, 2022
cc2a34c
updated the util
Vishwas1 May 25, 2022
f265fec
fixed a bug
Vishwas1 May 26, 2022
f54fa17
added old tests , need to remove them later
Vishwas1 May 26, 2022
dc884b5
fixed the error message
Vishwas1 May 27, 2022
39b46d5
removed hardcoded gas fee, made it dynamic
Vishwas1 May 31, 2022
c113dcc
small bug fix in packagejson
Vishwas1 May 31, 2022
058c8e5
cleared
Vishwas1 Jun 1, 2022
5cb1db8
pushing dist for npm git
Vishwas1 Jun 1, 2022
22cad05
updated error logs
Vishwas1 Jun 1, 2022
b7731d4
updated dist
Vishwas1 Jun 1, 2022
9824fd8
updated the package version
Vishwas1 Jun 15, 2022
032447a
fixed testcases
Vishwas1 Jun 30, 2022
468f54e
removed redundatant folder
Vishwas1 Jun 30, 2022
aa836b2
made compatible with lastest build of hid-node
Vishwas1 Jun 30, 2022
3e263fc
updated schema and vc mocks
Vishwas1 Jun 30, 2022
d64fbae
implemented credential status
Vishwas1 Jul 1, 2022
b9385ec
added comment and log
Vishwas1 Jul 1, 2022
1771dd4
updated
Vishwas1 Jul 1, 2022
e89ba93
removed the hardcoing as bug is fixed at hidnode
Vishwas1 Jul 1, 2022
41e5516
added namespace: todo: need to take the namespace fromuser
Vishwas1 Jul 5, 2022
ff666b2
added name space
Vishwas1 Jul 5, 2022
81ba999
updated mocks
Vishwas1 Jul 5, 2022
660be8c
took namespace as a param to init sdk
Vishwas1 Jul 5, 2022
c24c93d
updated test
Vishwas1 Jul 5, 2022
1542b3c
added dist - will remove it
Vishwas1 Jul 7, 2022
8540520
changed dist to build
Vishwas1 Jul 7, 2022
8f1abf8
revert
Vishwas1 Jul 7, 2022
23b270f
fixed tests cases and fixed tx rpc codes
Aug 17, 2022
1375512
refactor code
Aug 17, 2022
f079393
refactor
Aug 17, 2022
87d2338
Merge pull request #43 from hypersign-protocol/ssi-integration-testing
Vishwas1 Aug 19, 2022
612eea7
changed name of test dir
Vishwas1 Aug 24, 2022
9c4cb21
updated with latest version of network
Vishwas1 Sep 6, 2022
89006f4
remove consoloe log
Vishwas1 Sep 6, 2022
28f3de5
bumped version
Vishwas1 Sep 6, 2022
835a9c2
fixed digest bug
Vishwas1 Sep 7, 2022
bbcc725
bumped the version
Vishwas1 Sep 7, 2022
76079b2
fixed sdk
Sep 8, 2022
b8841ea
Merge pull request #50 from hypersign-protocol/ssi-wallet-hypersign
Pratap2018 Sep 8, 2022
d717314
schema dynamic support
Sep 13, 2022
735812b
refactorize
Vishwas1 Sep 14, 2022
b29e753
refactorize
Vishwas1 Sep 14, 2022
3f8a232
updated mocks
Vishwas1 Sep 14, 2022
64d2383
testcases for vc with custom schema and for schema.org
Vishwas1 Sep 14, 2022
40291c5
tring to fix didAuth
Sep 14, 2022
69976a7
DID AUTH
Sep 15, 2022
f4b46ea
support for private did resolve
Sep 15, 2022
b0f2be2
Merge pull request #52 from hypersign-protocol/figureout-schmea-refactor
Vishwas1 Oct 1, 2022
8aa742f
updated config
Vishwas1 Oct 1, 2022
1297ebf
added latest mocks
Vishwas1 Oct 1, 2022
5b29dfb
adding w3 org cache
Vishwas1 Oct 1, 2022
8789610
Merge branch 'figureout-Schema' into support-private-did
Vishwas1 Oct 1, 2022
76e689e
Merge pull request #53 from hypersign-protocol/support-private-did
Vishwas1 Oct 1, 2022
2158196
fixed didAuth bug
Oct 3, 2022
a888a3a
Merge pull request #54 from hypersign-protocol/figureout-Schema
Pratap2018 Oct 3, 2022
7ab02e9
all scenario tested
Oct 3, 2022
5cf6b3f
test cases for private did
Oct 3, 2022
a70d5f6
mock updated
Oct 3, 2022
60f2727
mock added
Oct 3, 2022
3fad148
fixed all
Oct 3, 2022
0d49b8b
added test files
Oct 3, 2022
3e73f22
deterministic Did creation
Oct 4, 2022
3487bda
Merge pull request #57 from hypersign-protocol/deterministic
Pratap2018 Oct 5, 2022
a886114
added build to remove npm error while import
Oct 11, 2022
b89d400
fixed the issue
Oct 12, 2022
bf8184f
Merge pull request #66 from hypersign-protocol/date-race-arround
Pratap2018 Oct 12, 2022
fc7f656
bumped version
Oct 14, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions .eslintignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
node_modules
dist
21 changes: 21 additions & 0 deletions .eslintrc.json
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
}
}
4 changes: 3 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
node_modules
libs
dist
libs


1 change: 1 addition & 0 deletions .husky/.gitignore
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
_
4 changes: 4 additions & 0 deletions .husky/pre-commit
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
#!/bin/sh
. "$(dirname "$0")/_/husky.sh"

npm run build
3 changes: 3 additions & 0 deletions .prettierignore
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
node_modules
dist
hypersign.json
5 changes: 5 additions & 0 deletions .prettierrc.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
{
"singleQuote": true,
"arrowParens": "always",
"printWidth": 120
}
126 changes: 87 additions & 39 deletions README.md
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!
75 changes: 75 additions & 0 deletions build/src/constants.js
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';
2 changes: 2 additions & 0 deletions build/src/credential/ICredential.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
Loading