euclid-ndk 0.2.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 (127) hide show
  1. package/LICENSE +201 -0
  2. package/README.md +603 -0
  3. package/dist/auth/index.d.ts +18 -0
  4. package/dist/auth/index.d.ts.map +1 -0
  5. package/dist/auth/index.js +17 -0
  6. package/dist/auth/index.js.map +1 -0
  7. package/dist/auth/rfc9421.d.ts +112 -0
  8. package/dist/auth/rfc9421.d.ts.map +1 -0
  9. package/dist/auth/rfc9421.js +452 -0
  10. package/dist/auth/rfc9421.js.map +1 -0
  11. package/dist/auth/scheme.d.ts +46 -0
  12. package/dist/auth/scheme.d.ts.map +1 -0
  13. package/dist/auth/scheme.js +44 -0
  14. package/dist/auth/scheme.js.map +1 -0
  15. package/dist/auth/signable.d.ts +37 -0
  16. package/dist/auth/signable.d.ts.map +1 -0
  17. package/dist/auth/signable.js +70 -0
  18. package/dist/auth/signable.js.map +1 -0
  19. package/dist/auth/sigv4.d.ts +72 -0
  20. package/dist/auth/sigv4.d.ts.map +1 -0
  21. package/dist/auth/sigv4.js +227 -0
  22. package/dist/auth/sigv4.js.map +1 -0
  23. package/dist/credentials.d.ts +56 -0
  24. package/dist/credentials.d.ts.map +1 -0
  25. package/dist/credentials.js +135 -0
  26. package/dist/credentials.js.map +1 -0
  27. package/dist/dto/com.d.ts +101 -0
  28. package/dist/dto/com.d.ts.map +1 -0
  29. package/dist/dto/com.js +132 -0
  30. package/dist/dto/com.js.map +1 -0
  31. package/dist/dto/eag.d.ts +104 -0
  32. package/dist/dto/eag.d.ts.map +1 -0
  33. package/dist/dto/eag.js +70 -0
  34. package/dist/dto/eag.js.map +1 -0
  35. package/dist/dto/eam.d.ts +105 -0
  36. package/dist/dto/eam.d.ts.map +1 -0
  37. package/dist/dto/eam.js +98 -0
  38. package/dist/dto/eam.js.map +1 -0
  39. package/dist/dto/eap.d.ts +88 -0
  40. package/dist/dto/eap.d.ts.map +1 -0
  41. package/dist/dto/eap.js +54 -0
  42. package/dist/dto/eap.js.map +1 -0
  43. package/dist/dto/ekm.d.ts +109 -0
  44. package/dist/dto/ekm.d.ts.map +1 -0
  45. package/dist/dto/ekm.js +78 -0
  46. package/dist/dto/ekm.js.map +1 -0
  47. package/dist/dto/ekv.d.ts +73 -0
  48. package/dist/dto/ekv.d.ts.map +1 -0
  49. package/dist/dto/ekv.js +45 -0
  50. package/dist/dto/ekv.js.map +1 -0
  51. package/dist/dto/ens.d.ts +84 -0
  52. package/dist/dto/ens.d.ts.map +1 -0
  53. package/dist/dto/ens.js +72 -0
  54. package/dist/dto/ens.js.map +1 -0
  55. package/dist/dto/eqs.d.ts +160 -0
  56. package/dist/dto/eqs.d.ts.map +1 -0
  57. package/dist/dto/eqs.js +120 -0
  58. package/dist/dto/eqs.js.map +1 -0
  59. package/dist/dto/esm.d.ts +192 -0
  60. package/dist/dto/esm.d.ts.map +1 -0
  61. package/dist/dto/esm.js +147 -0
  62. package/dist/dto/esm.js.map +1 -0
  63. package/dist/dto/ess.d.ts +49 -0
  64. package/dist/dto/ess.d.ts.map +1 -0
  65. package/dist/dto/ess.js +30 -0
  66. package/dist/dto/ess.js.map +1 -0
  67. package/dist/dto/json.d.ts +24 -0
  68. package/dist/dto/json.d.ts.map +1 -0
  69. package/dist/dto/json.js +47 -0
  70. package/dist/dto/json.js.map +1 -0
  71. package/dist/errors.d.ts +40 -0
  72. package/dist/errors.d.ts.map +1 -0
  73. package/dist/errors.js +73 -0
  74. package/dist/errors.js.map +1 -0
  75. package/dist/http/client.d.ts +96 -0
  76. package/dist/http/client.d.ts.map +1 -0
  77. package/dist/http/client.js +258 -0
  78. package/dist/http/client.js.map +1 -0
  79. package/dist/index.d.ts +93 -0
  80. package/dist/index.d.ts.map +1 -0
  81. package/dist/index.js +110 -0
  82. package/dist/index.js.map +1 -0
  83. package/dist/modules/base.d.ts +121 -0
  84. package/dist/modules/base.d.ts.map +1 -0
  85. package/dist/modules/base.js +142 -0
  86. package/dist/modules/base.js.map +1 -0
  87. package/dist/modules/eag.d.ts +166 -0
  88. package/dist/modules/eag.d.ts.map +1 -0
  89. package/dist/modules/eag.js +189 -0
  90. package/dist/modules/eag.js.map +1 -0
  91. package/dist/modules/eam.d.ts +314 -0
  92. package/dist/modules/eam.d.ts.map +1 -0
  93. package/dist/modules/eam.js +641 -0
  94. package/dist/modules/eam.js.map +1 -0
  95. package/dist/modules/eap.d.ts +204 -0
  96. package/dist/modules/eap.d.ts.map +1 -0
  97. package/dist/modules/eap.js +218 -0
  98. package/dist/modules/eap.js.map +1 -0
  99. package/dist/modules/ekm.d.ts +182 -0
  100. package/dist/modules/ekm.d.ts.map +1 -0
  101. package/dist/modules/ekm.js +228 -0
  102. package/dist/modules/ekm.js.map +1 -0
  103. package/dist/modules/ekv.d.ts +189 -0
  104. package/dist/modules/ekv.d.ts.map +1 -0
  105. package/dist/modules/ekv.js +212 -0
  106. package/dist/modules/ekv.js.map +1 -0
  107. package/dist/modules/ens.d.ts +122 -0
  108. package/dist/modules/ens.d.ts.map +1 -0
  109. package/dist/modules/ens.js +167 -0
  110. package/dist/modules/ens.js.map +1 -0
  111. package/dist/modules/eqs.d.ts +283 -0
  112. package/dist/modules/eqs.d.ts.map +1 -0
  113. package/dist/modules/eqs.js +355 -0
  114. package/dist/modules/eqs.js.map +1 -0
  115. package/dist/modules/esm.d.ts +358 -0
  116. package/dist/modules/esm.d.ts.map +1 -0
  117. package/dist/modules/esm.js +660 -0
  118. package/dist/modules/esm.js.map +1 -0
  119. package/dist/modules/ess.d.ts +96 -0
  120. package/dist/modules/ess.d.ts.map +1 -0
  121. package/dist/modules/ess.js +110 -0
  122. package/dist/modules/ess.js.map +1 -0
  123. package/dist/url.d.ts +31 -0
  124. package/dist/url.d.ts.map +1 -0
  125. package/dist/url.js +47 -0
  126. package/dist/url.js.map +1 -0
  127. package/package.json +47 -0
