Warning: This package still is in very early development. Breaking changes without notice will happen at this point!
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.
For now the following connection types are supported:
- OpenID Connect
- Self Issued OpenID v2
- cmGetContact
- cmGetContacts
- cmAddContact
- cmUpdateContact
- cmRemoveContact
- cmGetIdentity
- cmGetIdentities
- cmAddIdentity
- cmUpdateIdentity
- cmRemoveIdentity
import { migrations, Entities } from '@veramo/data-store'
import { ContactManager } from '@sphereon/ssi-sdk.contact-manager'
import { ContactStore, DataStoreMigrations, DataStoreContactEntities } from '@sphereon/ssi-sdk.data-store'
const dbConnection = createConnection({
type: 'react-native',
database: 'app.sqlite',
location: 'default',
logging: false,
synchronize: false,
migrationsRun: true,
migrations: [...DataStoreMigrations, ...migrations],
entities: [...DataStoreContactEntities, ...Entities],
})
const agent = createAgent<IContactManager>({
plugins: [
new ContactManager({
store: new ContactStore(dbConnection),
}),
],
})
const contactId = '8efb937f-4e90-4056-9a4d-7185ce8dc173'
const result = await agent.cmGetContact({
contactId,
})
const result = await agent.cmGetContacts()
const result = await agent.cmAddContact({ name: 'contact_name', alias: 'contact_alias' })
const contactId = '8efb937f-4e90-4056-9a4d-7185ce8dc173'
const contact = await agent
.cmGetContact({
contact,
})
.then((contact) => {
return { ...contact, name: 'new_name' }
})
const result = await agent.cmUpdateContact({ contact })
const contactId = 'ef6e13b2-a520-4bb6-9a13-9be529ce22b8'
const result = await agent.cmRemoveContact({ contactId })
const identityId = 'cdfd231c-6d40-4e43-9bd0-e8c97262ffe1'
const result = await agent.cmGetIdentity({
identityId,
})
const contactId = '00492d95-22b9-41c1-b475-90bf1667ae52'
const result = await agent.cmGetIdentities({ contactId })
const contactId = 'a4a47842-43a7-4741-9562-0fb3a973ec98'
const identity = {
alias: correlationId,
identifier: {
type: CorrelationIdentifierType.URL,
correlationId,
},
connection: {
type: ConnectionType.DIDAUTH,
config: {
identifier: {
did: 'did:test:138d7bf8-c930-4c6e-b928-97d3a4928b01',
provider: 'test_provider',
keys: [],
services: [],
},
redirectUrl: 'https://example.com',
stateId: 'e91f3510-5ce9-42ee-83b7-fa68ff323d27',
sessionId: 'https://example.com/did:test:138d7bf8-c930-4c6e-b928-97d3a4928b01',
},
},
metadata: [
{
label: 'Authorization URL',
value: 'https://example.com',
},
{
label: 'Scope',
value: 'Authorization',
},
],
}
const result = await agent.cmAddIdentity({
contactId,
identity,
})
const identityId = 'cdfd231c-6d40-4e43-9bd0-e8c97262ffe1'
const identity = await agent
.cmGetIdentity({
identityId,
})
.then((identity) => {
return { ...identity, alias: 'new_alias' }
})
const result = await agent.cmUpdateIdentity({ identity })
const identityId = 'cdfd231c-6d40-4e43-9bd0-e8c97262ffe1'
await agent.cmRemoveIdentity({
identityId,
})
yarn add @sphereon/ssi-sdk.contact-manager
yarn build