@keetanetwork/anchor 0.0.62 → 0.0.63

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.
Files changed (80) hide show
  1. package/lib/anchor-metadata-server.d.ts +54 -0
  2. package/lib/anchor-metadata-server.d.ts.map +1 -0
  3. package/lib/anchor-metadata-server.js +62 -0
  4. package/lib/anchor-metadata-server.js.map +1 -0
  5. package/lib/error.d.ts +35 -0
  6. package/lib/error.d.ts.map +1 -1
  7. package/lib/error.generated.d.ts +3 -0
  8. package/lib/error.generated.d.ts.map +1 -0
  9. package/lib/error.generated.js +104 -0
  10. package/lib/error.generated.js.map +1 -0
  11. package/lib/error.js +66 -1
  12. package/lib/error.js.map +1 -1
  13. package/lib/http-server/common.d.ts +20 -2
  14. package/lib/http-server/common.d.ts.map +1 -1
  15. package/lib/http-server/common.js +47 -0
  16. package/lib/http-server/common.js.map +1 -1
  17. package/lib/http-server/index.d.ts +22 -0
  18. package/lib/http-server/index.d.ts.map +1 -1
  19. package/lib/http-server/index.js +23 -0
  20. package/lib/http-server/index.js.map +1 -1
  21. package/lib/metadata.types.d.ts +40 -0
  22. package/lib/metadata.types.d.ts.map +1 -1
  23. package/lib/metadata.types.js.map +1 -1
  24. package/lib/resolver.d.ts +19 -20
  25. package/lib/resolver.d.ts.map +1 -1
  26. package/lib/resolver.js +1420 -681
  27. package/lib/resolver.js.map +1 -1
  28. package/lib/utils/certificate-network.d.ts +84 -0
  29. package/lib/utils/certificate-network.d.ts.map +1 -0
  30. package/lib/utils/certificate-network.js +104 -0
  31. package/lib/utils/certificate-network.js.map +1 -0
  32. package/lib/utils/signing.d.ts +12 -0
  33. package/lib/utils/signing.d.ts.map +1 -1
  34. package/lib/utils/signing.js +145 -2
  35. package/lib/utils/signing.js.map +1 -1
  36. package/npm-shrinkwrap.json +4 -4
  37. package/package.json +1 -1
  38. package/services/asset-movement/common.d.ts.map +1 -1
  39. package/services/asset-movement/common.js +7 -53
  40. package/services/asset-movement/common.js.map +1 -1
  41. package/services/asset-movement/server.d.ts +6 -4
  42. package/services/asset-movement/server.d.ts.map +1 -1
  43. package/services/asset-movement/server.js +3 -3
  44. package/services/asset-movement/server.js.map +1 -1
  45. package/services/fx/common.js +7 -7
  46. package/services/fx/server.d.ts +9 -7
  47. package/services/fx/server.d.ts.map +1 -1
  48. package/services/fx/server.js +5 -5
  49. package/services/fx/server.js.map +1 -1
  50. package/services/kyc/server.d.ts +6 -4
  51. package/services/kyc/server.d.ts.map +1 -1
  52. package/services/kyc/server.js +3 -3
  53. package/services/kyc/server.js.map +1 -1
  54. package/services/notification/common.d.ts +2 -1
  55. package/services/notification/common.d.ts.map +1 -1
  56. package/services/notification/common.generated.js +20 -20
  57. package/services/notification/common.js +3 -2
  58. package/services/notification/common.js.map +1 -1
  59. package/services/notification/server.d.ts +7 -6
  60. package/services/notification/server.d.ts.map +1 -1
  61. package/services/notification/server.js +25 -62
  62. package/services/notification/server.js.map +1 -1
  63. package/services/storage/common.d.ts +2 -1
  64. package/services/storage/common.d.ts.map +1 -1
  65. package/services/storage/common.js +7 -2
  66. package/services/storage/common.js.map +1 -1
  67. package/services/storage/server.d.ts +7 -5
  68. package/services/storage/server.d.ts.map +1 -1
  69. package/services/storage/server.js +29 -99
  70. package/services/storage/server.js.map +1 -1
  71. package/services/username/common.d.ts +2 -1
  72. package/services/username/common.d.ts.map +1 -1
  73. package/services/username/common.generated.js +14 -48
  74. package/services/username/common.generated.js.map +1 -1
  75. package/services/username/common.js +3 -2
  76. package/services/username/common.js.map +1 -1
  77. package/services/username/server.d.ts +7 -6
  78. package/services/username/server.d.ts.map +1 -1
  79. package/services/username/server.js +38 -46
  80. package/services/username/server.js.map +1 -1
