@sphereon/ssi-sdk.contact-manager 0.11.1-next.65
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/LICENSE +201 -0
- package/README.md +200 -0
- package/dist/agent/ContactManager.d.ts +35 -0
- package/dist/agent/ContactManager.d.ts.map +1 -0
- package/dist/agent/ContactManager.js +96 -0
- package/dist/agent/ContactManager.js.map +1 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +26 -0
- package/dist/index.js.map +1 -0
- package/dist/types/IContactManager.d.ts +50 -0
- package/dist/types/IContactManager.d.ts.map +1 -0
- package/dist/types/IContactManager.js +3 -0
- package/dist/types/IContactManager.js.map +1 -0
- package/package.json +49 -0
- package/plugin.schema.json +661 -0
- package/src/agent/ContactManager.ts +92 -0
- package/src/index.ts +7 -0
- package/src/types/IContactManager.ts +61 -0
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
import { IAgentPlugin } from '@veramo/core'
|
|
2
|
+
import { schema } from '../index'
|
|
3
|
+
import {
|
|
4
|
+
IAddContactArgs,
|
|
5
|
+
IUpdateContactArgs,
|
|
6
|
+
IGetIdentitiesArgs,
|
|
7
|
+
IRemoveContactArgs,
|
|
8
|
+
IAddIdentityArgs,
|
|
9
|
+
IContactManager,
|
|
10
|
+
IGetIdentityArgs,
|
|
11
|
+
IRemoveIdentityArgs,
|
|
12
|
+
IRequiredContext,
|
|
13
|
+
IUpdateIdentityArgs,
|
|
14
|
+
IGetContactsArgs,
|
|
15
|
+
IGetContactArgs,
|
|
16
|
+
} from '../types/IContactManager'
|
|
17
|
+
import { IContact, IIdentity, AbstractContactStore } from '@sphereon/ssi-sdk.data-store'
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* {@inheritDoc IContactManager}
|
|
21
|
+
*/
|
|
22
|
+
export class ContactManager implements IAgentPlugin {
|
|
23
|
+
readonly schema = schema.IContactManager
|
|
24
|
+
readonly methods: IContactManager = {
|
|
25
|
+
cmGetContact: this.cmGetContact.bind(this),
|
|
26
|
+
cmGetContacts: this.cmGetContacts.bind(this),
|
|
27
|
+
cmAddContact: this.cmAddContact.bind(this),
|
|
28
|
+
cmUpdateContact: this.cmUpdateContact.bind(this),
|
|
29
|
+
cmRemoveContact: this.cmRemoveContact.bind(this),
|
|
30
|
+
cmGetIdentity: this.cmGetIdentity.bind(this),
|
|
31
|
+
cmGetIdentities: this.cmGetIdentities.bind(this),
|
|
32
|
+
cmAddIdentity: this.cmAddIdentity.bind(this),
|
|
33
|
+
cmUpdateIdentity: this.cmUpdateIdentity.bind(this),
|
|
34
|
+
cmRemoveIdentity: this.cmRemoveIdentity.bind(this),
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
private readonly store: AbstractContactStore
|
|
38
|
+
|
|
39
|
+
constructor(options: { store: AbstractContactStore }) {
|
|
40
|
+
this.store = options.store
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/** {@inheritDoc IContactManager.cmGetContact} */
|
|
44
|
+
private async cmGetContact(args: IGetContactArgs, context: IRequiredContext): Promise<IContact> {
|
|
45
|
+
return this.store.getContact(args)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** {@inheritDoc IContactManager.cmGetContacts} */
|
|
49
|
+
private async cmGetContacts(args?: IGetContactsArgs): Promise<Array<IContact>> {
|
|
50
|
+
return this.store.getContacts(args)
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** {@inheritDoc IContactManager.cmAddContact} */
|
|
54
|
+
private async cmAddContact(args: IAddContactArgs, context: IRequiredContext): Promise<IContact> {
|
|
55
|
+
return this.store.addContact(args)
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/** {@inheritDoc IContactManager.cmUpdateContact} */
|
|
59
|
+
private async cmUpdateContact(args: IUpdateContactArgs, context: IRequiredContext): Promise<IContact> {
|
|
60
|
+
return this.store.updateContact(args)
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
/** {@inheritDoc IContactManager.cmRemoveContact} */
|
|
64
|
+
private async cmRemoveContact(args: IRemoveContactArgs, context: IRequiredContext): Promise<boolean> {
|
|
65
|
+
return this.store.removeContact(args).then(() => true)
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
/** {@inheritDoc IContactManager.cmGetIdentity} */
|
|
69
|
+
private async cmGetIdentity(args: IGetIdentityArgs, context: IRequiredContext): Promise<IIdentity> {
|
|
70
|
+
return this.store.getIdentity(args)
|
|
71
|
+
}
|
|
72
|
+
|
|
73
|
+
/** {@inheritDoc IContactManager.cmGetIdentities} */
|
|
74
|
+
private async cmGetIdentities(args: IGetIdentitiesArgs, context: IRequiredContext): Promise<Array<IIdentity>> {
|
|
75
|
+
return this.store.getIdentities(args)
|
|
76
|
+
}
|
|
77
|
+
|
|
78
|
+
/** {@inheritDoc IContactManager.cmAddIdentity} */
|
|
79
|
+
private async cmAddIdentity(args: IAddIdentityArgs, context: IRequiredContext): Promise<IIdentity> {
|
|
80
|
+
return this.store.addIdentity(args)
|
|
81
|
+
}
|
|
82
|
+
|
|
83
|
+
/** {@inheritDoc IContactManager.cmUpdateIdentity} */
|
|
84
|
+
private async cmUpdateIdentity(args: IUpdateIdentityArgs, context: IRequiredContext): Promise<IIdentity> {
|
|
85
|
+
return this.store.updateIdentity(args)
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
/** {@inheritDoc IContactManager.cmRemoveIdentity} */
|
|
89
|
+
private async cmRemoveIdentity(args: IRemoveIdentityArgs, context: IRequiredContext): Promise<boolean> {
|
|
90
|
+
return this.store.removeIdentity(args).then(() => true) // TODO
|
|
91
|
+
}
|
|
92
|
+
}
|
package/src/index.ts
ADDED
|
@@ -0,0 +1,61 @@
|
|
|
1
|
+
import { IAgentContext, IPluginMethodMap } from '@veramo/core'
|
|
2
|
+
import { FindContactArgs, FindIdentityArgs, IBasicIdentity, IContact, IIdentity } from '@sphereon/ssi-sdk.data-store'
|
|
3
|
+
|
|
4
|
+
export interface IContactManager extends IPluginMethodMap {
|
|
5
|
+
cmGetContact(args: IGetContactArgs, context: IRequiredContext): Promise<IContact>
|
|
6
|
+
cmGetContacts(args?: IGetContactsArgs): Promise<Array<IContact>>
|
|
7
|
+
cmAddContact(args: IAddContactArgs, context: IRequiredContext): Promise<IContact>
|
|
8
|
+
cmUpdateContact(args: IUpdateContactArgs, context: IRequiredContext): Promise<IContact>
|
|
9
|
+
cmRemoveContact(args: IRemoveContactArgs, context: IRequiredContext): Promise<boolean>
|
|
10
|
+
cmGetIdentity(args: IGetIdentityArgs, context: IRequiredContext): Promise<IIdentity>
|
|
11
|
+
cmGetIdentities(args: IGetIdentitiesArgs, context: IRequiredContext): Promise<Array<IIdentity>>
|
|
12
|
+
cmAddIdentity(args: IAddIdentityArgs, context: IRequiredContext): Promise<IIdentity>
|
|
13
|
+
cmUpdateIdentity(args: IUpdateIdentityArgs, context: IRequiredContext): Promise<IIdentity>
|
|
14
|
+
cmRemoveIdentity(args: IRemoveIdentityArgs, context: IRequiredContext): Promise<boolean>
|
|
15
|
+
}
|
|
16
|
+
|
|
17
|
+
export interface IGetContactArgs {
|
|
18
|
+
contactId: string
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
export interface IGetContactsArgs {
|
|
22
|
+
filter?: FindContactArgs
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export interface IAddContactArgs {
|
|
26
|
+
name: string
|
|
27
|
+
alias: string
|
|
28
|
+
uri?: string
|
|
29
|
+
identities?: Array<IBasicIdentity>
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
export interface IUpdateContactArgs {
|
|
33
|
+
contact: IContact
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export interface IRemoveContactArgs {
|
|
37
|
+
contactId: string
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
export interface IGetIdentityArgs {
|
|
41
|
+
identityId: string
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface IGetIdentitiesArgs {
|
|
45
|
+
filter?: FindIdentityArgs
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
export interface IAddIdentityArgs {
|
|
49
|
+
contactId: string
|
|
50
|
+
identity: IBasicIdentity
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export interface IUpdateIdentityArgs {
|
|
54
|
+
identity: IIdentity
|
|
55
|
+
}
|
|
56
|
+
|
|
57
|
+
export interface IRemoveIdentityArgs {
|
|
58
|
+
identityId: string
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
export type IRequiredContext = IAgentContext<never>
|