@majikah/sdk 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (71) hide show
  1. package/LICENSE +67 -0
  2. package/README.md +1112 -0
  3. package/dist/client/MajikahSDKClient.d.ts +308 -0
  4. package/dist/client/MajikahSDKClient.js +318 -0
  5. package/dist/errors/APIError.d.ts +7 -0
  6. package/dist/errors/APIError.js +14 -0
  7. package/dist/errors/AuthenticationError.d.ts +3 -0
  8. package/dist/errors/AuthenticationError.js +4 -0
  9. package/dist/errors/MajikahError.d.ts +4 -0
  10. package/dist/errors/MajikahError.js +9 -0
  11. package/dist/errors/QuotaExhaustedError.d.ts +3 -0
  12. package/dist/errors/QuotaExhaustedError.js +4 -0
  13. package/dist/errors/RateLimitError.d.ts +5 -0
  14. package/dist/errors/RateLimitError.js +10 -0
  15. package/dist/errors/ServiceUnavailableError.d.ts +3 -0
  16. package/dist/errors/ServiceUnavailableError.js +4 -0
  17. package/dist/errors/ValidationError.d.ts +5 -0
  18. package/dist/errors/ValidationError.js +10 -0
  19. package/dist/errors/index.d.ts +8 -0
  20. package/dist/errors/index.js +8 -0
  21. package/dist/errors/mapError.d.ts +3 -0
  22. package/dist/errors/mapError.js +22 -0
  23. package/dist/index.d.ts +10 -0
  24. package/dist/index.js +10 -0
  25. package/dist/services/index.d.ts +4 -0
  26. package/dist/services/index.js +4 -0
  27. package/dist/services/muid/MUIDClient.d.ts +95 -0
  28. package/dist/services/muid/MUIDClient.js +138 -0
  29. package/dist/services/muid/key-resolver.d.ts +24 -0
  30. package/dist/services/muid/key-resolver.js +32 -0
  31. package/dist/services/notary/NotaryClient.d.ts +188 -0
  32. package/dist/services/notary/NotaryClient.js +291 -0
  33. package/dist/services/notary/validation.d.ts +7 -0
  34. package/dist/services/notary/validation.js +19 -0
  35. package/dist/services/shared/encoding.d.ts +21 -0
  36. package/dist/services/shared/encoding.js +43 -0
  37. package/dist/services/shared/resolve-signature.d.ts +23 -0
  38. package/dist/services/shared/resolve-signature.js +31 -0
  39. package/dist/services/shared/sleep.d.ts +1 -0
  40. package/dist/services/shared/sleep.js +3 -0
  41. package/dist/services/shared/validation.d.ts +9 -0
  42. package/dist/services/shared/validation.js +16 -0
  43. package/dist/services/slink/SLinkClient.d.ts +174 -0
  44. package/dist/services/slink/SLinkClient.js +231 -0
  45. package/dist/services/slink/validation.d.ts +24 -0
  46. package/dist/services/slink/validation.js +31 -0
  47. package/dist/services/tsa/TSAClient.d.ts +101 -0
  48. package/dist/services/tsa/TSAClient.js +178 -0
  49. package/dist/services/tsa/validation.d.ts +2 -0
  50. package/dist/services/tsa/validation.js +12 -0
  51. package/dist/transport/HttpClient.d.ts +85 -0
  52. package/dist/transport/HttpClient.js +135 -0
  53. package/dist/transport/RouteResolver.d.ts +54 -0
  54. package/dist/transport/RouteResolver.js +67 -0
  55. package/dist/transport/retry-after.d.ts +17 -0
  56. package/dist/transport/retry-after.js +39 -0
  57. package/dist/transport/retry.d.ts +8 -0
  58. package/dist/transport/retry.js +61 -0
  59. package/dist/types/common.d.ts +133 -0
  60. package/dist/types/common.js +42 -0
  61. package/dist/types/index.d.ts +4 -0
  62. package/dist/types/index.js +1 -0
  63. package/dist/types/muid.d.ts +80 -0
  64. package/dist/types/muid.js +1 -0
  65. package/dist/types/notary.d.ts +243 -0
  66. package/dist/types/notary.js +1 -0
  67. package/dist/types/slink.d.ts +60 -0
  68. package/dist/types/slink.js +1 -0
  69. package/dist/types/tsa.d.ts +144 -0
  70. package/dist/types/tsa.js +1 -0
  71. package/package.json +67 -0