@@ -0,0 +1,54 @@
1
+ import type { KeetaAnchorHTTPServerConfig } from './http-server/index.js';
2
+ import type { HTTPSignedField } from './http-server/common.js';
3
+ import type { SignableAccount, VerifiableAccount } from './utils/signing.js';
4
+ import type { ServiceMetadataEndpoint, SharedAnchorMetadataLegalExtension, SharedAnchorMetadataSignedExtension } from './metadata.types.js';
5
+ import { KeetaNetAnchorHTTPServer } from './http-server/index.js';
6
+ /**
7
+ * Namespace tag bound into every service metadata signature.
8
+ */
9
+ export declare const METADATA_SIGNATURE_NAMESPACE = "keetanet/anchor/service-metadata/v1";
10
+ /**
11
+ * Service metadata shape whose signed fields can be authenticated
12
+ * by {@link KeetaAnchorMetadataServer}.
13
+ */
14
+ export type SignableServiceMetadata = SharedAnchorMetadataLegalExtension & {
15
+ operations: {
16
+ [operationName: string]: ServiceMetadataEndpoint | undefined;
17
+ };
18
+ };
19
+ /**
20
+ * Canonical fields covered by the metadata signature. `namespace` scopes
21
+ * the signature to this protocol/version.
22
+ */
23
+ export type SignedServiceMetadataFields = {
24
+ namespace: typeof METADATA_SIGNATURE_NAMESPACE;
25
+ account: string;
26
+ operations: SignableServiceMetadata['operations'];
27
+ legal?: SignableServiceMetadata['legal'];
28
+ };
29
+ export interface KeetaAnchorMetadataServerConfig extends KeetaAnchorHTTPServerConfig {
30
+ /** Signs the published metadata. Omit for unsigned metadata. */
31
+ metadataSigner?: SignableAccount | undefined;
32
+ }
33
+ /**
34
+ * Extracts the subset of `metadata` that is covered by the signature.
35
+ * `account` is the public-key string of the claimed signer.
36
+ */
37
+ export declare function extractSignedFields(account: string, metadata: SignableServiceMetadata): SignedServiceMetadataFields;
38
+ /**
39
+ * Verifies that `signed` was produced by `account` over the signed
40
+ * fields of `metadata` (see {@link extractSignedFields}).
41
+ */
42
+ export declare function verifyMetadataSignature(account: VerifiableAccount, metadata: SignableServiceMetadata, signed: HTTPSignedField): Promise<boolean>;
43
+ /**
44
+ * Publishes anchor service metadata, optionally signed by `metadataSigner`.
45
+ * Subclasses implement {@link buildServiceMetadata}.
46
+ */
47
+ export declare abstract class KeetaAnchorMetadataServer<Built extends SignableServiceMetadata, C extends KeetaAnchorMetadataServerConfig = KeetaAnchorMetadataServerConfig> extends KeetaNetAnchorHTTPServer<C> {
48
+ #private;
49
+ constructor(config: C);
50
+ get metadataSigner(): SignableAccount | undefined;
51
+ protected abstract buildServiceMetadata(): Promise<Built>;
52
+ serviceMetadata(): Promise<Built & SharedAnchorMetadataSignedExtension>;
53
+ }
54
+ //# sourceMappingURL=anchor-metadata-server.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchor-metadata-server.d.ts","sourceRoot":"","sources":["../../src/lib/anchor-metadata-server.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,2BAA2B,EAAE,MAAM,wBAAwB,CAAC;AAC1E,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,yBAAyB,CAAC;AAC/D,OAAO,KAAK,EAAE,eAAe,EAAE,iBAAiB,EAAE,MAAM,oBAAoB,CAAC;AAC7E,OAAO,KAAK,EAAE,uBAAuB,EAAE,kCAAkC,EAAE,mCAAmC,EAAE,MAAM,qBAAqB,CAAC;AAC5I,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAGlE;;GAEG;AACH,eAAO,MAAM,4BAA4B,wCAAwC,CAAC;AAElF;;;GAGG;AACH,MAAM,MAAM,uBAAuB,GAAG,kCAAkC,GAAG;IAC1E,UAAU,EAAE;QAAE,CAAC,aAAa,EAAE,MAAM,GAAG,uBAAuB,GAAG,SAAS,CAAA;KAAE,CAAC;CAC7E,CAAC;AAEF;;;GAGG;AACH,MAAM,MAAM,2BAA2B,GAAG;IACzC,SAAS,EAAE,OAAO,4BAA4B,CAAC;IAC/C,OAAO,EAAE,MAAM,CAAC;IAChB,UAAU,EAAE,uBAAuB,CAAC,YAAY,CAAC,CAAC;IAClD,KAAK,CAAC,EAAE,uBAAuB,CAAC,OAAO,CAAC,CAAC;CACzC,CAAC;AAEF,MAAM,WAAW,+BAAgC,SAAQ,2BAA2B;IACnF,gEAAgE;IAChE,cAAc,CAAC,EAAE,eAAe,GAAG,SAAS,CAAC;CAC7C;AAED;;;GAGG;AACH,wBAAgB,mBAAmB,CAAC,OAAO,EAAE,MAAM,EAAE,QAAQ,EAAE,uBAAuB,GAAG,2BAA2B,CAWnH;AAED;;;GAGG;AACH,wBAAsB,uBAAuB,CAAC,OAAO,EAAE,iBAAiB,EAAE,QAAQ,EAAE,uBAAuB,EAAE,MAAM,EAAE,eAAe,GAAG,OAAO,CAAC,OAAO,CAAC,CAMtJ;AAED;;;GAGG;AACH,8BAAsB,yBAAyB,CAC9C,KAAK,SAAS,uBAAuB,EACrC,CAAC,SAAS,+BAA+B,GAAG,+BAA+B,CAC1E,SAAQ,wBAAwB,CAAC,CAAC,CAAC;;gBAGxB,MAAM,EAAE,CAAC;IAKrB,IAAI,cAAc,IAAI,eAAe,GAAG,SAAS,CAEhD;IAED,SAAS,CAAC,QAAQ,CAAC,oBAAoB,IAAI,OAAO,CAAC,KAAK,CAAC;IAEnD,eAAe,IAAI,OAAO,CAAC,KAAK,GAAG,mCAAmC,CAAC;CAmB7E"}
@@ -0,0 +1,62 @@
1
+ import { KeetaNetAnchorHTTPServer } from './http-server/index.js';
2
+ import { SignData, VerifySignedData, objectToSignable } from './utils/signing.js';
3
+ /**
4
+ * Namespace tag bound into every service metadata signature.
5
+ */
6
+ export const METADATA_SIGNATURE_NAMESPACE = 'keetanet/anchor/service-metadata/v1';
7
+ /**
8
+ * Extracts the subset of `metadata` that is covered by the signature.
9
+ * `account` is the public-key string of the claimed signer.
10
+ */
11
+ export function extractSignedFields(account, metadata) {
12
+ const fields = {
13
+ namespace: METADATA_SIGNATURE_NAMESPACE,
14
+ account: account,
15
+ operations: metadata.operations
16
+ };
17
+ if (metadata.legal !== undefined) {
18
+ fields.legal = metadata.legal;
19
+ }
20
+ return (fields);
21
+ }
22
+ /**
23
+ * Verifies that `signed` was produced by `account` over the signed
24
+ * fields of `metadata` (see {@link extractSignedFields}).
25
+ */
26
+ export async function verifyMetadataSignature(account, metadata, signed) {
27
+ const signedFields = extractSignedFields(account.publicKeyString.get(), metadata);
28
+ const signable = objectToSignable(signedFields);
29
+ const verifyOptions = { maxSkewMs: Number.POSITIVE_INFINITY };
30
+ return (await VerifySignedData(account, signable, signed, verifyOptions));
31
+ }
32
+ /**
33
+ * Publishes anchor service metadata, optionally signed by `metadataSigner`.
34
+ * Subclasses implement {@link buildServiceMetadata}.
35
+ */
36
+ export class KeetaAnchorMetadataServer extends KeetaNetAnchorHTTPServer {
37
+ #metadataSigner;
38
+ constructor(config) {
39
+ super(config);
40
+ this.#metadataSigner = config.metadataSigner;
41
+ }
42
+ get metadataSigner() {
43
+ return (this.#metadataSigner);
44
+ }
45
+ async serviceMetadata() {
46
+ const built = await this.buildServiceMetadata();
47
+ const signer = this.#metadataSigner;
48
+ if (signer === undefined) {
49
+ return (built);
50
+ }
51
+ const account = signer.publicKeyString.get();
52
+ const signedFields = extractSignedFields(account, built);
53
+ const signable = objectToSignable(signedFields);
54
+ const signed = await SignData(signer, signable);
55
+ return ({
56
+ ...built,
57
+ account,
58
+ signed
59
+ });
60
+ }
61
+ }
62
+ //# sourceMappingURL=anchor-metadata-server.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"anchor-metadata-server.js","sourceRoot":"","sources":["../../src/lib/anchor-metadata-server.ts"],"names":[],"mappings":"AAIA,OAAO,EAAE,wBAAwB,EAAE,MAAM,wBAAwB,CAAC;AAClE,OAAO,EAAE,QAAQ,EAAE,gBAAgB,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAElF;;GAEG;AACH,MAAM,CAAC,MAAM,4BAA4B,GAAG,qCAAqC,CAAC;AA0BlF;;;GAGG;AACH,MAAM,UAAU,mBAAmB,CAAC,OAAe,EAAE,QAAiC;IACrF,MAAM,MAAM,GAAgC;QAC3C,SAAS,EAAE,4BAA4B;QACvC,OAAO,EAAE,OAAO;QAChB,UAAU,EAAE,QAAQ,CAAC,UAAU;KAC/B,CAAC;IACF,IAAI,QAAQ,CAAC,KAAK,KAAK,SAAS,EAAE,CAAC;QAClC,MAAM,CAAC,KAAK,GAAG,QAAQ,CAAC,KAAK,CAAC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C,MAAM,EAAE,QAAQ,CAAC,CAAC;QAEhD,OAAM,CAAC;YACN,GAAG,KAAK;YACR,OAAO;YACP,MAAM;SACN,CAAC,CAAC;IACJ,CAAC;CACD","sourcesContent":["import type { KeetaAnchorHTTPServerConfig } from './http-server/index.js';\nimport type { HTTPSignedField } from './http-server/common.js';\nimport type { SignableAccount, VerifiableAccount } from './utils/signing.js';\nimport type { ServiceMetadataEndpoint, SharedAnchorMetadataLegalExtension, SharedAnchorMetadataSignedExtension } from './metadata.types.js';\nimport { KeetaNetAnchorHTTPServer } from './http-server/index.js';\nimport { SignData, VerifySignedData, objectToSignable } from './utils/signing.js';\n\n/**\n * Namespace tag bound into every service metadata signature.\n */\nexport const METADATA_SIGNATURE_NAMESPACE = 'keetanet/anchor/service-metadata/v1';\n\n/**\n * Service metadata shape whose signed fields can be authenticated\n * by {@link KeetaAnchorMetadataServer}.\n */\nexport type SignableServiceMetadata = SharedAnchorMetadataLegalExtension & {\n\toperations: { [operationName: string]: ServiceMetadataEndpoint | undefined };\n};\n\n/**\n * Canonical fields covered by the metadata signature. `namespace` scopes\n * the signature to this protocol/version.\n */\nexport type SignedServiceMetadataFields = {\n\tnamespace: typeof METADATA_SIGNATURE_NAMESPACE;\n\taccount: string;\n\toperations: SignableServiceMetadata['operations'];\n\tlegal?: SignableServiceMetadata['legal'];\n};\n\nexport interface KeetaAnchorMetadataServerConfig extends KeetaAnchorHTTPServerConfig {\n\t/** Signs the published metadata. Omit for unsigned metadata. */\n\tmetadataSigner?: SignableAccount | undefined;\n}\n\n/**\n * Extracts the subset of `metadata` that is covered by the signature.\n * `account` is the public-key string of the claimed signer.\n */\nexport function extractSignedFields(account: string, metadata: SignableServiceMetadata): SignedServiceMetadataFields {\n\tconst fields: SignedServiceMetadataFields = {\n\t\tnamespace: METADATA_SIGNATURE_NAMESPACE,\n\t\taccount: account,\n\t\toperations: metadata.operations\n\t};\n\tif (metadata.legal !== undefined) {\n\t\tfields.legal = metadata.legal;\n\t}\n\n\treturn(fields);\n}\n\n/**\n * Verifies that `signed` was produced by `account` over the signed\n * fields of `metadata` (see {@link extractSignedFields}).\n */\nexport async function verifyMetadataSignature(account: VerifiableAccount, metadata: SignableServiceMetadata, signed: HTTPSignedField): Promise<boolean> {\n\tconst signedFields = extractSignedFields(account.publicKeyString.get(), metadata);\n\tconst signable = objectToSignable(signedFields);\n\tconst verifyOptions = { maxSkewMs: Number.POSITIVE_INFINITY };\n\n\treturn(await VerifySignedData(account, signable, signed, verifyOptions));\n}\n\n/**\n * Publishes anchor service metadata, optionally signed by `metadataSigner`.\n * Subclasses implement {@link buildServiceMetadata}.\n */\nexport abstract class KeetaAnchorMetadataServer<\n\tBuilt extends SignableServiceMetadata,\n\tC extends KeetaAnchorMetadataServerConfig = KeetaAnchorMetadataServerConfig\n> extends KeetaNetAnchorHTTPServer<C> {\n\treadonly #metadataSigner: SignableAccount | undefined;\n\n\tconstructor(config: C) {\n\t\tsuper(config);\n\t\tthis.#metadataSigner = config.metadataSigner;\n\t}\n\n\tget metadataSigner(): SignableAccount | undefined {\n\t\treturn(this.#metadataSigner);\n\t}\n\n\tprotected abstract buildServiceMetadata(): Promise<Built>;\n\n\tasync serviceMetadata(): Promise<Built & SharedAnchorMetadataSignedExtension> {\n\t\tconst built = await this.buildServiceMetadata();\n\n\t\tconst signer = this.#metadataSigner;\n\t\tif (signer === undefined) {\n\t\t\treturn(built);\n\t\t}\n\n\t\tconst account = signer.publicKeyString.get();\n\t\tconst signedFields = extractSignedFields(account, built);\n\t\tconst signable = objectToSignable(signedFields);\n\t\tconst signed = await SignData(signer, signable);\n\n\t\treturn({\n\t\t\t...built,\n\t\t\taccount,\n\t\t\tsigned\n\t\t});\n\t}\n}\n"]}
package/lib/error.d.ts CHANGED
@@ -106,5 +106,40 @@ export declare class KeetaAnchorUserValidationError extends KeetaAnchorUserError
106
106
  static fromJSON(input: unknown): Promise<KeetaAnchorUserValidationError>;
107
107
  static fromTypeGuardError(input: TypeGuardErrorLike | TypeGuardErrorLike[], message?: string): KeetaAnchorUserValidationError;
108
108
  }
109
+ /**
110
+ * Failure mode for the certificate-chain gate.
111
+ */
112
+ export type KeetaAnchorCertificateRequiredKind = 'missing' | 'untrusted';
113
+ export interface KeetaAnchorCertificateRequiredErrorJSONProperties {
114
+ /**
115
+ * Outer array: any-of (OR). Inner array: all-of (AND).
116
+ */
117
+ acceptedIssuers: {
118
+ name: string;
119
+ value: string;
120
+ }[][];
121
+ kind: KeetaAnchorCertificateRequiredKind;
122
+ }
123
+ type KeetaAnchorCertificateRequiredErrorJSON = ReturnType<KeetaAnchorUserError['toJSON']> & KeetaAnchorCertificateRequiredErrorJSONProperties;
124
+ export declare class KeetaAnchorCertificateRequiredError extends KeetaAnchorUserError implements KeetaAnchorCertificateRequiredErrorJSONProperties {
125
+ static readonly name: string;
126
+ private readonly KeetaAnchorCertificateRequiredErrorObjectTypeID;
127
+ private static readonly KeetaAnchorCertificateRequiredErrorObjectTypeID;
128
+ readonly acceptedIssuers: {
129
+ name: string;
130
+ value: string;
131
+ }[][];
132
+ readonly kind: KeetaAnchorCertificateRequiredKind;
133
+ constructor(args: KeetaAnchorCertificateRequiredErrorJSONProperties, message?: string);
134
+ private static defaultMessage;
135
+ static isInstance(input: unknown): input is KeetaAnchorCertificateRequiredError;
136
+ asErrorResponse(contentType: 'text/plain' | 'application/json'): {
137
+ error: string;
138
+ statusCode: number;
139
+ contentType: string;
140
+ };
141
+ toJSON(): KeetaAnchorCertificateRequiredErrorJSON;
142
+ static fromJSON(input: unknown): Promise<KeetaAnchorCertificateRequiredError>;
143
+ }
109
144
  export {};
