Skip to content

Commit

Permalink
fix(remote-server): create an Ed25519 key for the default did:web
Browse files Browse the repository at this point in the history
  • Loading branch information
mirceanis committed Jul 14, 2021
1 parent 339201a commit a2f7f8c
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 3 deletions.
5 changes: 3 additions & 2 deletions packages/did-provider-web/src/web-did-provider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,11 @@ export class WebDIDProvider extends AbstractIdentifierProvider {
}

async createIdentifier(
{ kms, alias }: { kms?: string; alias?: string },
{ kms, alias, options }: { kms?: string; alias?: string; options: any },
context: IContext,
): Promise<Omit<IIdentifier, 'provider'>> {
const key = await context.agent.keyManagerCreate({ kms: kms || this.defaultKms, type: 'Secp256k1' })
const keyType = options?.keyType || 'Secp256k1'
const key = await context.agent.keyManagerCreate({ kms: kms || this.defaultKms, type: keyType })

const identifier: Omit<IIdentifier, 'provider'> = {
did: 'did:web:' + alias,
Expand Down
5 changes: 4 additions & 1 deletion packages/remote-server/src/default-did.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import parse from 'url-parse'

import { IDIDManager, TAgent } from '@veramo/core'
import { IDIDManager, TAgent, TKeyType } from '@veramo/core'

interface CreateDefaultDidOptions {
agent: TAgent<IDIDManager>
Expand All @@ -17,6 +17,9 @@ export async function createDefaultDid(options: CreateDefaultDidOptions) {
const serverIdentifier = await options?.agent?.didManagerGetOrCreate({
provider: 'did:web',
alias: hostname,
options: {
keyType: <TKeyType>'Ed25519',
},
})
console.log('🆔', serverIdentifier?.did)

Expand Down

0 comments on commit a2f7f8c

Please sign in to comment.