From f9b9c8dda1066ee82055bb3b98f57b847b979463 Mon Sep 17 00:00:00 2001 From: Stefan Adolf Date: Fri, 26 Feb 2021 15:12:28 +0100 Subject: [PATCH] feat: add type definition for JWK formatted public keys (#80) * feat: adds type support for JWK formatted keys * fix: remove private key related props * fix: add a generic JsonWebKey prop --- src/resolver.ts | 36 ++++++++++++++++++++++++++---------- 1 file changed, 26 insertions(+), 10 deletions(-) diff --git a/src/resolver.ts b/src/resolver.ts index f0a4695..c3af4b2 100644 --- a/src/resolver.ts +++ b/src/resolver.ts @@ -18,21 +18,21 @@ export interface DIDDocument { publicKey: PublicKey[] authentication?: (string | PublicKey | Authentication)[] /** - * @deprecated This does not appear in the did-core spec - */ + * @deprecated This does not appear in the did-core spec + */ uportProfile?: any service?: ServiceEndpoint[] /** - * @deprecated this property has been removed from the did-core spec - */ + * @deprecated this property has been removed from the did-core spec + */ created?: string /** - * @deprecated this property has been removed from the did-core spec - */ + * @deprecated this property has been removed from the did-core spec + */ updated?: string /** - * @deprecated this property has been removed from the did-core spec - */ + * @deprecated this property has been removed from the did-core spec + */ proof?: LinkedDataProof keyAgreement?: (string | PublicKey)[] } @@ -44,6 +44,21 @@ export interface ServiceEndpoint { description?: string } +interface JsonWebKey { + alg?: string + crv?: string + e?: string + ext?: boolean + key_ops?: string[] + kid?: string + kty: string + n?: string + use?: string + x?: string + y?: string + [x: string]: any +} + export interface PublicKey { id: string type: string @@ -53,11 +68,12 @@ export interface PublicKey { publicKeyBase58?: string publicKeyHex?: string publicKeyPem?: string + publicKeyJwk?: JsonWebKey } /** -* @deprecated The `authentication` array should be an array of strings or `PublicKey` -*/ + * @deprecated The `authentication` array should be an array of strings or `PublicKey` + */ export interface Authentication { type: string publicKey: string