110
145
  //# sourceMappingURL=error.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"error.d.ts","sourceRoot":"","sources":["../../src/lib/error.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,cAAc,EAAE,MAAM,OAAO,CAAC;AAEzD,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;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C;QAAC,KAAK,EAAE,MAAM,CAAC;KAAE,EAAE,EAAE,CAAC;IAC/D,QAAQ,CAAC,IAAI,EAAE,kCAAkC,CAAC;gBAEtC,IAAI,EAAE,iDAAiD,EAAE,OAAO,CAAC,EAAE,MAAM;IAiBrF,OAAO,CAAC,MAAM,CAAC,cAAc;WAQb,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,mCAAmC;IAI/E,eAAe,CAAC,WAAW,EAAE,YAAY,GAAG,kBAAkB,GAAG;QAAE,KAAK,EAAE,MAAM,CAAC;QAAC,UAAU,EAAE,MAAM,CAAC;QAAC,WAAW,EAAE,MAAM,CAAA;KAAE;IAkB3H,MAAM,IAAI,uCAAuC;WAQpC,QAAQ,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAAC,mCAAmC,CAAC;CAc5F"}
@@ -0,0 +1,3 @@
1
+ import type { KeetaAnchorCertificateRequiredErrorJSONProperties } from './error.js';
2
+ export declare const assertKeetaAnchorCertificateRequiredErrorJSONProperties: (input: unknown) => KeetaAnchorCertificateRequiredErrorJSONProperties;
3
+ //# sourceMappingURL=error.generated.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.generated.d.ts","sourceRoot":"","sources":["../../src/lib/error.generated.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,iDAAiD,EAAE,MAAM,YAAY,CAAC;AAEpF,eAAO,MAAM,uDAAuD,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,iDAAiI,CAAC"}
@@ -0,0 +1,104 @@
1
+ import * as __typia_transform__assertGuard from "typia/lib/internal/_assertGuard.js";
2
+ import * as __typia_transform__accessExpressionAsString from "typia/lib/internal/_accessExpressionAsString.js";
3
+ import * as typia from 'typia';
4
+ export const assertKeetaAnchorCertificateRequiredErrorJSONProperties = (() => { const _io0 = (input, _exceptionable = true) => Array.isArray(input.acceptedIssuers) && input.acceptedIssuers.every((elem, _index1) => Array.isArray(elem) && elem.every((elem, _index2) => "object" === typeof elem && null !== elem && _io1(elem, true && _exceptionable))) && ("missing" === input.kind || "untrusted" === input.kind) && (2 === Object.keys(input).length || Object.keys(input).every(key => {
5
+ if (["acceptedIssuers", "kind"].some(prop => key === prop))
6
+ return true;
7
+ const value = input[key];
8
+ if (undefined === value)
9
+ return true;
10
+ return false;
11
+ })); const _io1 = (input, _exceptionable = true) => "string" === typeof input.name && "string" === typeof input.value && (2 === Object.keys(input).length || Object.keys(input).every(key => {
12
+ if (["name", "value"].some(prop => key === prop))
13
+ return true;
14
+ const value = input[key];
15
+ if (undefined === value)
16
+ return true;
17
+ return false;
18
+ })); const _ao0 = (input, _path, _exceptionable = true) => ((Array.isArray(input.acceptedIssuers) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
19
+ method: "typia.createAssertEquals",
20
+ path: _path + ".acceptedIssuers",
21
+ expected: "Array<Array<__type>>",
22
+ value: input.acceptedIssuers
23
+ }, _errorFactory)) && input.acceptedIssuers.every((elem, _index3) => (Array.isArray(elem) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
24
+ method: "typia.createAssertEquals",
25
+ path: _path + ".acceptedIssuers[" + _index3 + "]",
26
+ expected: "Array<__type>",
27
+ value: elem
28
+ }, _errorFactory)) && elem.every((elem, _index4) => ("object" === typeof elem && null !== elem || __typia_transform__assertGuard._assertGuard(_exceptionable, {
29
+ method: "typia.createAssertEquals",
30
+ path: _path + ".acceptedIssuers[" + _index3 + "][" + _index4 + "]",
31
+ expected: "__type",
32
+ value: elem
33
+ }, _errorFactory)) && _ao1(elem, _path + ".acceptedIssuers[" + _index3 + "][" + _index4 + "]", true && _exceptionable) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
34
+ method: "typia.createAssertEquals",
35
+ path: _path + ".acceptedIssuers[" + _index3 + "][" + _index4 + "]",
36
+ expected: "__type",
37
+ value: elem
38
+ }, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
39
+ method: "typia.createAssertEquals",
40
+ path: _path + ".acceptedIssuers[" + _index3 + "]",
41
+ expected: "Array<__type>",
42
+ value: elem
43
+ }, _errorFactory)) || __typia_transform__assertGuard._assertGuard(_exceptionable, {
44
+ method: "typia.createAssertEquals",
45
+ path: _path + ".acceptedIssuers",
46
+ expected: "Array<Array<__type>>",
47
+ value: input.acceptedIssuers
48
+ }, _errorFactory)) && ("missing" === input.kind || "untrusted" === input.kind || __typia_transform__assertGuard._assertGuard(_exceptionable, {
49
+ method: "typia.createAssertEquals",
50
+ path: _path + ".kind",
51
+ expected: "(\"missing\" | \"untrusted\")",
52
+ value: input.kind
53
+ }, _errorFactory)) && (2 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).every(key => {
54
+ if (["acceptedIssuers", "kind"].some(prop => key === prop))
55
+ return true;
56
+ const value = input[key];
57
+ if (undefined === value)
58
+ return true;
59
+ return __typia_transform__assertGuard._assertGuard(_exceptionable, {
60
+ method: "typia.createAssertEquals",
61
+ path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
62
+ expected: "undefined",
63
+ value: value
64
+ }, _errorFactory);
65
+ }))); const _ao1 = (input, _path, _exceptionable = true) => ("string" === typeof input.name || __typia_transform__assertGuard._assertGuard(_exceptionable, {
66
+ method: "typia.createAssertEquals",
67
+ path: _path + ".name",
68
+ expected: "string",
69
+ value: input.name
70
+ }, _errorFactory)) && ("string" === typeof input.value || __typia_transform__assertGuard._assertGuard(_exceptionable, {
71
+ method: "typia.createAssertEquals",
72
+ path: _path + ".value",
73
+ expected: "string",
74
+ value: input.value
75
+ }, _errorFactory)) && (2 === Object.keys(input).length || (false === _exceptionable || Object.keys(input).every(key => {
76
+ if (["name", "value"].some(prop => key === prop))
77
+ return true;
78
+ const value = input[key];
79
+ if (undefined === value)
80
+ return true;
81
+ return __typia_transform__assertGuard._assertGuard(_exceptionable, {
82
+ method: "typia.createAssertEquals",
83
+ path: _path + __typia_transform__accessExpressionAsString._accessExpressionAsString(key),
84
+ expected: "undefined",
85
+ value: value
86
+ }, _errorFactory);
87
+ }))); const __is = (input, _exceptionable = true) => "object" === typeof input && null !== input && _io0(input, true); let _errorFactory; return (input, errorFactory) => {
88
+ if (false === __is(input)) {
89
+ _errorFactory = errorFactory;
90
+ ((input, _path, _exceptionable = true) => ("object" === typeof input && null !== input || __typia_transform__assertGuard._assertGuard(true, {
91
+ method: "typia.createAssertEquals",
92
+ path: _path + "",
93
+ expected: "KeetaAnchorCertificateRequiredErrorJSONProperties",
94
+ value: input
95
+ }, _errorFactory)) && _ao0(input, _path + "", true) || __typia_transform__assertGuard._assertGuard(true, {
96
+ method: "typia.createAssertEquals",
97
+ path: _path + "",
98
+ expected: "KeetaAnchorCertificateRequiredErrorJSONProperties",
99
+ value: input
100
+ }, _errorFactory))(input, "$input", true);
101
+ }
102
+ return input;
103
+ }; })();
104
+ //# sourceMappingURL=error.generated.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"error.generated.js","sourceRoot":"","sources":["../../src/lib/error.generated.ts"],"names":[],"mappings":";;AAAA,OAAO,KAAK,KAAK,MAAM,OAAO,CAAC;AAG/B,MAAM,CAAC,MAAM,uDAAuD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;OAAuJ,CAAC","sourcesContent":["import * as typia from 'typia';\nimport type { KeetaAnchorCertificateRequiredErrorJSONProperties } from './error.js';\n\nexport const assertKeetaAnchorCertificateRequiredErrorJSONProperties: (input: unknown) => KeetaAnchorCertificateRequiredErrorJSONProperties = typia.createAssertEquals<KeetaAnchorCertificateRequiredErrorJSONProperties>();\n"]}
package/lib/error.js CHANGED
@@ -1,6 +1,7 @@
1
1
  import * as __typia_transform__assertGuard from "typia/lib/internal/_assertGuard.js";
2
2
  import * as __typia_transform__accessExpressionAsString from "typia/lib/internal/_accessExpressionAsString.js";
3
3
  import { createAssertEquals, createIs } from 'typia';
4
+ import { assertKeetaAnchorCertificateRequiredErrorJSONProperties } from './error.generated.js';
4
5
  /**
5
6
  * Lazy-loaded error classes to avoid circular dependencies
6
7
  * The classes are loaded on first use
@@ -16,7 +17,7 @@ async function getErrorClassMapping() {
16
17
  * is the base error class and could cause circular resolution
17
18
  */
18
19
  // eslint-disable-next-line @typescript-eslint/no-use-before-define
19
- KeetaAnchorUserError, KeetaAnchorUserValidationError
20
+ KeetaAnchorUserError, KeetaAnchorUserValidationError, KeetaAnchorCertificateRequiredError
20
21
  ];