@@ -0,0 +1,96 @@
1
+ /**
2
+ * The connection to a euclid server.
3
+ *
4
+ * euclid speaks one request shape: `POST /` with a JSON body, the module named in
5
+ * `x-euclid-target` and the operation in `x-euclid-action`. Everything else - which module, which
6
+ * action, who is asking - travels in headers, which is why the signing schemes cover the headers
7
+ * they do. This client knows that shape and nothing about any particular module.
8
+ *
9
+ * Built on node's own `http`/`https` rather than a third-party client so that installing this SDK
10
+ * does not drag a dependency tree into an application that only wanted to call euclid.
11
+ */
12
+ /**
13
+ * Where euclid installs the certificate its gateway presents. Applied only when the file is there,
14
+ * so this is a no-op on a machine with no euclid deployment, and the same default euclid-cli uses.
15
+ */
16
+ export declare const DEFAULT_CA_CERT_PATH = "/etc/euclid/euclid_cert.crt";
17
+ /** How long to wait for a response, in milliseconds, unless a call overrides it. */
18
+ export declare const DEFAULT_TIMEOUT_MS = 10000;
19
+ /** One HTTP response, with the body already read. */
20
+ export declare class Response {
21
+ readonly status: number;
22
+ readonly reason: string;
23
+ readonly headers: Record<string, string>;
24
+ readonly content: Buffer;
25
+ constructor(status: number, reason: string, headers: Record<string, string>, content: Buffer);
26
+ /** Whether the server answered 2xx. */
27
+ get ok(): boolean;
28
+ /** The body decoded as UTF-8. */
29
+ get text(): string;
30
+ /** The body parsed as JSON. An empty body reads as an empty object. */
31
+ json(): unknown;
32
+ }
33
+ /** How a request's authentication headers are rebuilt when the first attempt is refused. */
34
+ export type HeaderFactory = (action: string, body: Buffer) => Record<string, string>;
35
+ export interface HttpClientOptions {
36
+ /**
37
+ * A PEM CA certificate to trust *alongside* the system trust store, for reaching a euclid server
38
+ * that presents its own certificate. Null uses only the system store. Mirrors euclid-cli's
39
+ * `--ca-cert`.
40
+ */
41
+ caCertPath?: string | null;
42
+ /** How long to wait for a response, in milliseconds, unless a call overrides it. */
43
+ timeoutMs?: number;
44
+ /**
45
+ * Whether to verify the server certificate at all. Turning it off is for a development server
46
+ * with a certificate nothing vouches for, and for nothing else.
47
+ */
48
+ verify?: boolean;
49
+ }
50
+ /**
51
+ * Sends euclid's action requests over a connection it keeps open.
52
+ *
53
+ * One keep-alive agent rather than a connection per call: a fresh connection per action would pay
54
+ * for a TLS handshake every time, and node's agent already serialises what has to be serialised.
55
+ *
56
+ * Two retries are built in, and both are deliberately narrow:
57
+ *
58
+ * - A connection closed while it sat idle - by the server's timeout, a proxy, a load balancer - is
59
+ * not visible until the next write, and surfaces as a failure with no response at all. That is
60
+ * retried once on a fresh connection. It is not quite the same as knowing the request was never
61
+ * processed, so this trades a possible repeat for the far commoner case of a socket that was
62
+ * already gone.
63
+ * - A 401 whose body says the credentials had expired is retried once with rebuilt headers, if
64
+ * {@link EuclidHttpClient.headerFactory} was given one and it produces different headers. A wrong
65
+ * password or a missing permission is answered once, as before; and a token nobody has refreshed
66
+ * comes back identical, so there is nothing to retry with.
67
+ */
68
+ export declare class EuclidHttpClient {
69
+ #private;
70
+ readonly caCertPath: string | null;
71
+ constructor(options?: HttpClientOptions);
72
+ /**
73
+ * Registers how to rebuild the authentication headers for an `(action, body)` pair.
74
+ *
75
+ * Without one, a request whose credentials expired between the header being built and the server
76
+ * reading it fails like any other error - which for a long-lived application is a business
77
+ * operation lost to a token that a second attempt would have carried correctly.
78
+ */
79
+ headerFactory(factory: HeaderFactory | null): this;
80
+ /**
81
+ * Sends one euclid action request.
82
+ *
83
+ * @param url the full URL to post to, normally the server's base URL plus `/`.
84
+ * @param body the JSON request body.
85
+ * @param target the module to route to, e.g. `"eam"`.
86
+ * @param action the operation, e.g. `"list-users"`.
87
+ * @param headers authentication and routing headers, as a module client builds them.
88
+ * @param timeoutMs overrides this client's timeout, for the actions a server answers slowly on
89
+ * purpose - a long poll is told how many seconds to hold the request open, and a caller
90
+ * unwilling to wait that long would abandon a request still being served.
91
+ */
92
+ post(url: string, body: Buffer | string, target: string, action: string, headers?: Record<string, string>, timeoutMs?: number): Promise<Response>;
93
+ /** Releases the connections this client was holding. */
94
+ close(): void;
95
+ }
96
+ //# sourceMappingURL=client.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.d.ts","sourceRoot":"","s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lD;;;;;;;;;;;OAWG;IACG,IAAI,CACR,GAAG,EAAE,MAAM,EACX,IAAI,EAAE,MAAM,GAAG,MAAM,EACrB,MAAM,EAAE,MAAM,EACd,MAAM,EAAE,MAAM,EACd,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,MAAM,CAAM,EACpC,SAAS,CAAC,EAAE,MAAM,GACjB,OAAO,CAAC,QAAQ,CAAC;IAWpB,wDAAwD;IACxD,KAAK,IAAI,IAAI;CA2Id"}
@@ -0,0 +1,258 @@
1
+ /**
2
+ * The connection to a euclid server.
3
+ *
4
+ * euclid speaks one request shape: `POST /` with a JSON body, the module named in
5
+ * `x-euclid-target` and the operation in `x-euclid-action`. Everything else - which module, which
6
+ * action, who is asking - travels in headers, which is why the signing schemes cover the headers
7
+ * they do. This client knows that shape and nothing about any particular module.
8
+ *
9
+ * Built on node's own `http`/`https` rather than a third-party client so that installing this SDK
10
+ * does not drag a dependency tree into an application that only wanted to call euclid.
11
+ */
12
+ import { readFile } from "node:fs/promises";
13
+ import * as http from "node:http";
14
+ import * as https from "node:https";
15
+ import { rootCertificates } from "node:tls";
16
+ /**
17
+ * Where euclid installs the certificate its gateway presents. Applied only when the file is there,
18
+ * so this is a no-op on a machine with no euclid deployment, and the same default euclid-cli uses.
19
+ */
20
+ export const DEFAULT_CA_CERT_PATH = "/etc/euclid/euclid_cert.crt";
21
+ /** How long to wait for a response, in milliseconds, unless a call overrides it. */
22
+ export const DEFAULT_TIMEOUT_MS = 10_000;
23
+ /** One HTTP response, with the body already read. */
24
+ export class Response {
25
+ status;
26
+ reason;
27
+ headers;
28
+ content;
29
+ constructor(status, reason, headers, content) {
30
+ this.status = status;
31
+ this.reason = reason;
32
+ this.headers = headers;
33
+ this.content = content;
34
+ }
35
+ /** Whether the server answered 2xx. */
36
+ get ok() {
37
+ return Math.floor(this.status / 100) === 2;
38
+ }
39
+ /** The body decoded as UTF-8. */
40
+ get text() {
41
+ return this.content.toString("utf8");
42
+ }
43
+ /** The body parsed as JSON. An empty body reads as an empty object. */
44
+ json() {
45
+ return this.content.toString("utf8").trim() ? JSON.parse(this.content.toString("utf8")) : {};
46
+ }
47
+ }
48
+ /**
49
+ * Sends euclid's action requests over a connection it keeps open.
50
+ *
51
+ * One keep-alive agent rather than a connection per call: a fresh connection per action would pay
52
+ * for a TLS handshake every time, and node's agent already serialises what has to be serialised.
53
+ *
54
+ * Two retries are built in, and both are deliberately narrow:
55
+ *
56
+ * - A connection closed while it sat idle - by the server's timeout, a proxy, a load balancer - is
57
+ * not visible until the next write, and surfaces as a failure with no response at all. That is
58
+ * retried once on a fresh connection. It is not quite the same as knowing the request was never
59
+ * processed, so this trades a possible repeat for the far commoner case of a socket that was
60
+ * already gone.
61
+ * - A 401 whose body says the credentials had expired is retried once with rebuilt headers, if
62
+ * {@link EuclidHttpClient.headerFactory} was given one and it produces different headers. A wrong
63
+ * password or a missing permission is answered once, as before; and a token nobody has refreshed
64
+ * comes back identical, so there is nothing to retry with.
65
+ */
66
+ export class EuclidHttpClient {
67
+ caCertPath;
68
+ #timeoutMs;
69
+ #verify;
70
+ #agents = new Map();
71
+ #headerFactory = null;
72
+ #ca = null;
73
+ #caLoaded = false;
74
+ constructor(options = {}) {
75
+ this.caCertPath = options.caCertPath ?? null;
76
+ this.#timeoutMs = options.timeoutMs ?? DEFAULT_TIMEOUT_MS;
77
+ this.#verify = options.verify ?? true;
78
+ }
79
+ /**
80
+ * Registers how to rebuild the authentication headers for an `(action, body)` pair.
81
+ *
82
+ * Without one, a request whose credentials expired between the header being built and the server
83
+ * reading it fails like any other error - which for a long-lived application is a business
84
+ * operation lost to a token that a second attempt would have carried correctly.
85
+ */
86
+ headerFactory(factory) {
87
+ this.#headerFactory = factory;
88
+ return this;
89
+ }
90
+ /**
91
+ * Sends one euclid action request.
92
+ *
93
+ * @param url the full URL to post to, normally the server's base URL plus `/`.
94
+ * @param body the JSON request body.
95
+ * @param target the module to route to, e.g. `"eam"`.
96
+ * @param action the operation, e.g. `"list-users"`.
97
+ * @param headers authentication and routing headers, as a module client builds them.
98
+ * @param timeoutMs overrides this client's timeout, for the actions a server answers slowly on
99
+ * purpose - a long poll is told how many seconds to hold the request open, and a caller
100
+ * unwilling to wait that long would abandon a request still being served.
101
+ */
102
+ async post(url, body, target, action, headers = {}, timeoutMs) {
103
+ const payload = typeof body === "string" ? Buffer.from(body, "utf8") : body;
104
+ const sent = { ...headers, "x-euclid-target": target, "x-euclid-action": action };
105
+ const response = await this.#send(url, payload, sent, timeoutMs);
106
+ const refreshed = this.#refreshedHeaders(response, action, payload, sent);
107
+ if (refreshed === null)
108
+ return response;
109
+ return this.#send(url, payload, refreshed, timeoutMs);
110
+ }
111
+ /** Releases the connections this client was holding. */
112
+ close() {
113
+ for (const agent of this.#agents.values())
114
+ agent.destroy();
115
+ this.#agents.clear();
116
+ }
117
+ // -- internals -----------------------------------------------------------------------------
118
+ /**
119
+ * The headers to retry with, or null if this response should not be retried.
120
+ *
121
+ * Kept narrow so it never turns one real rejection into two: only 401, only when the server said
122
+ * the credentials had expired, and only when the rebuilt headers actually differ.
123
+ */
124
+ #refreshedHeaders(response, action, body, headers) {
125
+ if (this.#headerFactory === null || response.status !== 401)
126
+ return null;
127
+ if (!response.text.toLowerCase().includes("expired"))
128
+ return null;
129
+ const refreshed = { ...headers, ...this.#headerFactory(action, body) };
130
+ return sameHeaders(refreshed, headers) ? null : refreshed;
131
+ }
132
+ async #send(url, body, headers, timeoutMs) {
133
+ try {
134
+ return await this.#exchange(url, body, headers, timeoutMs);
135
+ }
136
+ catch (error) {
137
+ // No response at all came back, which is what a connection closed while it was idle looks
138
+ // like from here. One more attempt, on a socket that is definitely new.
139
+ if (!isRetryable(error))
140
+ throw error;
141
+ this.#dropAgent(url);
142
+ return this.#exchange(url, body, headers, timeoutMs);
143
+ }
144
+ }
145
+ async #exchange(url, body, headers, timeoutMs) {
146
+ const target = new URL(url);
147
+ const secure = target.protocol === "https:";
148
+ const agent = await this.#agentFor(url, secure);
149
+ const effectiveTimeout = timeoutMs ?? this.#timeoutMs;
150
+ const options = {
151
+ method: "POST",
152
+ host: target.hostname,
153
+ port: target.port || (secure ? 443 : 80),
154
+ path: `${target.pathname}${target.search}`,
155
+ // Host is the client's to set: it is a signed header, and letting node compose it would put
156
+ // a different spelling on the wire than the one the signature covers.
157
+ headers: { ...headers, "content-length": String(body.length) },
158
+ agent,
159
+ timeout: effectiveTimeout,
160
+ };
161
+ if (secure && !this.#verify)
162
+ options.rejectUnauthorized = false;
163
+ return new Promise((resolve, reject) => {
164
+ const request = (secure ? https : http).request(options, (message) => {
165
+ const chunks = [];
166
+ message.on("data", (chunk) => chunks.push(chunk));
167
+ message.on("end", () => {
168
+ const responseHeaders = {};
169
+ for (const [name, value] of Object.entries(message.headers)) {
170
+ if (value !== undefined)
171
+ responseHeaders[name.toLowerCase()] = Array.isArray(value) ? value.join(", ") : value;
172
+ }
173
+ resolve(new Response(message.statusCode ?? 0, message.statusMessage ?? "", responseHeaders, Buffer.concat(chunks)));
174
+ });
175
+ message.on("error", reject);
176
+ });
177
+ request.on("timeout", () => {
178
+ // node does not fail a timed-out request by itself; it only tells us the socket went quiet.
179
+ request.destroy(new Error(`no response within ${effectiveTimeout}ms`));
180
+ });
181
+ request.on("error", reject);
182
+ request.end(body);
183
+ });
184
+ }
185
+ /**
186
+ * The keep-alive agent for one origin, built on first use.
187
+ *
188
+ * The CA file is read once, here, rather than per request: it is the same file every time, and a
189
+ * client that read it on every call would turn one action into two system calls plus a parse.
190
+ */
191
+ async #agentFor(url, secure) {
192
+ const key = originOf(url);
193
+ const existing = this.#agents.get(key);
194
+ if (existing)
195
+ return existing;
196
+ let agent;
197
+ if (secure) {
198
+ const ca = await this.#caCertificate();
199
+ // Added to the system trust store rather than replacing it, so a certificate is accepted if
200
+ // either root set vouches for it - the same union euclid-cli builds with
201
+ // set_default_verify_paths() followed by load_verify_file(). Node replaces the store when
202
+ // "ca" is given, so the union has to be spelled out.
203
+ agent = new https.Agent({ keepAlive: true, ...(ca ? { ca: [...rootCertificates, ca] } : {}) });
204
+ }
205
+ else {
206
+ agent = new http.Agent({ keepAlive: true });
207
+ }
208
+ this.#agents.set(key, agent);
209
+ return agent;
210
+ }
211
+ async #caCertificate() {
212
+ if (this.#caLoaded)
213
+ return this.#ca;
214
+ this.#caLoaded = true;
215
+ if (this.caCertPath) {
216
+ try {
217
+ this.#ca = await readFile(this.caCertPath, "utf8");
218
+ }
219
+ catch {
220
+ // Absent is the ordinary case on a machine with no euclid deployment - see
221
+ // DEFAULT_CA_CERT_PATH - and unreadable is the same thing as far as trust goes.
222
+ this.#ca = null;
223
+ }
224
+ }
225
+ return this.#ca;
226
+ }
227
+ #dropAgent(url) {
228
+ const key = originOf(url);
229
+ const agent = this.#agents.get(key);
230
+ if (agent) {
231
+ agent.destroy();
232
+ this.#agents.delete(key);
233
+ }
234
+ }
235
+ }
236
+ function originOf(url) {
237
+ const target = new URL(url);
238
+ return `${target.protocol}//${target.host}`;
239
+ }
240
+ function sameHeaders(left, right) {
241
+ const leftKeys = Object.keys(left);
242
+ if (leftKeys.length !== Object.keys(right).length)
243
+ return false;
244
+ return leftKeys.every((key) => left[key] === right[key]);
245
+ }
246
+ /**
247
+ * Failures that mean nothing came back. A reset, a broken pipe, or a socket that hung up where the
248
+ * status line should have been is a dead cached socket, and a fresh one usually answers. A refused
249
+ * connection is not in here: that one means the server is not listening, and a second attempt a
250
+ * microsecond later would tell the caller the same thing more slowly.
251
+ */
252
+ function isRetryable(error) {
253
+ const code = error?.code;
254
+ if (code === "ECONNRESET" || code === "EPIPE")
255
+ return true;
256
+ return error instanceof Error && error.message.includes("socket hang up");
257
+ }
258
+ //# sourceMappingURL=client.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"client.js","sourceRoot":"","sources":["../../src/http/client.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AAEH,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AAC5C,OAAO,KAAK,IAAI,MAAM,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,KAAK,GAAG,IAAI,CAAC,OAAO,CAAC,GAAG,CAAC,GAAG,CAAC,CAAC;QACpC,IAAI,KAAK,EAAE,CAAC;YACV,KAAK,CAAC,OAAO,EAAE,CAAC;YAChB,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,GAAG,CAAC,CAAC;QAC3B,CAAC;IACH,CAAC;CACF;AAED,SAAS,QAAQ,CAAC,GAAW;IAC3B,MAAM,MAAM,GAAG,IAAI,GAAG,CAAC,GAAG,CAAC,CAAC;IAC5B,OAAO,GAAG,MAAM,CAAC,QAAQ,KAAK,MAAM,CAAC,IAAI,EAAE,CAAC;AAC9C,CAAC;AAED,SAAS,WAAW,CAAC,IAA4B,EAAE,KAA6B;IAC9E,MAAM,QAAQ,GAAG,MAAM,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACnC,IAAI,QAAQ,CAAC,MAAM,KAAK,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,MAAM;QAAE,OAAO,KAAK,CAAC;IAChE,OAAO,QAAQ,CAAC,KAAK,CAAC,CAAC,GAAG,EAAE,EAAE,CAAC,IAAI,CAAC,GAAG,CAAC,KAAK,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC;AAC3D,CAAC;AAED;;;;;GAKG;AACH,SAAS,WAAW,CAAC,KAAc;IACjC,MAAM,IAAI,GAAI,KAAkC,EAAE,IAAI,CAAC;IACvD,IAAI,IAAI,KAAK,YAAY,IAAI,IAAI,KAAK,OAAO;QAAE,OAAO,IAAI,CAAC;IAC3D,OAAO,KAAK,YAAY,KAAK,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAC,CAAC;AAC5E,CAAC"}
@@ -0,0 +1,93 @@
1
+ /**
2
+ * euclid-ndk - the Node.js SDK for a euclid server.
3
+ *
4
+ * Start here:
5
+ *
6
+ * ```ts
7
+ * import { Euclid } from "euclid-ndk";
8
+ *
9
+ * const session = await Euclid.forServer("https://euclid.example.com").login("jens", "secret");
10
+ * const users = await session.listUsers({ prefix: "j", pageSize: 25 });
11
+ * for (const user of users.items) console.log(user.userId, user.email);
12
+ * session.close();
13
+ * ```
14
+ *
15
+ * Nine modules so far. EAM - euclid's access management module - is where a login comes from; ESM (storage),
16
+ * EQS (queues), ENS (notifications), EKM (keys), EKV (tables), EAP (applications), ESS (secrets) and EAG
17
+ * (the API gateway) are reached from the session it hands back:
18
+ *
19
+ * ```ts
20
+ * const bucket = await session.esm().createBucket("reports");
21
+ * const queue = await session.eqs().createQueue("orders");
22
+ * const key = await session.ekm().createKey({ description: "customer exports" });
23
+ * const password = await session.ess().getSecret("db-password");
24
+ * await session.eap().startApplication("order-service");
25
+ * await session.eag().createRoute("orders", "/api/orders", { applicationId: "order-service" });
26
+ * ```
27
+ *
28
+ * The remaining modules (EES, ETS) speak the same protocol through the same client and will follow;
29
+ * {@link EuclidSession.call} and
30
+ * {@link import("./modules/base.js").ModuleClient.call} reach any action this SDK does not name.
31
+ */
32
+ import { EuclidEam, type EuclidSession } from "./modules/eam.js";
33
+ export { RFC9421, SIGV4, SignableRequest, signingSchemeOf, type SigningScheme, rfc9421, sigv4, } from "./auth/index.js";
34
+ export { credentialsPath, isTokenValid, type CachedCredentials, } from "./credentials.js";
35
+ export { PRIORITY_HIGH, PRIORITY_LOW, PRIORITY_MIDDLE, QUEUE, TOPIC, VARIANT_BINARY, VARIANT_BOOL, VARIANT_DOUBLE, VARIANT_FLOAT, VARIANT_INT, VARIANT_LONG, VARIANT_STRING, toSubscribeResult, toSubscription, toVariant, toVariantMap, variantMapToJson, variantOf, variantToJson, type SubscribeResult, type Subscription, type Variant, type VariantInput, } from "./dto/com.js";
36
+ export type { AccessKey, Account, AccountGrant, CreateAccessKeyResult, LoginResult, Metadata, Namespace, Page, User, UserGroup, } from "./dto/eam.js";
37
+ export type { ListListenersResult, Listener, ListenerCertificate, Route, } from "./dto/eag.js";
38
+ export type { Application, Endpoint, LogLevelResult } from "./dto/eap.js";
39
+ export { CREATED_ATTRIBUTE, MODIFIED_ATTRIBUTE, type Item, type QueryResult, type ScanResult, type TableDescription, } from "./dto/ekv.js";
40
+ export type { Certificate, CreateKeyResult, DeleteCertificateResult, DeleteKeyResult, Key, KeyDescriptionResult, RevokeKeyResult, } from "./dto/ekm.js";
41
+ export type { CreateTopicResult, Topic, TopicMessage, TopicMessageAttribute, TopicMessageCount, TopicMetadata, } from "./dto/ens.js";
42
+ export type { DeleteSecretResult, Secret, SecretValue } from "./dto/ess.js";
43
+ export type { CreateQueueResult, Queue, QueueMessage, QueueMessageAttribute, QueueMessageCount, QueueMessageMetadata, QueueMetadata, QueueStatusResult, RedriveDlqResult, RedriveTarget, } from "./dto/eqs.js";
44
+ export type { Bucket, BucketEvent, CreateBucketResult, CreateDownloadResult, CreateUploadResult, DeleteObjectsResult, DisableEncryptionResult, EnableEncryptionResult, EsmObject, ObjectAttribute, PurgeBucketResult, RenameBucketResult, SetBucketInternalResult, StoredObject, TouchObjectResult, } from "./dto/esm.js";
45
+ export { EuclidAuthenticationError, EuclidError, EuclidServiceError } from "./errors.js";
46
+ export { DEFAULT_CA_CERT_PATH, EuclidHttpClient, Response } from "./http/client.js";
47
+ export { ModuleClient, type Bytes, type ModuleClientOptions, type PageOptions } from "./modules/base.js";
48
+ export { AUTH_AUTO, AUTH_BEARER, AUTH_SIGNATURE, EuclidEam, EuclidSession, type AuthMode, type ListOptions, } from "./modules/eam.js";
49
+ export { EuclidEag, PROTOCOL_HTTP, PROTOCOL_HTTPS, ROUTE_AUTH_BASIC, ROUTE_AUTH_EUCLID, ROUTE_AUTH_NONE, type CreateModuleRouteOptions, type CreateRouteOptions, type UpdateRouteChanges, } from "./modules/eag.js";
50
+ export { DEFAULT_MAX_INSTANCES, DEFAULT_MIN_INSTANCES, DEFAULT_READY_TIMEOUT_MS, EuclidEap, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_OFF, LOG_TRACE, LOG_WARNING, RUNTIME_BINARY, RUNTIME_JAVA, RUNTIME_NODEJS, RUNTIME_PYTHON, STATE_RUNNING, STATE_STOPPED, type CreateApplicationOptions, type UpdateApplicationChanges, } from "./modules/eap.js";
51
+ export { EuclidEkv, KEY_BINARY, KEY_NUMBER, KEY_STRING, SORT_BEGINS_WITH, SORT_BETWEEN, SORT_EQ, SORT_GE, SORT_GT, SORT_LE, SORT_LT, WHOLE_PARTITION, type CreateTableOptions, type QueryOptions, type ScanOptions, } from "./modules/ekv.js";
52
+ export { AES, DEFAULT_KEY_LENGTH, DEFAULT_PENDING_WINDOW_DAYS, EuclidEkm, type CreateCertificateOptions, type CreateKeyOptions, } from "./modules/ekm.js";
53
+ export { EuclidEns, type PublishMessageOptions, type PurgeAllTopicsOptions, } from "./modules/ens.js";
54
+ export { DEFAULT_MAX_RETRIES, DEFAULT_VISIBILITY, EuclidEqs, type CreateQueueOptions, type ListQueuesOptions, type PurgeAllQueuesOptions, type ReceiveMessagesOptions, type SendMessageOptions, } from "./modules/eqs.js";
55
+ export { EuclidEss, type CreateSecretOptions, type UpdateSecretChanges, } from "./modules/ess.js";
56
+ export { DEFAULT_CONCURRENCY, DEFAULT_PART_SIZE, EuclidEsm, OBJECT_CREATED, OBJECT_DELETED, OBJECT_UPDATED, parseBucketEvent, type AttributeOptions, type DownloadOptions, type ListBucketsOptions, type ListObjectsOptions, type SubscribeOptions, type TouchObjectOptions, type UploadOptions, } from "./modules/esm.js";
57
+ /** The version this package was published as. */
58
+ export declare const VERSION = "0.2.0";
59
+ /** Options {@link Euclid.login} passes through to the builder, for the case that needs no builder. */
60
+ export interface LoginOptions {
61
+ email?: string;
62
+ namespace?: string;
63
+ caCertPath?: string | null;
64
+ verify?: boolean;
65
+ timeoutMs?: number;
66
+ signingScheme?: import("./auth/index.js").SigningScheme;
67
+ auth?: import("./modules/eam.js").AuthMode;
68
+ useCache?: boolean;
69
+ loginPath?: string;
70
+ }
71
+ /**
72
+ * Entry point: names a server, and hands out the module clients for it.
73
+ *
74
+ * Exists so that a caller writes the server's URL once. Only EAM is reached from here, because only
75
+ * EAM is reached before logging in; every other module hangs off the session that login answers with -
76
+ * {@link EuclidSession.esm}, {@link EuclidSession.eqs}, {@link EuclidSession.ens},
77
+ * {@link EuclidSession.ekm}, {@link EuclidSession.ekv}, {@link EuclidSession.eap},
78
+ * {@link EuclidSession.ess}, {@link EuclidSession.eag} - as in euclid-jdk and euclid-pdk.
79
+ */
80
+ export declare class Euclid {
81
+ #private;
82
+ constructor(baseUrl: string);
83
+ /** Targets a euclid server, e.g. `https://euclid.example.com`. */
84
+ static forServer(baseUrl: string): Euclid;
85
+ get baseUrl(): string;
86
+ /** Starts a login against this server. */
87
+ access(): EuclidEam;
88
+ /** Alias for {@link access}, for callers who think in module names. */
89
+ eam(): EuclidEam;
90
+ /** Logs in, for the common case that needs no builder. */
91
+ login(username?: string, password?: string, options?: LoginOptions): Promise<EuclidSession>;
92
+ }
93
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,SAAS,EAAE,KAAK,aAAa,EAAE,MAAM,kBAAkB,CAAC;AAEjE,OAAO,EACL,OAAO,EACP,KAAK,EACL,eAAe,EACf,eAAe,EACf,KAAK,aAAa,EAClB,OAAO,EACP,KAAK,GACN,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,EACf,YAAY,EACZ,KAAK,iBAAiB,GACvB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,aAAa,EACb,YAAY,EACZ,eAAe,EACf,KAAK,EACL,KAAK,EACL,cAAc,EACd,YAAY,EACZ,cAAc,EACd,aAAa,EACb,WAAW,EACX,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,aAAa,EACb,KAAK,eAAe,EACpB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I,OAAO,IAAI,MAAM,CAEpB;IAED,0CAA0C;IAC1C,MAAM,IAAI,SAAS;IAInB,uEAAuE;IACvE,GAAG,IAAI,SAAS;IAIhB,0DAA0D;IACpD,KAAK,CAAC,QAAQ,CAAC,EAAE,MAAM,EAAE,QAAQ,CAAC,EAAE,MAAM,EAAE,OAAO,GAAE,YAAiB,GAAG,OAAO,CAAC,aAAa,CAAC;CAetG"}
package/dist/index.js ADDED
@@ -0,0 +1,110 @@
1
+ /**
2
+ * euclid-ndk - the Node.js SDK for a euclid server.
3
+ *
4
+ * Start here:
5
+ *
6
+ * ```ts
7
+ * import { Euclid } from "euclid-ndk";
8
+ *
9
+ * const session = await Euclid.forServer("https://euclid.example.com").login("jens", "secret");
10
+ * const users = await session.listUsers({ prefix: "j", pageSize: 25 });
11
+ * for (const user of users.items) console.log(user.userId, user.email);
12
+ * session.close();
13
+ * ```
14
+ *
15
+ * Nine modules so far. EAM - euclid's access management module - is where a login comes from; ESM (storage),
16
+ * EQS (queues), ENS (notifications), EKM (keys), EKV (tables), EAP (applications), ESS (secrets) and EAG
17
+ * (the API gateway) are reached from the session it hands back:
18
+ *
19
+ * ```ts
20
+ * const bucket = await session.esm().createBucket("reports");
21
+ * const queue = await session.eqs().createQueue("orders");
22
+ * const key = await session.ekm().createKey({ description: "customer exports" });
23
+ * const password = await session.ess().getSecret("db-password");
24
+ * await session.eap().startApplication("order-service");
25
+ * await session.eag().createRoute("orders", "/api/orders", { applicationId: "order-service" });
26
+ * ```
27
+ *
28
+ * The remaining modules (EES, ETS) speak the same protocol through the same client and will follow;
29
+ * {@link EuclidSession.call} and
30
+ * {@link import("./modules/base.js").ModuleClient.call} reach any action this SDK does not name.
31
+ */
32
+ import { EuclidEam } from "./modules/eam.js";
33
+ export { RFC9421, SIGV4, SignableRequest, signingSchemeOf, rfc9421, sigv4, } from "./auth/index.js";
34
+ export { credentialsPath, isTokenValid, } from "./credentials.js";
35
+ export { PRIORITY_HIGH, PRIORITY_LOW, PRIORITY_MIDDLE, QUEUE, TOPIC, VARIANT_BINARY, VARIANT_BOOL, VARIANT_DOUBLE, VARIANT_FLOAT, VARIANT_INT, VARIANT_LONG, VARIANT_STRING, toSubscribeResult, toSubscription, toVariant, toVariantMap, variantMapToJson, variantOf, variantToJson, } from "./dto/com.js";
36
+ export { CREATED_ATTRIBUTE, MODIFIED_ATTRIBUTE, } from "./dto/ekv.js";
37
+ export { EuclidAuthenticationError, EuclidError, EuclidServiceError } from "./errors.js";
38
+ export { DEFAULT_CA_CERT_PATH, EuclidHttpClient, Response } from "./http/client.js";
39
+ export { ModuleClient } from "./modules/base.js";
40
+ export { AUTH_AUTO, AUTH_BEARER, AUTH_SIGNATURE, EuclidEam, EuclidSession, } from "./modules/eam.js";
41
+ export { EuclidEag, PROTOCOL_HTTP, PROTOCOL_HTTPS, ROUTE_AUTH_BASIC, ROUTE_AUTH_EUCLID, ROUTE_AUTH_NONE, } from "./modules/eag.js";
42
+ export { DEFAULT_MAX_INSTANCES, DEFAULT_MIN_INSTANCES, DEFAULT_READY_TIMEOUT_MS, EuclidEap, LOG_DEBUG, LOG_ERROR, LOG_FATAL, LOG_INFO, LOG_OFF, LOG_TRACE, LOG_WARNING, RUNTIME_BINARY, RUNTIME_JAVA, RUNTIME_NODEJS, RUNTIME_PYTHON, STATE_RUNNING, STATE_STOPPED, } from "./modules/eap.js";
43
+ export { EuclidEkv, KEY_BINARY, KEY_NUMBER, KEY_STRING, SORT_BEGINS_WITH, SORT_BETWEEN, SORT_EQ, SORT_GE, SORT_GT, SORT_LE, SORT_LT, WHOLE_PARTITION, } from "./modules/ekv.js";
44
+ export { AES, DEFAULT_KEY_LENGTH, DEFAULT_PENDING_WINDOW_DAYS, EuclidEkm, } from "./modules/ekm.js";
45
+ export { EuclidEns, } from "./modules/ens.js";
46
+ export { DEFAULT_MAX_RETRIES, DEFAULT_VISIBILITY, EuclidEqs, } from "./modules/eqs.js";
47
+ export { EuclidEss, } from "./modules/ess.js";
48
+ export { DEFAULT_CONCURRENCY, DEFAULT_PART_SIZE, EuclidEsm, OBJECT_CREATED, OBJECT_DELETED, OBJECT_UPDATED, parseBucketEvent, } from "./modules/esm.js";
49
+ /** The version this package was published as. */
50
+ export const VERSION = "0.2.0";
51
+ /**
52
+ * Entry point: names a server, and hands out the module clients for it.
53
+ *
54
+ * Exists so that a caller writes the server's URL once. Only EAM is reached from here, because only
55
+ * EAM is reached before logging in; every other module hangs off the session that login answers with -
56
+ * {@link EuclidSession.esm}, {@link EuclidSession.eqs}, {@link EuclidSession.ens},
57
+ * {@link EuclidSession.ekm}, {@link EuclidSession.ekv}, {@link EuclidSession.eap},
58
+ * {@link EuclidSession.ess}, {@link EuclidSession.eag} - as in euclid-jdk and euclid-pdk.
59
+ */
60
+ export class Euclid {
61
+ #baseUrl;
62
+ constructor(baseUrl) {
63
+ if (!baseUrl)
64
+ throw new Error("baseUrl must not be empty");
65
+ this.#baseUrl = baseUrl;
66
+ }
67
+ /** Targets a euclid server, e.g. `https://euclid.example.com`. */
68
+ static forServer(baseUrl) {
69
+ return new Euclid(baseUrl);
70
+ }
71
+ get baseUrl() {
72
+ return this.#baseUrl;
73
+ }
74
+ /** Starts a login against this server. */
75
+ access() {
76
+ return EuclidEam.forServer(this.#baseUrl);
77
+ }
78
+ /** Alias for {@link access}, for callers who think in module names. */
79
+ eam() {
80
+ return this.access();
81
+ }
82
+ /** Logs in, for the common case that needs no builder. */
83
+ async login(username, password, options = {}) {
84
+ const builder = this.access();
85
+ if (username !== undefined)
86
+ builder.username(username);
87
+ if (password !== undefined)
88
+ builder.password(password);
89
+ if (options.email !== undefined)
90
+ builder.email(options.email);
91
+ if (options.namespace !== undefined)
92
+ builder.namespace(options.namespace);
93
+ if (options.caCertPath !== undefined)
94
+ builder.caCertPath(options.caCertPath);
95
+ if (options.verify !== undefined)
96
+ builder.verify(options.verify);
97
+ if (options.timeoutMs !== undefined)
98
+ builder.timeout(options.timeoutMs);
99
+ if (options.signingScheme !== undefined)
100
+ builder.signingScheme(options.signingScheme);
101
+ if (options.auth !== undefined)
102
+ builder.auth(options.auth);
103
+ if (options.useCache !== undefined)
104
+ builder.useCache(options.useCache);
105
+ if (options.loginPath !== undefined)
106
+ builder.loginPath(options.loginPath);
107
+ return builder.login();
108
+ }
109
+ }
110
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA8BG;AAEH,OAAO,EAAE,SAAS,EAAsB,MAAM,kBAAkB,CAAC;AAEjE,OAAO,EACL,OAAO,EACP,KAAK,EACL,eAAe,EACf,eAAe,EAEf,OAAO,EACP,KAAK,GACN,MAAM,iBAAiB,CAAC;AACzB,OAAO,EACL,eAAe,EACf,YAAY,GAEb,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,aAAa,EACb,YAAY,EACZ,eAAe,EACf,KAAK,EACL,KAAK,EACL,cAAc,EACd,YAAY,EACZ,cAAc,EACd,aAAa,EACb,WAAW,EACX,YAAY,EACZ,cAAc,EACd,iBAAiB,EACjB,cAAc,EACd,SAAS,EACT,YAAY,EACZ,gBAAgB,EAChB,SAAS,EACT,aAAa,GAKd,MAAM,cAAc,CAAC;AAoBtB,OAAO,EACL,iBAAiB,EACjB,kBAAkB,GAKnB,MAAM,cAAc,CAAC;AAgDtB,OAAO,EAAE,yBAAyB,EAAE,WAAW,EAAE,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACzF,OAAO,EAAE,oBAAoB,EAAE,gBAAgB,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAC;AACpF,OAAO,EAAE,YAAY,EAA0D,MAAM,mBAAmB,CAAC;AACzG,OAAO,EACL,SAAS,EACT,WAAW,EACX,cAAc,EACd,SAAS,EACT,aAAa,GAGd,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,SAAS,EACT,aAAa,EACb,cAAc,EACd,gBAAgB,E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