@truvity/sdk 0.40.13 → 0.40.14

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/Client.js CHANGED
@@ -56,9 +56,9 @@ class TruvityClient {
56
56
  this._options = Object.assign(Object.assign({}, _options), { headers: (0, headers_1.mergeHeaders)({
57
57
  'X-Fern-Language': 'JavaScript',
58
58
  'X-Fern-SDK-Name': '@truvity/sdk',
59
- 'X-Fern-SDK-Version': '0.40.13',
59
+ 'X-Fern-SDK-Version': '0.40.14',
60
60
  'X-Truvity-OAS-Version': '0.40.12-devel+a26921cf75bc',
61
- 'User-Agent': '@truvity/sdk/0.40.13',
61
+ 'User-Agent': '@truvity/sdk/0.40.14',
62
62
  'X-Fern-Runtime': core.RUNTIME.type,
63
63
  'X-Fern-Runtime-Version': core.RUNTIME.version,
64
64
  }, _options === null || _options === void 0 ? void 0 : _options.headers) });
package/Client.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"Client.js","sourceRoot":"","sources":["../src/Client.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAAgE;AAChE,sEAAwE;AACxE,+DAA0D;AAC1D,0EAAgF;AAChF,+DAA0D;AAC1D,iEAA8D;AAC9D,gEAA4D;AAC5D,+DAA0D;AAC1D,+DAA0D;AAC1D,yEAA4E;AAC5E,4EAAkF;AAClF,mEAAgE;AAChE,6CAA+B;AAC/B,4CAA8C;AA4B9C,MAAa,aAAa;IAetB,YAAY,WAAkC,EAAE;QAC5C,IAAI,CAAC,QAAQ,mCACN,QAAQ,KACX,OAAO,EAAE,IAAA,sBAAY,EACjB;gBACI,iBAAiB,EAAE,YAAY;gBAC/B,iBAAiB,EAAE,cAAc;gBACjC,oBAAoB,EAAE,SAAS;gBAC/B,uBAAuB,EAAE,4BAA4B;gBACrD,YAAY,EAAE,sBAAsB;gBACpC,gBAAgB,EAAE,IAAI,CAAC,O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AC;IAED,IAAW,aAAa;;QACpB,OAAO,OAAC,IAAI,CAAC,cAAc,oCAAnB,IAAI,CAAC,cAAc,GAAK,IAAI,uBAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAC,CAAC;IACtE,CAAC;IAED,IAAW,gBAAgB;;QACvB,OAAO,OAAC,IAAI,CAAC,iBAAiB,oCAAtB,IAAI,CAAC,iBAAiB,GAAK,IAAI,0BAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAC,CAAC;IAC5E,CAAC;IAED,IAAW,OAAO;;QACd,OAAO,OAAC,IAAI,CAAC,QAAQ,oCAAb,IAAI,CAAC,QAAQ,GAAK,IAAI,iBAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAC,CAAC;IAC1D,CAAC;IAED,IAAW,IAAI;;QACX,OAAO,OAAC,IAAI,CAAC,KAAK,oCAAV,IAAI,CAAC,KAAK,GAAK,IAAI,aAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAC,CAAC;IACpD,CAAC;IAED,IAAW,IAAI;;QACX,OAAO,OAAC,IAAI,CAAC,KAAK,oCAAV,IAAI,CAAC,KAAK,GAAK,IAAI,aAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAC,CAAC;IACpD,CAAC;CACJ;AAhFD,sCAgFC","sourcesContent":["/**\n * This file was auto-generated by Fern from our API Definition.\n */\n\nimport { ApiKeys } from './api/resources/apiKeys/client/Client';\nimport { Credentials } from './api/resources/credentials/client/Client';\nimport { Desk } from './api/resources/desk/client/Client';\nimport { DidcommMessages } from './api/resources/didcommMessages/client/Client';\nimport { Dids } from './api/resources/dids/client/Client';\nimport { Drafts } from './api/resources/drafts/client/Client';\nimport { Files } from './api/resources/files/client/Client';\nimport { Gdpr } from './api/resources/gdpr/client/Client';\nimport { Keys } from './api/resources/keys/client/Client';\nimport { Presentations } from './api/resources/presentations/client/Client';\nimport { PublishedSchemas } from './api/resources/publishedSchemas/client/Client';\nimport { Schemas } from './api/resources/schemas/client/Client';\nimport * as core from './core';\nimport { mergeHeaders } from './core/headers';\nimport * as environments from './environments';\n\nexport declare namespace TruvityClient {\n export interface Options {\n environment?: core.Supplier<environments.TruvityEnvironment | string>;\n /** Specify a custom URL to connect the client to. */\n baseUrl?: core.Supplier<string>;\n apiKey?: core.Supplier<string | undefined>;\n /** Additional headers to include in requests. */\n headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;\n fetcher?: core.FetchFunction;\n }\n\n export interface RequestOptions {\n /** The maximum time to wait for a response in seconds. */\n timeoutInSeconds?: number;\n /** The number of times to retry the request. Defaults to 2. */\n maxRetries?: number;\n /** A hook to abort the request. */\n abortSignal?: AbortSignal;\n /** Additional query string parameters to include in the request. */\n queryParams?: Record<string, unknown>;\n /** Additional headers to include in the request. */\n headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;\n }\n}\n\nexport class TruvityClient {\n protected readonly _options: TruvityClient.Options;\n protected _apiKeys: ApiKeys | undefined;\n protected _credentials: Credentials | undefined;\n protected _didcommMessages: DidcommMessages | undefined;\n protected _dids: Dids | undefined;\n protected _drafts: Drafts | undefined;\n protected _files: Files | undefined;\n protected _keys: Keys | undefined;\n protected _presentations: Presentations | undefined;\n protected _publishedSchemas: PublishedSchemas | undefined;\n protected _schemas: Schemas | undefined;\n protected _gdpr: Gdpr | undefined;\n protected _desk: Desk | undefined;\n\n constructor(_options: TruvityClient.Options = {}) {\n this._options = {\n ..._options,\n headers: mergeHeaders(\n {\n 'X-Fern-Language': 'JavaScript',\n 'X-Fern-SDK-Name': '@truvity/sdk',\n 'X-Fern-SDK-Version': '0.40.13',\n 'X-Truvity-OAS-Version': '0.40.12-devel+a26921cf75bc',\n 'User-Agent': '@truvity/sdk/0.40.13',\n 'X-Fern-Runtime': core.RUNTIME.type,\n 'X-Fern-Runtime-Version': core.RUNTIME.version,\n },\n _options?.headers,\n ),\n };\n }\n\n public get apiKeys(): ApiKeys {\n return (this._apiKeys ??= new ApiKeys(this._options));\n }\n\n public get credentials(): Credentials {\n return (this._credentials ??= new Credentials(this._options));\n }\n\n public get didcommMessages(): DidcommMessages {\n return (this._didcommMessages ??= new DidcommMessages(this._options));\n }\n\n public get dids(): Dids {\n return (this._dids ??= new Dids(this._options));\n }\n\n public get drafts(): Drafts {\n return (this._drafts ??= new Drafts(this._options));\n }\n\n public get files(): Files {\n return (this._files ??= new Files(this._options));\n }\n\n public get keys(): Keys {\n return (this._keys ??= new Keys(this._options));\n }\n\n public get presentations(): Presentations {\n return (this._presentations ??= new Presentations(this._options));\n }\n\n public get publishedSchemas(): PublishedSchemas {\n return (this._publishedSchemas ??= new PublishedSchemas(this._options));\n }\n\n public get schemas(): Schemas {\n return (this._schemas ??= new Schemas(this._options));\n }\n\n public get gdpr(): Gdpr {\n return (this._gdpr ??= new Gdpr(this._options));\n }\n\n public get desk(): Desk {\n return (this._desk ??= new Desk(this._options));\n }\n}\n"]}
1
+ {"version":3,"file":"Client.js","sourceRoot":"","sources":["../src/Client.ts"],"names":[],"mappings":";AAAA;;GAEG;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAEH,kEAAgE;AAChE,sEAAwE;AACxE,+DAA0D;AAC1D,0EAAgF;AAChF,+DAA0D;AAC1D,iEAA8D;AAC9D,gEAA4D;AAC5D,+DAA0D;AAC1D,+DAA0D;AAC1D,yEAA4E;AAC5E,4EAAkF;AAClF,mEAAgE;AAChE,6CAA+B;AAC/B,4CAA8C;AA4B9C,MAAa,aAAa;IAetB,YAAY,WAAkC,EAAE;QAC5C,IAAI,CAAC,QAAQ,mCACN,QAAQ,KACX,OAAO,EAAE,IAAA,sBAAY,EACjB;gBACI,iBAAiB,EAAE,YAAY;gBAC/B,iBAAiB,EAAE,cAAc;gBACjC,oBAAoB,EAAE,SAAS;gBAC/B,uBAAuB,EAAE,4BAA4B;gBACrD,YAAY,EAAE,sBAAsB;gBACpC,gBAAgB,EAAE,IAAI,CAAC,OAAO,CAAC,IAAI;gBACnC,wBAAwB,EAAE,IAAI,CAA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AC,cAAc,oCAAnB,IAAI,CAAC,cAAc,GAAK,IAAI,uBAAa,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAC,CAAC;IACtE,CAAC;IAED,IAAW,gBAAgB;;QACvB,OAAO,OAAC,IAAI,CAAC,iBAAiB,oCAAtB,IAAI,CAAC,iBAAiB,GAAK,IAAI,0BAAgB,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAC,CAAC;IAC5E,CAAC;IAED,IAAW,OAAO;;QACd,OAAO,OAAC,IAAI,CAAC,QAAQ,oCAAb,IAAI,CAAC,QAAQ,GAAK,IAAI,iBAAO,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAC,CAAC;IAC1D,CAAC;IAED,IAAW,IAAI;;QACX,OAAO,OAAC,IAAI,CAAC,KAAK,oCAAV,IAAI,CAAC,KAAK,GAAK,IAAI,aAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAC,CAAC;IACpD,CAAC;IAED,IAAW,IAAI;;QACX,OAAO,OAAC,IAAI,CAAC,KAAK,oCAAV,IAAI,CAAC,KAAK,GAAK,IAAI,aAAI,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAC,CAAC;IACpD,CAAC;CACJ;AAhFD,sCAgFC","sourcesContent":["/**\n * This file was auto-generated by Fern from our API Definition.\n */\n\nimport { ApiKeys } from './api/resources/apiKeys/client/Client';\nimport { Credentials } from './api/resources/credentials/client/Client';\nimport { Desk } from './api/resources/desk/client/Client';\nimport { DidcommMessages } from './api/resources/didcommMessages/client/Client';\nimport { Dids } from './api/resources/dids/client/Client';\nimport { Drafts } from './api/resources/drafts/client/Client';\nimport { Files } from './api/resources/files/client/Client';\nimport { Gdpr } from './api/resources/gdpr/client/Client';\nimport { Keys } from './api/resources/keys/client/Client';\nimport { Presentations } from './api/resources/presentations/client/Client';\nimport { PublishedSchemas } from './api/resources/publishedSchemas/client/Client';\nimport { Schemas } from './api/resources/schemas/client/Client';\nimport * as core from './core';\nimport { mergeHeaders } from './core/headers';\nimport * as environments from './environments';\n\nexport declare namespace TruvityClient {\n export interface Options {\n environment?: core.Supplier<environments.TruvityEnvironment | string>;\n /** Specify a custom URL to connect the client to. */\n baseUrl?: core.Supplier<string>;\n apiKey?: core.Supplier<string | undefined>;\n /** Additional headers to include in requests. */\n headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;\n fetcher?: core.FetchFunction;\n }\n\n export interface RequestOptions {\n /** The maximum time to wait for a response in seconds. */\n timeoutInSeconds?: number;\n /** The number of times to retry the request. Defaults to 2. */\n maxRetries?: number;\n /** A hook to abort the request. */\n abortSignal?: AbortSignal;\n /** Additional query string parameters to include in the request. */\n queryParams?: Record<string, unknown>;\n /** Additional headers to include in the request. */\n headers?: Record<string, string | core.Supplier<string | undefined> | undefined>;\n }\n}\n\nexport class TruvityClient {\n protected readonly _options: TruvityClient.Options;\n protected _apiKeys: ApiKeys | undefined;\n protected _credentials: Credentials | undefined;\n protected _didcommMessages: DidcommMessages | undefined;\n protected _dids: Dids | undefined;\n protected _drafts: Drafts | undefined;\n protected _files: Files | undefined;\n protected _keys: Keys | undefined;\n protected _presentations: Presentations | undefined;\n protected _publishedSchemas: PublishedSchemas | undefined;\n protected _schemas: Schemas | undefined;\n protected _gdpr: Gdpr | undefined;\n protected _desk: Desk | undefined;\n\n constructor(_options: TruvityClient.Options = {}) {\n this._options = {\n ..._options,\n headers: mergeHeaders(\n {\n 'X-Fern-Language': 'JavaScript',\n 'X-Fern-SDK-Name': '@truvity/sdk',\n 'X-Fern-SDK-Version': '0.40.14',\n 'X-Truvity-OAS-Version': '0.40.12-devel+a26921cf75bc',\n 'User-Agent': '@truvity/sdk/0.40.14',\n 'X-Fern-Runtime': core.RUNTIME.type,\n 'X-Fern-Runtime-Version': core.RUNTIME.version,\n },\n _options?.headers,\n ),\n };\n }\n\n public get apiKeys(): ApiKeys {\n return (this._apiKeys ??= new ApiKeys(this._options));\n }\n\n public get credentials(): Credentials {\n return (this._credentials ??= new Credentials(this._options));\n }\n\n public get didcommMessages(): DidcommMessages {\n return (this._didcommMessages ??= new DidcommMessages(this._options));\n }\n\n public get dids(): Dids {\n return (this._dids ??= new Dids(this._options));\n }\n\n public get drafts(): Drafts {\n return (this._drafts ??= new Drafts(this._options));\n }\n\n public get files(): Files {\n return (this._files ??= new Files(this._options));\n }\n\n public get keys(): Keys {\n return (this._keys ??= new Keys(this._options));\n }\n\n public get presentations(): Presentations {\n return (this._presentations ??= new Presentations(this._options));\n }\n\n public get publishedSchemas(): PublishedSchemas {\n return (this._publishedSchemas ??= new PublishedSchemas(this._options));\n }\n\n public get schemas(): Schemas {\n return (this._schemas ??= new Schemas(this._options));\n }\n\n public get gdpr(): Gdpr {\n return (this._gdpr ??= new Gdpr(this._options));\n }\n\n public get desk(): Desk {\n return (this._desk ??= new Desk(this._options));\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"ExtendedClient.d.ts","sourceRoot":"","sources":["../src/ExtendedClient.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAEzC,OAAO,EAAE,UAAU,EAAE,WAAW,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC;AACnE,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACjD,OAAO,EAAgC,UAAU,EAAE,MAAM,eAAe,CAAC;AAEzE,KAAK,4BAA4B,GAAG,aAAa,CAAC,OAAO,GAAG;IACxD,kBAAkB,CAAC,EAAE,UAAU,CAAC,GAAG,CAAC,EAAE,CAAC;CAC1C,CAAC;AAEF,qBAAa,qBAAsB,SAAQ,aAAa;gBACxC,EAAE,kBAAkB,EAAE,OAAO,EAAE,aAAa,EAAE,GAAG,OAAO,EAAE,GAAE,4BAAiC;IASlG,iBAAiB,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,CAAC,CAAC,GAAG,WAAW,CAAC,CAAC,CAAC;IAInE,iBAAiB,IAAI,WAAW;IAI1B,QAAQ,I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C,MAAM,EAAE,MAAM,CAAC,CAAC;QAAC,MAAM,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAA;KAAE,GACtG,OAAO,CAAC,UAAU,CAAC;CAkBzB"}
package/ExtendedClient.js CHANGED
@@ -1,4 +1,13 @@
1
1
  "use strict";
2
+ var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) {
3
+ var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d;
4
+ if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc);
5
+ else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r;
6
+ return c > 3 && r && Object.defineProperty(target, key, r), r;
7
+ };
8
+ var __metadata = (this && this.__metadata) || function (k, v) {
9
+ if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v);
10
+ };
2
11
  var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
3
12
  function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
4
13
  return new (P || (P = Promise))(function (resolve, reject) {
@@ -19,8 +28,12 @@ var __rest = (this && this.__rest) || function (s, e) {
19
28
  }
20
29
  return t;
21
30
  };
31
+ var __importDefault = (this && this.__importDefault) || function (mod) {
32
+ return (mod && mod.__esModule) ? mod : { "default": mod };
33
+ };
22
34
  Object.defineProperty(exports, "__esModule", { value: true });
23
35
  exports.ExtendedTruvityClient = void 0;
36
+ const mem_1 = __importDefault(require("mem"));
24
37
  const Client_1 = require("./Client");
25
38
  const core_1 = require("./core");
26
39
  const documents_1 = require("./documents");
@@ -59,4 +72,10 @@ class ExtendedTruvityClient extends Client_1.TruvityClient {
59
72
  }
60
73
  }
61
74
  exports.ExtendedTruvityClient = ExtendedTruvityClient;
75
+ __decorate([
76
+ mem_1.default.decorator(),
77
+ __metadata("design:type", Function),
78
+ __metadata("design:paramtypes", []),
79
+ __metadata("design:returntype", Promise)
80
+ ], ExtendedTruvityClient.prototype, "tenantId", null);
62
81
  //# sourceMappingURL=ExtendedClient.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"ExtendedClient.js","sourceRoot":"","sources":["../src/ExtendedClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;AAAA,qCAAyC;AACzC,iCAAiC;AACjC,2CAAmE;AAEnE,+CAAyE;AAMzE,MAAa,qBAAsB,SAAQ,sBAAa;IACpD,YAAY,KAA2F,EAAE;YAA7F,EAAE,kBAAkB,EAAE,OAAO,EAAE,aAAa,OAAiD,EAA5C,OAAO,cAAxD,iCAA0D,CAAF;QAChE,KAAK,iCACE,OAAO,KACV,OAAO,EAAE,kBAAkB;gBACvB,CAAC,CAAC,IAAA,0CAA4B,EAAC,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,cAAO,EAAE,kBAAkB,CAAC;gBAC5E,CAAC,CAAC,aAAa,IACrB,CAAC;IACP,CAAC;IAEM,iBAAiB,CAAmB,KAAc;QACrD,OAAO,IAAI,uBAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAEM,iBAAiB;QACpB,OAAO,IAAI,uBAAW,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAEY,QAAQ;;YACjB,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC,EAAE,CAAC;YACrD,OAAO,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACjD,CAAC;KAAA;IAEY,gBAAgB,CACzB,IAAoD,EACpD,MAAqG;;YAErG,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;YAE9E,MAAM,KAAK,CAAC,gBAAgB,EAAE;gBAC1B,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,IAAI;aACb,CAAC,CAAC;YAEH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,+BACxC,MAAM,IACH,MAAM,KACT,IAAI,EAAE;oBACF,QAAQ,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ;iBAC7B,IACH,CAAC;YAEH,OAAO,IAAI,sBAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAC5E,CAAC;KAAA;CACJ;AA5CD,sDA4CC","sourcesContent":["import { TruvityClient } from './Client';\nimport { fetcher } from './core';\nimport { LinkedFile, VcDecorator, VpDecorator } from './documents';\nimport { Claims, Ctor } from './documents/types';\nimport { createFetcherWithMiddlewares, Middleware } from './middlewares';\n\ntype ExtendedTruvityClientOptions = TruvityClient.Options & {\n fetcherMiddlewares?: Middleware<any>[];\n};\n\nexport class ExtendedTruvityClient extends TruvityClient {\n constructor({ fetcherMiddlewares, fetcher: customFetcher, ...options }: ExtendedTruvityClientOptions = {}) {\n super({\n ...options,\n fetcher: fetcherMiddlewares\n ? createFetcherWithMiddlewares(customFetcher ?? fetcher, fetcherMiddlewares)\n : customFetcher,\n });\n }\n\n public createVcDecorator<T extends Claims>(model: Ctor<T>): VcDecorator<T> {\n return new VcDecorator(this, model);\n }\n\n public createVpDecorator(): VpDecorator {\n return new VpDecorator(this);\n }\n\n public async tenantId(): Promise<string> {\n const id = (await this.dids.didDocumentSelfGet()).id;\n return id.substring(id.lastIndexOf(':') + 1);\n }\n\n public async createLinkedFile(\n file: ArrayBufferView | ArrayBuffer | ReadableStream,\n params?: { filename?: string; annotations?: Record<string, string>; labels?: Record<string, string> },\n ): Promise<LinkedFile> {\n const { blobId, uploadUri: initialUploadUri } = await this.files.fileUpload();\n\n await fetch(initialUploadUri, {\n method: 'PUT',\n body: file,\n });\n\n const resource = await this.files.fileCreate({\n blobId,\n ...params,\n data: {\n filename: params?.filename,\n },\n });\n\n return new LinkedFile(this, resource.id, resource.data.digestMultibase);\n }\n}\n"]}
