Skip to content

Commit af04155

Browse files
authored
Merge pull request #121 from hypersign-protocol/develop
Develop
2 parents 731c11b + 3407e26 commit af04155

File tree

216 files changed

+55555
-9519
lines changed

Some content is hidden

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

216 files changed

+55555
-9519
lines changed

.eslintrc.json

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

.github/workflows/Build.yml

Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
# This workflow will do a clean installation of node dependencies, cache/restore them, build the source code and run tests across different versions of node
2+
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs
3+
4+
name: Build
5+
6+
on:
7+
push:
8+
branches: [ "main","develop" ]
9+
pull_request:
10+
branches: [ "main","develop" ]
11+
12+
jobs:
13+
build:
14+
15+
runs-on: ubuntu-latest
16+
17+
strategy:
18+
matrix:
19+
node-version: [16.x]
20+
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/
21+
22+
steps:
23+
- uses: actions/checkout@v3
24+
- name: Use Node.js ${{ matrix.node-version }}
25+
uses: actions/setup-node@v3
26+
with:
27+
node-version: ${{ matrix.node-version }}
28+
cache: 'npm'
29+
- run: npm ci
30+
- run: npm run build --if-present
31+
- run: npm test

.gitignore

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

54

README.md

Lines changed: 45 additions & 91 deletions
Original file line numberDiff line numberDiff line change
@@ -1,128 +1,82 @@
1-
# Hypersign Self Soverign Identity (SSI) Js SDK
1+
# Hypersign Self Soverign Identity (SSI) SDK ![Build](https://github.com/hypersign-protocol/hid-ssi-js-sdk/workflows/Build/badge.svg)
22

3-
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/)
3+
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/).
44

55
## Building
66

77
```sh
88
npm i
99
npm run build
10+
```
11+
12+
## Testing
13+
14+
```bash
15+
## Run this to test all features
1016
npm run test
17+
18+
## OR Run individual test cases
19+
npm run test-did
20+
npm run test-schema
21+
npm run test-credential
22+
npm run test-presentation
1123
```
1224

1325
## Install
1426

1527
```js
16-
npm i hs-ssi-sdk --save
28+
npm i https://github.com/hypersign-protocol/hid-ssi-js-sdk --save
1729
```
30+
**Supported node version: ^v16**
1831

1932
## Usage
2033

21-
```js
22-
import HypersignSsiSDK from "hs-ssi-sdk";
23-
const hsSdk = new HypersignSsiSDK(
34+
```javascript
35+
// Import SSI SDK
36+
import { HypersignSSISdk } from "hs-ssi-sdk";
37+
38+
// Instantiate SSI SDK
39+
const hsSdk = new HypersignSSISdk(
2440
offlineSigner,
25-
"http://localhost:26657", // RPC
26-
"http://localhost:1317" // REST Endpoint
41+
namespace: 'testnet'
42+
nodeRpcEndpoint: "https://rpc.jagrat.hypersign.id", // RPC
43+
nodeRestEndpoint: "https://api.jagrat.hypersign.id" // REST Endpoint
2744
);
45+
// Mandatory method call to initialize offlineSigner
2846
await hsSdk.init();
29-
const { did, schema, vc, vp } = hsSdk;
47+
48+
// Exposes these 4 instance of objects
49+
const hypersignDID: HypersignDID = hsSdk.did;
50+
const hypersignVC: HypersignVerifiableCredential = hsSdk.vc;
51+
const hypersignVP: HypersignVerifiablePresentation = hsSdk.vp;
52+
const hypersignSchema: HypersignSchema = hsSdk.schema;
3053
```
3154

32-
## APIs
55+
### OfflineSigner
3356

34-
### hsSdk.did
57+
You may follow this [this code snnipet](https://github.com/hypersign-protocol/hid-ssi-js-sdk/blob/develop/src/tests/config.ts) for creating OfflineSigner
3558

3659
```js
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>;
60+
offlineSigner = await createWallet(mnemonic);
5761
```
5862

59-
### hsSdk.schema
63+
## APIs
6064

61-
```js
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>;
65+
### Hypersign DID SDK
8066

