@twin.org/identity-rest-client 0.0.3-next.8 → 0.9.0-next.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +2 -2
- package/dist/es/identityProfileRestClient.js +4 -4
- package/dist/es/identityProfileRestClient.js.map +1 -1
- package/dist/es/identityResolverRestClient.js +1 -1
- package/dist/es/identityResolverRestClient.js.map +1 -1
- package/dist/es/identityRestClient.js +80 -25
- package/dist/es/identityRestClient.js.map +1 -1
- package/dist/types/identityProfileRestClient.d.ts +4 -4
- package/dist/types/identityResolverRestClient.d.ts +1 -1
- package/dist/types/identityRestClient.d.ts +52 -13
- package/docs/changelog.md +576 -85
- package/docs/examples.md +175 -1
- package/docs/reference/classes/IdentityProfileRestClient.md +12 -12
- package/docs/reference/classes/IdentityResolverRestClient.md +4 -4
- package/docs/reference/classes/IdentityRestClient.md +155 -45
- package/package.json +13 -13
package/docs/examples.md
CHANGED
|
@@ -1 +1,175 @@
|
|
|
1
|
-
#
|
|
1
|
+
# Identity REST Client Examples
|
|
2
|
+
|
|
3
|
+
Use these examples to call identity REST endpoints from applications that need document lifecycle, credential, and profile operations.
|
|
4
|
+
|
|
5
|
+
## IdentityRestClient
|
|
6
|
+
|
|
7
|
+
```typescript
|
|
8
|
+
import { IdentityRestClient } from '@twin.org/identity-rest-client';
|
|
9
|
+
|
|
10
|
+
const client = new IdentityRestClient({
|
|
11
|
+
endpoint: 'http://localhost:8080'
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
const className = client.className();
|
|
15
|
+
const createdDocument = await client.identityCreate('iota');
|
|
16
|
+
|
|
17
|
+
await client.identityRemove(createdDocument.id);
|
|
18
|
+
|
|
19
|
+
console.log(className); // IdentityRestClient
|
|
20
|
+
console.log(createdDocument.id); // did:iota:tst:0x...
|
|
21
|
+
```
|
|
22
|
+
|
|
23
|
+
```typescript
|
|
24
|
+
import { IdentityRestClient } from '@twin.org/identity-rest-client';
|
|
25
|
+
import { DidVerificationMethodType, ProofTypes } from '@twin.org/standards-w3c-did';
|
|
26
|
+
|
|
27
|
+
const client = new IdentityRestClient({
|
|
28
|
+
endpoint: 'http://localhost:8080'
|
|
29
|
+
});
|
|
30
|
+
|
|
31
|
+
const did = 'did:iota:tst:0x1234abcd';
|
|
32
|
+
|
|
33
|
+
const verificationMethod = await client.verificationMethodCreate(
|
|
34
|
+
did,
|
|
35
|
+
DidVerificationMethodType.VerificationMethod,
|
|
36
|
+
'signing-key'
|
|
37
|
+
);
|
|
38
|
+
|
|
39
|
+
await client.verificationMethodRemove(verificationMethod.id);
|
|
40
|
+
|
|
41
|
+
const service = await client.serviceCreate(
|
|
42
|
+
did,
|
|
43
|
+
'linked-domain',
|
|
44
|
+
'LinkedDomains',
|
|
45
|
+
'https://example.org'
|
|
46
|
+
);
|
|
47
|
+
|
|
48
|
+
await client.serviceRemove(service.id);
|
|
49
|
+
|
|
50
|
+
const credentialCreateResult = await client.verifiableCredentialCreate(
|
|
51
|
+
`${did}#signing-key`,
|
|
52
|
+
'urn:uuid:credential-001',
|
|
53
|
+
{
|
|
54
|
+
id: 'did:iota:tst:0x5678efab',
|
|
55
|
+
name: 'Alice'
|
|
56
|
+
},
|
|
57
|
+
{
|
|
58
|
+
revocationIndex: 2
|
|
59
|
+
}
|
|
60
|
+
);
|
|
61
|
+
|
|
62
|
+
const credentialVerificationResult = await client.verifiableCredentialVerify(
|
|
63
|
+
credentialCreateResult.jwt
|
|
64
|
+
);
|
|
65
|
+
|
|
66
|
+
await client.verifiableCredentialRevoke(did, 2);
|
|
67
|
+
await client.verifiableCredentialUnrevoke(did, 2);
|
|
68
|
+
|
|
69
|
+
const presentationCreateResult = await client.verifiablePresentationCreate(
|
|
70
|
+
`${did}#signing-key`,
|
|
71
|
+
'urn:uuid:presentation-001',
|
|
72
|
+
['https://www.w3.org/2018/credentials/v1'],
|
|
73
|
+
['VerifiablePresentation'],
|
|
74
|
+
[credentialCreateResult.jwt]
|
|
75
|
+
);
|
|
76
|
+
|
|
77
|
+
const presentationVerificationResult = await client.verifiablePresentationVerify(
|
|
78
|
+
presentationCreateResult.jwt
|
|
79
|
+
);
|
|
80
|
+
|
|
81
|
+
const proof = await client.proofCreate(`${did}#signing-key`, ProofTypes.DataIntegrityProof, {
|
|
82
|
+
id: 'urn:example:doc-1',
|
|
83
|
+
name: 'Sample'
|
|
84
|
+
});
|
|
85
|
+
|
|
86
|
+
const proofVerified = await client.proofVerify(
|
|
87
|
+
{
|
|
88
|
+
id: 'urn:example:doc-1',
|
|
89
|
+
name: 'Sample'
|
|
90
|
+
},
|
|
91
|
+
proof
|
|
92
|
+
);
|
|
93
|
+
|
|
94
|
+
console.log(credentialVerificationResult.revoked); // false
|
|
95
|
+
console.log(presentationVerificationResult.revoked); // false
|
|
96
|
+
console.log(proofVerified); // true
|
|
97
|
+
```
|
|
98
|
+
|
|
99
|
+
## IdentityProfileRestClient
|
|
100
|
+
|
|
101
|
+
```typescript
|
|
102
|
+
import { IdentityProfileRestClient } from '@twin.org/identity-rest-client';
|
|
103
|
+
|
|
104
|
+
interface PublicProfile {
|
|
105
|
+
displayName: string;
|
|
106
|
+
website: string;
|
|
107
|
+
}
|
|
108
|
+
|
|
109
|
+
interface PrivateProfile {
|
|
110
|
+
contactEmail: string;
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
const profileClient = new IdentityProfileRestClient<PublicProfile, PrivateProfile>({
|
|
114
|
+
endpoint: 'http://localhost:8080'
|
|
115
|
+
});
|
|
116
|
+
|
|
117
|
+
const className = profileClient.className();
|
|
118
|
+
|
|
119
|
+
await profileClient.create(
|
|
120
|
+
{
|
|
121
|
+
displayName: 'Alice',
|
|
122
|
+
website: 'https://example.org'
|
|
123
|
+
},
|
|
124
|
+
{
|
|
125
|
+
contactEmail: 'alice@example.org'
|
|
126
|
+
}
|
|
127
|
+
);
|
|
128
|
+
|
|
129
|
+
const profile = await profileClient.get(['displayName'], ['contactEmail']);
|
|
130
|
+
const publicProfile = await profileClient.getPublic(profile.identity, ['displayName']);
|
|
131
|
+
|
|
132
|
+
await profileClient.update(
|
|
133
|
+
{
|
|
134
|
+
displayName: 'Alice Doe',
|
|
135
|
+
website: 'https://example.org'
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
contactEmail: 'alice.doe@example.org'
|
|
139
|
+
}
|
|
140
|
+
);
|
|
141
|
+
|
|
142
|
+
const profileList = await profileClient.list(
|
|
143
|
+
[
|
|
144
|
+
{
|
|
145
|
+
propertyName: 'displayName',
|
|
146
|
+
propertyValue: 'Alice Doe'
|
|
147
|
+
}
|
|
148
|
+
],
|
|
149
|
+
['displayName'],
|
|
150
|
+
undefined,
|
|
151
|
+
10
|
|
152
|
+
);
|
|
153
|
+
|
|
154
|
+
await profileClient.remove();
|
|
155
|
+
|
|
156
|
+
console.log(className); // IdentityProfileRestClient
|
|
157
|
+
console.log(publicProfile.displayName); // Alice
|
|
158
|
+
console.log(profileList.items.length); // 1
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
## IdentityResolverRestClient
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
import { IdentityResolverRestClient } from '@twin.org/identity-rest-client';
|
|
165
|
+
|
|
166
|
+
const resolverClient = new IdentityResolverRestClient({
|
|
167
|
+
endpoint: 'http://localhost:8080'
|
|
168
|
+
});
|
|
169
|
+
|
|
170
|
+
const className = resolverClient.className();
|
|
171
|
+
const didDocument = await resolverClient.identityResolve('did:iota:tst:0x1234abcd');
|
|
172
|
+
|
|
173
|
+
console.log(className); // IdentityResolverRestClient
|
|
174
|
+
console.log(didDocument.id); // did:iota:tst:0x1234abcd
|
|
175
|
+
```
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Class: IdentityProfileRestClient\<T, U\>
|
|
2
2
|
|
|
3
|
-
Client for performing identity through
|
|
3
|
+
Client for performing identity profile operations through REST endpoints.
|
|
4
4
|
|
|
5
5
|
## Extends
|
|
6
6
|
|
|
@@ -46,7 +46,7 @@ The configuration for the client.
|
|
|
46
46
|
|
|
47
47
|
## Properties
|
|
48
48
|
|
|
49
|
-
### CLASS\_NAME
|
|
49
|
+
### CLASS\_NAME {#class_name}
|
|
50
50
|
|
|
51
51
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
52
52
|
|
|
@@ -54,7 +54,7 @@ Runtime name for the class.
|
|
|
54
54
|
|
|
55
55
|
## Methods
|
|
56
56
|
|
|
57
|
-
### className()
|
|
57
|
+
### className() {#classname}
|
|
58
58
|
|
|
59
59
|
> **className**(): `string`
|
|
60
60
|
|
|
@@ -72,7 +72,7 @@ The class name of the component.
|
|
|
72
72
|
|
|
73
73
|
***
|
|
74
74
|
|
|
75
|
-
### create()
|
|
75
|
+
### create() {#create}
|
|
76
76
|
|
|
77
77
|
> **create**(`publicProfile?`, `privateProfile?`): `Promise`\<`void`\>
|
|
78
78
|
|
|
@@ -96,7 +96,7 @@ The private profile data as JSON-LD.
|
|
|
96
96
|
|
|
97
97
|
`Promise`\<`void`\>
|
|
98
98
|
|
|
99
|
-
|
|
99
|
+
A promise that resolves when the profile has been created.
|
|
100
100
|
|
|
101
101
|
#### Implementation of
|
|
102
102
|
|
|
@@ -104,7 +104,7 @@ Nothing.
|
|
|
104
104
|
|
|
105
105
|
***
|
|
106
106
|
|
|
107
|
-
### get()
|
|
107
|
+
### get() {#get}
|
|
108
108
|
|
|
109
109
|
> **get**(`publicPropertyNames?`, `privatePropertyNames?`): `Promise`\<\{ `identity`: `string`; `publicProfile?`: `Partial`\<`T`\>; `privateProfile?`: `Partial`\<`U`\>; \}\>
|
|
110
110
|
|
|
@@ -136,7 +136,7 @@ The identity and the items properties.
|
|
|
136
136
|
|
|
137
137
|
***
|
|
138
138
|
|
|
139
|
-
### getPublic()
|
|
139
|
+
### getPublic() {#getpublic}
|
|
140
140
|
|
|
141
141
|
> **getPublic**(`identity`, `propertyNames?`): `Promise`\<`Partial`\<`T`\>\>
|
|
142
142
|
|
|
@@ -168,7 +168,7 @@ The items properties.
|
|
|
168
168
|
|
|
169
169
|
***
|
|
170
170
|
|
|
171
|
-
### update()
|
|
171
|
+
### update() {#update}
|
|
172
172
|
|
|
173
173
|
> **update**(`publicProfile?`, `privateProfile?`): `Promise`\<`void`\>
|
|
174
174
|
|
|
@@ -192,7 +192,7 @@ The private profile data as JSON-LD.
|
|
|
192
192
|
|
|
193
193
|
`Promise`\<`void`\>
|
|
194
194
|
|
|
195
|
-
|
|
195
|
+
A promise that resolves when the profile has been updated.
|
|
196
196
|
|
|
197
197
|
#### Implementation of
|
|
198
198
|
|
|
@@ -200,7 +200,7 @@ Nothing.
|
|
|
200
200
|
|
|
201
201
|
***
|
|
202
202
|
|
|
203
|
-
### remove()
|
|
203
|
+
### remove() {#remove}
|
|
204
204
|
|
|
205
205
|
> **remove**(): `Promise`\<`void`\>
|
|
206
206
|
|
|
@@ -210,7 +210,7 @@ Delete the profile for an identity.
|
|
|
210
210
|
|
|
211
211
|
`Promise`\<`void`\>
|
|
212
212
|
|
|
213
|
-
|
|
213
|
+
A promise that resolves when the profile has been removed.
|
|
214
214
|
|
|
215
215
|
#### Implementation of
|
|
216
216
|
|
|
@@ -218,7 +218,7 @@ Nothing.
|
|
|
218
218
|
|
|
219
219
|
***
|
|
220
220
|
|
|
221
|
-
### list()
|
|
221
|
+
### list() {#list}
|
|
222
222
|
|
|
223
223
|
> **list**(`publicFilters?`, `publicPropertyNames?`, `cursor?`, `limit?`): `Promise`\<\{ `items`: `object`[]; `cursor?`: `string`; \}\>
|
|
224
224
|
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Class: IdentityResolverRestClient
|
|
2
2
|
|
|
3
|
-
Client for performing identity through
|
|
3
|
+
Client for performing identity resolution through REST endpoints.
|
|
4
4
|
|
|
5
5
|
## Extends
|
|
6
6
|
|
|
@@ -36,7 +36,7 @@ The configuration for the client.
|
|
|
36
36
|
|
|
37
37
|
## Properties
|
|
38
38
|
|
|
39
|
-
### CLASS\_NAME
|
|
39
|
+
### CLASS\_NAME {#class_name}
|
|
40
40
|
|
|
41
41
|
> `readonly` `static` **CLASS\_NAME**: `string`
|
|
42
42
|
|
|
@@ -44,7 +44,7 @@ Runtime name for the class.
|
|
|
44
44
|
|
|
45
45
|
## Methods
|
|
46
46
|
|
|
47
|
-
### className()
|
|
47
|
+
### className() {#classname}
|
|
48
48
|
|
|
49
49
|
> **className**(): `string`
|
|
50
50
|
|
|
@@ -62,7 +62,7 @@ The class name of the component.
|
|
|
62
62
|
|
|
63
63
|
***
|
|
64
64
|
|
|
65
|
-
### identityResolve()
|
|
65
|
+
### identityResolve() {#identityresolve}
|
|
66
66
|
|
|
67
67
|
> **identityResolve**(`documentId`): `Promise`\<`IDidDocument`\>
|
|
68
68
|
|