@ontemper/sdk 0.7.1-postgresql.1 → 0.7.1-postgresql.3
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.
- package/README.md +50 -6
- package/dist/As2Resource.d.ts +431 -76
- package/dist/As2Resource.d.ts.map +1 -1
- package/dist/As2Resource.js +31 -30
- package/dist/As2Resource.js.map +1 -1
- package/dist/As2Transport.d.ts.map +1 -1
- package/dist/As2Transport.js +3 -1
- package/dist/As2Transport.js.map +1 -1
- package/dist/As2Wire.d.ts +39 -0
- package/dist/As2Wire.d.ts.map +1 -1
- package/dist/DatabaseTunnelAuthorization.d.ts +11 -0
- package/dist/DatabaseTunnelAuthorization.d.ts.map +1 -0
- package/dist/DatabaseTunnelAuthorization.js +35 -0
- package/dist/DatabaseTunnelAuthorization.js.map +1 -0
- package/dist/ExpiringMap.d.ts +21 -0
- package/dist/ExpiringMap.d.ts.map +1 -0
- package/dist/ExpiringMap.js +79 -0
- package/dist/ExpiringMap.js.map +1 -0
- package/dist/HttpApiResource.d.ts +2904 -177
- package/dist/HttpApiResource.d.ts.map +1 -1
- package/dist/HttpApiResource.js +81 -59
- package/dist/HttpApiResource.js.map +1 -1
- package/dist/Kafka.d.ts +89 -0
- package/dist/Kafka.d.ts.map +1 -0
- package/dist/Kafka.js +297 -0
- package/dist/Kafka.js.map +1 -0
- package/dist/Manifest.d.ts +1 -1
- package/dist/Manifest.js +1 -1
- package/dist/PostgreSql.d.ts +2 -2
- package/dist/PostgreSql.d.ts.map +1 -1
- package/dist/PostgreSql.js +4 -13
- package/dist/PostgreSql.js.map +1 -1
- package/dist/PostgreSqlPool.d.ts +2 -40
- package/dist/PostgreSqlPool.d.ts.map +1 -1
- package/dist/PostgreSqlPool.js +13 -26
- package/dist/PostgreSqlPool.js.map +1 -1
- package/dist/PostgreSqlTimeouts.d.ts +4 -2
- package/dist/PostgreSqlTimeouts.d.ts.map +1 -1
- package/dist/PostgreSqlTimeouts.js +5 -4
- package/dist/PostgreSqlTimeouts.js.map +1 -1
- package/dist/Redaction.d.ts +2 -0
- package/dist/Redaction.d.ts.map +1 -1
- package/dist/Redaction.js +16 -4
- package/dist/Redaction.js.map +1 -1
- package/dist/ResourceRecords.d.ts +1086 -0
- package/dist/ResourceRecords.d.ts.map +1 -0
- package/dist/ResourceRecords.js +303 -0
- package/dist/ResourceRecords.js.map +1 -0
- package/dist/Resources.d.ts +17 -0
- package/dist/Resources.d.ts.map +1 -0
- package/dist/Resources.js +15 -0
- package/dist/Resources.js.map +1 -0
- package/dist/ResourcesCache.d.ts +33 -0
- package/dist/ResourcesCache.d.ts.map +1 -0
- package/dist/ResourcesCache.js +205 -0
- package/dist/ResourcesCache.js.map +1 -0
- package/dist/ResourcesEnv.d.ts +81 -0
- package/dist/ResourcesEnv.d.ts.map +1 -0
- package/dist/ResourcesEnv.js +104 -0
- package/dist/ResourcesEnv.js.map +1 -0
- package/dist/ResourcesErrors.d.ts +5 -1
- package/dist/ResourcesErrors.d.ts.map +1 -1
- package/dist/ResourcesErrors.js +5 -2
- package/dist/ResourcesErrors.js.map +1 -1
- package/dist/ResourcesToken.d.ts +9 -0
- package/dist/ResourcesToken.d.ts.map +1 -1
- package/dist/ResourcesToken.js +20 -7
- package/dist/ResourcesToken.js.map +1 -1
- package/dist/RuntimeResources.d.ts +18 -3
- package/dist/RuntimeResources.d.ts.map +1 -1
- package/dist/RuntimeResources.js +54 -30
- package/dist/RuntimeResources.js.map +1 -1
- package/dist/TransportResource.d.ts +1 -32
- package/dist/TransportResource.d.ts.map +1 -1
- package/dist/TransportResource.js +1 -19
- package/dist/TransportResource.js.map +1 -1
- package/dist/Workflow.js +2 -2
- package/dist/Workflow.js.map +1 -1
- package/package.json +17 -5
package/dist/Kafka.js
ADDED
|
@@ -0,0 +1,297 @@
|
|
|
1
|
+
import { constants, createPrivateKey, createSign, randomUUID } from 'node:crypto';
|
|
2
|
+
import { Option, Redacted, Schema } from 'effect';
|
|
3
|
+
export class OptionalKafkaDependencyError extends Error {
|
|
4
|
+
constructor(packageName) {
|
|
5
|
+
super(`Kafka authentication requires the optional package ${packageName}.`);
|
|
6
|
+
this.name = 'OptionalKafkaDependencyError';
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
export class UnsupportedKafkaAuthError extends Error {
|
|
10
|
+
constructor(field) {
|
|
11
|
+
super(`Kafka record uses an unsupported ${field}. Upgrade @ontemper/sdk to support it.`);
|
|
12
|
+
this.name = 'UnsupportedKafkaAuthError';
|
|
13
|
+
}
|
|
14
|
+
}
|
|
15
|
+
// STS credentials are reused until this long before they expire.
|
|
16
|
+
const ASSUMED_ROLE_REFRESH_MARGIN_MS = 60_000;
|
|
17
|
+
const OAUTH_TOKEN_REQUEST_TIMEOUT_MS = 15_000;
|
|
18
|
+
const base64Url = (value) => Buffer.from(value).toString('base64url');
|
|
19
|
+
const formEncode = (value) => encodeURIComponent(value).replace(/%20/g, '+');
|
|
20
|
+
function privateKeyAssertion(tokenRequest, now) {
|
|
21
|
+
const clientAuthentication = tokenRequest.clientAuthentication;
|
|
22
|
+
if (clientAuthentication.type !== 'private_key_jwt') {
|
|
23
|
+
throw new UnsupportedKafkaAuthError('auth.tokenRequest.clientAuthentication');
|
|
24
|
+
}
|
|
25
|
+
const header = {
|
|
26
|
+
alg: clientAuthentication.algorithm,
|
|
27
|
+
typ: 'JWT',
|
|
28
|
+
};
|
|
29
|
+
if (clientAuthentication.keyId !== undefined) {
|
|
30
|
+
header.kid = clientAuthentication.keyId;
|
|
31
|
+
}
|
|
32
|
+
const issuedAt = Math.floor(now / 1000);
|
|
33
|
+
const claims = {
|
|
34
|
+
iss: tokenRequest.clientId,
|
|
35
|
+
sub: tokenRequest.clientId,
|
|
36
|
+
aud: tokenRequest.tokenUrl,
|
|
37
|
+
exp: issuedAt + 60,
|
|
38
|
+
iat: issuedAt,
|
|
39
|
+
jti: randomUUID(),
|
|
40
|
+
};
|
|
41
|
+
const signed = `${base64Url(JSON.stringify(header))}.${base64Url(JSON.stringify(claims))}`;
|
|
42
|
+
const signature = createSign('SHA256');
|
|
43
|
+
signature.update(signed);
|
|
44
|
+
signature.end();
|
|
45
|
+
const value = clientAuthentication.algorithm === 'ES256'
|
|
46
|
+
? signature.sign({ key: Redacted.value(clientAuthentication.privateKey), dsaEncoding: 'ieee-p1363' })
|
|
47
|
+
: clientAuthentication.algorithm === 'PS256'
|
|
48
|
+
? signature.sign({
|
|
49
|
+
key: Redacted.value(clientAuthentication.privateKey),
|
|
50
|
+
padding: constants.RSA_PKCS1_PSS_PADDING,
|
|
51
|
+
saltLength: constants.RSA_PSS_SALTLEN_DIGEST,
|
|
52
|
+
})
|
|
53
|
+
: signature.sign(Redacted.value(clientAuthentication.privateKey));
|
|
54
|
+
return `${signed}.${base64Url(value)}`;
|
|
55
|
+
}
|
|
56
|
+
function oauthBearerProvider(tokenRequest, options) {
|
|
57
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
58
|
+
const now = options.now ?? Date.now;
|
|
59
|
+
let cached;
|
|
60
|
+
// Concurrent broker authentications share one in-flight token request.
|
|
61
|
+
let pendingFetch = null;
|
|
62
|
+
const fetchToken = async () => {
|
|
63
|
+
const clientAuthentication = tokenRequest.clientAuthentication;
|
|
64
|
+
if (!['none', 'basic', 'body', 'query', 'private_key_jwt'].includes(clientAuthentication.type)) {
|
|
65
|
+
throw new UnsupportedKafkaAuthError('auth.tokenRequest.clientAuthentication');
|
|
66
|
+
}
|
|
67
|
+
const parameters = new URLSearchParams({ ...tokenRequest.extraParams, grant_type: 'client_credentials' });
|
|
68
|
+
if (tokenRequest.scope !== undefined)
|
|
69
|
+
parameters.set('scope', tokenRequest.scope);
|
|
70
|
+
if (tokenRequest.audience !== undefined)
|
|
71
|
+
parameters.set('audience', tokenRequest.audience);
|
|
72
|
+
const headers = {};
|
|
73
|
+
const tokenUrl = new URL(tokenRequest.tokenUrl);
|
|
74
|
+
switch (clientAuthentication.type) {
|
|
75
|
+
case 'none':
|
|
76
|
+
parameters.set('client_id', tokenRequest.clientId);
|
|
77
|
+
break;
|
|
78
|
+
case 'basic':
|
|
79
|
+
headers.Authorization = `Basic ${Buffer.from(`${formEncode(tokenRequest.clientId)}:${formEncode(Redacted.value(clientAuthentication.clientSecret))}`).toString('base64')}`;
|
|
80
|
+
break;
|
|
81
|
+
case 'body':
|
|
82
|
+
parameters.set('client_id', tokenRequest.clientId);
|
|
83
|
+
parameters.set('client_secret', Redacted.value(clientAuthentication.clientSecret));
|
|
84
|
+
break;
|
|
85
|
+
case 'query':
|
|
86
|
+
tokenUrl.searchParams.set('client_id', tokenRequest.clientId);
|
|
87
|
+
tokenUrl.searchParams.set('client_secret', Redacted.value(clientAuthentication.clientSecret));
|
|
88
|
+
break;
|
|
89
|
+
case 'private_key_jwt':
|
|
90
|
+
parameters.set('client_id', tokenRequest.clientId);
|
|
91
|
+
parameters.set('client_assertion_type', 'urn:ietf:params:oauth:client-assertion-type:jwt-bearer');
|
|
92
|
+
parameters.set('client_assertion', privateKeyAssertion(tokenRequest, now()));
|
|
93
|
+
break;
|
|
94
|
+
}
|
|
95
|
+
const isJson = tokenRequest.tokenRequestFormat === 'json';
|
|
96
|
+
headers['Content-Type'] = isJson ? 'application/json' : 'application/x-www-form-urlencoded';
|
|
97
|
+
const response = await fetchImpl(tokenUrl, {
|
|
98
|
+
method: 'POST',
|
|
99
|
+
headers,
|
|
100
|
+
body: isJson ? JSON.stringify(Object.fromEntries(parameters)) : parameters,
|
|
101
|
+
redirect: 'error',
|
|
102
|
+
signal: AbortSignal.timeout(OAUTH_TOKEN_REQUEST_TIMEOUT_MS),
|
|
103
|
+
});
|
|
104
|
+
if (!response.ok)
|
|
105
|
+
throw new Error(`OAuth token request failed with status ${response.status}.`);
|
|
106
|
+
const body = await response.json();
|
|
107
|
+
const parsed = decodeTokenResponse(body);
|
|
108
|
+
if (Option.isNone(parsed))
|
|
109
|
+
throw new Error('OAuth token response did not include an access token.');
|
|
110
|
+
const accessToken = parsed.value.access_token;
|
|
111
|
+
const expiresIn = Option.getOrUndefined(decodeExpiresIn(parsed.value.expires_in));
|
|
112
|
+
// Without a stated lifetime the token's expiry is unknown, so each authentication requests a fresh one.
|
|
113
|
+
cached =
|
|
114
|
+
expiresIn === undefined
|
|
115
|
+
? undefined
|
|
116
|
+
: { value: accessToken, expiresAt: now() + Math.max(0, expiresIn - 30) * 1000 };
|
|
117
|
+
return { value: accessToken };
|
|
118
|
+
};
|
|
119
|
+
return () => {
|
|
120
|
+
if (cached !== undefined && cached.expiresAt > now())
|
|
121
|
+
return Promise.resolve({ value: cached.value });
|
|
122
|
+
if (pendingFetch !== null)
|
|
123
|
+
return pendingFetch;
|
|
124
|
+
const request = (async () => {
|
|
125
|
+
try {
|
|
126
|
+
return await fetchToken();
|
|
127
|
+
}
|
|
128
|
+
finally {
|
|
129
|
+
pendingFetch = null;
|
|
130
|
+
}
|
|
131
|
+
})();
|
|
132
|
+
pendingFetch = request;
|
|
133
|
+
return request;
|
|
134
|
+
};
|
|
135
|
+
}
|
|
136
|
+
const decodeTokenResponse = Schema.decodeUnknownOption(Schema.Struct({
|
|
137
|
+
access_token: Schema.String.check(Schema.isMinLength(1)),
|
|
138
|
+
expires_in: Schema.optionalKey(Schema.Unknown),
|
|
139
|
+
}));
|
|
140
|
+
// A missing, non-numeric, or non-positive expires_in reads as absent, so the token is not cached.
|
|
141
|
+
const decodeExpiresIn = Schema.decodeUnknownOption(Schema.Finite.check(Schema.isGreaterThan(0)));
|
|
142
|
+
function mskOAuthBearerProvider(resource, options) {
|
|
143
|
+
const auth = resource.auth;
|
|
144
|
+
if (auth.type !== 'aws_msk_iam')
|
|
145
|
+
throw new UnsupportedKafkaAuthError('auth.type');
|
|
146
|
+
const loadMskSigner = options.loadMskSigner ??
|
|
147
|
+
(async () => {
|
|
148
|
+
// The optional peer is absent in workflows that do not use MSK IAM, so loading it must remain lazy.
|
|
149
|
+
try {
|
|
150
|
+
return await import('aws-msk-iam-sasl-signer-js');
|
|
151
|
+
}
|
|
152
|
+
catch (error) {
|
|
153
|
+
if (error instanceof Error && 'code' in error && error.code === 'ERR_MODULE_NOT_FOUND') {
|
|
154
|
+
throw new OptionalKafkaDependencyError('aws-msk-iam-sasl-signer-js');
|
|
155
|
+
}
|
|
156
|
+
throw error;
|
|
157
|
+
}
|
|
158
|
+
});
|
|
159
|
+
const loadCredentialProviders = options.loadCredentialProviders ??
|
|
160
|
+
(async () => {
|
|
161
|
+
// The optional peer is loaded only when a record asks the client to assume an AWS role.
|
|
162
|
+
try {
|
|
163
|
+
return await import('@aws-sdk/credential-providers');
|
|
164
|
+
}
|
|
165
|
+
catch (error) {
|
|
166
|
+
if (error instanceof Error && 'code' in error && error.code === 'ERR_MODULE_NOT_FOUND') {
|
|
167
|
+
throw new OptionalKafkaDependencyError('@aws-sdk/credential-providers');
|
|
168
|
+
}
|
|
169
|
+
throw error;
|
|
170
|
+
}
|
|
171
|
+
});
|
|
172
|
+
const now = options.now ?? Date.now;
|
|
173
|
+
// One STS provider per config, and its credentials reused until shortly before expiry, so each broker
|
|
174
|
+
// authentication does not send its own AssumeRole call.
|
|
175
|
+
let assumeRoleProvider;
|
|
176
|
+
let assumedCredentials;
|
|
177
|
+
const loadAssumeRoleProvider = async (params) => {
|
|
178
|
+
try {
|
|
179
|
+
return (await loadCredentialProviders()).fromTemporaryCredentials({
|
|
180
|
+
params,
|
|
181
|
+
clientConfig: { region: auth.region },
|
|
182
|
+
});
|
|
183
|
+
}
|
|
184
|
+
catch (error) {
|
|
185
|
+
// A failed load is retried on the next authentication instead of caching the rejection.
|
|
186
|
+
assumeRoleProvider = undefined;
|
|
187
|
+
throw error;
|
|
188
|
+
}
|
|
189
|
+
};
|
|
190
|
+
const assumedRoleCredentials = async (params) => {
|
|
191
|
+
if (assumedCredentials !== undefined && assumedCredentials.refreshAt > now())
|
|
192
|
+
return assumedCredentials.credentials;
|
|
193
|
+
assumeRoleProvider ??= loadAssumeRoleProvider(params);
|
|
194
|
+
const { expiration, ...credentials } = await (await assumeRoleProvider)();
|
|
195
|
+
assumedCredentials =
|
|
196
|
+
expiration === undefined
|
|
197
|
+
? undefined
|
|
198
|
+
: { credentials, refreshAt: expiration.getTime() - ASSUMED_ROLE_REFRESH_MARGIN_MS };
|
|
199
|
+
return credentials;
|
|
200
|
+
};
|
|
201
|
+
return async () => {
|
|
202
|
+
const signer = await loadMskSigner();
|
|
203
|
+
const awsAuth = auth.awsAuth;
|
|
204
|
+
if (!['access_key', 'assume_role', 'ambient'].includes(awsAuth.type)) {
|
|
205
|
+
throw new UnsupportedKafkaAuthError('auth.awsAuth');
|
|
206
|
+
}
|
|
207
|
+
const token = awsAuth.type === 'access_key'
|
|
208
|
+
? await signer.generateAuthTokenFromCredentialsProvider({
|
|
209
|
+
region: auth.region,
|
|
210
|
+
awsCredentialsProvider: async () => {
|
|
211
|
+
const creds = {
|
|
212
|
+
accessKeyId: awsAuth.accessKeyId,
|
|
213
|
+
secretAccessKey: Redacted.value(awsAuth.secretAccessKey),
|
|
214
|
+
};
|
|
215
|
+
if (awsAuth.sessionToken !== undefined)
|
|
216
|
+
creds.sessionToken = Redacted.value(awsAuth.sessionToken);
|
|
217
|
+
return creds;
|
|
218
|
+
},
|
|
219
|
+
})
|
|
220
|
+
: awsAuth.type === 'assume_role'
|
|
221
|
+
? await signer.generateAuthTokenFromCredentialsProvider({
|
|
222
|
+
region: auth.region,
|
|
223
|
+
awsCredentialsProvider: () => {
|
|
224
|
+
const params = { RoleArn: awsAuth.roleArn, RoleSessionName: 'temper-kafka' };
|
|
225
|
+
if (awsAuth.externalId !== undefined)
|
|
226
|
+
params.ExternalId = awsAuth.externalId;
|
|
227
|
+
return assumedRoleCredentials(params);
|
|
228
|
+
},
|
|
229
|
+
})
|
|
230
|
+
: await signer.generateAuthToken({ region: auth.region });
|
|
231
|
+
return { value: token.token };
|
|
232
|
+
};
|
|
233
|
+
}
|
|
234
|
+
// A bad endpoint or key would otherwise surface only at the first broker authentication, deep inside KafkaJS.
|
|
235
|
+
function assertTokenRequestUsable(tokenRequest) {
|
|
236
|
+
const tokenUrl = URL.canParse(tokenRequest.tokenUrl) ? new URL(tokenRequest.tokenUrl) : undefined;
|
|
237
|
+
if (tokenUrl?.protocol !== 'https:') {
|
|
238
|
+
throw new Error('Kafka OAuth auth.tokenRequest.tokenUrl must be an https URL.');
|
|
239
|
+
}
|
|
240
|
+
const clientAuthentication = tokenRequest.clientAuthentication;
|
|
241
|
+
if (clientAuthentication.type !== 'private_key_jwt')
|
|
242
|
+
return;
|
|
243
|
+
try {
|
|
244
|
+
createPrivateKey(Redacted.value(clientAuthentication.privateKey));
|
|
245
|
+
}
|
|
246
|
+
catch {
|
|
247
|
+
throw new Error('Kafka OAuth auth.tokenRequest.clientAuthentication.privateKey is not a valid PEM private key.');
|
|
248
|
+
}
|
|
249
|
+
}
|
|
250
|
+
/** Maps a resolved Kafka record to the options accepted by `new Kafka(...)`. */
|
|
251
|
+
export function kafkaConfig(resource, options = {}) {
|
|
252
|
+
if (resource.brokers.some((broker) => broker.startsWith('['))) {
|
|
253
|
+
throw new Error('KafkaJS does not support bracketed IPv6 bootstrap broker addresses; configure a hostname or IPv4 address.');
|
|
254
|
+
}
|
|
255
|
+
let ssl;
|
|
256
|
+
if (resource.tls !== undefined) {
|
|
257
|
+
const tlsOptions = {};
|
|
258
|
+
if (resource.tls.caCertificate !== undefined)
|
|
259
|
+
tlsOptions.ca = resource.tls.caCertificate;
|
|
260
|
+
if (resource.tls.clientCertificate !== undefined)
|
|
261
|
+
tlsOptions.cert = resource.tls.clientCertificate;
|
|
262
|
+
if (resource.tls.clientKey !== undefined)
|
|
263
|
+
tlsOptions.key = Redacted.value(resource.tls.clientKey);
|
|
264
|
+
if (resource.tls.clientKeyPassphrase !== undefined) {
|
|
265
|
+
tlsOptions.passphrase = Redacted.value(resource.tls.clientKeyPassphrase);
|
|
266
|
+
}
|
|
267
|
+
if (resource.tls.serverName !== undefined)
|
|
268
|
+
tlsOptions.servername = resource.tls.serverName;
|
|
269
|
+
ssl = Object.keys(tlsOptions).length === 0 ? true : tlsOptions;
|
|
270
|
+
}
|
|
271
|
+
const auth = resource.auth;
|
|
272
|
+
if (!['none', 'sasl_plain', 'sasl_scram', 'oauthbearer', 'aws_msk_iam'].includes(auth.type)) {
|
|
273
|
+
throw new UnsupportedKafkaAuthError('auth.type');
|
|
274
|
+
}
|
|
275
|
+
if (auth.type === 'oauthbearer')
|
|
276
|
+
assertTokenRequestUsable(auth.tokenRequest);
|
|
277
|
+
const sasl = auth.type === 'none'
|
|
278
|
+
? undefined
|
|
279
|
+
: auth.type === 'sasl_plain'
|
|
280
|
+
? { mechanism: 'plain', username: auth.username, password: Redacted.value(auth.password) }
|
|
281
|
+
: auth.type === 'sasl_scram'
|
|
282
|
+
? auth.mechanism === 'SCRAM-SHA-256'
|
|
283
|
+
? { mechanism: 'scram-sha-256', username: auth.username, password: Redacted.value(auth.password) }
|
|
284
|
+
: { mechanism: 'scram-sha-512', username: auth.username, password: Redacted.value(auth.password) }
|
|
285
|
+
: auth.type === 'oauthbearer'
|
|
286
|
+
? { mechanism: 'oauthbearer', oauthBearerProvider: oauthBearerProvider(auth.tokenRequest, options) }
|
|
287
|
+
: { mechanism: 'oauthbearer', oauthBearerProvider: mskOAuthBearerProvider(resource, options) };
|
|
288
|
+
const config = { brokers: [...resource.brokers] };
|
|
289
|
+
if (resource.clientId !== undefined)
|
|
290
|
+
config.clientId = resource.clientId;
|
|
291
|
+
if (ssl !== undefined)
|
|
292
|
+
config.ssl = ssl;
|
|
293
|
+
if (sasl !== undefined)
|
|
294
|
+
config.sasl = sasl;
|
|
295
|
+
return config;
|
|
296
|
+
}
|
|
297
|
+
//# sourceMappingURL=Kafka.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"Kafka.js","sourceRoot":"","sources":["../src/Kafka.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,gBAAgB,EAAE,UAAU,EAAE,UAAU,EAAE,MAAM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AI,CAAC,YAAY,EAAE,OAAO,CAAC,EAAE;oBACpG,CAAC,CAAC,EAAE,SAAS,EAAE,aAAa,EAAE,mBAAmB,EAAE,sBAAsB,CAAC,QAAQ,EAAE,OAAO,CAAC,EAAE,CAAC;IACzG,MAAM,MAAM,GAAsB,EAAE,OAAO,EAAE,CAAC,GAAG,QAAQ,CAAC,OAAO,CAAC,EAAE,CAAC;IACrE,IAAI,QAAQ,CAAC,QAAQ,KAAK,SAAS;QAAE,MAAM,CAAC,QAAQ,GAAG,QAAQ,CAAC,QAAQ,CAAC;IACzE,IAAI,GAAG,KAAK,SAAS;QAAE,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;IACxC,IAAI,IAAI,KAAK,SAAS;QAAE,MAAM,CAAC,IAAI,GAAG,IAAI,CAAC;IAC3C,OAAO,MAAM,CAAC;AAChB,CAAC"}
|
package/dist/Manifest.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { HttpApi, type HttpApiGroup } from 'effect/http-api';
|
|
2
2
|
import { type WorkflowManifest } from './Contract/Manifest.js';
|
|
3
|
-
export declare const SDK_VERSION = "0.7.1-postgresql.
|
|
3
|
+
export declare const SDK_VERSION = "0.7.1-postgresql.3";
|
|
4
4
|
export declare const RUNTIME_API_VERSION = 1;
|
|
5
5
|
/** The route the SDK serves for platform probes; an API declaring `GET` on it collides with it on every request. */
|
|
6
6
|
export declare const HEALTHCHECK_PATH = "/healthcheck";
|
package/dist/Manifest.js
CHANGED
|
@@ -5,7 +5,7 @@ import { declarationOf } from './Resource.js';
|
|
|
5
5
|
import { Trigger } from './Trigger.js';
|
|
6
6
|
const decodeTrigger = Schema.decodeUnknownSync(TriggerMetadata, { onExcessProperty: 'error' });
|
|
7
7
|
const identityOf = (resource) => `${resource.kind}:${resource.kind === 'resourceType' ? resource.type : resource.key}`;
|
|
8
|
-
export const SDK_VERSION = '0.7.1-postgresql.
|
|
8
|
+
export const SDK_VERSION = '0.7.1-postgresql.3';
|
|
9
9
|
export const RUNTIME_API_VERSION = 1;
|
|
10
10
|
/** The route the SDK serves for platform probes; an API declaring `GET` on it collides with it on every request. */
|
|
11
11
|
export const HEALTHCHECK_PATH = '/healthcheck';
|
package/dist/PostgreSql.d.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* PostgreSQL Resource pools
|
|
3
|
-
*
|
|
2
|
+
* PostgreSQL Resource pools, exported from `@temper/workflow/resources`. A pool needs the `pg` package, and a
|
|
3
|
+
* builder's tunnel to a Temper-managed database needs `ws`; both load only when a pool is built.
|
|
4
4
|
*/
|
|
5
5
|
import { Effect, type Scope } from 'effect';
|
|
6
6
|
import type pg from 'pg';
|
package/dist/PostgreSql.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgreSql.d.ts","sourceRoot":"","sources":["../src/PostgreSql.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAA2C,MAAM,EAAuB,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE1G,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"PostgreSql.d.ts","sourceRoot":"","sources":["../src/PostgreSql.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAA2C,MAAM,EAAuB,KAAK,KAAK,EAAE,MAAM,QAAQ,CAAC;AAE1G,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAIzB,OAAO,KAAK,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AACjE,OAAO,EAA6B,KAAK,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAElF,OAAO,EAAE,kBAAkB,EAAE,MAAM,qBAAqB,CAAC;AAEzD,0GAA0G;AAC1G,MAAM,MAAM,mBAAmB,GAAG,SAAS,GAAG,oBAAoB,CAAC;AAqCnE;;;;GAIG;AACH,eAAO,MAAM,kBAAkB,QAAS,MAAM,KAAG,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,mBAAmB,EAAE,KAAK,CAAC,KAAK,CAC7C,CAAC;AAS5D;;;;GAIG;AACH,wBAAsB,oBAAoB,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,EAAE,CAAC,IAAI,CAAC,CAIxE"}
|
package/dist/PostgreSql.js
CHANGED
|
@@ -1,9 +1,10 @@
|
|
|
1
1
|
/**
|
|
2
|
-
* PostgreSQL Resource pools
|
|
3
|
-
*
|
|
2
|
+
* PostgreSQL Resource pools, exported from `@temper/workflow/resources`. A pool needs the `pg` package, and a
|
|
3
|
+
* builder's tunnel to a Temper-managed database needs `ws`; both load only when a pool is built.
|
|
4
4
|
*/
|
|
5
5
|
import { Cause, Config, ConfigProvider, Duration, Effect, Exit, Layer, Option } from 'effect';
|
|
6
6
|
import { FetchHttpClient, HttpClient } from 'effect/http';
|
|
7
|
+
import { databaseTunnelUrl } from './DatabaseTunnelAuthorization.js';
|
|
7
8
|
import { loggerLayer, writeStdoutLine } from './Logger.js';
|
|
8
9
|
import { endPool, makeResourcePool, tunnelEnabled } from './PostgreSqlPool.js';
|
|
9
10
|
import { makeRuntimeResourceClient } from './RuntimeResources.js';
|
|
@@ -11,16 +12,6 @@ export { PostgresqlResource } from './PostgreSqlPool.js';
|
|
|
11
12
|
// A token in its refresh window waits for the provider's next publish. pg's connect timeout is 10 s, so the wait
|
|
12
13
|
// ends with the connection attempt instead of holding the process open.
|
|
13
14
|
const TUNNEL_AUTHORIZATION_TIMEOUT = Duration.seconds(10);
|
|
14
|
-
// The tunnel path keeps literal dots out of the router's file-extension handling, as @ontemper/resources did.
|
|
15
|
-
const tunnelAuthorization = (key) => Effect.gen(function* () {
|
|
16
|
-
const apiUrl = yield* Config.NonEmptyString('UNNBOUND_API_URL');
|
|
17
|
-
const endpoint = new URL(`/api/runtime/databases/${encodeURIComponent(key.replaceAll('.', '%2E'))}/tunnel`, apiUrl);
|
|
18
|
-
if (endpoint.protocol !== 'https:' && endpoint.protocol !== 'http:') {
|
|
19
|
-
return yield* Effect.fail(new Error('Temper API URL must use HTTP or HTTPS.'));
|
|
20
|
-
}
|
|
21
|
-
endpoint.protocol = endpoint.protocol === 'https:' ? 'wss:' : 'ws:';
|
|
22
|
-
return endpoint.href;
|
|
23
|
-
});
|
|
24
15
|
const open = (rawKey) => Effect.gen(function* () {
|
|
25
16
|
const key = rawKey.trim();
|
|
26
17
|
// A workflow's own HttpClient when there is one; resolver calls disable its tracing either way.
|
|
@@ -34,7 +25,7 @@ const open = (rawKey) => Effect.gen(function* () {
|
|
|
34
25
|
resolve: client.resolve,
|
|
35
26
|
inspect: client.inspect,
|
|
36
27
|
authorizeTunnel: tunnel
|
|
37
|
-
? (tunnelKey) => Effect.runPromiseWith(context)(Effect.all({ url:
|
|
28
|
+
? (tunnelKey) => Effect.runPromiseWith(context)(Effect.all({ url: databaseTunnelUrl(tunnelKey), token: client.tunnelToken }).pipe(Effect.timeoutOrElse({
|
|
38
29
|
duration: TUNNEL_AUTHORIZATION_TIMEOUT,
|
|
39
30
|
orElse: () => Effect.fail(new Error('No runtime token for the database tunnel within 10 s.')),
|
|
40
31
|
})))
|
package/dist/PostgreSql.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgreSql.js","sourceRoot":"","sources":["../src/PostgreSql.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,OAAO,EAAE,KAAK,EAAE,MAAM,EAAE,cAAc,EAAE,QAAQ,EAAE,MAAM,EAAE,IAAI,EAAE,KAAK,EAAE,MAAM,EAAc,MAAM,QAAQ,CAAC;AAC1G,OAAO,EAAE,eAAe,EAAE,UAAU,EAAE,MAAM,aAAa,CAAC;AAE1D,OAAO,EAAE,WAAW,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,EAAE,OAAO,EAAE,gBAAgB,EAAE,aAAa,EAAE,MAAM,qBAAqB,CAAC;AAE/E,OAAO,EAAE,yBAAyB,E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CAAC,EAAE,CAAC,IAAI,EAAE,EAAE,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC;AAE5D,4GAA4G;AAC5G,gFAAgF;AAChF,MAAM,UAAU,GAAG,WAAW,CAAC,eAAe,CAAC,CAAC,IAAI,CAClD,KAAK,CAAC,KAAK,EACX,KAAK,CAAC,YAAY,CAAC,cAAc,CAAC,KAAK,CAAC,cAAc,CAAC,aAAa,CAAC,OAAO,CAAC,GAAG,EAAE,EAAE,oBAAoB,EAAE,IAAI,EAAE,CAAC,CAAC,CAAC,CACpH,CAAC;AAEF;;;;GAIG;AACH,MAAM,CAAC,KAAK,UAAU,oBAAoB,CAAC,GAAW;IACpD,MAAM,IAAI,GAAG,MAAM,MAAM,CAAC,cAAc,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,OAAO,CAAC,UAAU,CAAC,CAAC,CAAC,CAAC;IACrF,IAAI,IAAI,CAAC,SAAS,CAAC,IAAI,CAAC;QAAE,OAAO,IAAI,CAAC,KAAK,CAAC;IAC5C,MAAM,KAAK,CAAC,MAAM,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC;AACjC,CAAC"}
|
package/dist/PostgreSqlPool.d.ts
CHANGED
|
@@ -1,46 +1,8 @@
|
|
|
1
1
|
import { type Duration, Effect, Option, Schema } from 'effect';
|
|
2
|
-
import pg from 'pg';
|
|
2
|
+
import type pg from 'pg';
|
|
3
3
|
import { InvalidResourceError } from './ResourcesErrors.js';
|
|
4
4
|
import type { InspectedResource, ReadError } from './RuntimeResources.js';
|
|
5
|
-
|
|
6
|
-
export declare const PostgresqlResource: Schema.Struct<{
|
|
7
|
-
readonly host: Schema.String;
|
|
8
|
-
readonly port: Schema.withDecodingDefaultKey<Schema.Int, never>;
|
|
9
|
-
readonly dbname: Schema.String;
|
|
10
|
-
readonly user: Schema.String;
|
|
11
|
-
readonly auth: Schema.Union<readonly [Schema.Struct<{
|
|
12
|
-
readonly type: Schema.Literal<"password">;
|
|
13
|
-
readonly password: Schema.RedactedFromValue<Schema.String>;
|
|
14
|
-
}>, Schema.Struct<{
|
|
15
|
-
readonly type: Schema.Literal<"rds_iam">;
|
|
16
|
-
readonly region: Schema.String;
|
|
17
|
-
readonly awsAuth: Schema.Union<readonly [Schema.Struct<{
|
|
18
|
-
readonly type: Schema.Literal<"access_key">;
|
|
19
|
-
readonly accessKeyId: Schema.String;
|
|
20
|
-
readonly secretAccessKey: Schema.RedactedFromValue<Schema.String>;
|
|
21
|
-
readonly sessionToken: Schema.optionalKey<Schema.RedactedFromValue<Schema.String>>;
|
|
22
|
-
}>, Schema.Struct<{
|
|
23
|
-
readonly type: Schema.Literal<"assume_role">;
|
|
24
|
-
readonly roleArn: Schema.String;
|
|
25
|
-
readonly externalId: Schema.optionalKey<Schema.String>;
|
|
26
|
-
}>, Schema.Struct<{
|
|
27
|
-
readonly type: Schema.Literal<"ambient">;
|
|
28
|
-
}>]>;
|
|
29
|
-
}>, Schema.Struct<{
|
|
30
|
-
readonly type: Schema.Literal<"none">;
|
|
31
|
-
}>]>;
|
|
32
|
-
readonly sslmode: Schema.withDecodingDefaultKey<Schema.Literals<readonly ["disable", "require", "verify-ca", "verify-full"]>, never>;
|
|
33
|
-
readonly tls: Schema.optionalKey<Schema.Struct<{
|
|
34
|
-
readonly caCertificate: Schema.optionalKey<Schema.String>;
|
|
35
|
-
readonly clientCertificate: Schema.optionalKey<Schema.String>;
|
|
36
|
-
readonly clientKey: Schema.optionalKey<Schema.RedactedFromValue<Schema.String>>;
|
|
37
|
-
readonly clientKeyPassphrase: Schema.optionalKey<Schema.RedactedFromValue<Schema.String>>;
|
|
38
|
-
readonly serverName: Schema.optionalKey<Schema.String>;
|
|
39
|
-
}>>;
|
|
40
|
-
readonly sshTunnel: Schema.optionalKey<Schema.$Record<Schema.String, Schema.Codec<Schema.Json, Schema.Json, never, never>>>;
|
|
41
|
-
readonly options: Schema.optionalKey<Schema.String>;
|
|
42
|
-
}>;
|
|
43
|
-
export type PostgresqlResource = typeof PostgresqlResource.Type;
|
|
5
|
+
export { PostgresqlResource } from './ResourceRecords.js';
|
|
44
6
|
/** Where a pool reads its Resource: the runtime API in a workflow, fixed answers in tests. */
|
|
45
7
|
export interface ResourceSource {
|
|
46
8
|
readonly resolve: (key: string) => Effect.Effect<Schema.Json, ReadError | InvalidResourceError>;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgreSqlPool.d.ts","sourceRoot":"","sources":["../src/PostgreSqlPool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAuB,MAAM,EAAE,MAAM,QAAQ,CAAC;AACpF,OAAO,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"PostgreSqlPool.d.ts","sourceRoot":"","sources":["../src/PostgreSqlPool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,QAAQ,EAAE,MAAM,EAAE,MAAM,EAAuB,MAAM,EAAE,MAAM,QAAQ,CAAC;AACpF,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAIzB,OAAO,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAC5D,OAAO,KAAK,EAAE,iBAAiB,EAAE,SAAS,EAAE,MAAM,uBAAuB,CAAC;AAE1E,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAE1D,8FAA8F;AAC9F,MAAM,WAAW,cAAc;IAC7B,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,IAAI,EAAE,SAAS,GAAG,oBAAoB,CAAC,CAAC;IAChG,oEAAoE;IACpE,QAAQ,CAAC,OAAO,EAAE,CAAC,GAAG,EAAE,MAAM,KAAK,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,iBAAiB,EAAE,UAAU,CAAC,EAAE,SAAS,CAAC,CAAC;IACjG,8FAA8F;IAC9F,QAAQ,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,GAAG,EAAE,MAAM,KAAK,OAAO,CAAC;QAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;QAAC,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAA;KAAE,CAAC,CAAC,GAAG,SAAS,CAAC;CACrH;AAgFD;;;GAGG;AACH,eAAO,MAAM,gBAAgB,QACtB,MAAM,UACH,cAAc,KACrB,MAAM,CAAC,MAAM,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,GAAG,oBAAoB,CAwCtD,CAAC;AAEL,eAAO,MAAM,aAAa,UAAW,MAAM,CAAC,MAAM,CAAC,MAAM,CAAC,YAAwC,CAAC;AAEnG,+GAA+G;AAC/G,eAAO,MAAM,gBAAgB,EAAE,QAAQ,CAAC,KAAoB,CAAC;AAE7D;;;GAGG;AACH,eAAO,MAAM,OAAO,SACZ;IAAE,QAAQ,CAAC,GAAG,EAAE,MAAM,OAAO,CAAC,IAAI,CAAC,CAAA;CAAE,YAClC,QAAQ,CAAC,KAAK,KACtB,MAAM,CAAC,MAAM,CAAC,IAAI,CAUlB,CAAC"}
|
package/dist/PostgreSqlPool.js
CHANGED
|
@@ -1,31 +1,9 @@
|
|
|
1
1
|
import { Effect, Option, Predicate, Redacted, Schema } from 'effect';
|
|
2
|
-
import pg from 'pg';
|
|
3
|
-
import { AwsAuth, TlsSettings } from './HttpApiResource.js';
|
|
4
2
|
import { observePostgreSqlTimeouts } from './PostgreSqlTimeouts.js';
|
|
5
|
-
import { PostgreSqlTunnelStream } from './PostgreSqlTunnel.js';
|
|
6
3
|
import { registerSecrets } from './Redaction.js';
|
|
4
|
+
import { PostgresqlResource } from './ResourceRecords.js';
|
|
7
5
|
import { InvalidResourceError } from './ResourcesErrors.js';
|
|
8
|
-
|
|
9
|
-
const Secret = Schema.RedactedFromValue(Schema.String);
|
|
10
|
-
/** A `postgresql` record as `@ontemper/resources` reads it; `sslmode` carries libpq semantics, and `tls` the CA and client certificate. */
|
|
11
|
-
export const PostgresqlResource = Schema.Struct({
|
|
12
|
-
host: NonEmptyString,
|
|
13
|
-
port: Schema.Int.check(Schema.isBetween({ minimum: 1, maximum: 65_535 })).pipe(Schema.withDecodingDefaultKey(Effect.succeed(5432))),
|
|
14
|
-
dbname: NonEmptyString,
|
|
15
|
-
user: NonEmptyString,
|
|
16
|
-
// Closed: the type decides how the client signs in.
|
|
17
|
-
auth: Schema.Union([
|
|
18
|
-
Schema.Struct({ type: Schema.Literal('password'), password: Secret }),
|
|
19
|
-
Schema.Struct({ type: Schema.Literal('rds_iam'), region: NonEmptyString, awsAuth: AwsAuth }),
|
|
20
|
-
Schema.Struct({ type: Schema.Literal('none') }),
|
|
21
|
-
]),
|
|
22
|
-
// Closed: libpq's weaker `allow` and `prefer` would map to no TLS at all.
|
|
23
|
-
sslmode: Schema.Literals(['disable', 'require', 'verify-ca', 'verify-full']).pipe(Schema.withDecodingDefaultKey(Effect.succeed('verify-full'))),
|
|
24
|
-
tls: Schema.optionalKey(TlsSettings),
|
|
25
|
-
// Only its presence matters: this pool refuses a bastion tunnel.
|
|
26
|
-
sshTunnel: Schema.optionalKey(Schema.Record(Schema.String, Schema.Json)),
|
|
27
|
-
options: Schema.optionalKey(Schema.String),
|
|
28
|
-
});
|
|
6
|
+
export { PostgresqlResource } from './ResourceRecords.js';
|
|
29
7
|
const validate = Schema.toStandardSchemaV1(PostgresqlResource)['~standard'].validate;
|
|
30
8
|
// Names only the failing paths: a schema message can quote the value, which may be a secret.
|
|
31
9
|
const decode = (key, value) => Effect.suspend(() => {
|
|
@@ -75,6 +53,13 @@ const resourcePassword = (key, resource) => {
|
|
|
75
53
|
}
|
|
76
54
|
return Effect.succeed(resource.auth.type === 'password' ? Redacted.value(resource.auth.password) : '');
|
|
77
55
|
};
|
|
56
|
+
// `pg` and `ws` are optional peers, so they load when a pool is built: importing `./resources` needs neither.
|
|
57
|
+
const loadOptional = (name, load) => Effect.tryPromise({
|
|
58
|
+
try: load,
|
|
59
|
+
catch: () => new Error(`PostgreSQL Resource pools need the ${name} package: add ${name} to the workflow dependencies.`),
|
|
60
|
+
}).pipe(Effect.orDie);
|
|
61
|
+
const loadPg = loadOptional('pg', () => import('pg').then((module) => module.default));
|
|
62
|
+
const loadTunnel = loadOptional('ws', () => import('./PostgreSqlTunnel.js'));
|
|
78
63
|
const ManagedPlacement = Schema.Struct({ managedDatabasePlacementId: Schema.String });
|
|
79
64
|
const isManaged = Schema.is(ManagedPlacement);
|
|
80
65
|
// The runtime API answers a missing Variable reference with the same 404 as a missing record, so after a found
|
|
@@ -94,14 +79,16 @@ export const makeResourcePool = (key, source) => Effect.gen(function* () {
|
|
|
94
79
|
yield* registerSecrets([password]);
|
|
95
80
|
const authorize = source.authorizeTunnel;
|
|
96
81
|
const managed = isManaged(record.metadata);
|
|
82
|
+
const driver = yield* loadPg;
|
|
83
|
+
const TunnelStream = managed && authorize ? (yield* loadTunnel).PostgreSqlTunnelStream : undefined;
|
|
97
84
|
const context = yield* Effect.context();
|
|
98
85
|
const warn = (event, message, fields = {}) => {
|
|
99
86
|
Effect.runForkWith(context)(Effect.logWarning(message).pipe(Effect.annotateLogs({ event, ...fields })));
|
|
100
87
|
};
|
|
101
88
|
// Each physical connection reads current runtime authorization, including connections opened after token renewal.
|
|
102
|
-
const stream =
|
|
89
|
+
const stream = TunnelStream && authorize ? () => new TunnelStream(() => authorize(key)) : undefined;
|
|
103
90
|
// A callback prevents pg from substituting ambient PGPASSWORD/pgpass for an empty Resource password.
|
|
104
|
-
const pool = observePostgreSqlTimeouts(new
|
|
91
|
+
const pool = observePostgreSqlTimeouts(driver, new driver.Pool({
|
|
105
92
|
stream,
|
|
106
93
|
host: resource.host,
|
|
107
94
|
port: resource.port,
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgreSqlPool.js","sourceRoot":"","sources":["../src/PostgreSqlPool.ts"],"names":[],"mappings":"AAAA,OAAO,EAAiB,MAAM,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ACN,CACF,CAAC"}
|
|
@@ -1,4 +1,6 @@
|
|
|
1
|
-
import pg from 'pg';
|
|
1
|
+
import type pg from 'pg';
|
|
2
|
+
/** The `pg` classes the observer checks against; the caller passes the module it loaded. */
|
|
3
|
+
export type PgClasses = Pick<typeof pg, 'Client' | 'DatabaseError'>;
|
|
2
4
|
/** Calls `report` once per statement timeout on any connection of the pool, without changing query results. */
|
|
3
|
-
export declare const observePostgreSqlTimeouts: (pool: pg.Pool, report: () => void) => pg.Pool;
|
|
5
|
+
export declare const observePostgreSqlTimeouts: (driver: PgClasses, pool: pg.Pool, report: () => void) => pg.Pool;
|
|
4
6
|
//# sourceMappingURL=PostgreSqlTimeouts.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgreSqlTimeouts.d.ts","sourceRoot":"","sources":["../src/PostgreSqlTimeouts.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,IAAI,CAAC;
|
|
1
|
+
{"version":3,"file":"PostgreSqlTimeouts.d.ts","sourceRoot":"","sources":["../src/PostgreSqlTimeouts.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,IAAI,CAAC;AAEzB,4FAA4F;AAC5F,MAAM,MAAM,SAAS,GAAG,IAAI,CAAC,OAAO,EAAE,EAAE,QAAQ,GAAG,eAAe,CAAC,CAAC;AAEpE,+GAA+G;AAC/G,eAAO,MAAM,yBAAyB,WAAY,SAAS,QAAQ,EAAE,CAAC,IAAI,UAAU,MAAM,IAAI,KAAG,EAAE,CAAC,IAenG,CAAC"}
|
|
@@ -1,12 +1,13 @@
|
|
|
1
|
-
import pg from 'pg';
|
|
2
1
|
/** Calls `report` once per statement timeout on any connection of the pool, without changing query results. */
|
|
3
|
-
export const observePostgreSqlTimeouts = (pool, report) => {
|
|
2
|
+
export const observePostgreSqlTimeouts = (driver, pool, report) => {
|
|
4
3
|
pool.on('connect', (client) => {
|
|
5
|
-
if (!(client instanceof
|
|
4
|
+
if (!(client instanceof driver.Client) || !client.connection)
|
|
6
5
|
return;
|
|
7
6
|
// Wire errors cover pool, checked-out client, and callback queries without changing their return values.
|
|
8
7
|
client.connection.on('errorMessage', (error) => {
|
|
9
|
-
if (error instanceof
|
|
8
|
+
if (error instanceof driver.DatabaseError &&
|
|
9
|
+
error.code === '57014' &&
|
|
10
|
+
error.message.includes('statement timeout')) {
|
|
10
11
|
report();
|
|
11
12
|
}
|
|
12
13
|
});
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"PostgreSqlTimeouts.js","sourceRoot":"","sources":["../src/PostgreSqlTimeouts.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"PostgreSqlTimeouts.js","sourceRoot":"","sources":["../src/PostgreSqlTimeouts.ts"],"names":[],"mappings":"AAKA,+GAA+G;AAC/G,MAAM,CAAC,MAAM,yBAAyB,GAAG,CAAC,MAAiB,EAAE,IAAa,EAAE,MAAkB,EAAW,EAAE;IACzG,IAAI,CAAC,EAAE,CAAC,SAAS,EAAE,CAAC,MAAM,EAAE,EAAE;QAC5B,IAAI,CAAC,CAAC,MAAM,YAAY,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,MAAM,CAAC,UAAU;YAAE,OAAO;QACrE,yGAAyG;QACzG,MAAM,CAAC,UAAU,CAAC,EAAE,CAAC,cAAc,EAAE,CAAC,KAAY,EAAE,EAAE;YACpD,IACE,KAAK,YAAY,MAAM,CAAC,aAAa;gBACrC,KAAK,CAAC,IAAI,KAAK,OAAO;gBACtB,KAAK,CAAC,OAAO,CAAC,QAAQ,CAAC,mBAAmB,CAAC,EAC3C,CAAC;gBACD,MAAM,EAAE,CAAC;YACX,CAAC;QACH,CAAC,CAAC,CAAC;IACL,CAAC,CAAC,CAAC;IACH,OAAO,IAAI,CAAC;AACd,CAAC,CAAC"}
|
package/dist/Redaction.d.ts
CHANGED
|
@@ -17,6 +17,8 @@ export interface SecretMasks {
|
|
|
17
17
|
readonly mask: (text: string) => string;
|
|
18
18
|
}
|
|
19
19
|
export declare const makeSecretMasks: () => SecretMasks;
|
|
20
|
+
/** A module's own registry that also masks every secret registered process-wide, in one longest-first pass. */
|
|
21
|
+
export declare const makeWorkflowSecretMasks: () => SecretMasks;
|
|
20
22
|
/** `workflow()` installs one registry per module, so a secret seen by one request stays masked in every later one. */
|
|
21
23
|
export declare const SecretMasks: Context.Reference<SecretMasks>;
|
|
22
24
|
/**
|