From 3f437dd76cf5923a5b5080a914b26b7e7c749561 Mon Sep 17 00:00:00 2001 From: Frank Hinek Date: Mon, 5 Feb 2024 04:06:47 -0500 Subject: [PATCH] Rename `DidUri` to `Did` (#400) * Rename DidUri to Did --------- Signed-off-by: Frank Hinek --- packages/dids/src/{did-uri.ts => did.ts} | 58 +++++++++---------- packages/dids/src/index.ts | 2 +- packages/dids/src/methods/did-dht.ts | 6 +- packages/dids/src/methods/did-ion.ts | 6 +- packages/dids/src/methods/did-jwk.ts | 6 +- packages/dids/src/methods/did-key.ts | 8 +-- packages/dids/src/methods/did-method.ts | 4 +- packages/dids/src/methods/did-web.ts | 4 +- packages/dids/src/resolver/did-resolver.ts | 6 +- .../tests/{did-uri.spec.ts => did.spec.ts} | 58 +++++++++---------- 10 files changed, 79 insertions(+), 79 deletions(-) rename packages/dids/src/{did-uri.ts => did.ts} (70%) rename packages/dids/tests/{did-uri.spec.ts => did.spec.ts} (81%) diff --git a/packages/dids/src/did-uri.ts b/packages/dids/src/did.ts similarity index 70% rename from packages/dids/src/did-uri.ts rename to packages/dids/src/did.ts index 22687abeb..5e856f3b7 100644 --- a/packages/dids/src/did-uri.ts +++ b/packages/dids/src/did.ts @@ -1,5 +1,5 @@ /** - * The `DidUri` class represents a Decentralized Identifier (DID) Uniform Resource Identifier (URI). + * The `Did` class represents a Decentralized Identifier (DID) Uniform Resource Identifier (URI). * * This class provides a method for parsing a DID URI string into its component parts, as well as a * method for serializing a DID URI object into a string. @@ -15,15 +15,15 @@ * * @see {@link https://www.w3.org/TR/did-core/#did-syntax | DID Core Specification, ยง DID Syntax} */ -export class DidUri { +export class Did { /** Regular expression pattern for matching the method component of a DID URI. */ static readonly METHOD_PATTERN = '([a-z0-9]+)'; /** Regular expression pattern for matching percent-encoded characters in a method identifier. */ static readonly PCT_ENCODED_PATTERN = '(?:%[0-9a-fA-F]{2})'; /** Regular expression pattern for matching the characters allowed in a method identifier. */ - static readonly ID_CHAR_PATTERN = `(?:[a-zA-Z0-9._-]|${DidUri.PCT_ENCODED_PATTERN})`; + static readonly ID_CHAR_PATTERN = `(?:[a-zA-Z0-9._-]|${Did.PCT_ENCODED_PATTERN})`; /** Regular expression pattern for matching the method identifier component of a DID URI. */ - static readonly METHOD_ID_PATTERN = `((?:${DidUri.ID_CHAR_PATTERN}*:)*(${DidUri.ID_CHAR_PATTERN}+))`; + static readonly METHOD_ID_PATTERN = `((?:${Did.ID_CHAR_PATTERN}*:)*(${Did.ID_CHAR_PATTERN}+))`; /** Regular expression pattern for matching the path component of a DID URI. */ static readonly PATH_PATTERN = `(/[^#?]*)?`; /** Regular expression pattern for matching the query component of a DID URI. */ @@ -32,7 +32,7 @@ export class DidUri { static readonly FRAGMENT_PATTERN = `(#.*)?`; /** Regular expression pattern for matching all of the components of a DID URI. */ static readonly DID_URI_PATTERN = new RegExp( - `^did:(?${DidUri.METHOD_PATTERN}):(?${DidUri.METHOD_ID_PATTERN})(?${DidUri.PATH_PATTERN})(?${DidUri.QUERY_PATTERN})(?${DidUri.FRAGMENT_PATTERN})$` + `^did:(?${Did.METHOD_PATTERN}):(?${Did.METHOD_ID_PATTERN})(?${Did.PATH_PATTERN})(?${Did.QUERY_PATTERN})(?${Did.FRAGMENT_PATTERN})$` ); /** @@ -94,7 +94,7 @@ export class DidUri { params?: Record; /** - * Constructs a new `DidUri` instance. + * Constructs a new `Did` instance from individual components. * * @param params - An object containing the parameters to be included in the DID URI. * @param params.method - The name of the DID method. @@ -126,25 +126,25 @@ export class DidUri { * * @example * ```ts - * const didUri = DidUri.parse('did:example:123?service=agent&relativeRef=/credentials#degree'); + * const did = Did.parse('did:example:123?service=agent&relativeRef=/credentials#degree'); * - * console.log(didUri.uri) // Output: 'did:example:123' - * console.log(didUri.method) // Output: 'example' - * console.log(didUri.id) // Output: '123' - * console.log(didUri.query) // Output: 'service=agent&relativeRef=/credentials' - * console.log(didUri.fragment) // Output: 'degree' - * console.log(didUri.params) // Output: { service: 'agent', relativeRef: '/credentials' } + * console.log(did.uri) // Output: 'did:example:123' + * console.log(did.method) // Output: 'example' + * console.log(did.id) // Output: '123' + * console.log(did.query) // Output: 'service=agent&relativeRef=/credentials' + * console.log(did.fragment) // Output: 'degree' + * console.log(did.params) // Output: { service: 'agent', relativeRef: '/credentials' } * ``` * - * @params didUriString - The DID URI string to be parsed. - * @returns A `DidUri` object representing the parsed DID URI, or `null` if the input string is not a valid DID URI. + * @params didUri - The DID URI string to be parsed. + * @returns A `Did` object representing the parsed DID URI, or `null` if the input string is not a valid DID URI. */ - static parse(didUriString: string): DidUri | null { + static parse(didUri: string): Did | null { // Return null if the input string is empty or not provided. - if (!didUriString) return null; + if (!didUri) return null; // Execute the regex pattern on the input string to extract URI components. - const match = DidUri.DID_URI_PATTERN.exec(didUriString); + const match = Did.DID_URI_PATTERN.exec(didUri); // If the pattern does not match, or if the required groups are not found, return null. if (!match || !match.groups) return null; @@ -152,23 +152,23 @@ export class DidUri { // Extract the method, id, params, path, query, and fragment from the regex match groups. const { method, id, path, query, fragment } = match.groups; - // Initialize a new DidUri object with the uri, method and id. - const didUri: DidUri = { + // Initialize a new Did object with the uri, method and id. + const did: Did = { uri: `did:${method}:${id}`, method, id, }; - // If path is present, add it to the DidUri object. - if (path) didUri.path = path; + // If path is present, add it to the Did object. + if (path) did.path = path; - // If query is present, add it to the DidUri object, removing the leading '?'. - if (query) didUri.query = query.slice(1); + // If query is present, add it to the Did object, removing the leading '?'. + if (query) did.query = query.slice(1); - // If fragment is present, add it to the DidUri object, removing the leading '#'. - if (fragment) didUri.fragment = fragment.slice(1); + // If fragment is present, add it to the Did object, removing the leading '#'. + if (fragment) did.fragment = fragment.slice(1); - // If query params are present, parse them into a key-value object and add to the DidUri object. + // If query params are present, parse them into a key-value object and add to the Did object. if (query) { const parsedParams = {} as Record; // Split the query string by '&' to get individual parameter strings. @@ -178,9 +178,9 @@ export class DidUri { const [key, value] = pair.split('='); parsedParams[key] = value; } - didUri.params = parsedParams; + did.params = parsedParams; } - return didUri; + return did; } } \ No newline at end of file diff --git a/packages/dids/src/index.ts b/packages/dids/src/index.ts index 6be03159d..83333c9d9 100644 --- a/packages/dids/src/index.ts +++ b/packages/dids/src/index.ts @@ -1,5 +1,5 @@ +export * from './did.js'; export * from './did-error.js'; -export * from './did-uri.js'; export * from './methods/did-dht.js'; export * from './methods/did-ion.js'; diff --git a/packages/dids/src/methods/did-dht.ts b/packages/dids/src/methods/did-dht.ts index ad9c724aa..aaa17335a 100644 --- a/packages/dids/src/methods/did-dht.ts +++ b/packages/dids/src/methods/did-dht.ts @@ -23,7 +23,7 @@ import type { DidVerificationMethod, } from '../types/did-core.js'; -import { DidUri } from '../did-uri.js'; +import { Did } from '../did.js'; import { DidMethod } from './did-method.js'; import { DidError, DidErrorCode } from '../did-error.js'; import { DidVerificationRelationship } from '../types/did-core.js'; @@ -628,7 +628,7 @@ export class DidDht extends DidMethod { methodId?: string; }): Promise { - const parsedDid = DidUri.parse(didDocument.id); + const parsedDid = Did.parse(didDocument.id); if (parsedDid && parsedDid.method !== this.methodName) { throw new Error(`Method not supported: ${parsedDid.method}`); } @@ -1417,7 +1417,7 @@ class DidDhtUtils { didUri: string }): Uint8Array { // Parse the DID URI. - const parsedDid = DidUri.parse(didUri); + const parsedDid = Did.parse(didUri); // Verify that the DID URI is valid. if (!parsedDid) { diff --git a/packages/dids/src/methods/did-ion.ts b/packages/dids/src/methods/did-ion.ts index 93ab82e99..1e26ba1c9 100644 --- a/packages/dids/src/methods/did-ion.ts +++ b/packages/dids/src/methods/did-ion.ts @@ -25,7 +25,7 @@ import type { PortableDidVerificationMethod, } from '../methods/did-method.js'; -import { DidUri } from '../did-uri.js'; +import { Did } from '../did.js'; import { DidMethod } from '../methods/did-method.js'; import { DidError, DidErrorCode } from '../did-error.js'; import { EMPTY_DID_RESOLUTION_RESULT } from '../resolver/did-resolver.js'; @@ -340,7 +340,7 @@ export class DidIon extends DidMethod { methodId?: string; }): Promise { // Verify the DID method is supported. - const parsedDid = DidUri.parse(didDocument.id); + const parsedDid = Did.parse(didDocument.id); if (parsedDid && parsedDid.method !== this.methodName) { throw new DidError(DidErrorCode.MethodNotSupported, `Method not supported: ${parsedDid.method}`); } @@ -449,7 +449,7 @@ export class DidIon extends DidMethod { */ public static async resolve(didUri: string, options: DidResolutionOptions = {}): Promise { // Attempt to parse the DID URI. - const parsedDid = DidUri.parse(didUri); + const parsedDid = Did.parse(didUri); // If parsing failed, the DID is invalid. if (!parsedDid) { diff --git a/packages/dids/src/methods/did-jwk.ts b/packages/dids/src/methods/did-jwk.ts index 9652bee73..70d9e0a6c 100644 --- a/packages/dids/src/methods/did-jwk.ts +++ b/packages/dids/src/methods/did-jwk.ts @@ -14,7 +14,7 @@ import { LocalKeyManager } from '@web5/crypto'; import type { BearerDid, DidCreateOptions, DidCreateVerificationMethod, DidMetadata, PortableDid } from './did-method.js'; import type { DidDocument, DidResolutionOptions, DidResolutionResult, DidVerificationMethod } from '../types/did-core.js'; -import { DidUri } from '../did-uri.js'; +import { Did } from '../did.js'; import { DidMethod } from './did-method.js'; import { DidError, DidErrorCode } from '../did-error.js'; import { EMPTY_DID_RESOLUTION_RESULT } from '../resolver/did-resolver.js'; @@ -275,7 +275,7 @@ export class DidJwk extends DidMethod { methodId?: string; }): Promise { // Verify the DID method is supported. - const parsedDid = DidUri.parse(didDocument.id); + const parsedDid = Did.parse(didDocument.id); if (parsedDid && parsedDid.method !== this.methodName) { throw new DidError(DidErrorCode.MethodNotSupported, `Method not supported: ${parsedDid.method}`); } @@ -295,7 +295,7 @@ export class DidJwk extends DidMethod { */ public static async resolve(didUri: string, _options?: DidResolutionOptions): Promise { // Attempt to parse the DID URI. - const parsedDid = DidUri.parse(didUri); + const parsedDid = Did.parse(didUri); // Attempt to decode the Base64URL-encoded JWK. let publicKey: Jwk | undefined; diff --git a/packages/dids/src/methods/did-key.ts b/packages/dids/src/methods/did-key.ts index f986bfe62..5180bddbf 100644 --- a/packages/dids/src/methods/did-key.ts +++ b/packages/dids/src/methods/did-key.ts @@ -23,7 +23,7 @@ import { import type { BearerDid, DidCreateOptions, DidCreateVerificationMethod, DidMetadata, PortableDid } from './did-method.js'; import type { DidDocument, DidResolutionOptions, DidResolutionResult, DidVerificationMethod } from '../types/did-core.js'; -import { DidUri } from '../did-uri.js'; +import { Did } from '../did.js'; import { DidMethod } from './did-method.js'; import { DidError, DidErrorCode } from '../did-error.js'; import { getVerificationMethodTypes } from '../utils.js'; @@ -446,7 +446,7 @@ export class DidKey extends DidMethod { methodId?: string; }): Promise { // Verify the DID method is supported. - const parsedDid = DidUri.parse(didDocument.id); + const parsedDid = Did.parse(didDocument.id); if (parsedDid && parsedDid.method !== this.methodName) { throw new DidError(DidErrorCode.MethodNotSupported, `Method not supported: ${parsedDid.method}`); } @@ -523,7 +523,7 @@ export class DidKey extends DidMethod { * If there are only three components set the version to the string * value 1 and use the last value as the multibaseValue. */ - const parsedDid = DidUri.parse(didUri); + const parsedDid = Did.parse(didUri); if (!parsedDid) { throw new DidError(DidErrorCode.InvalidDid, `Invalid DID URI: ${didUri}`); } @@ -1005,7 +1005,7 @@ export class DidKey extends DidMethod { * @returns `true` if the DID URI meets the `did:key` method's structural requirements, `false` otherwise. * */ - private static validateIdentifier(parsedDid: DidUri): boolean { + private static validateIdentifier(parsedDid: Did): boolean { const { method, id: multibaseValue } = parsedDid; const [ scheme ] = parsedDid.uri.split(':', 1); diff --git a/packages/dids/src/methods/did-method.ts b/packages/dids/src/methods/did-method.ts index 54751b548..08a884626 100644 --- a/packages/dids/src/methods/did-method.ts +++ b/packages/dids/src/methods/did-method.ts @@ -53,7 +53,7 @@ export interface BearerDid { /** {@inheritDoc DidMetadata} */ metadata: DidMetadata; - /** {@inheritDoc DidUri#uri} */ + /** {@inheritDoc Did#uri} */ uri: string; } @@ -216,7 +216,7 @@ export interface DidMethodResolver { * ``` */ export interface PortableDid { - /** {@inheritDoc DidUri#uri} */ + /** {@inheritDoc Did#uri} */ uri?: string; /** diff --git a/packages/dids/src/methods/did-web.ts b/packages/dids/src/methods/did-web.ts index 4a2b2c2a6..385837f4a 100644 --- a/packages/dids/src/methods/did-web.ts +++ b/packages/dids/src/methods/did-web.ts @@ -1,6 +1,6 @@ import type { DidDocument, DidResolutionOptions, DidResolutionResult } from '../types/did-core.js'; -import { DidUri } from '../did-uri.js'; +import { Did } from '../did.js'; import { DidMethod } from './did-method.js'; import { EMPTY_DID_RESOLUTION_RESULT } from '../resolver/did-resolver.js'; @@ -40,7 +40,7 @@ export class DidWeb extends DidMethod { */ public static async resolve(didUri: string, _options?: DidResolutionOptions): Promise { // Attempt to parse the DID URI. - const parsedDid = DidUri.parse(didUri); + const parsedDid = Did.parse(didUri); // If parsing failed, the DID is invalid. if (!parsedDid) { diff --git a/packages/dids/src/resolver/did-resolver.ts b/packages/dids/src/resolver/did-resolver.ts index 6a3168479..1c59cf182 100644 --- a/packages/dids/src/resolver/did-resolver.ts +++ b/packages/dids/src/resolver/did-resolver.ts @@ -3,7 +3,7 @@ import type { KeyValueStore } from '@web5/common'; import type { DidMethodResolver } from '../methods/did-method.js'; import type { DidDereferencingOptions, DidDereferencingResult, DidResolutionOptions, DidResolutionResult, DidResource } from '../types/did-core.js'; -import { DidUri } from '../did-uri.js'; +import { Did } from '../did.js'; import { DidErrorCode } from '../did-error.js'; import { DidResolverCacheNoop } from './resolver-cache-noop.js'; @@ -115,7 +115,7 @@ export class DidResolver { */ public async resolve(didUri: string, options?: DidResolutionOptions): Promise { - const parsedDid = DidUri.parse(didUri); + const parsedDid = Did.parse(didUri); if (!parsedDid) { return { ...EMPTY_DID_RESOLUTION_RESULT, @@ -181,7 +181,7 @@ export class DidResolver { ): Promise { // Validate the given `didUrl` confirms to the DID URL syntax. - const parsedDidUrl = DidUri.parse(didUrl); + const parsedDidUrl = Did.parse(didUrl); if (!parsedDidUrl) { return { diff --git a/packages/dids/tests/did-uri.spec.ts b/packages/dids/tests/did.spec.ts similarity index 81% rename from packages/dids/tests/did-uri.spec.ts rename to packages/dids/tests/did.spec.ts index 8f9cf0772..3e32b3ce7 100644 --- a/packages/dids/tests/did-uri.spec.ts +++ b/packages/dids/tests/did.spec.ts @@ -1,8 +1,8 @@ import { expect } from 'chai'; -import { DidUri } from '../src/did-uri.js'; +import { Did } from '../src/did.js'; -describe('DidUri', () => { +describe('Did', () => { it('constructor', () => { const didUriComponents = { method : 'example', @@ -13,14 +13,14 @@ describe('DidUri', () => { params : { versionId: '1' }, }; - const didUri = new DidUri(didUriComponents); + const didUri = new Did(didUriComponents); expect(didUri).to.deep.equal({ ...didUriComponents, uri: 'did:example:123' }); }); describe('parse()', () => { it('parses a basic DID URI', () => { - const didUri = DidUri.parse('did:example:123'); + const didUri = Did.parse('did:example:123'); expect(didUri).to.deep.equal({ uri : 'did:example:123', @@ -30,28 +30,28 @@ describe('DidUri', () => { }); it('parses a DID URI with unusual identifier characters', () => { - let didUri = DidUri.parse('did:123:test::test2'); + let didUri = Did.parse('did:123:test::test2'); expect(didUri).to.deep.equal({ method : '123', id : 'test::test2', uri : 'did:123:test::test2', }); - didUri = DidUri.parse('did:method:%12%AF'); + didUri = Did.parse('did:method:%12%AF'); expect(didUri).to.deep.equal({ method : 'method', id : '%12%AF', uri : 'did:method:%12%AF', }); - didUri = DidUri.parse('did:web:example.com%3A8443'); + didUri = Did.parse('did:web:example.com%3A8443'); expect(didUri).to.deep.equal({ uri : 'did:web:example.com%3A8443', method : 'web', id : 'example.com%3A8443', }); - didUri = DidUri.parse('did:web:example.com:path:some%2Bsubpath'); + didUri = Did.parse('did:web:example.com:path:some%2Bsubpath'); expect(didUri).to.deep.equal({ uri : 'did:web:example.com:path:some%2Bsubpath', method : 'web', @@ -60,7 +60,7 @@ describe('DidUri', () => { }); it('parses a DID URI with a path', () => { - const didUri = DidUri.parse('did:example:123/path'); + const didUri = Did.parse('did:example:123/path'); expect(didUri).to.deep.equal({ uri : 'did:example:123', @@ -71,7 +71,7 @@ describe('DidUri', () => { }); it('parses a DID URI with a query', () => { - const didUri = DidUri.parse('did:example:123?versionId=1'); + const didUri = Did.parse('did:example:123?versionId=1'); expect(didUri).to.deep.equal({ uri : 'did:example:123', @@ -83,7 +83,7 @@ describe('DidUri', () => { }); it('parses a DID URI with a fragment', () => { - const didUri = DidUri.parse('did:example:123#key-1'); + const didUri = Did.parse('did:example:123#key-1'); expect(didUri).to.deep.equal({ uri : 'did:example:123', @@ -94,7 +94,7 @@ describe('DidUri', () => { }); it('parses a DID URI with an identifier containing an underscore', () => { - const didUri = DidUri.parse('did:example:abcdefg_123456790'); + const didUri = Did.parse('did:example:abcdefg_123456790'); expect(didUri).to.deep.equal({ uri : 'did:example:abcdefg_123456790', @@ -104,7 +104,7 @@ describe('DidUri', () => { }); it('parses a complex DID URI with all components', () => { - const didUri = DidUri.parse('did:example:123/some/path?versionId=1#key1'); + const didUri = Did.parse('did:example:123/some/path?versionId=1#key1'); expect(didUri).to.deep.equal({ uri : 'did:example:123', @@ -119,7 +119,7 @@ describe('DidUri', () => { it('parses DID URIs with various combinations of components', () => { expect( - DidUri.parse('did:uport:123/some/path#fragment=123') + Did.parse('did:uport:123/some/path#fragment=123') ).to.deep.equal({ uri : 'did:uport:123', method : 'uport', @@ -129,7 +129,7 @@ describe('DidUri', () => { }); expect( - DidUri.parse('did:example:123?service=agent&relativeRef=/credentials#degree') + Did.parse('did:example:123?service=agent&relativeRef=/credentials#degree') ).to.deep.equal({ uri : 'did:example:123', method : 'example', @@ -143,7 +143,7 @@ describe('DidUri', () => { }); expect( - DidUri.parse('did:example:test:123/some/path?versionId=1#key1') + Did.parse('did:example:test:123/some/path?versionId=1#key1') ).to.deep.equal({ uri : 'did:example:test:123', method : 'example', @@ -156,7 +156,7 @@ describe('DidUri', () => { }); it('extracts ION DID long form identifier from a DID URI', async () => { - const { uri } = DidUri.parse( + const { uri } = Did.parse( 'did:ion:EiAi68p2irCNQIzaui8gTjGDeOqSUusZS8jWVHfseSWZ5g:eyJkZWx0YSI6eyJwYXRjaGVzIjpbeyJhY3Rpb24iOiJyZXBsYWNlIiwiZG9jdW1lbnQiOnsicHVibGljS2V5cyI6W3siaWQiOiJrZXktMSIsInB1YmxpY0tleUp3ayI6eyJjcnYiOiJzZWNwMjU2azEiLCJrdHkiOiJFQyIsIngiOiI2MWlQWXVHZWZ4b3R6QmRRWnREdnY2Y1dIWm1YclRUc2NZLXU3WTJwRlpjIiwieSI6Ijg4blBDVkxmckFZOWktd2c1T1Jjd1ZiSFdDX3RiZUFkMUpFMmUwY28wbFUifSwicHVycG9zZXMiOlsiYXV0aGVudGljYXRpb24iXSwidHlwZSI6IkVjZHNhU2VjcDI1NmsxVmVyaWZpY2F0aW9uS2V5MjAxOSJ9XSwic2VydmljZXMiOlt7ImlkIjoiZHduIiwic2VydmljZUVuZHBvaW50Ijp7Im5vZGVzIjpbImh0dHA6Ly9sb2NhbGhvc3Q6ODA4NSJdfSwidHlwZSI6IkRlY2VudHJhbGl6ZWRXZWJOb2RlIn1dfX1dLCJ1cGRhdGVDb21taXRtZW50IjoiRWlCb1c2dGs4WlZRTWs3YjFubkF2R3F3QTQ2amlaaUc2dWNYemxyNTZDWWFiUSJ9LCJzdWZmaXhEYXRhIjp7ImRlbHRhSGFzaCI6IkVpQ3Y2cUhEMFV4TTBadmZlTHU4dDR4eU5DVjNscFBSaTl6a3paU3h1LW8wWUEiLCJyZWNvdmVyeUNvbW1pdG1lbnQiOiJFaUN0STM0ckdGNU9USkJETXRUYm14a1lQeC0ydFd3MldZLTU2UTVPNHR0WWJBIn19' ) ?? {}; @@ -164,7 +164,7 @@ describe('DidUri', () => { }); it('extracts ION DID long form identifier from a DID URI with query and fragment', async () => { - const { uri } = DidUri.parse( + const { uri } = Did.parse( 'did:ion:EiAi68p2irCNQIzaui8gTjGDeOqSUusZS8jWVHfseSWZ5g:eyJkZWx0YSI6eyJwYXRjaGVzIjpbeyJhY3Rpb24iOiJyZXBsYWNlIiwiZG9jdW1lbnQiOnsicHVibGljS2V5cyI6W3siaWQiOiJrZXktMSIsInB1YmxpY0tleUp3ayI6eyJjcnYiOiJzZWNwMjU2azEiLCJrdHkiOiJFQyIsIngiOiI2MWlQWXVHZWZ4b3R6QmRRWnREdnY2Y1dIWm1YclRUc2NZLXU3WTJwRlpjIiwieSI6Ijg4blBDVkxmckFZOWktd2c1T1Jjd1ZiSFdDX3RiZUFkMUpFMmUwY28wbFUifSwicHVycG9zZXMiOlsiYXV0aGVudGljYXRpb24iXSwidHlwZSI6IkVjZHNhU2VjcDI1NmsxVmVyaWZpY2F0aW9uS2V5MjAxOSJ9XSwic2VydmljZXMiOlt7ImlkIjoiZHduIiwic2VydmljZUVuZHBvaW50Ijp7Im5vZGVzIjpbImh0dHA6Ly9sb2NhbGhvc3Q6ODA4NSJdfSwidHlwZSI6IkRlY2VudHJhbGl6ZWRXZWJOb2RlIn1dfX1dLCJ1cGRhdGVDb21taXRtZW50IjoiRWlCb1c2dGs4WlZRTWs3YjFubkF2R3F3QTQ2amlaaUc2dWNYemxyNTZDWWFiUSJ9LCJzdWZmaXhEYXRhIjp7ImRlbHRhSGFzaCI6IkVpQ3Y2cUhEMFV4TTBadmZlTHU4dDR4eU5DVjNscFBSaTl6a3paU3h1LW8wWUEiLCJyZWNvdmVyeUNvbW1pdG1lbnQiOiJFaUN0STM0ckdGNU9USkJETXRUYm14a1lQeC0ydFd3MldZLTU2UTVPNHR0WWJBIn19?service=files&relativeRef=/credentials#degree' ) ?? {}; @@ -172,17 +172,17 @@ describe('DidUri', () => { }); it('returns null for an invalid DID URI', () => { - expect(DidUri.parse('')).to.equal(null); - expect(DidUri.parse('not-a-did-uri')).to.equal(null); - expect(DidUri.parse('did:')).to.equal(null); - expect(DidUri.parse('did:uport')).to.equal(null); - expect(DidUri.parse('did:uport:')).to.equal(null); - expect(DidUri.parse('did:uport:1234_12313***')).to.equal(null); - expect(DidUri.parse('123')).to.equal(null); - expect(DidUri.parse('did:method:%12%1')).to.equal(null); - expect(DidUri.parse('did:method:%1233%Ay')).to.equal(null); - expect(DidUri.parse('did:CAP:id')).to.equal(null); - expect(DidUri.parse('did:method:id::anotherid%r9')).to.equal(null); + expect(Did.parse('')).to.equal(null); + expect(Did.parse('not-a-did-uri')).to.equal(null); + expect(Did.parse('did:')).to.equal(null); + expect(Did.parse('did:uport')).to.equal(null); + expect(Did.parse('did:uport:')).to.equal(null); + expect(Did.parse('did:uport:1234_12313***')).to.equal(null); + expect(Did.parse('123')).to.equal(null); + expect(Did.parse('did:method:%12%1')).to.equal(null); + expect(Did.parse('did:method:%1233%Ay')).to.equal(null); + expect(Did.parse('did:CAP:id')).to.equal(null); + expect(Did.parse('did:method:id::anotherid%r9')).to.equal(null); }); }); }); \ No newline at end of file