Skip to content

Commit

Permalink
feat: GraphQL KeyManager
Browse files Browse the repository at this point in the history
  • Loading branch information
simonas-notcat committed Sep 24, 2020
1 parent 12a79e6 commit 2b092e9
Showing 1 changed file with 67 additions and 5 deletions.
72 changes: 67 additions & 5 deletions packages/daf-graphql/src/methods/key-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,15 +9,15 @@ export const keyManagerGetKeyManagementSystems: IAgentGraphQLMethod = {
`,
typeDef: `
extend type Query {
keyManagerGetKeyManagementSystems: [String]
keyManagerGetKeyManagementSystems: [String!]
}
`,
}

export const keyManagerGetKey: IAgentGraphQLMethod = {
type: 'Query',
query: `
query keyManagerGetKey($kid: String) {
query keyManagerGetKey($kid: String!) {
keyManagerGetKey(kid: $kid) {
kid
kms
Expand All @@ -30,15 +30,15 @@ export const keyManagerGetKey: IAgentGraphQLMethod = {
`,
typeDef: `
extend type Query {
keyManagerGetKey(kid: String): Key
keyManagerGetKey(kid: String!): Key
}
`,
}

export const keyManagerCreateKey: IAgentGraphQLMethod = {
type: 'Mutation',
query: `
mutation keyManagerCreateKey($type: String, $kms: String, $meta: KeyMetaInput) {
mutation keyManagerCreateKey($type: String!, $kms: String!, $meta: KeyMetaInput) {
keyManagerCreateKey(type: $type, kms: $kms, meta: $meta) {
kid
kms
Expand All @@ -51,7 +51,65 @@ export const keyManagerCreateKey: IAgentGraphQLMethod = {
typeDef: `
scalar KeyMetaInput
extend type Mutation {
keyManagerCreateKey(type: String, kms: String, meta: KeyMetaInput): Key!
keyManagerCreateKey(type: String!, kms: String!, meta: KeyMetaInput): Key!
}
`,
}

export const keyManagerDeleteKey: IAgentGraphQLMethod = {
type: 'Mutation',
query: `
mutation keyManagerDeleteKey($kid: String!) {
keyManagerDeleteKey(kid: $kid)
}
`,
typeDef: `
extend type Mutation {
keyManagerDeleteKey(kid: String!): Boolean!
}
`,
}

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

export const keyManagerSignJWT: IAgentGraphQLMethod = {
type: 'Mutation',
query: `
mutation keyManagerSignJWT($kid: String!, $data: String!) {
keyManagerSignJWT(kid: $kid, data: $data)
}
`,
typeDef: `
scalar JWTSignature
extend type Mutation {
keyManagerSignJWT(kid: String!, data: String!): JWTSignature!
}
`,
}

export const keyManagerSignEthTX: IAgentGraphQLMethod = {
type: 'Mutation',
query: `
mutation keyManagerSignEthTX($kid: String!, $transaction: TransactionInput!) {
keyManagerSignEthTX(kid: $kid, transaction: $transaction)
}
`,
typeDef: `
scalar TransactionInput
extend type Mutation {
keyManagerSignEthTX(kid: String!, transaction: TransactionInput!): String!
}
`,
}
Expand All @@ -60,6 +118,10 @@ export const supportedMethods: Record<string, IAgentGraphQLMethod> = {
keyManagerGetKeyManagementSystems,
keyManagerCreateKey,
keyManagerGetKey,
keyManagerDeleteKey,
keyManagerImportKey,
keyManagerSignJWT,
keyManagerSignEthTX,
}

export default supportedMethods

0 comments on commit 2b092e9

Please sign in to comment.