@cef-ebsi/ebsi-uri 0.1.0-alpha.1 → 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@cef-ebsi/ebsi-uri",
3
- "version": "0.1.0-alpha.1",
3
+ "version": "0.1.0",
4
4
  "description": "EBSI URIs parser and serializer",
5
5
  "license": "EUPL-1.2",
6
6
  "publishConfig": {
@@ -30,5 +30,5 @@
30
30
  "test:e2e": "echo \"Info: there's no e2e tests for @cef-ebsi/ebsi-uri\" && exit 0",
31
31
  "test:ci": "yarn test:unit --coverage --reporter=default"
32
32
  },
33
- "gitHead": "fd527248d908246b0f28d6ebf10c54fb52f87a23"
33
+ "gitHead": "4a9d0f7280c4a4d60876bd574cffe6291e43f3d0"
34
34
  }
@@ -1,19 +0,0 @@
1
- export declare const EBSI_DID_METHOD_PREFIX = "did:ebsi:";
2
- export declare const LEGAL_ENTITY = "LEGAL_ENTITY";
3
- export declare const SUPPORTED_VERSIONS: readonly ["LEGAL_ENTITY"];
4
- export declare const EBSI_DID_SPECS: Record<(typeof SUPPORTED_VERSIONS)[number], {
5
- VERSION_ID: number;
6
- BYTE_LENGTH: number;
7
- PREFIX: string;
8
- }>;
9
- export declare const DID_RESOLUTION_ERROR_CODES: {
10
- readonly INVALID_DID: "invalidDid";
11
- readonly NOT_FOUND: "notFound";
12
- readonly REPRESENTATION_NOT_SUPPORTED: "representationNotSupported";
13
- readonly UNKNOWN_ERROR: "unknownError";
14
- readonly INTERNAL_SERVER_ERROR: "internalServerError";
15
- readonly CONFIGURATION_ERROR: "configurationError";
16
- readonly INVALID_JWK: "invalidJwk";
17
- };
18
- export type DidResolutionErrorCode = (typeof DID_RESOLUTION_ERROR_CODES)[keyof typeof DID_RESOLUTION_ERROR_CODES];
19
- //# sourceMappingURL=constants.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,sBAAsB,cAAc,CAAC;AAClD,eAAO,MAAM,YAAY,iBAAiB,CAAC;AAC3C,eAAO,MAAM,kBAAkB,2BAA0B,CAAC;AAC1D,eAAO,MAAM,cAAc,EAAE,MAAM,CACjC,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAC,EACnC;IAAE,UAAU,EAAE,MAAM,CAAC;IAAC,WAAW,EAAE,MAAM,CAAC;IAAC,MAAM,EAAE,MAAM,CAAA;CAAE,CAOnD,CAAC;AAIX,eAAO,MAAM,0BAA0B;;;;;;;;CAU7B,CAAC;AAEX,MAAM,MAAM,sBAAsB,GAChC,CAAC,OAAO,0BAA0B,CAAC,CAAC,MAAM,OAAO,0BAA0B,CAAC,CAAC"}
package/dist/constants.js DELETED
@@ -1,20 +0,0 @@
1
- export const EBSI_DID_METHOD_PREFIX = "did:ebsi:";
2
- export const LEGAL_ENTITY = "LEGAL_ENTITY";
3
- export const SUPPORTED_VERSIONS = [LEGAL_ENTITY];
4
- export const EBSI_DID_SPECS = {
5
- [LEGAL_ENTITY]: {
6
- VERSION_ID: 0x01,
7
- BYTE_LENGTH: 16,
8
- PREFIX: EBSI_DID_METHOD_PREFIX,
9
- },
10
- };
11
- export const DID_RESOLUTION_ERROR_CODES = {
12
- INVALID_DID: "invalidDid",
13
- NOT_FOUND: "notFound",
14
- REPRESENTATION_NOT_SUPPORTED: "representationNotSupported",
15
- UNKNOWN_ERROR: "unknownError",
16
- INTERNAL_SERVER_ERROR: "internalServerError",
17
- CONFIGURATION_ERROR: "configurationError",
18
- INVALID_JWK: "invalidJwk",
19
- };
20
- //# sourceMappingURL=constants.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,MAAM,CAAC,MAAM,sBAAsB,GAAG,WAAW,CAAC;AAClD,MAAM,CAAC,MAAM,YAAY,GAAG,cAAc,CAAC;AAC3C,MAAM,CAAC,MAAM,kBAAkB,GAAG,CAAC,YAAY,CAAU,CAAC;AAC1D,MAAM,CAAC,MAAM,cAAc,GAGvB;IACF,CAAC,YAAY,CAAC,EAAE;QACd,UAAU,EAAE,IAAI;QAChB,WAAW,EAAE,EAAE;QACf,MAAM,EAAE,sBAAsB;KAC/B;CACO,CAAC;AAIX,MAAM,CAAC,MAAM,0BAA0B,GAAG;IAExC,WAAW,EAAE,YAAY;IACzB,SAAS,EAAE,UAAU;IACrB,4BAA4B,EAAE,4BAA4B;IAE1D,aAAa,EAAE,cAAc;IAC7B,qBAAqB,EAAE,qBAAqB;IAC5C,mBAAmB,EAAE,oBAAoB;IACzC,WAAW,EAAE,YAAY;CACjB,CAAC"}
package/dist/errors.d.ts DELETED
@@ -1,30 +0,0 @@
1
- interface ErrorOptions {
2
- type?: string;
3
- detail?: string;
4
- instance?: string;
5
- extensions?: {
6
- [x: string]: unknown;
7
- };
8
- }
9
- export declare class ProblemDetailsError extends Error {
10
- status: number;
11
- title: string;
12
- type?: string;
13
- detail?: string;
14
- instance?: string;
15
- extensions?: {
16
- [x: string]: unknown;
17
- };
18
- constructor(status: number, title: string, options?: ErrorOptions);
19
- toJSON(): {
20
- title: string;
21
- status: number;
22
- type?: string;
23
- detail?: string;
24
- instance?: string;
25
- [x: string]: unknown;
26
- };
27
- toString(): string;
28
- }
29
- export {};
30
- //# sourceMappingURL=errors.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAKA,UAAU,YAAY;IAEpB,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,UAAU,CAAC,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;CACvC;AAED,qBAAa,mBAAoB,SAAQ,KAAK;IACrC,MAAM,EAAE,MAAM,CAAC;IAEf,KAAK,EAAE,MAAM,CAAC;IAEd,IAAI,CAAC,EAAE,MAAM,CAAC;IAEd,MAAM,CAAC,EAAE,MAAM,CAAC;IAEhB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAElB,UAAU,CAAC,EAAE;QAAE,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAA;KAAE,CAAC;gBAOjC,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,YAAY;IAkBjE,MAAM,IAAI;QACR,KAAK,EAAE,MAAM,CAAC;QACd,MAAM,EAAE,MAAM,CAAC;QACf,IAAI,CAAC,EAAE,MAAM,CAAC;QACd,MAAM,CAAC,EAAE,MAAM,CAAC;QAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;QAClB,CAAC,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC;KACtB;IAWQ,QAAQ,IAAI,MAAM;CAG5B"}
package/dist/errors.js DELETED
@@ -1,34 +0,0 @@
1
- export class ProblemDetailsError extends Error {
2
- constructor(status, title, options) {
3
- super(title);
4
- this.name = "ProblemDetailsError";
5
- this.status = status;
6
- this.title = title;
7
- if (options) {
8
- if (options.type)
9
- this.type = options.type;
10
- if (options.detail)
11
- this.detail = options.detail;
12
- if (options.instance)
13
- this.instance = options.instance;
14
- if (options.extensions)
15
- this.extensions = options.extensions;
16
- }
17
- if (!this.type)
18
- this.type = "about:blank";
19
- }
20
- toJSON() {
21
- return {
22
- title: this.title,
23
- status: this.status,
24
- ...(this.type && { type: this.type }),
25
- ...(this.detail && { detail: this.detail }),
26
- ...(this.instance && { instance: this.instance }),
27
- ...this.extensions,
28
- };
29
- }
30
- toString() {
31
- return `${this.status} - ${this.title}`;
32
- }
33
- }
34
- //# sourceMappingURL=errors.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAgBA,M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AC;IAC1C,CAAC;CACF"}
@@ -1,6 +0,0 @@
1
- import type { DIDResolver } from "did-resolver";
2
- export interface ResolverOptions {
3
- registry?: string;
4
- }
5
- export declare function getResolver(resolverOptions: ResolverOptions): Record<"ebsi", DIDResolver>;
6
- //# sourceMappingURL=resolver.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolver.d.ts","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAGV,WAAW,EAEZ,MAAM,cAAc,CAAC;AAKtB,MAAM,WAAW,eAAe;IAI9B,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAKD,wBAAgB,WAAW,CACzB,eAAe,EAAE,eAAe,GAC/B,MAAM,CAAC,MAAM,EAAE,WAAW,CAAC,CAqC7B"}
package/dist/resolver.js DELETED
@@ -1,34 +0,0 @@
1
- import { DID_RESOLUTION_ERROR_CODES } from "./constants.js";
2
- import { resolve as resolveV1 } from "./resolvers/v1.js";
3
- import { validate } from "./validator.js";
4
- export function getResolver(resolverOptions) {
5
- async function resolve(did, _, __, didResolutionOptions) {
6
- if (!resolverOptions || typeof resolverOptions !== "object") {
7
- return {
8
- didDocument: null,
9
- didDocumentMetadata: {},
10
- didResolutionMetadata: {
11
- error: DID_RESOLUTION_ERROR_CODES.CONFIGURATION_ERROR,
12
- message: "Invalid or missing resolver options",
13
- },
14
- };
15
- }
16
- try {
17
- validate(did);
18
- }
19
- catch (e) {
20
- const message = e instanceof Error ? e.message : "Unknown error";
21
- return {
22
- didDocument: null,
23
- didDocumentMetadata: {},
24
- didResolutionMetadata: {
25
- error: "invalidDid",
26
- message,
27
- },
28
- };
29
- }
30
- return resolveV1(did, resolverOptions.registry, didResolutionOptions);
31
- }
32
- return { ebsi: resolve };
33
- }
34
- //# sourceMappingURL=resolver.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"resolver.js","sourceRoot":"","sources":["../src/resolver.ts"],"names":[],"mappings":"AAMA,OAAO,EAAE,0BAA0B,EAAE,MAAM,gBAAgB,CAAC;AAC5D,OAAO,EAAE,OAAO,IAAI,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACzD,OAAO,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAY1C,MAAM,UAAU,WAAW,CACzB,eAAgC;IAEhC,KAAK,UAAU,OAAO,CACpB,GAAW,EACX,CAAY,EACZ,EAAW,EACX,oBAA2C;QAE3C,IAAI,CAAC,eAAe,IAAI,OAAO,eAAe,KAAK,QAAQ,EAAE,CAAC;YAC5D,OAAO;gBACL,WAAW,EAAE,IAAI;gBACjB,mBAAmB,EAAE,EAAE;gBACvB,qBAAqB,EAAE;oBACrB,KAAK,EAAE,0BAA0B,CAAC,mBAAmB;oBACrD,OAAO,EAAE,qCAAqC;iBAC/C;aACF,CAAC;QACJ,CAAC;QAGD,IAAI,CAAC;YACH,QAAQ,CAAC,GAAG,CAAC,CAAC;QAChB,CAAC;QAAC,OAAO,CAAC,EAAE,CAAC;YACX,MAAM,OAAO,GAAG,CAAC,YAAY,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,OAAO,CAAC,CAAC,CAAC,eAAe,CAAC;YACjE,OAAO;gBACL,WAAW,EAAE,IAAI;gBACjB,mBAAmB,EAAE,EAAE;gBACvB,qBAAqB,EAAE;oBACrB,KAAK,EAAE,YAAY;oBACnB,OAAO;iBACR;aACF,CAAC;QACJ,CAAC;QAED,OAAO,SAAS,CAAC,GAAG,EAAE,eAAe,CAAC,QAAQ,EAAE,oBAAoB,CAAC,CAAC;IACxE,CAAC;IAED,OAAO,EAAE,IAAI,EAAE,OAAO,EAAE,CAAC;AAC3B,CAAC"}
@@ -1,3 +0,0 @@
1
- import type { DIDResolutionOptions, DIDResolutionResult } from "did-resolver";
2
- export declare function resolve(did: string, registry?: string, didResolutionOptions?: DIDResolutionOptions): Promise<DIDResolutionResult>;
3
- //# sourceMappingURL=v1.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v1.d.ts","sourceRoot":"","sources":["../../src/resolvers/v1.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAEV,oBAAoB,EACpB,mBAAmB,EACpB,MAAM,cAAc,CAAC;AAyDtB,wBAAsB,OAAO,CAC3B,GAAG,EAAE,MAAM,EACX,QAAQ,CAAC,EAAE,MAAM,EACjB,oBAAoB,CAAC,EAAE,oBAAoB,GAC1C,OAAO,CAAC,mBAAmB,CAAC,CA+E9B"}
@@ -1,109 +0,0 @@
1
- import axios from "axios";
2
- import { ProblemDetailsError } from "../errors.js";
3
- import { DID_RESOLUTION_ERROR_CODES, } from "../constants.js";
4
- const AXIOS_TIMEOUT = 15_000;
5
- const SUPPORTED_CONTENT_TYPES = [
6
- "application/did+ld+json",
7
- "application/did+json",
8
- ];
9
- function isSupportedContentType(contentType) {
10
- return SUPPORTED_CONTENT_TYPES.includes(contentType);
11
- }
12
- async function get(url, contentType, timeout) {
13
- try {
14
- const response = await axios.get(url, {
15
- headers: {
16
- accept: contentType,
17
- },
18
- timeout: timeout || AXIOS_TIMEOUT,
19
- });
20
- return response.data;
21
- }
22
- catch (e) {
23
- let message = "";
24
- if (axios.isAxiosError(e)) {
25
- try {
26
- const { detail, title } = e.response?.data;
27
- message = detail || title;
28
- }
29
- catch (err) {
30
- message = e.message;
31
- }
32
- throw new ProblemDetailsError(e.response?.status || 500, e.response?.statusText || "", {
33
- detail: message,
34
- });
35
- }
36
- throw e;
37
- }
38
- }
39
- export async function resolve(did, registry, didResolutionOptions) {
40
- if (!registry) {
41
- return {
42
- didDocument: null,
43
- didDocumentMetadata: {},
44
- didResolutionMetadata: {
45
- error: DID_RESOLUTION_ERROR_CODES.CONFIGURATION_ERROR,
46
- message: "A DID registry must be defined in order to resolve EBSI DID method v1 documents",
47
- },
48
- };
49
- }
50
- let accept = "application/did+ld+json";
51
- if (didResolutionOptions && didResolutionOptions.accept) {
52
- if (!isSupportedContentType(didResolutionOptions.accept)) {
53
- return {
54
- didDocument: null,
55
- didDocumentMetadata: {},
56
- didResolutionMetadata: {
57
- error: DID_RESOLUTION_ERROR_CODES.REPRESENTATION_NOT_SUPPORTED,
58
- message: `Representation ${didResolutionOptions.accept} is not supported. Valid representations include: ${SUPPORTED_CONTENT_TYPES.join(", ")}`,
59
- },
60
- };
61
- }
62
- accept = didResolutionOptions.accept;
63
- }
64
- try {
65
- const timeout = didResolutionOptions &&
66
- typeof didResolutionOptions["timeout"] === "number"
67
- ? didResolutionOptions["timeout"]
68
- : AXIOS_TIMEOUT;
69
- const didDocument = await get(`${registry}/${did}`, accept, timeout);
70
- return {
71
- didDocument,
72
- didDocumentMetadata: {},
73
- didResolutionMetadata: { contentType: accept },
74
- };
75
- }
76
- catch (e) {
77
- let error = DID_RESOLUTION_ERROR_CODES.UNKNOWN_ERROR;
78
- let message = "";
79
- if (e instanceof ProblemDetailsError) {
80
- if (e.status === 400) {
81
- error = DID_RESOLUTION_ERROR_CODES.INVALID_DID;
82
- message = e.detail || e.title || "Bad Request";
83
- }
84
- else if (e.status === 404) {
85
- error = DID_RESOLUTION_ERROR_CODES.NOT_FOUND;
86
- message = e.detail || e.title || "Not Found";
87
- }
88
- else if (e.status === 500) {
89
- error = DID_RESOLUTION_ERROR_CODES.INTERNAL_SERVER_ERROR;
90
- message = e.detail || e.title || "Internal Server Error";
91
- }
92
- else {
93
- message = e.detail || e.title || "unknown";
94
- }
95
- }
96
- else if (e instanceof Error) {
97
- message = e.message;
98
- }
99
- return {
100
- didDocument: null,
101
- didDocumentMetadata: {},
102
- didResolutionMetadata: {
103
- error,
104
- message: `${message} | Registry used: ${registry}`,
105
- },
106
- };
107
- }
108
- }
109
- //# sourceMappingURL=v1.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"v1.js","sourceRoot":"","sources":["../../src/resolvers/v1.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,OAAO,CAAC;AAM1B,OAAO,EAAE,mBAAmB,EAAE,MAAM,cAAc,CAAC;AACnD,OAAO,EACL,0BAA0B,GA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AAE,CAAC;YACrC,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBACrB,KAAK,GAAG,0BAA0B,CAAC,WAAW,CAAC;gBAC/C,OAAO,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,IAAI,aAAa,CAAC;YACjD,CAAC;iBAAM,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBAC5B,KAAK,GAAG,0BAA0B,CAAC,SAAS,CAAC;gBAC7C,OAAO,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,IAAI,WAAW,CAAC;YAC/C,CAAC;iBAAM,IAAI,CAAC,CAAC,MAAM,KAAK,GAAG,EAAE,CAAC;gBAC5B,KAAK,GAAG,0BAA0B,CAAC,qBAAqB,CAAC;gBACzD,OAAO,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,IAAI,uBAAuB,CAAC;YAC3D,CAAC;iBAAM,CAAC;gBACN,OAAO,GAAG,CAAC,CAAC,MAAM,IAAI,CAAC,CAAC,KAAK,IAAI,SAAS,CAAC;YAC7C,CAAC;QACH,CAAC;aAAM,IAAI,CAAC,YAAY,KAAK,EAAE,CAAC;YAC9B,OAAO,GAAG,CAAC,CAAC,OAAO,CAAC;QACtB,CAAC;QAED,OAAO;YACL,WAAW,EAAE,IAAI;YACjB,mBAAmB,EAAE,EAAE;YACvB,qBAAqB,EAAE;gBACrB,KAAK;gBACL,OAAO,EAAE,GAAG,OAAO,qBAAqB,QAAQ,EAAE;aACnD;SACF,CAAC;IACJ,CAAC;AACH,CAAC"}
package/dist/util.d.ts DELETED
@@ -1,3 +0,0 @@
1
- import { SUPPORTED_VERSIONS } from "./constants.js";
2
- export declare function createDid(subjectIdentifierBytes: ArrayLike<number>, version?: (typeof SUPPORTED_VERSIONS)[number]): string;
3
- //# sourceMappingURL=util.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"util.d.ts","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AACA,OAAO,EAIL,kBAAkB,EACnB,MAAM,gBAAgB,CAAC;AASxB,wBAAgB,SAAS,CACvB,sBAAsB,EAAE,SAAS,CAAC,MAAM,CAAC,EACzC,OAAO,GAAE,CAAC,OAAO,kBAAkB,CAAC,CAAC,MAAM,CAAgB,GAC1D,MAAM,CAmBR"}
package/dist/util.js DELETED
@@ -1,13 +0,0 @@
1
- import { base58btc } from "multiformats/bases/base58";
2
- import { EBSI_DID_METHOD_PREFIX, EBSI_DID_SPECS, LEGAL_ENTITY, } from "./constants.js";
3
- export function createDid(subjectIdentifierBytes, version = LEGAL_ENTITY) {
4
- const bytesArray = new Uint8Array(1 + EBSI_DID_SPECS[version].BYTE_LENGTH);
5
- bytesArray.set([EBSI_DID_SPECS[version].VERSION_ID]);
6
- if (subjectIdentifierBytes.length !== EBSI_DID_SPECS[version].BYTE_LENGTH) {
7
- throw new Error(`Invalid subject identifier length. Expected: ${EBSI_DID_SPECS[version].BYTE_LENGTH} bytes. Received: ${subjectIdentifierBytes.length} bytes.`);
8
- }
9
- bytesArray.set(subjectIdentifierBytes, 1);
10
- const methodSpecificIdentifier = base58btc.encode(bytesArray);
11
- return `${EBSI_DID_METHOD_PREFIX}${methodSpecificIdentifier}`;
12
- }
13
- //# sourceMappingURL=util.js.map
package/dist/util.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"util.js","sourceRoot":"","sources":["../src/util.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,YAAY,GAEb,MAAM,gBAAgB,CAAC;AASxB,MAAM,UAAU,SAAS,CACvB,sBAAyC,EACzC,UAA+C,YAAY;IAG3D,MAAM,UAAU,GAAG,IAAI,UAAU,CAAC,CAAC,GAAG,cAAc,CAAC,OAAO,CAAC,CAAC,WAAW,CAAC,CAAC;IAG3E,UAAU,CAAC,GAAG,CAAC,CAAC,cAAc,CAAC,OAAO,CAAC,CAAC,UAAU,CAAC,CAAC,CAAC;IAErD,IAAI,sBAAsB,CAAC,MAAM,KAAK,cAAc,CAAC,OAAO,CAAC,CAAC,WAAW,EAAE,CAAC;QAC1E,MAAM,IAAI,KAAK,CACb,gDAAgD,cAAc,CAAC,OAAO,CAAC,CAAC,WAAW,qBAAqB,sBAAsB,CAAC,MAAM,SAAS,CAC/I,CAAC;IACJ,CAAC;IAED,UAAU,CAAC,GAAG,CAAC,sBAAsB,EAAE,CAAC,CAAC,CAAC;IAG1C,MAAM,wBAAwB,GAAG,SAAS,CAAC,MAAM,CAAC,UAAU,CAAC,CAAC;IAE9D,OAAO,GAAG,sBAAsB,GAAG,wBAAwB,EAAE,CAAC;AAChE,CAAC"}
@@ -1,2 +0,0 @@
1
- export declare function validate(did: string): number;
2
- //# sourceMappingURL=validator.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validator.d.ts","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":"AAaA,wBAAgB,QAAQ,CAAC,GAAG,EAAE,MAAM,GAAG,MAAM,CAsD5C"}
package/dist/validator.js DELETED
@@ -1,35 +0,0 @@
1
- import { base58btc } from "multiformats/bases/base58";
2
- import { EBSI_DID_METHOD_PREFIX, EBSI_DID_SPECS, SUPPORTED_VERSIONS, } from "./constants.js";
3
- export function validate(did) {
4
- if (!did || typeof did !== "string") {
5
- throw new Error("The DID must be a string");
6
- }
7
- if (!did.startsWith(EBSI_DID_METHOD_PREFIX)) {
8
- throw new Error(`The DID must start with "${EBSI_DID_METHOD_PREFIX}"`);
9
- }
10
- const methodSpecificIdentifier = did.substring(EBSI_DID_METHOD_PREFIX.length);
11
- if (!methodSpecificIdentifier.startsWith("z")) {
12
- throw new Error('The method-specific identifier must start with "z" (multibase base58btc-encoded)');
13
- }
14
- let decodedIdentifier;
15
- try {
16
- decodedIdentifier = base58btc.decode(methodSpecificIdentifier);
17
- }
18
- catch (e) {
19
- throw new Error("The method-specific identifier is not a valid multibase base58btc-encoded string");
20
- }
21
- const version = decodedIdentifier[0];
22
- if (!version) {
23
- throw new Error("No version found");
24
- }
25
- const didSpecsKey = SUPPORTED_VERSIONS.find((specKey) => version === EBSI_DID_SPECS[specKey].VERSION_ID);
26
- if (!didSpecsKey) {
27
- throw new Error(`Unsupported version "${version}"`);
28
- }
29
- if (decodedIdentifier.byteLength - 1 !==
30
- EBSI_DID_SPECS[didSpecsKey].BYTE_LENGTH) {
31
- throw new Error(`The subject identifier length (${decodedIdentifier.byteLength - 1} bytes) does not match the expected length (${EBSI_DID_SPECS[didSpecsKey].BYTE_LENGTH} bytes)`);
32
- }
33
- return version;
34
- }
35
- //# sourceMappingURL=validator.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"validator.js","sourceRoot":"","sources":["../src/validator.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AACtD,OAAO,EACL,sBAAsB,EACtB,cAAc,EACd,kBAAkB,GACnB,MAAM,gBAAgB,CAAC;AAQxB,MAAM,UAAU,QAAQ,CAAC,GAAW;IAClC,IAAI,CAAC,GAAG,IAAI,OAAO,GAAG,KAAK,QAAQ,EAAE,CAAC;QACpC,MAAM,IAAI,KAAK,CAAC,0BAA0B,CAAC,CAAC;IAC9C,CAAC;IAED,IAAI,CAAC,GAAG,CAAC,UAAU,CAAC,sBAAsB,CAAC,EAAE,CAAC;QAC5C,MAAM,IAAI,KAAK,CAAC,4BAA4B,sBAAsB,GAAG,CAAC,CAAC;IACzE,CAAC;IAED,MAAM,wBAAwB,GAAG,GAAG,CAAC,SAAS,CAAC,sBAAsB,CAAC,MAAM,CAAC,CAAC;IAE9E,IAAI,CAAC,wBAAwB,CAAC,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;QAC9C,MAAM,IAAI,KAAK,CACb,kFAAkF,CACnF,CAAC;IACJ,CAAC;IAED,IAAI,iBAA6B,CAAC;IAClC,IAAI,CAAC;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