Skip to content

Commit

Permalink
feat: Adding some key manager methods
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat committed Sep 23, 2020
1 parent 61eab78 commit ec6645d
Show file tree
Hide file tree
Showing 3 changed files with 72 additions and 1 deletion.
6 changes: 5 additions & 1 deletion packages/daf-graphql/src/base-type-def.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,15 @@ export const baseTypeDef = `
type Query
type Mutation
scalar KeyMeta
type Key {
kid: String!
kms: String!
type: String!
publicKeyHex: String
publicKeyHex: String!
privateKeyHex: String
meta: KeyMeta
}
type Service {
Expand Down
2 changes: 2 additions & 0 deletions packages/daf-graphql/src/methods/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import messageHandler from './message-handler'
import w3c from './w3c'
import sdr from './sdr'
import dataStoreORM from './data-store-orm'
import keyManager from './key-manager'

export const supportedMethods: Record<string, IAgentGraphQLMethod> = {
...identityManager,
Expand All @@ -13,4 +14,5 @@ export const supportedMethods: Record<string, IAgentGraphQLMethod> = {
...w3c,
...sdr,
...dataStoreORM,
...keyManager,
}
65 changes: 65 additions & 0 deletions packages/daf-graphql/src/methods/key-manager.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,65 @@
import { IAgentGraphQLMethod } from '../types'

export const keyManagerGetKeyManagementSystems: IAgentGraphQLMethod = {
type: 'Query',
query: `
query keyManagerGetKeyManagementSystems {
keyManagerGetKeyManagementSystems
}
`,
typeDef: `
extend type Query {
keyManagerGetKeyManagementSystems: [String]
}
`,
}

export const keyManagerGetKey: IAgentGraphQLMethod = {
type: 'Query',
query: `
query keyManagerGetKey($kid: String) {
keyManagerGetKey(kid: $kid) {
kid
kms
type
publicKeyHex
privateKeyHex
meta
}
}
`,
typeDef: `
extend type Query {
keyManagerGetKey(kid: String): Key
}
`,
}

export const keyManagerCreateKey: IAgentGraphQLMethod = {
type: 'Mutation',
query: `
mutation keyManagerCreateKey($type: String, $kms: String, $meta: KeyMetaInput) {
keyManagerCreateKey(type: $type, kms: $kms, meta: $meta) {
kid
kms
type
publicKeyHex
meta
}
}
`,
typeDef: `
scalar KeyMetaInput
extend type Mutation {
keyManagerCreateKey(type: String, kms: String, meta: KeyMetaInput): Key!
}
`,
}

export const supportedMethods: Record<string, IAgentGraphQLMethod> = {
keyManagerGetKeyManagementSystems,
keyManagerCreateKey,
keyManagerGetKey,
}

export default supportedMethods

0 comments on commit ec6645d

Please sign in to comment.