21
22
  // Dynamically import errors to avoid circular dependencies
22
23
  const importPromises = await Promise.all([
@@ -452,4 +453,68 @@ export class KeetaAnchorUserValidationError extends KeetaAnchorUserError {
452
453
  }, message));
453
454
  }
454
455
  }
456
+ export class KeetaAnchorCertificateRequiredError extends KeetaAnchorUserError {
457
+ static name = 'KeetaAnchorCertificateRequiredError';
458
+ KeetaAnchorCertificateRequiredErrorObjectTypeID;
459
+ static KeetaAnchorCertificateRequiredErrorObjectTypeID = 'b8c5b6df-2f4d-4f60-9d6c-2f4d8a6b1f01';
460
+ acceptedIssuers;
461
+ kind;
462
+ constructor(args, message) {
463
+ super(message ?? KeetaAnchorCertificateRequiredError.defaultMessage(args.kind));
464
+ if (args.kind === 'missing') {
465
+ this.statusCode = 401;
466
+ }
467
+ else {
468
+ this.statusCode = 403;
469
+ }
470
+ Object.defineProperty(this, 'KeetaAnchorCertificateRequiredErrorObjectTypeID', {
471
+ value: KeetaAnchorCertificateRequiredError.KeetaAnchorCertificateRequiredErrorObjectTypeID,
472
+ enumerable: false
473
+ });
474
+ this.acceptedIssuers = args.acceptedIssuers;
475
+ this.kind = args.kind;
476
+ }
477
+ static defaultMessage(kind) {
478
+ if (kind === 'missing') {
479
+ return ('No certificate has been published for the signing account');
480
+ }
481
+ return ('Published certificates do not chain to an accepted issuer');
482
+ }
483
+ static isInstance(input) {
484
+ return (this.hasPropWithValue(input, 'KeetaAnchorCertificateRequiredErrorObjectTypeID', KeetaAnchorCertificateRequiredError.KeetaAnchorCertificateRequiredErrorObjectTypeID));
485
+ }
486
+ asErrorResponse(contentType) {
487
+ let message = this.message;
488
+ if (contentType === 'application/json') {
489
+ message = JSON.stringify({
490
+ ok: false,
491
+ name: this.name,
492
+ data: { acceptedIssuers: this.acceptedIssuers, kind: this.kind },
493
+ error: this.message
494
+ });
495
+ }
496
+ return ({
497
+ error: message,
498
+ statusCode: this.statusCode,
499
+ contentType: contentType
500
+ });
501
+ }
502
+ toJSON() {
503
+ return ({
504
+ ...super.toJSON(),
505
+ acceptedIssuers: this.acceptedIssuers,
506
+ kind: this.kind
507
+ });
508
+ }
509
+ static async fromJSON(input) {
510
+ const { message, other } = this.extractErrorProperties(input, this);
511
+ if (!('data' in other)) {
512
+ throw (new Error('Invalid KeetaAnchorCertificateRequiredError JSON: missing data property'));
513
+ }
514
+ const parsed = assertKeetaAnchorCertificateRequiredErrorJSONProperties(other.data);
515
+ const error = new this({ acceptedIssuers: parsed.acceptedIssuers, kind: parsed.kind }, message);
516
+ error.restoreFromJSON(other);
517
+ return (error);
518
+ }
519
+ }
455
520
  //# sourceMappingURL=error.js.map
