Skip to content

Commit

Permalink
Merge pull request #121 from hypersign-protocol/develop
Browse files Browse the repository at this point in the history
Develop
  • Loading branch information
Vishwas1 authored Oct 18, 2023
2 parents 731c11b + 3407e26 commit af04155
Show file tree
Hide file tree
Showing 216 changed files with 55,555 additions and 9,519 deletions.
34 changes: 15 additions & 19 deletions .eslintrc.json
Original file line number Diff line number Diff line change
@@ -1,21 +1,17 @@
{
"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
}
"ignorePatterns": ["node_modules/", "build/"],
"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
}
}
31 changes: 31 additions & 0 deletions .github/workflows/Build.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
# 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
# For more information see: https://docs.github.com/en/actions/automating-builds-and-tests/building-and-testing-nodejs

name: Build

on:
push:
branches: [ "main","develop" ]
pull_request:
branches: [ "main","develop" ]

jobs:
build:

runs-on: ubuntu-latest

strategy:
matrix:
node-version: [16.x]
# See supported Node.js release schedule at https://nodejs.org/en/about/releases/

steps:
- uses: actions/checkout@v3
- name: Use Node.js ${{ matrix.node-version }}
uses: actions/setup-node@v3
with:
node-version: ${{ matrix.node-version }}
cache: 'npm'
- run: npm ci
- run: npm run build --if-present
- run: npm test
1 change: 0 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
node_modules
libs
dist


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

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/)
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
npm i
npm run build
```

## Testing

```bash
## Run this to test all features
npm run test

## OR Run individual test cases
npm run test-did
npm run test-schema
npm run test-credential
npm run test-presentation
```

## Install

```js
npm i hs-ssi-sdk --save
npm i https://github.com/hypersign-protocol/hid-ssi-js-sdk --save
```
**Supported node version: ^v16**

## Usage

```js
import HypersignSsiSDK from "hs-ssi-sdk";
const hsSdk = new HypersignSsiSDK(
```javascript
// Import SSI SDK
import { HypersignSSISdk } from "hs-ssi-sdk";

// Instantiate SSI SDK
const hsSdk = new HypersignSSISdk(
offlineSigner,
"http://localhost:26657", // RPC
"http://localhost:1317" // REST Endpoint
namespace: 'testnet'
nodeRpcEndpoint: "https://rpc.jagrat.hypersign.id", // RPC
nodeRestEndpoint: "https://api.jagrat.hypersign.id" // REST Endpoint
);
// Mandatory method call to initialize offlineSigner
await hsSdk.init();
const { did, schema, vc, vp } = hsSdk;

// Exposes these 4 instance of objects
const hypersignDID: HypersignDID = hsSdk.did;
const hypersignVC: HypersignVerifiableCredential = hsSdk.vc;
const hypersignVP: HypersignVerifiablePresentation = hsSdk.vp;
const hypersignSchema: HypersignSchema = hsSdk.schema;
```

## APIs
### OfflineSigner

### hsSdk.did
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

```js
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>;
offlineSigner = await createWallet(mnemonic);
```

### hsSdk.schema
## APIs

```js
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>;
### Hypersign DID SDK

```
Read [documentation](/docs/did.md)

### hsSdk.vc
### Hypersign Schema SDK

Read [documentation](/docs/schema.md)

```js
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>;
```
### Hypersign Verifiable Credential SDK

### hsSdk.vp
Read [documentation](/docs/vc.md)

```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>;
### Hypersign Verifiable Presentation SDK

```
Read [documentation](/docs/vp.md)

## Issue

Expand Down
19 changes: 19 additions & 0 deletions build/libs/generated/ssi/clientSpec.d.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
import { Writer, Reader } from "protobufjs/minimal";
export declare const protobufPackage = "hypersignprotocol.hidnode.ssi";
export interface ClientSpec {
type: string;
adr036SignerAddress: string;
}
export declare const ClientSpec: {
encode(message: ClientSpec, writer?: Writer): Writer;
decode(input: Reader | Uint8Array, length?: number): ClientSpec;
fromJSON(object: any): ClientSpec;
toJSON(message: ClientSpec): unknown;
fromPartial(object: DeepPartial<ClientSpec>): ClientSpec;
};
type Builtin = Date | Function | Uint8Array | string | number | undefined;
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 {} ? {
[K in keyof T]?: DeepPartial<T[K]>;
} : Partial<T>;
export {};
//# sourceMappingURL=clientSpec.d.ts.map
1 change: 1 addition & 0 deletions build/libs/generated/ssi/clientSpec.d.ts.map

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

79 changes: 79 additions & 0 deletions build/libs/generated/ssi/clientSpec.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ClientSpec = exports.protobufPackage = void 0;
/* eslint-disable */
const minimal_1 = require("protobufjs/minimal");
exports.protobufPackage = "hypersignprotocol.hidnode.ssi";
const baseClientSpec = { type: "", adr036SignerAddress: "" };
exports.ClientSpec = {
encode(message, writer = minimal_1.Writer.create()) {
if (message.type !== "") {
writer.uint32(10).string(message.type);
}
if (message.adr036SignerAddress !== "") {
writer.uint32(18).string(message.adr036SignerAddress);
}
return writer;
},
decode(input, length) {
const reader = input instanceof Uint8Array ? new minimal_1.Reader(input) : input;
let end = length === undefined ? reader.len : reader.pos + length;
const message = Object.assign({}, baseClientSpec);
while (reader.pos < end) {
const tag = reader.uint32();
switch (tag >>> 3) {
case 1:
message.type = reader.string();
break;
case 2:
message.adr036SignerAddress = reader.string();
break;
default:
reader.skipType(tag & 7);
break;
}
}
return message;
},
fromJSON(object) {
const message = Object.assign({}, baseClientSpec);
if (object.type !== undefined && object.type !== null) {
message.type = String(object.type);
}
else {
message.type = "";
}
if (object.adr036SignerAddress !== undefined &&
object.adr036SignerAddress !== null) {
message.adr036SignerAddress = String(object.adr036SignerAddress);
}
else {
message.adr036SignerAddress = "";
}
return message;
},
toJSON(message) {
const obj = {};
message.type !== undefined && (obj.type = message.type);
message.adr036SignerAddress !== undefined &&
(obj.adr036SignerAddress = message.adr036SignerAddress);
return obj;
},
fromPartial(object) {
const message = Object.assign({}, baseClientSpec);
if (object.type !== undefined && object.type !== null) {
message.type = object.type;
}
else {
message.type = "";
}
if (object.adr036SignerAddress !== undefined &&
object.adr036SignerAddress !== null) {
message.adr036SignerAddress = object.adr036SignerAddress;
}
else {
message.adr036SignerAddress = "";
}
return message;
},
};
Loading

0 comments on commit af04155

Please sign in to comment.