@@ -0,0 +1,308 @@
1
+ import { TSAClient } from "../services/tsa/TSAClient";
2
+ import { MUIDClient } from "../services/muid/MUIDClient";
3
+ import { SLinkClient } from "../services/slink/SLinkClient";
4
+ import { NotaryClient } from "../services/notary/NotaryClient";
5
+ import type { MajikahClientOptions } from "../types/common";
6
+ /**
7
+ * Primary entry point for the Majikah TypeScript SDK.
8
+ *
9
+ * `MajikahSDKClient` composes the SDK's service-specific clients behind a
10
+ * single authenticated transport layer.
11
+ *
12
+ * Each service is exposed through a dedicated namespace:
13
+ *
14
+ * ```ts
15
+ * const majikah = new MajikahSDKClient({
16
+ * apiKey: process.env.MAJIKAH_API_KEY!,
17
+ * });
18
+ *
19
+ * await majikah.muid.lookup("alice");
20
+ * await majikah.tsa.timestampFile(signedFile);
21
+ * await majikah.slink.verifyUrl("example.com");
22
+ * await majikah.notary.initiateNotarization(sealedFile);
23
+ * ```
24
+ *
25
+ * The root client is intentionally thin. Service-specific functionality
26
+ * belongs to the corresponding client:
27
+ *
28
+ * - {@link MUIDClient} — identity lookup and signature verification
29
+ * - {@link TSAClient} — trusted timestamping
30
+ * - {@link SLinkClient} — signed link registration, lookup, and verification
31
+ * - {@link NotaryClient} — payment-aware on-chain notarization
32
+ *
33
+ * All service clients created by this class share the same underlying
34
+ * {@link HttpClient} instance. This provides a consistent transport and
35
+ * authentication configuration across the SDK while allowing each service to
36
+ * maintain its own public API and domain-specific behavior.
37
+ *
38
+ * ## Architecture
39
+ *
40
+ * ```text
41
+ * MajikahSDKClient
42
+ * │
43
+ * shared HttpClient
44
+ * │
45
+ * ┌────────────────┼────────────────┐
46
+ * │ │ │
47
+ * ▼ ▼ ▼
48
+ * MUID TSA SLink
49
+ * │
50
+ * └─────────────────────────────────┐
51
+ * ▼
52
+ * Notary
53
+ * ```
54
+ *
55
+ * The root client is responsible for SDK composition and configuration.
56
+ * It does not duplicate service methods or local cryptographic primitives.
57
+ * Operations that belong to a specific service should be accessed through
58
+ * that service's namespace.
59
+ *
60
+ * ## Getting an API key
61
+ *
62
+ * API keys are issued through the Majikah Developer Portal:
63
+ *
64
+ * https://developers.majikah.solutions/early-access
65
+ *
66
+ * To obtain an API key:
67
+ *
68
+ * 1. Create a Majikah account.
69
+ * 2. Create your **Majik Universal ID (MUID)**.
70
+ * 3. Complete the required **KYC verification** for your MUID.
71
+ * 4. Submit the **Early Access application** in the developer portal.
72
+ * 5. Wait for the application to be reviewed and approved by Majikah.
73
+ * 6. After approval, you will receive an email confirmation and gain access
74
+ * to API key generation in the developer portal.
75
+ *
76
+ * Public API access is currently subject to developer approval. An API key
77
+ * cannot be generated until the Early Access application has been approved.
78
+ *
79
+ * Example:
80
+ *
81
+ * ```ts
82
+ * const majikah = new MajikahSDKClient({
83
+ * apiKey: process.env.MAJIKAH_API_KEY!,
84
+ * });
85
+ * ```
86
+ *
87
+ * Keep your API key secure. Do not commit it to source control, embed
88
+ * privileged keys in public client bundles, or expose it through logs.
89
+ *
90
+ * ## Authentication
91
+ *
92
+ * The API key supplied through {@link MajikahClientOptions} is shared by the
93
+ * underlying HTTP transport and is automatically applied to authenticated
94
+ * API requests.
95
+ *
96
+ * ```ts
97
+ * const majikah = new MajikahSDKClient({
98
+ * apiKey: process.env.MAJIKAH_API_KEY!,
99
+ * });
100
+ * ```
101
+ *
102
+ * API keys should be treated as credentials and stored using the runtime's
103
+ * secure secret-management facilities. Do not commit production keys to
104
+ * source control or expose privileged keys in public browser bundles.
105
+ *
106
+ * ## Transport and configuration
107
+ *
108
+ * The constructor accepts the full {@link MajikahClientOptions} configuration,
109
+ * including the API base URL, API version configuration, request timeout,
110
+ * additional headers, retry policy, and optional custom `fetch`
111
+ * implementation.
112
+ *
113
+ * ```ts
114
+ * const majikah = new MajikahSDKClient({
115
+ * apiKey,
116
+ * baseUrl: "https://api-public.majikah.solutions",
117
+ * version: 1,
118
+ * timeoutMs: 15_000,
119
+ * retry: {
120
+ * maxAttempts: 3,
121
+ * initialDelayMs: 300,
122
+ * jitterFactor: 0.4,
123
+ * capDelayMs: 5_000,
124
+ * },
125
+ * });
126
+ * ```
127
+ *
128
+ * All configured services inherit the same transport configuration unless
129
+ * their own service-level behavior explicitly overrides it.
130
+ *
131
+ * ## Local cryptography
132
+ *
133
+ * `MajikahSDKClient` does not hold or manage application private keys.
134
+ * Signing, sealing, and verification operations that require private
135
+ * cryptographic material are delegated to the corresponding Majikah
136
+ * cryptographic libraries, such as `@majikah/majik-key` and
137
+ * `@majikah/majik-signature`.
138
+ *
139
+ * For example:
140
+ *
141
+ * ```ts
142
+ * const stamped = await majikah.tsa.stampFile(
143
+ * file,
144
+ * unlockedKey,
145
+ * );
146
+ * ```
147
+ *
148
+ * The SDK coordinates the service request but does not require private
149
+ * signing keys to be uploaded to the Majikah API.
150
+ *
151
+ * ## Service namespaces
152
+ *
153
+ * ### `muid`
154
+ *
155
+ * {@link MUIDClient} provides identity lookup and signature verification
156
+ * functionality through Majik Universal ID.
157
+ *
158
+ * ```ts
159
+ * const profile = await majikah.muid.lookup("alice");
160
+ * ```
161
+ *
162
+ * ### `tsa`
163
+ *
164
+ * {@link TSAClient} provides trusted timestamping operations.
165
+ *
166
+ * ```ts
167
+ * const result = await majikah.tsa.timestampFile(signedFile);
168
+ * ```
169
+ *
170
+ * ### `slink`
171
+ *
172
+ * {@link SLinkClient} provides signed link registration, lookup,
173
+ * pagination, and cryptographic verification workflows.
174
+ *
175
+ * ```ts
176
+ * const result = await majikah.slink.verifyUrl("example.com");
177
+ * ```
178
+ *
179
+ * ### `notary`
180
+ *
181
+ * {@link NotaryClient} provides payment-aware file notarization and
182
+ * on-chain anchor workflows.
183
+ *
184
+ * ```ts
185
+ * const result =
186
+ * await majikah.notary.initiateNotarization(sealedFile);
187
+ * ```
188
+ *
189
+ * ## Immutability
190
+ *
191
+ * The client class and its prototype are frozen after definition.
192
+ *
193
+ * Service properties are exposed as `readonly` references so consumers
194
+ * cannot replace the configured service clients through normal TypeScript
195
+ * usage.
196
+ *
197
+ * Freezing the class and prototype helps preserve the SDK's public service
198
+ * topology and prevents accidental mutation of the SDK's core methods at
199
+ * runtime.
200
+ *
201
+ * This does not freeze the internal state of the service clients or prevent
202
+ * normal object-level reflection capabilities provided by the JavaScript
203
+ * runtime.
204
+ *
205
+ * @param options SDK configuration used to initialize the shared HTTP
206
+ * transport and all service clients.
207
+ *
208
+ * @example
209
+ * ```ts
210
+ * import { MajikahSDKClient } from "@majikah/sdk";
211
+ *
212
+ * const majikah = new MajikahSDKClient({
213
+ * apiKey: process.env.MAJIKAH_API_KEY!,
214
+ * });
215
+ * ```
216
+ *
217
+ * @example
218
+ * ```ts
219
+ * const majikah = new MajikahSDKClient({
220
+ * apiKey,
221
+ * version: {
222
+ * muid: 2,
223
+ * tsa: 1,
224
+ * slink: 1,
225
+ * notary: 1,
226
+ * },
227
+ * timeoutMs: 15_000,
228
+ * });
229
+ *
230
+ * const profile = await majikah.muid.lookup("alice");
231
+ * const quota = await majikah.tsa.quota();
232
+ * ```
233
+ *
234
+ * @remarks
235
+ * Create one root client per application integration or logical
236
+ * configuration rather than constructing separate service clients manually.
237
+ * This ensures that all services share the same transport, authentication,
238
+ * retry policy, timeout configuration, and API version strategy.
239
+ */
240
+ export declare class MajikahSDKClient {
241
+ /**
242
+ * Trusted Timestamping Authority service client.
243
+ *
244
+ * Use this namespace for trusted timestamp issuance, timestamping existing
245
+ * signatures, detached timestamp envelopes, and TSA quota operations.
246
+ *
247
+ * @see {@link TSAClient}
248
+ */
249
+ readonly tsa: TSAClient;
250
+ /**
251
+ * Majik Universal ID service client.
252
+ *
253
+ * Use this namespace for public MUID lookup, authenticated MUID retrieval,
254
+ * and signature verification against MUID identities.
255
+ *
256
+ * @see {@link MUIDClient}
257
+ */
258
+ readonly muid: MUIDClient;
259
+ /**
260
+ * Signed Link service client.
261
+ *
262
+ * Use this namespace for SLink registration, lookup, pagination, and
263
+ * cryptographic verification workflows.
264
+ *
265
+ * @see {@link SLinkClient}
266
+ */
267
+ readonly slink: SLinkClient;
268
+ /**
269
+ * File Notarization service client.
270
+ *
271
+ * Use this namespace for payment-aware notarization, seal registration,
272
+ * anchor status, polling, and higher-level seal-and-notarize workflows.
273
+ *
274
+ * @see {@link NotaryClient}
275
+ */
276
+ readonly notary: NotaryClient;
277
+ /**
278
+ * Creates a configured Majikah SDK client and initializes all public
279
+ * service namespaces over a shared HTTP transport.
280
+ *
281
+ * The supplied options are passed to a single {@link HttpClient} instance,
282
+ * which is then shared by the MUID, TSA, SLink, and Notary clients.
283
+ *
284
+ * This means authentication, base URL, request timeout, retry behavior,
285
+ * custom headers, API versioning, and custom `fetch` behavior are
286
+ * consistently applied across the service clients.
287
+ *
288
+ * @param options SDK client configuration and transport options.
289
+ *
290
+ * @example
291
+ * ```ts
292
+ * const majikah = new MajikahSDKClient({
293
+ * apiKey: process.env.MAJIKAH_API_KEY!,
294
+ * });
295
+ * ```
296
+ *
297
+ * @example
298
+ * ```ts
299
+ * const majikah = new MajikahSDKClient({
300
+ * apiKey,
301
+ * baseUrl: "https://api-public.majikah.solutions",
302
+ * timeoutMs: 15_000,
303
+ * version: 1,
304
+ * });
305
+ * ```
306
+ */
307
+ constructor(options: MajikahClientOptions);
308
+ }
@@ -0,0 +1,318 @@
1
+ import { HttpClient } from "../transport/HttpClient";
2
+ import { TSAClient } from "../services/tsa/TSAClient";
3
+ import { MUIDClient } from "../services/muid/MUIDClient";
4
+ import { SLinkClient } from "../services/slink/SLinkClient";
5
+ import { NotaryClient } from "../services/notary/NotaryClient";
6
+ /**
7
+ * Primary entry point for the Majikah TypeScript SDK.
8
+ *
9
+ * `MajikahSDKClient` composes the SDK's service-specific clients behind a
10
+ * single authenticated transport layer.
11
+ *
12
+ * Each service is exposed through a dedicated namespace:
13
+ *
14
+ * ```ts
15
+ * const majikah = new MajikahSDKClient({
16
+ * apiKey: process.env.MAJIKAH_API_KEY!,
17
+ * });
18
+ *
19
+ * await majikah.muid.lookup("alice");
20
+ * await majikah.tsa.timestampFile(signedFile);
21
+ * await majikah.slink.verifyUrl("example.com");
22
+ * await majikah.notary.initiateNotarization(sealedFile);
23
+ * ```
24
+ *
25
+ * The root client is intentionally thin. Service-specific functionality
26
+ * belongs to the corresponding client:
27
+ *
28
+ * - {@link MUIDClient} — identity lookup and signature verification
29
+ * - {@link TSAClient} — trusted timestamping
30
+ * - {@link SLinkClient} — signed link registration, lookup, and verification
31
+ * - {@link NotaryClient} — payment-aware on-chain notarization
32
+ *
33
+ * All service clients created by this class share the same underlying
34
+ * {@link HttpClient} instance. This provides a consistent transport and
35
+ * authentication configuration across the SDK while allowing each service to
36
+ * maintain its own public API and domain-specific behavior.
37
+ *
38
+ * ## Architecture
39
+ *
40
+ * ```text
41
+ * MajikahSDKClient
42
+ * │
43
+ * shared HttpClient
44
+ * │
45
+ * ┌────────────────┼────────────────┐
46
+ * │ │ │
47
+ * ▼ ▼ ▼
48
+ * MUID TSA SLink
49
+ * │
50
+ * └─────────────────────────────────┐
51
+ * ▼
52
+ * Notary
53
+ * ```
54
+ *
55
+ * The root client is responsible for SDK composition and configuration.
56
+ * It does not duplicate service methods or local cryptographic primitives.
57
+ * Operations that belong to a specific service should be accessed through
58
+ * that service's namespace.
59
+ *
60
+ * ## Getting an API key
61
+ *
62
+ * API keys are issued through the Majikah Developer Portal:
63
+ *
64
+ * https://developers.majikah.solutions/early-access
65
+ *
66
+ * To obtain an API key:
67
+ *
68
+ * 1. Create a Majikah account.
69
+ * 2. Create your **Majik Universal ID (MUID)**.
70
+ * 3. Complete the required **KYC verification** for your MUID.
71
+ * 4. Submit the **Early Access application** in the developer portal.
72
+ * 5. Wait for the application to be reviewed and approved by Majikah.
73
+ * 6. After approval, you will receive an email confirmation and gain access
74
+ * to API key generation in the developer portal.
75
+ *
76
+ * Public API access is currently subject to developer approval. An API key
77
+ * cannot be generated until the Early Access application has been approved.
78
+ *
79
+ * Example:
80
+ *
81
+ * ```ts
82
+ * const majikah = new MajikahSDKClient({
83
+ * apiKey: process.env.MAJIKAH_API_KEY!,
84
+ * });
85
+ * ```
86
+ *
87
+ * Keep your API key secure. Do not commit it to source control, embed
88
+ * privileged keys in public client bundles, or expose it through logs.
89
+ *
90
+ * ## Authentication
91
+ *
92
+ * The API key supplied through {@link MajikahClientOptions} is shared by the
93
+ * underlying HTTP transport and is automatically applied to authenticated
94
+ * API requests.
95
+ *
96
+ * ```ts
97
+ * const majikah = new MajikahSDKClient({
98
+ * apiKey: process.env.MAJIKAH_API_KEY!,
99
+ * });
100
+ * ```
101
+ *
102
+ * API keys should be treated as credentials and stored using the runtime's
103
+ * secure secret-management facilities. Do not commit production keys to
104
+ * source control or expose privileged keys in public browser bundles.
105
+ *
106
+ * ## Transport and configuration
107
+ *
108
+ * The constructor accepts the full {@link MajikahClientOptions} configuration,
109
+ * including the API base URL, API version configuration, request timeout,
110
+ * additional headers, retry policy, and optional custom `fetch`
111
+ * implementation.
112
+ *
113
+ * ```ts
114
+ * const majikah = new MajikahSDKClient({
115
+ * apiKey,
116
+ * baseUrl: "https://api-public.majikah.solutions",
117
+ * version: 1,
118
+ * timeoutMs: 15_000,
119
+ * retry: {
120
+ * maxAttempts: 3,
121
+ * initialDelayMs: 300,
122
+ * jitterFactor: 0.4,
123
+ * capDelayMs: 5_000,
124
+ * },
125
+ * });
126
+ * ```
127
+ *
128
+ * All configured services inherit the same transport configuration unless
129
+ * their own service-level behavior explicitly overrides it.
130
+ *
131
+ * ## Local cryptography
132
+ *
133
+ * `MajikahSDKClient` does not hold or manage application private keys.
134
+ * Signing, sealing, and verification operations that require private
135
+ * cryptographic material are delegated to the corresponding Majikah
136
+ * cryptographic libraries, such as `@majikah/majik-key` and
137
+ * `@majikah/majik-signature`.
138
+ *
139
+ * For example:
140
+ *
141
+ * ```ts
142
+ * const stamped = await majikah.tsa.stampFile(
143
+ * file,
144
+ * unlockedKey,
145
+ * );
146
+ * ```
147
+ *
148
+ * The SDK coordinates the service request but does not require private
149
+ * signing keys to be uploaded to the Majikah API.
150
+ *
151
+ * ## Service namespaces
152
+ *
153
+ * ### `muid`
154
+ *
155
+ * {@link MUIDClient} provides identity lookup and signature verification
156
+ * functionality through Majik Universal ID.
157
+ *
158
+ * ```ts
159
+ * const profile = await majikah.muid.lookup("alice");
160
+ * ```
161
+ *
162
+ * ### `tsa`
163
+ *
164
+ * {@link TSAClient} provides trusted timestamping operations.
165
+ *
166
+ * ```ts
167
+ * const result = await majikah.tsa.timestampFile(signedFile);
168
+ * ```
169
+ *
170
+ * ### `slink`
171
+ *
172
+ * {@link SLinkClient} provides signed link registration, lookup,
173
+ * pagination, and cryptographic verification workflows.
174
+ *
175
+ * ```ts
176
+ * const result = await majikah.slink.verifyUrl("example.com");
177
+ * ```
178
+ *
179
+ * ### `notary`
180
+ *
181
+ * {@link NotaryClient} provides payment-aware file notarization and
182
+ * on-chain anchor workflows.
183
+ *
184
+ * ```ts
185
+ * const result =
186
+ * await majikah.notary.initiateNotarization(sealedFile);
187
+ * ```
188
+ *
189
+ * ## Immutability
190
+ *
191
+ * The client class and its prototype are frozen after definition.
192
+ *
193
+ * Service properties are exposed as `readonly` references so consumers
194
+ * cannot replace the configured service clients through normal TypeScript
195
+ * usage.
196
+ *
197
+ * Freezing the class and prototype helps preserve the SDK's public service
198
+ * topology and prevents accidental mutation of the SDK's core methods at
199
+ * runtime.
200
+ *
201
+ * This does not freeze the internal state of the service clients or prevent
202
+ * normal object-level reflection capabilities provided by the JavaScript
203
+ * runtime.
204
+ *
205
+ * @param options SDK configuration used to initialize the shared HTTP
206
+ * transport and all service clients.
207
+ *
208
+ * @example
209
+ * ```ts
210
+ * import { MajikahSDKClient } from "@majikah/sdk";
211
+ *
212
+ * const majikah = new MajikahSDKClient({
213
+ * apiKey: process.env.MAJIKAH_API_KEY!,
214
+ * });
215
+ * ```
216
+ *
217
+ * @example
218
+ * ```ts
219
+ * const majikah = new MajikahSDKClient({
220
+ * apiKey,
221
+ * version: {
222
+ * muid: 2,
223
+ * tsa: 1,
224
+ * slink: 1,
225
+ * notary: 1,
226
+ * },
227
+ * timeoutMs: 15_000,
228
+ * });
229
+ *
230
+ * const profile = await majikah.muid.lookup("alice");
231
+ * const quota = await majikah.tsa.quota();
232
+ * ```
233
+ *
234
+ * @remarks
235
+ * Create one root client per application integration or logical
236
+ * configuration rather than constructing separate service clients manually.
237
+ * This ensures that all services share the same transport, authentication,
238
+ * retry policy, timeout configuration, and API version strategy.
239
+ */
240
+ export class MajikahSDKClient {
241
+ /**
242
+ * Trusted Timestamping Authority service client.
243
+ *
244
+ * Use this namespace for trusted timestamp issuance, timestamping existing
245
+ * signatures, detached timestamp envelopes, and TSA quota operations.
246
+ *
247
+ * @see {@link TSAClient}
248
+ */
249
+ tsa;
250
+ /**
251
+ * Majik Universal ID service client.
252
+ *
253
+ * Use this namespace for public MUID lookup, authenticated MUID retrieval,
254
+ * and signature verification against MUID identities.
255
+ *
256
+ * @see {@link MUIDClient}
257
+ */
258
+ muid;
259
+ /**
260
+ * Signed Link service client.
261
+ *
262
+ * Use this namespace for SLink registration, lookup, pagination, and
263
+ * cryptographic verification workflows.
264
+ *
265
+ * @see {@link SLinkClient}
266
+ */
267
+ slink;
268
+ /**
269
+ * File Notarization service client.
270
+ *
271
+ * Use this namespace for payment-aware notarization, seal registration,
272
+ * anchor status, polling, and higher-level seal-and-notarize workflows.
273
+ *
274
+ * @see {@link NotaryClient}
275
+ */
276
+ notary;
277
+ /**
278
+ * Creates a configured Majikah SDK client and initializes all public
279
+ * service namespaces over a shared HTTP transport.
280
+ *
281
+ * The supplied options are passed to a single {@link HttpClient} instance,
282
+ * which is then shared by the MUID, TSA, SLink, and Notary clients.
283
+ *
284
+ * This means authentication, base URL, request timeout, retry behavior,
285
+ * custom headers, API versioning, and custom `fetch` behavior are
286
+ * consistently applied across the service clients.
287
+ *
288
+ * @param options SDK client configuration and transport options.
289
+ *
290
+ * @example
291
+ * ```ts
292
+ * const majikah = new MajikahSDKClient({
293
+ * apiKey: process.env.MAJIKAH_API_KEY!,
294
+ * });
295
+ * ```
296
+ *
297
+ * @example
298
+ * ```ts
299
+ * const majikah = new MajikahSDKClient({
300
+ * apiKey,
301
+ * baseUrl: "https://api-public.majikah.solutions",
302
+ * timeoutMs: 15_000,
303
+ * version: 1,
304
+ * });
305
+ * ```
306
+ */
307
+ constructor(options) {
308
+ const http = new HttpClient(options);
309
+ this.tsa = new TSAClient(http);
310
+ this.muid = new MUIDClient(http);
311
+ this.slink = new SLinkClient(http);
312
+ this.notary = new NotaryClient(http);
313
+ }
314
+ }
315
+ // Freeze static methods
316
+ Object.freeze(MajikahSDKClient);
317
+ // Freeze instance methods
318
+ Object.freeze(MajikahSDKClient.prototype);
@@ -0,0 +1,7 @@
1
+ import { MajikahError } from "./MajikahError";
2
+ export declare class APIError extends MajikahError {
3
+ readonly status: number;
4
+ readonly code: string;
5
+ readonly requestId?: string | undefined;
6
+ constructor(message: string, status: number, code: string, requestId?: string | undefined);
7
+ }
@@ -0,0 +1,14 @@
1
+ import { MajikahError } from "./MajikahError";
2
+ // errors/APIError.ts
3
+ export class APIError extends MajikahError {
4
+ status;
5
+ code;
6
+ requestId;
7
+ constructor(message, status, code, requestId) {
8
+ super(message);
9
+ this.status = status;
10
+ this.code = code;
11
+ this.requestId = requestId;
12
+ this.name = "APIError";
13
+ }
14
+ }
@@ -0,0 +1,3 @@
1
+ import { APIError } from "./APIError";
2
+ export declare class AuthenticationError extends APIError {
3
+ }
@@ -0,0 +1,4 @@
1
+ import { APIError } from "./APIError";
2
+ // errors/AuthenticationError.ts — 401
3
+ export class AuthenticationError extends APIError {
4
+ }
@@ -0,0 +1,4 @@
1
+ export declare class MajikahError extends Error {
2
+ readonly cause?: unknown;
3
+ constructor(message: string, cause?: unknown);
4
+ }
@@ -0,0 +1,9 @@
1
+ // errors/MajikahError.ts
2
+ export class MajikahError extends Error {
3
+ cause;
4
+ constructor(message, cause) {
5
+ super(message);
6
+ this.cause = cause;
7
+ this.name = "MajikahError";
8
+ }
9
+ }
@@ -0,0 +1,3 @@
1
+ import { APIError } from "./APIError";
2
+ export declare class QuotaExhaustedError extends APIError {
3
+ }
@@ -0,0 +1,4 @@
1
+ import { APIError } from "./APIError";
2
+ // errors/QuotaExhaustedError.ts — 402, TSA-specific but generic enough to live here
3
+ export class QuotaExhaustedError extends APIError {
4
+ }
@@ -0,0 +1,5 @@
1
+ import { APIError } from "./APIError";
2
+ export declare class RateLimitError extends APIError {
3
+ readonly retryAfterMs?: number | undefined;
4
+ constructor(message: string, status: number, code: string, retryAfterMs?: number | undefined, requestId?: string);
5
+ }
@@ -0,0 +1,10 @@
1
+ import { APIError } from "./APIError";
2
+ // errors/RateLimitError.ts — 429
3
+ export class RateLimitError extends APIError {
4
+ retryAfterMs;
5
+ constructor(message, status, code, retryAfterMs, requestId) {
6
+ super(message, status, code, requestId);
7
+ this.retryAfterMs = retryAfterMs;
8
+ this.name = "RateLimitError";
9
+ }
10
+ }