package/lib/error.js.map CHANGED
@@ -1 +1 @@
1
- {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/lib/error.ts"],"names":[],"mappings":";;AACA,OAAO,EAAE,kBAAkB,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAC;AAUrD;;;GAGG;AACH,IAAI,mBAAmB,GAA4E,IAAI,CAAC;AAExG,KAAK,UAAU,oBAAoB;IAClC,IAAI,mBAAmB,EAAE,CAAC;QACzB,OAAM,CAAC,mBAAmB,CAAC,CAAC;IAC7B,CAAC;IAED,MAAM,aAAa,GAA+B;QACjD;;;WAGG;QACH,mEAAmE;QACnE,oBAAoB,EAAE,8BAA8B;KACpD,CAAC;IAEF,2DAA2D;IAC3D,MAAM,cAAc,GAA6D,MAAM,OAAO,CAAC,GAAG,CAAC;QAClG,MAAM,CAAC,2BAA2B,CAAC;QACnC,MAAM,CAAC,0BAA0B,CAAC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,CAAC,MAAM,GAAG,CAAC,EAAE,CAAC;wBACtB,IAAI,GAAG,KAAK,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;oBACxB,CAAC;gBACF,CAAC;gBAED,OAAM,CAAC;oBACN,IAAI;oBACJ,OAAO,EAAE,OAAO,IAAI,eAAe;oBACnC,QAAQ,EAAE,MAAM,CAAC,QAAQ;oBACzB,aAAa,EAAE,MAAM,CAAC,KAAK;iBAC3B,CAAC,CAAC;YACJ,CAAC,CAAC;SACF,EAAE,OAAO,CAAC,CAAC,CAAA;IACb,CAAC","sourcesContent":["import type { IValidation, TypeGuardError } from 'typia';\nimport { createAssertEquals, createIs } from 'typia';\nimport type { LogLevel } from './log/index.ts';\n/**\n * Type for error classes that can be deserialized\n */\ninterface DeserializableErrorClass {\n\treadonly name: string;\n\tfromJSON: (input: unknown) => Promise<KeetaAnchorError>;\n}\n\n/**\n * Lazy-loaded error classes to avoid circular dependencies\n * The classes are loaded on first use\n */\nlet ERROR_CLASS_MAPPING: { [key: string]: (input: unknown) => Promise<KeetaAnchorError> } | null = null;\n\nasync function getErrorClassMapping(): Promise<{ [key: string]: (input: unknown) => Promise<KeetaAnchorError> }> {\n\tif (ERROR_CLASS_MAPPING) {\n\t\treturn(ERROR_CLASS_MAPPING);\n\t}\n\n\tconst ERROR_CLASSES: DeserializableErrorClass[] = [\n\t\t/*\n\t\t * We purposefully leave out KeetaAnchorError here since it\n\t\t * is the base error class and could cause circular resolution\n\t\t */\n\t\t// eslint-disable-next-line @typescript-eslint/no-use-before-define\n\t\tKeetaAnchorUserError, KeetaAnchorUserValidationError\n\t];\n\n\t// Dynamically import errors to avoid circular dependencies\n\tconst importPromises: { Errors: { [key: string]: DeserializableErrorClass }}[] = await Promise.all([\n\t\timport('../services/kyc/common.js'),\n\t\timport('../services/fx/common.js'),\n\t\timport('../services/asset-movement/common.js'),\n\t\timport('../services/storage/common.js'),\n\t\timport('../services/username/common.js')\n\t]);\n\n\tfor (const module of importPromises) {\n\t\tconst classes = Object.values(module.Errors);\n\t\tERROR_CLASSES.push(...classes);\n\t}\n\n\tconst mapping: { [key: string]: (input: unknown) => Promise<KeetaAnchorError> } = {};\n\tfor (const errorClass of ERROR_CLASSES) {\n\t\tmapping[errorClass.name] = errorClass.fromJSON.bind(errorClass);\n\t}\n\n\tERROR_CLASS_MAPPING = mapping;\n\treturn(mapping);\n}\n\n/**\n * Base error class for all Keeta Anchor errors\n */\nexport class KeetaAnchorError extends Error {\n\tstatic override readonly name: string = 'KeetaAnchorError';\n\t#name: string;\n\t#statusCode = 400;\n\t#retryable = false;\n\tprivate readonly keetaAnchorErrorObjectTypeID!: string;\n\tprivate static readonly keetaAnchorErrorObjectTypeID = '5d7f1578-e887-4104-bab0-4115ae33b08f';\n\tprotected userError = false;\n\treadonly logLevel: LogLevel = 'ERROR';\n\n\tget name(): string {\n\t\treturn(this.#name);\n\t}\n\n\tprotected set name(value: string) {\n\t\tthis.#name = value;\n\t}\n\n\tget statusCode(): number {\n\t\treturn(this.#statusCode);\n\t}\n\n\tprotected set statusCode(value: number) {\n\t\tthis.#statusCode = value;\n\t}\n\n\tget retryable(): boolean {\n\t\treturn(this.#retryable);\n\t}\n\n\tprotected set retryable(value: boolean) {\n\t\tthis.#retryable = value;\n\t}\n\n\tconstructor(message: string) {\n\t\tsuper(message);\n\n\t\t// Need to cast to access the static name property from the constructor\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\tthis.#name = (this.constructor as typeof KeetaAnchorError).name;\n\n\t\tObject.defineProperty(this, 'keetaAnchorErrorObjectTypeID', {\n\t\t\tvalue: KeetaAnchorError.keetaAnchorErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\t/**\n\t * Protected method to restore error properties from JSON\n\t * This allows subclasses to properly restore properties without using any\n\t */\n\tprotected restoreFromJSON(other: { [key: string]: unknown }): void {\n\t\t// Restore statusCode if present\n\t\tif ('statusCode' in other) {\n\t\t\tif (typeof other.statusCode !== 'number') {\n\t\t\t\tthrow(new TypeError('Invalid statusCode: expected number'));\n\t\t\t}\n\t\t\tthis.statusCode = other.statusCode;\n\t\t}\n\n\t\t// Restore retryable if present\n\t\tif ('retryable' in other) {\n\t\t\tif (typeof other.retryable !== 'boolean') {\n\t\t\t\tthrow(new TypeError('Invalid retryable: expected boolean'));\n\t\t\t}\n\t\t\tthis.retryable = other.retryable;\n\t\t}\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaAnchorError {\n\t\treturn(this.hasPropWithValue(input, 'keetaAnchorErrorObjectTypeID', KeetaAnchorError.keetaAnchorErrorObjectTypeID));\n\t}\n\n\tasErrorResponse(contentType: 'text/plain' | 'application/json', message?: string): { error: string; statusCode: number; contentType: string } {\n\t\tmessage ??= 'Internal error';\n\t\tif (contentType === 'application/json') {\n\t\t\tmessage = JSON.stringify({\n\t\t\t\t...this.toJSON(),\n\t\t\t\tstatusCode: undefined\n\t\t\t});\n\t\t}\n\n\t\treturn({\n\t\t\terror: message,\n\t\t\tstatusCode: this.statusCode,\n\t\t\tcontentType: contentType\n\t\t});\n\t}\n\n\ttoJSON(): { ok: false; retryable: boolean; error: string; name: string; statusCode: number } {\n\t\tlet message = 'Internal error';\n\t\tif (this.userError) {\n\t\t\tmessage = this.message;\n\t\t}\n\n\t\treturn({\n\t\t\tok: false,\n\t\t\tretryable: this.retryable,\n\t\t\terror: message,\n\t\t\tname: this.#name,\n\t\t\tstatusCode: this.statusCode\n\t\t});\n\t}\n\n\tprotected static hasPropWithValue<PROP extends string, VALUE extends string | number | boolean>(input: unknown, prop: PROP, value: VALUE): input is { [key in PROP]: VALUE } {\n\t\tif (typeof input !== 'object' || input === null) {\n\t\t\treturn(false);\n\t\t}\n\n\t\tif (!(prop in input)) {\n\t\t\treturn(false);\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\tconst inputValue = input[prop as keyof typeof input] as unknown;\n\t\tif (inputValue !== value) {\n\t\t\treturn(false);\n\t\t}\n\n\t\treturn(true);\n\t}\n\n\t/**\n\t * Extract common error properties from JSON input\n\t * This validates the structure and extracts properties needed for construction\n\t */\n\tprotected static extractErrorProperties(input: unknown, expectedClass?: { name: string }): { message: string; other: { [key: string]: unknown }} {\n\t\tif (!this.hasPropWithValue(input, 'ok', false)) {\n\t\t\tthrow(new Error('Invalid error JSON object'));\n\t\t}\n\n\t\tif (typeof input !== 'object' || input === null) {\n\t\t\tthrow(new Error('Invalid error JSON object'));\n\t\t}\n\n\t\t// Verify the name matches if an expected class is provided\n\t\tif (expectedClass && 'name' in input && input.name !== expectedClass.name) {\n\t\t\tthrow(new Error(`Error name mismatch: expected ${expectedClass.name}, got ${input.name}`));\n\t\t}\n\n\t\t// Extract error message\n\t\tlet message = 'Internal error';\n\t\tif ('error' in input && typeof input.error === 'string') {\n\t\t\tmessage = input.error;\n\t\t}\n\n\t\t// Extract other properties\n\t\tconst other: { [key: string]: unknown } = {};\n\t\tfor (const key in input) {\n\t\t\tif (key !== 'error' && key !== 'ok') {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\t\tother[key] = input[key as keyof typeof input];\n\t\t\t}\n\t\t}\n\n\t\treturn({ message, other });\n\t}\n\n\tstatic async fromJSON(input: unknown): Promise<KeetaAnchorError> {\n\t\t// Try to use the deserializer mapping if available for subclasses\n\t\tif (typeof input !== 'object' || input === null) {\n\t\t\tthrow(new Error('Invalid error JSON object'));\n\t\t}\n\n\t\tif (!('ok' in input) || input.ok !== false) {\n\t\t\tthrow(new Error('Invalid error JSON object: expected ok: false'));\n\t\t}\n\n\t\t// Check if there's a specific error class name\n\t\tif ('name' in input && typeof input.name === 'string') {\n\t\t\tif (input.name === 'KeetaAnchorError') {\n\t\t\t\tconst { message, other } = KeetaAnchorError.extractErrorProperties(input, this);\n\t\t\t\tconst error = new this(message);\n\t\t\t\terror.restoreFromJSON(other);\n\t\t\t\treturn(error);\n\t\t\t}\n\t\t\tconst mapping = await getErrorClassMapping();\n\t\t\tconst deserializer = mapping[input.name];\n\t\t\tif (deserializer) {\n\t\t\t\treturn(await deserializer(input));\n\t\t\t}\n\t\t}\n\n\t\tthrow(new Error('Invalid error JSON object: unknown error class'));\n\t}\n}\n\n/**\n * User-facing error class that extends KeetaAnchorError\n */\nexport class KeetaAnchorUserError extends KeetaAnchorError {\n\tstatic readonly name: string = 'KeetaAnchorUserError';\n\tprivate readonly keetaAnchorUserErrorObjectTypeID!: string;\n\tprivate static readonly keetaAnchorUserErrorObjectTypeID = 'a1e64819-14b6-45ac-a1ec-b9c0bdd51e7b';\n\tprotected override userError = true;\n\n\tstatic isInstance(input: unknown): input is KeetaAnchorUserError {\n\t\treturn(this.hasPropWithValue(input, 'keetaAnchorUserErrorObjectTypeID', KeetaAnchorUserError.keetaAnchorUserErrorObjectTypeID));\n\t}\n\n\tconstructor(message: string) {\n\t\tsuper(message);\n\n\t\tObject.defineProperty(this, 'keetaAnchorUserErrorObjectTypeID', {\n\t\t\tvalue: KeetaAnchorUserError.keetaAnchorUserErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tasErrorResponse(contentType: 'text/plain' | 'application/json'): { error: string; statusCode: number; contentType: string } {\n\t\treturn(super.asErrorResponse(contentType, this.message));\n\t}\n\n\tstatic async fromJSON(input: unknown): Promise<InstanceType<typeof this>> {\n\t\tconst { message, other } = this.extractErrorProperties(input, this);\n\t\tconst error = new this(message);\n\t\terror.restoreFromJSON(other);\n\t\treturn(error);\n\t}\n}\n\ninterface KeetaAnchorUserValidationErrorDetails {\n\tfields: {\n\t\tpath?: string | undefined;\n\t\tmessage: string;\n\t\tallowedValues?: string[];\n\t\texpected?: string;\n\t\treceivedValue?: unknown;\n\t\tvalueRules?: { minimum?: string | undefined; maximum?: string | undefined };\n\t}[];\n}\n\nconst assertKeetaAnchorUserValidationErrorDetails: (input: unknown) => KeetaAnchorUserValidationErrorDetails = createAssertEquals<KeetaAnchorUserValidationErrorDetails>();\ntype KeetaAnchorUserValidationErrorJSON = ReturnType<KeetaAnchorUserError['toJSON']> & KeetaAnchorUserValidationErrorDetails;\n\ntype TypeGuardErrorLike = Pick<TypeGuardError.IProps | IValidation.IError, 'path' | 'expected' | 'value'>;\n\nconst isTypeGuardErrorLike: (error: unknown) => error is TypeGuardErrorLike = createIs<TypeGuardErrorLike>();\n\nexport class KeetaAnchorUserValidationError extends KeetaAnchorUserError implements KeetaAnchorUserValidationErrorDetails {\n\tstatic readonly isTypeGuardErrorLike: typeof isTypeGuardErrorLike = isTypeGuardErrorLike;\n\n\tstatic override readonly name: string = 'KeetaAnchorUserValidationError';\n\tprivate readonly KeetaAnchorUserValidationErrorObjectTypeID!: string;\n\tprivate static readonly KeetaAnchorUserValidationErrorObjectTypeID = '5fa46799-48b8-4cf2-a3de-9c01418d3ba0';\n\tprotected override userError = true;\n\n\treadonly fields: KeetaAnchorUserValidationErrorDetails['fields'];\n\n\tstatic isInstance(input: unknown): input is KeetaAnchorUserValidationError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaAnchorUserValidationErrorObjectTypeID', KeetaAnchorUserValidationError.KeetaAnchorUserValidationErrorObjectTypeID));\n\t}\n\n\tconstructor(args: KeetaAnchorUserValidationErrorDetails, message?: string) {\n\t\tsuper(message ?? `Validation error on fields ${args.fields.map((f) => f.path).join(', ')}`);\n\n\t\tObject.defineProperty(this, 'KeetaAnchorUserValidationErrorObjectTypeID', {\n\t\t\tvalue: KeetaAnchorUserValidationError.KeetaAnchorUserValidationErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\n\t\tthis.fields = args.fields;\n\t}\n\n\toverride get statusCode() {\n\t\treturn(400);\n\t}\n\n\tasErrorResponse(contentType: 'text/plain' | 'application/json'): { error: string; statusCode: number; contentType: string } {\n\t\tlet message = this.message;\n\t\tif (contentType === 'application/json') {\n\t\t\tmessage = JSON.stringify({\n\t\t\t\tok: false,\n\t\t\t\tname: this.name,\n\t\t\t\tdata: { fields: this.fields },\n\t\t\t\terror: this.message\n\t\t\t});\n\t\t}\n\n\t\treturn({\n\t\t\terror: message,\n\t\t\tstatusCode: this.statusCode,\n\t\t\tcontentType: contentType\n\t\t});\n\t}\n\n\ttoJSON(): KeetaAnchorUserValidationErrorJSON {\n\t\treturn({\n\t\t\t...super.toJSON(),\n\t\t\tfields: this.fields\n\t\t});\n\t}\n\n\n\tstatic async fromJSON(input: unknown): Promise<KeetaAnchorUserValidationError> {\n\t\tconst { message, other } = this.extractErrorProperties(input, this);\n\n\t\tif (!('data' in other)) {\n\t\t\tthrow(new Error('Invalid KeetaAnchorUserValidationError JSON: missing data property'));\n\t\t}\n\n\t\tconst parsed = assertKeetaAnchorUserValidationErrorDetails(other.data);\n\n\t\tconst error = new this(\n\t\t\t{ fields: parsed.fields },\n\t\t\tmessage\n\t\t);\n\n\t\terror.restoreFromJSON(other);\n\t\treturn(error);\n\t}\n\n\tstatic fromTypeGuardError(input: TypeGuardErrorLike | TypeGuardErrorLike[], message?: string): KeetaAnchorUserValidationError {\n\t\tlet asArr;\n\n\t\tif (Array.isArray(input)) {\n\t\t\tasArr = input;\n\t\t} else {\n\t\t\tasArr = [ input ];\n\t\t}\n\n\t\treturn(new this({\n\t\t\tfields: asArr.map(function(single) {\n\t\t\t\tlet path;\n\t\t\t\tif (single.path !== undefined) {\n\t\t\t\t\tconst split = single.path.split('.');\n\n\t\t\t\t\tif (split[0] === '$input') {\n\t\t\t\t\t\tsplit.shift();\n\t\t\t\t\t}\n\n\t\t\t\t\tif (split.length > 0) {\n\t\t\t\t\t\tpath = split.join('.');\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn({\n\t\t\t\t\tpath,\n\t\t\t\t\tmessage: message ?? 'Invalid value',\n\t\t\t\t\texpected: single.expected,\n\t\t\t\t\treceivedValue: single.value\n\t\t\t\t});\n\t\t\t})\n\t\t}, message))\n\t}\n}\n"]}
1
+ {"version":3,"file":"error.js","sourceRoot":"","sources":["../../src/lib/error.ts"],"names":[],"mappings":";;AACA,OA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C,CAAC;IACJ,CAAC;IAEQ,MAAM;QACd,OAAM,CAAC;YACN,GAAG,KAAK,CAAC,MAAM,EAAE;YACjB,eAAe,EAAE,IAAI,CAAC,eAAe;YACrC,IAAI,EAAE,IAAI,CAAC,IAAI;SACf,CAAC,CAAC;IACJ,CAAC;IAED,MAAM,CAAU,KAAK,CAAC,QAAQ,CAAC,KAAc;QAC5C,MAAM,EAAE,OAAO,EAAE,KAAK,EAAE,GAAG,IAAI,CAAC,sBAAsB,CAAC,KAAK,EAAE,IAAI,CAAC,CAAC;QAEpE,IAAI,CAAC,CAAC,MAAM,IAAI,KAAK,CAAC,EAAE,CAAC;YACxB,MAAK,CAAC,IAAI,KAAK,CAAC,yEAAyE,CAAC,CAAC,CAAC;QAC7F,CAAC;QAED,MAAM,MAAM,GAAG,uDAAuD,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC;QACnF,MAAM,KAAK,GAAG,IAAI,IAAI,CAAC,EAAE,eAAe,EAAE,MAAM,CAAC,eAAe,EAAE,IAAI,EAAE,MAAM,CAAC,IAAI,EAAE,EAAE,OAAO,CAAC,CAAC;QAEhG,KAAK,CAAC,eAAe,CAAC,KAAK,CAAC,CAAC;QAE7B,OAAM,CAAC,KAAK,CAAC,CAAC;IACf,CAAC","sourcesContent":["import type { IValidation, TypeGuardError } from 'typia';\nimport { createAssertEquals, createIs } from 'typia';\nimport type { LogLevel } from './log/index.ts';\nimport { assertKeetaAnchorCertificateRequiredErrorJSONProperties } from './error.generated.js';\n/**\n * Type for error classes that can be deserialized\n */\ninterface DeserializableErrorClass {\n\treadonly name: string;\n\tfromJSON: (input: unknown) => Promise<KeetaAnchorError>;\n}\n\n/**\n * Lazy-loaded error classes to avoid circular dependencies\n * The classes are loaded on first use\n */\nlet ERROR_CLASS_MAPPING: { [key: string]: (input: unknown) => Promise<KeetaAnchorError> } | null = null;\n\nasync function getErrorClassMapping(): Promise<{ [key: string]: (input: unknown) => Promise<KeetaAnchorError> }> {\n\tif (ERROR_CLASS_MAPPING) {\n\t\treturn(ERROR_CLASS_MAPPING);\n\t}\n\n\tconst ERROR_CLASSES: DeserializableErrorClass[] = [\n\t\t/*\n\t\t * We purposefully leave out KeetaAnchorError here since it\n\t\t * is the base error class and could cause circular resolution\n\t\t */\n\t\t// eslint-disable-next-line @typescript-eslint/no-use-before-define\n\t\tKeetaAnchorUserError, KeetaAnchorUserValidationError, KeetaAnchorCertificateRequiredError\n\t];\n\n\t// Dynamically import errors to avoid circular dependencies\n\tconst importPromises: { Errors: { [key: string]: DeserializableErrorClass }}[] = await Promise.all([\n\t\timport('../services/kyc/common.js'),\n\t\timport('../services/fx/common.js'),\n\t\timport('../services/asset-movement/common.js'),\n\t\timport('../services/storage/common.js'),\n\t\timport('../services/username/common.js')\n\t]);\n\n\tfor (const module of importPromises) {\n\t\tconst classes = Object.values(module.Errors);\n\t\tERROR_CLASSES.push(...classes);\n\t}\n\n\tconst mapping: { [key: string]: (input: unknown) => Promise<KeetaAnchorError> } = {};\n\tfor (const errorClass of ERROR_CLASSES) {\n\t\tmapping[errorClass.name] = errorClass.fromJSON.bind(errorClass);\n\t}\n\n\tERROR_CLASS_MAPPING = mapping;\n\treturn(mapping);\n}\n\n/**\n * Base error class for all Keeta Anchor errors\n */\nexport class KeetaAnchorError extends Error {\n\tstatic override readonly name: string = 'KeetaAnchorError';\n\t#name: string;\n\t#statusCode = 400;\n\t#retryable = false;\n\tprivate readonly keetaAnchorErrorObjectTypeID!: string;\n\tprivate static readonly keetaAnchorErrorObjectTypeID = '5d7f1578-e887-4104-bab0-4115ae33b08f';\n\tprotected userError = false;\n\treadonly logLevel: LogLevel = 'ERROR';\n\n\tget name(): string {\n\t\treturn(this.#name);\n\t}\n\n\tprotected set name(value: string) {\n\t\tthis.#name = value;\n\t}\n\n\tget statusCode(): number {\n\t\treturn(this.#statusCode);\n\t}\n\n\tprotected set statusCode(value: number) {\n\t\tthis.#statusCode = value;\n\t}\n\n\tget retryable(): boolean {\n\t\treturn(this.#retryable);\n\t}\n\n\tprotected set retryable(value: boolean) {\n\t\tthis.#retryable = value;\n\t}\n\n\tconstructor(message: string) {\n\t\tsuper(message);\n\n\t\t// Need to cast to access the static name property from the constructor\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\tthis.#name = (this.constructor as typeof KeetaAnchorError).name;\n\n\t\tObject.defineProperty(this, 'keetaAnchorErrorObjectTypeID', {\n\t\t\tvalue: KeetaAnchorError.keetaAnchorErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\t/**\n\t * Protected method to restore error properties from JSON\n\t * This allows subclasses to properly restore properties without using any\n\t */\n\tprotected restoreFromJSON(other: { [key: string]: unknown }): void {\n\t\t// Restore statusCode if present\n\t\tif ('statusCode' in other) {\n\t\t\tif (typeof other.statusCode !== 'number') {\n\t\t\t\tthrow(new TypeError('Invalid statusCode: expected number'));\n\t\t\t}\n\t\t\tthis.statusCode = other.statusCode;\n\t\t}\n\n\t\t// Restore retryable if present\n\t\tif ('retryable' in other) {\n\t\t\tif (typeof other.retryable !== 'boolean') {\n\t\t\t\tthrow(new TypeError('Invalid retryable: expected boolean'));\n\t\t\t}\n\t\t\tthis.retryable = other.retryable;\n\t\t}\n\t}\n\n\tstatic isInstance(input: unknown): input is KeetaAnchorError {\n\t\treturn(this.hasPropWithValue(input, 'keetaAnchorErrorObjectTypeID', KeetaAnchorError.keetaAnchorErrorObjectTypeID));\n\t}\n\n\tasErrorResponse(contentType: 'text/plain' | 'application/json', message?: string): { error: string; statusCode: number; contentType: string } {\n\t\tmessage ??= 'Internal error';\n\t\tif (contentType === 'application/json') {\n\t\t\tmessage = JSON.stringify({\n\t\t\t\t...this.toJSON(),\n\t\t\t\tstatusCode: undefined\n\t\t\t});\n\t\t}\n\n\t\treturn({\n\t\t\terror: message,\n\t\t\tstatusCode: this.statusCode,\n\t\t\tcontentType: contentType\n\t\t});\n\t}\n\n\ttoJSON(): { ok: false; retryable: boolean; error: string; name: string; statusCode: number } {\n\t\tlet message = 'Internal error';\n\t\tif (this.userError) {\n\t\t\tmessage = this.message;\n\t\t}\n\n\t\treturn({\n\t\t\tok: false,\n\t\t\tretryable: this.retryable,\n\t\t\terror: message,\n\t\t\tname: this.#name,\n\t\t\tstatusCode: this.statusCode\n\t\t});\n\t}\n\n\tprotected static hasPropWithValue<PROP extends string, VALUE extends string | number | boolean>(input: unknown, prop: PROP, value: VALUE): input is { [key in PROP]: VALUE } {\n\t\tif (typeof input !== 'object' || input === null) {\n\t\t\treturn(false);\n\t\t}\n\n\t\tif (!(prop in input)) {\n\t\t\treturn(false);\n\t\t}\n\n\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\tconst inputValue = input[prop as keyof typeof input] as unknown;\n\t\tif (inputValue !== value) {\n\t\t\treturn(false);\n\t\t}\n\n\t\treturn(true);\n\t}\n\n\t/**\n\t * Extract common error properties from JSON input\n\t * This validates the structure and extracts properties needed for construction\n\t */\n\tprotected static extractErrorProperties(input: unknown, expectedClass?: { name: string }): { message: string; other: { [key: string]: unknown }} {\n\t\tif (!this.hasPropWithValue(input, 'ok', false)) {\n\t\t\tthrow(new Error('Invalid error JSON object'));\n\t\t}\n\n\t\tif (typeof input !== 'object' || input === null) {\n\t\t\tthrow(new Error('Invalid error JSON object'));\n\t\t}\n\n\t\t// Verify the name matches if an expected class is provided\n\t\tif (expectedClass && 'name' in input && input.name !== expectedClass.name) {\n\t\t\tthrow(new Error(`Error name mismatch: expected ${expectedClass.name}, got ${input.name}`));\n\t\t}\n\n\t\t// Extract error message\n\t\tlet message = 'Internal error';\n\t\tif ('error' in input && typeof input.error === 'string') {\n\t\t\tmessage = input.error;\n\t\t}\n\n\t\t// Extract other properties\n\t\tconst other: { [key: string]: unknown } = {};\n\t\tfor (const key in input) {\n\t\t\tif (key !== 'error' && key !== 'ok') {\n\t\t\t\t// eslint-disable-next-line @typescript-eslint/consistent-type-assertions\n\t\t\t\tother[key] = input[key as keyof typeof input];\n\t\t\t}\n\t\t}\n\n\t\treturn({ message, other });\n\t}\n\n\tstatic async fromJSON(input: unknown): Promise<KeetaAnchorError> {\n\t\t// Try to use the deserializer mapping if available for subclasses\n\t\tif (typeof input !== 'object' || input === null) {\n\t\t\tthrow(new Error('Invalid error JSON object'));\n\t\t}\n\n\t\tif (!('ok' in input) || input.ok !== false) {\n\t\t\tthrow(new Error('Invalid error JSON object: expected ok: false'));\n\t\t}\n\n\t\t// Check if there's a specific error class name\n\t\tif ('name' in input && typeof input.name === 'string') {\n\t\t\tif (input.name === 'KeetaAnchorError') {\n\t\t\t\tconst { message, other } = KeetaAnchorError.extractErrorProperties(input, this);\n\t\t\t\tconst error = new this(message);\n\t\t\t\terror.restoreFromJSON(other);\n\t\t\t\treturn(error);\n\t\t\t}\n\t\t\tconst mapping = await getErrorClassMapping();\n\t\t\tconst deserializer = mapping[input.name];\n\t\t\tif (deserializer) {\n\t\t\t\treturn(await deserializer(input));\n\t\t\t}\n\t\t}\n\n\t\tthrow(new Error('Invalid error JSON object: unknown error class'));\n\t}\n}\n\n/**\n * User-facing error class that extends KeetaAnchorError\n */\nexport class KeetaAnchorUserError extends KeetaAnchorError {\n\tstatic readonly name: string = 'KeetaAnchorUserError';\n\tprivate readonly keetaAnchorUserErrorObjectTypeID!: string;\n\tprivate static readonly keetaAnchorUserErrorObjectTypeID = 'a1e64819-14b6-45ac-a1ec-b9c0bdd51e7b';\n\tprotected override userError = true;\n\n\tstatic isInstance(input: unknown): input is KeetaAnchorUserError {\n\t\treturn(this.hasPropWithValue(input, 'keetaAnchorUserErrorObjectTypeID', KeetaAnchorUserError.keetaAnchorUserErrorObjectTypeID));\n\t}\n\n\tconstructor(message: string) {\n\t\tsuper(message);\n\n\t\tObject.defineProperty(this, 'keetaAnchorUserErrorObjectTypeID', {\n\t\t\tvalue: KeetaAnchorUserError.keetaAnchorUserErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\t}\n\n\tasErrorResponse(contentType: 'text/plain' | 'application/json'): { error: string; statusCode: number; contentType: string } {\n\t\treturn(super.asErrorResponse(contentType, this.message));\n\t}\n\n\tstatic async fromJSON(input: unknown): Promise<InstanceType<typeof this>> {\n\t\tconst { message, other } = this.extractErrorProperties(input, this);\n\t\tconst error = new this(message);\n\t\terror.restoreFromJSON(other);\n\t\treturn(error);\n\t}\n}\n\ninterface KeetaAnchorUserValidationErrorDetails {\n\tfields: {\n\t\tpath?: string | undefined;\n\t\tmessage: string;\n\t\tallowedValues?: string[];\n\t\texpected?: string;\n\t\treceivedValue?: unknown;\n\t\tvalueRules?: { minimum?: string | undefined; maximum?: string | undefined };\n\t}[];\n}\n\nconst assertKeetaAnchorUserValidationErrorDetails: (input: unknown) => KeetaAnchorUserValidationErrorDetails = createAssertEquals<KeetaAnchorUserValidationErrorDetails>();\ntype KeetaAnchorUserValidationErrorJSON = ReturnType<KeetaAnchorUserError['toJSON']> & KeetaAnchorUserValidationErrorDetails;\n\ntype TypeGuardErrorLike = Pick<TypeGuardError.IProps | IValidation.IError, 'path' | 'expected' | 'value'>;\n\nconst isTypeGuardErrorLike: (error: unknown) => error is TypeGuardErrorLike = createIs<TypeGuardErrorLike>();\n\nexport class KeetaAnchorUserValidationError extends KeetaAnchorUserError implements KeetaAnchorUserValidationErrorDetails {\n\tstatic readonly isTypeGuardErrorLike: typeof isTypeGuardErrorLike = isTypeGuardErrorLike;\n\n\tstatic override readonly name: string = 'KeetaAnchorUserValidationError';\n\tprivate readonly KeetaAnchorUserValidationErrorObjectTypeID!: string;\n\tprivate static readonly KeetaAnchorUserValidationErrorObjectTypeID = '5fa46799-48b8-4cf2-a3de-9c01418d3ba0';\n\tprotected override userError = true;\n\n\treadonly fields: KeetaAnchorUserValidationErrorDetails['fields'];\n\n\tstatic isInstance(input: unknown): input is KeetaAnchorUserValidationError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaAnchorUserValidationErrorObjectTypeID', KeetaAnchorUserValidationError.KeetaAnchorUserValidationErrorObjectTypeID));\n\t}\n\n\tconstructor(args: KeetaAnchorUserValidationErrorDetails, message?: string) {\n\t\tsuper(message ?? `Validation error on fields ${args.fields.map((f) => f.path).join(', ')}`);\n\n\t\tObject.defineProperty(this, 'KeetaAnchorUserValidationErrorObjectTypeID', {\n\t\t\tvalue: KeetaAnchorUserValidationError.KeetaAnchorUserValidationErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\n\t\tthis.fields = args.fields;\n\t}\n\n\toverride get statusCode() {\n\t\treturn(400);\n\t}\n\n\tasErrorResponse(contentType: 'text/plain' | 'application/json'): { error: string; statusCode: number; contentType: string } {\n\t\tlet message = this.message;\n\t\tif (contentType === 'application/json') {\n\t\t\tmessage = JSON.stringify({\n\t\t\t\tok: false,\n\t\t\t\tname: this.name,\n\t\t\t\tdata: { fields: this.fields },\n\t\t\t\terror: this.message\n\t\t\t});\n\t\t}\n\n\t\treturn({\n\t\t\terror: message,\n\t\t\tstatusCode: this.statusCode,\n\t\t\tcontentType: contentType\n\t\t});\n\t}\n\n\ttoJSON(): KeetaAnchorUserValidationErrorJSON {\n\t\treturn({\n\t\t\t...super.toJSON(),\n\t\t\tfields: this.fields\n\t\t});\n\t}\n\n\n\tstatic async fromJSON(input: unknown): Promise<KeetaAnchorUserValidationError> {\n\t\tconst { message, other } = this.extractErrorProperties(input, this);\n\n\t\tif (!('data' in other)) {\n\t\t\tthrow(new Error('Invalid KeetaAnchorUserValidationError JSON: missing data property'));\n\t\t}\n\n\t\tconst parsed = assertKeetaAnchorUserValidationErrorDetails(other.data);\n\n\t\tconst error = new this(\n\t\t\t{ fields: parsed.fields },\n\t\t\tmessage\n\t\t);\n\n\t\terror.restoreFromJSON(other);\n\t\treturn(error);\n\t}\n\n\tstatic fromTypeGuardError(input: TypeGuardErrorLike | TypeGuardErrorLike[], message?: string): KeetaAnchorUserValidationError {\n\t\tlet asArr;\n\n\t\tif (Array.isArray(input)) {\n\t\t\tasArr = input;\n\t\t} else {\n\t\t\tasArr = [ input ];\n\t\t}\n\n\t\treturn(new this({\n\t\t\tfields: asArr.map(function(single) {\n\t\t\t\tlet path;\n\t\t\t\tif (single.path !== undefined) {\n\t\t\t\t\tconst split = single.path.split('.');\n\n\t\t\t\t\tif (split[0] === '$input') {\n\t\t\t\t\t\tsplit.shift();\n\t\t\t\t\t}\n\n\t\t\t\t\tif (split.length > 0) {\n\t\t\t\t\t\tpath = split.join('.');\n\t\t\t\t\t}\n\t\t\t\t}\n\n\t\t\t\treturn({\n\t\t\t\t\tpath,\n\t\t\t\t\tmessage: message ?? 'Invalid value',\n\t\t\t\t\texpected: single.expected,\n\t\t\t\t\treceivedValue: single.value\n\t\t\t\t});\n\t\t\t})\n\t\t}, message))\n\t}\n}\n\n/**\n * Failure mode for the certificate-chain gate.\n */\nexport type KeetaAnchorCertificateRequiredKind = 'missing' | 'untrusted';\n\nexport interface KeetaAnchorCertificateRequiredErrorJSONProperties {\n\t/**\n\t * Outer array: any-of (OR). Inner array: all-of (AND).\n\t */\n\tacceptedIssuers: { name: string; value: string; }[][];\n\tkind: KeetaAnchorCertificateRequiredKind;\n}\n\ntype KeetaAnchorCertificateRequiredErrorJSON =\n\tReturnType<KeetaAnchorUserError['toJSON']>\n\t& KeetaAnchorCertificateRequiredErrorJSONProperties;\n\nexport class KeetaAnchorCertificateRequiredError extends KeetaAnchorUserError implements KeetaAnchorCertificateRequiredErrorJSONProperties {\n\tstatic override readonly name: string = 'KeetaAnchorCertificateRequiredError';\n\tprivate readonly KeetaAnchorCertificateRequiredErrorObjectTypeID!: string;\n\tprivate static readonly KeetaAnchorCertificateRequiredErrorObjectTypeID = 'b8c5b6df-2f4d-4f60-9d6c-2f4d8a6b1f01';\n\n\treadonly acceptedIssuers: { name: string; value: string; }[][];\n\treadonly kind: KeetaAnchorCertificateRequiredKind;\n\n\tconstructor(args: KeetaAnchorCertificateRequiredErrorJSONProperties, message?: string) {\n\t\tsuper(message ?? KeetaAnchorCertificateRequiredError.defaultMessage(args.kind));\n\t\tif (args.kind === 'missing') {\n\t\t\tthis.statusCode = 401;\n\t\t} else {\n\t\t\tthis.statusCode = 403;\n\t\t}\n\n\t\tObject.defineProperty(this, 'KeetaAnchorCertificateRequiredErrorObjectTypeID', {\n\t\t\tvalue: KeetaAnchorCertificateRequiredError.KeetaAnchorCertificateRequiredErrorObjectTypeID,\n\t\t\tenumerable: false\n\t\t});\n\n\t\tthis.acceptedIssuers = args.acceptedIssuers;\n\t\tthis.kind = args.kind;\n\t}\n\n\tprivate static defaultMessage(kind: KeetaAnchorCertificateRequiredKind): string {\n\t\tif (kind === 'missing') {\n\t\t\treturn('No certificate has been published for the signing account');\n\t\t}\n\n\t\treturn('Published certificates do not chain to an accepted issuer');\n\t}\n\n\tstatic override isInstance(input: unknown): input is KeetaAnchorCertificateRequiredError {\n\t\treturn(this.hasPropWithValue(input, 'KeetaAnchorCertificateRequiredErrorObjectTypeID', KeetaAnchorCertificateRequiredError.KeetaAnchorCertificateRequiredErrorObjectTypeID));\n\t}\n\n\toverride asErrorResponse(contentType: 'text/plain' | 'application/json'): { error: string; statusCode: number; contentType: string } {\n\t\tlet message = this.message;\n\t\tif (contentType === 'application/json') {\n\t\t\tmessage = JSON.stringify({\n\t\t\t\tok: false,\n\t\t\t\tname: this.name,\n\t\t\t\tdata: { acceptedIssuers: this.acceptedIssuers, kind: this.kind },\n\t\t\t\terror: this.message\n\t\t\t});\n\t\t}\n\n\t\treturn({\n\t\t\terror: message,\n\t\t\tstatusCode: this.statusCode,\n\t\t\tcontentType: contentType\n\t\t});\n\t}\n\n\toverride toJSON(): KeetaAnchorCertificateRequiredErrorJSON {\n\t\treturn({\n\t\t\t...super.toJSON(),\n\t\t\tacceptedIssuers: this.acceptedIssuers,\n\t\t\tkind: this.kind\n\t\t});\n\t}\n\n\tstatic override async fromJSON(input: unknown): Promise<KeetaAnchorCertificateRequiredError> {\n\t\tconst { message, other } = this.extractErrorProperties(input, this);\n\n\t\tif (!('data' in other)) {\n\t\t\tthrow(new Error('Invalid KeetaAnchorCertificateRequiredError JSON: missing data property'));\n\t\t}\n\n\t\tconst parsed = assertKeetaAnchorCertificateRequiredErrorJSONProperties(other.data);\n\t\tconst error = new this({ acceptedIssuers: parsed.acceptedIssuers, kind: parsed.kind }, message);\n\n\t\terror.restoreFromJSON(other);\n\n\t\treturn(error);\n\t}\n}\n"]}
@@ -1,12 +1,14 @@
1
1
  import type { Account } from "@keetanetwork/keetanet-client/lib/account.js";
2
+ import type { ResolvedCertificateChainRequirement } from "../utils/certificate-network.js";
3
+ import type { Signable } from "../utils/signing.js";
2
4
  export type ExtractOk<T> = Omit<Extract<T, {
3
5
  ok: true;
4
6
  }>, 'ok'>;
5
- export interface HTTPSignedField {
7
+ export type HTTPSignedField = {
6
8
  nonce: string;
7
9
  timestamp: string;
8
10
  signature: string;
9
- }
11
+ };
10
12
  export declare const assertHTTPSignedField: (input: unknown) => HTTPSignedField;
11
13
  export interface HTTPSignedFieldURLParameters {
12
14
  signedField: HTTPSignedField;
@@ -14,4 +16,20 @@ export interface HTTPSignedFieldURLParameters {
14
16
  }
15
17
  export declare function addSignatureToURL(input: URL | string, data: HTTPSignedFieldURLParameters): URL;
16
18
  export declare function parseSignatureFromURL(input: URL | string): Partial<HTTPSignedFieldURLParameters>;
19
+ /**
20
+ * Verify a signed body, then enforce the cert-chain gate. Returns the
21
+ * authenticated account. Throws `KeetaAnchorUserError` on missing or
22
+ * invalid auth, and `KeetaAnchorCertificateRequiredError` when the
23
+ * caller's on-chain cert chain doesn't satisfy `certificateChain`.
24
+ */
25
+ export declare function verifyBodyAuth<T extends {
26
+ account?: string;
27
+ signed?: unknown;
28
+ }>(request: T, getSigningData: (req: T) => Signable, certificateChain?: ResolvedCertificateChainRequirement): Promise<Account>;
29
+ /**
30
+ * Verify a URL-signed request, then enforce the cert-chain gate. Returns
31
+ * the authenticated account. The signable is built by the caller from a
32
+ * request derived from the URL-bound account public key.
33
+ */
34
+ export declare function verifyURLAuth(url: URL | string, getSigningData: (account: Account) => Signable, certificateChain?: ResolvedCertificateChainRequirement): Promise<Account>;
17
35
  //# sourceMappingURL=common.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/lib/http-server/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8CAA8C,CAAC;AAK5E,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,CAAC,EAAE,IAAI,CAAC,CAAC;AAEhE,MAAM,WAAW,eAAe;IAC/B,KAAK,EAAE,MAAM,CAAC;IAEd,SAAS,EAAE,MAAM,CAAC;IAElB,SAAS,EAAE,MAAM,CAAC;CAClB;AAED,eAAO,MAAM,qBAAqB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,eAAuD,CAAC;AAEhH,MAAM,WAAW,4BAA4B;IAC5C,WAAW,EAAE,eAAe,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,EAAE,IAAI,EAAE,4BAA4B,GAAG,GAAG,CAsB9F;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,GAAG,OAAO,CAAC,4BAA4B,CAAC,CA6ChG"}
1
+ {"version":3,"file":"common.d.ts","sourceRoot":"","sources":["../../../src/lib/http-server/common.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,OAAO,EAAE,MAAM,8CAA8C,CAAC;AAC5E,OAAO,KAAK,EAAE,mCAAmC,EAAE,MAAM,iCAAiC,CAAC;AAC3F,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AAOpD,MAAM,MAAM,SAAS,CAAC,CAAC,IAAI,IAAI,CAAC,OAAO,CAAC,CAAC,EAAE;IAAE,EAAE,EAAE,IAAI,CAAA;CAAE,CAAC,EAAE,IAAI,CAAC,CAAC;AAEhE,MAAM,MAAM,eAAe,GAAG;IAC7B,KAAK,EAAE,MAAM,CAAC;IAEd,SAAS,EAAE,MAAM,CAAC;IAElB,SAAS,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,eAAO,MAAM,qBAAqB,EAAE,CAAC,KAAK,EAAE,OAAO,KAAK,eAAuD,CAAC;AAEhH,MAAM,WAAW,4BAA4B;IAC5C,WAAW,EAAE,eAAe,CAAC;IAC7B,OAAO,EAAE,OAAO,CAAC;CACjB;AAED,wBAAgB,iBAAiB,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,EAAE,IAAI,EAAE,4BAA4B,GAAG,GAAG,CAsB9F;AAED,wBAAgB,qBAAqB,CAAC,KAAK,EAAE,GAAG,GAAG,MAAM,GAAG,OAAO,CAAC,4BAA4B,CAAC,CA6ChG;AAED;;;;;GAKG;AACH,wBAAsB,cAAc,CAAC,CAAC,SAAS;IAAE,OAAO,CAAC,EAAE,MAAM,CAAC;IAAC,MAAM,CAAC,EAAE,OAAO,CAAA;CAAE,EACpF,OAAO,EAAE,CAAC,EACV,cAAc,EAAE,CAAC,GAAG,EAAE,CAAC,KAAK,QAAQ,EACpC,gBAAgB,CAAC,EAAE,mCAAmC,GACpD,OAAO,CAAC,OAAO,CAAC,CAiBlB;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CAClC,GAAG,EAAE,GAAG,GAAG,MAAM,EACjB,cAAc,EAAE,CAAC,OAAO,EAAE,OAAO,KAAK,QAAQ,EAC9C,gBAAgB,CAAC,EAAE,mCAAmC,GACpD,OAAO,CAAC,OAAO,CAAC,CAsBlB"}
@@ -2,7 +2,9 @@ import * as __typia_transform__assertGuard from "typia/lib/internal/_assertGuard
2
2
  import * as __typia_transform__accessExpressionAsString from "typia/lib/internal/_accessExpressionAsString.js";
3
3
  import { KeetaAnchorUserError } from "../error.js";
4
4
  import { KeetaNet } from "../../client/index.js";
5
+ import { assertAccountCertificateChain } from "../utils/certificate-network.js";
5
6
  import { createAssertEquals } from "typia";
7
+ import { VerifySignedData } from "../utils/signing.js";
6
8
  export const assertHTTPSignedField = (() => { const _io0 = (input, _exceptionable = true) => "string" === typeof input.nonce && "string" === typeof input.timestamp && "string" === typeof input.signature && (3 === Object.keys(input).length || Object.keys(input).every(key => {
7
9
  if (["nonce", "timestamp", "signature"].some(prop => key === prop))
8
10
  return true;
@@ -108,4 +110,49 @@ export function parseSignatureFromURL(input) {
108
110
  }
109
111
  return (retVal);
110
112
  }
113
+ /**
114
+ * Verify a signed body, then enforce the cert-chain gate. Returns the
115
+ * authenticated account. Throws `KeetaAnchorUserError` on missing or
116
+ * invalid auth, and `KeetaAnchorCertificateRequiredError` when the
117
+ * caller's on-chain cert chain doesn't satisfy `certificateChain`.
118
+ */
119
+ export async function verifyBodyAuth(request, getSigningData, certificateChain) {
120
+ if (!request.account || !request.signed) {
121
+ throw (new KeetaAnchorUserError('Authentication required'));
122
+ }
123
+ const account = KeetaNet.lib.Account.fromPublicKeyString(request.account).assertAccount();
124
+ const signable = getSigningData(request);
125
+ const signed = assertHTTPSignedField(request.signed);
126
+ const valid = await VerifySignedData(account, signable, signed);
127
+ if (!valid) {
128
+ throw (new KeetaAnchorUserError('Invalid signature'));
129
+ }
130
+ await assertAccountCertificateChain(account, certificateChain);
131
+ return (account);
132
+ }
133
+ /**
134
+ * Verify a URL-signed request, then enforce the cert-chain gate. Returns
135
+ * the authenticated account. The signable is built by the caller from a
136
+ * request derived from the URL-bound account public key.
137
+ */
138
+ export async function verifyURLAuth(url, getSigningData, certificateChain) {
139
+ let urlString;
140
+ if (typeof url === 'string') {
141
+ urlString = url;
142
+ }
143
+ else {
144
+ urlString = url.href;
145
+ }
146
+ const parsed = parseSignatureFromURL(urlString);
147
+ if (!parsed.account || !parsed.signedField) {
148
+ throw (new KeetaAnchorUserError('Authentication required'));
149
+ }
150
+ const signable = getSigningData(parsed.account);
151
+ const valid = await VerifySignedData(parsed.account, signable, parsed.signedField);
152
+ if (!valid) {
153
+ throw (new KeetaAnchorUserError('Invalid signature'));
154
+ }
155
+ await assertAccountCertificateChain(parsed.account, certificateChain);
156
+ return (parsed.account);
157
+ }
111
158
  //# sourceMappingURL=common.js.map