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,204 @@
1
+ /**
2
+ * EAP - euclid's application platform: what euclid runs, from what, and as whom.
3
+ *
4
+ * One object, {@link EuclidEap}, built from a session that has already logged in:
5
+ *
6
+ * ```ts
7
+ * const eap = session.eap();
8
+ *
9
+ * await eap.createApplication("order-service", RUNTIME_JAVA, "artifacts", "order-service-1.4.0.jar", {
10
+ * queues: ["orders"],
11
+ * });
12
+ * await eap.startApplication("order-service");
13
+ * ```
14
+ *
15
+ * An application is deployed from an artifact already in a bucket - ESM puts it there, and EAP names it.
16
+ * The deployment says which buckets and queues it may reach, and euclid grants those to the identity it
17
+ * runs as: a technical principal it creates for the application unless one is named, with no password, no
18
+ * login and one access key. Nothing an application leaks is then a person's credential.
19
+ *
20
+ * Two names for the same things, and the asymmetry is the server's: a deployment names a `bucket` and an
21
+ * `artifact`, and the application that comes back describes a `bucketErn` and an `artifactKey`. Likewise
22
+ * the `buckets` and `queues` it is granted come back resolved into `resources`.
23
+ *
24
+ * Every action here is administrator-only, server-side. {@link EuclidSession.isAdmin} says whether the
25
+ * logged-in user is one, though the server enforces it regardless.
26
+ */
27
+ import { type Application, type LogLevelResult } from "../dto/eap.js";
28
+ import { ModuleClient } from "./base.js";
29
+ import type { EuclidSession } from "./eam.js";
30
+ export declare const TARGET = "eap";
31
+ /**
32
+ * What an artifact is handed to. Matched exactly, in upper case, and anything else is refused with
33
+ * HTTP 400 - a runtime is a category rather than a version, so a JDK 17 and a JDK 25 application are both
34
+ * {@link RUNTIME_JAVA} and it is the command or the PATH that decides which one runs.
35
+ */
36
+ export declare const RUNTIME_JAVA = "JAVA";
37
+ export declare const RUNTIME_PYTHON = "PYTHON";
38
+ export declare const RUNTIME_NODEJS = "NODEJS";
39
+ /** Anything already executable, which is where C++ and Rust applications land. */
40
+ export declare const RUNTIME_BINARY = "BINARY";
41
+ /**
42
+ * The levels {@link EuclidEap.setLogLevel} accepts. An unrecognised one is refused rather than defaulted:
43
+ * "warnign" quietly meaning "info" is an application logging more than somebody asked for, and quietly
44
+ * meaning "off" is silence nobody asked for at all.
45
+ */
46
+ export declare const LOG_TRACE = "trace";
47
+ export declare const LOG_DEBUG = "debug";
48
+ export declare const LOG_INFO = "info";
49
+ export declare const LOG_WARNING = "warning";
50
+ export declare const LOG_ERROR = "error";
51
+ export declare const LOG_FATAL = "fatal";
52
+ export declare const LOG_OFF = "off";
53
+ /** What an application's `desiredState` and `state` read as. */
54
+ export declare const STATE_RUNNING = "RUNNING";
55
+ export declare const STATE_STOPPED = "STOPPED";
56
+ /** What a pool is sized at unless the deployment says otherwise. */
57
+ export declare const DEFAULT_MIN_INSTANCES = 1;
58
+ export declare const DEFAULT_MAX_INSTANCES = 1;
59
+ /** How long an instance has to become ready before the manager gives up on it, in milliseconds. */
60
+ export declare const DEFAULT_READY_TIMEOUT_MS = 30000;
61
+ /** Everything a deployment says beyond what it runs and where the artifact is. */
62
+ export interface CreateApplicationOptions {
63
+ /**
64
+ * What to record as the deployed version. Left empty, the server reads it out of the artifact's name,
65
+ * and refuses the deployment if it cannot.
66
+ */
67
+ version?: string;
68
+ /**
69
+ * What to run, when the runtime's own interpreter is not it. Empty means the runtime decides, resolved
70
+ * through PATH.
71
+ */
72
+ command?: string;
73
+ /** What follows the command. */
74
+ arguments?: readonly string[];
75
+ /** The environment the process is given. */
76
+ environment?: Record<string, string>;
77
+ /**
78
+ * The buckets this application may reach, by name; euclid resolves them and grants them to the identity
79
+ * it runs as.
80
+ */
81
+ buckets?: readonly string[];
82
+ /** Likewise for queues. */
83
+ queues?: readonly string[];
84
+ /**
85
+ * An existing user to run as. Left empty, euclid creates a technical principal for the application -
86
+ * which is the better answer, and why this is not required.
87
+ */
88
+ user?: string;
89
+ /** The smallest the pool goes; at least 1. */
90
+ minInstances?: number;
91
+ /** The largest it goes; never below `minInstances`. */
92
+ maxInstances?: number;
93
+ /** How long an instance has to become ready; at least 1000. */
94
+ readyTimeoutMs?: number;
95
+ }
96
+ /**
97
+ * What an update changes - and only what it names.
98
+ *
99
+ * The distinction the server draws is between a field being sent and not being sent, rather than between
100
+ * its values: leaving `command` out leaves the stored command alone, while passing `""` clears it and
101
+ * hands the artifact back to the runtime's own interpreter.
102
+ *
103
+ * `buckets` and `queues` are re-resolved together whenever either is named, so naming one and not the
104
+ * other revokes what the other used to grant. Pass both, or neither.
105
+ */
106
+ export interface UpdateApplicationChanges {
107
+ runtime?: string;
108
+ artifact?: string;
109
+ version?: string;
110
+ command?: string;
111
+ arguments?: readonly string[];
112
+ environment?: Record<string, string>;
113
+ buckets?: readonly string[];
114
+ queues?: readonly string[];
115
+ minInstances?: number;
116
+ maxInstances?: number;
117
+ readyTimeoutMs?: number;
118
+ namespace?: string;
119
+ }
120
+ /**
121
+ * EAP's operations, on the credentials of the session that created it.
122
+ *
123
+ * Built by {@link EuclidSession.eap} rather than directly, so that it shares that session's identity,
124
+ * namespace and connection settings - and follows them as they change.
125
+ */
126
+ export declare class EuclidEap extends ModuleClient {
127
+ #private;
128
+ constructor(session: EuclidSession);
129
+ /**
130
+ * Deploys an application, stopped, and answers with it as it was stored.
131
+ *
132
+ * Nothing runs yet: a new application's desired state is `STOPPED`, so {@link startApplication} is what
133
+ * puts it in service. Refused with HTTP 409 if the ID is taken, and with 404 if the bucket, the
134
+ * artifact, a named resource or a named user is not there - a deployment pointing at nothing would
135
+ * otherwise become an application that fails to start for a reason nobody can see.
136
+ *
137
+ * @param applicationId aoolication ID
138
+ * @param runtime {@link RUNTIME_JAVA}, {@link RUNTIME_PYTHON}, {@link RUNTIME_NODEJS} or
139
+ * {@link RUNTIME_BINARY}.
140
+ * @param bucket the name of the bucket holding the artifact - a name, not an ERN.
141
+ * @param artifact the artifact's object key within that bucket.
142
+ * @param options call options
143
+ */
144
+ createApplication(applicationId: string, runtime: string, bucket: string, artifact: string, options?: CreateApplicationOptions): Promise<Application>;
145
+ /**
146
+ * Changes a deployed application. Only what `changes` names changes - see
147
+ * {@link UpdateApplicationChanges}, which is where the rules about that live.
148
+ *
149
+ * Changing the artifact is a change of what will run next; {@link redeployApplication} is what a new
150
+ * build of the same application usually wants.
151
+ */
152
+ updateApplication(applicationId: string, changes?: UpdateApplicationChanges): Promise<Application>;
153
+ /**
154
+ * Points an application at a new build of itself.
155
+ *
156
+ * The artifact defaults to the one already deployed - which is what a rebuilt artifact stored under the
157
+ * same key wants - and the version to whatever the artifact's name says. A redeploy that would change
158
+ * neither the version nor the checksum is refused with HTTP 409: it would restart the instances for
159
+ * nothing, and usually means the new artifact never reached the bucket.
160
+ */
161
+ redeployApplication(applicationId: string, artifact?: string, version?: string): Promise<Application>;
162
+ /** Removes an application. Stop it first - this does not. */
163
+ deleteApplication(applicationId: string): Promise<void>;
164
+ /**
165
+ * Asks for an application to run, and answers with it as it stands.
166
+ *
167
+ * Asking is all this does: the desired state changes here and the manager acts on it, so the application
168
+ * in the answer is usually still `STOPPED` - it says what was asked for, not what has happened yet.
169
+ */
170
+ startApplication(applicationId: string): Promise<Application>;
171
+ /** Asks for an application to stop, and answers with it as it stands. */
172
+ stopApplication(applicationId: string): Promise<Application>;
173
+ /**
174
+ * The applications whose ID starts with a prefix; an empty prefix lists them all.
175
+ *
176
+ * A list rather than a page: EAP answers with every match at once, since an installation has tens of
177
+ * applications rather than thousands.
178
+ */
179
+ listApplications(prefix?: string): Promise<Application[]>;
180
+ /** One application, by its ID, with the instances that are answering for it. */
181
+ getApplication(applicationId: string): Promise<Application>;
182
+ /**
183
+ * Sets what one application logs at, without restarting or redeploying it.
184
+ *
185
+ * @param applicationId application ID
186
+ * @param level {@link LOG_TRACE}, {@link LOG_DEBUG}, {@link LOG_INFO}, {@link LOG_WARNING},
187
+ * {@link LOG_ERROR}, {@link LOG_FATAL} or {@link LOG_OFF}. An empty one takes the setting back - see
188
+ * {@link resetLogLevel}, which says that in a word.
189
+ */
190
+ setLogLevel(applicationId: string, level: string): Promise<LogLevelResult>;
191
+ /**
192
+ * Puts an application back under the installation's own logging configuration.
193
+ *
194
+ * Which is not the same as setting it to whatever that configuration says: this removes the override, so
195
+ * the application follows the configuration as it changes from here on.
196
+ */
197
+ resetLogLevel(applicationId: string): Promise<LogLevelResult>;
198
+ /**
199
+ * EAP's own metrics, as the server collects them. Answered unparsed - the shape belongs to the
200
+ * monitoring module rather than to EAP.
201
+ */
202
+ metrics(): Promise<Record<string, unknown>>;
203
+ }
204
+ //# sourceMappingURL=eap.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eap.d.ts","sourceRoot":"","sources":["../../src/modules/eap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EAGL,KAAK,WAAW,EAChB,KAAK,cAAc,EACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AACzC,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AAE9C,eAAO,MAAM,MAAM,QAAQ,CAAC;AAE5B;;;;GAIG;AACH,eAAO,MAAM,YAAY,SAAS,CAAC;AACnC,eAAO,MAAM,cAAc,WAAW,CAAC;AACvC,eAAO,MAAM,cAAc,WAAW,CAAC;AACvC,kFAAkF;AAClF,eAAO,MAAM,cAAc,WAAW,CAAC;AAEvC;;;;GAIG;AACH,eAAO,MAAM,SAAS,UAAU,CAAC;AACjC,eAAO,MAAM,SAAS,UAAU,CAAC;AACjC,eAAO,MAAM,QAAQ,SAAS,CAAC;AAC/B,eAAO,MAAM,WAAW,YAAY,CAAC;AACrC,eAAO,MAAM,SAAS,UAAU,CAAC;AACjC,eAAO,MAAM,SAAS,UAAU,CAAC;AACjC,eAAO,MAAM,OAAO,QAAQ,CAAC;AAE7B,gEAAgE;AAChE,eAAO,MAAM,aAAa,YAAY,CAAC;AACvC,eAAO,MAAM,aAAa,YAAY,CAAC;AAEvC,oEAAoE;AACpE,eAAO,MAAM,qBAAqB,IAAI,CAAC;AACvC,eAAO,MAAM,qBAAqB,IAAI,CAAC;AAEvC,mGAAmG;AACnG,eAAO,MAAM,wBAAwB,QAAS,CAAC;AAE/C,kFAAkF;AAClF,MAAM,WAAW,wBA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;;;;;;OAcG;IACG,iBAAiB,CACrB,aAAa,EAAE,MAAM,EACrB,OAAO,EAAE,MAAM,EACf,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,MAAM,EAChB,OAAO,GAAE,wBAA6B,GACrC,OAAO,CAAC,WAAW,CAAC;IAmBvB;;;;;;OAMG;IACG,iBAAiB,CAAC,aAAa,EAAE,MAAM,EAAE,OAAO,GAAE,wBAA6B,GAAG,OAAO,CAAC,WAAW,CAAC;IAS5G;;;;;;;OAOG;IACG,mBAAmB,CAAC,aAAa,EAAE,MAAM,EAAE,QAAQ,SAAK,EAAE,OAAO,SAAK,GAAG,OAAO,CAAC,WAAW,CAAC;IAOnG,6DAA6D;IACvD,iBAAiB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM7D;;;;;OAKG;IACG,gBAAgB,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAInE,yEAAyE;IACnE,eAAe,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAIlE;;;;;OAKG;IACG,gBAAgB,CAAC,MAAM,SAAK,GAAG,OAAO,CAAC,WAAW,EAAE,CAAC;IAM3D,gFAAgF;IAC1E,cAAc,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAMjE;;;;;;;OAOG;IACG,WAAW,CAAC,aAAa,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAIhF;;;;;OAKG;IACG,aAAa,CAAC,aAAa,EAAE,MAAM,GAAG,OAAO,CAAC,cAAc,CAAC;IAMnE;;;OAGG;IACG,OAAO,IAAI,OAAO,CAAC,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,CAAC;CAQlD"}
@@ -0,0 +1,218 @@
1
+ /**
2
+ * EAP - euclid's application platform: what euclid runs, from what, and as whom.
3
+ *
4
+ * One object, {@link EuclidEap}, built from a session that has already logged in:
5
+ *
6
+ * ```ts
7
+ * const eap = session.eap();
8
+ *
9
+ * await eap.createApplication("order-service", RUNTIME_JAVA, "artifacts", "order-service-1.4.0.jar", {
10
+ * queues: ["orders"],
11
+ * });
12
+ * await eap.startApplication("order-service");
13
+ * ```
14
+ *
15
+ * An application is deployed from an artifact already in a bucket - ESM puts it there, and EAP names it.
16
+ * The deployment says which buckets and queues it may reach, and euclid grants those to the identity it
17
+ * runs as: a technical principal it creates for the application unless one is named, with no password, no
18
+ * login and one access key. Nothing an application leaks is then a person's credential.
19
+ *
20
+ * Two names for the same things, and the asymmetry is the server's: a deployment names a `bucket` and an
21
+ * `artifact`, and the application that comes back describes a `bucketErn` and an `artifactKey`. Likewise
22
+ * the `buckets` and `queues` it is granted come back resolved into `resources`.
23
+ *
24
+ * Every action here is administrator-only, server-side. {@link EuclidSession.isAdmin} says whether the
25
+ * logged-in user is one, though the server enforces it regardless.
26
+ */
27
+ import { toApplication, toLogLevelResult, } from "../dto/eap.js";
28
+ import { ModuleClient } from "./base.js";
29
+ export const TARGET = "eap";
30
+ /**
31
+ * What an artifact is handed to. Matched exactly, in upper case, and anything else is refused with
32
+ * HTTP 400 - a runtime is a category rather than a version, so a JDK 17 and a JDK 25 application are both
33
+ * {@link RUNTIME_JAVA} and it is the command or the PATH that decides which one runs.
34
+ */
35
+ export const RUNTIME_JAVA = "JAVA";
36
+ export const RUNTIME_PYTHON = "PYTHON";
37
+ export const RUNTIME_NODEJS = "NODEJS";
38
+ /** Anything already executable, which is where C++ and Rust applications land. */
39
+ export const RUNTIME_BINARY = "BINARY";
40
+ /**
41
+ * The levels {@link EuclidEap.setLogLevel} accepts. An unrecognised one is refused rather than defaulted:
42
+ * "warnign" quietly meaning "info" is an application logging more than somebody asked for, and quietly
43
+ * meaning "off" is silence nobody asked for at all.
44
+ */
45
+ export const LOG_TRACE = "trace";
46
+ export const LOG_DEBUG = "debug";
47
+ export const LOG_INFO = "info";
48
+ export const LOG_WARNING = "warning";
49
+ export const LOG_ERROR = "error";
50
+ export const LOG_FATAL = "fatal";
51
+ export const LOG_OFF = "off";
52
+ /** What an application's `desiredState` and `state` read as. */
53
+ export const STATE_RUNNING = "RUNNING";
54
+ export const STATE_STOPPED = "STOPPED";
55
+ /** What a pool is sized at unless the deployment says otherwise. */
56
+ export const DEFAULT_MIN_INSTANCES = 1;
57
+ export const DEFAULT_MAX_INSTANCES = 1;
58
+ /** How long an instance has to become ready before the manager gives up on it, in milliseconds. */
59
+ export const DEFAULT_READY_TIMEOUT_MS = 30_000;
60
+ /** The fields an update sends when - and only when - it was given them. */
61
+ const UPDATABLE = [
62
+ "runtime",
63
+ "artifact",
64
+ "version",
65
+ "command",
66
+ "arguments",
67
+ "environment",
68
+ "buckets",
69
+ "queues",
70
+ "minInstances",
71
+ "maxInstances",
72
+ "readyTimeoutMs",
73
+ "namespace",
74
+ ];
75
+ /**
76
+ * EAP's operations, on the credentials of the session that created it.
77
+ *
78
+ * Built by {@link EuclidSession.eap} rather than directly, so that it shares that session's identity,
79
+ * namespace and connection settings - and follows them as they change.
80
+ */
81
+ export class EuclidEap extends ModuleClient {
82
+ constructor(session) {
83
+ super(session, { target: TARGET });
84
+ }
85
+ // -- deploying -------------------------------------------------------------------------------
86
+ /**
87
+ * Deploys an application, stopped, and answers with it as it was stored.
88
+ *
89
+ * Nothing runs yet: a new application's desired state is `STOPPED`, so {@link startApplication} is what
90
+ * puts it in service. Refused with HTTP 409 if the ID is taken, and with 404 if the bucket, the
91
+ * artifact, a named resource or a named user is not there - a deployment pointing at nothing would
92
+ * otherwise become an application that fails to start for a reason nobody can see.
93
+ *
94
+ * @param applicationId aoolication ID
95
+ * @param runtime {@link RUNTIME_JAVA}, {@link RUNTIME_PYTHON}, {@link RUNTIME_NODEJS} or
96
+ * {@link RUNTIME_BINARY}.
97
+ * @param bucket the name of the bucket holding the artifact - a name, not an ERN.
98
+ * @param artifact the artifact's object key within that bucket.
99
+ * @param options call options
100
+ */
101
+ async createApplication(applicationId, runtime, bucket, artifact, options = {}) {
102
+ return this.#application("create-application", {
103
+ applicationId,
104
+ runtime,
105
+ bucket,
106
+ artifact,
107
+ version: options.version ?? "",
108
+ command: options.command ?? "",
109
+ arguments: [...(options.arguments ?? [])],
110
+ environment: { ...options.environment },
111
+ buckets: [...(options.buckets ?? [])],
112
+ queues: [...(options.queues ?? [])],
113
+ user: options.user ?? "",
114
+ minInstances: options.minInstances ?? DEFAULT_MIN_INSTANCES,
115
+ maxInstances: options.maxInstances ?? DEFAULT_MAX_INSTANCES,
116
+ readyTimeoutMs: options.readyTimeoutMs ?? DEFAULT_READY_TIMEOUT_MS,
117
+ });
118
+ }
119
+ /**
120
+ * Changes a deployed application. Only what `changes` names changes - see
121
+ * {@link UpdateApplicationChanges}, which is where the rules about that live.
122
+ *
123
+ * Changing the artifact is a change of what will run next; {@link redeployApplication} is what a new
124
+ * build of the same application usually wants.
125
+ */
126
+ async updateApplication(applicationId, changes = {}) {
127
+ const payload = { applicationId };
128
+ for (const field of UPDATABLE) {
129
+ const value = changes[field];
130
+ if (value !== undefined)
131
+ payload[field] = value;
132
+ }
133
+ return this.#application("update-application", payload);
134
+ }
135
+ /**
136
+ * Points an application at a new build of itself.
137
+ *
138
+ * The artifact defaults to the one already deployed - which is what a rebuilt artifact stored under the
139
+ * same key wants - and the version to whatever the artifact's name says. A redeploy that would change
140
+ * neither the version nor the checksum is refused with HTTP 409: it would restart the instances for
141
+ * nothing, and usually means the new artifact never reached the bucket.
142
+ */
143
+ async redeployApplication(applicationId, artifact = "", version = "") {
144
+ const payload = { applicationId };
145
+ if (artifact)
146
+ payload["artifact"] = artifact;
147
+ if (version)
148
+ payload["version"] = version;
149
+ return this.#application("redeploy-application", payload);
150
+ }
151
+ /** Removes an application. Stop it first - this does not. */
152
+ async deleteApplication(applicationId) {
153
+ await this.call("delete-application", { applicationId });
154
+ }
155
+ // -- running ---------------------------------------------------------------------------------
156
+ /**
157
+ * Asks for an application to run, and answers with it as it stands.
158
+ *
159
+ * Asking is all this does: the desired state changes here and the manager acts on it, so the application
160
+ * in the answer is usually still `STOPPED` - it says what was asked for, not what has happened yet.
161
+ */
162
+ async startApplication(applicationId) {
163
+ return this.#application("start-application", { applicationId });
164
+ }
165
+ /** Asks for an application to stop, and answers with it as it stands. */
166
+ async stopApplication(applicationId) {
167
+ return this.#application("stop-application", { applicationId });
168
+ }
169
+ /**
170
+ * The applications whose ID starts with a prefix; an empty prefix lists them all.
171
+ *
172
+ * A list rather than a page: EAP answers with every match at once, since an installation has tens of
173
+ * applications rather than thousands.
174
+ */
175
+ async listApplications(prefix = "") {
176
+ const response = await this.call("list-applications", { prefix });
177
+ const applications = response["applications"];
178
+ return Array.isArray(applications) ? applications.map(toApplication) : [];
179
+ }
180
+ /** One application, by its ID, with the instances that are answering for it. */
181
+ async getApplication(applicationId) {
182
+ return this.#application("get-application", { applicationId });
183
+ }
184
+ // -- logging ---------------------------------------------------------------------------------
185
+ /**
186
+ * Sets what one application logs at, without restarting or redeploying it.
187
+ *
188
+ * @param applicationId application ID
189
+ * @param level {@link LOG_TRACE}, {@link LOG_DEBUG}, {@link LOG_INFO}, {@link LOG_WARNING},
190
+ * {@link LOG_ERROR}, {@link LOG_FATAL} or {@link LOG_OFF}. An empty one takes the setting back - see
191
+ * {@link resetLogLevel}, which says that in a word.
192
+ */
193
+ async setLogLevel(applicationId, level) {
194
+ return toLogLevelResult(await this.call("set-log-level", { applicationId, level }));
195
+ }
196
+ /**
197
+ * Puts an application back under the installation's own logging configuration.
198
+ *
199
+ * Which is not the same as setting it to whatever that configuration says: this removes the override, so
200
+ * the application follows the configuration as it changes from here on.
201
+ */
202
+ async resetLogLevel(applicationId) {
203
+ return this.setLogLevel(applicationId, "");
204
+ }
205
+ // -- monitoring ------------------------------------------------------------------------------
206
+ /**
207
+ * EAP's own metrics, as the server collects them. Answered unparsed - the shape belongs to the
208
+ * monitoring module rather than to EAP.
209
+ */
210
+ async metrics() {
211
+ return this.call("get-metrics");
212
+ }
213
+ /** The actions that answer with one application, which is most of them. */
214
+ async #application(action, payload) {
215
+ return toApplication(await this.call(action, payload));
216
+ }
217
+ }
218
+ //# sourceMappingURL=eap.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"eap.js","sourceRoot":"","sources":["../../src/modules/eap.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;;;GAyBG;AAEH,OAAO,EACL,aAAa,EACb,gBAAgB,GAGjB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAC;AAGzC,MAAM,CAAC,MAAM,MAAM,GAAG,KAAK,CAAC;AAE5B;;;;GAIG;AACH,MAAM,CAAC,MAAM,YAAY,GAAG,MAAM,CAAC;AACnC,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC;AACvC,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC;AACvC,kFAAkF;AAClF,MAAM,CAAC,MAAM,cAAc,GAAG,QAAQ,CAAC;AAEvC;;;;GAIG;AACH,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC;AACjC,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC;AACjC,MAAM,CAAC,MAAM,QAAQ,GAAG,MAAM,CAAC;AAC/B,MAAM,CAAC,MAAM,WAAW,GAAG,SAAS,CAAC;AACrC,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC;AACjC,MAAM,CAAC,MAAM,SAAS,GAAG,OAAO,CAAC;AACjC,MAAM,CAAC,MAAM,OAAO,GAAG,KAAK,CAAC;AAE7B,gEAAgE;AAChE,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AACvC,MAAM,CAAC,MAAM,aAAa,GAAG,SAAS,CAAC;AAEvC,oEAAoE;AACpE,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AACvC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,CAAC;AAEvC,mGAAmG;AACnG,MAAM,CA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object, {@link EuclidEkm}, built from a session that has already logged in:
5
+ *
6
+ * ```ts
7
+ * const ekm = session.ekm();
8
+ * const key = await ekm.createKey({ description: "customer exports" });
9
+ *
10
+ * const sealed = await ekm.encrypt(key.name, "account 4711");
11
+ * const plain = await ekm.decrypt(key.name, sealed);
12
+ * ```
13
+ *
14
+ * Key material never leaves the server: {@link EuclidEkm.encrypt} and {@link EuclidEkm.decrypt} send the
15
+ * bytes to the key rather than fetching the key to the bytes. That is what makes a key deletable as a
16
+ * unit - and what makes deleting one final, since nothing anywhere else has a copy.
17
+ *
18
+ * A key is named two ways, and they are not interchangeable. `name` is the ID the server minted and is
19
+ * what encrypts, decrypts and is deleted; the ERN is what revokes, describes and tags. Both are on every
20
+ * {@link import("../dto/ekm.js").Key} a listing returns.
21
+ *
22
+ * `encrypt` and `decrypt` carry raw bytes rather than JSON, and present the session's bearer token for
23
+ * the same reason ESM's transfer actions do - see {@link ModuleClient}.
24
+ */
25
+ import { type Page } from "../dto/eam.js";
26
+ import { type Certificate, type CreateKeyResult, type DeleteCertificateResult, type DeleteKeyResult, type Key, type KeyDescriptionResult, type RevokeKeyResult } from "../dto/ekm.js";
27
+ import { ModuleClient, type Bytes, type ListOptions } from "./base.js";
28
+ import type { EuclidSession } from "./eam.js";
29
+ export declare const TARGET = "ekm";
30
+ /** The only algorithm the server generates so far; anything else is refused with HTTP 400. */
31
+ export declare const AES = "AES";
32
+ /**
33
+ * The key length this SDK asks for when the caller does not say. 128 is the other one the server
34
+ * accepts, and what euclid-jdk's no-argument `createKey()` mints; 256 is what euclid itself creates when
35
+ * a bucket asks to be encrypted, which is the better default to inherit.
36
+ */
37
+ export declare const DEFAULT_KEY_LENGTH = 256;
38
+ /**
39
+ * How long a key scheduled for deletion stays alive by default, in days. The server's own default when
40
+ * the field is left out, restated here because it is the one number in this module that decides whether
41
+ * a mistake can be caught.
42
+ */
43
+ export declare const DEFAULT_PENDING_WINDOW_DAYS = 7;
44
+ /** The actions that carry raw bytes rather than JSON. */
45
+ export declare const BYTE_ACTIONS: string[];
46
+ /** What a key is created as, and what it says it is for. */
47
+ export interface CreateKeyOptions {
48
+ /** {@link AES}; the server generates nothing else so far. */
49
+ algorithm?: string;
50
+ /** 128 or 256 bits. */
51
+ length?: number;
52
+ /** What the key is for. Free text, never interpreted - and worth supplying; see {@link EuclidEkm.createKey}. */
53
+ description?: string;
54
+ }
55
+ /** What a generated certificate is valid for, and for how long. */
56
+ export interface CreateCertificateOptions {
57
+ /**
58
+ * The certificate's common name. Defaults to the name it is stored under: for a listener certificate
59
+ * those are usually the same word, and a certificate with an empty subject is refused by everything
60
+ * that reads it.
61
+ */
62
+ commonName?: string;
63
+ /** The other names it should be valid for. */
64
+ subjectAltNames?: Iterable<string>;
65
+ /** How long it is valid, in days, or left out for the server's default of 825. */
66
+ validDays?: number;
67
+ /** The RSA key length, or left out for the server's default of 2048. */
68
+ keyBits?: number;
69
+ description?: string;
70
+ }
71
+ /**
72
+ * EKM's operations, on the credentials of the session that created it.
73
+ *
74
+ * Built by {@link EuclidSession.ekm} rather than directly, so that it shares that session's identity,
75
+ * namespace and connection settings - and follows them as they change.
76
+ */
77
+ export declare class EuclidEkm extends ModuleClient {
78
+ #private;
79
+ constructor(session: EuclidSession);
80
+ /**
81
+ * Creates a key, and answers with the ID the server minted for it.
82
+ *
83
+ * The description is worth supplying. A key is identified by that generated ID, which says nothing
84
+ * about what the key protects, and a key outlives the reason it was made - so months later this is the
85
+ * only thing that answers whether it can be deleted, and deleting one is not a mistake that can be
86
+ * undone.
87
+ */
88
+ createKey(options?: CreateKeyOptions): Promise<CreateKeyResult>;
89
+ /** One page of keys, and how many exist in total. Never their material. */
90
+ listKeys(options?: ListOptions): Promise<Page<Key>>;
91
+ /**
92
+ * Schedules a key for deletion, and answers with the date it goes for good.
93
+ *
94
+ * Scheduled rather than immediate, because this is the one action here that cannot be undone by any
95
+ * other: everything the key encrypted - a bucket's objects, a secret's value - becomes unreadable when
96
+ * the date passes, and the window is the only chance anybody gets to notice. A key inside its window
97
+ * still decrypts.
98
+ *
99
+ * Takes the key's ID rather than its ERN, as {@link encrypt} does.
100
+ */
101
+ deleteKey(keyId: string, pendingWindowInDays?: number): Promise<DeleteKeyResult>;
102
+ /**
103
+ * Stops a key encrypting anything further, without touching what it already wrote.
104
+ *
105
+ * The difference from {@link deleteKey} is that nothing becomes unreadable: a revoked key still
106
+ * decrypts, so this is what to reach for when a key should no longer be used but the data under it is
107
+ * still wanted.
108
+ *
109
+ * Takes the key's ERN rather than its ID.
110
+ */
111
+ revokeKey(ern: string): Promise<RevokeKeyResult>;
112
+ /**
113
+ * Changes what a key says it is for.
114
+ *
115
+ * Only the description changes: the material, algorithm, length, status and any scheduled deletion are
116
+ * untouched, so describing a key neither prolongs nor shortens its life. An empty string clears the
117
+ * description rather than leaving it alone - otherwise there would be no way to remove one.
118
+ *
119
+ * Takes the key's ERN rather than its ID.
120
+ */
121
+ setKeyDescription(ern: string, description: string): Promise<KeyDescriptionResult>;
122
+ /**
123
+ * Tags a key. The tag is upserted, so one already there has its value replaced - EKM has no separate
124
+ * set-key-tag action to distinguish the two.
125
+ */
126
+ addKeyTag(ern: string, key: string, value: string): Promise<void>;
127
+ /** Removes a tag from a key. */
128
+ deleteKeyTag(ern: string, key: string): Promise<void>;
129
+ /**
130
+ * Encrypts bytes with a key the server holds, and answers with `IV || ciphertext || tag`.
131
+ *
132
+ * Those are the exact bytes {@link decrypt} takes back; nothing here needs to be unpacked or
133
+ * re-assembled. Only a key whose status is `AVAILABLE` encrypts - a revoked one, or one scheduled for
134
+ * deletion, is refused with HTTP 403.
135
+ *
136
+ * Takes the key's ID - the `name` {@link createKey} answered with - rather than its ERN.
137
+ */
138
+ encrypt(keyId: string, plaintext: Bytes): Promise<Buffer>;
139
+ /**
140
+ * Decrypts what {@link encrypt} produced.
141
+ *
142
+ * Works for a revoked key and for one scheduled for deletion, right up until its deletion date passes -
143
+ * which is the whole difference between revoking a key and deleting it.
144
+ */
145
+ decrypt(keyId: string, ciphertext: Buffer | Uint8Array): Promise<Buffer>;
146
+ /**
147
+ * Stores a certificate somebody else issued, together with the private key that proves it.
148
+ *
149
+ * Both halves are required and the server checks them against each other: a certificate stored with a
150
+ * key that is not its own is accepted silently by every step after this one and only shows itself as a
151
+ * handshake that fails for every caller. A mismatch is HTTP 400 here instead.
152
+ *
153
+ * The private key stays with EKM. It goes in and is never handed back - no action returns one.
154
+ */
155
+ importCertificate(name: string, certificatePem: string, privateKeyPem: string, description?: string): Promise<Certificate>;
156
+ /**
157
+ * Generates a self-signed certificate, for an installation that has to serve HTTPS before anybody has
158
+ * bought it a real one.
159
+ *
160
+ * Nobody has vouched for the result - {@link import("../dto/ekm.js").Certificate.generated} says so,
161
+ * and a client still has to be told to trust it.
162
+ */
163
+ createCertificate(name: string, options?: CreateCertificateOptions): Promise<Certificate>;
164
+ /** One stored certificate, by name. The PEM comes back; the private key does not. */
165
+ getCertificate(name: string): Promise<Certificate>;
166
+ /** One page of certificates, and how many exist in total. */
167
+ listCertificates(options?: ListOptions): Promise<Page<Certificate>>;
168
+ /**
169
+ * Deletes a certificate, outright and with no grace period.
170
+ *
171
+ * Unlike {@link deleteKey} this needs none: nothing becomes unreadable, because a certificate is
172
+ * public. A listener already serving it keeps the copy it loaded until it is restarted, which is what
173
+ * makes this recoverable - import a replacement under the same name.
174
+ */
175
+ deleteCertificate(name: string): Promise<DeleteCertificateResult>;
176
+ /**
177
+ * EKM's own metrics, as the server collects them. Answered unparsed - the shape belongs to the
178
+ * monitoring module rather than to EKM.
179
+ */
180
+ metrics(): Promise<Record<string, unknown>>;
181
+ }
182
+ //# sourceMappingURL=ekm.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"ekm.d.ts","sourceRoot":"","sources":["../../src/modules/ekm.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAU,KAAK,IAAI,EAAE,MAAM,eAAe,CAAC;AAClD,OAAO,EAQL,KAA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