@sphereon/ssi-sdk.contact-manager 0.23.5-unstable.88 → 0.24.0
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 +200 -200
- package/package.json +4 -4
- package/src/agent/ContactManager.ts +306 -306
- package/src/index.ts +7 -7
- package/src/types/IContactManager.ts +187 -187
package/README.md
CHANGED
|
@@ -1,200 +1,200 @@
|
|
|
1
|
-
<!--suppress HtmlDeprecatedAttribute -->
|
|
2
|
-
<h1 align="center">
|
|
3
|
-
<br>
|
|
4
|
-
<a href="https://www.sphereon.com"><img src="https://sphereon.com/content/themes/sphereon/assets/img/logo.svg" alt="Sphereon" width="400"></a>
|
|
5
|
-
<br>Contact Manager (Typescript)
|
|
6
|
-
<br>
|
|
7
|
-
</h1>
|
|
8
|
-
|
|
9
|
-
---
|
|
10
|
-
|
|
11
|
-
**Warning: This package still is in very early development. Breaking changes without notice will happen at this point!**
|
|
12
|
-
|
|
13
|
-
---
|
|
14
|
-
|
|
15
|
-
A Veramo contact manager plugin. This plugin manages contacts and identity configurations to third parties and persists them. These configurations can then be used to establish a connection.
|
|
16
|
-
|
|
17
|
-
## Supported identity connection types
|
|
18
|
-
|
|
19
|
-
For now the following connection types are supported:
|
|
20
|
-
|
|
21
|
-
- OpenID Connect
|
|
22
|
-
- Self Issued OpenID v2
|
|
23
|
-
|
|
24
|
-
## Available functions
|
|
25
|
-
|
|
26
|
-
- cmGetContact
|
|
27
|
-
- cmGetContacts
|
|
28
|
-
- cmAddContact
|
|
29
|
-
- cmUpdateContact
|
|
30
|
-
- cmRemoveContact
|
|
31
|
-
- cmGetIdentity
|
|
32
|
-
- cmGetIdentities
|
|
33
|
-
- cmAddIdentity
|
|
34
|
-
- cmUpdateIdentity
|
|
35
|
-
- cmRemoveIdentity
|
|
36
|
-
|
|
37
|
-
## Usage
|
|
38
|
-
|
|
39
|
-
### Adding the plugin to an agent:
|
|
40
|
-
|
|
41
|
-
```typescript
|
|
42
|
-
import { migrations, Entities } from '@veramo/data-store'
|
|
43
|
-
import { ContactManager } from '@sphereon/ssi-sdk.contact-manager'
|
|
44
|
-
import { ContactStore, DataStoreMigrations, DataStoreContactEntities } from '@sphereon/ssi-sdk.data-store'
|
|
45
|
-
|
|
46
|
-
const dbConnection = createConnection({
|
|
47
|
-
type: 'react-native',
|
|
48
|
-
database: 'app.sqlite',
|
|
49
|
-
location: 'default',
|
|
50
|
-
logging: false,
|
|
51
|
-
synchronize: false,
|
|
52
|
-
migrationsRun: true,
|
|
53
|
-
migrations: [...DataStoreMigrations, ...migrations],
|
|
54
|
-
entities: [...DataStoreContactEntities, ...Entities],
|
|
55
|
-
})
|
|
56
|
-
|
|
57
|
-
const agent = createAgent<IContactManager>({
|
|
58
|
-
plugins: [
|
|
59
|
-
new ContactManager({
|
|
60
|
-
store: new ContactStore(dbConnection),
|
|
61
|
-
}),
|
|
62
|
-
],
|
|
63
|
-
})
|
|
64
|
-
```
|
|
65
|
-
|
|
66
|
-
### Get a contact:
|
|
67
|
-
|
|
68
|
-
```typescript
|
|
69
|
-
const contactId = '8efb937f-4e90-4056-9a4d-7185ce8dc173'
|
|
70
|
-
const result = await agent.cmGetContact({
|
|
71
|
-
contactId,
|
|
72
|
-
})
|
|
73
|
-
```
|
|
74
|
-
|
|
75
|
-
### Get contacts:
|
|
76
|
-
|
|
77
|
-
```typescript
|
|
78
|
-
const result = await agent.cmGetContacts()
|
|
79
|
-
```
|
|
80
|
-
|
|
81
|
-
### Add a contact:
|
|
82
|
-
|
|
83
|
-
```typescript
|
|
84
|
-
const result = await agent.cmAddContact({ name: 'contact_name', alias: 'contact_alias' })
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Update a contact:
|
|
88
|
-
|
|
89
|
-
```typescript
|
|
90
|
-
const contactId = '8efb937f-4e90-4056-9a4d-7185ce8dc173'
|
|
91
|
-
const contact = await agent
|
|
92
|
-
.cmGetContact({
|
|
93
|
-
contact,
|
|
94
|
-
})
|
|
95
|
-
.then((contact) => {
|
|
96
|
-
return { ...contact, name: 'new_name' }
|
|
97
|
-
})
|
|
98
|
-
|
|
99
|
-
const result = await agent.cmUpdateContact({ contact })
|
|
100
|
-
```
|
|
101
|
-
|
|
102
|
-
### Remove a contact:
|
|
103
|
-
|
|
104
|
-
```typescript
|
|
105
|
-
const contactId = 'ef6e13b2-a520-4bb6-9a13-9be529ce22b8'
|
|
106
|
-
const result = await agent.cmRemoveContact({ contactId })
|
|
107
|
-
```
|
|
108
|
-
|
|
109
|
-
### Get an identity:
|
|
110
|
-
|
|
111
|
-
```typescript
|
|
112
|
-
const identityId = 'cdfd231c-6d40-4e43-9bd0-e8c97262ffe1'
|
|
113
|
-
const result = await agent.cmGetIdentity({
|
|
114
|
-
identityId,
|
|
115
|
-
})
|
|
116
|
-
```
|
|
117
|
-
|
|
118
|
-
### Get identities:
|
|
119
|
-
|
|
120
|
-
```typescript
|
|
121
|
-
const contactId = '00492d95-22b9-41c1-b475-90bf1667ae52'
|
|
122
|
-
const result = await agent.cmGetIdentities({ contactId })
|
|
123
|
-
```
|
|
124
|
-
|
|
125
|
-
### Add an identity:
|
|
126
|
-
|
|
127
|
-
```typescript
|
|
128
|
-
const contactId = 'a4a47842-43a7-4741-9562-0fb3a973ec98'
|
|
129
|
-
const identity = {
|
|
130
|
-
alias: correlationId,
|
|
131
|
-
identifier: {
|
|
132
|
-
type: CorrelationIdentifierType.URL,
|
|
133
|
-
correlationId,
|
|
134
|
-
},
|
|
135
|
-
connection: {
|
|
136
|
-
type: ConnectionType.DIDAUTH,
|
|
137
|
-
config: {
|
|
138
|
-
identifier: {
|
|
139
|
-
did: 'did:test:138d7bf8-c930-4c6e-b928-97d3a4928b01',
|
|
140
|
-
provider: 'test_provider',
|
|
141
|
-
keys: [],
|
|
142
|
-
services: [],
|
|
143
|
-
},
|
|
144
|
-
redirectUrl: 'https://example.com',
|
|
145
|
-
stateId: 'e91f3510-5ce9-42ee-83b7-fa68ff323d27',
|
|
146
|
-
sessionId: 'https://example.com/did:test:138d7bf8-c930-4c6e-b928-97d3a4928b01',
|
|
147
|
-
},
|
|
148
|
-
},
|
|
149
|
-
metadata: [
|
|
150
|
-
{
|
|
151
|
-
label: 'Authorization URL',
|
|
152
|
-
value: 'https://example.com',
|
|
153
|
-
},
|
|
154
|
-
{
|
|
155
|
-
label: 'Scope',
|
|
156
|
-
value: 'Authorization',
|
|
157
|
-
},
|
|
158
|
-
],
|
|
159
|
-
}
|
|
160
|
-
|
|
161
|
-
const result = await agent.cmAddIdentity({
|
|
162
|
-
contactId,
|
|
163
|
-
identity,
|
|
164
|
-
})
|
|
165
|
-
```
|
|
166
|
-
|
|
167
|
-
### Update an identity:
|
|
168
|
-
|
|
169
|
-
```typescript
|
|
170
|
-
const identityId = 'cdfd231c-6d40-4e43-9bd0-e8c97262ffe1'
|
|
171
|
-
const identity = await agent
|
|
172
|
-
.cmGetIdentity({
|
|
173
|
-
identityId,
|
|
174
|
-
})
|
|
175
|
-
.then((identity) => {
|
|
176
|
-
return { ...identity, alias: 'new_alias' }
|
|
177
|
-
})
|
|
178
|
-
const result = await agent.cmUpdateIdentity({ identity })
|
|
179
|
-
```
|
|
180
|
-
|
|
181
|
-
### Remove an identity:
|
|
182
|
-
|
|
183
|
-
```typescript
|
|
184
|
-
const identityId = 'cdfd231c-6d40-4e43-9bd0-e8c97262ffe1'
|
|
185
|
-
await agent.cmRemoveIdentity({
|
|
186
|
-
identityId,
|
|
187
|
-
})
|
|
188
|
-
```
|
|
189
|
-
|
|
190
|
-
## Installation
|
|
191
|
-
|
|
192
|
-
```shell
|
|
193
|
-
yarn add @sphereon/ssi-sdk.contact-manager
|
|
194
|
-
```
|
|
195
|
-
|
|
196
|
-
## Build
|
|
197
|
-
|
|
198
|
-
```shell
|
|
199
|
-
yarn build
|
|
200
|
-
```
|
|
1
|
+
<!--suppress HtmlDeprecatedAttribute -->
|
|
2
|
+
<h1 align="center">
|
|
3
|
+
<br>
|
|
4
|
+
<a href="https://www.sphereon.com"><img src="https://sphereon.com/content/themes/sphereon/assets/img/logo.svg" alt="Sphereon" width="400"></a>
|
|
5
|
+
<br>Contact Manager (Typescript)
|
|
6
|
+
<br>
|
|
7
|
+
</h1>
|
|
8
|
+
|
|
9
|
+
---
|
|
10
|
+
|
|
11
|
+
**Warning: This package still is in very early development. Breaking changes without notice will happen at this point!**
|
|
12
|
+
|
|
13
|
+
---
|
|
14
|
+
|
|
15
|
+
A Veramo contact manager plugin. This plugin manages contacts and identity configurations to third parties and persists them. These configurations can then be used to establish a connection.
|
|
16
|
+
|
|
17
|
+
## Supported identity connection types
|
|
18
|
+
|
|
19
|
+
For now the following connection types are supported:
|
|
20
|
+
|
|
21
|
+
- OpenID Connect
|
|
22
|
+
- Self Issued OpenID v2
|
|
23
|
+
|
|
24
|
+
## Available functions
|
|
25
|
+
|
|
26
|
+
- cmGetContact
|
|
27
|
+
- cmGetContacts
|
|
28
|
+
- cmAddContact
|
|
29
|
+
- cmUpdateContact
|
|
30
|
+
- cmRemoveContact
|
|
31
|
+
- cmGetIdentity
|
|
32
|
+
- cmGetIdentities
|
|
33
|
+
- cmAddIdentity
|
|
34
|
+
- cmUpdateIdentity
|
|
35
|
+
- cmRemoveIdentity
|
|
36
|
+
|
|
37
|
+
## Usage
|
|
38
|
+
|
|
39
|
+
### Adding the plugin to an agent:
|
|
40
|
+
|
|
41
|
+
```typescript
|
|
42
|
+
import { migrations, Entities } from '@veramo/data-store'
|
|
43
|
+
import { ContactManager } from '@sphereon/ssi-sdk.contact-manager'
|
|
44
|
+
import { ContactStore, DataStoreMigrations, DataStoreContactEntities } from '@sphereon/ssi-sdk.data-store'
|
|
45
|
+
|
|
46
|
+
const dbConnection = createConnection({
|
|
47
|
+
type: 'react-native',
|
|
48
|
+
database: 'app.sqlite',
|
|
49
|
+
location: 'default',
|
|
50
|
+
logging: false,
|
|
51
|
+
synchronize: false,
|
|
52
|
+
migrationsRun: true,
|
|
53
|
+
migrations: [...DataStoreMigrations, ...migrations],
|
|
54
|
+
entities: [...DataStoreContactEntities, ...Entities],
|
|
55
|
+
})
|
|
56
|
+
|
|
57
|
+
const agent = createAgent<IContactManager>({
|
|
58
|
+
plugins: [
|
|
59
|
+
new ContactManager({
|
|
60
|
+
store: new ContactStore(dbConnection),
|
|
61
|
+
}),
|
|
62
|
+
],
|
|
63
|
+
})
|
|
64
|
+
```
|
|
65
|
+
|
|
66
|
+
### Get a contact:
|
|
67
|
+
|
|
68
|
+
```typescript
|
|
69
|
+
const contactId = '8efb937f-4e90-4056-9a4d-7185ce8dc173'
|
|
70
|
+
const result = await agent.cmGetContact({
|
|
71
|
+
contactId,
|
|
72
|
+
})
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
### Get contacts:
|
|
76
|
+
|
|
77
|
+
```typescript
|
|
78
|
+
const result = await agent.cmGetContacts()
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
### Add a contact:
|
|
82
|
+
|
|
83
|
+
```typescript
|
|
84
|
+
const result = await agent.cmAddContact({ name: 'contact_name', alias: 'contact_alias' })
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
### Update a contact:
|
|
88
|
+
|
|
89
|
+
```typescript
|
|
90
|
+
const contactId = '8efb937f-4e90-4056-9a4d-7185ce8dc173'
|
|
91
|
+
const contact = await agent
|
|
92
|
+
.cmGetContact({
|
|
93
|
+
contact,
|
|
94
|
+
})
|
|
95
|
+
.then((contact) => {
|
|
96
|
+
return { ...contact, name: 'new_name' }
|
|
97
|
+
})
|
|
98
|
+
|
|
99
|
+
const result = await agent.cmUpdateContact({ contact })
|
|
100
|
+
```
|
|
101
|
+
|
|
102
|
+
### Remove a contact:
|
|
103
|
+
|
|
104
|
+
```typescript
|
|
105
|
+
const contactId = 'ef6e13b2-a520-4bb6-9a13-9be529ce22b8'
|
|
106
|
+
const result = await agent.cmRemoveContact({ contactId })
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
### Get an identity:
|
|
110
|
+
|
|
111
|
+
```typescript
|
|
112
|
+
const identityId = 'cdfd231c-6d40-4e43-9bd0-e8c97262ffe1'
|
|
113
|
+
const result = await agent.cmGetIdentity({
|
|
114
|
+
identityId,
|
|
115
|
+
})
|
|
116
|
+
```
|
|
117
|
+
|
|
118
|
+
### Get identities:
|
|
119
|
+
|
|
120
|
+
```typescript
|
|
121
|
+
const contactId = '00492d95-22b9-41c1-b475-90bf1667ae52'
|
|
122
|
+
const result = await agent.cmGetIdentities({ contactId })
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Add an identity:
|
|
126
|
+
|
|
127
|
+
```typescript
|
|
128
|
+
const contactId = 'a4a47842-43a7-4741-9562-0fb3a973ec98'
|
|
129
|
+
const identity = {
|
|
130
|
+
alias: correlationId,
|
|
131
|
+
identifier: {
|
|
132
|
+
type: CorrelationIdentifierType.URL,
|
|
133
|
+
correlationId,
|
|
134
|
+
},
|
|
135
|
+
connection: {
|
|
136
|
+
type: ConnectionType.DIDAUTH,
|
|
137
|
+
config: {
|
|
138
|
+
identifier: {
|
|
139
|
+
did: 'did:test:138d7bf8-c930-4c6e-b928-97d3a4928b01',
|
|
140
|
+
provider: 'test_provider',
|
|
141
|
+
keys: [],
|
|
142
|
+
services: [],
|
|
143
|
+
},
|
|
144
|
+
redirectUrl: 'https://example.com',
|
|
145
|
+
stateId: 'e91f3510-5ce9-42ee-83b7-fa68ff323d27',
|
|
146
|
+
sessionId: 'https://example.com/did:test:138d7bf8-c930-4c6e-b928-97d3a4928b01',
|
|
147
|
+
},
|
|
148
|
+
},
|
|
149
|
+
metadata: [
|
|
150
|
+
{
|
|
151
|
+
label: 'Authorization URL',
|
|
152
|
+
value: 'https://example.com',
|
|
153
|
+
},
|
|
154
|
+
{
|
|
155
|
+
label: 'Scope',
|
|
156
|
+
value: 'Authorization',
|
|
157
|
+
},
|
|
158
|
+
],
|
|
159
|
+
}
|
|
160
|
+
|
|
161
|
+
const result = await agent.cmAddIdentity({
|
|
162
|
+
contactId,
|
|
163
|
+
identity,
|
|
164
|
+
})
|
|
165
|
+
```
|
|
166
|
+
|
|
167
|
+
### Update an identity:
|
|
168
|
+
|
|
169
|
+
```typescript
|
|
170
|
+
const identityId = 'cdfd231c-6d40-4e43-9bd0-e8c97262ffe1'
|
|
171
|
+
const identity = await agent
|
|
172
|
+
.cmGetIdentity({
|
|
173
|
+
identityId,
|
|
174
|
+
})
|
|
175
|
+
.then((identity) => {
|
|
176
|
+
return { ...identity, alias: 'new_alias' }
|
|
177
|
+
})
|
|
178
|
+
const result = await agent.cmUpdateIdentity({ identity })
|
|
179
|
+
```
|
|
180
|
+
|
|
181
|
+
### Remove an identity:
|
|
182
|
+
|
|
183
|
+
```typescript
|
|
184
|
+
const identityId = 'cdfd231c-6d40-4e43-9bd0-e8c97262ffe1'
|
|
185
|
+
await agent.cmRemoveIdentity({
|
|
186
|
+
identityId,
|
|
187
|
+
})
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
## Installation
|
|
191
|
+
|
|
192
|
+
```shell
|
|
193
|
+
yarn add @sphereon/ssi-sdk.contact-manager
|
|
194
|
+
```
|
|
195
|
+
|
|
196
|
+
## Build
|
|
197
|
+
|
|
198
|
+
```shell
|
|
199
|
+
yarn build
|
|
200
|
+
```
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sphereon/ssi-sdk.contact-manager",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.24.0",
|
|
4
4
|
"source": "src/index.ts",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -14,13 +14,13 @@
|
|
|
14
14
|
"build:clean": "tsc --build --clean && tsc --build"
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
|
-
"@sphereon/ssi-sdk.data-store": "0.
|
|
17
|
+
"@sphereon/ssi-sdk.data-store": "0.24.0",
|
|
18
18
|
"cross-fetch": "^3.1.8",
|
|
19
19
|
"debug": "^4.3.4",
|
|
20
20
|
"typeorm": "^0.3.20"
|
|
21
21
|
},
|
|
22
22
|
"devDependencies": {
|
|
23
|
-
"@sphereon/ssi-sdk.agent-config": "0.
|
|
23
|
+
"@sphereon/ssi-sdk.agent-config": "0.24.0",
|
|
24
24
|
"@veramo/remote-client": "4.2.0",
|
|
25
25
|
"@veramo/remote-server": "4.2.0"
|
|
26
26
|
},
|
|
@@ -45,5 +45,5 @@
|
|
|
45
45
|
"OpenID",
|
|
46
46
|
"Contact Manager"
|
|
47
47
|
],
|
|
48
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "fd8e1082588463c2bd5c8d81d711974971812ef7"
|
|
49
49
|
}
|