@hasna/shortlinks 0.2.2 → 0.2.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/dist/cli/index.js +40 -249
- package/dist/serve/index.js +161 -197
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -2894,7 +2894,7 @@ async function upsertCloudflareDnsRecord(options) {
|
|
|
2894
2894
|
return { id: created.id, action: "created" };
|
|
2895
2895
|
}
|
|
2896
2896
|
|
|
2897
|
-
// node_modules
|
|
2897
|
+
// node_modules/@hasna/events/dist/commander.js
|
|
2898
2898
|
import { chmod, mkdir, readFile, rename, writeFile } from "fs/promises";
|
|
2899
2899
|
import { existsSync as existsSync3 } from "fs";
|
|
2900
2900
|
import { homedir as homedir2 } from "os";
|
|
@@ -2911,83 +2911,29 @@ function getPathValue(input, path) {
|
|
|
2911
2911
|
return;
|
|
2912
2912
|
}, input);
|
|
2913
2913
|
}
|
|
2914
|
-
function
|
|
2915
|
-
const
|
|
2916
|
-
|
|
2917
|
-
if (!values.some((item) => Object.is(item, value)))
|
|
2918
|
-
values.push(value);
|
|
2919
|
-
};
|
|
2920
|
-
if (path.includes(".") && path in input)
|
|
2921
|
-
push(input[path]);
|
|
2922
|
-
const nestedValue = getPathValue(input, path);
|
|
2923
|
-
if (nestedValue !== undefined || !path.includes("."))
|
|
2924
|
-
push(nestedValue);
|
|
2925
|
-
return values;
|
|
2926
|
-
}
|
|
2927
|
-
function wildcardToRegExp(pattern, options = {}) {
|
|
2928
|
-
let body = "";
|
|
2929
|
-
for (let index = 0;index < pattern.length; index += 1) {
|
|
2930
|
-
const char = pattern[index];
|
|
2931
|
-
if (char === "*") {
|
|
2932
|
-
if (pattern[index + 1] === "*") {
|
|
2933
|
-
body += ".*";
|
|
2934
|
-
index += 1;
|
|
2935
|
-
} else {
|
|
2936
|
-
body += options.segmentSafe ? "[^/]*" : ".*";
|
|
2937
|
-
}
|
|
2938
|
-
} else {
|
|
2939
|
-
body += char.replace(/[|\\{}()[\]^$+?.]/g, "\\$&");
|
|
2940
|
-
}
|
|
2941
|
-
}
|
|
2942
|
-
return new RegExp(`^${body}$`);
|
|
2914
|
+
function wildcardToRegExp(pattern) {
|
|
2915
|
+
const escaped = pattern.replace(/[|\\{}()[\]^$+?.]/g, "\\$&").replace(/\*/g, ".*");
|
|
2916
|
+
return new RegExp(`^${escaped}$`);
|
|
2943
2917
|
}
|
|
2944
|
-
function matchString(value, matcher
|
|
2918
|
+
function matchString(value, matcher) {
|
|
2945
2919
|
if (matcher === undefined)
|
|
2946
2920
|
return true;
|
|
2947
2921
|
if (value === undefined)
|
|
2948
2922
|
return false;
|
|
2949
2923
|
const matchers = Array.isArray(matcher) ? matcher : [matcher];
|
|
2950
|
-
return matchers.some((item) => wildcardToRegExp(item
|
|
2924
|
+
return matchers.some((item) => wildcardToRegExp(item).test(value));
|
|
2951
2925
|
}
|
|
2952
2926
|
function matchRecord(input, matcher) {
|
|
2953
2927
|
if (!matcher)
|
|
2954
2928
|
return true;
|
|
2955
2929
|
return Object.entries(matcher).every(([path, expected]) => {
|
|
2956
|
-
const
|
|
2957
|
-
|
|
2930
|
+
const actual = getPathValue(input, path);
|
|
2931
|
+
if (typeof expected === "string" || Array.isArray(expected)) {
|
|
2932
|
+
return matchString(actual === undefined ? undefined : String(actual), expected);
|
|
2933
|
+
}
|
|
2934
|
+
return actual === expected;
|
|
2958
2935
|
});
|
|
2959
2936
|
}
|
|
2960
|
-
function matchField(actualValues, expected, path) {
|
|
2961
|
-
if (isNegativeMatcher(expected)) {
|
|
2962
|
-
return !actualValues.some((actual) => matchPositiveField(actual, expected.not, path));
|
|
2963
|
-
}
|
|
2964
|
-
return actualValues.some((actual) => matchPositiveField(actual, expected, path));
|
|
2965
|
-
}
|
|
2966
|
-
function matchPositiveField(actual, expected, path) {
|
|
2967
|
-
if (typeof expected === "string" || Array.isArray(expected)) {
|
|
2968
|
-
return stringCandidates(actual).some((candidate) => matchString(candidate, expected, {
|
|
2969
|
-
segmentSafe: path.endsWith("_path") || path.endsWith(".path")
|
|
2970
|
-
}));
|
|
2971
|
-
}
|
|
2972
|
-
if (Array.isArray(actual)) {
|
|
2973
|
-
return actual.some((item) => item === expected);
|
|
2974
|
-
}
|
|
2975
|
-
return actual === expected;
|
|
2976
|
-
}
|
|
2977
|
-
function stringCandidates(actual) {
|
|
2978
|
-
if (actual === undefined)
|
|
2979
|
-
return [];
|
|
2980
|
-
if (Array.isArray(actual)) {
|
|
2981
|
-
return actual.flatMap((item) => isPrimitiveFieldValue(item) ? [String(item)] : []);
|
|
2982
|
-
}
|
|
2983
|
-
return [String(actual)];
|
|
2984
|
-
}
|
|
2985
|
-
function isPrimitiveFieldValue(value) {
|
|
2986
|
-
return value === null || typeof value === "string" || typeof value === "number" || typeof value === "boolean";
|
|
2987
|
-
}
|
|
2988
|
-
function isNegativeMatcher(value) {
|
|
2989
|
-
return Boolean(value && typeof value === "object" && !Array.isArray(value) && "not" in value);
|
|
2990
|
-
}
|
|
2991
2937
|
function eventMatchesFilter(event, filter) {
|
|
2992
2938
|
return matchString(event.source, filter.source) && matchString(event.type, filter.type) && matchString(event.subject, filter.subject) && matchString(event.severity, filter.severity) && matchRecord(event.data, filter.data) && matchRecord(event.metadata, filter.metadata);
|
|
2993
2939
|
}
|
|
@@ -3003,13 +2949,6 @@ var HASNA_EVENTS_HOME_ENV = "HASNA_EVENTS_HOME";
|
|
|
3003
2949
|
function getEventsDataDir(override) {
|
|
3004
2950
|
return override || process.env[HASNA_EVENTS_DIR_ENV] || process.env[HASNA_EVENTS_HOME_ENV] || join4(homedir2(), ".hasna", "events");
|
|
3005
2951
|
}
|
|
3006
|
-
function getActiveEventsDirEnv() {
|
|
3007
|
-
if (process.env[HASNA_EVENTS_DIR_ENV])
|
|
3008
|
-
return HASNA_EVENTS_DIR_ENV;
|
|
3009
|
-
if (process.env[HASNA_EVENTS_HOME_ENV])
|
|
3010
|
-
return HASNA_EVENTS_HOME_ENV;
|
|
3011
|
-
return null;
|
|
3012
|
-
}
|
|
3013
2952
|
|
|
3014
2953
|
class JsonEventsStore {
|
|
3015
2954
|
dataDir;
|
|
@@ -3122,52 +3061,6 @@ class JsonEventsStore {
|
|
|
3122
3061
|
});
|
|
3123
3062
|
}
|
|
3124
3063
|
}
|
|
3125
|
-
async function getEventsStatus(dataDir) {
|
|
3126
|
-
const store = new JsonEventsStore(dataDir);
|
|
3127
|
-
await store.init();
|
|
3128
|
-
const [channels, events, deliveries] = await Promise.all([
|
|
3129
|
-
store.listChannels(),
|
|
3130
|
-
store.listEvents(),
|
|
3131
|
-
store.listDeliveries()
|
|
3132
|
-
]);
|
|
3133
|
-
const transports = channels.reduce((counts, channel) => {
|
|
3134
|
-
counts[channel.transport] = (counts[channel.transport] ?? 0) + 1;
|
|
3135
|
-
return counts;
|
|
3136
|
-
}, {});
|
|
3137
|
-
return {
|
|
3138
|
-
service: "events",
|
|
3139
|
-
schemaVersion: "1.0",
|
|
3140
|
-
dataDir: store.dataDir,
|
|
3141
|
-
env: {
|
|
3142
|
-
primary: HASNA_EVENTS_DIR_ENV,
|
|
3143
|
-
fallback: HASNA_EVENTS_HOME_ENV,
|
|
3144
|
-
active: getActiveEventsDirEnv()
|
|
3145
|
-
},
|
|
3146
|
-
files: {
|
|
3147
|
-
channels: statusFile(store.dataDir, "channels.json", channels.length),
|
|
3148
|
-
events: statusFile(store.dataDir, "events.json", events.length),
|
|
3149
|
-
deliveries: statusFile(store.dataDir, "deliveries.json", deliveries.length)
|
|
3150
|
-
},
|
|
3151
|
-
counts: {
|
|
3152
|
-
channels: channels.length,
|
|
3153
|
-
enabledChannels: channels.filter((channel) => channel.enabled).length,
|
|
3154
|
-
disabledChannels: channels.filter((channel) => !channel.enabled).length,
|
|
3155
|
-
events: events.length,
|
|
3156
|
-
deliveries: deliveries.length
|
|
3157
|
-
},
|
|
3158
|
-
transports,
|
|
3159
|
-
safety: {
|
|
3160
|
-
includesEventPayloads: false,
|
|
3161
|
-
includesWebhookSecrets: false,
|
|
3162
|
-
listOutputsRedactSecrets: true,
|
|
3163
|
-
statusOutputIsMetadataOnly: true
|
|
3164
|
-
}
|
|
3165
|
-
};
|
|
3166
|
-
}
|
|
3167
|
-
function statusFile(dataDir, fileName, records) {
|
|
3168
|
-
const path = join4(dataDir, fileName);
|
|
3169
|
-
return { path, exists: existsSync3(path), records };
|
|
3170
|
-
}
|
|
3171
3064
|
var DEFAULT_SIGNATURE_TOLERANCE_MS = 5 * 60 * 1000;
|
|
3172
3065
|
function buildSignatureBase(timestamp, body) {
|
|
3173
3066
|
return `${timestamp}.${body}`;
|
|
@@ -3393,7 +3286,7 @@ class EventsClient {
|
|
|
3393
3286
|
}
|
|
3394
3287
|
return deliveries;
|
|
3395
3288
|
}
|
|
3396
|
-
async
|
|
3289
|
+
async testChannel(id, input = {}) {
|
|
3397
3290
|
const channel = await this.store.getChannel(id);
|
|
3398
3291
|
if (!channel)
|
|
3399
3292
|
throw new Error(`Channel not found: ${id}`);
|
|
@@ -3410,34 +3303,6 @@ class EventsClient {
|
|
|
3410
3303
|
time: input.time,
|
|
3411
3304
|
id: input.id
|
|
3412
3305
|
});
|
|
3413
|
-
const matched = channelMatchesEvent(channel, event);
|
|
3414
|
-
return {
|
|
3415
|
-
channelId: channel.id,
|
|
3416
|
-
matched,
|
|
3417
|
-
event,
|
|
3418
|
-
filters: channel.filters,
|
|
3419
|
-
reason: matched ? undefined : channel.enabled ? "event did not match channel filters" : "channel is disabled"
|
|
3420
|
-
};
|
|
3421
|
-
}
|
|
3422
|
-
async testChannel(id, input = {}, options = {}) {
|
|
3423
|
-
const channel = await this.store.getChannel(id);
|
|
3424
|
-
if (!channel)
|
|
3425
|
-
throw new Error(`Channel not found: ${id}`);
|
|
3426
|
-
const match = await this.matchChannel(id, input);
|
|
3427
|
-
const event = match.event;
|
|
3428
|
-
if (options.honorFilters && !match.matched) {
|
|
3429
|
-
const timestamp = new Date().toISOString();
|
|
3430
|
-
const result2 = createDeliveryResult(event, channel, [{
|
|
3431
|
-
attempt: 1,
|
|
3432
|
-
status: "skipped",
|
|
3433
|
-
startedAt: timestamp,
|
|
3434
|
-
completedAt: timestamp,
|
|
3435
|
-
error: match.reason
|
|
3436
|
-
}]);
|
|
3437
|
-
result2.metadata = { reason: "filter_mismatch" };
|
|
3438
|
-
await this.store.appendDelivery(result2);
|
|
3439
|
-
return result2;
|
|
3440
|
-
}
|
|
3441
3306
|
const eventForChannel = await this.applyRedaction(event, channel);
|
|
3442
3307
|
const result = await this.deliverWithRetry(eventForChannel, channel);
|
|
3443
3308
|
await this.store.appendDelivery(result);
|
|
@@ -3548,76 +3413,6 @@ function normalizeRetryPolicy(policy) {
|
|
|
3548
3413
|
multiplier: Math.max(1, policy?.multiplier ?? 2)
|
|
3549
3414
|
};
|
|
3550
3415
|
}
|
|
3551
|
-
function parseFieldMatchers(values, label, typed = false) {
|
|
3552
|
-
if (!values?.length)
|
|
3553
|
-
return;
|
|
3554
|
-
const result = {};
|
|
3555
|
-
for (const value of values) {
|
|
3556
|
-
const parsed = parseMatcherExpression(value, label);
|
|
3557
|
-
const path = parsed.path;
|
|
3558
|
-
if (path in result)
|
|
3559
|
-
throw new Error(`Duplicate ${label} filter path: ${path}`);
|
|
3560
|
-
const matcherValue = typed ? parseTypedMatcherValue(parsed.rawValue, label) : parsed.rawValue;
|
|
3561
|
-
result[path] = parsed.negated ? { not: matcherValue } : matcherValue;
|
|
3562
|
-
}
|
|
3563
|
-
return result;
|
|
3564
|
-
}
|
|
3565
|
-
function parseFilterOptions(options) {
|
|
3566
|
-
const filter2 = {};
|
|
3567
|
-
if (options.source)
|
|
3568
|
-
filter2.source = options.source;
|
|
3569
|
-
if (options.type)
|
|
3570
|
-
filter2.type = options.type;
|
|
3571
|
-
if (options.subject)
|
|
3572
|
-
filter2.subject = options.subject;
|
|
3573
|
-
if (options.severity)
|
|
3574
|
-
filter2.severity = options.severity;
|
|
3575
|
-
const data = mergeMatchers(parseFieldMatchers(options.data, "data"), parseFieldMatchers(options.dataJson, "data-json", true));
|
|
3576
|
-
const metadata = mergeMatchers(parseFieldMatchers(options.metadata, "metadata"), parseFieldMatchers(options.metadataJson, "metadata-json", true));
|
|
3577
|
-
if (Object.keys(data).length > 0)
|
|
3578
|
-
filter2.data = data;
|
|
3579
|
-
if (Object.keys(metadata).length > 0)
|
|
3580
|
-
filter2.metadata = metadata;
|
|
3581
|
-
return Object.keys(filter2).length > 0 ? [filter2] : undefined;
|
|
3582
|
-
}
|
|
3583
|
-
function mergeMatchers(...records) {
|
|
3584
|
-
const result = {};
|
|
3585
|
-
for (const record of records) {
|
|
3586
|
-
if (!record)
|
|
3587
|
-
continue;
|
|
3588
|
-
for (const [path, value] of Object.entries(record)) {
|
|
3589
|
-
if (path in result)
|
|
3590
|
-
throw new Error(`Duplicate filter path: ${path}`);
|
|
3591
|
-
result[path] = value;
|
|
3592
|
-
}
|
|
3593
|
-
}
|
|
3594
|
-
return result;
|
|
3595
|
-
}
|
|
3596
|
-
function parseTypedMatcherValue(value, label) {
|
|
3597
|
-
const parsed = JSON.parse(value);
|
|
3598
|
-
if (parsed === null || typeof parsed === "string" || typeof parsed === "number" || typeof parsed === "boolean" || Array.isArray(parsed) && parsed.every((item) => typeof item === "string")) {
|
|
3599
|
-
return parsed;
|
|
3600
|
-
}
|
|
3601
|
-
throw new Error(`${label} filter JSON values must be string, string[], number, boolean, or null`);
|
|
3602
|
-
}
|
|
3603
|
-
function parseMatcherExpression(value, label) {
|
|
3604
|
-
const negativeSeparator = value.indexOf("!=");
|
|
3605
|
-
if (negativeSeparator > 0) {
|
|
3606
|
-
return {
|
|
3607
|
-
path: value.slice(0, negativeSeparator),
|
|
3608
|
-
rawValue: value.slice(negativeSeparator + 2),
|
|
3609
|
-
negated: true
|
|
3610
|
-
};
|
|
3611
|
-
}
|
|
3612
|
-
const separator = value.indexOf("=");
|
|
3613
|
-
if (separator <= 0)
|
|
3614
|
-
throw new Error(`Invalid ${label} filter, expected path=value or path!=value: ${value}`);
|
|
3615
|
-
return {
|
|
3616
|
-
path: value.slice(0, separator),
|
|
3617
|
-
rawValue: value.slice(separator + 1),
|
|
3618
|
-
negated: false
|
|
3619
|
-
};
|
|
3620
|
-
}
|
|
3621
3416
|
function parseJsonObject2(value, fallback) {
|
|
3622
3417
|
if (!value)
|
|
3623
3418
|
return fallback;
|
|
@@ -3639,6 +3434,18 @@ function parseHeaders(values) {
|
|
|
3639
3434
|
}
|
|
3640
3435
|
return headers;
|
|
3641
3436
|
}
|
|
3437
|
+
function parseFilter(options) {
|
|
3438
|
+
const filter2 = {};
|
|
3439
|
+
if (options.source)
|
|
3440
|
+
filter2.source = options.source;
|
|
3441
|
+
if (options.type)
|
|
3442
|
+
filter2.type = options.type;
|
|
3443
|
+
if (options.subject)
|
|
3444
|
+
filter2.subject = options.subject;
|
|
3445
|
+
if (options.severity)
|
|
3446
|
+
filter2.severity = options.severity;
|
|
3447
|
+
return Object.keys(filter2).length > 0 ? [filter2] : undefined;
|
|
3448
|
+
}
|
|
3642
3449
|
function createClient(options) {
|
|
3643
3450
|
if (options.createClient)
|
|
3644
3451
|
return options.createClient();
|
|
@@ -3656,16 +3463,16 @@ function hasJsonOption(options) {
|
|
|
3656
3463
|
function wantsJson(actionOptions, command) {
|
|
3657
3464
|
return hasJsonOption(actionOptions) || hasJsonOption(command);
|
|
3658
3465
|
}
|
|
3659
|
-
function
|
|
3660
|
-
const
|
|
3661
|
-
|
|
3466
|
+
function registerWebhookCommands(program, options) {
|
|
3467
|
+
const webhooks = program.command(options.webhooksCommandName ?? "webhooks").description("Manage Hasna event webhook subscriptions");
|
|
3468
|
+
webhooks.command("add").description("Add or replace a webhook or command subscription").argument("<target>", "Webhook URL or command binary").requiredOption("--id <id>", "Subscription/channel identifier").option("--transport <kind>", "Transport kind: webhook or command", "webhook").option("--name <name>", "Display name").option("--type <pattern>", "Event type filter, e.g. todos.task.*").option("--source <pattern>", "Event source filter").option("--subject <pattern>", "Event subject filter").option("--severity <pattern>", "Event severity filter").option("--secret <secret>", "Webhook HMAC secret").option("--header <name=value...>", "Webhook header", collectValues, []).option("--arg <arg...>", "Command argument", collectValues, []).option("--timeout-ms <ms>", "Transport timeout in milliseconds", parseNumber).option("--retry-attempts <n>", "Maximum delivery attempts", parseNumber).option("--retry-backoff-ms <ms>", "Initial retry backoff in milliseconds", parseNumber).option("--redact <path...>", "Event field path to redact before delivery", collectValues, []).option("--disabled", "Create channel disabled", false).option("-j, --json", "Print JSON output", false).action(async (target, actionOptions, command) => {
|
|
3662
3469
|
const timestamp = new Date().toISOString();
|
|
3663
3470
|
const channel = {
|
|
3664
3471
|
id: actionOptions.id,
|
|
3665
3472
|
name: actionOptions.name,
|
|
3666
3473
|
enabled: !actionOptions.disabled,
|
|
3667
3474
|
transport: actionOptions.transport,
|
|
3668
|
-
filters:
|
|
3475
|
+
filters: parseFilter(actionOptions),
|
|
3669
3476
|
retry: actionOptions.retryAttempts || actionOptions.retryBackoffMs ? { maxAttempts: actionOptions.retryAttempts, backoffMs: actionOptions.retryBackoffMs } : undefined,
|
|
3670
3477
|
redact: actionOptions.redact?.length ? { paths: actionOptions.redact } : undefined,
|
|
3671
3478
|
createdAt: timestamp,
|
|
@@ -3681,51 +3488,35 @@ function registerChannelCommands(program, options) {
|
|
|
3681
3488
|
const saved = await createClient(options).addChannel(channel);
|
|
3682
3489
|
print(sanitizeChannelForOutput(saved), wantsJson(actionOptions, command), `Added ${saved.transport} channel ${saved.id}`);
|
|
3683
3490
|
});
|
|
3684
|
-
|
|
3685
|
-
const
|
|
3491
|
+
webhooks.command("list").description("List configured subscriptions").option("-j, --json", "Print JSON output", false).action(async (actionOptions, command) => {
|
|
3492
|
+
const channels = await createClient(options).listChannels();
|
|
3686
3493
|
if (wantsJson(actionOptions, command)) {
|
|
3687
|
-
console.log(JSON.stringify(sanitizeChannelsForOutput(
|
|
3494
|
+
console.log(JSON.stringify(sanitizeChannelsForOutput(channels), null, 2));
|
|
3688
3495
|
return;
|
|
3689
3496
|
}
|
|
3690
|
-
if (!
|
|
3497
|
+
if (!channels.length) {
|
|
3691
3498
|
console.log("No channels configured.");
|
|
3692
3499
|
return;
|
|
3693
3500
|
}
|
|
3694
|
-
for (const channel of
|
|
3501
|
+
for (const channel of channels) {
|
|
3695
3502
|
console.log(`${channel.id} ${channel.enabled ? "enabled" : "disabled"} ${channel.transport} ${channel.webhook?.url ?? channel.command?.command ?? channel.transport}`);
|
|
3696
3503
|
}
|
|
3697
3504
|
});
|
|
3698
|
-
|
|
3699
|
-
const status = await getEventsStatus(options.dataDir);
|
|
3700
|
-
print(status, wantsJson(actionOptions, command), `events dataDir: ${status.dataDir}`);
|
|
3701
|
-
});
|
|
3702
|
-
channels.command("remove").description("Remove a channel").argument("<id>", "Channel identifier").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions, command) => {
|
|
3505
|
+
webhooks.command("remove").description("Remove a subscription").argument("<id>", "Subscription/channel identifier").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions, command) => {
|
|
3703
3506
|
const removed = await createClient(options).removeChannel(id);
|
|
3704
3507
|
print({ removed }, wantsJson(actionOptions, command), removed ? `Removed ${id}` : `Channel not found: ${id}`);
|
|
3705
3508
|
});
|
|
3706
|
-
|
|
3509
|
+
webhooks.command("test").description("Send a test event to one subscription").argument("<id>", "Subscription/channel identifier").option("--type <type>", "Event type", "events.test").option("--subject <subject>", "Event subject").option("--message <message>", "Event message", "Hasna events test delivery").option("--data <json>", "Event data JSON object").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions, command) => {
|
|
3707
3510
|
const result = await createClient(options).testChannel(id, {
|
|
3708
|
-
source:
|
|
3709
|
-
type: actionOptions.type,
|
|
3710
|
-
subject: actionOptions.subject ?? id,
|
|
3711
|
-
message: actionOptions.message,
|
|
3712
|
-
data: parseJsonObject2(actionOptions.data, { test: true }),
|
|
3713
|
-
metadata: parseJsonObject2(actionOptions.metadata, {})
|
|
3714
|
-
}, { honorFilters: actionOptions.honorFilters });
|
|
3715
|
-
print(result, wantsJson(actionOptions, command), `${result.status}: ${result.channelId}`);
|
|
3716
|
-
});
|
|
3717
|
-
channels.command("match").description("Check whether a sample event matches one channel without delivering").argument("<id>", "Channel identifier").option("--source <source>", "Event source override").option("--type <type>", "Event type", "events.test").option("--subject <subject>", "Event subject").option("--message <message>", "Event message", "Hasna events match preview").option("--data <json>", "Event data JSON object").option("--metadata <json>", "Event metadata JSON object").option("-j, --json", "Print JSON output", false).action(async (id, actionOptions, command) => {
|
|
3718
|
-
const result = await createClient(options).matchChannel(id, {
|
|
3719
|
-
source: actionOptions.source ?? options.source,
|
|
3511
|
+
source: options.source,
|
|
3720
3512
|
type: actionOptions.type,
|
|
3721
3513
|
subject: actionOptions.subject ?? id,
|
|
3722
3514
|
message: actionOptions.message,
|
|
3723
|
-
data: parseJsonObject2(actionOptions.data, { test: true })
|
|
3724
|
-
metadata: parseJsonObject2(actionOptions.metadata, {})
|
|
3515
|
+
data: parseJsonObject2(actionOptions.data, { test: true })
|
|
3725
3516
|
});
|
|
3726
|
-
print(result, wantsJson(actionOptions, command), `${result.
|
|
3517
|
+
print(result, wantsJson(actionOptions, command), `${result.status}: ${result.channelId}`);
|
|
3727
3518
|
});
|
|
3728
|
-
return
|
|
3519
|
+
return webhooks;
|
|
3729
3520
|
}
|
|
3730
3521
|
function registerEventCommands(program, options) {
|
|
3731
3522
|
const events = program.command(options.eventsCommandName ?? "events").description("Emit, list, and replay Hasna events");
|
|
@@ -3773,7 +3564,7 @@ function registerEventCommands(program, options) {
|
|
|
3773
3564
|
return events;
|
|
3774
3565
|
}
|
|
3775
3566
|
function registerEventsCommands(program, options) {
|
|
3776
|
-
|
|
3567
|
+
registerWebhookCommands(program, options);
|
|
3777
3568
|
registerEventCommands(program, options);
|
|
3778
3569
|
}
|
|
3779
3570
|
function parseNumber(value) {
|
package/dist/serve/index.js
CHANGED
|
@@ -33,7 +33,7 @@ var __toESM = (mod, isNodeMode, target) => {
|
|
|
33
33
|
var __commonJS = (cb, mod) => () => (mod || cb((mod = { exports: {} }).exports, mod), mod.exports);
|
|
34
34
|
var __require = import.meta.require;
|
|
35
35
|
|
|
36
|
-
// node_modules
|
|
36
|
+
// node_modules/postgres-array/index.js
|
|
37
37
|
var require_postgres_array = __commonJS((exports) => {
|
|
38
38
|
exports.parse = function(source, transform) {
|
|
39
39
|
return new ArrayParser(source, transform).parse();
|
|
@@ -129,7 +129,7 @@ var require_postgres_array = __commonJS((exports) => {
|
|
|
129
129
|
}
|
|
130
130
|
});
|
|
131
131
|
|
|
132
|
-
// node_modules
|
|
132
|
+
// node_modules/pg-types/lib/arrayParser.js
|
|
133
133
|
var require_arrayParser = __commonJS((exports, module) => {
|
|
134
134
|
var array = require_postgres_array();
|
|
135
135
|
module.exports = {
|
|
@@ -143,7 +143,7 @@ var require_arrayParser = __commonJS((exports, module) => {
|
|
|
143
143
|
};
|
|
144
144
|
});
|
|
145
145
|
|
|
146
|
-
// node_modules
|
|
146
|
+
// node_modules/postgres-date/index.js
|
|
147
147
|
var require_postgres_date = __commonJS((exports, module) => {
|
|
148
148
|
var DATE_TIME = /(\d{1,})-(\d{2})-(\d{2}) (\d{2}):(\d{2}):(\d{2})(\.\d{1,})?.*?( BC)?$/;
|
|
149
149
|
var DATE = /^(\d{1,})-(\d{2})-(\d{2})( BC)?$/;
|
|
@@ -228,7 +228,7 @@ var require_postgres_date = __commonJS((exports, module) => {
|
|
|
228
228
|
}
|
|
229
229
|
});
|
|
230
230
|
|
|
231
|
-
// node_modules
|
|
231
|
+
// node_modules/xtend/mutable.js
|
|
232
232
|
var require_mutable = __commonJS((exports, module) => {
|
|
233
233
|
module.exports = extend;
|
|
234
234
|
var hasOwnProperty = Object.prototype.hasOwnProperty;
|
|
@@ -245,7 +245,7 @@ var require_mutable = __commonJS((exports, module) => {
|
|
|
245
245
|
}
|
|
246
246
|
});
|
|
247
247
|
|
|
248
|
-
// node_modules
|
|
248
|
+
// node_modules/postgres-interval/index.js
|
|
249
249
|
var require_postgres_interval = __commonJS((exports, module) => {
|
|
250
250
|
var extend = require_mutable();
|
|
251
251
|
module.exports = PostgresInterval;
|
|
@@ -337,7 +337,7 @@ var require_postgres_interval = __commonJS((exports, module) => {
|
|
|
337
337
|
}
|
|
338
338
|
});
|
|
339
339
|
|
|
340
|
-
// node_modules
|
|
340
|
+
// node_modules/postgres-bytea/index.js
|
|
341
341
|
var require_postgres_bytea = __commonJS((exports, module) => {
|
|
342
342
|
var bufferFrom = Buffer.from || Buffer;
|
|
343
343
|
module.exports = function parseBytea(input) {
|
|
@@ -370,7 +370,7 @@ var require_postgres_bytea = __commonJS((exports, module) => {
|
|
|
370
370
|
};
|
|
371
371
|
});
|
|
372
372
|
|
|
373
|
-
// node_modules
|
|
373
|
+
// node_modules/pg-types/lib/textParsers.js
|
|
374
374
|
var require_textParsers = __commonJS((exports, module) => {
|
|
375
375
|
var array = require_postgres_array();
|
|
376
376
|
var arrayParser = require_arrayParser();
|
|
@@ -573,7 +573,7 @@ var require_textParsers = __commonJS((exports, module) => {
|
|
|
573
573
|
};
|
|
574
574
|
});
|
|
575
575
|
|
|
576
|
-
// node_modules
|
|
576
|
+
// node_modules/pg-int8/index.js
|
|
577
577
|
var require_pg_int8 = __commonJS((exports, module) => {
|
|
578
578
|
var BASE = 1e6;
|
|
579
579
|
function readInt8(buffer) {
|
|
@@ -650,7 +650,7 @@ var require_pg_int8 = __commonJS((exports, module) => {
|
|
|
650
650
|
module.exports = readInt8;
|
|
651
651
|
});
|
|
652
652
|
|
|
653
|
-
// node_modules
|
|
653
|
+
// node_modules/pg-types/lib/binaryParsers.js
|
|
654
654
|
var require_binaryParsers = __commonJS((exports, module) => {
|
|
655
655
|
var parseInt64 = require_pg_int8();
|
|
656
656
|
var parseBits = function(data, bits, offset, invert, callback) {
|
|
@@ -849,7 +849,7 @@ var require_binaryParsers = __commonJS((exports, module) => {
|
|
|
849
849
|
};
|
|
850
850
|
});
|
|
851
851
|
|
|
852
|
-
// node_modules
|
|
852
|
+
// node_modules/pg-types/lib/builtins.js
|
|
853
853
|
var require_builtins = __commonJS((exports, module) => {
|
|
854
854
|
module.exports = {
|
|
855
855
|
BOOL: 16,
|
|
@@ -915,7 +915,7 @@ var require_builtins = __commonJS((exports, module) => {
|
|
|
915
915
|
};
|
|
916
916
|
});
|
|
917
917
|
|
|
918
|
-
// node_modules
|
|
918
|
+
// node_modules/pg-types/index.js
|
|
919
919
|
var require_pg_types = __commonJS((exports) => {
|
|
920
920
|
var textParsers = require_textParsers();
|
|
921
921
|
var binaryParsers = require_binaryParsers();
|
|
@@ -954,7 +954,7 @@ var require_pg_types = __commonJS((exports) => {
|
|
|
954
954
|
});
|
|
955
955
|
});
|
|
956
956
|
|
|
957
|
-
// node_modules
|
|
957
|
+
// node_modules/pg/lib/defaults.js
|
|
958
958
|
var require_defaults = __commonJS((exports, module) => {
|
|
959
959
|
var user;
|
|
960
960
|
try {
|
|
@@ -973,7 +973,6 @@ var require_defaults = __commonJS((exports, module) => {
|
|
|
973
973
|
idleTimeoutMillis: 30000,
|
|
974
974
|
client_encoding: "",
|
|
975
975
|
ssl: false,
|
|
976
|
-
sslnegotiation: undefined,
|
|
977
976
|
application_name: undefined,
|
|
978
977
|
fallback_application_name: undefined,
|
|
979
978
|
options: undefined,
|
|
@@ -995,10 +994,11 @@ var require_defaults = __commonJS((exports, module) => {
|
|
|
995
994
|
});
|
|
996
995
|
});
|
|
997
996
|
|
|
998
|
-
// node_modules
|
|
997
|
+
// node_modules/pg/lib/utils.js
|
|
999
998
|
var require_utils = __commonJS((exports, module) => {
|
|
1000
999
|
var defaults = require_defaults();
|
|
1001
|
-
var
|
|
1000
|
+
var util = __require("util");
|
|
1001
|
+
var { isDate } = util.types || util;
|
|
1002
1002
|
function escapeElement(elementRepresentation) {
|
|
1003
1003
|
const escaped = elementRepresentation.replace(/\\/g, "\\\\").replace(/"/g, "\\\"");
|
|
1004
1004
|
return '"' + escaped + '"';
|
|
@@ -1007,23 +1007,28 @@ var require_utils = __commonJS((exports, module) => {
|
|
|
1007
1007
|
let result = "{";
|
|
1008
1008
|
for (let i = 0;i < val.length; i++) {
|
|
1009
1009
|
if (i > 0) {
|
|
1010
|
-
result
|
|
1011
|
-
}
|
|
1012
|
-
|
|
1013
|
-
|
|
1014
|
-
|
|
1015
|
-
|
|
1016
|
-
|
|
1017
|
-
|
|
1010
|
+
result = result + ",";
|
|
1011
|
+
}
|
|
1012
|
+
if (val[i] === null || typeof val[i] === "undefined") {
|
|
1013
|
+
result = result + "NULL";
|
|
1014
|
+
} else if (Array.isArray(val[i])) {
|
|
1015
|
+
result = result + arrayString(val[i]);
|
|
1016
|
+
} else if (ArrayBuffer.isView(val[i])) {
|
|
1017
|
+
let item = val[i];
|
|
1018
1018
|
if (!(item instanceof Buffer)) {
|
|
1019
|
-
|
|
1019
|
+
const buf = Buffer.from(item.buffer, item.byteOffset, item.byteLength);
|
|
1020
|
+
if (buf.length === item.byteLength) {
|
|
1021
|
+
item = buf;
|
|
1022
|
+
} else {
|
|
1023
|
+
item = buf.slice(item.byteOffset, item.byteOffset + item.byteLength);
|
|
1024
|
+
}
|
|
1020
1025
|
}
|
|
1021
1026
|
result += "\\\\x" + item.toString("hex");
|
|
1022
1027
|
} else {
|
|
1023
|
-
result += escapeElement(prepareValue(
|
|
1028
|
+
result += escapeElement(prepareValue(val[i]));
|
|
1024
1029
|
}
|
|
1025
1030
|
}
|
|
1026
|
-
result
|
|
1031
|
+
result = result + "}";
|
|
1027
1032
|
return result;
|
|
1028
1033
|
}
|
|
1029
1034
|
var prepareValue = function(val, seen) {
|
|
@@ -1035,7 +1040,11 @@ var require_utils = __commonJS((exports, module) => {
|
|
|
1035
1040
|
return val;
|
|
1036
1041
|
}
|
|
1037
1042
|
if (ArrayBuffer.isView(val)) {
|
|
1038
|
-
|
|
1043
|
+
const buf = Buffer.from(val.buffer, val.byteOffset, val.byteLength);
|
|
1044
|
+
if (buf.length === val.byteLength) {
|
|
1045
|
+
return buf;
|
|
1046
|
+
}
|
|
1047
|
+
return buf.slice(val.byteOffset, val.byteOffset + val.byteLength);
|
|
1039
1048
|
}
|
|
1040
1049
|
if (isDate(val)) {
|
|
1041
1050
|
if (defaults.parseInputDatesAsUTC) {
|
|
@@ -1144,8 +1153,43 @@ var require_utils = __commonJS((exports, module) => {
|
|
|
1144
1153
|
};
|
|
1145
1154
|
});
|
|
1146
1155
|
|
|
1147
|
-
// node_modules
|
|
1148
|
-
var
|
|
1156
|
+
// node_modules/pg/lib/crypto/utils-legacy.js
|
|
1157
|
+
var require_utils_legacy = __commonJS((exports, module) => {
|
|
1158
|
+
var nodeCrypto = __require("crypto");
|
|
1159
|
+
function md5(string) {
|
|
1160
|
+
return nodeCrypto.createHash("md5").update(string, "utf-8").digest("hex");
|
|
1161
|
+
}
|
|
1162
|
+
function postgresMd5PasswordHash(user, password, salt) {
|
|
1163
|
+
const inner = md5(password + user);
|
|
1164
|
+
const outer = md5(Buffer.concat([Buffer.from(inner), salt]));
|
|
1165
|
+
return "md5" + outer;
|
|
1166
|
+
}
|
|
1167
|
+
function sha256(text) {
|
|
1168
|
+
return nodeCrypto.createHash("sha256").update(text).digest();
|
|
1169
|
+
}
|
|
1170
|
+
function hashByName(hashName, text) {
|
|
1171
|
+
hashName = hashName.replace(/(\D)-/, "$1");
|
|
1172
|
+
return nodeCrypto.createHash(hashName).update(text).digest();
|
|
1173
|
+
}
|
|
1174
|
+
function hmacSha256(key, msg) {
|
|
1175
|
+
return nodeCrypto.createHmac("sha256", key).update(msg).digest();
|
|
1176
|
+
}
|
|
1177
|
+
async function deriveKey(password, salt, iterations) {
|
|
1178
|
+
return nodeCrypto.pbkdf2Sync(password, salt, iterations, 32, "sha256");
|
|
1179
|
+
}
|
|
1180
|
+
module.exports = {
|
|
1181
|
+
postgresMd5PasswordHash,
|
|
1182
|
+
randomBytes: nodeCrypto.randomBytes,
|
|
1183
|
+
deriveKey,
|
|
1184
|
+
sha256,
|
|
1185
|
+
hashByName,
|
|
1186
|
+
hmacSha256,
|
|
1187
|
+
md5
|
|
1188
|
+
};
|
|
1189
|
+
});
|
|
1190
|
+
|
|
1191
|
+
// node_modules/pg/lib/crypto/utils-webcrypto.js
|
|
1192
|
+
var require_utils_webcrypto = __commonJS((exports, module) => {
|
|
1149
1193
|
var nodeCrypto = __require("crypto");
|
|
1150
1194
|
module.exports = {
|
|
1151
1195
|
postgresMd5PasswordHash,
|
|
@@ -1193,7 +1237,17 @@ var require_utils2 = __commonJS((exports, module) => {
|
|
|
1193
1237
|
}
|
|
1194
1238
|
});
|
|
1195
1239
|
|
|
1196
|
-
// node_modules
|
|
1240
|
+
// node_modules/pg/lib/crypto/utils.js
|
|
1241
|
+
var require_utils2 = __commonJS((exports, module) => {
|
|
1242
|
+
var useLegacyCrypto = parseInt(process.versions && process.versions.node && process.versions.node.split(".")[0]) < 15;
|
|
1243
|
+
if (useLegacyCrypto) {
|
|
1244
|
+
module.exports = require_utils_legacy();
|
|
1245
|
+
} else {
|
|
1246
|
+
module.exports = require_utils_webcrypto();
|
|
1247
|
+
}
|
|
1248
|
+
});
|
|
1249
|
+
|
|
1250
|
+
// node_modules/pg/lib/crypto/cert-signatures.js
|
|
1197
1251
|
var require_cert_signatures = __commonJS((exports, module) => {
|
|
1198
1252
|
function x509Error(msg, cert) {
|
|
1199
1253
|
return new Error("SASL channel binding: " + msg + " when parsing public certificate " + cert.toString("base64"));
|
|
@@ -1305,17 +1359,11 @@ var require_cert_signatures = __commonJS((exports, module) => {
|
|
|
1305
1359
|
module.exports = { signatureAlgorithmHashFromCertificate };
|
|
1306
1360
|
});
|
|
1307
1361
|
|
|
1308
|
-
// node_modules
|
|
1362
|
+
// node_modules/pg/lib/crypto/sasl.js
|
|
1309
1363
|
var require_sasl = __commonJS((exports, module) => {
|
|
1310
1364
|
var crypto2 = require_utils2();
|
|
1311
1365
|
var { signatureAlgorithmHashFromCertificate } = require_cert_signatures();
|
|
1312
|
-
function
|
|
1313
|
-
const nonAsciiSpace = /[\u00A0\u1680\u2000-\u200B\u202F\u205F\u3000]/g;
|
|
1314
|
-
const mappedToNothing = /[\u00AD\u034F\u1806\u180B\u180C\u180D\u200C\u200D\u2060\uFE00-\uFE0F\uFEFF]/g;
|
|
1315
|
-
return password.replace(nonAsciiSpace, " ").replace(mappedToNothing, "").normalize("NFKC");
|
|
1316
|
-
}
|
|
1317
|
-
var DEFAULT_MAX_SCRAM_ITERATIONS = 1e5;
|
|
1318
|
-
function startSession(mechanisms, stream, scramMaxIterations = DEFAULT_MAX_SCRAM_ITERATIONS) {
|
|
1366
|
+
function startSession(mechanisms, stream) {
|
|
1319
1367
|
const candidates = ["SCRAM-SHA-256"];
|
|
1320
1368
|
if (stream)
|
|
1321
1369
|
candidates.unshift("SCRAM-SHA-256-PLUS");
|
|
@@ -1332,8 +1380,7 @@ var require_sasl = __commonJS((exports, module) => {
|
|
|
1332
1380
|
mechanism,
|
|
1333
1381
|
clientNonce,
|
|
1334
1382
|
response: gs2Header + ",,n=*,r=" + clientNonce,
|
|
1335
|
-
message: "SASLInitialResponse"
|
|
1336
|
-
scramMaxIterations
|
|
1383
|
+
message: "SASLInitialResponse"
|
|
1337
1384
|
};
|
|
1338
1385
|
}
|
|
1339
1386
|
async function continueSession(session, password, serverData, stream) {
|
|
@@ -1355,10 +1402,6 @@ var require_sasl = __commonJS((exports, module) => {
|
|
|
1355
1402
|
} else if (sv.nonce.length === session.clientNonce.length) {
|
|
1356
1403
|
throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: server nonce is too short");
|
|
1357
1404
|
}
|
|
1358
|
-
const scramMaxIterations = typeof session.scramMaxIterations === "number" ? session.scramMaxIterations : DEFAULT_MAX_SCRAM_ITERATIONS;
|
|
1359
|
-
if (scramMaxIterations !== 0 && sv.iteration > scramMaxIterations) {
|
|
1360
|
-
throw new Error("SASL: SCRAM-SERVER-FIRST-MESSAGE: iteration count " + sv.iteration + " exceeds scramMaxIterations of " + scramMaxIterations);
|
|
1361
|
-
}
|
|
1362
1405
|
const clientFirstMessageBare = "n=*,r=" + session.clientNonce;
|
|
1363
1406
|
const serverFirstMessage = "r=" + sv.nonce + ",s=" + sv.salt + ",i=" + sv.iteration;
|
|
1364
1407
|
let channelBinding = stream ? "eSws" : "biws";
|
|
@@ -1374,7 +1417,7 @@ var require_sasl = __commonJS((exports, module) => {
|
|
|
1374
1417
|
const clientFinalMessageWithoutProof = "c=" + channelBinding + ",r=" + sv.nonce;
|
|
1375
1418
|
const authMessage = clientFirstMessageBare + "," + serverFirstMessage + "," + clientFinalMessageWithoutProof;
|
|
1376
1419
|
const saltBytes = Buffer.from(sv.salt, "base64");
|
|
1377
|
-
const saltedPassword = await crypto2.deriveKey(
|
|
1420
|
+
const saltedPassword = await crypto2.deriveKey(password, saltBytes, sv.iteration);
|
|
1378
1421
|
const clientKey = await crypto2.hmacSha256(saltedPassword, "Client Key");
|
|
1379
1422
|
const storedKey = await crypto2.sha256(clientKey);
|
|
1380
1423
|
const clientSignature = await crypto2.hmacSha256(storedKey, authMessage);
|
|
@@ -1448,11 +1491,7 @@ var require_sasl = __commonJS((exports, module) => {
|
|
|
1448
1491
|
}
|
|
1449
1492
|
function parseServerFinalMessage(serverData) {
|
|
1450
1493
|
const attrPairs = parseAttributePairs(serverData);
|
|
1451
|
-
const error = attrPairs.get("e");
|
|
1452
1494
|
const serverSignature = attrPairs.get("v");
|
|
1453
|
-
if (error) {
|
|
1454
|
-
throw new Error(`SASL: SCRAM-SERVER-FINAL-MESSAGE: server returned error: "${error}"`);
|
|
1455
|
-
}
|
|
1456
1495
|
if (!serverSignature) {
|
|
1457
1496
|
throw new Error("SASL: SCRAM-SERVER-FINAL-MESSAGE: server signature is missing");
|
|
1458
1497
|
} else if (!isBase64(serverSignature)) {
|
|
@@ -1480,12 +1519,11 @@ var require_sasl = __commonJS((exports, module) => {
|
|
|
1480
1519
|
module.exports = {
|
|
1481
1520
|
startSession,
|
|
1482
1521
|
continueSession,
|
|
1483
|
-
finalizeSession
|
|
1484
|
-
DEFAULT_MAX_SCRAM_ITERATIONS
|
|
1522
|
+
finalizeSession
|
|
1485
1523
|
};
|
|
1486
1524
|
});
|
|
1487
1525
|
|
|
1488
|
-
// node_modules
|
|
1526
|
+
// node_modules/pg/lib/type-overrides.js
|
|
1489
1527
|
var require_type_overrides = __commonJS((exports, module) => {
|
|
1490
1528
|
var types = require_pg_types();
|
|
1491
1529
|
function TypeOverrides(userTypes) {
|
|
@@ -1517,14 +1555,14 @@ var require_type_overrides = __commonJS((exports, module) => {
|
|
|
1517
1555
|
module.exports = TypeOverrides;
|
|
1518
1556
|
});
|
|
1519
1557
|
|
|
1520
|
-
// node_modules
|
|
1558
|
+
// node_modules/pg-connection-string/index.js
|
|
1521
1559
|
var require_pg_connection_string = __commonJS((exports, module) => {
|
|
1522
1560
|
function parse(str, options = {}) {
|
|
1523
1561
|
if (str.charAt(0) === "/") {
|
|
1524
1562
|
const config2 = str.split(" ");
|
|
1525
1563
|
return { host: config2[0], database: config2[1] };
|
|
1526
1564
|
}
|
|
1527
|
-
const config =
|
|
1565
|
+
const config = {};
|
|
1528
1566
|
let result;
|
|
1529
1567
|
let dummyHost = false;
|
|
1530
1568
|
if (/ |%[^a-f0-9]|%[a-f0-9][^a-f0-9]/i.test(str)) {
|
|
@@ -1572,9 +1610,6 @@ var require_pg_connection_string = __commonJS((exports, module) => {
|
|
|
1572
1610
|
if (config.sslcert || config.sslkey || config.sslrootcert || config.sslmode) {
|
|
1573
1611
|
config.ssl = {};
|
|
1574
1612
|
}
|
|
1575
|
-
if (config.sslnegotiation === "direct" && config.ssl === undefined) {
|
|
1576
|
-
config.ssl = true;
|
|
1577
|
-
}
|
|
1578
1613
|
const fs = config.sslcert || config.sslkey || config.sslrootcert ? __require("fs") : null;
|
|
1579
1614
|
if (config.sslcert) {
|
|
1580
1615
|
config.ssl.cert = fs.readFileSync(config.sslcert).toString();
|
|
@@ -1646,7 +1681,7 @@ var require_pg_connection_string = __commonJS((exports, module) => {
|
|
|
1646
1681
|
c[key] = value;
|
|
1647
1682
|
}
|
|
1648
1683
|
return c;
|
|
1649
|
-
},
|
|
1684
|
+
}, {});
|
|
1650
1685
|
return connectionOptions;
|
|
1651
1686
|
}
|
|
1652
1687
|
function toClientConfig(config) {
|
|
@@ -1673,7 +1708,7 @@ var require_pg_connection_string = __commonJS((exports, module) => {
|
|
|
1673
1708
|
}
|
|
1674
1709
|
}
|
|
1675
1710
|
return c;
|
|
1676
|
-
},
|
|
1711
|
+
}, {});
|
|
1677
1712
|
return poolConfig;
|
|
1678
1713
|
}
|
|
1679
1714
|
function parseIntoClientConfig(str) {
|
|
@@ -1698,7 +1733,7 @@ See https://www.postgresql.org/docs/current/libpq-ssl.html for libpq SSL mode de
|
|
|
1698
1733
|
parse.parseIntoClientConfig = parseIntoClientConfig;
|
|
1699
1734
|
});
|
|
1700
1735
|
|
|
1701
|
-
// node_modules
|
|
1736
|
+
// node_modules/pg/lib/connection-parameters.js
|
|
1702
1737
|
var require_connection_parameters = __commonJS((exports, module) => {
|
|
1703
1738
|
var dns = __require("dns");
|
|
1704
1739
|
var defaults = require_defaults();
|
|
@@ -1773,13 +1808,6 @@ var require_connection_parameters = __commonJS((exports, module) => {
|
|
|
1773
1808
|
enumerable: false
|
|
1774
1809
|
});
|
|
1775
1810
|
}
|
|
1776
|
-
this.sslnegotiation = val("sslnegotiation", config, "PGSSLNEGOTIATION");
|
|
1777
|
-
if (this.sslnegotiation !== undefined && this.sslnegotiation !== "postgres" && this.sslnegotiation !== "direct") {
|
|
1778
|
-
throw new Error(`Invalid sslnegotiation value: "${this.sslnegotiation}". Valid values are "postgres" and "direct".`);
|
|
1779
|
-
}
|
|
1780
|
-
if (this.sslnegotiation === "direct" && !this.ssl) {
|
|
1781
|
-
throw new Error("sslnegotiation=direct requires SSL to be enabled");
|
|
1782
|
-
}
|
|
1783
1811
|
this.client_encoding = val("client_encoding", config);
|
|
1784
1812
|
this.replication = val("replication", config);
|
|
1785
1813
|
this.isDomainSocket = !(this.host || "").indexOf("/");
|
|
@@ -1818,7 +1846,6 @@ var require_connection_parameters = __commonJS((exports, module) => {
|
|
|
1818
1846
|
add(params, ssl, "sslkey");
|
|
1819
1847
|
add(params, ssl, "sslcert");
|
|
1820
1848
|
add(params, ssl, "sslrootcert");
|
|
1821
|
-
add(params, this, "sslnegotiation");
|
|
1822
1849
|
if (this.database) {
|
|
1823
1850
|
params.push("dbname=" + quoteParamValue(this.database));
|
|
1824
1851
|
}
|
|
@@ -1845,7 +1872,7 @@ var require_connection_parameters = __commonJS((exports, module) => {
|
|
|
1845
1872
|
module.exports = ConnectionParameters;
|
|
1846
1873
|
});
|
|
1847
1874
|
|
|
1848
|
-
// node_modules
|
|
1875
|
+
// node_modules/pg/lib/result.js
|
|
1849
1876
|
var require_result = __commonJS((exports, module) => {
|
|
1850
1877
|
var types = require_pg_types();
|
|
1851
1878
|
var matchRegexp = /^([A-Za-z]+)(?: (\d+))?(?: (\d+))?/;
|
|
@@ -1917,7 +1944,7 @@ var require_result = __commonJS((exports, module) => {
|
|
|
1917
1944
|
if (this.fields.length) {
|
|
1918
1945
|
this._parsers = new Array(fieldDescriptions.length);
|
|
1919
1946
|
}
|
|
1920
|
-
const row =
|
|
1947
|
+
const row = {};
|
|
1921
1948
|
for (let i = 0;i < fieldDescriptions.length; i++) {
|
|
1922
1949
|
const desc = fieldDescriptions[i];
|
|
1923
1950
|
row[desc.name] = null;
|
|
@@ -1933,7 +1960,7 @@ var require_result = __commonJS((exports, module) => {
|
|
|
1933
1960
|
module.exports = Result;
|
|
1934
1961
|
});
|
|
1935
1962
|
|
|
1936
|
-
// node_modules
|
|
1963
|
+
// node_modules/pg/lib/query.js
|
|
1937
1964
|
var require_query = __commonJS((exports, module) => {
|
|
1938
1965
|
var { EventEmitter } = __require("events");
|
|
1939
1966
|
var Result = require_result();
|
|
@@ -2102,8 +2129,6 @@ var require_query = __commonJS((exports, module) => {
|
|
|
2102
2129
|
valueMapper: utils.prepareValue
|
|
2103
2130
|
});
|
|
2104
2131
|
} catch (err) {
|
|
2105
|
-
connection.close({ type: "S", name: this.name });
|
|
2106
|
-
connection.sync();
|
|
2107
2132
|
this.handleError(err, connection);
|
|
2108
2133
|
return;
|
|
2109
2134
|
}
|
|
@@ -2121,7 +2146,7 @@ var require_query = __commonJS((exports, module) => {
|
|
|
2121
2146
|
module.exports = Query;
|
|
2122
2147
|
});
|
|
2123
2148
|
|
|
2124
|
-
// node_modules
|
|
2149
|
+
// node_modules/pg-protocol/dist/messages.js
|
|
2125
2150
|
var require_messages = __commonJS((exports) => {
|
|
2126
2151
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2127
2152
|
exports.NoticeMessage = exports.DataRowMessage = exports.CommandCompleteMessage = exports.ReadyForQueryMessage = exports.NotificationResponseMessage = exports.BackendKeyDataMessage = exports.AuthenticationMD5Password = exports.ParameterStatusMessage = exports.ParameterDescriptionMessage = exports.RowDescriptionMessage = exports.Field = exports.CopyResponse = exports.CopyDataMessage = exports.DatabaseError = exports.copyDone = exports.emptyQuery = exports.replicationStart = exports.portalSuspended = exports.noData = exports.closeComplete = exports.bindComplete = exports.parseComplete = undefined;
|
|
@@ -2297,7 +2322,7 @@ var require_messages = __commonJS((exports) => {
|
|
|
2297
2322
|
exports.NoticeMessage = NoticeMessage;
|
|
2298
2323
|
});
|
|
2299
2324
|
|
|
2300
|
-
// node_modules
|
|
2325
|
+
// node_modules/pg-protocol/dist/buffer-writer.js
|
|
2301
2326
|
var require_buffer_writer = __commonJS((exports) => {
|
|
2302
2327
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2303
2328
|
exports.Writer = undefined;
|
|
@@ -2351,19 +2376,6 @@ var require_buffer_writer = __commonJS((exports) => {
|
|
|
2351
2376
|
this.offset += len;
|
|
2352
2377
|
return this;
|
|
2353
2378
|
}
|
|
2354
|
-
addInt32PrefixedString(string) {
|
|
2355
|
-
const len = Buffer.byteLength(string);
|
|
2356
|
-
this.ensure(4 + len);
|
|
2357
|
-
const buffer = this.buffer;
|
|
2358
|
-
let offset = this.offset;
|
|
2359
|
-
buffer[offset++] = len >>> 24 & 255;
|
|
2360
|
-
buffer[offset++] = len >>> 16 & 255;
|
|
2361
|
-
buffer[offset++] = len >>> 8 & 255;
|
|
2362
|
-
buffer[offset++] = len >>> 0 & 255;
|
|
2363
|
-
buffer.write(string, offset, "utf-8");
|
|
2364
|
-
this.offset = offset + len;
|
|
2365
|
-
return this;
|
|
2366
|
-
}
|
|
2367
2379
|
add(otherBuffer) {
|
|
2368
2380
|
this.ensure(otherBuffer.length);
|
|
2369
2381
|
otherBuffer.copy(this.buffer, this.offset);
|
|
@@ -2385,15 +2397,11 @@ var require_buffer_writer = __commonJS((exports) => {
|
|
|
2385
2397
|
this.buffer = Buffer.allocUnsafe(this.size);
|
|
2386
2398
|
return result;
|
|
2387
2399
|
}
|
|
2388
|
-
clear() {
|
|
2389
|
-
this.offset = 5;
|
|
2390
|
-
this.headerPosition = 0;
|
|
2391
|
-
}
|
|
2392
2400
|
}
|
|
2393
2401
|
exports.Writer = Writer;
|
|
2394
2402
|
});
|
|
2395
2403
|
|
|
2396
|
-
// node_modules
|
|
2404
|
+
// node_modules/pg-protocol/dist/serializer.js
|
|
2397
2405
|
var require_serializer = __commonJS((exports) => {
|
|
2398
2406
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2399
2407
|
exports.serialize = undefined;
|
|
@@ -2419,7 +2427,7 @@ var require_serializer = __commonJS((exports) => {
|
|
|
2419
2427
|
return writer.addCString(password2).flush(112);
|
|
2420
2428
|
};
|
|
2421
2429
|
var sendSASLInitialResponseMessage = function(mechanism, initialResponse) {
|
|
2422
|
-
writer.addCString(mechanism).
|
|
2430
|
+
writer.addCString(mechanism).addInt32(Buffer.byteLength(initialResponse)).addString(initialResponse);
|
|
2423
2431
|
return writer.flush(112);
|
|
2424
2432
|
};
|
|
2425
2433
|
var sendSCRAMClientFinalMessage = function(additionalData) {
|
|
@@ -2457,7 +2465,8 @@ var require_serializer = __commonJS((exports) => {
|
|
|
2457
2465
|
paramWriter.add(mappedVal);
|
|
2458
2466
|
} else {
|
|
2459
2467
|
writer.addInt16(0);
|
|
2460
|
-
paramWriter.
|
|
2468
|
+
paramWriter.addInt32(Buffer.byteLength(mappedVal));
|
|
2469
|
+
paramWriter.addString(mappedVal);
|
|
2461
2470
|
}
|
|
2462
2471
|
}
|
|
2463
2472
|
};
|
|
@@ -2469,13 +2478,7 @@ var require_serializer = __commonJS((exports) => {
|
|
|
2469
2478
|
const len = values.length;
|
|
2470
2479
|
writer.addCString(portal).addCString(statement);
|
|
2471
2480
|
writer.addInt16(len);
|
|
2472
|
-
|
|
2473
|
-
writeValues(values, config.valueMapper);
|
|
2474
|
-
} catch (err) {
|
|
2475
|
-
writer.clear();
|
|
2476
|
-
paramWriter.clear();
|
|
2477
|
-
throw err;
|
|
2478
|
-
}
|
|
2481
|
+
writeValues(values, config.valueMapper);
|
|
2479
2482
|
writer.addInt16(len);
|
|
2480
2483
|
writer.add(paramWriter.flush());
|
|
2481
2484
|
writer.addInt16(1);
|
|
@@ -2561,7 +2564,7 @@ var require_serializer = __commonJS((exports) => {
|
|
|
2561
2564
|
exports.serialize = serialize;
|
|
2562
2565
|
});
|
|
2563
2566
|
|
|
2564
|
-
// node_modules
|
|
2567
|
+
// node_modules/pg-protocol/dist/buffer-reader.js
|
|
2565
2568
|
var require_buffer_reader = __commonJS((exports) => {
|
|
2566
2569
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2567
2570
|
exports.BufferReader = undefined;
|
|
@@ -2604,7 +2607,7 @@ var require_buffer_reader = __commonJS((exports) => {
|
|
|
2604
2607
|
cstring() {
|
|
2605
2608
|
const start = this.offset;
|
|
2606
2609
|
let end = start;
|
|
2607
|
-
while (this.buffer[end++]) {}
|
|
2610
|
+
while (this.buffer[end++] !== 0) {}
|
|
2608
2611
|
this.offset = end;
|
|
2609
2612
|
return this.buffer.toString(this.encoding, start, end - 1);
|
|
2610
2613
|
}
|
|
@@ -2617,7 +2620,7 @@ var require_buffer_reader = __commonJS((exports) => {
|
|
|
2617
2620
|
exports.BufferReader = BufferReader;
|
|
2618
2621
|
});
|
|
2619
2622
|
|
|
2620
|
-
// node_modules
|
|
2623
|
+
// node_modules/pg-protocol/dist/parser.js
|
|
2621
2624
|
var require_parser = __commonJS((exports) => {
|
|
2622
2625
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2623
2626
|
exports.Parser = undefined;
|
|
@@ -2922,11 +2925,10 @@ var require_parser = __commonJS((exports) => {
|
|
|
2922
2925
|
};
|
|
2923
2926
|
});
|
|
2924
2927
|
|
|
2925
|
-
// node_modules
|
|
2928
|
+
// node_modules/pg-protocol/dist/index.js
|
|
2926
2929
|
var require_dist = __commonJS((exports) => {
|
|
2927
2930
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2928
|
-
exports.DatabaseError = exports.serialize = undefined;
|
|
2929
|
-
exports.parse = parse;
|
|
2931
|
+
exports.DatabaseError = exports.serialize = exports.parse = undefined;
|
|
2930
2932
|
var messages_1 = require_messages();
|
|
2931
2933
|
Object.defineProperty(exports, "DatabaseError", { enumerable: true, get: function() {
|
|
2932
2934
|
return messages_1.DatabaseError;
|
|
@@ -2941,15 +2943,16 @@ var require_dist = __commonJS((exports) => {
|
|
|
2941
2943
|
stream.on("data", (buffer) => parser.parse(buffer, callback));
|
|
2942
2944
|
return new Promise((resolve2) => stream.on("end", () => resolve2()));
|
|
2943
2945
|
}
|
|
2946
|
+
exports.parse = parse;
|
|
2944
2947
|
});
|
|
2945
2948
|
|
|
2946
|
-
// node_modules
|
|
2949
|
+
// node_modules/pg-cloudflare/dist/empty.js
|
|
2947
2950
|
var require_empty = __commonJS((exports) => {
|
|
2948
2951
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
2949
2952
|
exports.default = {};
|
|
2950
2953
|
});
|
|
2951
2954
|
|
|
2952
|
-
// node_modules
|
|
2955
|
+
// node_modules/pg/lib/stream.js
|
|
2953
2956
|
var require_stream = __commonJS((exports, module) => {
|
|
2954
2957
|
var { getStream, getSecureStream } = getStreamFuncs();
|
|
2955
2958
|
module.exports = {
|
|
@@ -3004,12 +3007,11 @@ var require_stream = __commonJS((exports, module) => {
|
|
|
3004
3007
|
}
|
|
3005
3008
|
});
|
|
3006
3009
|
|
|
3007
|
-
// node_modules
|
|
3010
|
+
// node_modules/pg/lib/connection.js
|
|
3008
3011
|
var require_connection = __commonJS((exports, module) => {
|
|
3009
3012
|
var EventEmitter = __require("events").EventEmitter;
|
|
3010
3013
|
var { parse, serialize } = require_dist();
|
|
3011
|
-
var
|
|
3012
|
-
var { getStream } = stream;
|
|
3014
|
+
var { getStream, getSecureStream } = require_stream();
|
|
3013
3015
|
var flushBuffer = serialize.flush();
|
|
3014
3016
|
var syncBuffer = serialize.sync();
|
|
3015
3017
|
var endBuffer = serialize.end();
|
|
@@ -3026,7 +3028,6 @@ var require_connection = __commonJS((exports, module) => {
|
|
|
3026
3028
|
this._keepAliveInitialDelayMillis = config.keepAliveInitialDelayMillis;
|
|
3027
3029
|
this.parsedStatements = {};
|
|
3028
3030
|
this.ssl = config.ssl || false;
|
|
3029
|
-
this.sslNegotiation = config.sslNegotiation || "postgres";
|
|
3030
3031
|
this._ending = false;
|
|
3031
3032
|
this._emitMessage = false;
|
|
3032
3033
|
const self = this;
|
|
@@ -3060,11 +3061,6 @@ var require_connection = __commonJS((exports, module) => {
|
|
|
3060
3061
|
if (!this.ssl) {
|
|
3061
3062
|
return this.attachListeners(this.stream);
|
|
3062
3063
|
}
|
|
3063
|
-
if (this.sslNegotiation === "direct") {
|
|
3064
|
-
return this.stream.once("connect", function() {
|
|
3065
|
-
self.upgradeToSSL(host, reportStreamError);
|
|
3066
|
-
});
|
|
3067
|
-
}
|
|
3068
3064
|
this.stream.once("data", function(buffer) {
|
|
3069
3065
|
const responseCode = buffer.toString("utf8");
|
|
3070
3066
|
switch (responseCode) {
|
|
@@ -3077,38 +3073,31 @@ var require_connection = __commonJS((exports, module) => {
|
|
|
3077
3073
|
self.stream.end();
|
|
3078
3074
|
return self.emit("error", new Error("There was an error establishing an SSL connection"));
|
|
3079
3075
|
}
|
|
3080
|
-
|
|
3081
|
-
|
|
3082
|
-
|
|
3083
|
-
|
|
3084
|
-
|
|
3085
|
-
|
|
3086
|
-
|
|
3087
|
-
|
|
3088
|
-
if (self.ssl !== true) {
|
|
3089
|
-
Object.assign(options, self.ssl);
|
|
3090
|
-
if ("key" in self.ssl) {
|
|
3091
|
-
options.key = self.ssl.key;
|
|
3076
|
+
const options = {
|
|
3077
|
+
socket: self.stream
|
|
3078
|
+
};
|
|
3079
|
+
if (self.ssl !== true) {
|
|
3080
|
+
Object.assign(options, self.ssl);
|
|
3081
|
+
if ("key" in self.ssl) {
|
|
3082
|
+
options.key = self.ssl.key;
|
|
3083
|
+
}
|
|
3092
3084
|
}
|
|
3093
|
-
|
|
3094
|
-
|
|
3095
|
-
|
|
3096
|
-
|
|
3097
|
-
|
|
3098
|
-
|
|
3099
|
-
|
|
3100
|
-
|
|
3101
|
-
|
|
3102
|
-
self.stream
|
|
3103
|
-
|
|
3104
|
-
|
|
3105
|
-
}
|
|
3106
|
-
self.attachListeners(self.stream);
|
|
3107
|
-
self.stream.on("error", reportStreamError);
|
|
3108
|
-
self.emit("sslconnect");
|
|
3085
|
+
const net = __require("net");
|
|
3086
|
+
if (net.isIP && net.isIP(host) === 0) {
|
|
3087
|
+
options.servername = host;
|
|
3088
|
+
}
|
|
3089
|
+
try {
|
|
3090
|
+
self.stream = getSecureStream(options);
|
|
3091
|
+
} catch (err) {
|
|
3092
|
+
return self.emit("error", err);
|
|
3093
|
+
}
|
|
3094
|
+
self.attachListeners(self.stream);
|
|
3095
|
+
self.stream.on("error", reportStreamError);
|
|
3096
|
+
self.emit("sslconnect");
|
|
3097
|
+
});
|
|
3109
3098
|
}
|
|
3110
|
-
attachListeners(
|
|
3111
|
-
parse(
|
|
3099
|
+
attachListeners(stream) {
|
|
3100
|
+
parse(stream, (msg) => {
|
|
3112
3101
|
const eventName = msg.name === "error" ? "errorMessage" : msg.name;
|
|
3113
3102
|
if (this._emitMessage) {
|
|
3114
3103
|
this.emit("message", msg);
|
|
@@ -3196,7 +3185,7 @@ var require_connection = __commonJS((exports, module) => {
|
|
|
3196
3185
|
module.exports = Connection;
|
|
3197
3186
|
});
|
|
3198
3187
|
|
|
3199
|
-
// node_modules
|
|
3188
|
+
// node_modules/split2/index.js
|
|
3200
3189
|
var require_split2 = __commonJS((exports, module) => {
|
|
3201
3190
|
var { Transform } = __require("stream");
|
|
3202
3191
|
var { StringDecoder } = __require("string_decoder");
|
|
@@ -3295,7 +3284,7 @@ var require_split2 = __commonJS((exports, module) => {
|
|
|
3295
3284
|
module.exports = split;
|
|
3296
3285
|
});
|
|
3297
3286
|
|
|
3298
|
-
// node_modules
|
|
3287
|
+
// node_modules/pgpass/lib/helper.js
|
|
3299
3288
|
var require_helper = __commonJS((exports, module) => {
|
|
3300
3289
|
var path = __require("path");
|
|
3301
3290
|
var Stream = __require("stream").Stream;
|
|
@@ -3459,7 +3448,7 @@ var require_helper = __commonJS((exports, module) => {
|
|
|
3459
3448
|
};
|
|
3460
3449
|
});
|
|
3461
3450
|
|
|
3462
|
-
// node_modules
|
|
3451
|
+
// node_modules/pgpass/lib/index.js
|
|
3463
3452
|
var require_lib = __commonJS((exports, module) => {
|
|
3464
3453
|
var path = __require("path");
|
|
3465
3454
|
var fs = __require("fs");
|
|
@@ -3477,7 +3466,7 @@ var require_lib = __commonJS((exports, module) => {
|
|
|
3477
3466
|
module.exports.warnTo = helper.warnTo;
|
|
3478
3467
|
});
|
|
3479
3468
|
|
|
3480
|
-
// node_modules
|
|
3469
|
+
// node_modules/pg/lib/client.js
|
|
3481
3470
|
var require_client = __commonJS((exports, module) => {
|
|
3482
3471
|
var EventEmitter = __require("events").EventEmitter;
|
|
3483
3472
|
var utils = require_utils();
|
|
@@ -3494,16 +3483,6 @@ var require_client = __commonJS((exports, module) => {
|
|
|
3494
3483
|
var pgPassDeprecationNotice = nodeUtils.deprecate(() => {}, "pgpass support is deprecated and will be removed in pg@9.0. " + "You can provide an async function as the password property to the Client/Pool constructor that returns a password instead. Within this function you can call the pgpass module in your own code.");
|
|
3495
3484
|
var byoPromiseDeprecationNotice = nodeUtils.deprecate(() => {}, "Passing a custom Promise implementation to the Client/Pool constructor is deprecated and will be removed in pg@9.0.");
|
|
3496
3485
|
var queryQueueLengthDeprecationNotice = nodeUtils.deprecate(() => {}, "Calling client.query() when the client is already executing a query is deprecated and will be removed in pg@9.0. Use async/await or an external async flow control mechanism instead.");
|
|
3497
|
-
function coerceNumberOrDefault(value, defaultValue) {
|
|
3498
|
-
if (typeof value === "number") {
|
|
3499
|
-
return Number.isFinite(value) ? value : defaultValue;
|
|
3500
|
-
}
|
|
3501
|
-
if (typeof value === "string" && value.trim() !== "") {
|
|
3502
|
-
const n = Number(value);
|
|
3503
|
-
return Number.isFinite(n) ? n : defaultValue;
|
|
3504
|
-
}
|
|
3505
|
-
return defaultValue;
|
|
3506
|
-
}
|
|
3507
3486
|
|
|
3508
3487
|
class Client extends EventEmitter {
|
|
3509
3488
|
constructor(config) {
|
|
@@ -3533,13 +3512,10 @@ var require_client = __commonJS((exports, module) => {
|
|
|
3533
3512
|
this._connectionError = false;
|
|
3534
3513
|
this._queryable = true;
|
|
3535
3514
|
this._activeQuery = null;
|
|
3536
|
-
this._txStatus = null;
|
|
3537
3515
|
this.enableChannelBinding = Boolean(c.enableChannelBinding);
|
|
3538
|
-
this.scramMaxIterations = coerceNumberOrDefault(c.scramMaxIterations, sasl.DEFAULT_MAX_SCRAM_ITERATIONS);
|
|
3539
3516
|
this.connection = c.connection || new Connection({
|
|
3540
3517
|
stream: c.stream,
|
|
3541
3518
|
ssl: this.connectionParameters.ssl,
|
|
3542
|
-
sslNegotiation: this.connectionParameters.sslnegotiation,
|
|
3543
3519
|
keepAlive: c.keepAlive || false,
|
|
3544
3520
|
keepAliveInitialDelayMillis: c.keepAliveInitialDelayMillis || 0,
|
|
3545
3521
|
encoding: this.connectionParameters.client_encoding || "utf8"
|
|
@@ -3549,7 +3525,6 @@ var require_client = __commonJS((exports, module) => {
|
|
|
3549
3525
|
this.processID = null;
|
|
3550
3526
|
this.secretKey = null;
|
|
3551
3527
|
this.ssl = this.connectionParameters.ssl || false;
|
|
3552
|
-
this.sslNegotiation = this.connectionParameters.sslnegotiation || "postgres";
|
|
3553
3528
|
if (this.ssl && this.ssl.key) {
|
|
3554
3529
|
Object.defineProperty(this.ssl, "key", {
|
|
3555
3530
|
enumerable: false
|
|
@@ -3610,9 +3585,7 @@ var require_client = __commonJS((exports, module) => {
|
|
|
3610
3585
|
}
|
|
3611
3586
|
con.on("connect", function() {
|
|
3612
3587
|
if (self.ssl) {
|
|
3613
|
-
|
|
3614
|
-
con.requestSsl();
|
|
3615
|
-
}
|
|
3588
|
+
con.requestSsl();
|
|
3616
3589
|
} else {
|
|
3617
3590
|
con.startup(self.getStartupConf());
|
|
3618
3591
|
}
|
|
@@ -3730,7 +3703,7 @@ var require_client = __commonJS((exports, module) => {
|
|
|
3730
3703
|
_handleAuthSASL(msg) {
|
|
3731
3704
|
this._getPassword(() => {
|
|
3732
3705
|
try {
|
|
3733
|
-
this.saslSession = sasl.startSession(msg.mechanisms, this.enableChannelBinding && this.connection.stream
|
|
3706
|
+
this.saslSession = sasl.startSession(msg.mechanisms, this.enableChannelBinding && this.connection.stream);
|
|
3734
3707
|
this.connection.sendSASLInitialResponseMessage(this.saslSession.mechanism, this.saslSession.response);
|
|
3735
3708
|
} catch (err) {
|
|
3736
3709
|
this.connection.emit("error", err);
|
|
@@ -3770,7 +3743,6 @@ var require_client = __commonJS((exports, module) => {
|
|
|
3770
3743
|
}
|
|
3771
3744
|
const activeQuery = this._getActiveQuery();
|
|
3772
3745
|
this._activeQuery = null;
|
|
3773
|
-
this._txStatus = msg?.status ?? null;
|
|
3774
3746
|
this.readyForQuery = true;
|
|
3775
3747
|
if (activeQuery) {
|
|
3776
3748
|
activeQuery.handleReadyForQuery(this.connection);
|
|
@@ -3966,10 +3938,13 @@ var require_client = __commonJS((exports, module) => {
|
|
|
3966
3938
|
query(config, values, callback) {
|
|
3967
3939
|
let query;
|
|
3968
3940
|
let result;
|
|
3969
|
-
|
|
3941
|
+
let readTimeout;
|
|
3942
|
+
let readTimeoutTimer;
|
|
3943
|
+
let queryCallback;
|
|
3944
|
+
if (config === null || config === undefined) {
|
|
3970
3945
|
throw new TypeError("Client was passed a null or undefined query");
|
|
3971
|
-
}
|
|
3972
|
-
|
|
3946
|
+
} else if (typeof config.submit === "function") {
|
|
3947
|
+
readTimeout = config.query_timeout || this.connectionParameters.query_timeout;
|
|
3973
3948
|
result = query = config;
|
|
3974
3949
|
if (!query.callback) {
|
|
3975
3950
|
if (typeof values === "function") {
|
|
@@ -3979,6 +3954,7 @@ var require_client = __commonJS((exports, module) => {
|
|
|
3979
3954
|
}
|
|
3980
3955
|
}
|
|
3981
3956
|
} else {
|
|
3957
|
+
readTimeout = config.query_timeout || this.connectionParameters.query_timeout;
|
|
3982
3958
|
query = new Query(config, values, callback);
|
|
3983
3959
|
if (!query.callback) {
|
|
3984
3960
|
result = new this._Promise((resolve2, reject) => {
|
|
@@ -3987,14 +3963,11 @@ var require_client = __commonJS((exports, module) => {
|
|
|
3987
3963
|
Error.captureStackTrace(err);
|
|
3988
3964
|
throw err;
|
|
3989
3965
|
});
|
|
3990
|
-
} else if (typeof query.callback !== "function") {
|
|
3991
|
-
throw new TypeError("callback is not a function");
|
|
3992
3966
|
}
|
|
3993
3967
|
}
|
|
3994
|
-
const readTimeout = config.query_timeout || this.connectionParameters.query_timeout;
|
|
3995
3968
|
if (readTimeout) {
|
|
3996
|
-
|
|
3997
|
-
|
|
3969
|
+
queryCallback = query.callback || (() => {});
|
|
3970
|
+
readTimeoutTimer = setTimeout(() => {
|
|
3998
3971
|
const error = new Error("Query read timeout");
|
|
3999
3972
|
process.nextTick(() => {
|
|
4000
3973
|
query.handleError(error, this.connection);
|
|
@@ -4043,15 +4016,11 @@ var require_client = __commonJS((exports, module) => {
|
|
|
4043
4016
|
unref() {
|
|
4044
4017
|
this.connection.unref();
|
|
4045
4018
|
}
|
|
4046
|
-
getTransactionStatus() {
|
|
4047
|
-
return this._txStatus;
|
|
4048
|
-
}
|
|
4049
4019
|
end(cb) {
|
|
4050
4020
|
this._ending = true;
|
|
4051
4021
|
if (!this.connection._connecting || this._ended) {
|
|
4052
4022
|
if (cb) {
|
|
4053
4023
|
cb();
|
|
4054
|
-
return;
|
|
4055
4024
|
} else {
|
|
4056
4025
|
return this._Promise.resolve();
|
|
4057
4026
|
}
|
|
@@ -4078,7 +4047,7 @@ var require_client = __commonJS((exports, module) => {
|
|
|
4078
4047
|
module.exports = Client;
|
|
4079
4048
|
});
|
|
4080
4049
|
|
|
4081
|
-
// node_modules
|
|
4050
|
+
// node_modules/pg-pool/index.js
|
|
4082
4051
|
var require_pg_pool = __commonJS((exports, module) => {
|
|
4083
4052
|
var EventEmitter = __require("events").EventEmitter;
|
|
4084
4053
|
var NOOP = function() {};
|
|
@@ -4490,7 +4459,7 @@ var require_pg_pool = __commonJS((exports, module) => {
|
|
|
4490
4459
|
module.exports = Pool;
|
|
4491
4460
|
});
|
|
4492
4461
|
|
|
4493
|
-
// node_modules
|
|
4462
|
+
// node_modules/pg/lib/native/query.js
|
|
4494
4463
|
var require_query2 = __commonJS((exports, module) => {
|
|
4495
4464
|
var EventEmitter = __require("events").EventEmitter;
|
|
4496
4465
|
var util = __require("util");
|
|
@@ -4626,7 +4595,7 @@ var require_query2 = __commonJS((exports, module) => {
|
|
|
4626
4595
|
};
|
|
4627
4596
|
});
|
|
4628
4597
|
|
|
4629
|
-
// node_modules
|
|
4598
|
+
// node_modules/pg/lib/native/client.js
|
|
4630
4599
|
var require_client2 = __commonJS((exports, module) => {
|
|
4631
4600
|
var nodeUtils = __require("util");
|
|
4632
4601
|
var Native;
|
|
@@ -4808,10 +4777,8 @@ var require_client2 = __commonJS((exports, module) => {
|
|
|
4808
4777
|
Client.prototype.end = function(cb) {
|
|
4809
4778
|
const self = this;
|
|
4810
4779
|
this._ending = true;
|
|
4811
|
-
if (
|
|
4812
|
-
this.once("connect", ()
|
|
4813
|
-
this.end(() => {});
|
|
4814
|
-
});
|
|
4780
|
+
if (!this._connected) {
|
|
4781
|
+
this.once("connect", this.end.bind(this, cb));
|
|
4815
4782
|
}
|
|
4816
4783
|
let result;
|
|
4817
4784
|
if (!cb) {
|
|
@@ -4872,12 +4839,9 @@ var require_client2 = __commonJS((exports, module) => {
|
|
|
4872
4839
|
Client.prototype.isConnected = function() {
|
|
4873
4840
|
return this._connected;
|
|
4874
4841
|
};
|
|
4875
|
-
Client.prototype.getTransactionStatus = function() {
|
|
4876
|
-
return this.native.getTransactionStatus();
|
|
4877
|
-
};
|
|
4878
4842
|
});
|
|
4879
4843
|
|
|
4880
|
-
// node_modules
|
|
4844
|
+
// node_modules/pg/lib/index.js
|
|
4881
4845
|
var require_lib2 = __commonJS((exports, module) => {
|
|
4882
4846
|
var Client = require_client();
|
|
4883
4847
|
var defaults = require_defaults();
|
|
@@ -4943,7 +4907,7 @@ var require_lib2 = __commonJS((exports, module) => {
|
|
|
4943
4907
|
var require_package = __commonJS((exports, module) => {
|
|
4944
4908
|
module.exports = {
|
|
4945
4909
|
name: "@hasna/shortlinks",
|
|
4946
|
-
version: "0.2.
|
|
4910
|
+
version: "0.2.3",
|
|
4947
4911
|
description: "Shortlink manager for custom domains and click tracking, with local SQLite or self-hosted cloud (/v1 API + bearer key) storage and Cloudflare setup helpers",
|
|
4948
4912
|
type: "module",
|
|
4949
4913
|
main: "dist/index.js",
|
|
@@ -5664,7 +5628,7 @@ class PgShortlinksStore {
|
|
|
5664
5628
|
}
|
|
5665
5629
|
}
|
|
5666
5630
|
|
|
5667
|
-
// node_modules
|
|
5631
|
+
// node_modules/pg/esm/index.mjs
|
|
5668
5632
|
var import_lib = __toESM(require_lib2(), 1);
|
|
5669
5633
|
var Client = import_lib.default.Client;
|
|
5670
5634
|
var Pool = import_lib.default.Pool;
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@hasna/shortlinks",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.3",
|
|
4
4
|
"description": "Shortlink manager for custom domains and click tracking, with local SQLite or self-hosted cloud (/v1 API + bearer key) storage and Cloudflare setup helpers",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "dist/index.js",
|