1
+ {"version":3,"file":"ExtendedClient.js","sourceRoot":"","sources":["../src/ExtendedClient.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAsB;AACtB,qCAAyC;AACzC,iCAAiC;AACjC,2CAAmE;AAEnE,+CAAyE;AAMzE,MAAa,qBAAsB,SAAQ,sBAAa;IACpD,YAAY,KAA2F,EAAE;YAA7F,EAAE,kBAAkB,EAAE,OAAO,EAAE,aAAa,OAAiD,EAA5C,OAAO,cAAxD,iCAA0D,CAAF;QAChE,KAAK,iCACE,OAAO,KACV,OAAO,EAAE,kBAAkB;gBACvB,CAAC,CAAC,IAAA,0CAA4B,EAAC,aAAa,aAAb,aAAa,cAAb,aAAa,GAAI,cAAO,EAAE,kBAAkB,CAAC;gBAC5E,CAAC,CAAC,aAAa,IACrB,CAAC;IACP,CAAC;IAEM,iBAAiB,CAAmB,KAAc;QACrD,OAAO,IAAI,uBAAW,CAAC,IAAI,EAAE,KAAK,CAAC,CAAC;IACxC,CAAC;IAEM,iBAAiB;QACpB,OAAO,IAAI,uBAAW,CAAC,IAAI,CAAC,CAAC;IACjC,CAAC;IAGY,QAAQ;;YACjB,MAAM,EAAE,GAAG,CAAC,MAAM,IAAI,CAAC,IAAI,CAAC,kBAAkB,EAAE,CAAC,CAAC,EAAE,CAAC;YACrD,OAAO,EAAE,CAAC,SAAS,CAAC,EAAE,CAAC,WAAW,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC,CAAC;QACjD,CAAC;KAAA;IAEY,gBAAgB,CACzB,IAAoD,EACpD,MAAqG;;YAErG,MAAM,EAAE,MAAM,EAAE,SAAS,EAAE,gBAAgB,EAAE,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,EAAE,CAAC;YAE9E,MAAM,KAAK,CAAC,gBAAgB,EAAE;gBAC1B,MAAM,EAAE,KAAK;gBACb,IAAI,EAAE,IAAI;aACb,CAAC,CAAC;YAEH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,KAAK,CAAC,UAAU,+BACxC,MAAM,IACH,MAAM,KACT,IAAI,EAAE;oBACF,QAAQ,EAAE,MAAM,aAAN,MAAM,uBAAN,MAAM,CAAE,QAAQ;iBAC7B,IACH,CAAC;YAEH,OAAO,IAAI,sBAAU,CAAC,IAAI,EAAE,QAAQ,CAAC,EAAE,EAAE,QAAQ,CAAC,IAAI,CAAC,eAAe,CAAC,CAAC;QAC5E,CAAC;KAAA;CACJ;AA7CD,sDA6CC;AA1BgB;IADZ,aAAG,CAAC,SAAS,EAAE;;;;qDAIf","sourcesContent":["import mem from 'mem';\nimport { TruvityClient } from './Client';\nimport { fetcher } from './core';\nimport { LinkedFile, VcDecorator, VpDecorator } from './documents';\nimport { Claims, Ctor } from './documents/types';\nimport { createFetcherWithMiddlewares, Middleware } from './middlewares';\n\ntype ExtendedTruvityClientOptions = TruvityClient.Options & {\n fetcherMiddlewares?: Middleware<any>[];\n};\n\nexport class ExtendedTruvityClient extends TruvityClient {\n constructor({ fetcherMiddlewares, fetcher: customFetcher, ...options }: ExtendedTruvityClientOptions = {}) {\n super({\n ...options,\n fetcher: fetcherMiddlewares\n ? createFetcherWithMiddlewares(customFetcher ?? fetcher, fetcherMiddlewares)\n : customFetcher,\n });\n }\n\n public createVcDecorator<T extends Claims>(model: Ctor<T>): VcDecorator<T> {\n return new VcDecorator(this, model);\n }\n\n public createVpDecorator(): VpDecorator {\n return new VpDecorator(this);\n }\n\n @mem.decorator()\n public async tenantId(): Promise<string> {\n const id = (await this.dids.didDocumentSelfGet()).id;\n return id.substring(id.lastIndexOf(':') + 1);\n }\n\n public async createLinkedFile(\n file: ArrayBufferView | ArrayBuffer | ReadableStream,\n params?: { filename?: string; annotations?: Record<string, string>; labels?: Record<string, string> },\n ): Promise<LinkedFile> {\n const { blobId, uploadUri: initialUploadUri } = await this.files.fileUpload();\n\n await fetch(initialUploadUri, {\n method: 'PUT',\n body: file,\n });\n\n const resource = await this.files.fileCreate({\n blobId,\n ...params,\n data: {\n filename: params?.filename,\n },\n });\n\n return new LinkedFile(this, resource.id, resource.data.digestMultibase);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"claims.d.ts","sourceRoot":"","sources":["../../../src/documents/credential/claims.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,YAAY,EAAE,sBAAsB,EAAwB,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAE9G,OAAO,EACH,eAAe,EAIlB,MAAM,eAAe,CAAC;AAEvB,OAAO,EACH,SAAS,EACT,MAAM,EACN,IAAI,EAIJ,UAAU,EACV,eAAe,EACf,gBAAgB,EACnB,MAAM,UAAU,CAAC;AAKlB,OAAO,EAA0B,IAAI,EAAE,MAAM,SAAS,CAAC;AAGvD,qBAAa,SAAS,CAAC,CAAC,SAAS,MAAM;IAE/B,SAAS,CAAC,MAAM,EAAE,SAAS;IAC3B,SAAS,CAAC,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;gBADpB,MAAM,EAAE,SAAS,EACjB,WAAW,EAAE,IAAI,CAAC,CAAC,CAAC;IAGlC,OAAO,CAAC,aAAa;IAkCrB,OAAO,CAAC,UAAU;IAsClB,OAAO,CAAC,4BAA4B;IAkCpC,OAAO,CAAC,gBAAgB;IAYxB,iHAAiH;IACjH,SAAS,CAAC,iCAAiC,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,qBAAqB,GAAG,CAAC;IAwGhH,qGAAqG;IACrG,SAAS,CAAC,qBAAqB,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,CAAC;IAiEnF,oGAAoG;IACpG,SAAS,CAAC,iCAAiC,CAAC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AAK,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,qBAAqB,GAAG,CAAC;IAwGhH,qGAAqG;IACrG,SAAS,CAAC,qBAAqB,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,IAAI,GAAG,CAAC;IAiEnF,oGAAoG;IACpG,SAAS,CAAC,iCAAiC,CAAC,CAAC,SAAS,MAAM,EAAE,KAAK,EAAE,IAAI,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,qBAAqB;IAiGhH,SAAS,CAAC,yCAAyC,CAC/C,KAAK,EAAE,eAAe,EACtB,WAAW,EAAE,IAAI,CAAC,GAAG,CAAC,GACvB,sBAAsB;IAsGzB;;;OAGG;IACH,aAAa,CAAC,KAAK,EAAE,gBAAgB,CAAC,CAAC,CAAC,GAAG,MAAM;IAIjD;;;OAGG;IACH,sBAAsB,CAAC,KAAK,EAAE,qBAAqB,GAAG,eAAe,CAAC,CAAC,CAAC;IAIxE,2BAA2B,CAAC,KAAK,EAAE,IAAI,GAAG,UAAU,CAAC,CAAC,CAAC;IAIvD,eAAe,IAAI,YAAY;CAalC"}
@@ -36,10 +36,10 @@ Object.defineProperty(exports, "__esModule", { value: true });
36
36
  exports.UdtClaims = void 0;
37
37
  const serialization = __importStar(require("../../serialization"));
38
38
  const decorators_1 = require("../decorators");
39
+ const error_1 = require("../error");
39
40
  const models_1 = require("../models");
40
41
  const types_1 = require("../types");
41
42
  const converters_1 = require("../utils/converters");
42
- const error_1 = require("../utils/error");
43
43
  const credential_1 = require("./credential");
44
44
  const draft_1 = require("./draft/draft");
45
45
  const verifiable_1 = require("./verifiable/verifiable");
@@ -63,7 +63,7 @@ class UdtClaims {
63
63
  });
64
64
  }
65
65
  else {
66
- throw new error_1.DocumentedError(error_1.ErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "Array".`);
66
+ throw new error_1.UdtError(error_1.UdtErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "Array".`);
67
67
  }
68
68
  }
69
69
  else {
@@ -92,7 +92,7 @@ class UdtClaims {
92
92
  };
93
93
  }
94
94
  else {
95
- throw new error_1.DocumentedError(error_1.ErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "Array".`);
95
+ throw new error_1.UdtError(error_1.UdtErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "Array".`);
96
96
  }
97
97
  }
98
98
  else {
@@ -118,7 +118,7 @@ class UdtClaims {
118
118
  });
119
119
  }
120
120
  else {
121
- throw new error_1.DocumentedError(error_1.ErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "Array".`);
121
+ throw new error_1.UdtError(error_1.UdtErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "Array".`);
122
122
  }
123
123
  }
124
124
  else {
@@ -145,54 +145,54 @@ class UdtClaims {
145
145
  const typeInfo = this.getClaimTypeInfo(model, descriptor);
146
146
  if (typeInfo === models_1.LinkedCredential) {
147
147
  if (value.kind !== 'LINK') {
148
- throw new error_1.DocumentedError(error_1.ErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "LinkedCredential".`);
148
+ throw new error_1.UdtError(error_1.UdtErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "LinkedCredential".`);
149
149
  }
150
150
  return new models_1.LinkedCredential(this.client, value.value.id, value.value.digestMultibase);
151
151
  }
152
152
  if (typeInfo === models_1.LinkedFile) {
153
153
  if (value.kind !== 'FILE') {
154
- throw new error_1.DocumentedError(error_1.ErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "LinkedFile".`);
154
+ throw new error_1.UdtError(error_1.UdtErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "LinkedFile".`);
155
155
  }
156
156
  return new models_1.LinkedFile(this.client, value.value.id, value.value.digestMultibase);
157
157
  }
158
158
  if (typeInfo === Date) {
159
159
  if (value.kind !== 'DATETIME') {
160
- throw new error_1.DocumentedError(error_1.ErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "Date".`);
160
+ throw new error_1.UdtError(error_1.UdtErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "Date".`);
161
161
  }
162
162
  return new Date(value.value);
163
163
  }
164
164
  if (typeInfo === models_1.Rfc3339DateTime) {
165
165
  if (value.kind !== 'DATETIME') {
166
- throw new error_1.DocumentedError(error_1.ErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "Rfc3339DateTime".`);
166
+ throw new error_1.UdtError(error_1.UdtErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "Rfc3339DateTime".`);
167
167
  }
168
168
  return new models_1.Rfc3339DateTime(value.value);
169
169
  }
170
170
  if (typeInfo === models_1.Rfc3339Date) {
171
171
  if (value.kind !== 'DATE') {
172
- throw new error_1.DocumentedError(error_1.ErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "Rfc3339Date".`);
172
+ throw new error_1.UdtError(error_1.UdtErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "Rfc3339Date".`);
173
173
  }
174
174
  return new models_1.Rfc3339Date(value.value);
175
175
  }
176
176
  if (typeInfo === String) {
177
177
  if (value.kind !== 'STRING') {
178
- throw new error_1.DocumentedError(error_1.ErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "string".`);
178
+ throw new error_1.UdtError(error_1.UdtErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "string".`);
179
179
  }
180
180
  return value.value;
181
181
  }
182
182
  if (typeInfo === Number) {
183
183
  if (value.kind !== 'NUMBER') {
184
- throw new error_1.DocumentedError(error_1.ErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "number".`);
184
+ throw new error_1.UdtError(error_1.UdtErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "number".`);
185
185
  }
186
186
  return value.value;
187
187
  }
188
188
  if (typeInfo === Boolean) {
189
189
  if (value.kind !== 'BOOLEAN') {
190
- throw new error_1.DocumentedError(error_1.ErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "boolean".`);
190
+ throw new error_1.UdtError(error_1.UdtErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "boolean".`);
191
191
  }
192
192
  return value.value;
193
193
  }
194
194
  if (value.kind !== 'STRUCT') {
195
- throw new error_1.DocumentedError(error_1.ErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "${typeInfo.name}".`);
195
+ throw new error_1.UdtError(error_1.UdtErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "${typeInfo.name}".`);
196
196
  }
197
197
  return this.convertCredentialClaimValuesToUdt(typeInfo, value.value);
198
198
  };
@@ -215,19 +215,19 @@ class UdtClaims {
215
215
  }
216
216
  if (typeInfo === Date) {
217
217
  if (typeof value !== 'string') {
218
- throw new error_1.DocumentedError(error_1.ErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "Date".`);
218
+ throw new error_1.UdtError(error_1.UdtErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "Date".`);
219
219
  }
220
220
  return new Date(value);
221
221
  }
222
222
  if (typeInfo === models_1.Rfc3339DateTime) {
223
223
  if (typeof value !== 'string') {
224
- throw new error_1.DocumentedError(error_1.ErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "Rfc3339DateTime".`);
224
+ throw new error_1.UdtError(error_1.UdtErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "Rfc3339DateTime".`);
225
225
  }
226
226
  return new models_1.Rfc3339DateTime(value);
227
227
  }
228
228
  if (typeInfo === models_1.Rfc3339Date) {
229
229
  if (typeof value !== 'string') {
230
- throw new error_1.DocumentedError(error_1.ErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "Rfc3339Date".`);
230
+ throw new error_1.UdtError(error_1.UdtErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "Rfc3339Date".`);
231
231
  }
232
232
  return new models_1.Rfc3339Date(value);
233
233
  }
@@ -236,7 +236,7 @@ class UdtClaims {
236
236
  return value;
237
237
  }
238
238
  if (!(value instanceof Object)) {
239
- throw new error_1.DocumentedError(error_1.ErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "${typeInfo.name}".`);
239
+ throw new error_1.UdtError(error_1.UdtErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "${typeInfo.name}".`);
240
240
  }
241
241
  return this.convertApiValuesToUdt(typeInfo, value);
242
242
  };
@@ -258,7 +258,7 @@ class UdtClaims {
258
258
  if ((0, types_1.isValueWithId)(value)) {
259
259
  return models_1.LinkedCredential.createCredentialClaimValue(value.id, value.digestMultibase);
260
260
  }
261
- throw new error_1.DocumentedError(error_1.ErrorCode.UnexpectedTypeInSerialization, 'Invalid value for linked credential');
261
+ throw new error_1.UdtError(error_1.UdtErrorCode.UnexpectedTypeInSerialization, 'Invalid value for linked credential');
262
262
  }
