|
1 |
| - |
2 | 1 | # Hypersign Self Soverign Identity (SSI) Js SDK
|
3 | 2 |
|
4 | 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/)
|
5 | 4 |
|
6 | 5 | ## Building
|
7 | 6 |
|
8 | 7 | ```sh
|
9 |
| -git submodule update --init --recursive |
10 |
| -cd libs/vc-js && npm i && cd - |
11 |
| -npm i |
| 8 | +npm i |
12 | 9 | npm run build
|
13 | 10 | npm run test
|
14 | 11 | ```
|
15 |
| -## Usage |
16 |
| - |
17 |
| -Install |
18 | 12 |
|
| 13 | +## Install |
19 | 14 |
|
20 | 15 | ```js
|
21 | 16 | npm i hs-ssi-sdk --save
|
22 | 17 | ```
|
23 | 18 |
|
24 |
| - |
25 |
| -Use |
| 19 | +## Usage |
26 | 20 |
|
27 | 21 | ```js
|
28 |
| -// import |
29 |
| -import HypersignSsiSDK from 'hs-ssi-sdk'; |
30 |
| - |
31 |
| -// initialise |
| 22 | +import HypersignSsiSDK from "hs-ssi-sdk"; |
32 | 23 | 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; |
37 | 30 | ```
|
38 | 31 |
|
39 |
| - |
40 | 32 | ## APIs
|
41 | 33 |
|
42 | 34 | ### hsSdk.did
|
43 | 35 |
|
44 | 36 | ```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>; |
53 | 57 | ```
|
54 | 58 |
|
55 | 59 | ### hsSdk.schema
|
56 | 60 |
|
57 | 61 | ```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>; |
62 | 80 |
|
63 | 81 | ```
|
64 | 82 |
|
65 |
| -### hsSdk.credential |
| 83 | +### hsSdk.vc |
66 | 84 |
|
67 | 85 | ```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>; |
74 | 102 | ```
|
75 | 103 |
|
76 |
| -## Issue |
| 104 | +### hsSdk.vp |
77 | 105 |
|
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>; |
79 | 124 |
|
| 125 | +``` |
80 | 126 |
|
| 127 | +## Issue |
81 | 128 |
|
| 129 | +This sdk is in highly under development. In case you find any bug, kindly report it ASAP. Thank You! |
0 commit comments