Skip to content

Commit

Permalink
Removed universal DID Resolver
Browse files Browse the repository at this point in the history
  • Loading branch information
Kolezhniuk committed Jul 18, 2023
1 parent 74d80d3 commit 9fefe1a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 36 deletions.
5 changes: 0 additions & 5 deletions src/iden3comm/constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,11 +41,6 @@ export enum MediaType {
SignedMessage = 'application/iden3comm-signed-json'
}

/**
* Universal resolver url
*/
export const UNIVERSAL_RESOLVER_URL = 'https://dev.uniresolver.io/1.0/identifiers';

export const SUPPORTED_PUBLIC_KEY_TYPES = {
ES256K: [
'EcdsaSecp256k1VerificationKey2019',
Expand Down
13 changes: 3 additions & 10 deletions src/iden3comm/packers/jws.ts
Original file line number Diff line number Diff line change
@@ -1,10 +1,6 @@
import { BasicMessage, IPacker, PackerParams } from '../types';
import { MediaType, SUPPORTED_PUBLIC_KEY_TYPES } from '../constants';
import {
extractPublicKeyBytes,
resolveVerificationMethods,
resolveDIDDocument
} from '../utils/did';
import { extractPublicKeyBytes, resolveVerificationMethods } from '../utils/did';
import { keyPath, KMS } from '../../kms/';

import { Signer, verifyJWS } from 'did-jwt';
Expand All @@ -31,13 +27,10 @@ export class JWSPacker implements IPacker {
* Creates an instance of JWSPacker.
*
* @param {KMS} _kms
* @param {Resolvable} [_documentResolver={ resolve: resolveDIDDocument }]
* @param {Resolvable} _documentResolver
* @memberof JWSPacker
*/
constructor(
private readonly _kms: KMS,
private readonly _documentResolver: Resolvable = { resolve: resolveDIDDocument }
) {}
constructor(private readonly _kms: KMS, private readonly _documentResolver: Resolvable) {}
/**
* creates JSON Web Signature token
*
Expand Down
23 changes: 2 additions & 21 deletions src/iden3comm/utils/did.ts
Original file line number Diff line number Diff line change
@@ -1,29 +1,10 @@
import { SUPPORTED_PUBLIC_KEY_TYPES, UNIVERSAL_RESOLVER_URL } from '../constants';
import { SUPPORTED_PUBLIC_KEY_TYPES } from '../constants';
import elliptic from 'elliptic';
import {
DIDDocument,
DIDResolutionOptions,
DIDResolutionResult,
VerificationMethod
} from 'did-resolver';
import { DIDDocument, VerificationMethod } from 'did-resolver';

import { KmsKeyType } from '../../kms';
import { base58ToBytes, base64ToBytes, bytesToHex, hexToBytes } from '../../utils';

export const resolveDIDDocument = async (
didUrl: string,
// eslint-disable-next-line @typescript-eslint/no-unused-vars
options?: DIDResolutionOptions
): Promise<DIDResolutionResult> => {
try {
const response = await fetch(`${UNIVERSAL_RESOLVER_URL}/${didUrl}`);
const data = await response.json();
return data as DIDResolutionResult;
} catch (error: unknown) {
throw new Error(`Can't resolve did document: ${(error as Error).message}`);
}
};

const DIDAuthenticationSection = 'authentication';
export const resolveVerificationMethods = (didDocument: DIDDocument): VerificationMethod[] => {
const vms: VerificationMethod[] = didDocument.verificationMethod || [];
Expand Down

0 comments on commit 9fefe1a

Please sign in to comment.