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,135 @@
1
+ /**
2
+ * The `~/.euclid/credentials` file, shared with euclid-cli, euclid-jdk and euclid-pdk.
3
+ *
4
+ * All four clients read and write the same file, so a login from any of them is picked up by the
5
+ * others. That makes the field names a wire format rather than an implementation detail: the
6
+ * namespace key is `namespace` (not `nameSpace`), `isAdmin` travels alongside the token, and an
7
+ * absent namespace is written as an empty string rather than null so the CLI's string reader can
8
+ * take it. `baseUrl` is the one field the CLI has no equivalent for - it is what lets a cached
9
+ * session be recognised as belonging to the server being talked to now.
10
+ */
11
+ import { chmod, mkdir, readFile, writeFile } from "node:fs/promises";
12
+ import { homedir } from "node:os";
13
+ import { dirname, join } from "node:path";
14
+ /**
15
+ * Where the credentials live.
16
+ *
17
+ * Resolved per call rather than captured at import, mirroring euclid-cli's
18
+ * `Credentials::FilePath()`: the home directory is read when the file is actually touched, so a
19
+ * process that changes it is not left talking to a stale path. `EUCLID_CREDENTIALS_FILE` overrides
20
+ * it, which is also how a euclid-managed application is handed its own credentials.
21
+ */
22
+ export function credentialsPath() {
23
+ return process.env["EUCLID_CREDENTIALS_FILE"] || join(homedir(), ".euclid", "credentials");
24
+ }
25
+ /** The cached credentials, or null when there is no readable, well-formed file. */
26
+ export async function load() {
27
+ let document;
28
+ try {
29
+ document = JSON.parse(await readFile(credentialsPath(), "utf8"));
30
+ }
31
+ catch {
32
+ // No file, no permission, or not JSON. All three mean the same thing to a caller: there is
33
+ // nothing cached to reuse, so log in.
34
+ return null;
35
+ }
36
+ if (document === null || typeof document !== "object" || Array.isArray(document))
37
+ return null;
38
+ return fromJson(document);
39
+ }
40
+ /** Writes the credentials, readable by their owner alone. */
41
+ export async function save(credentials) {
42
+ const path = credentialsPath();
43
+ await mkdir(dirname(path), { recursive: true });
44
+ await writeFile(path, JSON.stringify(toJson(credentials)), "utf8");
45
+ try {
46
+ await chmod(path, 0o600);
47
+ }
48
+ catch {
49
+ // Not every filesystem has POSIX permissions, and a credentials file that exists is better
50
+ // than a login that failed over its mode.
51
+ }
52
+ }
53
+ /**
54
+ * Patches the cached namespace in place, if what is cached belongs to `baseUrl`.
55
+ *
56
+ * Keeps the file in step when a session's namespace changes outside of a login. A no-op when
57
+ * nothing is cached for that server, in keeping with the best-effort nature of the cache: failing
58
+ * to record a namespace is not a reason to fail the call that changed it.
59
+ */
60
+ export async function updateNamespace(baseUrl, namespace) {
61
+ const cached = await load();
62
+ if (cached === null || cached.baseUrl !== baseUrl)
63
+ return;
64
+ cached.namespace = namespace || "";
65
+ await save(cached);
66
+ }
67
+ /**
68
+ * Whether a JWT is well-formed and its `exp` is still in the future.
69
+ *
70
+ * Checked locally to avoid a round trip that would only tell us what the token already says. The
71
+ * signature is not verified - the client does not hold the server's secret, and a token the client
72
+ * forged for itself would be rejected on arrival anyway.
73
+ */
74
+ export function isTokenValid(token) {
75
+ const parts = token.split(".");
76
+ if (parts.length < 2)
77
+ return false;
78
+ let payload;
79
+ try {
80
+ payload = JSON.parse(Buffer.from(parts[1], "base64url").toString("utf8"));
81
+ }
82
+ catch {
83
+ return false;
84
+ }
85
+ if (payload === null || typeof payload !== "object")
86
+ return false;
87
+ const expiry = payload.exp;
88
+ return typeof expiry === "number" && Date.now() / 1000 < expiry;
89
+ }
90
+ /** An empty set of credentials, which is what every field defaults from. */
91
+ export function emptyCredentials() {
92
+ return {
93
+ token: "",
94
+ userId: "",
95
+ accountId: "",
96
+ region: "",
97
+ accessKeyId: "",
98
+ secretAccessKey: "",
99
+ isAdmin: false,
100
+ baseUrl: "",
101
+ namespace: "",
102
+ raw: {},
103
+ };
104
+ }
105
+ function fromJson(document) {
106
+ return {
107
+ token: text(document["token"]),
108
+ userId: text(document["userId"]),
109
+ accountId: text(document["accountId"]),
110
+ region: text(document["region"]),
111
+ accessKeyId: text(document["accessKeyId"]),
112
+ secretAccessKey: text(document["secretAccessKey"]),
113
+ isAdmin: document["isAdmin"] === true,
114
+ baseUrl: text(document["baseUrl"]),
115
+ namespace: text(document["namespace"]),
116
+ raw: document,
117
+ };
118
+ }
119
+ function toJson(credentials) {
120
+ return {
121
+ token: credentials.token,
122
+ userId: credentials.userId,
123
+ accountId: credentials.accountId,
124
+ region: credentials.region,
125
+ accessKeyId: credentials.accessKeyId,
126
+ secretAccessKey: credentials.secretAccessKey,
127
+ isAdmin: credentials.isAdmin,
128
+ baseUrl: credentials.baseUrl,
129
+ namespace: credentials.namespace,
130
+ };
131
+ }
132
+ function text(value) {
133
+ return typeof value === "string" ? value : "";
134
+ }
135
+ //# sourceMappingURL=credentials.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"credentials.js","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,KAAK,EAAE,KAAK,EAAE,QAAQ,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AACrE,OAAO,EAAE,OAAO,EAAE,MAAM,SAAS,CAAC;AAClC,OAAO,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAiB1C;;;;;;;GAOG;AACH,MAAM,UAAU,eAAe;IAC7B,OAAO,OAAO,CAAC,GAAG,CAAC,yBAAyB,CAAC,IAAI,IAAI,CAAC,OAAO,EAAE,EAAE,SAAS,EAAE,aAAa,CAAC,CAAC;AAC7F,CAAC;AAED,mFAAmF;AACnF,MAAM,CAAC,KAAK,UAAU,IAAI;IACxB,IAAI,QAAiB,CAAC;IACtB,IAAI,CAAC;QACH,QAAQ,GAAG,IAAI,CAAC,KAAK,CAAC,MAAM,QAAQ,CAAC,eAAe,EAAE,EAAE,MAAM,CAAC,CAAC,CAAC;IACnE,CAAC;IAAC,MAAM,CAAC;QACP,2FAA2F;QAC3F,sCAAsC;QACtC,OAAO,IAAI,CAAC;IACd,CAAC;IACD,IAAI,QAAQ,KAAK,IAAI,IAAI,OAAO,QAAQ,KAAK,QAAQ,IAAI,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC;QAAE,OAAO,IAAI,CAAC;IAC9F,OAAO,QAAQ,CAAC,QAAmC,CAAC,CAAC;AACvD,CAAC;AAED,6DAA6D;AA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AAE,WAAW,CAAC,KAAK;QACxB,MAAM,EAAE,WAAW,CAAC,MAAM;QAC1B,SAAS,EAAE,WAAW,CAAC,SAAS;QAChC,MAAM,EAAE,WAAW,CAAC,MAAM;QAC1B,WAAW,EAAE,WAAW,CAAC,WAAW;QACpC,eAAe,EAAE,WAAW,CAAC,eAAe;QAC5C,OAAO,EAAE,WAAW,CAAC,OAAO;QAC5B,OAAO,EAAE,WAAW,CAAC,OAAO;QAC5B,SAAS,EAAE,WAAW,CAAC,SAAS;KACjC,CAAC;AACJ,CAAC;AAED,SAAS,IAAI,CAAC,KAAc;IAC1B,OAAO,OAAO,KAAK,KAAK,QAAQ,CAAC,CAAC,CAAC,KAAK,CAAC,CAAC,CAAC,EAAE,CAAC;AAChD,CAAC"}
@@ -0,0 +1,101 @@
1
+ /**
2
+ * The shapes more than one euclid module speaks.
3
+ *
4
+ * {@link Variant} is here rather than in the module that needed it first for the same reason the
5
+ * server keeps it in `Euclid::Dto::COM`: a queue message attribute, a topic message attribute and a
6
+ * storage object attribute are the same typed value on the wire.
7
+ *
8
+ * {@link Subscription} is here for a plainer reason - ESM and ENS answer with the same four fields,
9
+ * because both are saying the same thing: messages from this source go to that target from now on.
10
+ */
11
+ /**
12
+ * What a message is delivered at, and the only three values euclid accepts.
13
+ *
14
+ * Shared for the same reason {@link Variant} is: a queue message, a topic message and the `priority`
15
+ * system attribute of a stored object all mean the same thing by it.
16
+ */
17
+ export declare const PRIORITY_LOW = "LOW";
18
+ export declare const PRIORITY_MIDDLE = "MIDDLE";
19
+ export declare const PRIORITY_HIGH = "HIGH";
20
+ /**
21
+ * What a subscription delivers to: a queue...
22
+ *
23
+ * Shared by ESM and ENS because the server's subscription is: both name a source, a target and which
24
+ * of these two the target is.
25
+ */
26
+ export declare const QUEUE = "SQS";
27
+ /** ...or a topic. The two name different modules, and this is what says which. */
28
+ export declare const TOPIC = "SNS";
29
+ /** The type tags `Euclid::Dto::COM::Variant` round-trips a value through. */
30
+ export declare const VARIANT_INT = "int";
31
+ export declare const VARIANT_LONG = "long";
32
+ export declare const VARIANT_DOUBLE = "double";
33
+ export declare const VARIANT_FLOAT = "float";
34
+ export declare const VARIANT_BOOL = "bool";
35
+ export declare const VARIANT_STRING = "string";
36
+ export declare const VARIANT_BINARY = "binary";
37
+ /**
38
+ * A typed value: what it is, and what it holds.
39
+ *
40
+ * The tag is what makes the round trip lossless. JSON has one number type and euclid's server has
41
+ * several, so an attribute stored as a `long` would come back as a `double` - or an `int`, depending
42
+ * on the reader - if the type travelled only in the shape of the value.
43
+ *
44
+ * `binary` is base64 on the wire and a {@link Buffer} here; {@link toVariant} decodes it and
45
+ * {@link variantToJson} encodes it again, so a caller never sees the encoding.
46
+ */
47
+ export interface Variant {
48
+ type: string;
49
+ value: unknown;
50
+ }
51
+ /** What {@link variantOf} takes: a plain value to be tagged, or a variant that already is. */
52
+ export type VariantInput = Variant | string | number | boolean | Uint8Array;
53
+ /**
54
+ * A variant from a plain JavaScript value, tagged with the type euclid stores it under.
55
+ *
56
+ * A whole number becomes a `long` rather than an `int` because JavaScript has one number type and
57
+ * the 64-bit tag is the one that holds all of the integers it can represent exactly; anything else
58
+ * numeric becomes a `double` for the same reason.
59
+ *
60
+ * A {@link Variant} is returned as it is, so a caller may mix the two spellings in the same
61
+ * attribute map - and reach for the explicit one exactly when it wants a tag other than the obvious
62
+ * one.
63
+ *
64
+ * @throws {TypeError} for a value with no euclid variant type, which a variant spelled out by hand
65
+ * is the way past.
66
+ */
67
+ export declare function variantOf(value: VariantInput): Variant;
68
+ /** This variant as the server reads it, with a `binary` value encoded as base64. */
69
+ export declare function variantToJson(variant: Variant): Record<string, unknown>;
70
+ /** One variant as the server sent it. An unreadable one reads as an empty string value. */
71
+ export declare function toVariant(document: unknown): Variant;
72
+ /** An object of variants keyed by name, empty when absent. */
73
+ export declare function toVariantMap(document: unknown): Record<string, Variant>;
74
+ /** An attribute map as the server reads it, taking plain values or variants. */
75
+ export declare function variantMapToJson(attributes: Record<string, VariantInput> | undefined): Record<string, Record<string, unknown>>;
76
+ /**
77
+ * A standing instruction to deliver what arrives at a source onward to a target.
78
+ *
79
+ * One shape for both modules that have them: a bucket's events going to a queue (ESM) and a topic's
80
+ * messages going to a queue (ENS) differ in what is delivered, not in how the instruction is
81
+ * described. `type` is {@link QUEUE} or {@link TOPIC}, and `ern` is the subscription's own - which is
82
+ * what removing it takes.
83
+ */
84
+ export interface Subscription {
85
+ ern: string;
86
+ sourceErn: string;
87
+ type: string;
88
+ targetErn: string;
89
+ created: string;
90
+ modified: string;
91
+ }
92
+ /** A new subscription, as the `subscribe` actions answer with it: the same, minus the timestamps. */
93
+ export interface SubscribeResult {
94
+ ern: string;
95
+ sourceErn: string;
96
+ type: string;
97
+ targetErn: string;
98
+ }
99
+ export declare function toSubscription(document: unknown): Subscription;
100
+ export declare function toSubscribeResult(document: unknown): SubscribeResult;
101
+ //# sourceMappingURL=com.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"com.d.ts","sourceRoot":"","sources":["../../src/dto/com.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAIH;;;;;GAKG;AACH,eAAO,MAAM,YAAY,QAAQ,CAAC;AAClC,eAAO,MAAM,eAAe,WAAW,CAAC;AACxC,eAAO,MAAM,aAAa,SAAS,CAAC;AAEpC;;;;;GAKG;AACH,eAAO,MAAM,KAAK,QAAQ,CAAC;AAC3B,kFAAkF;AAClF,eAAO,MAAM,KAAK,QAAQ,CAAC;AAE3B,6EAA6E;AAC7E,eAAO,MAAM,WAAW,QAAQ,CAAC;AACjC,eAAO,MAAM,YAAY,SAAS,CAAC;AACnC,eAAO,MAAM,cAAc,WAAW,CAAC;AACvC,eAAO,MAAM,aAAa,UAAU,CAAC;AACrC,eAAO,MAAM,YAAY,SAAS,CAAC;AACnC,eAAO,MAAM,cAAc,WAAW,CAAC;AACvC,eAAO,MAAM,cAAc,WAAW,CAAC;AAEvC;;;;;;;;;GASG;AACH,MAAM,WAAW,OAAO;IACt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OAAO,GAAG,eAAe,CAOpE"}
@@ -0,0 +1,132 @@
1
+ /**
2
+ * The shapes more than one euclid module speaks.
3
+ *
4
+ * {@link Variant} is here rather than in the module that needed it first for the same reason the
5
+ * server keeps it in `Euclid::Dto::COM`: a queue message attribute, a topic message attribute and a
6
+ * storage object attribute are the same typed value on the wire.
7
+ *
8
+ * {@link Subscription} is here for a plainer reason - ESM and ENS answer with the same four fields,
9
+ * because both are saying the same thing: messages from this source go to that target from now on.
10
+ */
11
+ import { object, text } from "./json.js";
12
+ /**
13
+ * What a message is delivered at, and the only three values euclid accepts.
14
+ *
15
+ * Shared for the same reason {@link Variant} is: a queue message, a topic message and the `priority`
16
+ * system attribute of a stored object all mean the same thing by it.
17
+ */
18
+ export const PRIORITY_LOW = "LOW";
19
+ export const PRIORITY_MIDDLE = "MIDDLE";
20
+ export const PRIORITY_HIGH = "HIGH";
21
+ /**
22
+ * What a subscription delivers to: a queue...
23
+ *
24
+ * Shared by ESM and ENS because the server's subscription is: both name a source, a target and which
25
+ * of these two the target is.
26
+ */
27
+ export const QUEUE = "SQS";
28
+ /** ...or a topic. The two name different modules, and this is what says which. */
29
+ export const TOPIC = "SNS";
30
+ /** The type tags `Euclid::Dto::COM::Variant` round-trips a value through. */
31
+ export const VARIANT_INT = "int";
32
+ export const VARIANT_LONG = "long";
33
+ export const VARIANT_DOUBLE = "double";
34
+ export const VARIANT_FLOAT = "float";
35
+ export const VARIANT_BOOL = "bool";
36
+ export const VARIANT_STRING = "string";
37
+ export const VARIANT_BINARY = "binary";
38
+ /**
39
+ * A variant from a plain JavaScript value, tagged with the type euclid stores it under.
40
+ *
41
+ * A whole number becomes a `long` rather than an `int` because JavaScript has one number type and
42
+ * the 64-bit tag is the one that holds all of the integers it can represent exactly; anything else
43
+ * numeric becomes a `double` for the same reason.
44
+ *
45
+ * A {@link Variant} is returned as it is, so a caller may mix the two spellings in the same
46
+ * attribute map - and reach for the explicit one exactly when it wants a tag other than the obvious
47
+ * one.
48
+ *
49
+ * @throws {TypeError} for a value with no euclid variant type, which a variant spelled out by hand
50
+ * is the way past.
51
+ */
52
+ export function variantOf(value) {
53
+ if (isVariant(value))
54
+ return value;
55
+ if (typeof value === "boolean")
56
+ return { type: VARIANT_BOOL, value };
57
+ if (typeof value === "number") {
58
+ return { type: Number.isInteger(value) ? VARIANT_LONG : VARIANT_DOUBLE, value };
59
+ }
60
+ if (typeof value === "string")
61
+ return { type: VARIANT_STRING, value };
62
+ if (value instanceof Uint8Array)
63
+ return { type: VARIANT_BINARY, value: Buffer.from(value) };
64
+ throw new TypeError(`a ${typeof value} has no euclid variant type - pass a Variant with the tag it should carry`);
65
+ }
66
+ /** This variant as the server reads it, with a `binary` value encoded as base64. */
67
+ export function variantToJson(variant) {
68
+ if (variant.type === VARIANT_BINARY && variant.value instanceof Uint8Array) {
69
+ return { type: variant.type, value: Buffer.from(variant.value).toString("base64") };
70
+ }
71
+ return { type: variant.type, value: variant.value };
72
+ }
73
+ /** One variant as the server sent it. An unreadable one reads as an empty string value. */
74
+ export function toVariant(document) {
75
+ if (document === null || typeof document !== "object" || Array.isArray(document)) {
76
+ return { type: VARIANT_STRING, value: "" };
77
+ }
78
+ const type = text(document, "type");
79
+ const value = document["value"];
80
+ if (type === VARIANT_BINARY && typeof value === "string") {
81
+ // Handed back as the text it arrived as rather than throwing: a caller that can make sense of it
82
+ // is better served than one that gets an exception instead of the object the attribute hung off.
83
+ return { type, value: isBase64(value) ? Buffer.from(value, "base64") : value };
84
+ }
85
+ return { type, value };
86
+ }
87
+ /** An object of variants keyed by name, empty when absent. */
88
+ export function toVariantMap(document) {
89
+ return Object.fromEntries(Object.entries(object(document)).map(([name, value]) => [name, toVariant(value)]));
90
+ }
91
+ /** An attribute map as the server reads it, taking plain values or variants. */
92
+ export function variantMapToJson(attributes) {
93
+ if (attributes === undefined)
94
+ return {};
95
+ return Object.fromEntries(Object.entries(attributes).map(([name, value]) => [name, variantToJson(variantOf(value))]));
96
+ }
97
+ export function toSubscription(document) {
98
+ return {
99
+ ern: text(document, "ern"),
100
+ sourceErn: text(document, "sourceErn"),
101
+ type: text(document, "type"),
102
+ targetErn: text(document, "targetErn"),
103
+ created: text(document, "created"),
104
+ modified: text(document, "modified"),
105
+ };
106
+ }
107
+ export function toSubscribeResult(document) {
108
+ return {
109
+ ern: text(document, "ern"),
110
+ sourceErn: text(document, "sourceErn"),
111
+ type: text(document, "type"),
112
+ targetErn: text(document, "targetErn"),
113
+ };
114
+ }
115
+ /** Whether this is already a variant rather than a value to be tagged as one. */
116
+ function isVariant(value) {
117
+ return (value !== null &&
118
+ typeof value === "object" &&
119
+ !(value instanceof Uint8Array) &&
120
+ typeof value.type === "string" &&
121
+ "value" in value);
122
+ }
123
+ /**
124
+ * Whether a string is base64 at all.
125
+ *
126
+ * Checked rather than trusted because node's decoder silently drops what it cannot read, which would
127
+ * turn a `binary` attribute that arrived mangled into a shorter buffer that looks fine.
128
+ */
129
+ function isBase64(value) {
130
+ return value.length % 4 === 0 && /^[A-Za-z0-9+/]*={0,2}$/.test(value);
131
+ }
132
+ //# sourceMappingURL=com.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"com.js","sourceRoot":"","sources":["../../src/dto/com.ts"],"names":[],"mappings":"AAAA;;;;;;;;;GASG;AAEH,OAAO,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEzC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAC;AAClC,MAAM,CAAC,MAAM,eAAe,GAAG,QAAQ,CAAC;AACxC,MAAM,CAAC,MAAM,aAAa,GAAG,MAAM,CAAC;AAEpC;;;;;GAKG;AACH,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,CAAC;AAC3B,kFAAkF;AAClF,MAAM,CAAC,MAAM,KAAK,GAAG,KAAK,CAAC;AAE3B,6EAA6E;AAC7E,MAAM,CAAC,MAAM,WAAW,GAAG,KAAK,CAAC;AACjC,MAAM,CAAC,MAAM,YAAY,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ACtD,OAAO,IAAI,KAAK,CACjB,CAAC;AACJ,CAAC;AAED;;;;;GAKG;AACH,SAAS,QAAQ,CAAC,KAAa;IAC7B,OAAO,KAAK,CAAC,MAAM,GAAG,CAAC,KAAK,CAAC,IAAI,wBAAwB,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACxE,CAAC"}
@@ -0,0 +1,104 @@
1
+ /**
2
+ * The shapes EAG sends back.
3
+ *
4
+ * Parsed the same defensive way as every other module's. One thing is not just parsed but gathered: a
5
+ * listener's certificate arrives flat, as a dozen `certificate*` fields alongside the listener's own, and
6
+ * {@link toListener} collects them into a {@link ListenerCertificate} - or into null, when the server said
7
+ * it found none.
8
+ */
9
+ import { type Page } from "./eam.js";
10
+ /**
11
+ * One published path: what the gateway answers for, and where it sends it.
12
+ *
13
+ * A route goes to an application euclid runs or to a euclid module, never to both and never to neither, so
14
+ * a non-empty `moduleTarget` is exactly what says this is a module route. An empty `methods` means every
15
+ * method.
16
+ */
17
+ export interface Route {
18
+ routeId: string;
19
+ ern: string;
20
+ accountId: string;
21
+ region: string;
22
+ namespace: string;
23
+ path: string;
24
+ applicationId: string;
25
+ moduleTarget: string;
26
+ moduleAction: string;
27
+ methods: string[];
28
+ /**
29
+ * `NONE`, `EUCLID` or `BASIC` - what a caller has to present before anything is forwarded. See
30
+ * {@link import("../modules/eag.js")}.
31
+ */
32
+ authentication: string;
33
+ /**
34
+ * Whether the gateway is serving this path at all - see
35
+ * {@link import("../modules/eag.js").EuclidEag.setRouteActive}.
36
+ */
37
+ active: boolean;
38
+ created: string;
39
+ modified: string;
40
+ }
41
+ /**
42
+ * The certificate an HTTPS listener is actually serving.
43
+ *
44
+ * `generated` is whether euclid minted it itself because the listener needed something to start with.
45
+ * Callers reject a self-signed certificate until they are given it, so which of the two this is decides
46
+ * whether the port works for anybody who has not been told about it.
47
+ */
48
+ export interface ListenerCertificate {
49
+ ern: string;
50
+ subject: string;
51
+ issuer: string;
52
+ serialNumber: string;
53
+ fingerprint: string;
54
+ subjectAltNames: string[];
55
+ generated: boolean;
56
+ notBefore: string;
57
+ notAfter: string;
58
+ /** Whether `notAfter` is already in the past, as the server judged it against its own clock. */
59
+ expired: boolean;
60
+ }
61
+ /**
62
+ * One port the gateway was configured to answer on, and what it speaks.
63
+ *
64
+ * `certificateName` is the certificate this listener serves, which is the conventional one for its
65
+ * namespace when the configuration named none; `certificateConfigured` is what the configuration actually
66
+ * wrote, so "this listener names its certificate" and "this listener takes the conventional one" can be
67
+ * told apart - the second is a non-empty `certificateConfigured`.
68
+ */
69
+ export interface Listener {
70
+ namespace: string;
71
+ port: number;
72
+ /** `http` or `https`. */
73
+ protocol: string;
74
+ /**
75
+ * Whether the gateway's ports are bound at all - the same answer for every listener, since it is a
76
+ * property of the proxy rather than of one port.
77
+ */
78
+ serving: boolean;
79
+ certificateName: string;
80
+ certificateConfigured: string;
81
+ /** Null for a plain HTTP listener, and for an HTTPS one whose certificate the server did not find. */
82
+ certificate: ListenerCertificate | null;
83
+ }
84
+ /**
85
+ * What the gateway was configured to serve, and whether it is serving it.
86
+ *
87
+ * A listener whose port was taken, or whose certificate could not be loaded, is still in `items` - it is
88
+ * the one somebody is looking for - and `serving` is what says whether anything is actually bound.
89
+ */
90
+ export interface ListListenersResult extends Page<Listener> {
91
+ serving: boolean;
92
+ }
93
+ export declare function toRoute(document: unknown): Route;
94
+ /**
95
+ * The certificate a listener entry describes, or null when it describes none.
96
+ *
97
+ * A plain HTTP listener has no certificate to be missing, and an HTTPS one whose certificate is absent is
98
+ * what a port that never came up looks like - neither is a certificate this can describe, and the server
99
+ * says which by `certificateFound`.
100
+ */
101
+ export declare function toListenerCertificate(document: unknown): ListenerCertificate | null;
102
+ export declare function toListener(document: unknown): Listener;
103
+ export declare function toListListenersResult(document: unknown): ListListenersResult;
104
+ //# sourceMappingURL=eag.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eag.d.ts","sourceRoot":"","sources":["../../src/dto/eag.ts"],"names":[],"mappings":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mBAAmB,GAAG,IAAI,CAAC;CACzC;AAED;;;;;GAKG;AACH,MAAM,WAAW,mBAAoB,SAAQ,IAAI,CAAC,QAAQ,CAAC;IACzD,OAAO,EAAE,OAAO,CAAC;CAClB;AAID,wBAAgB,OAAO,CAAC,QAAQ,EAAE,OAAO,GAAG,KAAK,CAkBhD;AAED;;;;;;GAMG;AACH,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,OAAO,GAAG,mBAAmB,GAAG,IAAI,CAcnF;AAED,wBAAgB,UAAU,CAAC,QAAQ,EAAE,OAAO,GAAG,QAAQ,CAUtD;AAED,wBAAgB,qBAAqB,CAAC,QAAQ,EAAE,OAAO,GAAG,mBAAmB,CAI5E"}
@@ -0,0 +1,70 @@
1
+ /**
2
+ * The shapes EAG sends back.
3
+ *
4
+ * Parsed the same defensive way as every other module's. One thing is not just parsed but gathered: a
5
+ * listener's certificate arrives flat, as a dozen `certificate*` fields alongside the listener's own, and
6
+ * {@link toListener} collects them into a {@link ListenerCertificate} - or into null, when the server said
7
+ * it found none.
8
+ */
9
+ import {} from "./eam.js";
10
+ import { documents, flag, number, strings, text } from "./json.js";
11
+ // -- parsers ---------------------------------------------------------------------------------------
12
+ export function toRoute(document) {
13
+ return {
14
+ routeId: text(document, "routeId"),
15
+ ern: text(document, "ern"),
16
+ accountId: text(document, "accountId"),
17
+ region: text(document, "region"),
18
+ namespace: text(document, "namespace"),
19
+ path: text(document, "path"),
20
+ applicationId: text(document, "applicationId"),
21
+ moduleTarget: text(document, "moduleTarget"),
22
+ moduleAction: text(document, "moduleAction"),
23
+ methods: strings(document, "methods"),
24
+ authentication: text(document, "authentication"),
25
+ // Absent means serving, which is the server's default for a stored route.
26
+ active: flag(document, "active", true),
27
+ created: text(document, "created"),
28
+ modified: text(document, "modified"),
29
+ };
30
+ }
31
+ /**
32
+ * The certificate a listener entry describes, or null when it describes none.
33
+ *
34
+ * A plain HTTP listener has no certificate to be missing, and an HTTPS one whose certificate is absent is
35
+ * what a port that never came up looks like - neither is a certificate this can describe, and the server
36
+ * says which by `certificateFound`.
37
+ */
38
+ export function toListenerCertificate(document) {
39
+ if (!flag(document, "certificateFound"))
40
+ return null;
41
+ return {
42
+ ern: text(document, "certificateErn"),
43
+ subject: text(document, "certificateSubject"),
44
+ issuer: text(document, "certificateIssuer"),
45
+ serialNumber: text(document, "certificateSerialNumber"),
46
+ fingerprint: text(document, "certificateFingerprint"),
47
+ subjectAltNames: strings(document, "certificateSubjectAltNames"),
48
+ generated: flag(document, "certificateGenerated"),
49
+ notBefore: text(document, "certificateNotBefore"),
50
+ notAfter: text(document, "certificateNotAfter"),
51
+ expired: flag(document, "certificateExpired"),
52
+ };
53
+ }
54
+ export function toListener(document) {
55
+ return {
56
+ namespace: text(document, "namespace"),
57
+ port: number(document, "port"),
58
+ protocol: text(document, "protocol"),
59
+ serving: flag(document, "serving"),
60
+ certificateName: text(document, "certificate"),
61
+ certificateConfigured: text(document, "certificateConfigured"),
62
+ certificate: toListenerCertificate(document),
63
+ };
64
+ }
65
+ export function toListListenersResult(document) {
66
+ const items = documents(document, "listeners").map(toListener);
67
+ // The server sends a total; falling back to what arrived keeps a sparse answer self-consistent.
68
+ return { total: number(document, "total") || items.length, items, serving: flag(document, "serving") };
69
+ }
70
+ //# sourceMappingURL=eag.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eag.js","sourceRoot":"","sources":["../../src/dto/eag.ts"],"names":[],"mappings":"AAAA;;;;;;;GAOG;AAEH,OAAO,EAAa,MAAM,UAAU,CAAC;AACrC,OAAO,EAAE,SAAS,EAAE,IAAI,EAAE,MAAM,EAAE,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAyFnE,qGAAqG;AAErG,MAAM,UAAU,OAAO,CAAC,QAAiB;IACvC,OAAO;QACL,OAAO,EAAE,IAAI,CAAC,QAAQ,EAAE,SAAS,CAAC;QAClC,GAAG,EAAE,IAAI,CAAC,QAAQ,EAAE,KAAK,CAAC;QAC1B,SAAS,E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