81-
```
67+
Read [documentation](/docs/did.md)
8268

83-
### hsSdk.vc
69+
### Hypersign Schema SDK
70+
71+
Read [documentation](/docs/schema.md)
8472

85-
```js
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>;
102-
```
73+
### Hypersign Verifiable Credential SDK
10374

104-
### hsSdk.vp
75+
Read [documentation](/docs/vc.md)
10576

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>;
77+
### Hypersign Verifiable Presentation SDK
12478

125-
```
79+
Read [documentation](/docs/vp.md)
12680

12781
## Issue
12882

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
import { Writer, Reader } from "protobufjs/minimal";
2+
export declare const protobufPackage = "hypersignprotocol.hidnode.ssi";
3+
export interface ClientSpec {
4+
type: string;
5+
adr036SignerAddress: string;
6+
}
7+
export declare const ClientSpec: {
8+
encode(message: ClientSpec, writer?: Writer): Writer;
9+
decode(input: Reader | Uint8Array, length?: number): ClientSpec;
10+
fromJSON(object: any): ClientSpec;
11+
toJSON(message: ClientSpec): unknown;
12+
fromPartial(object: DeepPartial<ClientSpec>): ClientSpec;
13+
};
14+
type Builtin = Date | Function | Uint8Array | string | number | undefined;
15+
export type DeepPartial<T> = T extends Builtin ? T : T extends Array<infer U> ? Array<DeepPartial<U>> : T extends ReadonlyArray<infer U> ? ReadonlyArray<DeepPartial<U>> : T extends {} ? {
16+
[K in keyof T]?: DeepPartial<T[K]>;
17+
} : Partial<T>;
18+
export {};
19+
//# sourceMappingURL=clientSpec.d.ts.map

build/libs/generated/ssi/clientSpec.d.ts.map

Lines changed: 1 addition & 0 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 79 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,79 @@
1+
"use strict";
2+
Object.defineProperty(exports, "__esModule", { value: true });
3+
exports.ClientSpec = exports.protobufPackage = void 0;
4+
/* eslint-disable */
5+
const minimal_1 = require("protobufjs/minimal");
6+
exports.protobufPackage = "hypersignprotocol.hidnode.ssi";
7+
const baseClientSpec = { type: "", adr036SignerAddress: "" };
8+
exports.ClientSpec = {
9+
encode(message, writer = minimal_1.Writer.create()) {
10+
if (message.type !== "") {
11+
writer.uint32(10).string(message.type);
12+
}
13+
if (message.adr036SignerAddress !== "") {
14+
writer.uint32(18).string(message.adr036SignerAddress);
15+
}
16+
return writer;
17+
},
18+
decode(input, length) {
19+
const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input;
20+
let end = length === undefined ? reader.len : reader.pos + length;
21+
const message = Object.assign({}, baseClientSpec);
22+
while (reader.pos < end) {
23+
const tag = reader.uint32();
24+
switch (tag >>> 3) {
25+
case 1:
26+
message.type = reader.string();
27+
break;
28+
case 2:
29+
message.adr036SignerAddress = reader.string();
30+
break;
31+
default:
32+
reader.skipType(tag & 7);
33+
break;
34+
}
35+
}
36+
return message;
37+
},
38+
fromJSON(object) {
39+
const message = Object.assign({}, baseClientSpec);
40+
if (object.type !== undefined && object.type !== null) {
41+
message.type = String(object.type);
42+
}
43+
else {
44+
message.type = "";
45+
}
46+
if (object.adr036SignerAddress !== undefined &&
47+
object.adr036SignerAddress !== null) {
48+
message.adr036SignerAddress = String(object.adr036SignerAddress);
49+
}
50+
else {
51+
message.adr036SignerAddress = "";
52+
}
53+
return message;
54+
},
55+
toJSON(message) {
56+
const obj = {};
57+
message.type !== undefined && (obj.type = message.type);
58+
message.adr036SignerAddress !== undefined &&
59+
(obj.adr036SignerAddress = message.adr036SignerAddress);
60+
return obj;
61+
},
62+
fromPartial(object) {
63+
const message = Object.assign({}, baseClientSpec);
64+
if (object.type !== undefined && object.type !== null) {
65+
message.type = object.type;
66+
}
67+
else {
68+
message.type = "";
69+
}
70+
if (object.adr036SignerAddress !== undefined &&
71+
object.adr036SignerAddress !== null) {
72+
message.adr036SignerAddress = object.adr036SignerAddress;
73+
}
74+
else {
75+
message.adr036SignerAddress = "";
76+
}
77+
return message;
78+
},
79+
};

0 commit comments

Comments
 (0)