263
263
  if (typeInfo === models_1.LinkedFile) {
264
264
  if (value instanceof models_1.LinkedFile) {
@@ -270,7 +270,7 @@ class UdtClaims {
270
270
  if ((0, types_1.isValueWithId)(value)) {
271
271
  return models_1.LinkedFile.createCredentialClaimValue(value.id, value.digestMultibase);
272
272
  }
273
- throw new error_1.DocumentedError(error_1.ErrorCode.UnexpectedTypeInSerialization, 'Invalid value for linked file');
273
+ throw new error_1.UdtError(error_1.UdtErrorCode.UnexpectedTypeInSerialization, 'Invalid value for linked file');
274
274
  }
275
275
  if (typeInfo === String && typeof value === 'string') {
276
276
  return {
@@ -309,7 +309,7 @@ class UdtClaims {
309
309
  };
310
310
  }
311
311
  if (!(value instanceof Object)) {
312
- throw new error_1.DocumentedError(error_1.ErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "${typeInfo.name}".`);
312
+ throw new error_1.UdtError(error_1.UdtErrorCode.UnexpectedTypeInSerialization, `Can't convert received value as it has an unexpected type. The value is defined in UDT as "${typeInfo.name}".`);
313
313
  }
314
314
  return {
315
315
  kind: 'STRUCT',
@@ -354,7 +354,7 @@ class UdtClaims {
354
354
  case models_1.LinkedCredential:
355
355
  return (0, converters_1.strictlyConvertToApiType)(serialization.ClaimsSchemaFieldsItem, Object.assign(Object.assign({}, draftBaseFieldValue), { kind: 'LINK', linkType: undefined }));
356
356
  default:
357
- throw new error_1.DocumentedError(error_1.ErrorCode.UnsupportedTypeInUDT, `Unsupported data type: ${tsDataType.name}. Please use one of the supported types.`);
357
+ throw new error_1.UdtError(error_1.UdtErrorCode.UnsupportedTypeInUDT, `Unsupported data type: ${tsDataType.name}. Please use one of the supported types.`);
358
358
  }
359
359
  }
360
360
  /**
@@ -1 +1 @@
1
- {"version":3,"file":"claims.js","sourceRoot":"","sources":["../../../src/documents/credential/claims.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mEAAqD;AACrD,8CAKuB;AACvB,sCAAuF;AACvF,oCAUkB;AAClB,oDAA8E;AAC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AAc,EAAE,gBAAgB,CAAC,cAAc;YAC/C,0BAA0B,EAAE,SAAS;SACxC,CAAC,CAAC;IACP,CAAC;CACJ;AAthBD,8BAshBC","sourcesContent":["import { ClaimsSchema, ClaimsSchemaFieldsItem, CredentialClaimValue, CredentialClaimValues } from '../../api';\nimport * as serialization from '../../serialization';\nimport {\n ClaimDescriptor,\n getRegisteredClaimsList,\n getTsDataTypeMetadata,\n getVcSchemaMetadataOrThrow,\n} from '../decorators';\nimport { LinkedCredential, LinkedFile, Rfc3339Date, Rfc3339DateTime } from '../models';\nimport {\n ApiClient,\n Claims,\n Ctor,\n isLinkedEntityDescriptor,\n isValueWithDataId,\n isValueWithId,\n ReadClaims,\n ReadDraftClaims,\n UserUpdateClaims,\n} from '../types';\nimport { StrictPartial, strictlyConvertToApiType } from '../utils/converters';\nimport { DocumentedError, ErrorCode } from '../utils/error';\nimport { Credential } from './credential';\nimport { DraftCredential } from './draft/draft';\nimport { ClaimsSchemaFieldValue, Json } from './types';\nimport { VerifiableCredential } from './verifiable/verifiable';\n\nexport class UdtClaims<T extends Claims> {\n constructor(\n protected client: ApiClient,\n protected claimsModel: Ctor<T>,\n ) {}\n\n private processValues<K extends Claims>(\n model: Ctor<any>,\n input: Json,\n processValue: (descriptor: ClaimDescriptor, value: unknown) => unknown,\n initialValue: K,\n ): K {\n return getRegisteredClaimsList(model).reduce((result, descriptor) => {\n if (descriptor.name in input) {\n const value: unknown = input[descriptor.name];\n let processedValue: unknown;\n\n if (descriptor.isArray) {\n if (value == null) {\n processedValue = null;\n } else if (Array.isArray(value)) {\n processedValue = value.map((item) => {\n return processValue(descriptor, item);\n });\n } else {\n throw new DocumentedError(\n ErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"Array\".`,\n );\n }\n } else {\n processedValue = processValue(descriptor, value);\n }\n Reflect.set(result, descriptor.name, processedValue);\n }\n\n return result;\n }, initialValue);\n }\n\n private processUdt<K extends Claims>(\n model: Ctor<any>,\n input: K,\n processValue: (descriptor: ClaimDescriptor, value: unknown) => CredentialClaimValue,\n initialValue: CredentialClaimValues,\n ): CredentialClaimValues {\n return getRegisteredClaimsList(model).reduce((result, descriptor) => {\n if (descriptor.name in input) {\n const value: unknown = input[descriptor.name];\n let processedValue: CredentialClaimValue | null;\n\n if (value == null) {\n return result;\n }\n if (descriptor.isArray) {\n if (Array.isArray(value)) {\n processedValue = {\n kind: 'ARRAY',\n value: value.map((item) => {\n return processValue(descriptor, item);\n }),\n };\n } else {\n throw new DocumentedError(\n ErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"Array\".`,\n );\n }\n } else {\n processedValue = processValue(descriptor, value);\n }\n Reflect.set(result, descriptor.name, processedValue);\n }\n\n return result;\n }, initialValue);\n }\n\n private processCredentialClaimValues<K extends Claims>(\n model: Ctor<any>,\n input: CredentialClaimValues,\n processValue: (descriptor: ClaimDescriptor, value: CredentialClaimValue) => unknown,\n initialValue: K,\n ): K {\n return getRegisteredClaimsList(model).reduce((result, descriptor) => {\n if (descriptor.name in input) {\n const value = input[descriptor.name];\n let processedValue: unknown;\n\n if (descriptor.isArray) {\n if (value == null) {\n processedValue = null;\n } else if (value.kind === 'ARRAY') {\n processedValue = value.value.map((item) => {\n return processValue(descriptor, item);\n });\n } else {\n throw new DocumentedError(\n ErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"Array\".`,\n );\n }\n } else {\n processedValue = processValue(descriptor, value);\n }\n Reflect.set(result, descriptor.name, processedValue);\n }\n\n return result;\n }, initialValue);\n }\n\n private getClaimTypeInfo(model: Ctor<any>, descriptor: ClaimDescriptor): Ctor<any> {\n const typeInfo = descriptor.nestedType ? descriptor.nestedType : getTsDataTypeMetadata(model, descriptor.name);\n\n if (typeInfo == null) {\n throw new Error(\n `Can't convert received value. Inconsistent data definition. Please reach out to support for assistance.`,\n );\n }\n\n return typeInfo;\n }\n\n /** convertCredentialClaimValuesToUdt maps and converts the API received claims values to the UDT claims model */\n protected convertCredentialClaimValuesToUdt<K extends Claims>(model: Ctor<any>, input: CredentialClaimValues): K {\n const processValue = (descriptor: ClaimDescriptor, value: CredentialClaimValue): unknown => {\n if (value == null) {\n return null;\n }\n\n const typeInfo = this.getClaimTypeInfo(model, descriptor);\n\n if (typeInfo === LinkedCredential) {\n if (value.kind !== 'LINK') {\n throw new DocumentedError(\n ErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"LinkedCredential\".`,\n );\n }\n return new LinkedCredential(this.client, value.value.id, value.value.digestMultibase);\n }\n\n if (typeInfo === LinkedFile) {\n if (value.kind !== 'FILE') {\n throw new DocumentedError(\n ErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"LinkedFile\".`,\n );\n }\n return new LinkedFile(this.client, value.value.id, value.value.digestMultibase);\n }\n\n if (typeInfo === Date) {\n if (value.kind !== 'DATETIME') {\n throw new DocumentedError(\n ErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"Date\".`,\n );\n }\n return new Date(value.value);\n }\n\n if (typeInfo === Rfc3339DateTime) {\n if (value.kind !== 'DATETIME') {\n throw new DocumentedError(\n ErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"Rfc3339DateTime\".`,\n );\n }\n return new Rfc3339DateTime(value.value);\n }\n\n if (typeInfo === Rfc3339Date) {\n if (value.kind !== 'DATE') {\n throw new DocumentedError(\n ErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"Rfc3339Date\".`,\n );\n }\n return new Rfc3339Date(value.value);\n }\n\n if (typeInfo === String) {\n if (value.kind !== 'STRING') {\n throw new DocumentedError(\n ErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"string\".`,\n );\n }\n\n return value.value;\n }\n\n if (typeInfo === Number) {\n if (value.kind !== 'NUMBER') {\n throw new DocumentedError(\n ErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"number\".`,\n );\n }\n\n return value.value;\n }\n\n if (typeInfo === Boolean) {\n if (value.kind !== 'BOOLEAN') {\n throw new DocumentedError(\n ErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"boolean\".`,\n );\n }\n\n return value.value;\n }\n\n if (value.kind !== 'STRUCT') {\n throw new DocumentedError(\n ErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"${typeInfo.name}\".`,\n );\n }\n\n return this.convertCredentialClaimValuesToUdt(typeInfo, value.value);\n };\n\n return this.processCredentialClaimValues<K>(model, input, processValue, new model());\n }\n\n /** convertApiValuesToUdt maps and converts the API received claims values to the UDT claims model */\n protected convertApiValuesToUdt<K extends Claims>(model: Ctor<any>, input: Json): K {\n const processValue = (descriptor: ClaimDescriptor, value: unknown): unknown => {\n if (value == null) {\n return null;\n }\n\n const typeInfo = this.getClaimTypeInfo(model, descriptor);\n\n if (isLinkedEntityDescriptor(value)) {\n if (typeInfo === LinkedCredential) {\n return new LinkedCredential(this.client, value.id, value.digestMultibase);\n }\n\n if (typeInfo === LinkedFile) {\n return new LinkedFile(this.client, value.id, value.digestMultibase);\n }\n }\n\n if (typeInfo === Date) {\n if (typeof value !== 'string') {\n throw new DocumentedError(\n ErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"Date\".`,\n );\n }\n return new Date(value);\n }\n\n if (typeInfo === Rfc3339DateTime) {\n if (typeof value !== 'string') {\n throw new DocumentedError(\n ErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"Rfc3339DateTime\".`,\n );\n }\n return new Rfc3339DateTime(value);\n }\n\n if (typeInfo === Rfc3339Date) {\n if (typeof value !== 'string') {\n throw new DocumentedError(\n ErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"Rfc3339Date\".`,\n );\n }\n return new Rfc3339Date(value);\n }\n\n // Primitive values should be returned as-is\n if (Array.of<Ctor<any>>(String, Number, Boolean, Object).includes(typeInfo)) {\n return value;\n }\n\n if (!(value instanceof Object)) {\n throw new DocumentedError(\n ErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"${typeInfo.name}\".`,\n );\n }\n return this.convertApiValuesToUdt(typeInfo, value);\n };\n\n return this.processValues<K>(model, input, processValue, new model());\n }\n\n /** convertUdtToApiValues maps and converts the user received claims values onto UDT claims model */\n protected convertUdtToCredentialClaimValues<K extends Claims>(model: Ctor<any>, input: K): CredentialClaimValues {\n const processValue = (descriptor: ClaimDescriptor, value: unknown): CredentialClaimValue => {\n const typeInfo = this.getClaimTypeInfo(model, descriptor);\n\n if (typeInfo === LinkedCredential) {\n if (value instanceof LinkedCredential) {\n return value.toJSON();\n }\n\n if (\n value instanceof VerifiableCredential ||\n value instanceof DraftCredential ||\n value instanceof Credential\n ) {\n return value.toLinkedCredential().toJSON();\n }\n\n if (isValueWithId(value)) {\n return LinkedCredential.createCredentialClaimValue(value.id, value.digestMultibase);\n }\n\n throw new DocumentedError(\n ErrorCode.UnexpectedTypeInSerialization,\n 'Invalid value for linked credential',\n );\n }\n\n if (typeInfo === LinkedFile) {\n if (value instanceof LinkedFile) {\n return value.toJSON();\n }\n\n if (isValueWithDataId(value)) {\n return LinkedFile.createCredentialClaimValue(value.data.id, value.data.digestMultibase);\n }\n\n if (isValueWithId(value)) {\n return LinkedFile.createCredentialClaimValue(value.id, value.digestMultibase);\n }\n\n throw new DocumentedError(ErrorCode.UnexpectedTypeInSerialization, 'Invalid value for linked file');\n }\n\n if (typeInfo === String && typeof value === 'string') {\n return {\n kind: 'STRING',\n value,\n };\n }\n\n if (typeInfo === Number && typeof value === 'number') {\n return {\n kind: 'NUMBER',\n value,\n };\n }\n\n if (typeInfo === Date && value instanceof Date) {\n return {\n kind: 'DATETIME',\n value,\n };\n }\n\n if (typeInfo === Rfc3339Date && value instanceof Rfc3339Date) {\n return {\n kind: 'DATE',\n value: value.toString(),\n };\n }\n\n if (typeInfo === Rfc3339DateTime && value instanceof Rfc3339DateTime) {\n return {\n kind: 'DATETIME',\n value: value.toDate(),\n };\n }\n\n if (typeInfo === Boolean && typeof value === 'boolean') {\n return {\n kind: 'BOOLEAN',\n value,\n };\n }\n\n if (!(value instanceof Object)) {\n throw new DocumentedError(\n ErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"${typeInfo.name}\".`,\n );\n }\n\n return {\n kind: 'STRUCT',\n value: this.convertUdtToCredentialClaimValues(typeInfo, value),\n };\n };\n return this.processUdt(model, input, processValue, {});\n }\n\n protected mapClaimDescriptorToClaimsSchemaFieldItem(\n claim: ClaimDescriptor,\n claimsModel: Ctor<any>,\n ): ClaimsSchemaFieldsItem {\n const draftBaseFieldValue: StrictPartial<ClaimsSchemaFieldValue> = {\n name: claim.name,\n title: claim.title,\n notEmpty: claim.notEmpty,\n isArray: claim.isArray || undefined,\n };\n\n if (\n claim.nestedType &&\n !Array.of<Ctor<any>>(\n String,\n Number,\n Date,\n Rfc3339DateTime,\n Rfc3339Date,\n Boolean,\n LinkedFile,\n LinkedCredential,\n ).includes(claim.nestedType)\n ) {\n const claimNestedType = claim.nestedType;\n const nestedVcSchemaMetadata = getVcSchemaMetadataOrThrow(claimNestedType);\n\n return strictlyConvertToApiType(serialization.ClaimsSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'STRUCT',\n fields: getRegisteredClaimsList(claimNestedType).map((nestedClaim) => {\n return this.mapClaimDescriptorToClaimsSchemaFieldItem(nestedClaim, claimNestedType);\n }),\n jsonLdIri: undefined,\n jsonLdBaseIri: nestedVcSchemaMetadata.jsonLdBaseIri,\n jsonLdTermName: nestedVcSchemaMetadata.jsonLdTermName,\n jsonLdRelativeIriDelimiter: undefined,\n });\n }\n\n const tsDataType = claim.nestedType || getTsDataTypeMetadata(claimsModel, claim.name);\n\n if (!tsDataType) {\n throw new Error(\n `The information about the VC claim data type was not found for the \"${claim.name}\" property. Ensure that \"emitDecoratorMetadata\" is enabled in your \"tsconfig.json\".`,\n );\n }\n\n switch (tsDataType) {\n case String:\n return strictlyConvertToApiType(serialization.ClaimsSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'STRING',\n enum: claim.enumValuesDescriptor,\n jsonLdIri: claim.jsonLdIri,\n jsonLdType: claim.jsonLdType,\n });\n case Number:\n return strictlyConvertToApiType(serialization.ClaimsSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'NUMBER',\n jsonLdIri: claim.jsonLdIri,\n jsonLdType: claim.jsonLdType,\n });\n case Boolean:\n return strictlyConvertToApiType(serialization.ClaimsSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'BOOLEAN',\n jsonLdIri: claim.jsonLdIri,\n jsonLdType: claim.jsonLdType,\n });\n case Rfc3339Date:\n return strictlyConvertToApiType(serialization.ClaimsSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'DATE',\n jsonLdIri: claim.jsonLdIri,\n jsonLdType: claim.jsonLdType,\n });\n case Rfc3339DateTime:\n case Date:\n return strictlyConvertToApiType(serialization.ClaimsSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'DATETIME',\n jsonLdIri: claim.jsonLdIri,\n jsonLdType: claim.jsonLdType,\n });\n case LinkedFile:\n return strictlyConvertToApiType(serialization.ClaimsSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'FILE',\n });\n case LinkedCredential:\n return strictlyConvertToApiType(serialization.ClaimsSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'LINK',\n linkType: undefined,\n });\n default:\n throw new DocumentedError(\n ErrorCode.UnsupportedTypeInUDT,\n `Unsupported data type: ${tsDataType.name}. Please use one of the supported types.`,\n );\n }\n }\n\n /**\n * Marshalling is the process of transforming the internal representation of values to a data format suitable\n * for transmission.\n */\n marshalValues(input: UserUpdateClaims<T>): Claims {\n return this.convertUdtToCredentialClaimValues(this.claimsModel, input);\n }\n\n /**\n * Unmarshalling is the reverse process of marshalling. It involves converting data from a serialized format back\n * into an internal representation.\n */\n unmarshalValuesToDraft(input: CredentialClaimValues): ReadDraftClaims<T> {\n return this.convertCredentialClaimValuesToUdt(this.claimsModel, input);\n }\n\n unmarshalValuesToCredential(input: Json): ReadClaims<T> {\n return this.convertApiValuesToUdt(this.claimsModel, input);\n }\n\n getClaimsSchema(): ClaimsSchema {\n const vcSchemaMetadata = getVcSchemaMetadataOrThrow(this.claimsModel);\n\n return strictlyConvertToApiType(serialization.ClaimsSchema, {\n fields: getRegisteredClaimsList(this.claimsModel).map((claim) =>\n this.mapClaimDescriptorToClaimsSchemaFieldItem(claim, this.claimsModel),\n ),\n jsonLdBaseIri: vcSchemaMetadata.jsonLdBaseIri,\n jsonLdIri: undefined,\n jsonLdTermName: vcSchemaMetadata.jsonLdTermName,\n jsonLdRelativeIriDelimiter: undefined,\n });\n }\n}\n"]}
1
+ {"version":3,"file":"claims.js","sourceRoot":"","sources":["../../../src/documents/credential/claims.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AACA,mEAAqD;AACrD,8CAKuB;AACvB,oCAAkD;AAClD,sCAAuF;AACvF,oCAUkB;AAClB,oDAA8E;AAC9E,6CAA0C;AAC1C,yCAAgD;AAEhD,wDAA+D;AAE/D,MAAa,SAAS;IAClB,YACc,MAAiB,EACjB,WAAoB;QADpB,WAAM,GAAN,MAAM,CAAW;QACjB,gBAAW,GAAX,WAAW,CAAS;IAC/B,CAAC;IAEI,aAAa,CACjB,KAAgB,EAChB,KAAW,EACX,YAAsE,EACtE,YAAe;QAEf,OAAO,IAAA,oCAAuB,EAAC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AmB,KACtB,IAAI,EAAE,MAAM,EACZ,QAAQ,EAAE,SAAS,IACrB,CAAC;YACP;gBACI,MAAM,IAAI,gBAAQ,CACd,oBAAY,CAAC,oBAAoB,EACjC,0BAA0B,UAAU,CAAC,IAAI,0CAA0C,CACtF,CAAC;QACV,CAAC;IACL,CAAC;IAED;;;OAGG;IACH,aAAa,CAAC,KAA0B;QACpC,OAAO,IAAI,CAAC,iCAAiC,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC3E,CAAC;IAED;;;OAGG;IACH,sBAAsB,CAAC,KAA4B;QAC/C,OAAO,IAAI,CAAC,iCAAiC,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC3E,CAAC;IAED,2BAA2B,CAAC,KAAW;QACnC,OAAO,IAAI,CAAC,qBAAqB,CAAC,IAAI,CAAC,WAAW,EAAE,KAAK,CAAC,CAAC;IAC/D,CAAC;IAED,eAAe;QACX,MAAM,gBAAgB,GAAG,IAAA,uCAA0B,EAAC,IAAI,CAAC,WAAW,CAAC,CAAC;QAEtE,OAAO,IAAA,qCAAwB,EAAC,aAAa,CAAC,YAAY,EAAE;YACxD,MAAM,EAAE,IAAA,oCAAuB,EAAC,IAAI,CAAC,WAAW,CAAC,CAAC,GAAG,CAAC,CAAC,KAAK,EAAE,EAAE,CAC5D,IAAI,CAAC,yCAAyC,CAAC,KAAK,EAAE,IAAI,CAAC,WAAW,CAAC,CAC1E;YACD,aAAa,EAAE,gBAAgB,CAAC,aAAa;YAC7C,SAAS,EAAE,SAAS;YACpB,cAAc,EAAE,gBAAgB,CAAC,cAAc;YAC/C,0BAA0B,EAAE,SAAS;SACxC,CAAC,CAAC;IACP,CAAC;CACJ;AAnhBD,8BAmhBC","sourcesContent":["import { ClaimsSchema, ClaimsSchemaFieldsItem, CredentialClaimValue, CredentialClaimValues } from '../../api';\nimport * as serialization from '../../serialization';\nimport {\n ClaimDescriptor,\n getRegisteredClaimsList,\n getTsDataTypeMetadata,\n getVcSchemaMetadataOrThrow,\n} from '../decorators';\nimport { UdtError, UdtErrorCode } from '../error';\nimport { LinkedCredential, LinkedFile, Rfc3339Date, Rfc3339DateTime } from '../models';\nimport {\n ApiClient,\n Claims,\n Ctor,\n isLinkedEntityDescriptor,\n isValueWithDataId,\n isValueWithId,\n ReadClaims,\n ReadDraftClaims,\n UserUpdateClaims,\n} from '../types';\nimport { StrictPartial, strictlyConvertToApiType } from '../utils/converters';\nimport { Credential } from './credential';\nimport { DraftCredential } from './draft/draft';\nimport { ClaimsSchemaFieldValue, Json } from './types';\nimport { VerifiableCredential } from './verifiable/verifiable';\n\nexport class UdtClaims<T extends Claims> {\n constructor(\n protected client: ApiClient,\n protected claimsModel: Ctor<T>,\n ) {}\n\n private processValues<K extends Claims>(\n model: Ctor<any>,\n input: Json,\n processValue: (descriptor: ClaimDescriptor, value: unknown) => unknown,\n initialValue: K,\n ): K {\n return getRegisteredClaimsList(model).reduce((result, descriptor) => {\n if (descriptor.name in input) {\n const value: unknown = input[descriptor.name];\n let processedValue: unknown;\n\n if (descriptor.isArray) {\n if (value == null) {\n processedValue = null;\n } else if (Array.isArray(value)) {\n processedValue = value.map((item) => {\n return processValue(descriptor, item);\n });\n } else {\n throw new UdtError(\n UdtErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"Array\".`,\n );\n }\n } else {\n processedValue = processValue(descriptor, value);\n }\n Reflect.set(result, descriptor.name, processedValue);\n }\n\n return result;\n }, initialValue);\n }\n\n private processUdt<K extends Claims>(\n model: Ctor<any>,\n input: K,\n processValue: (descriptor: ClaimDescriptor, value: unknown) => CredentialClaimValue,\n initialValue: CredentialClaimValues,\n ): CredentialClaimValues {\n return getRegisteredClaimsList(model).reduce((result, descriptor) => {\n if (descriptor.name in input) {\n const value: unknown = input[descriptor.name];\n let processedValue: CredentialClaimValue | null;\n\n if (value == null) {\n return result;\n }\n if (descriptor.isArray) {\n if (Array.isArray(value)) {\n processedValue = {\n kind: 'ARRAY',\n value: value.map((item) => {\n return processValue(descriptor, item);\n }),\n };\n } else {\n throw new UdtError(\n UdtErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"Array\".`,\n );\n }\n } else {\n processedValue = processValue(descriptor, value);\n }\n Reflect.set(result, descriptor.name, processedValue);\n }\n\n return result;\n }, initialValue);\n }\n\n private processCredentialClaimValues<K extends Claims>(\n model: Ctor<any>,\n input: CredentialClaimValues,\n processValue: (descriptor: ClaimDescriptor, value: CredentialClaimValue) => unknown,\n initialValue: K,\n ): K {\n return getRegisteredClaimsList(model).reduce((result, descriptor) => {\n if (descriptor.name in input) {\n const value = input[descriptor.name];\n let processedValue: unknown;\n\n if (descriptor.isArray) {\n if (value == null) {\n processedValue = null;\n } else if (value.kind === 'ARRAY') {\n processedValue = value.value.map((item) => {\n return processValue(descriptor, item);\n });\n } else {\n throw new UdtError(\n UdtErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"Array\".`,\n );\n }\n } else {\n processedValue = processValue(descriptor, value);\n }\n Reflect.set(result, descriptor.name, processedValue);\n }\n\n return result;\n }, initialValue);\n }\n\n private getClaimTypeInfo(model: Ctor<any>, descriptor: ClaimDescriptor): Ctor<any> {\n const typeInfo = descriptor.nestedType ? descriptor.nestedType : getTsDataTypeMetadata(model, descriptor.name);\n\n if (typeInfo == null) {\n throw new Error(\n `Can't convert received value. Inconsistent data definition. Please reach out to support for assistance.`,\n );\n }\n\n return typeInfo;\n }\n\n /** convertCredentialClaimValuesToUdt maps and converts the API received claims values to the UDT claims model */\n protected convertCredentialClaimValuesToUdt<K extends Claims>(model: Ctor<any>, input: CredentialClaimValues): K {\n const processValue = (descriptor: ClaimDescriptor, value: CredentialClaimValue): unknown => {\n if (value == null) {\n return null;\n }\n\n const typeInfo = this.getClaimTypeInfo(model, descriptor);\n\n if (typeInfo === LinkedCredential) {\n if (value.kind !== 'LINK') {\n throw new UdtError(\n UdtErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"LinkedCredential\".`,\n );\n }\n return new LinkedCredential(this.client, value.value.id, value.value.digestMultibase);\n }\n\n if (typeInfo === LinkedFile) {\n if (value.kind !== 'FILE') {\n throw new UdtError(\n UdtErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"LinkedFile\".`,\n );\n }\n return new LinkedFile(this.client, value.value.id, value.value.digestMultibase);\n }\n\n if (typeInfo === Date) {\n if (value.kind !== 'DATETIME') {\n throw new UdtError(\n UdtErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"Date\".`,\n );\n }\n return new Date(value.value);\n }\n\n if (typeInfo === Rfc3339DateTime) {\n if (value.kind !== 'DATETIME') {\n throw new UdtError(\n UdtErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"Rfc3339DateTime\".`,\n );\n }\n return new Rfc3339DateTime(value.value);\n }\n\n if (typeInfo === Rfc3339Date) {\n if (value.kind !== 'DATE') {\n throw new UdtError(\n UdtErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"Rfc3339Date\".`,\n );\n }\n return new Rfc3339Date(value.value);\n }\n\n if (typeInfo === String) {\n if (value.kind !== 'STRING') {\n throw new UdtError(\n UdtErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"string\".`,\n );\n }\n\n return value.value;\n }\n\n if (typeInfo === Number) {\n if (value.kind !== 'NUMBER') {\n throw new UdtError(\n UdtErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"number\".`,\n );\n }\n\n return value.value;\n }\n\n if (typeInfo === Boolean) {\n if (value.kind !== 'BOOLEAN') {\n throw new UdtError(\n UdtErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"boolean\".`,\n );\n }\n\n return value.value;\n }\n\n if (value.kind !== 'STRUCT') {\n throw new UdtError(\n UdtErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"${typeInfo.name}\".`,\n );\n }\n\n return this.convertCredentialClaimValuesToUdt(typeInfo, value.value);\n };\n\n return this.processCredentialClaimValues<K>(model, input, processValue, new model());\n }\n\n /** convertApiValuesToUdt maps and converts the API received claims values to the UDT claims model */\n protected convertApiValuesToUdt<K extends Claims>(model: Ctor<any>, input: Json): K {\n const processValue = (descriptor: ClaimDescriptor, value: unknown): unknown => {\n if (value == null) {\n return null;\n }\n\n const typeInfo = this.getClaimTypeInfo(model, descriptor);\n\n if (isLinkedEntityDescriptor(value)) {\n if (typeInfo === LinkedCredential) {\n return new LinkedCredential(this.client, value.id, value.digestMultibase);\n }\n\n if (typeInfo === LinkedFile) {\n return new LinkedFile(this.client, value.id, value.digestMultibase);\n }\n }\n\n if (typeInfo === Date) {\n if (typeof value !== 'string') {\n throw new UdtError(\n UdtErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"Date\".`,\n );\n }\n return new Date(value);\n }\n\n if (typeInfo === Rfc3339DateTime) {\n if (typeof value !== 'string') {\n throw new UdtError(\n UdtErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"Rfc3339DateTime\".`,\n );\n }\n return new Rfc3339DateTime(value);\n }\n\n if (typeInfo === Rfc3339Date) {\n if (typeof value !== 'string') {\n throw new UdtError(\n UdtErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"Rfc3339Date\".`,\n );\n }\n return new Rfc3339Date(value);\n }\n\n // Primitive values should be returned as-is\n if (Array.of<Ctor<any>>(String, Number, Boolean, Object).includes(typeInfo)) {\n return value;\n }\n\n if (!(value instanceof Object)) {\n throw new UdtError(\n UdtErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"${typeInfo.name}\".`,\n );\n }\n return this.convertApiValuesToUdt(typeInfo, value);\n };\n\n return this.processValues<K>(model, input, processValue, new model());\n }\n\n /** convertUdtToApiValues maps and converts the user received claims values onto UDT claims model */\n protected convertUdtToCredentialClaimValues<K extends Claims>(model: Ctor<any>, input: K): CredentialClaimValues {\n const processValue = (descriptor: ClaimDescriptor, value: unknown): CredentialClaimValue => {\n const typeInfo = this.getClaimTypeInfo(model, descriptor);\n\n if (typeInfo === LinkedCredential) {\n if (value instanceof LinkedCredential) {\n return value.toJSON();\n }\n\n if (\n value instanceof VerifiableCredential ||\n value instanceof DraftCredential ||\n value instanceof Credential\n ) {\n return value.toLinkedCredential().toJSON();\n }\n\n if (isValueWithId(value)) {\n return LinkedCredential.createCredentialClaimValue(value.id, value.digestMultibase);\n }\n\n throw new UdtError(UdtErrorCode.UnexpectedTypeInSerialization, 'Invalid value for linked credential');\n }\n\n if (typeInfo === LinkedFile) {\n if (value instanceof LinkedFile) {\n return value.toJSON();\n }\n\n if (isValueWithDataId(value)) {\n return LinkedFile.createCredentialClaimValue(value.data.id, value.data.digestMultibase);\n }\n\n if (isValueWithId(value)) {\n return LinkedFile.createCredentialClaimValue(value.id, value.digestMultibase);\n }\n\n throw new UdtError(UdtErrorCode.UnexpectedTypeInSerialization, 'Invalid value for linked file');\n }\n\n if (typeInfo === String && typeof value === 'string') {\n return {\n kind: 'STRING',\n value,\n };\n }\n\n if (typeInfo === Number && typeof value === 'number') {\n return {\n kind: 'NUMBER',\n value,\n };\n }\n\n if (typeInfo === Date && value instanceof Date) {\n return {\n kind: 'DATETIME',\n value,\n };\n }\n\n if (typeInfo === Rfc3339Date && value instanceof Rfc3339Date) {\n return {\n kind: 'DATE',\n value: value.toString(),\n };\n }\n\n if (typeInfo === Rfc3339DateTime && value instanceof Rfc3339DateTime) {\n return {\n kind: 'DATETIME',\n value: value.toDate(),\n };\n }\n\n if (typeInfo === Boolean && typeof value === 'boolean') {\n return {\n kind: 'BOOLEAN',\n value,\n };\n }\n\n if (!(value instanceof Object)) {\n throw new UdtError(\n UdtErrorCode.UnexpectedTypeInSerialization,\n `Can't convert received value as it has an unexpected type. The value is defined in UDT as \"${typeInfo.name}\".`,\n );\n }\n\n return {\n kind: 'STRUCT',\n value: this.convertUdtToCredentialClaimValues(typeInfo, value),\n };\n };\n return this.processUdt(model, input, processValue, {});\n }\n\n protected mapClaimDescriptorToClaimsSchemaFieldItem(\n claim: ClaimDescriptor,\n claimsModel: Ctor<any>,\n ): ClaimsSchemaFieldsItem {\n const draftBaseFieldValue: StrictPartial<ClaimsSchemaFieldValue> = {\n name: claim.name,\n title: claim.title,\n notEmpty: claim.notEmpty,\n isArray: claim.isArray || undefined,\n };\n\n if (\n claim.nestedType &&\n !Array.of<Ctor<any>>(\n String,\n Number,\n Date,\n Rfc3339DateTime,\n Rfc3339Date,\n Boolean,\n LinkedFile,\n LinkedCredential,\n ).includes(claim.nestedType)\n ) {\n const claimNestedType = claim.nestedType;\n const nestedVcSchemaMetadata = getVcSchemaMetadataOrThrow(claimNestedType);\n\n return strictlyConvertToApiType(serialization.ClaimsSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'STRUCT',\n fields: getRegisteredClaimsList(claimNestedType).map((nestedClaim) => {\n return this.mapClaimDescriptorToClaimsSchemaFieldItem(nestedClaim, claimNestedType);\n }),\n jsonLdIri: undefined,\n jsonLdBaseIri: nestedVcSchemaMetadata.jsonLdBaseIri,\n jsonLdTermName: nestedVcSchemaMetadata.jsonLdTermName,\n jsonLdRelativeIriDelimiter: undefined,\n });\n }\n\n const tsDataType = claim.nestedType || getTsDataTypeMetadata(claimsModel, claim.name);\n\n if (!tsDataType) {\n throw new Error(\n `The information about the VC claim data type was not found for the \"${claim.name}\" property. Ensure that \"emitDecoratorMetadata\" is enabled in your \"tsconfig.json\".`,\n );\n }\n\n switch (tsDataType) {\n case String:\n return strictlyConvertToApiType(serialization.ClaimsSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'STRING',\n enum: claim.enumValuesDescriptor,\n jsonLdIri: claim.jsonLdIri,\n jsonLdType: claim.jsonLdType,\n });\n case Number:\n return strictlyConvertToApiType(serialization.ClaimsSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'NUMBER',\n jsonLdIri: claim.jsonLdIri,\n jsonLdType: claim.jsonLdType,\n });\n case Boolean:\n return strictlyConvertToApiType(serialization.ClaimsSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'BOOLEAN',\n jsonLdIri: claim.jsonLdIri,\n jsonLdType: claim.jsonLdType,\n });\n case Rfc3339Date:\n return strictlyConvertToApiType(serialization.ClaimsSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'DATE',\n jsonLdIri: claim.jsonLdIri,\n jsonLdType: claim.jsonLdType,\n });\n case Rfc3339DateTime:\n case Date:\n return strictlyConvertToApiType(serialization.ClaimsSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'DATETIME',\n jsonLdIri: claim.jsonLdIri,\n jsonLdType: claim.jsonLdType,\n });\n case LinkedFile:\n return strictlyConvertToApiType(serialization.ClaimsSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'FILE',\n });\n case LinkedCredential:\n return strictlyConvertToApiType(serialization.ClaimsSchemaFieldsItem, {\n ...draftBaseFieldValue,\n kind: 'LINK',\n linkType: undefined,\n });\n default:\n throw new UdtError(\n UdtErrorCode.UnsupportedTypeInUDT,\n `Unsupported data type: ${tsDataType.name}. Please use one of the supported types.`,\n );\n }\n }\n\n /**\n * Marshalling is the process of transforming the internal representation of values to a data format suitable\n * for transmission.\n */\n marshalValues(input: UserUpdateClaims<T>): Claims {\n return this.convertUdtToCredentialClaimValues(this.claimsModel, input);\n }\n\n /**\n * Unmarshalling is the reverse process of marshalling. It involves converting data from a serialized format back\n * into an internal representation.\n */\n unmarshalValuesToDraft(input: CredentialClaimValues): ReadDraftClaims<T> {\n return this.convertCredentialClaimValuesToUdt(this.claimsModel, input);\n }\n\n unmarshalValuesToCredential(input: Json): ReadClaims<T> {\n return this.convertApiValuesToUdt(this.claimsModel, input);\n }\n\n getClaimsSchema(): ClaimsSchema {\n const vcSchemaMetadata = getVcSchemaMetadataOrThrow(this.claimsModel);\n\n return strictlyConvertToApiType(serialization.ClaimsSchema, {\n fields: getRegisteredClaimsList(this.claimsModel).map((claim) =>\n this.mapClaimDescriptorToClaimsSchemaFieldItem(claim, this.claimsModel),\n ),\n jsonLdBaseIri: vcSchemaMetadata.jsonLdBaseIri,\n jsonLdIri: undefined,\n jsonLdTermName: vcSchemaMetadata.jsonLdTermName,\n jsonLdRelativeIriDelimiter: undefined,\n });\n }\n}\n"]}
@@ -6,7 +6,7 @@ import { VerifiableCredentialWithClaims } from './credential/verifiable/with-cla
6
6
  import { ApiClient, BlobInput, Ctor, UpdatePayload, UpdatePayloadWithIssueClaims } from './types';
7
7
  export type SchemaPublicationResult = {
8
8
  published: boolean;
9
- error?: string;
9
+ error?: Error;
10
10
  };
11
11
  export type CredentialEnvelope<T extends Claims> = {
12
12
  isVerifiable: false;
@@ -1 +1 @@
1
- {"version":3,"file":"credential.d.ts","sourceRoot":"","sources":["../../src/documents/credential.ts"],"names":[],"mappings":"AACA,OAAO,EAKH,kBAAkB,EAClB,aAAa,EAChB,MAAM,QAAQ,CAAC;AAGhB,OAAO,EAAE,yBAAyB,EAAE,MAAM,gCAAgC,CAAC;AAC3E,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AACvD,OAAO,EAAE,MAAM,EAAE,uBAAuB,EAAE,MAAM,oBAAoB,CAAC;AACrE,OAAO,EAAE,8BAA8B,EAAE,MAAM,qCAAqC,CAAC;AAGrF,OAAO,EACH,SAAS,EACT,SAAS,EAET,IAAI,EAEJ,aAAa,EACb,4BAA4B,EAE/B,MAAM,SAAS,CAAC;AAKjB,MAAM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AO,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC;IAWnF,KAAK,CACP,YAAY,EAAE,MAAM,EACpB,OAAO,EAAE,4BAA4B,CAAC,CAAC,CAAC,GACzC,OAAO,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAAC;IAKvC,WAAW,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,yBAAyB,CAAC,CAAC,CAAC,CAAC;IAQjF,gBAAgB,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAAC;IAQ3F,IAAI,CAAC,EAAE,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,CAAC,CAAC,CAAC,CAAC;IA2BjE,gBAAgB,CAAC,IAAI,EAAE,SAAS,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,8BAA8B,CAAC,CAAC,CAAC,CAAC;CAK/G"}
@@ -24,16 +24,15 @@ Object.defineProperty(exports, "__esModule", { value: true });
24
24
  exports.VcDecorator = void 0;
25
25
  const mem_1 = __importDefault(require("mem"));
26
26
  const api_1 = require("../api");
27
- const errors_1 = require("../errors");
28
27
  const claims_1 = require("./credential/claims");
29
28
  const with_claims_1 = require("./credential/draft/with-claims");
30
29
  const flavor_1 = require("./credential/flavor");
31
30
  const with_claims_2 = require("./credential/verifiable/with-claims");
32
31
  const decorators_1 = require("./decorators");
32
+ const error_1 = require("./error");
33
33
  const schemas_1 = require("./schemas");
34
34
  const types_1 = require("./types");
35
35
  const converters_1 = require("./utils/converters");
36
- const error_1 = require("./utils/error");
37
36
  const idempotency_1 = require("./utils/idempotency");
38
37
  class VcDecorator {
39
38
  constructor(client, claimsModel) {
@@ -49,10 +48,16 @@ class VcDecorator {
49
48
  publishSchema() {
50
49
  return __awaiter(this, void 0, void 0, function* () {
51
50
  if (this.vcSchemaMetadata.slug == null) {
52
- return { published: false, error: 'A schema requires a slug to be published as stable' };
51
+ return {
52
+ published: false,
53
+ error: new error_1.UdtError(error_1.UdtErrorCode.VcSchemaMissingSlug, `A schema requires a slug to be published as stable`),
54
+ };
53
55
  }
54
56
  if (this.vcSchemaMetadata.owner != null && this.vcSchemaMetadata.owner !== (yield this.client.tenantId())) {
55
- return { published: false, error: 'A schema with a different owner cannot be published' };
57
+ return {
58
+ published: false,
59
+ error: new error_1.UdtError(error_1.UdtErrorCode.VcSchemaDifferentOwner, `It's not possible to publish a schema to a tenant different from the configured one.`),
60
+ };
56
61
  }
57
62
  try {
58
63
  const credentialSchema = yield this.client.schemas.schemaCreate({
@@ -67,8 +72,8 @@ class VcDecorator {
67
72
  return { published: true };
68
73
  }
69
74
  catch (error) {
70
- if (error instanceof errors_1.TruvityError) {
71
- return { published: false, error: error.message };
75
+ if (error instanceof Error) {
76
+ return { published: false, error };
72
77
  }
73
78
  throw error;
74
79
  }
@@ -91,7 +96,7 @@ class VcDecorator {
91
96
  publishedCredentialSchema = yield this.client.desk.publishedMetaSchemaFetch(this.vcSchemaMetadata.owner, this.vcSchemaMetadata.slug, this.vcSchemaMetadata.version);
92
97
  }
93
98
  else {
94
- throw new error_1.DocumentedError(error_1.ErrorCode.VcSchemaMissingSlug, 'A VcSchema annotation with an owner value requires a slug value');
99
+ throw new error_1.UdtError(error_1.UdtErrorCode.VcSchemaMissingSlug, 'A VcSchema annotation with an owner value requires a slug value');
95
100
  }
96
101
  if (publishedCredentialSchema.schema.jsonLdTermName != null) {
97
102
  return `${publishedCredentialSchema.schema.jsonLdTermName}Credential`;
@@ -109,14 +114,14 @@ class VcDecorator {
109
114
  if ((0, types_1.isResourceCredential)(input)) {
110
115
  // ResourceCredential
111
116
  if (!(yield this.canMap(input))) {
112
- throw new error_1.DocumentedError(error_1.ErrorCode.IncompatibleUDT, `The received ResourceCredential is incompatible with the current VcDecorator instance claims model`);
117
+ throw new error_1.UdtError(error_1.UdtErrorCode.IncompatibleUDT, `The received ResourceCredential is incompatible with the current VcDecorator instance claims model`);
113
118
  }
114
119
  return new with_claims_2.VerifiableCredentialWithClaims(this.client, this.flavor, this.claimsModel, input);
115
120
  }
116
121
  else {
117
122
  // ResourceDraft
118
123
  if (!(yield this.canMap(input))) {
119
- throw new error_1.DocumentedError(error_1.ErrorCode.IncompatibleUDT, `The received ResourceDraft is incompatible with the current VcDecorator instance claims model`);
124
+ throw new error_1.UdtError(error_1.UdtErrorCode.IncompatibleUDT, `The received ResourceDraft is incompatible with the current VcDecorator instance claims model`);
120
125
  }
121
126
  return new with_claims_1.DraftCredentialWithClaims(this.client, this.flavor, this.claimsModel, input.data, input);
122
127
  }
@@ -197,7 +202,7 @@ class VcDecorator {
197
202
  }
198
203
  }
199
204
  else {
200
- throw new error_1.DocumentedError(error_1.ErrorCode.VcSchemaMissingSlug, 'A VcSchema annotation with an owner value requires a slug value');
205
+ throw new error_1.UdtError(error_1.UdtErrorCode.VcSchemaMissingSlug, 'A VcSchema annotation with an owner value requires a slug value');
201
206
  }
202
207
  return {
203
208
  metaSchema,
@@ -1 +1 @@
1
- {"version":3,"file":"credential.js","sourceRoot":"","sources":["../../src/documents/credential.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAsB;AACtB,gCAOgB;AAChB,sCAAyC;AACzC,gDAAgD;AAChD,gEAA2E;AAC3E,gDAAuD;AAEvD,qEAAqF;AACrF,6CAAsF;AACtF,uCAA2D;AAC3D,mCASiB;AACjB,mDAA8D;AAC9D,yCAA2D;AAC3D,qDAAkD;AAmBlD,MAAa,WAAW;IAKpB,YACY,MAAiB,EACjB,WAAoB;QADpB,WAAM,GAAN,MAAM,CAAW;QACjB,gBAAW,GAAX,WAAW,CAAS;QANvB,WAAM,GAAG,IAAI,CAAC,sBAAsB,EAAE,CAAC;QACxC,WAAM,GAAG,IAAI,kBAAS,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WA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AAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACtG,CAAC;KAAA;CACJ;AA5QD,kCA4QC;AAjOS;IADL,aAAG,CAAC,SAAS,EAAE;;;;oDA4Bf","sourcesContent":["import mem from 'mem';\nimport {\n DraftCreate,\n DraftCreateMetaSchema,\n NotFoundError,\n PublishedCredentialSchema,\n ResourceCredential,\n ResourceDraft,\n} from '../api';\nimport { TruvityError } from '../errors';\nimport { UdtClaims } from './credential/claims';\nimport { DraftCredentialWithClaims } from './credential/draft/with-claims';\nimport { CredentialFlavor } from './credential/flavor';\nimport { Claims, UpdatePayloadWithClaims } from './credential/types';\nimport { VerifiableCredentialWithClaims } from './credential/verifiable/with-claims';\nimport { getVcSchemaMetadataOrThrow, VcSchema, VcSchemaMetadata } from './decorators';\nimport { verifiableCredentialDataSchema } from './schemas';\nimport {\n ApiClient,\n BlobInput,\n CredentialDescriptor,\n Ctor,\n isResourceCredential,\n UpdatePayload,\n UpdatePayloadWithIssueClaims,\n UserUpdateClaims,\n} from './types';\nimport { strictlyConvertToApiType } from './utils/converters';\nimport { DocumentedError, ErrorCode } from './utils/error';\nimport { generateKey } from './utils/idempotency';\n\nexport type SchemaPublicationResult = {\n published: boolean;\n error?: string;\n};\n\nexport type CredentialEnvelope<T extends Claims> = {\n isVerifiable: false;\n credential: DraftCredentialWithClaims<T>;\n};\n\nexport type VerifiableCredentialEnvelope<T extends Claims> = {\n isVerifiable: true;\n credential: VerifiableCredentialWithClaims<T>;\n};\n\nexport type LoadedCredential<T extends Claims> = CredentialEnvelope<T> | VerifiableCredentialEnvelope<T>;\n\nexport class VcDecorator<T extends Claims> {\n readonly flavor = this.createCredentialFlavor();\n private claims = new UdtClaims(this.client, this.claimsModel);\n private vcSchemaMetadata: VcSchemaMetadata;\n\n constructor(\n private client: ApiClient,\n private claimsModel: Ctor<T>,\n ) {\n this.vcSchemaMetadata = getVcSchemaMetadataOrThrow(claimsModel);\n }\n\n protected createCredentialFlavor(): CredentialFlavor {\n return new CredentialFlavor();\n }\n\n async publishSchema(): Promise<SchemaPublicationResult> {\n if (this.vcSchemaMetadata.slug == null) {\n return { published: false, error: 'A schema requires a slug to be published as stable' };\n }\n if (this.vcSchemaMetadata.owner != null && this.vcSchemaMetadata.owner !== (await this.client.tenantId())) {\n return { published: false, error: 'A schema with a different owner cannot be published' };\n }\n try {\n const credentialSchema = await this.client.schemas.schemaCreate({\n data: {\n schema: this.claims.getClaimsSchema(),\n },\n });\n await this.client.schemas.schemaPublish(credentialSchema.id, {\n slug: this.vcSchemaMetadata.slug,\n version: this.vcSchemaMetadata.version,\n });\n return { published: true };\n } catch (error) {\n if (error instanceof TruvityError) {\n return { published: false, error: error.message };\n }\n throw error;\n }\n }\n\n @mem.decorator()\n async getCredentialTerm(): Promise<string> {\n let publishedCredentialSchema: PublishedCredentialSchema;\n if (this.vcSchemaMetadata.owner == null) {\n const result = await this.client.schemas.schemaImport({\n data: {\n schema: this.claims.getClaimsSchema(),\n version: this.vcSchemaMetadata.version,\n slug: this.vcSchemaMetadata.slug,\n },\n });\n publishedCredentialSchema = result.data;\n } else if (this.vcSchemaMetadata.slug != null) {\n publishedCredentialSchema = await this.client.desk.publishedMetaSchemaFetch(\n this.vcSchemaMetadata.owner,\n this.vcSchemaMetadata.slug,\n this.vcSchemaMetadata.version,\n );\n } else {\n throw new DocumentedError(\n ErrorCode.VcSchemaMissingSlug,\n 'A VcSchema annotation with an owner value requires a slug value',\n );\n }\n if (publishedCredentialSchema.schema.jsonLdTermName != null) {\n return `${publishedCredentialSchema.schema.jsonLdTermName}Credential`;\n }\n return `${publishedCredentialSchema.slug}v${publishedCredentialSchema.version}Credential`;\n }\n\n async canMap(input: ResourceDraft | ResourceCredential): Promise<boolean> {\n return input.data.type.includes(await this.getCredentialTerm());\n }\n\n async map(input: ResourceDraft): Promise<DraftCredentialWithClaims<T>>;\n async map(input: ResourceCredential): Promise<VerifiableCredentialWithClaims<T>>;\n async map(\n input: ResourceDraft | ResourceCredential,\n ): Promise<VerifiableCredentialWithClaims<T> | DraftCredentialWithClaims<T>> {\n if (isResourceCredential(input)) {\n // ResourceCredential\n if (!(await this.canMap(input))) {\n throw new DocumentedError(\n ErrorCode.IncompatibleUDT,\n `The received ResourceCredential is incompatible with the current VcDecorator instance claims model`,\n );\n }\n\n return new VerifiableCredentialWithClaims(this.client, this.flavor, this.claimsModel, input);\n } else {\n // ResourceDraft\n if (!(await this.canMap(input))) {\n throw new DocumentedError(\n ErrorCode.IncompatibleUDT,\n `The received ResourceDraft is incompatible with the current VcDecorator instance claims model`,\n );\n }\n\n return new DraftCredentialWithClaims(this.client, this.flavor, this.claimsModel, input.data, input);\n }\n }\n\n private async importBlob(blob: BlobInput, request?: UpdatePayload): Promise<CredentialDescriptor> {\n const idempotencyKey = generateKey('importBlob');\n const { blobId, uploadUri } = await this.client.credentials.credentialUpload({\n idempotencyKey,\n });\n\n await fetch(uploadUri, {\n method: 'PUT',\n body: blob,\n });\n\n const resourceCredential = await this.client.credentials.credentialImport({\n annotations: request?.annotations,\n labels: request?.labels,\n blobId,\n idempotencyKey,\n });\n\n return {\n data: strictlyConvertToApiType(verifiableCredentialDataSchema, {\n id: resourceCredential.data.id,\n digestMultibase: resourceCredential.data.digestMultibase,\n }),\n id: resourceCredential.id,\n etag: resourceCredential.etag,\n revision: resourceCredential.revision,\n };\n }\n\n private async convertUDTToDraftCreate(object: UserUpdateClaims<T> | null): Promise<DraftCreate> {\n let metaSchema: DraftCreateMetaSchema;\n let jsonLdVocabs = this.vcSchemaMetadata.jsonLdVocabs;\n let vcJsonSchemas = this.vcSchemaMetadata.vcJsonSchemas;\n if (this.vcSchemaMetadata.owner == null) {\n const claimsSchema = this.claims.getClaimsSchema();\n metaSchema = {\n schema: claimsSchema,\n slug: this.vcSchemaMetadata.slug,\n version: this.vcSchemaMetadata.version,\n };\n if (\n jsonLdVocabs?.includes(VcSchema.jsonLdVocabUrl) ||\n vcJsonSchemas?.includes(VcSchema.vcdmJsonSchemaUrl)\n ) {\n const result = await this.client.schemas.schemaImport({\n data: {\n schema: claimsSchema,\n slug: this.vcSchemaMetadata.slug,\n version: this.vcSchemaMetadata.version,\n },\n });\n jsonLdVocabs =\n jsonLdVocabs == null\n ? undefined\n : jsonLdVocabs.map((x) => (VcSchema.jsonLdVocabUrl === x ? result.data.jsonLdVocabUrl : x));\n vcJsonSchemas =\n vcJsonSchemas == null\n ? undefined\n : vcJsonSchemas.map((x) =>\n VcSchema.vcdmJsonSchemaUrl === x ? result.data.vcdmJsonSchemaUrl : x,\n );\n }\n } else if (this.vcSchemaMetadata.slug != null) {\n const deskBaseURL = (await this.client.dids.didDocumentSelfGet()).id.split(':')[2];\n metaSchema = `https://${deskBaseURL}/tenants/${this.vcSchemaMetadata.owner}/meta-schema/${this.vcSchemaMetadata.slug}/v${this.vcSchemaMetadata.version}`;\n if (\n jsonLdVocabs?.includes(VcSchema.jsonLdVocabUrl) ||\n vcJsonSchemas?.includes(VcSchema.vcdmJsonSchemaUrl)\n ) {\n const result = await this.client.desk.publishedMetaSchemaFetch(\n this.vcSchemaMetadata.owner,\n this.vcSchemaMetadata.slug,\n this.vcSchemaMetadata.version,\n );\n jsonLdVocabs =\n jsonLdVocabs == null\n ? undefined\n : jsonLdVocabs.map((x) => (VcSchema.jsonLdVocabUrl === x ? result.jsonLdVocabUrl : x));\n vcJsonSchemas =\n vcJsonSchemas == null\n ? undefined\n : vcJsonSchemas.map((x) => (VcSchema.vcdmJsonSchemaUrl === x ? result.vcdmJsonSchemaUrl : x));\n }\n } else {\n throw new DocumentedError(\n ErrorCode.VcSchemaMissingSlug,\n 'A VcSchema annotation with an owner value requires a slug value',\n );\n }\n return {\n metaSchema,\n jsonLdVocabs,\n vcdmJsonSchemas: vcJsonSchemas,\n values: object != null ? this.claims.marshalValues(object) : undefined,\n };\n }\n\n async create(request?: UpdatePayloadWithClaims<T>): Promise<DraftCredentialWithClaims<T>> {\n const { id, etag, revision, data } = await this.client.drafts.draftCreate({\n data: await this.convertUDTToDraftCreate(request?.claims || null),\n annotations: request?.annotations,\n labels: request?.labels,\n idempotencyKey: generateKey('create'),\n });\n\n return new DraftCredentialWithClaims(this.client, this.flavor, this.claimsModel, data, { id, etag, revision });\n }\n\n async issue(\n privateKeyId: string,\n request: UpdatePayloadWithIssueClaims<T>,\n ): Promise<VerifiableCredentialWithClaims<T>> {\n const result = await this.create(request);\n return result.issue(privateKeyId);\n }\n\n async loadAsDraft(id: string, revision?: number): Promise<DraftCredentialWithClaims<T>> {\n const resourceDraft = revision\n ? await this.client.drafts.draftRevision(id, revision)\n : await this.client.drafts.draftLatest(id);\n\n return this.map(resourceDraft);\n }\n\n async loadAsCredential(id: string, revision?: number): Promise<VerifiableCredentialWithClaims<T>> {\n const resourceCredential = revision\n ? await this.client.credentials.credentialRevision(id, revision)\n : await this.client.credentials.credentialLatest(id);\n\n return this.map(resourceCredential);\n }\n\n async load(id: string, revision?: number): Promise<LoadedCredential<T>> {\n let verifiableCredential: VerifiableCredentialWithClaims<T> | undefined;\n let draftCredential: DraftCredentialWithClaims<T> | undefined;\n\n try {\n verifiableCredential = await this.loadAsCredential(id, revision);\n } catch (error) {\n if (error instanceof NotFoundError) {\n draftCredential = await this.loadAsDraft(id, revision);\n } else throw error;\n }\n\n if (!draftCredential) {\n if (!verifiableCredential) throw new Error(`Resource with id '${id}' could not be found.`);\n\n return {\n isVerifiable: true,\n credential: verifiableCredential,\n };\n } else {\n return {\n isVerifiable: false,\n credential: draftCredential,\n };\n }\n }\n\n async importCredential(blob: BlobInput, request?: UpdatePayload): Promise<VerifiableCredentialWithClaims<T>> {\n const credential = await this.importBlob(blob, request);\n\n return new VerifiableCredentialWithClaims(this.client, this.flavor, this.claimsModel, credential);\n }\n}\n"]}
1
+ {"version":3,"file":"credential.js","sourceRoot":"","sources":["../../src/documents/credential.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;AAAA,8CAAsB;AACtB,gCAOgB;AAChB,gDAAgD;AAChD,gEAA2E;AAC3E,gDAAuD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AC;gBAE3F,OAAO;oBACH,YAAY,EAAE,IAAI;oBAClB,UAAU,EAAE,oBAAoB;iBACnC,CAAC;YACN,CAAC;iBAAM,CAAC;gBACJ,OAAO;oBACH,YAAY,EAAE,KAAK;oBACnB,UAAU,EAAE,eAAe;iBAC9B,CAAC;YACN,CAAC;QACL,CAAC;KAAA;IAEK,gBAAgB,CAAC,IAAe,EAAE,OAAuB;;YAC3D,MAAM,UAAU,GAAG,MAAM,IAAI,CAAC,UAAU,CAAC,IAAI,EAAE,OAAO,CAAC,CAAC;YAExD,OAAO,IAAI,4CAA8B,CAAC,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,MAAM,EAAE,IAAI,CAAC,WAAW,EAAE,UAAU,CAAC,CAAC;QACtG,CAAC;KAAA;CACJ;AA1RD,kCA0RC;AAjOS;IADL,aAAG,CAAC,SAAS,EAAE;;;;oDA4Bf","sourcesContent":["import mem from 'mem';\nimport {\n DraftCreate,\n DraftCreateMetaSchema,\n NotFoundError,\n PublishedCredentialSchema,\n ResourceCredential,\n ResourceDraft,\n} from '../api';\nimport { UdtClaims } from './credential/claims';\nimport { DraftCredentialWithClaims } from './credential/draft/with-claims';\nimport { CredentialFlavor } from './credential/flavor';\nimport { Claims, UpdatePayloadWithClaims } from './credential/types';\nimport { VerifiableCredentialWithClaims } from './credential/verifiable/with-claims';\nimport { getVcSchemaMetadataOrThrow, VcSchema, VcSchemaMetadata } from './decorators';\nimport { UdtError, UdtErrorCode } from './error';\nimport { verifiableCredentialDataSchema } from './schemas';\nimport {\n ApiClient,\n BlobInput,\n CredentialDescriptor,\n Ctor,\n isResourceCredential,\n UpdatePayload,\n UpdatePayloadWithIssueClaims,\n UserUpdateClaims,\n} from './types';\nimport { strictlyConvertToApiType } from './utils/converters';\nimport { generateKey } from './utils/idempotency';\n\nexport type SchemaPublicationResult = {\n published: boolean;\n error?: Error;\n};\n\nexport type CredentialEnvelope<T extends Claims> = {\n isVerifiable: false;\n credential: DraftCredentialWithClaims<T>;\n};\n\nexport type VerifiableCredentialEnvelope<T extends Claims> = {\n isVerifiable: true;\n credential: VerifiableCredentialWithClaims<T>;\n};\n\nexport type LoadedCredential<T extends Claims> = CredentialEnvelope<T> | VerifiableCredentialEnvelope<T>;\n\nexport class VcDecorator<T extends Claims> {\n readonly flavor = this.createCredentialFlavor();\n private claims = new UdtClaims(this.client, this.claimsModel);\n private vcSchemaMetadata: VcSchemaMetadata;\n\n constructor(\n private client: ApiClient,\n private claimsModel: Ctor<T>,\n ) {\n this.vcSchemaMetadata = getVcSchemaMetadataOrThrow(claimsModel);\n }\n\n protected createCredentialFlavor(): CredentialFlavor {\n return new CredentialFlavor();\n }\n\n async publishSchema(): Promise<SchemaPublicationResult> {\n if (this.vcSchemaMetadata.slug == null) {\n return {\n published: false,\n error: new UdtError(\n UdtErrorCode.VcSchemaMissingSlug,\n `A schema requires a slug to be published as stable`,\n ),\n };\n }\n\n if (this.vcSchemaMetadata.owner != null && this.vcSchemaMetadata.owner !== (await this.client.tenantId())) {\n return {\n published: false,\n error: new UdtError(\n UdtErrorCode.VcSchemaDifferentOwner,\n `It's not possible to publish a schema to a tenant different from the configured one.`,\n ),\n };\n }\n\n try {\n const credentialSchema = await this.client.schemas.schemaCreate({\n data: {\n schema: this.claims.getClaimsSchema(),\n },\n });\n await this.client.schemas.schemaPublish(credentialSchema.id, {\n slug: this.vcSchemaMetadata.slug,\n version: this.vcSchemaMetadata.version,\n });\n return { published: true };\n } catch (error) {\n if (error instanceof Error) {\n return { published: false, error };\n }\n throw error;\n }\n }\n\n @mem.decorator()\n async getCredentialTerm(): Promise<string> {\n let publishedCredentialSchema: PublishedCredentialSchema;\n if (this.vcSchemaMetadata.owner == null) {\n const result = await this.client.schemas.schemaImport({\n data: {\n schema: this.claims.getClaimsSchema(),\n version: this.vcSchemaMetadata.version,\n slug: this.vcSchemaMetadata.slug,\n },\n });\n publishedCredentialSchema = result.data;\n } else if (this.vcSchemaMetadata.slug != null) {\n publishedCredentialSchema = await this.client.desk.publishedMetaSchemaFetch(\n this.vcSchemaMetadata.owner,\n this.vcSchemaMetadata.slug,\n this.vcSchemaMetadata.version,\n );\n } else {\n throw new UdtError(\n UdtErrorCode.VcSchemaMissingSlug,\n 'A VcSchema annotation with an owner value requires a slug value',\n );\n }\n if (publishedCredentialSchema.schema.jsonLdTermName != null) {\n return `${publishedCredentialSchema.schema.jsonLdTermName}Credential`;\n }\n return `${publishedCredentialSchema.slug}v${publishedCredentialSchema.version}Credential`;\n }\n\n async canMap(input: ResourceDraft | ResourceCredential): Promise<boolean> {\n return input.data.type.includes(await this.getCredentialTerm());\n }\n\n async map(input: ResourceDraft): Promise<DraftCredentialWithClaims<T>>;\n async map(input: ResourceCredential): Promise<VerifiableCredentialWithClaims<T>>;\n async map(\n input: ResourceDraft | ResourceCredential,\n ): Promise<VerifiableCredentialWithClaims<T> | DraftCredentialWithClaims<T>> {\n if (isResourceCredential(input)) {\n // ResourceCredential\n if (!(await this.canMap(input))) {\n throw new UdtError(\n UdtErrorCode.IncompatibleUDT,\n `The received ResourceCredential is incompatible with the current VcDecorator instance claims model`,\n );\n }\n\n return new VerifiableCredentialWithClaims(this.client, this.flavor, this.claimsModel, input);\n } else {\n // ResourceDraft\n if (!(await this.canMap(input))) {\n throw new UdtError(\n UdtErrorCode.IncompatibleUDT,\n `The received ResourceDraft is incompatible with the current VcDecorator instance claims model`,\n );\n }\n\n return new DraftCredentialWithClaims(this.client, this.flavor, this.claimsModel, input.data, input);\n }\n }\n\n private async importBlob(blob: BlobInput, request?: UpdatePayload): Promise<CredentialDescriptor> {\n const idempotencyKey = generateKey('importBlob');\n const { blobId, uploadUri } = await this.client.credentials.credentialUpload({\n idempotencyKey,\n });\n\n await fetch(uploadUri, {\n method: 'PUT',\n body: blob,\n });\n\n const resourceCredential = await this.client.credentials.credentialImport({\n annotations: request?.annotations,\n labels: request?.labels,\n blobId,\n idempotencyKey,\n });\n\n return {\n data: strictlyConvertToApiType(verifiableCredentialDataSchema, {\n id: resourceCredential.data.id,\n digestMultibase: resourceCredential.data.digestMultibase,\n }),\n id: resourceCredential.id,\n etag: resourceCredential.etag,\n revision: resourceCredential.revision,\n };\n }\n\n private async convertUDTToDraftCreate(object: UserUpdateClaims<T> | null): Promise<DraftCreate> {\n let metaSchema: DraftCreateMetaSchema;\n let jsonLdVocabs = this.vcSchemaMetadata.jsonLdVocabs;\n let vcJsonSchemas = this.vcSchemaMetadata.vcJsonSchemas;\n if (this.vcSchemaMetadata.owner == null) {\n const claimsSchema = this.claims.getClaimsSchema();\n metaSchema = {\n schema: claimsSchema,\n slug: this.vcSchemaMetadata.slug,\n version: this.vcSchemaMetadata.version,\n };\n if (\n jsonLdVocabs?.includes(VcSchema.jsonLdVocabUrl) ||\n vcJsonSchemas?.includes(VcSchema.vcdmJsonSchemaUrl)\n ) {\n const result = await this.client.schemas.schemaImport({\n data: {\n schema: claimsSchema,\n slug: this.vcSchemaMetadata.slug,\n version: this.vcSchemaMetadata.version,\n },\n });\n jsonLdVocabs =\n jsonLdVocabs == null\n ? undefined\n : jsonLdVocabs.map((x) => (VcSchema.jsonLdVocabUrl === x ? result.data.jsonLdVocabUrl : x));\n vcJsonSchemas =\n vcJsonSchemas == null\n ? undefined\n : vcJsonSchemas.map((x) =>\n VcSchema.vcdmJsonSchemaUrl === x ? result.data.vcdmJsonSchemaUrl : x,\n );\n }\n } else if (this.vcSchemaMetadata.slug != null) {\n const deskBaseURL = (await this.client.dids.didDocumentSelfGet()).id.split(':')[2];\n metaSchema = `https://${deskBaseURL}/tenants/${this.vcSchemaMetadata.owner}/meta-schema/${this.vcSchemaMetadata.slug}/v${this.vcSchemaMetadata.version}`;\n if (\n jsonLdVocabs?.includes(VcSchema.jsonLdVocabUrl) ||\n vcJsonSchemas?.includes(VcSchema.vcdmJsonSchemaUrl)\n ) {\n const result = await this.client.desk.publishedMetaSchemaFetch(\n this.vcSchemaMetadata.owner,\n this.vcSchemaMetadata.slug,\n this.vcSchemaMetadata.version,\n );\n jsonLdVocabs =\n jsonLdVocabs == null\n ? undefined\n : jsonLdVocabs.map((x) => (VcSchema.jsonLdVocabUrl === x ? result.jsonLdVocabUrl : x));\n vcJsonSchemas =\n vcJsonSchemas == null\n ? undefined\n : vcJsonSchemas.map((x) => (VcSchema.vcdmJsonSchemaUrl === x ? result.vcdmJsonSchemaUrl : x));\n }\n } else {\n throw new UdtError(\n UdtErrorCode.VcSchemaMissingSlug,\n 'A VcSchema annotation with an owner value requires a slug value',\n );\n }\n return {\n metaSchema,\n jsonLdVocabs,\n vcdmJsonSchemas: vcJsonSchemas,\n values: object != null ? this.claims.marshalValues(object) : undefined,\n };\n }\n\n async create(request?: UpdatePayloadWithClaims<T>): Promise<DraftCredentialWithClaims<T>> {\n const { id, etag, revision, data } = await this.client.drafts.draftCreate({\n data: await this.convertUDTToDraftCreate(request?.claims || null),\n annotations: request?.annotations,\n labels: request?.labels,\n idempotencyKey: generateKey('create'),\n });\n\n return new DraftCredentialWithClaims(this.client, this.flavor, this.claimsModel, data, { id, etag, revision });\n }\n\n async issue(\n privateKeyId: string,\n request: UpdatePayloadWithIssueClaims<T>,\n ): Promise<VerifiableCredentialWithClaims<T>> {\n const result = await this.create(request);\n return result.issue(privateKeyId);\n }\n\n async loadAsDraft(id: string, revision?: number): Promise<DraftCredentialWithClaims<T>> {\n const resourceDraft = revision\n ? await this.client.drafts.draftRevision(id, revision)\n : await this.client.drafts.draftLatest(id);\n\n return this.map(resourceDraft);\n }\n\n async loadAsCredential(id: string, revision?: number): Promise<VerifiableCredentialWithClaims<T>> {\n const resourceCredential = revision\n ? await this.client.credentials.credentialRevision(id, revision)\n : await this.client.credentials.credentialLatest(id);\n\n return this.map(resourceCredential);\n }\n\n async load(id: string, revision?: number): Promise<LoadedCredential<T>> {\n let verifiableCredential: VerifiableCredentialWithClaims<T> | undefined;\n let draftCredential: DraftCredentialWithClaims<T> | undefined;\n\n try {\n verifiableCredential = await this.loadAsCredential(id, revision);\n } catch (error) {\n if (error instanceof NotFoundError) {\n draftCredential = await this.loadAsDraft(id, revision);\n } else throw error;\n }\n\n if (!draftCredential) {\n if (!verifiableCredential) throw new Error(`Resource with id '${id}' could not be found.`);\n\n return {\n isVerifiable: true,\n credential: verifiableCredential,\n };\n } else {\n return {\n isVerifiable: false,\n credential: draftCredential,\n };\n }\n }\n\n async importCredential(blob: BlobInput, request?: UpdatePayload): Promise<VerifiableCredentialWithClaims<T>> {\n const credential = await this.importBlob(blob, request);\n\n return new VerifiableCredentialWithClaims(this.client, this.flavor, this.claimsModel, credential);\n }\n}\n"]}
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.d.ts","sourceRoot":"","sources":["../../src/documents/decorators.ts"],"names":[],"mappings":"AAAA,OAAO,kBAAkB,CAAC;AAE1B,OAAO,EAAE,qBAAqB,EAAE,MAAM,QAAQ,CAAC;AAE/C,OAAO,KAAK,EAAE,IAAI,EAAE,MAAM,SAAS,CAAC;AAGpC,eAAO,MAAM,gBAAgB,qBAAqB,CAAC;AACnD,eAAO,MAAM,WAAW,0BAA6B,CAAC;AACtD,eAAO,MAAM,qBAAqB,gCAAmC,CAAC;AACtE,eAAO,MAAM,uBAAuB,uCAA0C,CAAC;AAC/E,eAAO,MAAM,wBAAwB,wCAA2C,CAAC;AACjF,eAAO,MAAM,iCAAiC,iDAAoD,CAAC;AACnG,eAAO,MAAM,kBAAkB,6BAAgC,CAAC;AAChE,eAAO,MAAM,iBAAiB,iCAAoC,CAAC;AAGnE,KAAK,gBAAgB,GAAG;IACpB,IAAI,EAAE,MAAM,CAAC;IACb,SAAS,EAAE,MAAM,CAAC;IAClB,MAAM,CAAC,EAAE,MAAM,EAAE,CAAC;CACrB,CAAC;AAEF,KAAK,eAAe,GAAG;IACnB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,MAAM,gBAAgB,GAAG;IAC3B,IAAI,CAAC,E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M,KAAG,cAGhB,CAAC;AAKN,eAAO,MAAM,qBAAqB,WAAY,IAAI,CAAC,GAAG,CAAC,eAAe,MAAM,KAAG,IAAI,CAAC,GAAG,CAAC,GAAG,SACtB,CAAC;AAEtE,eAAO,MAAM,wBAAwB,WAAY,IAAI,CAAC,GAAG,CAAC,KAAG,iBAAiB,GAAG,SAC3B,CAAC;AAEvD,eAAO,MAAM,mBAAmB,WAAY,IAAI,CAAC,GAAG,CAAC,KAAG,gBAAgB,GAAG,SAqB1E,CAAC;AAEF,eAAO,MAAM,0BAA0B,WAAY,IAAI,CAAC,GAAG,CAAC,KAAG,gBAM9D,CAAC;AAEF,eAAO,MAAM,uBAAuB,WAAY,IAAI,CAAC,GAAG,CAAC,KAAG,kBACA,CAAC"}
@@ -2,8 +2,8 @@
2
2
  Object.defineProperty(exports, "__esModule", { value: true });
3
3
  exports.getRegisteredClaimsList = exports.getVcSchemaMetadataOrThrow = exports.getVcSchemaMetadata = exports.getContextJsonLdMetadata = exports.getTsDataTypeMetadata = exports.VcSchemaJsonLdTermName = exports.VcSchema = exports.VcClaimType = exports.VcContext = exports.VcExternalSchema = exports.VcStringEnumClaim = exports.VcArrayClaim = exports.VcClaimTitle = exports.VcClaimJsonLdType = exports.VcClaimJsonLdIri = exports.VcNotEmptyClaim = exports.VcClaim = exports.VcClaimWithOptions = exports.CLAIM_LINKED_FILE = exports.CLAIM_JSON_LD_TYPE = exports.CLAIM_VC_SCHEMA_JSON_LD_TERM_NAME = exports.CLAIM_VC_EXTERNAL_SCHEMA = exports.CLAIM_VC_SCHEMA_OPTIONS = exports.CLAIM_JSON_LD_CONTEXT = exports.CLAIMS_LIST = exports.DECORATOR_PREFIX = void 0;
4
4
  require("reflect-metadata");
5
+ const error_1 = require("./error");
5
6
  const models_1 = require("./models");
6
- const error_1 = require("./utils/error");
7
7
  exports.DECORATOR_PREFIX = 'credential-claim';
8
8
  exports.CLAIMS_LIST = `${exports.DECORATOR_PREFIX}:list`;
9
9
  exports.CLAIM_JSON_LD_CONTEXT = `${exports.DECORATOR_PREFIX}:ld-context`;
@@ -274,7 +274,7 @@ exports.getVcSchemaMetadata = getVcSchemaMetadata;
274
274
  const getVcSchemaMetadataOrThrow = (target) => {
275
275
  const vcSchemaOptions = (0, exports.getVcSchemaMetadata)(target);
276
276
  if (vcSchemaOptions == null) {
277
- throw new error_1.DocumentedError(error_1.ErrorCode.VcSchemaAnnotationMissing, '@VcSchema annotation is required on the UDT class');
277
+ throw new error_1.UdtError(error_1.UdtErrorCode.VcSchemaAnnotationMissing, '@VcSchema annotation is required on the UDT class');
278
278
  }
279
279
  return vcSchemaOptions;
280
280
  };
@@ -1 +1 @@
1
- {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/documents/decorators.ts"],"names":[],"mappings":";;;AAAA,4BAA0B;AAG1B,qCAAwD;AAExD,yCAA2D;AAE9C,QAAA,gBAAgB,GAAG,kBAAkB,CAAC;AACtC,QAAA,WAAW,GAAG,GAAG,wBAAgB,OAAO,CAAC;AACzC,QAAA,qBAAqB,GAAG,GAAG,wBAAgB,aAAa,CAAC;AACzD,QAAA,uBAAuB,GAAG,GAAG,wBAAgB,oBAAoB,CAAC;AAClE,QAAA,wBAAwB,GAAG,GAAG,wBAAgB,qBAAqB,CAAC;AACpE,QAAA,iCAAiC,GAAG,GAAG,wBAAgB,8BAA8B,CAAC;AACtF,QAAA,kBAAkB,GAAG,GAAG,wBAAgB,UAAU,CAAC;AACnD,QAAA,iBAAiB,GAAG,GAAG,wBAAgB,cAAc,CAAC;AACnE,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAuCpD,MAAM,aAAa,GAAG,CAAC,MAAc,EAAE,KAAsB,EAAE,EAAE;IAC7D,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,mBAAW,EAAE,MAAM,CAAC,EAAE,CAAC;QAC5C,OAAO,CAAC,cAAc,CAAC,mBAAW,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;IACD,MAA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CAAC;IAED,OAAO,SAAS,CAAC;AACrB,CAAC,CAAC;AArBW,QAAA,mBAAmB,uBAqB9B;AAEK,MAAM,0BAA0B,GAAG,CAAC,MAAiB,EAAoB,EAAE;IAC9E,MAAM,eAAe,GAAG,IAAA,2BAAmB,EAAC,MAAM,CAAC,CAAC;IACpD,IAAI,eAAe,IAAI,IAAI,EAAE,CAAC;QAC1B,MAAM,IAAI,uBAAe,CACrB,iBAAS,CAAC,yBAAyB,EACnC,mDAAmD,CACtD,CAAC;IACN,CAAC;IACD,OAAO,eAAe,CAAC;AAC3B,CAAC,CAAC;AATW,QAAA,0BAA0B,8BASrC;AAEK,MAAM,uBAAuB,GAAG,CAAC,MAAiB,EAAsB,EAAE,CAC7E,OAAO,CAAC,WAAW,CAAC,mBAAW,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;AADhD,QAAA,uBAAuB,2BACyB","sourcesContent":["import 'reflect-metadata';\n\nimport { ClaimsSchemaEnumValue } from '../api';\nimport { LinkedCredential, LinkedFile } from './models';\nimport type { Ctor } from './types';\nimport { DocumentedError, ErrorCode } from './utils/error';\n\nexport const DECORATOR_PREFIX = 'credential-claim';\nexport const CLAIMS_LIST = `${DECORATOR_PREFIX}:list`;\nexport const CLAIM_JSON_LD_CONTEXT = `${DECORATOR_PREFIX}:ld-context`;\nexport const CLAIM_VC_SCHEMA_OPTIONS = `${DECORATOR_PREFIX}:vc-schema-options`;\nexport const CLAIM_VC_EXTERNAL_SCHEMA = `${DECORATOR_PREFIX}:vc-external-schema`;\nexport const CLAIM_VC_SCHEMA_JSON_LD_TERM_NAME = `${DECORATOR_PREFIX}:vc-schema-json-ld-term-name`;\nexport const CLAIM_JSON_LD_TYPE = `${DECORATOR_PREFIX}:ld-type`;\nexport const CLAIM_LINKED_FILE = `${DECORATOR_PREFIX}:linked-file`;\nconst DECORATOR_NAMES_LIST = `decorator-names:list`;\n\ntype VcContextOptions = {\n name: string;\n namespace: string;\n vcType?: string[];\n};\n\ntype VcSchemaOptions = {\n slug?: string;\n version?: number;\n owner?: string;\n};\n\nexport type VcSchemaMetadata = {\n slug?: string;\n version: number;\n owner?: string;\n vcJsonSchemas?: string[];\n jsonLdVocabs?: string[];\n jsonLdBaseIri?: string;\n jsonLdTermName?: string;\n};\n\ntype VcContextMetadata = VcContextOptions;\n\nexport type ClaimDescriptor = {\n name: string;\n nestedType?: Ctor<any>;\n title?: string;\n isArray?: boolean;\n notEmpty?: boolean;\n enumValuesDescriptor?: ClaimsSchemaEnumValue[];\n jsonLdIri?: string;\n jsonLdType?: string;\n};\n\ntype ClaimsListMetadata = ClaimDescriptor[];\n\nconst registerClaim = (target: object, claim: ClaimDescriptor) => {\n if (!Reflect.hasMetadata(CLAIMS_LIST, target)) {\n Reflect.defineMetadata(CLAIMS_LIST, [], target);\n }\n const claimsList: ClaimsListMetadata = Reflect.getMetadata(CLAIMS_LIST, target);\n\n const existingClaim = claimsList.find(({ name }) => name === claim.name);\n\n if (existingClaim) {\n Object.assign(existingClaim, claim);\n } else {\n claimsList.push(claim);\n }\n};\n\nconst PROPERTY_DECORATOR_NAMES = {\n VC_CLAIM: 'VcClaim',\n VC_CLAIM_TITLE: 'VcClaimTitle',\n VC_NOT_EMPTY_CLAIM: 'VcNotEmptyClaim',\n VC_STRING_ENUM_CLAIM: 'VcStringEnumClaim',\n VC_ARRAY_CLAIM: 'VcArrayClaim',\n VC_CLAIM_TYPE: 'VcClaimType',\n VC_CLAIM_JSON_LD_IRI: 'VcClaimJsonLdIri',\n VC_CLAIM_JSON_LD_TYPE: 'VcClaimJsonLdType',\n};\n\nconst reportDecoratorsUsage = (\n propertyKey: string | symbol,\n newPropertyDecoratorName: string,\n {\n irrelevantDueToList,\n makesObsoleteList,\n contradictsWithList,\n }: { irrelevantDueToList?: string[]; makesObsoleteList?: string[]; contradictsWithList?: string[] },\n existingDecoratorsList: string[],\n) => {\n const alreadyDefinedContradictsWith = contradictsWithList\n ? existingDecoratorsList.find((value) => contradictsWithList.includes(value))\n : undefined;\n\n if (alreadyDefinedContradictsWith) {\n throw new Error(\n `Property decorator \"${newPropertyDecoratorName}\" is incompatible with existing \"${alreadyDefinedContradictsWith}\" on property \"${String(propertyKey)}\". Please review the existing decorators and remove one of them.`,\n );\n }\n\n if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test') {\n const alreadyDefinedIrrelevantDueTo = irrelevantDueToList\n ? existingDecoratorsList.filter((value) => irrelevantDueToList.includes(value))\n : undefined;\n const alreadyDefinedMakesObsolete = makesObsoleteList\n ? existingDecoratorsList.filter((value) => makesObsoleteList.includes(value))\n : undefined;\n\n if (alreadyDefinedIrrelevantDueTo?.length) {\n console.warn(\n `The already defined decorator${alreadyDefinedIrrelevantDueTo.length > 1 ? 's' : ''} (\"${alreadyDefinedIrrelevantDueTo.join('\", \"')}\") on the property \"${String(propertyKey)}\" makes registering the new \"${newPropertyDecoratorName}\" decorator unnecessary. You can freely remove it.`,\n );\n }\n\n if (alreadyDefinedMakesObsolete?.length) {\n console.warn(\n `The already defined decorator${alreadyDefinedMakesObsolete.length > 1 ? 's' : ''} (\"${alreadyDefinedMakesObsolete.join('\", \"')}\") on the property \"${String(propertyKey)}\" ${alreadyDefinedMakesObsolete.length > 1 ? 'are' : 'is'} made obsolete by the new \"${newPropertyDecoratorName}\". You can freely remove ${alreadyDefinedMakesObsolete.length > 1 ? 'them' : 'it'}.`,\n );\n }\n }\n};\n\n/* incompatibility/overlapping property decorators table:\n\n| property decorator | VcClaim | VcNotEmptyClaim | VcClaimTitle | VcStringEnumClaim | VcArrayClaim | VcClaimType | VcClaimJsonLdIri | VcClaimJsonLdType |\n|-------------------------|---------|-----------------|--------------|-------------------|--------------|-------------|------------------|-------------------|\n| VcClaim | I | I | | I | I | | | |\n| VcNotEmptyClaim | O | I | | | | | | |\n| VcClaimTitle | | | C | | | | | |\n| VcStringEnumClaim | O | | | C | | | | |\n| VcArrayClaim | O | | | | C | | | |\n| VcClaimType | O | | | | | C | | C |\n| VcClaimJsonLdIri | O | | | | | | C | |\n| VcClaimJsonLdType | O | | | | | C | | C |\n\nLegend:\nO - <row name> makes obsolete <column name> [WARNING]\nI - <row name> irrelevant due to <column name> [WARNING]\nC - <row name> contradicts with <column name> [ERROR]\n\n */\nconst registerDecoratorName = (target: object, propertyKey: string | symbol, decoratorName: string) => {\n if (!Reflect.hasMetadata(DECORATOR_NAMES_LIST, target, propertyKey)) {\n Reflect.defineMetadata(DECORATOR_NAMES_LIST, [], target, propertyKey);\n }\n const existingDecoratorsList: string[] = Reflect.getMetadata(DECORATOR_NAMES_LIST, target, propertyKey);\n\n switch (decoratorName) {\n case PROPERTY_DECORATOR_NAMES.VC_CLAIM:\n reportDecoratorsUsage(\n propertyKey,\n decoratorName,\n {\n irrelevantDueToList: [\n PROPERTY_DECORATOR_NAMES.VC_CLAIM,\n PROPERTY_DECORATOR_NAMES.VC_NOT_EMPTY_CLAIM,\n PROPERTY_DECORATOR_NAMES.VC_STRING_ENUM_CLAIM,\n PROPERTY_DECORATOR_NAMES.VC_ARRAY_CLAIM,\n ],\n },\n existingDecoratorsList,\n );\n break;\n case PROPERTY_DECORATOR_NAMES.VC_NOT_EMPTY_CLAIM:\n reportDecoratorsUsage(\n propertyKey,\n decoratorName,\n {\n irrelevantDueToList: [PROPERTY_DECORATOR_NAMES.VC_NOT_EMPTY_CLAIM],\n makesObsoleteList: [PROPERTY_DECORATOR_NAMES.VC_CLAIM],\n },\n existingDecoratorsList,\n );\n break;\n case PROPERTY_DECORATOR_NAMES.VC_CLAIM_TITLE:\n reportDecoratorsUsage(\n propertyKey,\n decoratorName,\n {\n contradictsWithList: [PROPERTY_DECORATOR_NAMES.VC_CLAIM_TITLE],\n },\n existingDecoratorsList,\n );\n break;\n case PROPERTY_DECORATOR_NAMES.VC_STRING_ENUM_CLAIM:\n reportDecoratorsUsage(\n propertyKey,\n decoratorName,\n {\n contradictsWithList: [PROPERTY_DECORATOR_NAMES.VC_STRING_ENUM_CLAIM],\n makesObsoleteList: [PROPERTY_DECORATOR_NAMES.VC_CLAIM],\n },\n existingDecoratorsList,\n );\n break;\n case PROPERTY_DECORATOR_NAMES.VC_ARRAY_CLAIM:\n reportDecoratorsUsage(\n propertyKey,\n decoratorName,\n {\n contradictsWithList: [PROPERTY_DECORATOR_NAMES.VC_ARRAY_CLAIM],\n makesObsoleteList: [PROPERTY_DECORATOR_NAMES.VC_CLAIM],\n },\n existingDecoratorsList,\n );\n break;\n case PROPERTY_DECORATOR_NAMES.VC_CLAIM_TYPE:\n reportDecoratorsUsage(\n propertyKey,\n decoratorName,\n {\n contradictsWithList: [\n PROPERTY_DECORATOR_NAMES.VC_CLAIM_TYPE,\n PROPERTY_DECORATOR_NAMES.VC_CLAIM_JSON_LD_TYPE,\n ],\n makesObsoleteList: [PROPERTY_DECORATOR_NAMES.VC_CLAIM],\n },\n existingDecoratorsList,\n );\n break;\n case PROPERTY_DECORATOR_NAMES.VC_CLAIM_JSON_LD_IRI:\n reportDecoratorsUsage(\n propertyKey,\n decoratorName,\n {\n contradictsWithList: [PROPERTY_DECORATOR_NAMES.VC_CLAIM_JSON_LD_IRI],\n makesObsoleteList: [PROPERTY_DECORATOR_NAMES.VC_CLAIM],\n },\n existingDecoratorsList,\n );\n break;\n case PROPERTY_DECORATOR_NAMES.VC_CLAIM_JSON_LD_TYPE:\n reportDecoratorsUsage(\n propertyKey,\n decoratorName,\n {\n contradictsWithList: [\n PROPERTY_DECORATOR_NAMES.VC_CLAIM_JSON_LD_TYPE,\n PROPERTY_DECORATOR_NAMES.VC_CLAIM_TYPE,\n ],\n makesObsoleteList: [PROPERTY_DECORATOR_NAMES.VC_CLAIM],\n },\n existingDecoratorsList,\n );\n break;\n }\n\n existingDecoratorsList.push(decoratorName);\n};\n\ntype VcExternalSchemaOptions = {\n jsonLdVocabs?: string[];\n vcJsonSchemas?: string[];\n};\n\ntype VcClaimOptions = {\n title?: string;\n dataType?: Ctor<any>;\n notEmpty?: boolean;\n jsonLdIri?: string;\n jsonLdType?: string;\n};\n\nconst vcSchemaMetadataFromVcContextMetadata = (vcContextMetadata: VcContextMetadata): VcSchemaMetadata => {\n return {\n slug: undefined,\n version: 1,\n owner: undefined,\n jsonLdTermName: vcContextMetadata.name,\n jsonLdBaseIri: vcContextMetadata.namespace,\n };\n};\n\nexport const VcClaimWithOptions =\n ({ title, dataType, notEmpty, jsonLdIri, jsonLdType }: VcClaimOptions = {}): PropertyDecorator =>\n (target, propertyKey) => {\n if (typeof propertyKey !== 'string') return;\n\n let nestedType = dataType;\n const tsType: Ctor<any> = Reflect.getMetadata('design:type', target, propertyKey);\n\n if (\n !Array.of<Ctor<any>>(\n String,\n Number,\n Date,\n Boolean,\n Object,\n Array,\n Function,\n LinkedFile,\n LinkedCredential,\n ).includes(tsType)\n ) {\n nestedType = tsType;\n }\n\n const claim: ClaimDescriptor = {\n name: propertyKey,\n };\n\n if (nestedType != null) claim.nestedType = nestedType;\n if (tsType === Array) claim.isArray = true;\n if (title != null) claim.title = title;\n if (notEmpty != null) claim.notEmpty = notEmpty;\n if (jsonLdIri != null) claim.jsonLdIri = jsonLdIri;\n if (jsonLdType != null) claim.jsonLdType = jsonLdType;\n\n registerClaim(target, claim);\n };\n\nexport const VcClaim: PropertyDecorator = (target, propertyKey) => {\n VcClaimWithOptions()(target, propertyKey);\n\n registerDecoratorName(target, propertyKey, PROPERTY_DECORATOR_NAMES.VC_CLAIM);\n};\n\nexport const VcNotEmptyClaim: PropertyDecorator = (target, propertyKey) => {\n VcClaimWithOptions({ notEmpty: true })(target, propertyKey);\n\n registerDecoratorName(target, propertyKey, PROPERTY_DECORATOR_NAMES.VC_NOT_EMPTY_CLAIM);\n};\n\nexport const VcClaimJsonLdIri =\n (jsonLdIri: string): PropertyDecorator =>\n (target, propertyKey) => {\n VcClaimWithOptions({ jsonLdIri })(target, propertyKey);\n\n registerDecoratorName(target, propertyKey, PROPERTY_DECORATOR_NAMES.VC_CLAIM_JSON_LD_IRI);\n };\n\nexport const VcClaimJsonLdType =\n (jsonLdType: string): PropertyDecorator =>\n (target, propertyKey) => {\n VcClaimWithOptions({ jsonLdType })(target, propertyKey);\n\n registerDecoratorName(target, propertyKey, PROPERTY_DECORATOR_NAMES.VC_CLAIM_JSON_LD_TYPE);\n };\n\nexport const VcClaimTitle =\n (title: string): PropertyDecorator =>\n (target, propertyKey) => {\n VcClaimWithOptions({ title })(target, propertyKey);\n\n registerDecoratorName(target, propertyKey, PROPERTY_DECORATOR_NAMES.VC_CLAIM_TITLE);\n };\n\nexport const VcArrayClaim =\n (dataType: Ctor<any>): PropertyDecorator =>\n (target, propertyKey) => {\n VcClaimWithOptions({ dataType })(target, propertyKey);\n\n registerDecoratorName(target, propertyKey, PROPERTY_DECORATOR_NAMES.VC_ARRAY_CLAIM);\n };\n\nexport const VcStringEnumClaim =\n (value: ClaimsSchemaEnumValue[]): PropertyDecorator =>\n (target, propertyKey) => {\n if (typeof propertyKey !== 'string') return;\n\n const tsType: Ctor<any> = Reflect.getMetadata('design:type', target, propertyKey);\n\n if (tsType !== String) throw new Error(`Only string enum values allowed.`);\n\n VcClaimWithOptions()(target, propertyKey);\n registerClaim(target, {\n name: propertyKey,\n enumValuesDescriptor: value,\n });\n\n registerDecoratorName(target, propertyKey, PROPERTY_DECORATOR_NAMES.VC_STRING_ENUM_CLAIM);\n };\n\nexport const VcExternalSchema =\n (options: VcExternalSchemaOptions): ClassDecorator =>\n (target) => {\n Reflect.defineMetadata(CLAIM_VC_EXTERNAL_SCHEMA, options, target);\n };\n\nexport const VcContext =\n (options: VcContextOptions): ClassDecorator =>\n (target) => {\n const metadata: VcContextMetadata = options;\n Reflect.defineMetadata(CLAIM_JSON_LD_CONTEXT, metadata, target);\n };\n\nexport const VcClaimType =\n (jsonLdType: string): PropertyDecorator =>\n (target, propertyKey) => {\n VcClaimWithOptions({ jsonLdType })(target, propertyKey);\n\n registerDecoratorName(target, propertyKey, PROPERTY_DECORATOR_NAMES.VC_CLAIM_TYPE);\n };\n\nexport const VcSchema =\n (options?: VcSchemaOptions): ClassDecorator =>\n (target) => {\n Reflect.defineMetadata(CLAIM_VC_SCHEMA_OPTIONS, options || {}, target);\n };\n\nexport const VcSchemaJsonLdTermName =\n (value: string): ClassDecorator =>\n (target) => {\n Reflect.defineMetadata(CLAIM_VC_SCHEMA_JSON_LD_TERM_NAME, value, target);\n };\n\nVcSchema.jsonLdVocabUrl = 'VC_SCHEMA_JSON_LD_VOCAB_URL';\nVcSchema.vcdmJsonSchemaUrl = 'VC_SCHEMA_VCDM_JSON_SCHEMA_URL';\n\nexport const getTsDataTypeMetadata = (target: Ctor<any>, propertyKey: string): Ctor<any> | undefined =>\n Reflect.getMetadata('design:type', target.prototype, propertyKey);\n\nexport const getContextJsonLdMetadata = (target: Ctor<any>): VcContextMetadata | undefined =>\n Reflect.getMetadata(CLAIM_JSON_LD_CONTEXT, target);\n\nexport const getVcSchemaMetadata = (target: Ctor<any>): VcSchemaMetadata | undefined => {\n const vcSchemaOptions = Reflect.getMetadata(CLAIM_VC_SCHEMA_OPTIONS, target);\n if (vcSchemaOptions) {\n const vcExternalSchema = Reflect.getMetadata(CLAIM_VC_EXTERNAL_SCHEMA, target);\n const vcSchemaJsonLdTermName = Reflect.getMetadata(CLAIM_VC_SCHEMA_JSON_LD_TERM_NAME, target);\n return {\n slug: vcSchemaOptions.slug,\n version: vcSchemaOptions.version == null ? 1 : vcSchemaOptions.version,\n owner: vcSchemaOptions.owner,\n vcJsonSchemas: vcExternalSchema?.vcJsonSchemas,\n jsonLdVocabs: vcExternalSchema?.jsonLdVocabs,\n jsonLdTermName: vcSchemaJsonLdTermName || undefined,\n };\n }\n\n const vcContextMetadata = getContextJsonLdMetadata(target);\n if (vcContextMetadata) {\n return vcSchemaMetadataFromVcContextMetadata(vcContextMetadata);\n }\n\n return undefined;\n};\n\nexport const getVcSchemaMetadataOrThrow = (target: Ctor<any>): VcSchemaMetadata => {\n const vcSchemaOptions = getVcSchemaMetadata(target);\n if (vcSchemaOptions == null) {\n throw new DocumentedError(\n ErrorCode.VcSchemaAnnotationMissing,\n '@VcSchema annotation is required on the UDT class',\n );\n }\n return vcSchemaOptions;\n};\n\nexport const getRegisteredClaimsList = (target: Ctor<any>): ClaimsListMetadata =>\n Reflect.getMetadata(CLAIMS_LIST, target.prototype) || [];\n"]}
1
+ {"version":3,"file":"decorators.js","sourceRoot":"","sources":["../../src/documents/decorators.ts"],"names":[],"mappings":";;;AAAA,4BAA0B;AAG1B,mCAAiD;AACjD,qCAAwD;AAG3C,QAAA,gBAAgB,GAAG,kBAAkB,CAAC;AACtC,QAAA,WAAW,GAAG,GAAG,wBAAgB,OAAO,CAAC;AACzC,QAAA,qBAAqB,GAAG,GAAG,wBAAgB,aAAa,CAAC;AACzD,QAAA,uBAAuB,GAAG,GAAG,wBAAgB,oBAAoB,CAAC;AAClE,QAAA,wBAAwB,GAAG,GAAG,wBAAgB,qBAAqB,CAAC;AACpE,QAAA,iCAAiC,GAAG,GAAG,wBAAgB,8BAA8B,CAAC;AACtF,QAAA,kBAAkB,GAAG,GAAG,wBAAgB,UAAU,CAAC;AACnD,QAAA,iBAAiB,GAAG,GAAG,wBAAgB,cAAc,CAAC;AACnE,MAAM,oBAAoB,GAAG,sBAAsB,CAAC;AAuCpD,MAAM,aAAa,GAAG,CAAC,MAAc,EAAE,KAAsB,EAAE,EAAE;IAC7D,IAAI,CAAC,OAAO,CAAC,WAAW,CAAC,mBAAW,EAAE,MAAM,CAAC,EAAE,CAAC;QAC5C,OAAO,CAAC,cAAc,CAAC,mBAAW,EAAE,EAAE,EAAE,MAAM,CAAC,CAAC;IACpD,CAAC;IACD,MAAM,UAAU,GAAuB,OAAO,CAAC,WAAW,CAAC,mBAAW,EAAE,MAAM,CAAC,CAAC;IAEhF,MAAM,aAAa,GAAG,UAAU,CAAC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,EAAE,EAAE,CAAC,IAAI,KAAK,KAAK,CAAC,IAAI,CAAC,CAAC;IAEzE,IAAI,aAAa,EAAE,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CAAC;QAC1B,MAAM,IAAI,gBAAQ,CAAC,oBAAY,CAAC,yBAAyB,EAAE,mDAAmD,CAAC,CAAC;IACpH,CAAC;IACD,OAAO,eAAe,CAAC;AAC3B,CAAC,CAAC;AANW,QAAA,0BAA0B,8BAMrC;AAEK,MAAM,uBAAuB,GAAG,CAAC,MAAiB,EAAsB,EAAE,CAC7E,OAAO,CAAC,WAAW,CAAC,mBAAW,EAAE,MAAM,CAAC,SAAS,CAAC,IAAI,EAAE,CAAC;AADhD,QAAA,uBAAuB,2BACyB","sourcesContent":["import 'reflect-metadata';\n\nimport { ClaimsSchemaEnumValue } from '../api';\nimport { UdtError, UdtErrorCode } from './error';\nimport { LinkedCredential, LinkedFile } from './models';\nimport type { Ctor } from './types';\n\nexport const DECORATOR_PREFIX = 'credential-claim';\nexport const CLAIMS_LIST = `${DECORATOR_PREFIX}:list`;\nexport const CLAIM_JSON_LD_CONTEXT = `${DECORATOR_PREFIX}:ld-context`;\nexport const CLAIM_VC_SCHEMA_OPTIONS = `${DECORATOR_PREFIX}:vc-schema-options`;\nexport const CLAIM_VC_EXTERNAL_SCHEMA = `${DECORATOR_PREFIX}:vc-external-schema`;\nexport const CLAIM_VC_SCHEMA_JSON_LD_TERM_NAME = `${DECORATOR_PREFIX}:vc-schema-json-ld-term-name`;\nexport const CLAIM_JSON_LD_TYPE = `${DECORATOR_PREFIX}:ld-type`;\nexport const CLAIM_LINKED_FILE = `${DECORATOR_PREFIX}:linked-file`;\nconst DECORATOR_NAMES_LIST = `decorator-names:list`;\n\ntype VcContextOptions = {\n name: string;\n namespace: string;\n vcType?: string[];\n};\n\ntype VcSchemaOptions = {\n slug?: string;\n version?: number;\n owner?: string;\n};\n\nexport type VcSchemaMetadata = {\n slug?: string;\n version: number;\n owner?: string;\n vcJsonSchemas?: string[];\n jsonLdVocabs?: string[];\n jsonLdBaseIri?: string;\n jsonLdTermName?: string;\n};\n\ntype VcContextMetadata = VcContextOptions;\n\nexport type ClaimDescriptor = {\n name: string;\n nestedType?: Ctor<any>;\n title?: string;\n isArray?: boolean;\n notEmpty?: boolean;\n enumValuesDescriptor?: ClaimsSchemaEnumValue[];\n jsonLdIri?: string;\n jsonLdType?: string;\n};\n\ntype ClaimsListMetadata = ClaimDescriptor[];\n\nconst registerClaim = (target: object, claim: ClaimDescriptor) => {\n if (!Reflect.hasMetadata(CLAIMS_LIST, target)) {\n Reflect.defineMetadata(CLAIMS_LIST, [], target);\n }\n const claimsList: ClaimsListMetadata = Reflect.getMetadata(CLAIMS_LIST, target);\n\n const existingClaim = claimsList.find(({ name }) => name === claim.name);\n\n if (existingClaim) {\n Object.assign(existingClaim, claim);\n } else {\n claimsList.push(claim);\n }\n};\n\nconst PROPERTY_DECORATOR_NAMES = {\n VC_CLAIM: 'VcClaim',\n VC_CLAIM_TITLE: 'VcClaimTitle',\n VC_NOT_EMPTY_CLAIM: 'VcNotEmptyClaim',\n VC_STRING_ENUM_CLAIM: 'VcStringEnumClaim',\n VC_ARRAY_CLAIM: 'VcArrayClaim',\n VC_CLAIM_TYPE: 'VcClaimType',\n VC_CLAIM_JSON_LD_IRI: 'VcClaimJsonLdIri',\n VC_CLAIM_JSON_LD_TYPE: 'VcClaimJsonLdType',\n};\n\nconst reportDecoratorsUsage = (\n propertyKey: string | symbol,\n newPropertyDecoratorName: string,\n {\n irrelevantDueToList,\n makesObsoleteList,\n contradictsWithList,\n }: { irrelevantDueToList?: string[]; makesObsoleteList?: string[]; contradictsWithList?: string[] },\n existingDecoratorsList: string[],\n) => {\n const alreadyDefinedContradictsWith = contradictsWithList\n ? existingDecoratorsList.find((value) => contradictsWithList.includes(value))\n : undefined;\n\n if (alreadyDefinedContradictsWith) {\n throw new Error(\n `Property decorator \"${newPropertyDecoratorName}\" is incompatible with existing \"${alreadyDefinedContradictsWith}\" on property \"${String(propertyKey)}\". Please review the existing decorators and remove one of them.`,\n );\n }\n\n if (process.env.NODE_ENV !== 'production' && process.env.NODE_ENV !== 'test') {\n const alreadyDefinedIrrelevantDueTo = irrelevantDueToList\n ? existingDecoratorsList.filter((value) => irrelevantDueToList.includes(value))\n : undefined;\n const alreadyDefinedMakesObsolete = makesObsoleteList\n ? existingDecoratorsList.filter((value) => makesObsoleteList.includes(value))\n : undefined;\n\n if (alreadyDefinedIrrelevantDueTo?.length) {\n console.warn(\n `The already defined decorator${alreadyDefinedIrrelevantDueTo.length > 1 ? 's' : ''} (\"${alreadyDefinedIrrelevantDueTo.join('\", \"')}\") on the property \"${String(propertyKey)}\" makes registering the new \"${newPropertyDecoratorName}\" decorator unnecessary. You can freely remove it.`,\n );\n }\n\n if (alreadyDefinedMakesObsolete?.length) {\n console.warn(\n `The already defined decorator${alreadyDefinedMakesObsolete.length > 1 ? 's' : ''} (\"${alreadyDefinedMakesObsolete.join('\", \"')}\") on the property \"${String(propertyKey)}\" ${alreadyDefinedMakesObsolete.length > 1 ? 'are' : 'is'} made obsolete by the new \"${newPropertyDecoratorName}\". You can freely remove ${alreadyDefinedMakesObsolete.length > 1 ? 'them' : 'it'}.`,\n );\n }\n }\n};\n\n/* incompatibility/overlapping property decorators table:\n\n| property decorator | VcClaim | VcNotEmptyClaim | VcClaimTitle | VcStringEnumClaim | VcArrayClaim | VcClaimType | VcClaimJsonLdIri | VcClaimJsonLdType |\n|-------------------------|---------|-----------------|--------------|-------------------|--------------|-------------|------------------|-------------------|\n| VcClaim | I | I | | I | I | | | |\n| VcNotEmptyClaim | O | I | | | | | | |\n| VcClaimTitle | | | C | | | | | |\n| VcStringEnumClaim | O | | | C | | | | |\n| VcArrayClaim | O | | | | C | | | |\n| VcClaimType | O | | | | | C | | C |\n| VcClaimJsonLdIri | O | | | | | | C | |\n| VcClaimJsonLdType | O | | | | | C | | C |\n\nLegend:\nO - <row name> makes obsolete <column name> [WARNING]\nI - <row name> irrelevant due to <column name> [WARNING]\nC - <row name> contradicts with <column name> [ERROR]\n\n */\nconst registerDecoratorName = (target: object, propertyKey: string | symbol, decoratorName: string) => {\n if (!Reflect.hasMetadata(DECORATOR_NAMES_LIST, target, propertyKey)) {\n Reflect.defineMetadata(DECORATOR_NAMES_LIST, [], target, propertyKey);\n }\n const existingDecoratorsList: string[] = Reflect.getMetadata(DECORATOR_NAMES_LIST, target, propertyKey);\n\n switch (decoratorName) {\n case PROPERTY_DECORATOR_NAMES.VC_CLAIM:\n reportDecoratorsUsage(\n propertyKey,\n decoratorName,\n {\n irrelevantDueToList: [\n PROPERTY_DECORATOR_NAMES.VC_CLAIM,\n PROPERTY_DECORATOR_NAMES.VC_NOT_EMPTY_CLAIM,\n PROPERTY_DECORATOR_NAMES.VC_STRING_ENUM_CLAIM,\n PROPERTY_DECORATOR_NAMES.VC_ARRAY_CLAIM,\n ],\n },\n existingDecoratorsList,\n );\n break;\n case PROPERTY_DECORATOR_NAMES.VC_NOT_EMPTY_CLAIM:\n reportDecoratorsUsage(\n propertyKey,\n decoratorName,\n {\n irrelevantDueToList: [PROPERTY_DECORATOR_NAMES.VC_NOT_EMPTY_CLAIM],\n makesObsoleteList: [PROPERTY_DECORATOR_NAMES.VC_CLAIM],\n },\n existingDecoratorsList,\n );\n break;\n case PROPERTY_DECORATOR_NAMES.VC_CLAIM_TITLE:\n reportDecoratorsUsage(\n propertyKey,\n decoratorName,\n {\n contradictsWithList: [PROPERTY_DECORATOR_NAMES.VC_CLAIM_TITLE],\n },\n existingDecoratorsList,\n );\n break;\n case PROPERTY_DECORATOR_NAMES.VC_STRING_ENUM_CLAIM:\n reportDecoratorsUsage(\n propertyKey,\n decoratorName,\n {\n contradictsWithList: [PROPERTY_DECORATOR_NAMES.VC_STRING_ENUM_CLAIM],\n makesObsoleteList: [PROPERTY_DECORATOR_NAMES.VC_CLAIM],\n },\n existingDecoratorsList,\n );\n break;\n case PROPERTY_DECORATOR_NAMES.VC_ARRAY_CLAIM:\n reportDecoratorsUsage(\n propertyKey,\n decoratorName,\n {\n contradictsWithList: [PROPERTY_DECORATOR_NAMES.VC_ARRAY_CLAIM],\n makesObsoleteList: [PROPERTY_DECORATOR_NAMES.VC_CLAIM],\n },\n existingDecoratorsList,\n );\n break;\n case PROPERTY_DECORATOR_NAMES.VC_CLAIM_TYPE:\n reportDecoratorsUsage(\n propertyKey,\n decoratorName,\n {\n contradictsWithList: [\n PROPERTY_DECORATOR_NAMES.VC_CLAIM_TYPE,\n PROPERTY_DECORATOR_NAMES.VC_CLAIM_JSON_LD_TYPE,\n ],\n makesObsoleteList: [PROPERTY_DECORATOR_NAMES.VC_CLAIM],\n },\n existingDecoratorsList,\n );\n break;\n case PROPERTY_DECORATOR_NAMES.VC_CLAIM_JSON_LD_IRI:\n reportDecoratorsUsage(\n propertyKey,\n decoratorName,\n {\n contradictsWithList: [PROPERTY_DECORATOR_NAMES.VC_CLAIM_JSON_LD_IRI],\n makesObsoleteList: [PROPERTY_DECORATOR_NAMES.VC_CLAIM],\n },\n existingDecoratorsList,\n );\n break;\n case PROPERTY_DECORATOR_NAMES.VC_CLAIM_JSON_LD_TYPE:\n reportDecoratorsUsage(\n propertyKey,\n decoratorName,\n {\n contradictsWithList: [\n PROPERTY_DECORATOR_NAMES.VC_CLAIM_JSON_LD_TYPE,\n PROPERTY_DECORATOR_NAMES.VC_CLAIM_TYPE,\n ],\n makesObsoleteList: [PROPERTY_DECORATOR_NAMES.VC_CLAIM],\n },\n existingDecoratorsList,\n );\n break;\n }\n\n existingDecoratorsList.push(decoratorName);\n};\n\ntype VcExternalSchemaOptions = {\n jsonLdVocabs?: string[];\n vcJsonSchemas?: string[];\n};\n\ntype VcClaimOptions = {\n title?: string;\n dataType?: Ctor<any>;\n notEmpty?: boolean;\n jsonLdIri?: string;\n jsonLdType?: string;\n};\n\nconst vcSchemaMetadataFromVcContextMetadata = (vcContextMetadata: VcContextMetadata): VcSchemaMetadata => {\n return {\n slug: undefined,\n version: 1,\n owner: undefined,\n jsonLdTermName: vcContextMetadata.name,\n jsonLdBaseIri: vcContextMetadata.namespace,\n };\n};\n\nexport const VcClaimWithOptions =\n ({ title, dataType, notEmpty, jsonLdIri, jsonLdType }: VcClaimOptions = {}): PropertyDecorator =>\n (target, propertyKey) => {\n if (typeof propertyKey !== 'string') return;\n\n let nestedType = dataType;\n const tsType: Ctor<any> = Reflect.getMetadata('design:type', target, propertyKey);\n\n if (\n !Array.of<Ctor<any>>(\n String,\n Number,\n Date,\n Boolean,\n Object,\n Array,\n Function,\n LinkedFile,\n LinkedCredential,\n ).includes(tsType)\n ) {\n nestedType = tsType;\n }\n\n const claim: ClaimDescriptor = {\n name: propertyKey,\n };\n\n if (nestedType != null) claim.nestedType = nestedType;\n if (tsType === Array) claim.isArray = true;\n if (title != null) claim.title = title;\n if (notEmpty != null) claim.notEmpty = notEmpty;\n if (jsonLdIri != null) claim.jsonLdIri = jsonLdIri;\n if (jsonLdType != null) claim.jsonLdType = jsonLdType;\n\n registerClaim(target, claim);\n };\n\nexport const VcClaim: PropertyDecorator = (target, propertyKey) => {\n VcClaimWithOptions()(target, propertyKey);\n\n registerDecoratorName(target, propertyKey, PROPERTY_DECORATOR_NAMES.VC_CLAIM);\n};\n\nexport const VcNotEmptyClaim: PropertyDecorator = (target, propertyKey) => {\n VcClaimWithOptions({ notEmpty: true })(target, propertyKey);\n\n registerDecoratorName(target, propertyKey, PROPERTY_DECORATOR_NAMES.VC_NOT_EMPTY_CLAIM);\n};\n\nexport const VcClaimJsonLdIri =\n (jsonLdIri: string): PropertyDecorator =>\n (target, propertyKey) => {\n VcClaimWithOptions({ jsonLdIri })(target, propertyKey);\n\n registerDecoratorName(target, propertyKey, PROPERTY_DECORATOR_NAMES.VC_CLAIM_JSON_LD_IRI);\n };\n\nexport const VcClaimJsonLdType =\n (jsonLdType: string): PropertyDecorator =>\n (target, propertyKey) => {\n VcClaimWithOptions({ jsonLdType })(target, propertyKey);\n\n registerDecoratorName(target, propertyKey, PROPERTY_DECORATOR_NAMES.VC_CLAIM_JSON_LD_TYPE);\n };\n\nexport const VcClaimTitle =\n (title: string): PropertyDecorator =>\n (target, propertyKey) => {\n VcClaimWithOptions({ title })(target, propertyKey);\n\n registerDecoratorName(target, propertyKey, PROPERTY_DECORATOR_NAMES.VC_CLAIM_TITLE);\n };\n\nexport const VcArrayClaim =\n (dataType: Ctor<any>): PropertyDecorator =>\n (target, propertyKey) => {\n VcClaimWithOptions({ dataType })(target, propertyKey);\n\n registerDecoratorName(target, propertyKey, PROPERTY_DECORATOR_NAMES.VC_ARRAY_CLAIM);\n };\n\nexport const VcStringEnumClaim =\n (value: ClaimsSchemaEnumValue[]): PropertyDecorator =>\n (target, propertyKey) => {\n if (typeof propertyKey !== 'string') return;\n\n const tsType: Ctor<any> = Reflect.getMetadata('design:type', target, propertyKey);\n\n if (tsType !== String) throw new Error(`Only string enum values allowed.`);\n\n VcClaimWithOptions()(target, propertyKey);\n registerClaim(target, {\n name: propertyKey,\n enumValuesDescriptor: value,\n });\n\n registerDecoratorName(target, propertyKey, PROPERTY_DECORATOR_NAMES.VC_STRING_ENUM_CLAIM);\n };\n\nexport const VcExternalSchema =\n (options: VcExternalSchemaOptions): ClassDecorator =>\n (target) => {\n Reflect.defineMetadata(CLAIM_VC_EXTERNAL_SCHEMA, options, target);\n };\n\nexport const VcContext =\n (options: VcContextOptions): ClassDecorator =>\n (target) => {\n const metadata: VcContextMetadata = options;\n Reflect.defineMetadata(CLAIM_JSON_LD_CONTEXT, metadata, target);\n };\n\nexport const VcClaimType =\n (jsonLdType: string): PropertyDecorator =>\n (target, propertyKey) => {\n VcClaimWithOptions({ jsonLdType })(target, propertyKey);\n\n registerDecoratorName(target, propertyKey, PROPERTY_DECORATOR_NAMES.VC_CLAIM_TYPE);\n };\n\nexport const VcSchema =\n (options?: VcSchemaOptions): ClassDecorator =>\n (target) => {\n Reflect.defineMetadata(CLAIM_VC_SCHEMA_OPTIONS, options || {}, target);\n };\n\nexport const VcSchemaJsonLdTermName =\n (value: string): ClassDecorator =>\n (target) => {\n Reflect.defineMetadata(CLAIM_VC_SCHEMA_JSON_LD_TERM_NAME, value, target);\n };\n\nVcSchema.jsonLdVocabUrl = 'VC_SCHEMA_JSON_LD_VOCAB_URL';\nVcSchema.vcdmJsonSchemaUrl = 'VC_SCHEMA_VCDM_JSON_SCHEMA_URL';\n\nexport const getTsDataTypeMetadata = (target: Ctor<any>, propertyKey: string): Ctor<any> | undefined =>\n Reflect.getMetadata('design:type', target.prototype, propertyKey);\n\nexport const getContextJsonLdMetadata = (target: Ctor<any>): VcContextMetadata | undefined =>\n Reflect.getMetadata(CLAIM_JSON_LD_CONTEXT, target);\n\nexport const getVcSchemaMetadata = (target: Ctor<any>): VcSchemaMetadata | undefined => {\n const vcSchemaOptions = Reflect.getMetadata(CLAIM_VC_SCHEMA_OPTIONS, target);\n if (vcSchemaOptions) {\n const vcExternalSchema = Reflect.getMetadata(CLAIM_VC_EXTERNAL_SCHEMA, target);\n const vcSchemaJsonLdTermName = Reflect.getMetadata(CLAIM_VC_SCHEMA_JSON_LD_TERM_NAME, target);\n return {\n slug: vcSchemaOptions.slug,\n version: vcSchemaOptions.version == null ? 1 : vcSchemaOptions.version,\n owner: vcSchemaOptions.owner,\n vcJsonSchemas: vcExternalSchema?.vcJsonSchemas,\n jsonLdVocabs: vcExternalSchema?.jsonLdVocabs,\n jsonLdTermName: vcSchemaJsonLdTermName || undefined,\n };\n }\n\n const vcContextMetadata = getContextJsonLdMetadata(target);\n if (vcContextMetadata) {\n return vcSchemaMetadataFromVcContextMetadata(vcContextMetadata);\n }\n\n return undefined;\n};\n\nexport const getVcSchemaMetadataOrThrow = (target: Ctor<any>): VcSchemaMetadata => {\n const vcSchemaOptions = getVcSchemaMetadata(target);\n if (vcSchemaOptions == null) {\n throw new UdtError(UdtErrorCode.VcSchemaAnnotationMissing, '@VcSchema annotation is required on the UDT class');\n }\n return vcSchemaOptions;\n};\n\nexport const getRegisteredClaimsList = (target: Ctor<any>): ClaimsListMetadata =>\n Reflect.getMetadata(CLAIMS_LIST, target.prototype) || [];\n"]}
@@ -0,0 +1,14 @@
1
+ export declare const UdtErrorCode: {
2
+ readonly VcSchemaAnnotationMissing: "T001";
3
+ readonly UnexpectedTypeInSerialization: "T002";
4
+ readonly UnsupportedTypeInUDT: "T003";
5
+ readonly IncompatibleUDT: "T004";
6
+ readonly VcSchemaMissingSlug: "T005";
7
+ readonly VcSchemaDifferentOwner: "T006";
8
+ };
9
+ export type UdtErrorCode = (typeof UdtErrorCode)[keyof typeof UdtErrorCode];
10
+ export declare class UdtError extends Error {
11
+ code: UdtErrorCode;
12
+ constructor(code: UdtErrorCode, msg: string);
13
+ }
14
+ //# sourceMappingURL=error.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/documents/error.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,YAAY;;;;;;;CAOf,CAAC;AACX,MAAM,MAAM,YAAY,GAAG,CAAC,OAAO,YAAY,CAAC,CAAC,MAAM,OAAO,YAAY,CAAC,CAAC;AAE5E,qBAAa,QAAS,SAAQ,KAAK;IAEpB,IAAI,EAAE,YAAY;gBAAlB,IAAI,EAAE,YAAY,EACzB,GAAG,EAAE,MAAM;CAMlB"}
@@ -0,0 +1,19 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UdtError = exports.UdtErrorCode = void 0;
4
+ exports.UdtErrorCode = {
5
+ VcSchemaAnnotationMissing: 'T001',
6
+ UnexpectedTypeInSerialization: 'T002',
7
+ UnsupportedTypeInUDT: 'T003',
8
+ IncompatibleUDT: 'T004',
9
+ VcSchemaMissingSlug: 'T005',
10
+ VcSchemaDifferentOwner: 'T006',
11
+ };
12
+ class UdtError extends Error {
13
+ constructor(code, msg) {
14
+ super(`${msg}\nFor more information about this error, check https://docs.truvity.com/sdk/reference/error-codes#${code}`);
15
+ this.code = code;
16
+ }
17
+ }
18
+ exports.UdtError = UdtError;
19
+ //# sourceMappingURL=error.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/documents/error.ts"],"names":[],"mappings":";;;AAAa,QAAA,YAAY,GAAG;IACxB,yBAAyB,EAAE,MAAM;IACjC,6BAA6B,EAAE,MAAM;IACrC,oBAAoB,EAAE,MAAM;IAC5B,eAAe,EAAE,MAAM;IACvB,mBAAmB,EAAE,MAAM;IAC3B,sBAAsB,EAAE,MAAM;CACxB,CAAC;AAGX,MAAa,QAAS,SAAQ,KAAK;IAC/B,YACW,IAAkB,EACzB,GAAW;QAEX,KAAK,CACD,GAAG,GAAG,qGAAqG,IAAI,EAAE,CACpH,CAAC;QALK,SAAI,GAAJ,IAAI,CAAc;IAM7B,CAAC;CACJ;AATD,4BASC","sourcesContent":["export const UdtErrorCode = {\n VcSchemaAnnotationMissing: 'T001',\n UnexpectedTypeInSerialization: 'T002',\n UnsupportedTypeInUDT: 'T003',\n IncompatibleUDT: 'T004',\n VcSchemaMissingSlug: 'T005',\n VcSchemaDifferentOwner: 'T006',\n} as const;\nexport type UdtErrorCode = (typeof UdtErrorCode)[keyof typeof UdtErrorCode];\n\nexport class UdtError extends Error {\n constructor(\n public code: UdtErrorCode,\n msg: string,\n ) {\n super(\n `${msg}\\nFor more information about this error, check https://docs.truvity.com/sdk/reference/error-codes#${code}`,\n );\n }\n}\n"]}
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.spec.d.ts","sourceRoot":"","sources":["../../src/documents/error.spec.ts"],"names":[],"mappings":""}
@@ -0,0 +1,14 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ const error_1 = require("./error");
4
+ describe('UdtError', () => {
5
+ it('serializes correctly', () => {
6
+ expect(new error_1.UdtError(error_1.UdtErrorCode.VcSchemaAnnotationMissing, 'Specific error message').message).toEqual('Specific error message\nFor more information about this error, check https://docs.truvity.com/sdk/reference/error-codes#T001');
7
+ });
8
+ it('contains error code', () => {
9
+ expect(new error_1.UdtError(error_1.UdtErrorCode.VcSchemaAnnotationMissing, 'Specific error message')).toMatchObject({
10
+ code: error_1.UdtErrorCode.VcSchemaAnnotationMissing,
11
+ });
12
+ });
13
+ });
14
+ //# sourceMappingURL=error.spec.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.spec.js","sourceRoot":"","sources":["../../src/documents/error.spec.ts"],"names":[],"mappings":";;AAAA,mCAAiD;AAEjD,QAAQ,CAAC,UAAU,EAAE,GAAG,EAAE;IACtB,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE;QAC5B,MAAM,CAAC,IAAI,gBAAQ,CAAC,oBAAY,CAAC,yBAAyB,EAAE,wBAAwB,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CAClG,8HAA8H,CACjI,CAAC;IACN,CAAC,CAAC,CAAC;IAEH,EAAE,CAAC,qBAAqB,EAAE,GAAG,EAAE;QAC3B,MAAM,CAAC,IAAI,gBAAQ,CAAC,oBAAY,CAAC,yBAAyB,EAAE,wBAAwB,CAAC,CAAC,CAAC,aAAa,CAAC;YACjG,IAAI,EAAE,oBAAY,CAAC,yBAAyB;SAC/C,CAAC,CAAC;IACP,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["import { UdtError, UdtErrorCode } from './error';\n\ndescribe('UdtError', () => {\n it('serializes correctly', () => {\n expect(new UdtError(UdtErrorCode.VcSchemaAnnotationMissing, 'Specific error message').message).toEqual(\n 'Specific error message\\nFor more information about this error, check https://docs.truvity.com/sdk/reference/error-codes#T001',\n );\n });\n\n it('contains error code', () => {\n expect(new UdtError(UdtErrorCode.VcSchemaAnnotationMissing, 'Specific error message')).toMatchObject({\n code: UdtErrorCode.VcSchemaAnnotationMissing,\n });\n });\n});\n"]}
@@ -1,6 +1,7 @@
1
1
  export * from './credential';
2
2
  export * from './credential/flavor';
3
3
  export * from './decorators';
4
+ export * from './error';
4
5
  export * from './models';
5
6
  export * from './presentation';
6
7
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":"AAAA,cAAc,cAAc,CAAC;AAC7B,cAAc,qBAAqB,CAAC;AACpC,cAAc,cAAc,CAAC;AAC7B,cAAc,SAAS,CAAC;AACxB,cAAc,UAAU,CAAC;AACzB,cAAc,gBAAgB,CAAC"}
@@ -17,6 +17,7 @@ Object.defineProperty(exports, "__esModule", { value: true });
17
17
  __exportStar(require("./credential"), exports);
18
18
  __exportStar(require("./credential/flavor"), exports);
19
19
  __exportStar(require("./decorators"), exports);
20
+ __exportStar(require("./error"), exports);
20
21
  __exportStar(require("./models"), exports);
21
22
  __exportStar(require("./presentation"), exports);
22
23
  //# sourceMappingURL=index.js.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,sDAAoC;AACpC,+CAA6B;AAC7B,2CAAyB;AACzB,iDAA+B","sourcesContent":["export * from './credential';\nexport * from './credential/flavor';\nexport * from './decorators';\nexport * from './models';\nexport * from './presentation';\n"]}
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/documents/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,+CAA6B;AAC7B,sDAAoC;AACpC,+CAA6B;AAC7B,0CAAwB;AACxB,2CAAyB;AACzB,iDAA+B","sourcesContent":["export * from './credential';\nexport * from './credential/flavor';\nexport * from './decorators';\nexport * from './error';\nexport * from './models';\nexport * from './presentation';\n"]}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@truvity/sdk",
3
- "version": "0.40.13",
3
+ "version": "0.40.14",
4
4
  "repository": "https://github.com/truvity/sdk-typescript",
5
5
  "main": "./index.js",
6
6
  "types": "./index.d.ts",
@@ -1,13 +0,0 @@
1
- export declare const ErrorCode: {
2
- readonly VcContextAnnotationMissing: "T001";
3
- readonly UnexpectedTypeInSerialization: "T002";
4
- readonly UnsupportedTypeInUDT: "T003";
5
- readonly IncompatibleUDT: "T004";
6
- readonly VcSchemaAnnotationMissing: "T005";
7
- readonly VcSchemaMissingSlug: "T006";
8
- };
9
- export type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];
10
- export declare class DocumentedError extends Error {
11
- constructor(errorCode: ErrorCode, msg: string);
12
- }
13
- //# sourceMappingURL=error.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../../src/documents/utils/error.ts"],"names":[],"mappings":"AAAA,eAAO,MAAM,SAAS;;;;;;;CAOZ,CAAC;AAEX,MAAM,MAAM,SAAS,GAAG,CAAC,OAAO,SAAS,CAAC,CAAC,MAAM,OAAO,SAAS,CAAC,CAAC;AAEnE,qBAAa,eAAgB,SAAQ,KAAK;gBAC1B,SAAS,EAAE,SAAS,EAAE,GAAG,EAAE,MAAM;CAKhD"}
@@ -1,18 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DocumentedError = exports.ErrorCode = void 0;
4
- exports.ErrorCode = {
5
- VcContextAnnotationMissing: 'T001',
6
- UnexpectedTypeInSerialization: 'T002',
7
- UnsupportedTypeInUDT: 'T003',
8
- IncompatibleUDT: 'T004',
9
- VcSchemaAnnotationMissing: 'T005',
10
- VcSchemaMissingSlug: 'T006',
11
- };
12
- class DocumentedError extends Error {
13
- constructor(errorCode, msg) {
14
- super(`${msg}\nFor more information about this error, check https://docs.truvity.com/sdk/reference/error-codes#${errorCode}`);
15
- }
16
- }
17
- exports.DocumentedError = DocumentedError;
18
- //# sourceMappingURL=error.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../../src/documents/utils/error.ts"],"names":[],"mappings":";;;AAAa,QAAA,SAAS,GAAG;IACrB,0BAA0B,EAAE,MAAM;IAClC,6BAA6B,EAAE,MAAM;IACrC,oBAAoB,EAAE,MAAM;IAC5B,eAAe,EAAE,MAAM;IACvB,yBAAyB,EAAE,MAAM;IACjC,mBAAmB,EAAE,MAAM;CACrB,CAAC;AAIX,MAAa,eAAgB,SAAQ,KAAK;IACtC,YAAY,SAAoB,EAAE,GAAW;QACzC,KAAK,CACD,GAAG,GAAG,qGAAqG,SAAS,EAAE,CACzH,CAAC;IACN,CAAC;CACJ;AAND,0CAMC","sourcesContent":["export const ErrorCode = {\n VcContextAnnotationMissing: 'T001',\n UnexpectedTypeInSerialization: 'T002',\n UnsupportedTypeInUDT: 'T003',\n IncompatibleUDT: 'T004',\n VcSchemaAnnotationMissing: 'T005',\n VcSchemaMissingSlug: 'T006',\n} as const;\n\nexport type ErrorCode = (typeof ErrorCode)[keyof typeof ErrorCode];\n\nexport class DocumentedError extends Error {\n constructor(errorCode: ErrorCode, msg: string) {\n super(\n `${msg}\\nFor more information about this error, check https://docs.truvity.com/sdk/reference/error-codes#${errorCode}`,\n );\n }\n}\n"]}
@@ -1 +0,0 @@
1
- {"version":3,"file":"error.spec.d.ts","sourceRoot":"","sources":["../../../src/documents/utils/error.spec.ts"],"names":[],"mappings":""}
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const error_1 = require("./error");
4
- describe('DocumentedError', () => {
5
- it('serializes correctly', () => {
6
- expect(new error_1.DocumentedError(error_1.ErrorCode.VcSchemaAnnotationMissing, 'Specific error message').message).toEqual('Specific error message\nFor more information about this error, check https://docs.truvity.com/sdk/reference/error-codes#T005');
7
- });
8
- });
9
- //# sourceMappingURL=error.spec.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"error.spec.js","sourceRoot":"","sources":["../../../src/documents/utils/error.spec.ts"],"names":[],"mappings":";;AAAA,mCAAqD;AAErD,QAAQ,CAAC,iBAAiB,EAAE,GAAG,EAAE;IAC7B,EAAE,CAAC,sBAAsB,EAAE,GAAG,EAAE;QAC5B,MAAM,CAAC,IAAI,uBAAe,CAAC,iBAAS,CAAC,yBAAyB,EAAE,wBAAwB,CAAC,CAAC,OAAO,CAAC,CAAC,OAAO,CACtG,8HAA8H,CACjI,CAAC;IACN,CAAC,CAAC,CAAC;AACP,CAAC,CAAC,CAAC","sourcesContent":["import { DocumentedError, ErrorCode } from './error';\n\ndescribe('DocumentedError', () => {\n it('serializes correctly', () => {\n expect(new DocumentedError(ErrorCode.VcSchemaAnnotationMissing, 'Specific error message').message).toEqual(\n 'Specific error message\\nFor more information about this error, check https://docs.truvity.com/sdk/reference/error-codes#T005',\n );\n });\n});\n"]}