casualos 3.3.11-alpha.11060020867 → 3.3.11
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.js +1895 -623
- package/package.json +4 -4
- package/schema.js +40 -22
- package/schema.js.map +1 -1
package/dist/cli.js
CHANGED
|
@@ -9817,8 +9817,8 @@ var require_keyword = __commonJS({
|
|
|
9817
9817
|
var _a4;
|
|
9818
9818
|
const { gen, keyword, schema, parentSchema, $data, it: it2 } = cxt;
|
|
9819
9819
|
checkAsyncKeyword(it2, def);
|
|
9820
|
-
const
|
|
9821
|
-
const validateRef = useKeyword(gen, keyword,
|
|
9820
|
+
const validate2 = !$data && def.compile ? def.compile.call(it2.self, schema, parentSchema, it2) : def.validate;
|
|
9821
|
+
const validateRef = useKeyword(gen, keyword, validate2);
|
|
9822
9822
|
const valid = gen.let("valid");
|
|
9823
9823
|
cxt.block$data(valid, validateKeyword);
|
|
9824
9824
|
cxt.ok((_a4 = def.valid) !== null && _a4 !== void 0 ? _a4 : valid);
|
|
@@ -10900,28 +10900,28 @@ var require_compile = __commonJS({
|
|
|
10900
10900
|
if (this.opts.code.process)
|
|
10901
10901
|
sourceCode = this.opts.code.process(sourceCode, sch);
|
|
10902
10902
|
const makeValidate = new Function(`${names_1.default.self}`, `${names_1.default.scope}`, sourceCode);
|
|
10903
|
-
const
|
|
10904
|
-
this.scope.value(validateName, { ref:
|
|
10905
|
-
|
|
10906
|
-
|
|
10907
|
-
|
|
10903
|
+
const validate2 = makeValidate(this, this.scope.get());
|
|
10904
|
+
this.scope.value(validateName, { ref: validate2 });
|
|
10905
|
+
validate2.errors = null;
|
|
10906
|
+
validate2.schema = sch.schema;
|
|
10907
|
+
validate2.schemaEnv = sch;
|
|
10908
10908
|
if (sch.$async)
|
|
10909
|
-
|
|
10909
|
+
validate2.$async = true;
|
|
10910
10910
|
if (this.opts.code.source === true) {
|
|
10911
|
-
|
|
10911
|
+
validate2.source = { validateName, validateCode, scopeValues: gen._values };
|
|
10912
10912
|
}
|
|
10913
10913
|
if (this.opts.unevaluated) {
|
|
10914
10914
|
const { props, items } = schemaCxt;
|
|
10915
|
-
|
|
10915
|
+
validate2.evaluated = {
|
|
10916
10916
|
props: props instanceof codegen_1.Name ? void 0 : props,
|
|
10917
10917
|
items: items instanceof codegen_1.Name ? void 0 : items,
|
|
10918
10918
|
dynamicProps: props instanceof codegen_1.Name,
|
|
10919
10919
|
dynamicItems: items instanceof codegen_1.Name
|
|
10920
10920
|
};
|
|
10921
|
-
if (
|
|
10922
|
-
|
|
10921
|
+
if (validate2.source)
|
|
10922
|
+
validate2.source.evaluated = (0, codegen_1.stringify)(validate2.evaluated);
|
|
10923
10923
|
}
|
|
10924
|
-
sch.validate =
|
|
10924
|
+
sch.validate = validate2;
|
|
10925
10925
|
return sch;
|
|
10926
10926
|
} catch (e2) {
|
|
10927
10927
|
delete sch.validate;
|
|
@@ -11596,7 +11596,7 @@ var require_uri_all = __commonJS({
|
|
|
11596
11596
|
}
|
|
11597
11597
|
var URI_PARSE = /^(?:([^:\/?#]+):)?(?:\/\/((?:([^\/?#@]*)@)?(\[[^\/?#\]]+\]|[^\/?#:]*)(?:\:(\d*))?))?([^?#]*)(?:\?([^#]*))?(?:#((?:.|\n|\r)*))?/i;
|
|
11598
11598
|
var NO_MATCH_IS_UNDEFINED = "".match(/(){0}/)[1] === void 0;
|
|
11599
|
-
function
|
|
11599
|
+
function parse4(uriString) {
|
|
11600
11600
|
var options = arguments.length > 1 && arguments[1] !== void 0 ? arguments[1] : {};
|
|
11601
11601
|
var components = {};
|
|
11602
11602
|
var protocol = options.iri !== false ? IRI_PROTOCOL : URI_PROTOCOL;
|
|
@@ -11767,8 +11767,8 @@ var require_uri_all = __commonJS({
|
|
|
11767
11767
|
var skipNormalization = arguments[3];
|
|
11768
11768
|
var target = {};
|
|
11769
11769
|
if (!skipNormalization) {
|
|
11770
|
-
base2 =
|
|
11771
|
-
relative =
|
|
11770
|
+
base2 = parse4(serialize(base2, options), options);
|
|
11771
|
+
relative = parse4(serialize(relative, options), options);
|
|
11772
11772
|
}
|
|
11773
11773
|
options = options || {};
|
|
11774
11774
|
if (!options.tolerant && relative.scheme) {
|
|
@@ -11819,24 +11819,24 @@ var require_uri_all = __commonJS({
|
|
|
11819
11819
|
}
|
|
11820
11820
|
function resolve2(baseURI, relativeURI, options) {
|
|
11821
11821
|
var schemelessOptions = assign2({ scheme: "null" }, options);
|
|
11822
|
-
return serialize(resolveComponents(
|
|
11822
|
+
return serialize(resolveComponents(parse4(baseURI, schemelessOptions), parse4(relativeURI, schemelessOptions), schemelessOptions, true), schemelessOptions);
|
|
11823
11823
|
}
|
|
11824
11824
|
function normalize(uri, options) {
|
|
11825
11825
|
if (typeof uri === "string") {
|
|
11826
|
-
uri = serialize(
|
|
11826
|
+
uri = serialize(parse4(uri, options), options);
|
|
11827
11827
|
} else if (typeOf(uri) === "object") {
|
|
11828
|
-
uri =
|
|
11828
|
+
uri = parse4(serialize(uri, options), options);
|
|
11829
11829
|
}
|
|
11830
11830
|
return uri;
|
|
11831
11831
|
}
|
|
11832
11832
|
function equal(uriA, uriB, options) {
|
|
11833
11833
|
if (typeof uriA === "string") {
|
|
11834
|
-
uriA = serialize(
|
|
11834
|
+
uriA = serialize(parse4(uriA, options), options);
|
|
11835
11835
|
} else if (typeOf(uriA) === "object") {
|
|
11836
11836
|
uriA = serialize(uriA, options);
|
|
11837
11837
|
}
|
|
11838
11838
|
if (typeof uriB === "string") {
|
|
11839
|
-
uriB = serialize(
|
|
11839
|
+
uriB = serialize(parse4(uriB, options), options);
|
|
11840
11840
|
} else if (typeOf(uriB) === "object") {
|
|
11841
11841
|
uriB = serialize(uriB, options);
|
|
11842
11842
|
}
|
|
@@ -11851,7 +11851,7 @@ var require_uri_all = __commonJS({
|
|
|
11851
11851
|
var handler2 = {
|
|
11852
11852
|
scheme: "http",
|
|
11853
11853
|
domainHost: true,
|
|
11854
|
-
parse: function
|
|
11854
|
+
parse: function parse5(components, options) {
|
|
11855
11855
|
if (!components.host) {
|
|
11856
11856
|
components.error = components.error || "HTTP URIs must have a host.";
|
|
11857
11857
|
}
|
|
@@ -11880,7 +11880,7 @@ var require_uri_all = __commonJS({
|
|
|
11880
11880
|
var handler$2 = {
|
|
11881
11881
|
scheme: "ws",
|
|
11882
11882
|
domainHost: true,
|
|
11883
|
-
parse: function
|
|
11883
|
+
parse: function parse5(components, options) {
|
|
11884
11884
|
var wsComponents = components;
|
|
11885
11885
|
wsComponents.secure = isSecure(wsComponents);
|
|
11886
11886
|
wsComponents.resourceName = (wsComponents.path || "/") + (wsComponents.query ? "?" + wsComponents.query : "");
|
|
@@ -12056,7 +12056,7 @@ var require_uri_all = __commonJS({
|
|
|
12056
12056
|
var UUID = /^[0-9A-Fa-f]{8}(?:\-[0-9A-Fa-f]{4}){3}\-[0-9A-Fa-f]{12}$/;
|
|
12057
12057
|
var handler$6 = {
|
|
12058
12058
|
scheme: "urn:uuid",
|
|
12059
|
-
parse: function
|
|
12059
|
+
parse: function parse5(urnComponents, options) {
|
|
12060
12060
|
var uuidComponents = urnComponents;
|
|
12061
12061
|
uuidComponents.uuid = uuidComponents.nss;
|
|
12062
12062
|
uuidComponents.nss = void 0;
|
|
@@ -12081,7 +12081,7 @@ var require_uri_all = __commonJS({
|
|
|
12081
12081
|
exports2.SCHEMES = SCHEMES;
|
|
12082
12082
|
exports2.pctEncChar = pctEncChar;
|
|
12083
12083
|
exports2.pctDecChars = pctDecChars;
|
|
12084
|
-
exports2.parse =
|
|
12084
|
+
exports2.parse = parse4;
|
|
12085
12085
|
exports2.removeDotSegments = removeDotSegments;
|
|
12086
12086
|
exports2.serialize = serialize;
|
|
12087
12087
|
exports2.resolveComponents = resolveComponents;
|
|
@@ -14746,8 +14746,8 @@ var require_formats = __commonJS({
|
|
|
14746
14746
|
"use strict";
|
|
14747
14747
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
14748
14748
|
exports.formatNames = exports.fastFormats = exports.fullFormats = void 0;
|
|
14749
|
-
function fmtDef(
|
|
14750
|
-
return { validate, compare };
|
|
14749
|
+
function fmtDef(validate2, compare) {
|
|
14750
|
+
return { validate: validate2, compare };
|
|
14751
14751
|
}
|
|
14752
14752
|
exports.fullFormats = {
|
|
14753
14753
|
// date: http://tools.ietf.org/html/rfc3339#section-5.6
|
|
@@ -15428,7 +15428,7 @@ var require_semver = __commonJS({
|
|
|
15428
15428
|
var require_parse = __commonJS({
|
|
15429
15429
|
"../../node_modules/.pnpm/semver@7.5.4/node_modules/semver/functions/parse.js"(exports, module2) {
|
|
15430
15430
|
var SemVer = require_semver();
|
|
15431
|
-
var
|
|
15431
|
+
var parse4 = (version, options, throwErrors = false) => {
|
|
15432
15432
|
if (version instanceof SemVer) {
|
|
15433
15433
|
return version;
|
|
15434
15434
|
}
|
|
@@ -15441,16 +15441,16 @@ var require_parse = __commonJS({
|
|
|
15441
15441
|
throw er2;
|
|
15442
15442
|
}
|
|
15443
15443
|
};
|
|
15444
|
-
module2.exports =
|
|
15444
|
+
module2.exports = parse4;
|
|
15445
15445
|
}
|
|
15446
15446
|
});
|
|
15447
15447
|
|
|
15448
15448
|
// ../../node_modules/.pnpm/semver@7.5.4/node_modules/semver/functions/valid.js
|
|
15449
15449
|
var require_valid = __commonJS({
|
|
15450
15450
|
"../../node_modules/.pnpm/semver@7.5.4/node_modules/semver/functions/valid.js"(exports, module2) {
|
|
15451
|
-
var
|
|
15451
|
+
var parse4 = require_parse();
|
|
15452
15452
|
var valid = (version, options) => {
|
|
15453
|
-
const v2 =
|
|
15453
|
+
const v2 = parse4(version, options);
|
|
15454
15454
|
return v2 ? v2.version : null;
|
|
15455
15455
|
};
|
|
15456
15456
|
module2.exports = valid;
|
|
@@ -15460,9 +15460,9 @@ var require_valid = __commonJS({
|
|
|
15460
15460
|
// ../../node_modules/.pnpm/semver@7.5.4/node_modules/semver/functions/clean.js
|
|
15461
15461
|
var require_clean = __commonJS({
|
|
15462
15462
|
"../../node_modules/.pnpm/semver@7.5.4/node_modules/semver/functions/clean.js"(exports, module2) {
|
|
15463
|
-
var
|
|
15463
|
+
var parse4 = require_parse();
|
|
15464
15464
|
var clean = (version, options) => {
|
|
15465
|
-
const s3 =
|
|
15465
|
+
const s3 = parse4(version.trim().replace(/^[=v]+/, ""), options);
|
|
15466
15466
|
return s3 ? s3.version : null;
|
|
15467
15467
|
};
|
|
15468
15468
|
module2.exports = clean;
|
|
@@ -15495,10 +15495,10 @@ var require_inc = __commonJS({
|
|
|
15495
15495
|
// ../../node_modules/.pnpm/semver@7.5.4/node_modules/semver/functions/diff.js
|
|
15496
15496
|
var require_diff = __commonJS({
|
|
15497
15497
|
"../../node_modules/.pnpm/semver@7.5.4/node_modules/semver/functions/diff.js"(exports, module2) {
|
|
15498
|
-
var
|
|
15498
|
+
var parse4 = require_parse();
|
|
15499
15499
|
var diff = (version1, version2) => {
|
|
15500
|
-
const v1 =
|
|
15501
|
-
const v2 =
|
|
15500
|
+
const v1 = parse4(version1, null, true);
|
|
15501
|
+
const v2 = parse4(version2, null, true);
|
|
15502
15502
|
const comparison = v1.compare(v2);
|
|
15503
15503
|
if (comparison === 0) {
|
|
15504
15504
|
return null;
|
|
@@ -15566,9 +15566,9 @@ var require_patch = __commonJS({
|
|
|
15566
15566
|
// ../../node_modules/.pnpm/semver@7.5.4/node_modules/semver/functions/prerelease.js
|
|
15567
15567
|
var require_prerelease = __commonJS({
|
|
15568
15568
|
"../../node_modules/.pnpm/semver@7.5.4/node_modules/semver/functions/prerelease.js"(exports, module2) {
|
|
15569
|
-
var
|
|
15569
|
+
var parse4 = require_parse();
|
|
15570
15570
|
var prerelease = (version, options) => {
|
|
15571
|
-
const parsed =
|
|
15571
|
+
const parsed = parse4(version, options);
|
|
15572
15572
|
return parsed && parsed.prerelease.length ? parsed.prerelease : null;
|
|
15573
15573
|
};
|
|
15574
15574
|
module2.exports = prerelease;
|
|
@@ -15740,7 +15740,7 @@ var require_cmp = __commonJS({
|
|
|
15740
15740
|
var require_coerce = __commonJS({
|
|
15741
15741
|
"../../node_modules/.pnpm/semver@7.5.4/node_modules/semver/functions/coerce.js"(exports, module2) {
|
|
15742
15742
|
var SemVer = require_semver();
|
|
15743
|
-
var
|
|
15743
|
+
var parse4 = require_parse();
|
|
15744
15744
|
var { safeRe: re3, t: t2 } = require_re();
|
|
15745
15745
|
var coerce2 = (version, options) => {
|
|
15746
15746
|
if (version instanceof SemVer) {
|
|
@@ -15769,7 +15769,7 @@ var require_coerce = __commonJS({
|
|
|
15769
15769
|
if (match2 === null) {
|
|
15770
15770
|
return null;
|
|
15771
15771
|
}
|
|
15772
|
-
return
|
|
15772
|
+
return parse4(`${match2[2]}.${match2[3] || "0"}.${match2[4] || "0"}`, options);
|
|
15773
15773
|
};
|
|
15774
15774
|
module2.exports = coerce2;
|
|
15775
15775
|
}
|
|
@@ -17366,7 +17366,7 @@ var require_semver2 = __commonJS({
|
|
|
17366
17366
|
var constants3 = require_constants();
|
|
17367
17367
|
var SemVer = require_semver();
|
|
17368
17368
|
var identifiers = require_identifiers();
|
|
17369
|
-
var
|
|
17369
|
+
var parse4 = require_parse();
|
|
17370
17370
|
var valid = require_valid();
|
|
17371
17371
|
var clean = require_clean();
|
|
17372
17372
|
var inc = require_inc();
|
|
@@ -17404,7 +17404,7 @@ var require_semver2 = __commonJS({
|
|
|
17404
17404
|
var simplifyRange = require_simplify();
|
|
17405
17405
|
var subset = require_subset();
|
|
17406
17406
|
module2.exports = {
|
|
17407
|
-
parse:
|
|
17407
|
+
parse: parse4,
|
|
17408
17408
|
valid,
|
|
17409
17409
|
clean,
|
|
17410
17410
|
inc,
|
|
@@ -20912,7 +20912,7 @@ var require_lodash = __commonJS({
|
|
|
20912
20912
|
function uniq2(array) {
|
|
20913
20913
|
return array && array.length ? baseUniq(array) : [];
|
|
20914
20914
|
}
|
|
20915
|
-
function
|
|
20915
|
+
function uniqBy2(array, iteratee2) {
|
|
20916
20916
|
return array && array.length ? baseUniq(array, getIteratee(iteratee2, 2)) : [];
|
|
20917
20917
|
}
|
|
20918
20918
|
function uniqWith(array, comparator) {
|
|
@@ -22572,7 +22572,7 @@ var require_lodash = __commonJS({
|
|
|
22572
22572
|
lodash.unionBy = unionBy2;
|
|
22573
22573
|
lodash.unionWith = unionWith;
|
|
22574
22574
|
lodash.uniq = uniq2;
|
|
22575
|
-
lodash.uniqBy =
|
|
22575
|
+
lodash.uniqBy = uniqBy2;
|
|
22576
22576
|
lodash.uniqWith = uniqWith;
|
|
22577
22577
|
lodash.unset = unset;
|
|
22578
22578
|
lodash.unzip = unzip;
|
|
@@ -25206,23 +25206,23 @@ var require_nacl_fast = __commonJS({
|
|
|
25206
25206
|
randombytes = fn;
|
|
25207
25207
|
};
|
|
25208
25208
|
(function() {
|
|
25209
|
-
var
|
|
25210
|
-
if (
|
|
25209
|
+
var crypto8 = typeof self !== "undefined" ? self.crypto || self.msCrypto : null;
|
|
25210
|
+
if (crypto8 && crypto8.getRandomValues) {
|
|
25211
25211
|
var QUOTA = 65536;
|
|
25212
25212
|
nacl.setPRNG(function(x2, n3) {
|
|
25213
25213
|
var i2, v2 = new Uint8Array(n3);
|
|
25214
25214
|
for (i2 = 0; i2 < n3; i2 += QUOTA) {
|
|
25215
|
-
|
|
25215
|
+
crypto8.getRandomValues(v2.subarray(i2, i2 + Math.min(n3 - i2, QUOTA)));
|
|
25216
25216
|
}
|
|
25217
25217
|
for (i2 = 0; i2 < n3; i2++)
|
|
25218
25218
|
x2[i2] = v2[i2];
|
|
25219
25219
|
cleanup(v2);
|
|
25220
25220
|
});
|
|
25221
25221
|
} else if (typeof require !== "undefined") {
|
|
25222
|
-
|
|
25223
|
-
if (
|
|
25222
|
+
crypto8 = require("crypto");
|
|
25223
|
+
if (crypto8 && crypto8.randomBytes) {
|
|
25224
25224
|
nacl.setPRNG(function(x2, n3) {
|
|
25225
|
-
var i2, v2 =
|
|
25225
|
+
var i2, v2 = crypto8.randomBytes(n3);
|
|
25226
25226
|
for (i2 = 0; i2 < n3; i2++)
|
|
25227
25227
|
x2[i2] = v2[i2];
|
|
25228
25228
|
cleanup(v2);
|
|
@@ -44689,7 +44689,7 @@ var require_ms = __commonJS({
|
|
|
44689
44689
|
options = options || {};
|
|
44690
44690
|
var type = typeof val;
|
|
44691
44691
|
if (type === "string" && val.length > 0) {
|
|
44692
|
-
return
|
|
44692
|
+
return parse4(val);
|
|
44693
44693
|
} else if (type === "number" && isFinite(val)) {
|
|
44694
44694
|
return options.long ? fmtLong(val) : fmtShort(val);
|
|
44695
44695
|
}
|
|
@@ -44697,7 +44697,7 @@ var require_ms = __commonJS({
|
|
|
44697
44697
|
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
44698
44698
|
);
|
|
44699
44699
|
};
|
|
44700
|
-
function
|
|
44700
|
+
function parse4(str2) {
|
|
44701
44701
|
str2 = String(str2);
|
|
44702
44702
|
if (str2.length > 100) {
|
|
44703
44703
|
return;
|
|
@@ -45448,7 +45448,7 @@ var require_debug2 = __commonJS({
|
|
|
45448
45448
|
var require_follow_redirects = __commonJS({
|
|
45449
45449
|
"../../node_modules/.pnpm/follow-redirects@1.15.3/node_modules/follow-redirects/index.js"(exports, module2) {
|
|
45450
45450
|
var url2 = require("url");
|
|
45451
|
-
var
|
|
45451
|
+
var URL3 = url2.URL;
|
|
45452
45452
|
var http2 = require("http");
|
|
45453
45453
|
var https2 = require("https");
|
|
45454
45454
|
var Writable = require("stream").Writable;
|
|
@@ -45791,7 +45791,7 @@ var require_follow_redirects = __commonJS({
|
|
|
45791
45791
|
if (isString4(input2)) {
|
|
45792
45792
|
var parsed;
|
|
45793
45793
|
try {
|
|
45794
|
-
parsed = urlToOptions(new
|
|
45794
|
+
parsed = urlToOptions(new URL3(input2));
|
|
45795
45795
|
} catch (err) {
|
|
45796
45796
|
parsed = url2.parse(input2);
|
|
45797
45797
|
}
|
|
@@ -45799,7 +45799,7 @@ var require_follow_redirects = __commonJS({
|
|
|
45799
45799
|
throw new InvalidUrlError({ input: input2 });
|
|
45800
45800
|
}
|
|
45801
45801
|
input2 = parsed;
|
|
45802
|
-
} else if (
|
|
45802
|
+
} else if (URL3 && input2 instanceof URL3) {
|
|
45803
45803
|
input2 = urlToOptions(input2);
|
|
45804
45804
|
} else {
|
|
45805
45805
|
callback = options;
|
|
@@ -47486,8 +47486,8 @@ var require_URL = __commonJS({
|
|
|
47486
47486
|
var utils = require_utils2();
|
|
47487
47487
|
var Impl = require_URL_impl();
|
|
47488
47488
|
var impl = utils.implSymbol;
|
|
47489
|
-
function
|
|
47490
|
-
if (!this || this[impl] || !(this instanceof
|
|
47489
|
+
function URL3(url2) {
|
|
47490
|
+
if (!this || this[impl] || !(this instanceof URL3)) {
|
|
47491
47491
|
throw new TypeError("Failed to construct 'URL': Please use the 'new' operator, this DOM object constructor cannot be called as a function.");
|
|
47492
47492
|
}
|
|
47493
47493
|
if (arguments.length < 1) {
|
|
@@ -47503,7 +47503,7 @@ var require_URL = __commonJS({
|
|
|
47503
47503
|
}
|
|
47504
47504
|
module2.exports.setup(this, args2);
|
|
47505
47505
|
}
|
|
47506
|
-
|
|
47506
|
+
URL3.prototype.toJSON = function toJSON2() {
|
|
47507
47507
|
if (!this || !module2.exports.is(this)) {
|
|
47508
47508
|
throw new TypeError("Illegal invocation");
|
|
47509
47509
|
}
|
|
@@ -47513,7 +47513,7 @@ var require_URL = __commonJS({
|
|
|
47513
47513
|
}
|
|
47514
47514
|
return this[impl].toJSON.apply(this[impl], args2);
|
|
47515
47515
|
};
|
|
47516
|
-
Object.defineProperty(
|
|
47516
|
+
Object.defineProperty(URL3.prototype, "href", {
|
|
47517
47517
|
get() {
|
|
47518
47518
|
return this[impl].href;
|
|
47519
47519
|
},
|
|
@@ -47524,20 +47524,20 @@ var require_URL = __commonJS({
|
|
|
47524
47524
|
enumerable: true,
|
|
47525
47525
|
configurable: true
|
|
47526
47526
|
});
|
|
47527
|
-
|
|
47527
|
+
URL3.prototype.toString = function() {
|
|
47528
47528
|
if (!this || !module2.exports.is(this)) {
|
|
47529
47529
|
throw new TypeError("Illegal invocation");
|
|
47530
47530
|
}
|
|
47531
47531
|
return this.href;
|
|
47532
47532
|
};
|
|
47533
|
-
Object.defineProperty(
|
|
47533
|
+
Object.defineProperty(URL3.prototype, "origin", {
|
|
47534
47534
|
get() {
|
|
47535
47535
|
return this[impl].origin;
|
|
47536
47536
|
},
|
|
47537
47537
|
enumerable: true,
|
|
47538
47538
|
configurable: true
|
|
47539
47539
|
});
|
|
47540
|
-
Object.defineProperty(
|
|
47540
|
+
Object.defineProperty(URL3.prototype, "protocol", {
|
|
47541
47541
|
get() {
|
|
47542
47542
|
return this[impl].protocol;
|
|
47543
47543
|
},
|
|
@@ -47548,7 +47548,7 @@ var require_URL = __commonJS({
|
|
|
47548
47548
|
enumerable: true,
|
|
47549
47549
|
configurable: true
|
|
47550
47550
|
});
|
|
47551
|
-
Object.defineProperty(
|
|
47551
|
+
Object.defineProperty(URL3.prototype, "username", {
|
|
47552
47552
|
get() {
|
|
47553
47553
|
return this[impl].username;
|
|
47554
47554
|
},
|
|
@@ -47559,7 +47559,7 @@ var require_URL = __commonJS({
|
|
|
47559
47559
|
enumerable: true,
|
|
47560
47560
|
configurable: true
|
|
47561
47561
|
});
|
|
47562
|
-
Object.defineProperty(
|
|
47562
|
+
Object.defineProperty(URL3.prototype, "password", {
|
|
47563
47563
|
get() {
|
|
47564
47564
|
return this[impl].password;
|
|
47565
47565
|
},
|
|
@@ -47570,7 +47570,7 @@ var require_URL = __commonJS({
|
|
|
47570
47570
|
enumerable: true,
|
|
47571
47571
|
configurable: true
|
|
47572
47572
|
});
|
|
47573
|
-
Object.defineProperty(
|
|
47573
|
+
Object.defineProperty(URL3.prototype, "host", {
|
|
47574
47574
|
get() {
|
|
47575
47575
|
return this[impl].host;
|
|
47576
47576
|
},
|
|
@@ -47581,7 +47581,7 @@ var require_URL = __commonJS({
|
|
|
47581
47581
|
enumerable: true,
|
|
47582
47582
|
configurable: true
|
|
47583
47583
|
});
|
|
47584
|
-
Object.defineProperty(
|
|
47584
|
+
Object.defineProperty(URL3.prototype, "hostname", {
|
|
47585
47585
|
get() {
|
|
47586
47586
|
return this[impl].hostname;
|
|
47587
47587
|
},
|
|
@@ -47592,7 +47592,7 @@ var require_URL = __commonJS({
|
|
|
47592
47592
|
enumerable: true,
|
|
47593
47593
|
configurable: true
|
|
47594
47594
|
});
|
|
47595
|
-
Object.defineProperty(
|
|
47595
|
+
Object.defineProperty(URL3.prototype, "port", {
|
|
47596
47596
|
get() {
|
|
47597
47597
|
return this[impl].port;
|
|
47598
47598
|
},
|
|
@@ -47603,7 +47603,7 @@ var require_URL = __commonJS({
|
|
|
47603
47603
|
enumerable: true,
|
|
47604
47604
|
configurable: true
|
|
47605
47605
|
});
|
|
47606
|
-
Object.defineProperty(
|
|
47606
|
+
Object.defineProperty(URL3.prototype, "pathname", {
|
|
47607
47607
|
get() {
|
|
47608
47608
|
return this[impl].pathname;
|
|
47609
47609
|
},
|
|
@@ -47614,7 +47614,7 @@ var require_URL = __commonJS({
|
|
|
47614
47614
|
enumerable: true,
|
|
47615
47615
|
configurable: true
|
|
47616
47616
|
});
|
|
47617
|
-
Object.defineProperty(
|
|
47617
|
+
Object.defineProperty(URL3.prototype, "search", {
|
|
47618
47618
|
get() {
|
|
47619
47619
|
return this[impl].search;
|
|
47620
47620
|
},
|
|
@@ -47625,7 +47625,7 @@ var require_URL = __commonJS({
|
|
|
47625
47625
|
enumerable: true,
|
|
47626
47626
|
configurable: true
|
|
47627
47627
|
});
|
|
47628
|
-
Object.defineProperty(
|
|
47628
|
+
Object.defineProperty(URL3.prototype, "hash", {
|
|
47629
47629
|
get() {
|
|
47630
47630
|
return this[impl].hash;
|
|
47631
47631
|
},
|
|
@@ -47641,7 +47641,7 @@ var require_URL = __commonJS({
|
|
|
47641
47641
|
return !!obj && obj[impl] instanceof Impl.implementation;
|
|
47642
47642
|
},
|
|
47643
47643
|
create(constructorArgs, privateData) {
|
|
47644
|
-
let obj = Object.create(
|
|
47644
|
+
let obj = Object.create(URL3.prototype);
|
|
47645
47645
|
this.setup(obj, constructorArgs, privateData);
|
|
47646
47646
|
return obj;
|
|
47647
47647
|
},
|
|
@@ -47652,10 +47652,10 @@ var require_URL = __commonJS({
|
|
|
47652
47652
|
obj[impl] = new Impl.implementation(constructorArgs, privateData);
|
|
47653
47653
|
obj[impl][utils.wrapperSymbol] = obj;
|
|
47654
47654
|
},
|
|
47655
|
-
interface:
|
|
47655
|
+
interface: URL3,
|
|
47656
47656
|
expose: {
|
|
47657
|
-
Window: { URL:
|
|
47658
|
-
Worker: { URL:
|
|
47657
|
+
Window: { URL: URL3 },
|
|
47658
|
+
Worker: { URL: URL3 }
|
|
47659
47659
|
}
|
|
47660
47660
|
};
|
|
47661
47661
|
}
|
|
@@ -52214,12 +52214,12 @@ var require_lib4 = __commonJS({
|
|
|
52214
52214
|
configurable: true
|
|
52215
52215
|
});
|
|
52216
52216
|
var INTERNALS$2 = Symbol("Request internals");
|
|
52217
|
-
var
|
|
52217
|
+
var URL3 = Url.URL || whatwgUrl.URL;
|
|
52218
52218
|
var parse_url = Url.parse;
|
|
52219
52219
|
var format_url = Url.format;
|
|
52220
52220
|
function parseURL(urlStr) {
|
|
52221
52221
|
if (/^[a-zA-Z][a-zA-Z\d+\-.]*:/.exec(urlStr)) {
|
|
52222
|
-
urlStr = new
|
|
52222
|
+
urlStr = new URL3(urlStr).toString();
|
|
52223
52223
|
}
|
|
52224
52224
|
return parse_url(urlStr);
|
|
52225
52225
|
}
|
|
@@ -64928,7 +64928,7 @@ var require_ms2 = __commonJS({
|
|
|
64928
64928
|
options = options || {};
|
|
64929
64929
|
var type = typeof val;
|
|
64930
64930
|
if (type === "string" && val.length > 0) {
|
|
64931
|
-
return
|
|
64931
|
+
return parse4(val);
|
|
64932
64932
|
} else if (type === "number" && isFinite(val)) {
|
|
64933
64933
|
return options.long ? fmtLong(val) : fmtShort(val);
|
|
64934
64934
|
}
|
|
@@ -64936,7 +64936,7 @@ var require_ms2 = __commonJS({
|
|
|
64936
64936
|
"val is not a non-empty string or a valid number. val=" + JSON.stringify(val)
|
|
64937
64937
|
);
|
|
64938
64938
|
};
|
|
64939
|
-
function
|
|
64939
|
+
function parse4(str2) {
|
|
64940
64940
|
str2 = String(str2);
|
|
64941
64941
|
if (str2.length > 100) {
|
|
64942
64942
|
return;
|
|
@@ -72908,33 +72908,51 @@ async function askForRecordInputs(inputs, name, repl2) {
|
|
|
72908
72908
|
return result;
|
|
72909
72909
|
}
|
|
72910
72910
|
async function askForDiscriminatedUnionInputs(inputs, name, repl2) {
|
|
72911
|
-
|
|
72912
|
-
|
|
72913
|
-
|
|
72914
|
-
message: `Select a ${inputs.discriminator} for ${name}.`,
|
|
72915
|
-
choices: inputs.options.map((option) => {
|
|
72916
|
-
const prop = option.schema[inputs.discriminator];
|
|
72917
|
-
if (prop.type === "enum") {
|
|
72918
|
-
return {
|
|
72919
|
-
title: prop.values.join(", "),
|
|
72920
|
-
description: option.description,
|
|
72921
|
-
value: option
|
|
72922
|
-
};
|
|
72923
|
-
} else if (prop.type !== "literal") {
|
|
72924
|
-
return {
|
|
72925
|
-
title: option.type,
|
|
72926
|
-
description: option.description,
|
|
72927
|
-
value: option
|
|
72928
|
-
};
|
|
72929
|
-
}
|
|
72911
|
+
let choices = inputs.options.map((option) => {
|
|
72912
|
+
const prop = option.schema[inputs.discriminator];
|
|
72913
|
+
if (prop.type === "enum") {
|
|
72930
72914
|
return {
|
|
72931
|
-
title: prop.
|
|
72915
|
+
title: prop.values.join(", "),
|
|
72932
72916
|
description: option.description,
|
|
72933
72917
|
value: option
|
|
72934
72918
|
};
|
|
72935
|
-
})
|
|
72919
|
+
} else if (prop.type !== "literal") {
|
|
72920
|
+
return {
|
|
72921
|
+
title: option.type,
|
|
72922
|
+
description: option.description,
|
|
72923
|
+
value: option
|
|
72924
|
+
};
|
|
72925
|
+
}
|
|
72926
|
+
return {
|
|
72927
|
+
title: prop.value,
|
|
72928
|
+
description: option.description,
|
|
72929
|
+
value: option
|
|
72930
|
+
};
|
|
72931
|
+
});
|
|
72932
|
+
if (inputs.nullable) {
|
|
72933
|
+
choices.unshift({
|
|
72934
|
+
title: "(null)",
|
|
72935
|
+
description: "A null value.",
|
|
72936
|
+
value: null
|
|
72937
|
+
});
|
|
72938
|
+
}
|
|
72939
|
+
if (inputs.optional) {
|
|
72940
|
+
choices.unshift({
|
|
72941
|
+
title: "(undefined)",
|
|
72942
|
+
description: "An undefined value.",
|
|
72943
|
+
value: void 0
|
|
72944
|
+
});
|
|
72945
|
+
}
|
|
72946
|
+
const kind3 = await (0, import_prompts.default)({
|
|
72947
|
+
type: "select",
|
|
72948
|
+
name: "kind",
|
|
72949
|
+
message: `Select a ${inputs.discriminator} for ${name}.`,
|
|
72950
|
+
choices,
|
|
72936
72951
|
onState
|
|
72937
72952
|
});
|
|
72953
|
+
if (kind3.kind === null || kind3.kind === void 0) {
|
|
72954
|
+
return kind3.kind;
|
|
72955
|
+
}
|
|
72938
72956
|
return await askForInputs(kind3.kind, name, repl2);
|
|
72939
72957
|
}
|
|
72940
72958
|
async function askForAnyInputs(name, repl2) {
|
|
@@ -74322,6 +74340,42 @@ if (!globalThis.Blob) {
|
|
|
74322
74340
|
var import_base64_js = __toESM(require_base64_js());
|
|
74323
74341
|
var import_lodash = __toESM(require_lodash());
|
|
74324
74342
|
|
|
74343
|
+
// ../../node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/dist/esm-node/regex.js
|
|
74344
|
+
var regex_default = /^(?:[0-9a-f]{8}-[0-9a-f]{4}-[1-8][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}|00000000-0000-0000-0000-000000000000|ffffffff-ffff-ffff-ffff-ffffffffffff)$/i;
|
|
74345
|
+
|
|
74346
|
+
// ../../node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/dist/esm-node/validate.js
|
|
74347
|
+
function validate(uuid) {
|
|
74348
|
+
return typeof uuid === "string" && regex_default.test(uuid);
|
|
74349
|
+
}
|
|
74350
|
+
var validate_default = validate;
|
|
74351
|
+
|
|
74352
|
+
// ../../node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/dist/esm-node/parse.js
|
|
74353
|
+
function parse(uuid) {
|
|
74354
|
+
if (!validate_default(uuid)) {
|
|
74355
|
+
throw TypeError("Invalid UUID");
|
|
74356
|
+
}
|
|
74357
|
+
let v2;
|
|
74358
|
+
const arr = new Uint8Array(16);
|
|
74359
|
+
arr[0] = (v2 = parseInt(uuid.slice(0, 8), 16)) >>> 24;
|
|
74360
|
+
arr[1] = v2 >>> 16 & 255;
|
|
74361
|
+
arr[2] = v2 >>> 8 & 255;
|
|
74362
|
+
arr[3] = v2 & 255;
|
|
74363
|
+
arr[4] = (v2 = parseInt(uuid.slice(9, 13), 16)) >>> 8;
|
|
74364
|
+
arr[5] = v2 & 255;
|
|
74365
|
+
arr[6] = (v2 = parseInt(uuid.slice(14, 18), 16)) >>> 8;
|
|
74366
|
+
arr[7] = v2 & 255;
|
|
74367
|
+
arr[8] = (v2 = parseInt(uuid.slice(19, 23), 16)) >>> 8;
|
|
74368
|
+
arr[9] = v2 & 255;
|
|
74369
|
+
arr[10] = (v2 = parseInt(uuid.slice(24, 36), 16)) / 1099511627776 & 255;
|
|
74370
|
+
arr[11] = v2 / 4294967296 & 255;
|
|
74371
|
+
arr[12] = v2 >>> 24 & 255;
|
|
74372
|
+
arr[13] = v2 >>> 16 & 255;
|
|
74373
|
+
arr[14] = v2 >>> 8 & 255;
|
|
74374
|
+
arr[15] = v2 & 255;
|
|
74375
|
+
return arr;
|
|
74376
|
+
}
|
|
74377
|
+
var parse_default = parse;
|
|
74378
|
+
|
|
74325
74379
|
// ../../node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/dist/esm-node/stringify.js
|
|
74326
74380
|
var byteToHex = [];
|
|
74327
74381
|
for (let i2 = 0; i2 < 256; ++i2) {
|
|
@@ -74343,6 +74397,53 @@ function rng() {
|
|
|
74343
74397
|
return rnds8Pool.slice(poolPtr, poolPtr += 16);
|
|
74344
74398
|
}
|
|
74345
74399
|
|
|
74400
|
+
// ../../node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/dist/esm-node/v35.js
|
|
74401
|
+
function stringToBytes(str2) {
|
|
74402
|
+
str2 = unescape(encodeURIComponent(str2));
|
|
74403
|
+
const bytes = [];
|
|
74404
|
+
for (let i2 = 0; i2 < str2.length; ++i2) {
|
|
74405
|
+
bytes.push(str2.charCodeAt(i2));
|
|
74406
|
+
}
|
|
74407
|
+
return bytes;
|
|
74408
|
+
}
|
|
74409
|
+
var DNS = "6ba7b810-9dad-11d1-80b4-00c04fd430c8";
|
|
74410
|
+
var URL2 = "6ba7b811-9dad-11d1-80b4-00c04fd430c8";
|
|
74411
|
+
function v35(name, version, hashfunc) {
|
|
74412
|
+
function generateUUID(value, namespace, buf, offset2) {
|
|
74413
|
+
var _namespace;
|
|
74414
|
+
if (typeof value === "string") {
|
|
74415
|
+
value = stringToBytes(value);
|
|
74416
|
+
}
|
|
74417
|
+
if (typeof namespace === "string") {
|
|
74418
|
+
namespace = parse_default(namespace);
|
|
74419
|
+
}
|
|
74420
|
+
if (((_namespace = namespace) === null || _namespace === void 0 ? void 0 : _namespace.length) !== 16) {
|
|
74421
|
+
throw TypeError("Namespace must be array-like (16 iterable integer values, 0-255)");
|
|
74422
|
+
}
|
|
74423
|
+
let bytes = new Uint8Array(16 + value.length);
|
|
74424
|
+
bytes.set(namespace);
|
|
74425
|
+
bytes.set(value, namespace.length);
|
|
74426
|
+
bytes = hashfunc(bytes);
|
|
74427
|
+
bytes[6] = bytes[6] & 15 | version;
|
|
74428
|
+
bytes[8] = bytes[8] & 63 | 128;
|
|
74429
|
+
if (buf) {
|
|
74430
|
+
offset2 = offset2 || 0;
|
|
74431
|
+
for (let i2 = 0; i2 < 16; ++i2) {
|
|
74432
|
+
buf[offset2 + i2] = bytes[i2];
|
|
74433
|
+
}
|
|
74434
|
+
return buf;
|
|
74435
|
+
}
|
|
74436
|
+
return unsafeStringify(bytes);
|
|
74437
|
+
}
|
|
74438
|
+
try {
|
|
74439
|
+
generateUUID.name = name;
|
|
74440
|
+
} catch (err) {
|
|
74441
|
+
}
|
|
74442
|
+
generateUUID.DNS = DNS;
|
|
74443
|
+
generateUUID.URL = URL2;
|
|
74444
|
+
return generateUUID;
|
|
74445
|
+
}
|
|
74446
|
+
|
|
74346
74447
|
// ../../node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/dist/esm-node/native.js
|
|
74347
74448
|
var import_node_crypto3 = __toESM(require("node:crypto"));
|
|
74348
74449
|
var native_default = {
|
|
@@ -74369,6 +74470,22 @@ function v4(options, buf, offset2) {
|
|
|
74369
74470
|
}
|
|
74370
74471
|
var v4_default = v4;
|
|
74371
74472
|
|
|
74473
|
+
// ../../node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/dist/esm-node/sha1.js
|
|
74474
|
+
var import_node_crypto4 = __toESM(require("node:crypto"));
|
|
74475
|
+
function sha1(bytes) {
|
|
74476
|
+
if (Array.isArray(bytes)) {
|
|
74477
|
+
bytes = Buffer.from(bytes);
|
|
74478
|
+
} else if (typeof bytes === "string") {
|
|
74479
|
+
bytes = Buffer.from(bytes, "utf8");
|
|
74480
|
+
}
|
|
74481
|
+
return import_node_crypto4.default.createHash("sha1").update(bytes).digest();
|
|
74482
|
+
}
|
|
74483
|
+
var sha1_default = sha1;
|
|
74484
|
+
|
|
74485
|
+
// ../../node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/dist/esm-node/v5.js
|
|
74486
|
+
var v5 = v35("v5", 80, sha1_default);
|
|
74487
|
+
var v5_default = v5;
|
|
74488
|
+
|
|
74372
74489
|
// ../../node_modules/.pnpm/uuid@10.0.0/node_modules/uuid/dist/esm-node/v7.js
|
|
74373
74490
|
var _seqLow = null;
|
|
74374
74491
|
var _seqHigh = null;
|
|
@@ -76475,7 +76592,7 @@ function combineExtractors(...extractors) {
|
|
|
76475
76592
|
[{}, null, 1]
|
|
76476
76593
|
).slice(0, 2);
|
|
76477
76594
|
}
|
|
76478
|
-
function
|
|
76595
|
+
function parse2(s3, ...patterns) {
|
|
76479
76596
|
if (s3 == null) {
|
|
76480
76597
|
return [null, null];
|
|
76481
76598
|
}
|
|
@@ -76655,7 +76772,7 @@ var extractISOTimeAndOffset = combineExtractors(
|
|
|
76655
76772
|
extractIANAZone
|
|
76656
76773
|
);
|
|
76657
76774
|
function parseISODate(s3) {
|
|
76658
|
-
return
|
|
76775
|
+
return parse2(
|
|
76659
76776
|
s3,
|
|
76660
76777
|
[isoYmdWithTimeExtensionRegex, extractISOYmdTimeAndOffset],
|
|
76661
76778
|
[isoWeekWithTimeExtensionRegex, extractISOWeekTimeAndOffset],
|
|
@@ -76664,10 +76781,10 @@ function parseISODate(s3) {
|
|
|
76664
76781
|
);
|
|
76665
76782
|
}
|
|
76666
76783
|
function parseRFC2822Date(s3) {
|
|
76667
|
-
return
|
|
76784
|
+
return parse2(preprocessRFC2822(s3), [rfc2822, extractRFC2822]);
|
|
76668
76785
|
}
|
|
76669
76786
|
function parseHTTPDate(s3) {
|
|
76670
|
-
return
|
|
76787
|
+
return parse2(
|
|
76671
76788
|
s3,
|
|
76672
76789
|
[rfc1123, extractRFC1123Or850],
|
|
76673
76790
|
[rfc850, extractRFC1123Or850],
|
|
@@ -76675,11 +76792,11 @@ function parseHTTPDate(s3) {
|
|
|
76675
76792
|
);
|
|
76676
76793
|
}
|
|
76677
76794
|
function parseISODuration(s3) {
|
|
76678
|
-
return
|
|
76795
|
+
return parse2(s3, [isoDuration, extractISODuration]);
|
|
76679
76796
|
}
|
|
76680
76797
|
var extractISOTimeOnly = combineExtractors(extractISOTime);
|
|
76681
76798
|
function parseISOTimeOnly(s3) {
|
|
76682
|
-
return
|
|
76799
|
+
return parse2(s3, [isoTimeOnly, extractISOTimeOnly]);
|
|
76683
76800
|
}
|
|
76684
76801
|
var sqlYmdWithTimeExtensionRegex = combineRegexes(sqlYmdRegex, sqlTimeExtensionRegex);
|
|
76685
76802
|
var sqlTimeCombinedRegex = combineRegexes(sqlTimeRegex);
|
|
@@ -76689,7 +76806,7 @@ var extractISOTimeOffsetAndIANAZone = combineExtractors(
|
|
|
76689
76806
|
extractIANAZone
|
|
76690
76807
|
);
|
|
76691
76808
|
function parseSQL(s3) {
|
|
76692
|
-
return
|
|
76809
|
+
return parse2(
|
|
76693
76810
|
s3,
|
|
76694
76811
|
[sqlYmdWithTimeExtensionRegex, extractISOYmdTimeAndOffset],
|
|
76695
76812
|
[sqlTimeCombinedRegex, extractISOTimeOffsetAndIANAZone]
|
|
@@ -85800,6 +85917,7 @@ var LOOM_RESOURCE_KIND = "loom";
|
|
|
85800
85917
|
var SLOYD_RESOURCE_KIND = "ai.sloyd";
|
|
85801
85918
|
var HUME_RESOURCE_KIND = "ai.hume";
|
|
85802
85919
|
var WEBHOOK_RESOURCE_KIND = "webhook";
|
|
85920
|
+
var NOTIFICATION_RESOURCE_KIND = "notification";
|
|
85803
85921
|
var READ_ACTION = "read";
|
|
85804
85922
|
var CREATE_ACTION = "create";
|
|
85805
85923
|
var UPDATE_ACTION = "update";
|
|
@@ -85816,6 +85934,10 @@ var REVOKE_ACTION = "revoke";
|
|
|
85816
85934
|
var SEND_ACTION_ACTION = "sendAction";
|
|
85817
85935
|
var UPDATE_DATA_ACTION = "updateData";
|
|
85818
85936
|
var RUN_ACTION = "run";
|
|
85937
|
+
var SEND_ACTION = "send";
|
|
85938
|
+
var SUBSCRIBE_ACTION = "subscribe";
|
|
85939
|
+
var UNSUBSCRIBE_ACTION = "unsubscribe";
|
|
85940
|
+
var LIST_SUBSCRIPTIONS_ACTION = "listSubscriptions";
|
|
85819
85941
|
var SUBJECT_TYPE_VALIDATION = z.enum(["user", "inst", "role"]);
|
|
85820
85942
|
var DATA_ACTION_KINDS_VALIDATION = z.enum([
|
|
85821
85943
|
READ_ACTION,
|
|
@@ -85871,6 +85993,17 @@ var WEBHOOK_ACTION_KINDS_VALIDATION = z.enum([
|
|
|
85871
85993
|
LIST_ACTION,
|
|
85872
85994
|
RUN_ACTION
|
|
85873
85995
|
]);
|
|
85996
|
+
var NOTIFICATION_ACTION_KINDS_VALIDATION = z.enum([
|
|
85997
|
+
CREATE_ACTION,
|
|
85998
|
+
READ_ACTION,
|
|
85999
|
+
UPDATE_ACTION,
|
|
86000
|
+
DELETE_ACTION,
|
|
86001
|
+
LIST_ACTION,
|
|
86002
|
+
SEND_ACTION,
|
|
86003
|
+
SUBSCRIBE_ACTION,
|
|
86004
|
+
UNSUBSCRIBE_ACTION,
|
|
86005
|
+
LIST_SUBSCRIPTIONS_ACTION
|
|
86006
|
+
]);
|
|
85874
86007
|
var RESOURCE_KIND_VALIDATION = z.enum([
|
|
85875
86008
|
DATA_RESOURCE_KIND,
|
|
85876
86009
|
FILE_RESOURCE_KIND,
|
|
@@ -85881,7 +86014,8 @@ var RESOURCE_KIND_VALIDATION = z.enum([
|
|
|
85881
86014
|
LOOM_RESOURCE_KIND,
|
|
85882
86015
|
SLOYD_RESOURCE_KIND,
|
|
85883
86016
|
HUME_RESOURCE_KIND,
|
|
85884
|
-
WEBHOOK_RESOURCE_KIND
|
|
86017
|
+
WEBHOOK_RESOURCE_KIND,
|
|
86018
|
+
NOTIFICATION_RESOURCE_KIND
|
|
85885
86019
|
]);
|
|
85886
86020
|
var ACTION_KINDS_VALIDATION = z.enum([
|
|
85887
86021
|
CREATE_ACTION,
|
|
@@ -85899,7 +86033,11 @@ var ACTION_KINDS_VALIDATION = z.enum([
|
|
|
85899
86033
|
COUNT_ACTION,
|
|
85900
86034
|
GRANT_PERMISSION_ACTION,
|
|
85901
86035
|
REVOKE_PERMISSION_ACTION,
|
|
85902
|
-
RUN_ACTION
|
|
86036
|
+
RUN_ACTION,
|
|
86037
|
+
SEND_ACTION,
|
|
86038
|
+
SUBSCRIBE_ACTION,
|
|
86039
|
+
UNSUBSCRIBE_ACTION,
|
|
86040
|
+
LIST_SUBSCRIPTIONS_ACTION
|
|
85903
86041
|
]);
|
|
85904
86042
|
var PERMISSION_VALIDATION = z.object({
|
|
85905
86043
|
subjectType: SUBJECT_TYPE_VALIDATION,
|
|
@@ -85958,6 +86096,10 @@ var WEBHOOK_PERMISSION_VALIDATION = PERMISSION_VALIDATION.extend({
|
|
|
85958
86096
|
resourceKind: z.literal(WEBHOOK_RESOURCE_KIND),
|
|
85959
86097
|
action: WEBHOOK_ACTION_KINDS_VALIDATION.nullable()
|
|
85960
86098
|
});
|
|
86099
|
+
var NOTIFICATION_PERMISSION_VALIDATION = PERMISSION_VALIDATION.extend({
|
|
86100
|
+
resourceKind: z.literal(NOTIFICATION_RESOURCE_KIND),
|
|
86101
|
+
action: NOTIFICATION_ACTION_KINDS_VALIDATION.nullable()
|
|
86102
|
+
});
|
|
85961
86103
|
var AVAILABLE_PERMISSIONS_VALIDATION = z.discriminatedUnion(
|
|
85962
86104
|
"resourceKind",
|
|
85963
86105
|
[
|
|
@@ -85970,7 +86112,8 @@ var AVAILABLE_PERMISSIONS_VALIDATION = z.discriminatedUnion(
|
|
|
85970
86112
|
LOOM_PERMISSION_VALIDATION,
|
|
85971
86113
|
SLOYD_PERMISSION_VALIDATION,
|
|
85972
86114
|
HUME_PERMISSION_VALIDATION,
|
|
85973
|
-
WEBHOOK_PERMISSION_VALIDATION
|
|
86115
|
+
WEBHOOK_PERMISSION_VALIDATION,
|
|
86116
|
+
NOTIFICATION_PERMISSION_VALIDATION
|
|
85974
86117
|
]
|
|
85975
86118
|
);
|
|
85976
86119
|
var ADMIN_ROLE_NAME = "admin";
|
|
@@ -86924,14 +87067,14 @@ var StringDecoder = class {
|
|
|
86924
87067
|
};
|
|
86925
87068
|
|
|
86926
87069
|
// ../../node_modules/.pnpm/lib0@0.2.88/node_modules/lib0/webcrypto.node.js
|
|
86927
|
-
var
|
|
87070
|
+
var import_node_crypto5 = require("node:crypto");
|
|
86928
87071
|
var subtle = (
|
|
86929
87072
|
/** @type {any} */
|
|
86930
|
-
|
|
87073
|
+
import_node_crypto5.webcrypto.subtle
|
|
86931
87074
|
);
|
|
86932
87075
|
var getRandomValues = (
|
|
86933
87076
|
/** @type {any} */
|
|
86934
|
-
|
|
87077
|
+
import_node_crypto5.webcrypto.getRandomValues.bind(import_node_crypto5.webcrypto)
|
|
86935
87078
|
);
|
|
86936
87079
|
|
|
86937
87080
|
// ../../node_modules/.pnpm/lib0@0.2.88/node_modules/lib0/random.js
|
|
@@ -96760,7 +96903,7 @@ var trace = TraceAPI.getInstance();
|
|
|
96760
96903
|
function hashLowEntropyPasswordWithSalt2(password, salt) {
|
|
96761
96904
|
const tracer = trace.getTracer(
|
|
96762
96905
|
"InstrumentedHashHelpers",
|
|
96763
|
-
false ? void 0 : "v3.3.11
|
|
96906
|
+
false ? void 0 : "v3.3.11"
|
|
96764
96907
|
);
|
|
96765
96908
|
return tracer.startActiveSpan(
|
|
96766
96909
|
"hashLowEntropyPasswordWithSalt",
|
|
@@ -96778,7 +96921,7 @@ function hashLowEntropyPasswordWithSalt2(password, salt) {
|
|
|
96778
96921
|
function hashHighEntropyPasswordWithSalt2(password, salt) {
|
|
96779
96922
|
const tracer = trace.getTracer(
|
|
96780
96923
|
"InstrumentedHashHelpers",
|
|
96781
|
-
false ? void 0 : "v3.3.11
|
|
96924
|
+
false ? void 0 : "v3.3.11"
|
|
96782
96925
|
);
|
|
96783
96926
|
return tracer.startActiveSpan(
|
|
96784
96927
|
"hashHighEntropyPasswordWithSalt",
|
|
@@ -96796,7 +96939,7 @@ function hashHighEntropyPasswordWithSalt2(password, salt) {
|
|
|
96796
96939
|
function verifyPasswordAgainstHashes2(password, salt, hashes) {
|
|
96797
96940
|
const tracer = trace.getTracer(
|
|
96798
96941
|
"InstrumentedHashHelpers",
|
|
96799
|
-
false ? void 0 : "v3.3.11
|
|
96942
|
+
false ? void 0 : "v3.3.11"
|
|
96800
96943
|
);
|
|
96801
96944
|
return tracer.startActiveSpan(
|
|
96802
96945
|
"verifyPasswordAgainstHashes",
|
|
@@ -103397,7 +103540,7 @@ var import_semantic_conventions = __toESM(require_src3());
|
|
|
103397
103540
|
function traced(tracerName, options = {}, metricOptions = {}) {
|
|
103398
103541
|
const tracer = trace.getTracer(
|
|
103399
103542
|
tracerName,
|
|
103400
|
-
false ? void 0 : "v3.3.11
|
|
103543
|
+
false ? void 0 : "v3.3.11"
|
|
103401
103544
|
);
|
|
103402
103545
|
return function(target, propertyKey, descriptor) {
|
|
103403
103546
|
const originalMethod = descriptor.value;
|
|
@@ -103475,7 +103618,7 @@ function getHistogram(meter) {
|
|
|
103475
103618
|
}
|
|
103476
103619
|
return metrics.getMeter(
|
|
103477
103620
|
meter.meter,
|
|
103478
|
-
false ? void 0 : "v3.3.11
|
|
103621
|
+
false ? void 0 : "v3.3.11"
|
|
103479
103622
|
).createHistogram(meter.name, meter.options);
|
|
103480
103623
|
}
|
|
103481
103624
|
function getCounter(meter) {
|
|
@@ -103484,7 +103627,7 @@ function getCounter(meter) {
|
|
|
103484
103627
|
}
|
|
103485
103628
|
return metrics.getMeter(
|
|
103486
103629
|
meter.meter,
|
|
103487
|
-
false ? void 0 : "v3.3.11
|
|
103630
|
+
false ? void 0 : "v3.3.11"
|
|
103488
103631
|
).createCounter(meter.name, meter.options);
|
|
103489
103632
|
}
|
|
103490
103633
|
function traceHttpResponse(options = {}) {
|
|
@@ -103534,6 +103677,7 @@ var AuthController = class {
|
|
|
103534
103677
|
this._forceAllowSubscriptionFeatures = forceAllowSubscriptionFeatures;
|
|
103535
103678
|
this._privoClient = privoClient;
|
|
103536
103679
|
this._webAuthNRelyingParties = relyingParties;
|
|
103680
|
+
this._privoEnabled = this._privoClient !== null;
|
|
103537
103681
|
}
|
|
103538
103682
|
get relyingParties() {
|
|
103539
103683
|
return this._webAuthNRelyingParties;
|
|
@@ -103541,6 +103685,18 @@ var AuthController = class {
|
|
|
103541
103685
|
set relyingParties(value) {
|
|
103542
103686
|
this._webAuthNRelyingParties = value;
|
|
103543
103687
|
}
|
|
103688
|
+
/**
|
|
103689
|
+
* Gets whether Privo-features are enabled.
|
|
103690
|
+
*/
|
|
103691
|
+
get privoEnabled() {
|
|
103692
|
+
return this._privoEnabled;
|
|
103693
|
+
}
|
|
103694
|
+
/**
|
|
103695
|
+
* Sets whether Privo-features are enabled.
|
|
103696
|
+
*/
|
|
103697
|
+
set privoEnabled(value) {
|
|
103698
|
+
this._privoEnabled = value;
|
|
103699
|
+
}
|
|
103544
103700
|
async createAccount(request2) {
|
|
103545
103701
|
try {
|
|
103546
103702
|
const createSession = request2.createSession ?? true;
|
|
@@ -103579,7 +103735,13 @@ var AuthController = class {
|
|
|
103579
103735
|
userId: newUser.id,
|
|
103580
103736
|
sessionKey: null,
|
|
103581
103737
|
connectionKey: null,
|
|
103582
|
-
expireTimeMs: null
|
|
103738
|
+
expireTimeMs: null,
|
|
103739
|
+
metadata: {
|
|
103740
|
+
hasUserAuthenticator: false,
|
|
103741
|
+
userAuthenticatorCredentialIds: [],
|
|
103742
|
+
hasPushSubscription: false,
|
|
103743
|
+
pushSubscriptionIds: []
|
|
103744
|
+
}
|
|
103583
103745
|
};
|
|
103584
103746
|
}
|
|
103585
103747
|
} catch (err) {
|
|
@@ -104139,6 +104301,13 @@ var AuthController = class {
|
|
|
104139
104301
|
);
|
|
104140
104302
|
const serviceId = result.userInfo.serviceId;
|
|
104141
104303
|
const email = result.userInfo.email;
|
|
104304
|
+
if (result.userInfo.roleIdentifier !== config2.roleIds.adult && result.userInfo.roleIdentifier !== config2.roleIds.child) {
|
|
104305
|
+
return {
|
|
104306
|
+
success: false,
|
|
104307
|
+
errorCode: "invalid_request",
|
|
104308
|
+
errorMessage: "The login request is invalid. You attempted to sign into an account that is associated with a parent email address. This is not allowed because we don't ask consent for parent accounts, but all accounts must have consent. Please sign up with a new account instead."
|
|
104309
|
+
};
|
|
104310
|
+
}
|
|
104142
104311
|
let user;
|
|
104143
104312
|
if (serviceId) {
|
|
104144
104313
|
user = await this._store.findUserByPrivoServiceId(
|
|
@@ -104262,6 +104431,7 @@ var AuthController = class {
|
|
|
104262
104431
|
let updatePasswordUrl;
|
|
104263
104432
|
let serviceId;
|
|
104264
104433
|
let parentServiceId;
|
|
104434
|
+
let consentUrl;
|
|
104265
104435
|
if (years < 0) {
|
|
104266
104436
|
return {
|
|
104267
104437
|
success: false,
|
|
@@ -104298,6 +104468,7 @@ var AuthController = class {
|
|
|
104298
104468
|
serviceId = result.childServiceId;
|
|
104299
104469
|
parentServiceId = result.parentServiceId;
|
|
104300
104470
|
updatePasswordUrl = result.updatePasswordLink;
|
|
104471
|
+
consentUrl = result.consentUrl;
|
|
104301
104472
|
privacyFeatures = getPrivacyFeaturesFromPermissions(
|
|
104302
104473
|
config2.featureIds,
|
|
104303
104474
|
result.features
|
|
@@ -104328,6 +104499,7 @@ var AuthController = class {
|
|
|
104328
104499
|
}
|
|
104329
104500
|
serviceId = result.adultServiceId;
|
|
104330
104501
|
updatePasswordUrl = result.updatePasswordLink;
|
|
104502
|
+
consentUrl = result.consentUrl;
|
|
104331
104503
|
privacyFeatures = getPrivacyFeaturesFromPermissions(
|
|
104332
104504
|
config2.featureIds,
|
|
104333
104505
|
result.features
|
|
@@ -104344,6 +104516,7 @@ var AuthController = class {
|
|
|
104344
104516
|
currentLoginRequestId: null,
|
|
104345
104517
|
privoServiceId: serviceId,
|
|
104346
104518
|
privoParentServiceId: parentServiceId,
|
|
104519
|
+
privoConsentUrl: consentUrl,
|
|
104347
104520
|
privacyFeatures
|
|
104348
104521
|
};
|
|
104349
104522
|
const saveUserResult = await this._store.saveNewUser(user);
|
|
@@ -105589,6 +105762,77 @@ var AuthController = class {
|
|
|
105589
105762
|
};
|
|
105590
105763
|
}
|
|
105591
105764
|
}
|
|
105765
|
+
async requestPrivacyFeaturesChange(request2) {
|
|
105766
|
+
try {
|
|
105767
|
+
if (!this._privoClient) {
|
|
105768
|
+
return {
|
|
105769
|
+
success: false,
|
|
105770
|
+
errorCode: "not_supported",
|
|
105771
|
+
errorMessage: "Privo features are not supported on this server."
|
|
105772
|
+
};
|
|
105773
|
+
}
|
|
105774
|
+
const config2 = await this._config.getPrivoConfiguration();
|
|
105775
|
+
if (!config2) {
|
|
105776
|
+
return {
|
|
105777
|
+
success: false,
|
|
105778
|
+
errorCode: "not_supported",
|
|
105779
|
+
errorMessage: "Privo features are not supported on this server."
|
|
105780
|
+
};
|
|
105781
|
+
}
|
|
105782
|
+
const keyResult = await this.validateSessionKey(request2.sessionKey);
|
|
105783
|
+
if (keyResult.success === false) {
|
|
105784
|
+
return keyResult;
|
|
105785
|
+
} else if (keyResult.userId !== request2.userId && keyResult.role !== "superUser") {
|
|
105786
|
+
console.log(
|
|
105787
|
+
"[AuthController] [requestPrivacyFeaturesChange] Request User ID doesnt match session key User ID!"
|
|
105788
|
+
);
|
|
105789
|
+
return {
|
|
105790
|
+
success: false,
|
|
105791
|
+
errorCode: "invalid_key",
|
|
105792
|
+
errorMessage: INVALID_KEY_ERROR_MESSAGE
|
|
105793
|
+
};
|
|
105794
|
+
}
|
|
105795
|
+
const user = await this._store.findUser(request2.userId);
|
|
105796
|
+
if (!user) {
|
|
105797
|
+
throw new Error(
|
|
105798
|
+
"Unable to find user even though a valid session key was presented!"
|
|
105799
|
+
);
|
|
105800
|
+
}
|
|
105801
|
+
if (!user.privoServiceId) {
|
|
105802
|
+
return {
|
|
105803
|
+
success: false,
|
|
105804
|
+
errorCode: "not_supported",
|
|
105805
|
+
errorMessage: "Privo features are not supported on this server."
|
|
105806
|
+
};
|
|
105807
|
+
}
|
|
105808
|
+
const result = await this._privoClient.resendConsentRequest(
|
|
105809
|
+
user.privoServiceId,
|
|
105810
|
+
user.privoParentServiceId ?? user.privoServiceId
|
|
105811
|
+
);
|
|
105812
|
+
if (result.success === false) {
|
|
105813
|
+
return result;
|
|
105814
|
+
}
|
|
105815
|
+
console.log(
|
|
105816
|
+
`[AuthController] [requestPrivacyFeaturesChange] [userId: ${request2.userId}] Requested privacy features change.`
|
|
105817
|
+
);
|
|
105818
|
+
return {
|
|
105819
|
+
success: true
|
|
105820
|
+
};
|
|
105821
|
+
} catch (err) {
|
|
105822
|
+
const span = trace.getActiveSpan();
|
|
105823
|
+
span?.recordException(err);
|
|
105824
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
105825
|
+
console.error(
|
|
105826
|
+
"[AuthController] Error ocurred while requesting a change in privacy features",
|
|
105827
|
+
err
|
|
105828
|
+
);
|
|
105829
|
+
return {
|
|
105830
|
+
success: false,
|
|
105831
|
+
errorCode: "server_error",
|
|
105832
|
+
errorMessage: "A server error occurred."
|
|
105833
|
+
};
|
|
105834
|
+
}
|
|
105835
|
+
}
|
|
105592
105836
|
async listEmailRules() {
|
|
105593
105837
|
try {
|
|
105594
105838
|
const rules = await this._store.listEmailRules();
|
|
@@ -105782,6 +106026,7 @@ var AuthController = class {
|
|
|
105782
106026
|
} else {
|
|
105783
106027
|
await this._store.saveSession(newSession);
|
|
105784
106028
|
}
|
|
106029
|
+
const metadata = await this._store.findUserLoginMetadata(userId);
|
|
105785
106030
|
const info = {
|
|
105786
106031
|
userId,
|
|
105787
106032
|
sessionKey: formatV1SessionKey(
|
|
@@ -105796,7 +106041,13 @@ var AuthController = class {
|
|
|
105796
106041
|
newConnectionSecret,
|
|
105797
106042
|
newSession.expireTimeMs
|
|
105798
106043
|
),
|
|
105799
|
-
expireTimeMs: newSession.expireTimeMs
|
|
106044
|
+
expireTimeMs: newSession.expireTimeMs,
|
|
106045
|
+
metadata: {
|
|
106046
|
+
hasUserAuthenticator: metadata?.hasUserAuthenticator ?? false,
|
|
106047
|
+
userAuthenticatorCredentialIds: metadata?.userAuthenticatorCredentialIds ?? [],
|
|
106048
|
+
hasPushSubscription: metadata?.hasPushSubscription ?? false,
|
|
106049
|
+
pushSubscriptionIds: metadata?.pushSubscriptionIds ?? []
|
|
106050
|
+
}
|
|
105800
106051
|
};
|
|
105801
106052
|
return {
|
|
105802
106053
|
newSession,
|
|
@@ -105879,6 +106130,9 @@ __decorateClass([
|
|
|
105879
106130
|
__decorateClass([
|
|
105880
106131
|
traced(TRACE_NAME)
|
|
105881
106132
|
], AuthController.prototype, "updateUserInfo", 1);
|
|
106133
|
+
__decorateClass([
|
|
106134
|
+
traced(TRACE_NAME)
|
|
106135
|
+
], AuthController.prototype, "requestPrivacyFeaturesChange", 1);
|
|
105882
106136
|
__decorateClass([
|
|
105883
106137
|
traced(TRACE_NAME)
|
|
105884
106138
|
], AuthController.prototype, "listEmailRules", 1);
|
|
@@ -106127,6 +106381,27 @@ var subscriptionFeaturesSchema = z.object({
|
|
|
106127
106381
|
"The configuration for webhook features. Defaults to not allowed."
|
|
106128
106382
|
).optional().default({
|
|
106129
106383
|
allowed: false
|
|
106384
|
+
}),
|
|
106385
|
+
notifications: z.object({
|
|
106386
|
+
allowed: z.boolean().describe(
|
|
106387
|
+
"Whether notifications are allowed for the subscription."
|
|
106388
|
+
),
|
|
106389
|
+
maxItems: z.number().describe(
|
|
106390
|
+
"The maximum number of notification items that are allowed for the subscription. If not specified, then there is no limit."
|
|
106391
|
+
).int().positive().optional(),
|
|
106392
|
+
maxSubscribersPerItem: z.number().describe(
|
|
106393
|
+
"The maximum number of subscribers that a notification can have in the subscription. If not specified, then there is no limit."
|
|
106394
|
+
).int().positive().optional(),
|
|
106395
|
+
maxSentNotificationsPerPeriod: z.number().describe(
|
|
106396
|
+
'The maximum number of notifications that can be sent per subscription period. This tracks the number of times the "sendNotification" operation was called. If not specified, then there is no limit.'
|
|
106397
|
+
).int().positive().optional(),
|
|
106398
|
+
maxSentPushNotificationsPerPeriod: z.number().describe(
|
|
106399
|
+
"The maximum number of push notifications that can be sent per subscription period. This tracks the actual number of push notifications that were sent to users. If not specified, then there is no limit."
|
|
106400
|
+
).int().positive().optional()
|
|
106401
|
+
}).describe(
|
|
106402
|
+
"The configuration for notification features. Defaults to not allowed."
|
|
106403
|
+
).optional().default({
|
|
106404
|
+
allowed: false
|
|
106130
106405
|
})
|
|
106131
106406
|
});
|
|
106132
106407
|
var subscriptionConfigSchema = z.object({
|
|
@@ -106256,45 +106531,72 @@ function allowAllFeatures() {
|
|
|
106256
106531
|
},
|
|
106257
106532
|
insts: {
|
|
106258
106533
|
allowed: true
|
|
106534
|
+
},
|
|
106535
|
+
notifications: {
|
|
106536
|
+
allowed: true
|
|
106259
106537
|
}
|
|
106260
106538
|
};
|
|
106261
106539
|
}
|
|
106262
|
-
function
|
|
106540
|
+
function getNotificationFeatures(config2, subscriptionStatus, subscriptionId, type, periodStartMs, periodEndMs, nowMs = Date.now()) {
|
|
106263
106541
|
const features = getSubscriptionFeatures(
|
|
106264
106542
|
config2,
|
|
106265
106543
|
subscriptionStatus,
|
|
106266
106544
|
subscriptionId,
|
|
106267
|
-
type
|
|
106545
|
+
type,
|
|
106546
|
+
periodStartMs,
|
|
106547
|
+
periodEndMs,
|
|
106548
|
+
nowMs
|
|
106549
|
+
);
|
|
106550
|
+
return features.notifications ?? { allowed: false };
|
|
106551
|
+
}
|
|
106552
|
+
function getWebhookFeatures(config2, subscriptionStatus, subscriptionId, type, periodStartMs, periodEndMs, nowMs = Date.now()) {
|
|
106553
|
+
const features = getSubscriptionFeatures(
|
|
106554
|
+
config2,
|
|
106555
|
+
subscriptionStatus,
|
|
106556
|
+
subscriptionId,
|
|
106557
|
+
type,
|
|
106558
|
+
periodStartMs,
|
|
106559
|
+
periodEndMs,
|
|
106560
|
+
nowMs
|
|
106268
106561
|
);
|
|
106269
106562
|
return features.webhooks ?? { allowed: false };
|
|
106270
106563
|
}
|
|
106271
|
-
function getComIdFeatures(config2, subscriptionStatus, subscriptionId) {
|
|
106564
|
+
function getComIdFeatures(config2, subscriptionStatus, subscriptionId, periodStartMs, periodEndMs, nowMs = Date.now()) {
|
|
106272
106565
|
const features = getSubscriptionFeatures(
|
|
106273
106566
|
config2,
|
|
106274
106567
|
subscriptionStatus,
|
|
106275
106568
|
subscriptionId,
|
|
106276
|
-
"studio"
|
|
106569
|
+
"studio",
|
|
106570
|
+
periodStartMs,
|
|
106571
|
+
periodEndMs,
|
|
106572
|
+
nowMs
|
|
106277
106573
|
);
|
|
106278
106574
|
return features.comId ?? {
|
|
106279
106575
|
allowed: false
|
|
106280
106576
|
// allowCustomComId: false,
|
|
106281
106577
|
};
|
|
106282
106578
|
}
|
|
106283
|
-
function getLoomFeatures(config2, subscriptionStatus, subscriptionId) {
|
|
106579
|
+
function getLoomFeatures(config2, subscriptionStatus, subscriptionId, periodStartMs, periodEndMs, nowMs = Date.now()) {
|
|
106284
106580
|
const features = getSubscriptionFeatures(
|
|
106285
106581
|
config2,
|
|
106286
106582
|
subscriptionStatus,
|
|
106287
106583
|
subscriptionId,
|
|
106288
|
-
"studio"
|
|
106584
|
+
"studio",
|
|
106585
|
+
periodStartMs,
|
|
106586
|
+
periodEndMs,
|
|
106587
|
+
nowMs
|
|
106289
106588
|
);
|
|
106290
106589
|
return features.loom ?? { allowed: false };
|
|
106291
106590
|
}
|
|
106292
|
-
function getHumeAiFeatures(config2, subscriptionStatus, subscriptionId, type) {
|
|
106591
|
+
function getHumeAiFeatures(config2, subscriptionStatus, subscriptionId, type, periodStartMs, periodEndMs, nowMs = Date.now()) {
|
|
106293
106592
|
const features = getSubscriptionFeatures(
|
|
106294
106593
|
config2,
|
|
106295
106594
|
subscriptionStatus,
|
|
106296
106595
|
subscriptionId,
|
|
106297
|
-
type
|
|
106596
|
+
type,
|
|
106597
|
+
periodStartMs,
|
|
106598
|
+
periodEndMs,
|
|
106599
|
+
nowMs
|
|
106298
106600
|
);
|
|
106299
106601
|
return features.ai.hume ?? { allowed: false };
|
|
106300
106602
|
}
|
|
@@ -107828,6 +108130,13 @@ function getPublicReadPermission(resourceKind, action2) {
|
|
|
107828
108130
|
action: action2
|
|
107829
108131
|
};
|
|
107830
108132
|
}
|
|
108133
|
+
} else if (resourceKind === "notification") {
|
|
108134
|
+
if (action2 === "read" || action2 === "list" || action2 === "subscribe") {
|
|
108135
|
+
return {
|
|
108136
|
+
resourceKind,
|
|
108137
|
+
action: action2
|
|
108138
|
+
};
|
|
108139
|
+
}
|
|
107831
108140
|
}
|
|
107832
108141
|
return null;
|
|
107833
108142
|
}
|
|
@@ -107867,6 +108176,13 @@ function getPublicWritePermission(resourceKind, action2) {
|
|
|
107867
108176
|
action: action2
|
|
107868
108177
|
};
|
|
107869
108178
|
}
|
|
108179
|
+
} else if (resourceKind === "notification") {
|
|
108180
|
+
if (action2 === "read" || action2 === "list" || action2 === "subscribe") {
|
|
108181
|
+
return {
|
|
108182
|
+
resourceKind,
|
|
108183
|
+
action: action2
|
|
108184
|
+
};
|
|
108185
|
+
}
|
|
107870
108186
|
}
|
|
107871
108187
|
return null;
|
|
107872
108188
|
}
|
|
@@ -110645,12 +110961,21 @@ var PolicyController = class {
|
|
|
110645
110961
|
recordOwnerPrivacyFeatures = await this._policies.getUserPrivacyFeatures(ownerId);
|
|
110646
110962
|
}
|
|
110647
110963
|
if (!recordOwnerPrivacyFeatures) {
|
|
110648
|
-
|
|
110649
|
-
|
|
110650
|
-
|
|
110651
|
-
|
|
110652
|
-
|
|
110653
|
-
|
|
110964
|
+
if (this._auth.privoEnabled) {
|
|
110965
|
+
recordOwnerPrivacyFeatures = {
|
|
110966
|
+
allowAI: false,
|
|
110967
|
+
allowPublicData: false,
|
|
110968
|
+
allowPublicInsts: false,
|
|
110969
|
+
publishData: false
|
|
110970
|
+
};
|
|
110971
|
+
} else {
|
|
110972
|
+
recordOwnerPrivacyFeatures = {
|
|
110973
|
+
allowAI: true,
|
|
110974
|
+
allowPublicData: true,
|
|
110975
|
+
allowPublicInsts: true,
|
|
110976
|
+
publishData: true
|
|
110977
|
+
};
|
|
110978
|
+
}
|
|
110654
110979
|
}
|
|
110655
110980
|
if (request2.userId) {
|
|
110656
110981
|
userPrivacyFeatures = await this._policies.getUserPrivacyFeatures(
|
|
@@ -110658,12 +110983,21 @@ var PolicyController = class {
|
|
|
110658
110983
|
);
|
|
110659
110984
|
}
|
|
110660
110985
|
if (!userPrivacyFeatures) {
|
|
110661
|
-
|
|
110662
|
-
|
|
110663
|
-
|
|
110664
|
-
|
|
110665
|
-
|
|
110666
|
-
|
|
110986
|
+
if (this._auth.privoEnabled) {
|
|
110987
|
+
userPrivacyFeatures = {
|
|
110988
|
+
allowAI: false,
|
|
110989
|
+
allowPublicData: false,
|
|
110990
|
+
allowPublicInsts: false,
|
|
110991
|
+
publishData: false
|
|
110992
|
+
};
|
|
110993
|
+
} else {
|
|
110994
|
+
userPrivacyFeatures = {
|
|
110995
|
+
allowAI: true,
|
|
110996
|
+
allowPublicData: true,
|
|
110997
|
+
allowPublicInsts: true,
|
|
110998
|
+
publishData: true
|
|
110999
|
+
};
|
|
111000
|
+
}
|
|
110667
111001
|
}
|
|
110668
111002
|
const context = {
|
|
110669
111003
|
recordName,
|
|
@@ -114041,7 +114375,1062 @@ function eraseItemProcedure(auth7, controller, builder) {
|
|
|
114041
114375
|
}
|
|
114042
114376
|
|
|
114043
114377
|
// ../aux-records/RecordsServer.ts
|
|
114378
|
+
var import_lodash23 = __toESM(require_lodash());
|
|
114379
|
+
|
|
114380
|
+
// ../aux-records/crud/CrudRecordsController.ts
|
|
114381
|
+
var TRACE_NAME8 = "CrudRecordsController";
|
|
114382
|
+
var CrudRecordsController = class {
|
|
114383
|
+
get config() {
|
|
114384
|
+
return this._config;
|
|
114385
|
+
}
|
|
114386
|
+
/**
|
|
114387
|
+
* Gets the name of the controller.
|
|
114388
|
+
*/
|
|
114389
|
+
get name() {
|
|
114390
|
+
return this._name;
|
|
114391
|
+
}
|
|
114392
|
+
get policies() {
|
|
114393
|
+
return this._policies;
|
|
114394
|
+
}
|
|
114395
|
+
get store() {
|
|
114396
|
+
return this._store;
|
|
114397
|
+
}
|
|
114398
|
+
/**
|
|
114399
|
+
* Gets the kind of resources that this controller is for.
|
|
114400
|
+
*/
|
|
114401
|
+
get resourceKind() {
|
|
114402
|
+
return this._resourceKind;
|
|
114403
|
+
}
|
|
114404
|
+
constructor(config2) {
|
|
114405
|
+
this._name = config2.name;
|
|
114406
|
+
this._store = config2.store;
|
|
114407
|
+
this._policies = config2.policies;
|
|
114408
|
+
this._config = config2.config;
|
|
114409
|
+
this._resourceKind = config2.resourceKind;
|
|
114410
|
+
}
|
|
114411
|
+
async recordItem(request2) {
|
|
114412
|
+
try {
|
|
114413
|
+
const contextResult = await this._policies.constructAuthorizationContext({
|
|
114414
|
+
recordKeyOrRecordName: request2.recordKeyOrRecordName,
|
|
114415
|
+
userId: request2.userId
|
|
114416
|
+
});
|
|
114417
|
+
if (contextResult.success === false) {
|
|
114418
|
+
return contextResult;
|
|
114419
|
+
}
|
|
114420
|
+
const recordName = contextResult.context.recordName;
|
|
114421
|
+
const existingItem = await this._store.getItemByAddress(
|
|
114422
|
+
recordName,
|
|
114423
|
+
request2.item.address
|
|
114424
|
+
);
|
|
114425
|
+
let resourceMarkers;
|
|
114426
|
+
let action2 = existingItem ? "update" : "create";
|
|
114427
|
+
let authorization;
|
|
114428
|
+
if (action2 === "update") {
|
|
114429
|
+
const existingMarkers = existingItem.markers;
|
|
114430
|
+
resourceMarkers = request2.item.markers ?? existingMarkers;
|
|
114431
|
+
action2 = "update";
|
|
114432
|
+
authorization = await this._policies.authorizeUserAndInstancesForResources(
|
|
114433
|
+
contextResult.context,
|
|
114434
|
+
{
|
|
114435
|
+
userId: request2.userId,
|
|
114436
|
+
instances: request2.instances,
|
|
114437
|
+
resources: [
|
|
114438
|
+
{
|
|
114439
|
+
resourceKind: this._resourceKind,
|
|
114440
|
+
resourceId: existingItem.address,
|
|
114441
|
+
action: action2,
|
|
114442
|
+
markers: resourceMarkers
|
|
114443
|
+
},
|
|
114444
|
+
...getMarkerResourcesForUpdate(
|
|
114445
|
+
existingMarkers,
|
|
114446
|
+
request2.item.markers
|
|
114447
|
+
)
|
|
114448
|
+
]
|
|
114449
|
+
}
|
|
114450
|
+
);
|
|
114451
|
+
if (authorization.success === false) {
|
|
114452
|
+
return authorization;
|
|
114453
|
+
}
|
|
114454
|
+
} else {
|
|
114455
|
+
resourceMarkers = request2.item.markers;
|
|
114456
|
+
authorization = await this._policies.authorizeUserAndInstancesForResources(
|
|
114457
|
+
contextResult.context,
|
|
114458
|
+
{
|
|
114459
|
+
userId: request2.userId,
|
|
114460
|
+
instances: request2.instances,
|
|
114461
|
+
resources: [
|
|
114462
|
+
{
|
|
114463
|
+
resourceKind: this._resourceKind,
|
|
114464
|
+
resourceId: request2.item.address,
|
|
114465
|
+
action: action2,
|
|
114466
|
+
markers: resourceMarkers
|
|
114467
|
+
},
|
|
114468
|
+
...getMarkerResourcesForCreation(
|
|
114469
|
+
resourceMarkers
|
|
114470
|
+
)
|
|
114471
|
+
]
|
|
114472
|
+
}
|
|
114473
|
+
);
|
|
114474
|
+
if (authorization.success === false) {
|
|
114475
|
+
return authorization;
|
|
114476
|
+
}
|
|
114477
|
+
}
|
|
114478
|
+
if (!resourceMarkers) {
|
|
114479
|
+
return {
|
|
114480
|
+
success: false,
|
|
114481
|
+
errorCode: "invalid_request",
|
|
114482
|
+
errorMessage: "The item must have markers."
|
|
114483
|
+
};
|
|
114484
|
+
}
|
|
114485
|
+
const item = this._transformInputItem(request2.item);
|
|
114486
|
+
const subscriptionResult = await this._checkSubscriptionMetrics(
|
|
114487
|
+
action2,
|
|
114488
|
+
contextResult.context,
|
|
114489
|
+
authorization,
|
|
114490
|
+
item
|
|
114491
|
+
);
|
|
114492
|
+
if (subscriptionResult.success === false) {
|
|
114493
|
+
return subscriptionResult;
|
|
114494
|
+
}
|
|
114495
|
+
await this._store.putItem(recordName, item);
|
|
114496
|
+
return {
|
|
114497
|
+
success: true,
|
|
114498
|
+
recordName,
|
|
114499
|
+
address: item.address
|
|
114500
|
+
};
|
|
114501
|
+
} catch (err) {
|
|
114502
|
+
const span = trace.getActiveSpan();
|
|
114503
|
+
span?.recordException(err);
|
|
114504
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
114505
|
+
console.error(`[${this._name}] Error recording item:`, err);
|
|
114506
|
+
return {
|
|
114507
|
+
success: false,
|
|
114508
|
+
errorCode: "server_error",
|
|
114509
|
+
errorMessage: "A server error occurred."
|
|
114510
|
+
};
|
|
114511
|
+
}
|
|
114512
|
+
}
|
|
114513
|
+
async getItem(request2) {
|
|
114514
|
+
try {
|
|
114515
|
+
const baseRequest = {
|
|
114516
|
+
recordKeyOrRecordName: request2.recordName,
|
|
114517
|
+
userId: request2.userId,
|
|
114518
|
+
instances: request2.instances
|
|
114519
|
+
};
|
|
114520
|
+
const context = await this._policies.constructAuthorizationContext(
|
|
114521
|
+
baseRequest
|
|
114522
|
+
);
|
|
114523
|
+
if (context.success === false) {
|
|
114524
|
+
return context;
|
|
114525
|
+
}
|
|
114526
|
+
const result = await this._store.getItemByAddress(
|
|
114527
|
+
context.context.recordName,
|
|
114528
|
+
request2.address
|
|
114529
|
+
);
|
|
114530
|
+
if (!result) {
|
|
114531
|
+
return {
|
|
114532
|
+
success: false,
|
|
114533
|
+
errorCode: "data_not_found",
|
|
114534
|
+
errorMessage: "The item was not found."
|
|
114535
|
+
};
|
|
114536
|
+
}
|
|
114537
|
+
const markers = result.markers;
|
|
114538
|
+
const authorization = await this._policies.authorizeUserAndInstances(
|
|
114539
|
+
context.context,
|
|
114540
|
+
{
|
|
114541
|
+
userId: request2.userId,
|
|
114542
|
+
instances: request2.instances,
|
|
114543
|
+
resourceKind: this._resourceKind,
|
|
114544
|
+
resourceId: request2.address,
|
|
114545
|
+
action: "read",
|
|
114546
|
+
markers
|
|
114547
|
+
}
|
|
114548
|
+
);
|
|
114549
|
+
if (authorization.success === false) {
|
|
114550
|
+
return authorization;
|
|
114551
|
+
}
|
|
114552
|
+
return {
|
|
114553
|
+
success: true,
|
|
114554
|
+
item: this._convertItemToResult(result, context.context)
|
|
114555
|
+
};
|
|
114556
|
+
} catch (err) {
|
|
114557
|
+
const span = trace.getActiveSpan();
|
|
114558
|
+
span?.recordException(err);
|
|
114559
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
114560
|
+
console.error(`[${this._name}] Error getting item:`, err);
|
|
114561
|
+
return {
|
|
114562
|
+
success: false,
|
|
114563
|
+
errorCode: "server_error",
|
|
114564
|
+
errorMessage: "A server error occurred."
|
|
114565
|
+
};
|
|
114566
|
+
}
|
|
114567
|
+
}
|
|
114568
|
+
async eraseItem(request2) {
|
|
114569
|
+
try {
|
|
114570
|
+
const context = await this._policies.constructAuthorizationContext({
|
|
114571
|
+
recordKeyOrRecordName: request2.recordName,
|
|
114572
|
+
userId: request2.userId
|
|
114573
|
+
});
|
|
114574
|
+
if (context.success === false) {
|
|
114575
|
+
return context;
|
|
114576
|
+
}
|
|
114577
|
+
const result = await this._store.getItemByAddress(
|
|
114578
|
+
context.context.recordName,
|
|
114579
|
+
request2.address
|
|
114580
|
+
);
|
|
114581
|
+
if (!result) {
|
|
114582
|
+
return {
|
|
114583
|
+
success: false,
|
|
114584
|
+
errorCode: "data_not_found",
|
|
114585
|
+
errorMessage: "The item was not found."
|
|
114586
|
+
};
|
|
114587
|
+
}
|
|
114588
|
+
const markers = result.markers;
|
|
114589
|
+
const authorization = await this._policies.authorizeUserAndInstances(
|
|
114590
|
+
context.context,
|
|
114591
|
+
{
|
|
114592
|
+
userId: request2.userId,
|
|
114593
|
+
instances: request2.instances,
|
|
114594
|
+
resourceKind: this._resourceKind,
|
|
114595
|
+
resourceId: request2.address,
|
|
114596
|
+
action: "delete",
|
|
114597
|
+
markers
|
|
114598
|
+
}
|
|
114599
|
+
);
|
|
114600
|
+
if (authorization.success === false) {
|
|
114601
|
+
return authorization;
|
|
114602
|
+
}
|
|
114603
|
+
const recordName = context.context.recordName;
|
|
114604
|
+
const subscriptionResult = await this._checkSubscriptionMetrics(
|
|
114605
|
+
"delete",
|
|
114606
|
+
context.context,
|
|
114607
|
+
authorization
|
|
114608
|
+
);
|
|
114609
|
+
if (subscriptionResult.success === false) {
|
|
114610
|
+
return subscriptionResult;
|
|
114611
|
+
}
|
|
114612
|
+
await this._store.deleteItem(recordName, request2.address);
|
|
114613
|
+
return {
|
|
114614
|
+
success: true
|
|
114615
|
+
};
|
|
114616
|
+
} catch (err) {
|
|
114617
|
+
const span = trace.getActiveSpan();
|
|
114618
|
+
span?.recordException(err);
|
|
114619
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
114620
|
+
console.error(`[${this._name}] Error erasing item:`, err);
|
|
114621
|
+
return {
|
|
114622
|
+
success: false,
|
|
114623
|
+
errorCode: "server_error",
|
|
114624
|
+
errorMessage: "A server error occurred."
|
|
114625
|
+
};
|
|
114626
|
+
}
|
|
114627
|
+
}
|
|
114628
|
+
async listItems(request2) {
|
|
114629
|
+
try {
|
|
114630
|
+
const baseRequest = {
|
|
114631
|
+
recordKeyOrRecordName: request2.recordName,
|
|
114632
|
+
userId: request2.userId,
|
|
114633
|
+
instances: request2.instances
|
|
114634
|
+
};
|
|
114635
|
+
const context = await this._policies.constructAuthorizationContext(
|
|
114636
|
+
baseRequest
|
|
114637
|
+
);
|
|
114638
|
+
if (context.success === false) {
|
|
114639
|
+
return context;
|
|
114640
|
+
}
|
|
114641
|
+
const authorization = await this._policies.authorizeUserAndInstances(
|
|
114642
|
+
context.context,
|
|
114643
|
+
{
|
|
114644
|
+
userId: request2.userId,
|
|
114645
|
+
instances: request2.instances,
|
|
114646
|
+
resourceKind: this._resourceKind,
|
|
114647
|
+
action: "list",
|
|
114648
|
+
markers: [ACCOUNT_MARKER]
|
|
114649
|
+
}
|
|
114650
|
+
);
|
|
114651
|
+
if (authorization.success === false) {
|
|
114652
|
+
return authorization;
|
|
114653
|
+
}
|
|
114654
|
+
const result2 = await this._store.listItems(
|
|
114655
|
+
context.context.recordName,
|
|
114656
|
+
request2.startingAddress
|
|
114657
|
+
);
|
|
114658
|
+
return {
|
|
114659
|
+
success: true,
|
|
114660
|
+
recordName: context.context.recordName,
|
|
114661
|
+
items: result2.items.map(
|
|
114662
|
+
(item) => this._convertItemToResult(item, context.context)
|
|
114663
|
+
),
|
|
114664
|
+
totalCount: result2.totalCount
|
|
114665
|
+
};
|
|
114666
|
+
} catch (err) {
|
|
114667
|
+
const span = trace.getActiveSpan();
|
|
114668
|
+
span?.recordException(err);
|
|
114669
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
114670
|
+
console.error(`[${this._name}] Error listing items:`, err);
|
|
114671
|
+
return {
|
|
114672
|
+
success: false,
|
|
114673
|
+
errorCode: "server_error",
|
|
114674
|
+
errorMessage: "A server error occurred."
|
|
114675
|
+
};
|
|
114676
|
+
}
|
|
114677
|
+
}
|
|
114678
|
+
async listItemsByMarker(request2) {
|
|
114679
|
+
try {
|
|
114680
|
+
const baseRequest = {
|
|
114681
|
+
recordKeyOrRecordName: request2.recordName,
|
|
114682
|
+
userId: request2.userId,
|
|
114683
|
+
instances: request2.instances
|
|
114684
|
+
};
|
|
114685
|
+
const context = await this._policies.constructAuthorizationContext(
|
|
114686
|
+
baseRequest
|
|
114687
|
+
);
|
|
114688
|
+
if (context.success === false) {
|
|
114689
|
+
return context;
|
|
114690
|
+
}
|
|
114691
|
+
const authorization = await this._policies.authorizeUserAndInstances(
|
|
114692
|
+
context.context,
|
|
114693
|
+
{
|
|
114694
|
+
userId: request2.userId,
|
|
114695
|
+
instances: request2.instances,
|
|
114696
|
+
resourceKind: this._resourceKind,
|
|
114697
|
+
action: "list",
|
|
114698
|
+
markers: [request2.marker]
|
|
114699
|
+
}
|
|
114700
|
+
);
|
|
114701
|
+
if (authorization.success === false) {
|
|
114702
|
+
return authorization;
|
|
114703
|
+
}
|
|
114704
|
+
const result2 = await this._store.listItemsByMarker({
|
|
114705
|
+
recordName: context.context.recordName,
|
|
114706
|
+
startingAddress: request2.startingAddress,
|
|
114707
|
+
marker: request2.marker,
|
|
114708
|
+
sort: request2.sort
|
|
114709
|
+
});
|
|
114710
|
+
return {
|
|
114711
|
+
success: true,
|
|
114712
|
+
recordName: context.context.recordName,
|
|
114713
|
+
items: result2.items.map(
|
|
114714
|
+
(item) => this._convertItemToResult(item, context.context)
|
|
114715
|
+
),
|
|
114716
|
+
totalCount: result2.totalCount
|
|
114717
|
+
};
|
|
114718
|
+
} catch (err) {
|
|
114719
|
+
const span = trace.getActiveSpan();
|
|
114720
|
+
span?.recordException(err);
|
|
114721
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
114722
|
+
console.error(`[${this._name}] Error listing items:`, err);
|
|
114723
|
+
return {
|
|
114724
|
+
success: false,
|
|
114725
|
+
errorCode: "server_error",
|
|
114726
|
+
errorMessage: "A server error occurred."
|
|
114727
|
+
};
|
|
114728
|
+
}
|
|
114729
|
+
}
|
|
114730
|
+
/**
|
|
114731
|
+
* Converts the given item to a version that is able to be returned to clients.
|
|
114732
|
+
* Can be overriden to ensure that some fields are not returned.
|
|
114733
|
+
* @param item The item that should be converted.
|
|
114734
|
+
* @param context The authorization context.
|
|
114735
|
+
* @returns The converted item.
|
|
114736
|
+
*/
|
|
114737
|
+
_convertItemToResult(item, context) {
|
|
114738
|
+
return item;
|
|
114739
|
+
}
|
|
114740
|
+
/**
|
|
114741
|
+
* Transforms the given input item and returns the transformed item.
|
|
114742
|
+
* Useful for transforming items before they are stored.
|
|
114743
|
+
* @param item The item that should be transformed.
|
|
114744
|
+
*/
|
|
114745
|
+
_transformInputItem(item) {
|
|
114746
|
+
return item;
|
|
114747
|
+
}
|
|
114748
|
+
};
|
|
114749
|
+
__decorateClass([
|
|
114750
|
+
traced(TRACE_NAME8)
|
|
114751
|
+
], CrudRecordsController.prototype, "recordItem", 1);
|
|
114752
|
+
__decorateClass([
|
|
114753
|
+
traced(TRACE_NAME8)
|
|
114754
|
+
], CrudRecordsController.prototype, "getItem", 1);
|
|
114755
|
+
__decorateClass([
|
|
114756
|
+
traced(TRACE_NAME8)
|
|
114757
|
+
], CrudRecordsController.prototype, "eraseItem", 1);
|
|
114758
|
+
__decorateClass([
|
|
114759
|
+
traced(TRACE_NAME8)
|
|
114760
|
+
], CrudRecordsController.prototype, "listItems", 1);
|
|
114761
|
+
__decorateClass([
|
|
114762
|
+
traced(TRACE_NAME8)
|
|
114763
|
+
], CrudRecordsController.prototype, "listItemsByMarker", 1);
|
|
114764
|
+
|
|
114765
|
+
// ../aux-records/notifications/WebPushInterface.ts
|
|
114766
|
+
var SUBSCRIPTION_ID_NAMESPACE = "f12953a9-21e2-47d4-b7b7-f699bd9a5550";
|
|
114767
|
+
var PUSH_SUBSCRIPTION_SCHEMA = z.object({
|
|
114768
|
+
endpoint: z.string(),
|
|
114769
|
+
expirationTime: z.number().optional().nullable(),
|
|
114770
|
+
keys: z.record(z.string())
|
|
114771
|
+
});
|
|
114772
|
+
var PUSH_NOTIFICATION_PAYLOAD_ACTION = z.discriminatedUnion("type", [
|
|
114773
|
+
z.object({
|
|
114774
|
+
type: z.literal("open_url"),
|
|
114775
|
+
url: z.string()
|
|
114776
|
+
}),
|
|
114777
|
+
z.object({
|
|
114778
|
+
type: z.literal("webhook"),
|
|
114779
|
+
method: z.enum(["GET", "POST"]),
|
|
114780
|
+
url: z.string(),
|
|
114781
|
+
headers: z.record(z.string()).optional().nullable()
|
|
114782
|
+
})
|
|
114783
|
+
]);
|
|
114784
|
+
var PUSH_NOTIFICATION_PAYLOAD = z.object({
|
|
114785
|
+
title: z.string().min(1),
|
|
114786
|
+
body: z.string().min(2),
|
|
114787
|
+
icon: z.string().min(1).optional().nullable(),
|
|
114788
|
+
badge: z.string().min(1).optional().nullable(),
|
|
114789
|
+
silent: z.boolean().optional().nullable(),
|
|
114790
|
+
tag: z.string().min(1).optional().nullable(),
|
|
114791
|
+
timestamp: z.number().optional().nullable(),
|
|
114792
|
+
action: PUSH_NOTIFICATION_PAYLOAD_ACTION.optional().nullable(),
|
|
114793
|
+
actions: z.array(
|
|
114794
|
+
z.object({
|
|
114795
|
+
title: z.string().min(1),
|
|
114796
|
+
icon: z.string().min(1).optional().nullable(),
|
|
114797
|
+
action: PUSH_NOTIFICATION_PAYLOAD_ACTION
|
|
114798
|
+
})
|
|
114799
|
+
).optional().nullable()
|
|
114800
|
+
});
|
|
114801
|
+
|
|
114802
|
+
// ../aux-records/notifications/NotificationRecordsController.ts
|
|
114803
|
+
var TRACE_NAME9 = "NotificationRecordsController";
|
|
114804
|
+
var NotificationRecordsController = class extends CrudRecordsController {
|
|
114805
|
+
constructor(config2) {
|
|
114806
|
+
super({
|
|
114807
|
+
...config2,
|
|
114808
|
+
name: "NotificationRecordsController",
|
|
114809
|
+
resourceKind: "notification"
|
|
114810
|
+
});
|
|
114811
|
+
this._pushInterface = config2.pushInterface;
|
|
114812
|
+
}
|
|
114813
|
+
async getApplicationServerKey() {
|
|
114814
|
+
try {
|
|
114815
|
+
const key = this._pushInterface.getServerApplicationKey();
|
|
114816
|
+
return {
|
|
114817
|
+
success: true,
|
|
114818
|
+
key
|
|
114819
|
+
};
|
|
114820
|
+
} catch (err) {
|
|
114821
|
+
const span = trace.getActiveSpan();
|
|
114822
|
+
span?.recordException(err);
|
|
114823
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
114824
|
+
console.error(
|
|
114825
|
+
"[NotificationRecordsController] Error subscribing to notification:",
|
|
114826
|
+
err
|
|
114827
|
+
);
|
|
114828
|
+
return {
|
|
114829
|
+
success: false,
|
|
114830
|
+
errorCode: "server_error",
|
|
114831
|
+
errorMessage: "A server error occurred."
|
|
114832
|
+
};
|
|
114833
|
+
}
|
|
114834
|
+
}
|
|
114835
|
+
async subscribeToNotification(request2) {
|
|
114836
|
+
try {
|
|
114837
|
+
const context = await this.policies.constructAuthorizationContext({
|
|
114838
|
+
userId: request2.userId,
|
|
114839
|
+
recordKeyOrRecordName: request2.recordName
|
|
114840
|
+
});
|
|
114841
|
+
if (context.success === false) {
|
|
114842
|
+
return context;
|
|
114843
|
+
}
|
|
114844
|
+
const recordName = context.context.recordName;
|
|
114845
|
+
const userId = context.context.userId;
|
|
114846
|
+
const notification = await this.store.getItemByAddress(
|
|
114847
|
+
recordName,
|
|
114848
|
+
request2.address
|
|
114849
|
+
);
|
|
114850
|
+
if (!notification) {
|
|
114851
|
+
return {
|
|
114852
|
+
success: false,
|
|
114853
|
+
errorCode: "data_not_found",
|
|
114854
|
+
errorMessage: "Notification not found."
|
|
114855
|
+
};
|
|
114856
|
+
}
|
|
114857
|
+
const authorization = await this.policies.authorizeUserAndInstances(
|
|
114858
|
+
context.context,
|
|
114859
|
+
{
|
|
114860
|
+
action: "subscribe",
|
|
114861
|
+
resourceKind: "notification",
|
|
114862
|
+
resourceId: notification.address,
|
|
114863
|
+
markers: notification.markers,
|
|
114864
|
+
userId,
|
|
114865
|
+
instances: request2.instances
|
|
114866
|
+
}
|
|
114867
|
+
);
|
|
114868
|
+
if (authorization.success === false) {
|
|
114869
|
+
return authorization;
|
|
114870
|
+
}
|
|
114871
|
+
const metrics3 = await this._checkSubscriptionMetrics(
|
|
114872
|
+
"subscribe",
|
|
114873
|
+
context.context,
|
|
114874
|
+
authorization,
|
|
114875
|
+
notification
|
|
114876
|
+
);
|
|
114877
|
+
if (metrics3.success === false) {
|
|
114878
|
+
return metrics3;
|
|
114879
|
+
}
|
|
114880
|
+
const pushSubscriptionId = this._getPushSubscriptionId(
|
|
114881
|
+
request2.pushSubscription.endpoint
|
|
114882
|
+
);
|
|
114883
|
+
await this.store.savePushSubscription({
|
|
114884
|
+
id: pushSubscriptionId,
|
|
114885
|
+
active: true,
|
|
114886
|
+
endpoint: request2.pushSubscription.endpoint,
|
|
114887
|
+
keys: request2.pushSubscription.keys
|
|
114888
|
+
});
|
|
114889
|
+
await this.store.savePushSubscriptionUser({
|
|
114890
|
+
pushSubscriptionId,
|
|
114891
|
+
userId
|
|
114892
|
+
});
|
|
114893
|
+
let subscriptionId = null;
|
|
114894
|
+
if (userId) {
|
|
114895
|
+
const sub = await this.store.getSubscriptionByRecordAddressAndUserId(
|
|
114896
|
+
recordName,
|
|
114897
|
+
notification.address,
|
|
114898
|
+
userId
|
|
114899
|
+
);
|
|
114900
|
+
if (sub) {
|
|
114901
|
+
subscriptionId = sub.id;
|
|
114902
|
+
}
|
|
114903
|
+
} else {
|
|
114904
|
+
const sub = await this.store.getSubscriptionByRecordAddressAndPushSubscriptionId(
|
|
114905
|
+
recordName,
|
|
114906
|
+
notification.address,
|
|
114907
|
+
pushSubscriptionId
|
|
114908
|
+
);
|
|
114909
|
+
if (sub) {
|
|
114910
|
+
subscriptionId = sub.id;
|
|
114911
|
+
}
|
|
114912
|
+
}
|
|
114913
|
+
if (!subscriptionId) {
|
|
114914
|
+
subscriptionId = v7_default();
|
|
114915
|
+
await this.store.saveSubscription({
|
|
114916
|
+
id: subscriptionId,
|
|
114917
|
+
recordName,
|
|
114918
|
+
notificationAddress: notification.address,
|
|
114919
|
+
userId,
|
|
114920
|
+
pushSubscriptionId: !userId ? pushSubscriptionId : null
|
|
114921
|
+
});
|
|
114922
|
+
}
|
|
114923
|
+
console.log(
|
|
114924
|
+
`[NotificationRecordsController] [userId: ${userId} pushSubscriptionId: ${pushSubscriptionId} subscriptionId: ${subscriptionId}] Subscribed to notification`
|
|
114925
|
+
);
|
|
114926
|
+
return {
|
|
114927
|
+
success: true,
|
|
114928
|
+
subscriptionId
|
|
114929
|
+
};
|
|
114930
|
+
} catch (err) {
|
|
114931
|
+
const span = trace.getActiveSpan();
|
|
114932
|
+
span?.recordException(err);
|
|
114933
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
114934
|
+
console.error(
|
|
114935
|
+
"[NotificationRecordsController] Error subscribing to notification:",
|
|
114936
|
+
err
|
|
114937
|
+
);
|
|
114938
|
+
return {
|
|
114939
|
+
success: false,
|
|
114940
|
+
errorCode: "server_error",
|
|
114941
|
+
errorMessage: "A server error occurred."
|
|
114942
|
+
};
|
|
114943
|
+
}
|
|
114944
|
+
}
|
|
114945
|
+
_getPushSubscriptionId(endpoint2) {
|
|
114946
|
+
return v5_default(endpoint2, SUBSCRIPTION_ID_NAMESPACE);
|
|
114947
|
+
}
|
|
114948
|
+
async unsubscribeFromNotification(request2) {
|
|
114949
|
+
try {
|
|
114950
|
+
const subscription = await this.store.getSubscriptionById(
|
|
114951
|
+
request2.subscriptionId
|
|
114952
|
+
);
|
|
114953
|
+
if (!subscription) {
|
|
114954
|
+
return {
|
|
114955
|
+
success: false,
|
|
114956
|
+
errorCode: "data_not_found",
|
|
114957
|
+
errorMessage: "Subscription not found."
|
|
114958
|
+
};
|
|
114959
|
+
}
|
|
114960
|
+
const context = await this.policies.constructAuthorizationContext({
|
|
114961
|
+
userId: request2.userId,
|
|
114962
|
+
recordKeyOrRecordName: subscription.recordName
|
|
114963
|
+
});
|
|
114964
|
+
if (context.success === false) {
|
|
114965
|
+
return context;
|
|
114966
|
+
}
|
|
114967
|
+
let successfulAuthorization = false;
|
|
114968
|
+
if (subscription.userId) {
|
|
114969
|
+
const userContext = await this.policies.constructAuthorizationContext({
|
|
114970
|
+
userId: request2.userId,
|
|
114971
|
+
recordKeyOrRecordName: subscription.userId
|
|
114972
|
+
});
|
|
114973
|
+
if (userContext.success === true) {
|
|
114974
|
+
const userAuthorization = await this.policies.authorizeUserAndInstances(
|
|
114975
|
+
userContext.context,
|
|
114976
|
+
{
|
|
114977
|
+
userId: request2.userId,
|
|
114978
|
+
action: "unsubscribe",
|
|
114979
|
+
resourceKind: "notification",
|
|
114980
|
+
resourceId: subscription.id,
|
|
114981
|
+
instances: request2.instances,
|
|
114982
|
+
markers: [PRIVATE_MARKER]
|
|
114983
|
+
}
|
|
114984
|
+
);
|
|
114985
|
+
if (userAuthorization.success === true) {
|
|
114986
|
+
successfulAuthorization = true;
|
|
114987
|
+
}
|
|
114988
|
+
}
|
|
114989
|
+
}
|
|
114990
|
+
const userId = context.context.userId;
|
|
114991
|
+
const recordName = context.context.recordName;
|
|
114992
|
+
if (!successfulAuthorization) {
|
|
114993
|
+
const notification = await this.store.getItemByAddress(
|
|
114994
|
+
recordName,
|
|
114995
|
+
subscription.notificationAddress
|
|
114996
|
+
);
|
|
114997
|
+
if (!notification) {
|
|
114998
|
+
return {
|
|
114999
|
+
success: false,
|
|
115000
|
+
errorCode: "data_not_found",
|
|
115001
|
+
errorMessage: "Notification not found."
|
|
115002
|
+
};
|
|
115003
|
+
}
|
|
115004
|
+
const authorization = await this.policies.authorizeUserAndInstances(
|
|
115005
|
+
context.context,
|
|
115006
|
+
{
|
|
115007
|
+
userId,
|
|
115008
|
+
action: "unsubscribe",
|
|
115009
|
+
resourceKind: "notification",
|
|
115010
|
+
resourceId: notification.address,
|
|
115011
|
+
instances: request2.instances,
|
|
115012
|
+
markers: notification.markers
|
|
115013
|
+
}
|
|
115014
|
+
);
|
|
115015
|
+
if (authorization.success === false) {
|
|
115016
|
+
return authorization;
|
|
115017
|
+
}
|
|
115018
|
+
}
|
|
115019
|
+
await this.store.deleteSubscription(request2.subscriptionId);
|
|
115020
|
+
console.log(
|
|
115021
|
+
`[NotificationRecordsController] [userId: ${userId} subscriptionId: ${request2.subscriptionId}] Unsubscribed from notification`
|
|
115022
|
+
);
|
|
115023
|
+
return {
|
|
115024
|
+
success: true
|
|
115025
|
+
};
|
|
115026
|
+
} catch (err) {
|
|
115027
|
+
const span = trace.getActiveSpan();
|
|
115028
|
+
span?.recordException(err);
|
|
115029
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
115030
|
+
console.error(
|
|
115031
|
+
"[NotificationRecordsController] Error subscribing to notification:",
|
|
115032
|
+
err
|
|
115033
|
+
);
|
|
115034
|
+
return {
|
|
115035
|
+
success: false,
|
|
115036
|
+
errorCode: "server_error",
|
|
115037
|
+
errorMessage: "A server error occurred."
|
|
115038
|
+
};
|
|
115039
|
+
}
|
|
115040
|
+
}
|
|
115041
|
+
async registerPushSubscription(request2) {
|
|
115042
|
+
try {
|
|
115043
|
+
if (!request2.userId) {
|
|
115044
|
+
return {
|
|
115045
|
+
success: false,
|
|
115046
|
+
errorCode: "not_logged_in",
|
|
115047
|
+
errorMessage: "The user must be logged in. Please provide a sessionKey or a recordKey."
|
|
115048
|
+
};
|
|
115049
|
+
}
|
|
115050
|
+
const pushSubscriptionId = this._getPushSubscriptionId(
|
|
115051
|
+
request2.pushSubscription.endpoint
|
|
115052
|
+
);
|
|
115053
|
+
await this.store.savePushSubscription({
|
|
115054
|
+
id: pushSubscriptionId,
|
|
115055
|
+
active: true,
|
|
115056
|
+
endpoint: request2.pushSubscription.endpoint,
|
|
115057
|
+
keys: request2.pushSubscription.keys
|
|
115058
|
+
});
|
|
115059
|
+
await this.store.savePushSubscriptionUser({
|
|
115060
|
+
pushSubscriptionId,
|
|
115061
|
+
userId: request2.userId
|
|
115062
|
+
});
|
|
115063
|
+
console.log(
|
|
115064
|
+
`[NotificationRecordsController] [userId: ${request2.userId} pushSubscriptionId: ${pushSubscriptionId}] Registered push subscription`
|
|
115065
|
+
);
|
|
115066
|
+
return {
|
|
115067
|
+
success: true
|
|
115068
|
+
};
|
|
115069
|
+
} catch (err) {
|
|
115070
|
+
const span = trace.getActiveSpan();
|
|
115071
|
+
span?.recordException(err);
|
|
115072
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
115073
|
+
console.error(
|
|
115074
|
+
"[NotificationRecordsController] Error registering push subscription:",
|
|
115075
|
+
err
|
|
115076
|
+
);
|
|
115077
|
+
return {
|
|
115078
|
+
success: false,
|
|
115079
|
+
errorCode: "server_error",
|
|
115080
|
+
errorMessage: "A server error occurred."
|
|
115081
|
+
};
|
|
115082
|
+
}
|
|
115083
|
+
}
|
|
115084
|
+
async sendNotification(request2) {
|
|
115085
|
+
try {
|
|
115086
|
+
const context = await this.policies.constructAuthorizationContext({
|
|
115087
|
+
userId: request2.userId,
|
|
115088
|
+
recordKeyOrRecordName: request2.recordName
|
|
115089
|
+
});
|
|
115090
|
+
if (context.success === false) {
|
|
115091
|
+
return context;
|
|
115092
|
+
}
|
|
115093
|
+
const recordName = context.context.recordName;
|
|
115094
|
+
const userId = context.context.userId;
|
|
115095
|
+
const notification = await this.store.getItemByAddress(
|
|
115096
|
+
recordName,
|
|
115097
|
+
request2.address
|
|
115098
|
+
);
|
|
115099
|
+
if (!notification) {
|
|
115100
|
+
return {
|
|
115101
|
+
success: false,
|
|
115102
|
+
errorCode: "data_not_found",
|
|
115103
|
+
errorMessage: "Notification not found."
|
|
115104
|
+
};
|
|
115105
|
+
}
|
|
115106
|
+
const authorization = await this.policies.authorizeUserAndInstances(
|
|
115107
|
+
context.context,
|
|
115108
|
+
{
|
|
115109
|
+
action: "send",
|
|
115110
|
+
resourceKind: "notification",
|
|
115111
|
+
resourceId: notification.address,
|
|
115112
|
+
markers: notification.markers,
|
|
115113
|
+
userId,
|
|
115114
|
+
instances: request2.instances
|
|
115115
|
+
}
|
|
115116
|
+
);
|
|
115117
|
+
if (authorization.success === false) {
|
|
115118
|
+
return authorization;
|
|
115119
|
+
}
|
|
115120
|
+
const metrics3 = await this._checkSubscriptionMetrics(
|
|
115121
|
+
"send",
|
|
115122
|
+
context.context,
|
|
115123
|
+
authorization,
|
|
115124
|
+
notification
|
|
115125
|
+
);
|
|
115126
|
+
if (metrics3.success === false) {
|
|
115127
|
+
return metrics3;
|
|
115128
|
+
}
|
|
115129
|
+
const pushSubs = await this.store.listActivePushSubscriptionsForNotification(
|
|
115130
|
+
recordName,
|
|
115131
|
+
notification.address
|
|
115132
|
+
);
|
|
115133
|
+
if (typeof metrics3.features.maxSentPushNotificationsPerPeriod === "number") {
|
|
115134
|
+
if (metrics3.metrics.totalSentNotificationsInPeriod + pushSubs.length >= metrics3.features.maxSentPushNotificationsPerPeriod) {
|
|
115135
|
+
return {
|
|
115136
|
+
success: false,
|
|
115137
|
+
errorCode: "subscription_limit_reached",
|
|
115138
|
+
errorMessage: "The maximum number of sent push notifications has been reached for this period."
|
|
115139
|
+
};
|
|
115140
|
+
}
|
|
115141
|
+
}
|
|
115142
|
+
let promises = [];
|
|
115143
|
+
const sentTimeMs = Date.now();
|
|
115144
|
+
for (let push of pushSubs) {
|
|
115145
|
+
promises.push(
|
|
115146
|
+
this._pushInterface.sendNotification(
|
|
115147
|
+
{
|
|
115148
|
+
endpoint: push.endpoint,
|
|
115149
|
+
keys: push.keys
|
|
115150
|
+
},
|
|
115151
|
+
request2.payload,
|
|
115152
|
+
request2.topic
|
|
115153
|
+
).then((result) => {
|
|
115154
|
+
return [push, result];
|
|
115155
|
+
})
|
|
115156
|
+
);
|
|
115157
|
+
}
|
|
115158
|
+
const results = await Promise.allSettled(promises);
|
|
115159
|
+
const notificationId = v7_default();
|
|
115160
|
+
await this.store.saveSentNotification({
|
|
115161
|
+
id: notificationId,
|
|
115162
|
+
recordName,
|
|
115163
|
+
notificationAddress: notification.address,
|
|
115164
|
+
title: request2.payload.title,
|
|
115165
|
+
body: request2.payload.body,
|
|
115166
|
+
icon: request2.payload.icon,
|
|
115167
|
+
badge: request2.payload.badge,
|
|
115168
|
+
defaultAction: request2.payload.action,
|
|
115169
|
+
actions: request2.payload.actions,
|
|
115170
|
+
silent: request2.payload.silent,
|
|
115171
|
+
tag: request2.payload.tag,
|
|
115172
|
+
timestamp: request2.payload.timestamp,
|
|
115173
|
+
sentTimeMs,
|
|
115174
|
+
topic: request2.topic
|
|
115175
|
+
});
|
|
115176
|
+
let sentPushNotifications = [];
|
|
115177
|
+
let failedPushSubscriptions = [];
|
|
115178
|
+
for (let promiseResult of results) {
|
|
115179
|
+
if (promiseResult.status === "rejected") {
|
|
115180
|
+
console.error(
|
|
115181
|
+
"[NotificationRecordsController] Error sending notification:",
|
|
115182
|
+
promiseResult.reason
|
|
115183
|
+
);
|
|
115184
|
+
} else {
|
|
115185
|
+
const [push, result] = promiseResult.value;
|
|
115186
|
+
sentPushNotifications.push({
|
|
115187
|
+
id: v7_default(),
|
|
115188
|
+
pushSubscriptionId: push.id,
|
|
115189
|
+
sentNotificationId: notificationId,
|
|
115190
|
+
userId: push.userId,
|
|
115191
|
+
subscriptionId: push.subscriptionId,
|
|
115192
|
+
success: result.success,
|
|
115193
|
+
errorCode: result.success === false ? result.errorCode : null
|
|
115194
|
+
});
|
|
115195
|
+
if (result.success === false) {
|
|
115196
|
+
console.error(
|
|
115197
|
+
`[NotificationRecordsController] Error sending notification for ${push.id}:`,
|
|
115198
|
+
result.errorCode
|
|
115199
|
+
);
|
|
115200
|
+
if (result.errorCode === "subscription_gone" || result.errorCode === "subscription_not_found") {
|
|
115201
|
+
failedPushSubscriptions.push(push.id);
|
|
115202
|
+
}
|
|
115203
|
+
}
|
|
115204
|
+
}
|
|
115205
|
+
}
|
|
115206
|
+
if (sentPushNotifications.length > 0) {
|
|
115207
|
+
await this.store.createSentPushNotifications(
|
|
115208
|
+
sentPushNotifications
|
|
115209
|
+
);
|
|
115210
|
+
}
|
|
115211
|
+
if (failedPushSubscriptions.length > 0) {
|
|
115212
|
+
await this.store.markPushSubscriptionsInactiveAndDeleteUserRelations(
|
|
115213
|
+
failedPushSubscriptions
|
|
115214
|
+
);
|
|
115215
|
+
}
|
|
115216
|
+
console.log(
|
|
115217
|
+
`[NotificationRecordsController] [userId: ${userId} notificationId: ${notificationId} sent: ${sentPushNotifications.length} failed: ${failedPushSubscriptions.length}] Sent notification`
|
|
115218
|
+
);
|
|
115219
|
+
return {
|
|
115220
|
+
success: true
|
|
115221
|
+
};
|
|
115222
|
+
} catch (err) {
|
|
115223
|
+
const span = trace.getActiveSpan();
|
|
115224
|
+
span?.recordException(err);
|
|
115225
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
115226
|
+
console.error(
|
|
115227
|
+
"[NotificationRecordsController] Error sending notification:",
|
|
115228
|
+
err
|
|
115229
|
+
);
|
|
115230
|
+
return {
|
|
115231
|
+
success: false,
|
|
115232
|
+
errorCode: "server_error",
|
|
115233
|
+
errorMessage: "A server error occurred."
|
|
115234
|
+
};
|
|
115235
|
+
}
|
|
115236
|
+
}
|
|
115237
|
+
async listSubscriptionsForUser(request2) {
|
|
115238
|
+
try {
|
|
115239
|
+
if (!request2.userId) {
|
|
115240
|
+
return {
|
|
115241
|
+
success: false,
|
|
115242
|
+
errorCode: "not_logged_in",
|
|
115243
|
+
errorMessage: "The user must be logged in. Please provide a sessionKey or a recordKey."
|
|
115244
|
+
};
|
|
115245
|
+
}
|
|
115246
|
+
const subscriptions = await this.store.listSubscriptionsForUser(
|
|
115247
|
+
request2.userId
|
|
115248
|
+
);
|
|
115249
|
+
return {
|
|
115250
|
+
success: true,
|
|
115251
|
+
subscriptions: subscriptions.map((sub) => ({
|
|
115252
|
+
id: sub.id,
|
|
115253
|
+
userId: sub.userId,
|
|
115254
|
+
recordName: sub.recordName,
|
|
115255
|
+
notificationAddress: sub.notificationAddress,
|
|
115256
|
+
pushSubscriptionId: sub.pushSubscriptionId
|
|
115257
|
+
}))
|
|
115258
|
+
};
|
|
115259
|
+
} catch (err) {
|
|
115260
|
+
const span = trace.getActiveSpan();
|
|
115261
|
+
span?.recordException(err);
|
|
115262
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
115263
|
+
console.error(
|
|
115264
|
+
"[NotificationRecordsController] Error listing subscriptions for user:",
|
|
115265
|
+
err
|
|
115266
|
+
);
|
|
115267
|
+
return {
|
|
115268
|
+
success: false,
|
|
115269
|
+
errorCode: "server_error",
|
|
115270
|
+
errorMessage: "A server error occurred."
|
|
115271
|
+
};
|
|
115272
|
+
}
|
|
115273
|
+
}
|
|
115274
|
+
async listSubscriptions(request2) {
|
|
115275
|
+
try {
|
|
115276
|
+
if (!request2.userId) {
|
|
115277
|
+
return {
|
|
115278
|
+
success: false,
|
|
115279
|
+
errorCode: "not_logged_in",
|
|
115280
|
+
errorMessage: "The user must be logged in. Please provide a sessionKey or a recordKey."
|
|
115281
|
+
};
|
|
115282
|
+
}
|
|
115283
|
+
const context = await this.policies.constructAuthorizationContext({
|
|
115284
|
+
recordKeyOrRecordName: request2.recordName,
|
|
115285
|
+
userId: request2.userId
|
|
115286
|
+
});
|
|
115287
|
+
if (context.success === false) {
|
|
115288
|
+
return context;
|
|
115289
|
+
}
|
|
115290
|
+
const recordName = context.context.recordName;
|
|
115291
|
+
const notification = await this.store.getItemByAddress(
|
|
115292
|
+
recordName,
|
|
115293
|
+
request2.address
|
|
115294
|
+
);
|
|
115295
|
+
if (!notification) {
|
|
115296
|
+
return {
|
|
115297
|
+
success: false,
|
|
115298
|
+
errorCode: "data_not_found",
|
|
115299
|
+
errorMessage: "Notification not found."
|
|
115300
|
+
};
|
|
115301
|
+
}
|
|
115302
|
+
const authorization = await this.policies.authorizeUserAndInstances(
|
|
115303
|
+
context.context,
|
|
115304
|
+
{
|
|
115305
|
+
userId: request2.userId,
|
|
115306
|
+
resourceKind: "notification",
|
|
115307
|
+
markers: notification.markers,
|
|
115308
|
+
resourceId: notification.address,
|
|
115309
|
+
action: "listSubscriptions",
|
|
115310
|
+
instances: request2.instances
|
|
115311
|
+
}
|
|
115312
|
+
);
|
|
115313
|
+
if (authorization.success === false) {
|
|
115314
|
+
return authorization;
|
|
115315
|
+
}
|
|
115316
|
+
const subscriptions = await this.store.listSubscriptionsForNotification(
|
|
115317
|
+
recordName,
|
|
115318
|
+
request2.address
|
|
115319
|
+
);
|
|
115320
|
+
return {
|
|
115321
|
+
success: true,
|
|
115322
|
+
subscriptions: subscriptions.map((sub) => ({
|
|
115323
|
+
id: sub.id,
|
|
115324
|
+
userId: sub.userId,
|
|
115325
|
+
recordName: sub.recordName,
|
|
115326
|
+
notificationAddress: sub.notificationAddress,
|
|
115327
|
+
pushSubscriptionId: sub.pushSubscriptionId
|
|
115328
|
+
}))
|
|
115329
|
+
};
|
|
115330
|
+
} catch (err) {
|
|
115331
|
+
const span = trace.getActiveSpan();
|
|
115332
|
+
span?.recordException(err);
|
|
115333
|
+
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
115334
|
+
console.error(
|
|
115335
|
+
"[NotificationRecordsController] Error listing subscriptions for notification:",
|
|
115336
|
+
err
|
|
115337
|
+
);
|
|
115338
|
+
return {
|
|
115339
|
+
success: false,
|
|
115340
|
+
errorCode: "server_error",
|
|
115341
|
+
errorMessage: "A server error occurred."
|
|
115342
|
+
};
|
|
115343
|
+
}
|
|
115344
|
+
}
|
|
115345
|
+
async _checkSubscriptionMetrics(action2, context, authorization, item) {
|
|
115346
|
+
const config2 = await this.config.getSubscriptionConfiguration();
|
|
115347
|
+
const metrics3 = await this.store.getSubscriptionMetrics({
|
|
115348
|
+
ownerId: context.recordOwnerId,
|
|
115349
|
+
studioId: context.recordStudioId
|
|
115350
|
+
});
|
|
115351
|
+
const features = getNotificationFeatures(
|
|
115352
|
+
config2,
|
|
115353
|
+
metrics3.subscriptionStatus,
|
|
115354
|
+
metrics3.subscriptionId,
|
|
115355
|
+
metrics3.subscriptionType,
|
|
115356
|
+
metrics3.currentPeriodStartMs,
|
|
115357
|
+
metrics3.currentPeriodEndMs
|
|
115358
|
+
);
|
|
115359
|
+
if (!features.allowed) {
|
|
115360
|
+
return {
|
|
115361
|
+
success: false,
|
|
115362
|
+
errorCode: "not_authorized",
|
|
115363
|
+
errorMessage: "Notifications are not allowed for this subscription."
|
|
115364
|
+
};
|
|
115365
|
+
}
|
|
115366
|
+
if (action2 === "create" && typeof features.maxItems === "number") {
|
|
115367
|
+
if (metrics3.totalItems >= features.maxItems) {
|
|
115368
|
+
return {
|
|
115369
|
+
success: false,
|
|
115370
|
+
errorCode: "subscription_limit_reached",
|
|
115371
|
+
errorMessage: "The maximum number of notification items has been reached for your subscription."
|
|
115372
|
+
};
|
|
115373
|
+
}
|
|
115374
|
+
}
|
|
115375
|
+
if (action2 === "subscribe" && typeof features.maxSubscribersPerItem === "number") {
|
|
115376
|
+
const totalSubscriptions = await this.store.countSubscriptionsForNotification(
|
|
115377
|
+
context.recordName,
|
|
115378
|
+
item.address
|
|
115379
|
+
);
|
|
115380
|
+
if (totalSubscriptions >= features.maxSubscribersPerItem) {
|
|
115381
|
+
return {
|
|
115382
|
+
success: false,
|
|
115383
|
+
errorCode: "subscription_limit_reached",
|
|
115384
|
+
errorMessage: "The maximum number of subscriptions has been reached for this notification."
|
|
115385
|
+
};
|
|
115386
|
+
}
|
|
115387
|
+
}
|
|
115388
|
+
if (action2 === "send") {
|
|
115389
|
+
if (typeof features.maxSentNotificationsPerPeriod === "number" && metrics3.totalSentNotificationsInPeriod >= features.maxSentNotificationsPerPeriod) {
|
|
115390
|
+
return {
|
|
115391
|
+
success: false,
|
|
115392
|
+
errorCode: "subscription_limit_reached",
|
|
115393
|
+
errorMessage: "The maximum number of sent notifications has been reached for this period."
|
|
115394
|
+
};
|
|
115395
|
+
}
|
|
115396
|
+
}
|
|
115397
|
+
return {
|
|
115398
|
+
success: true,
|
|
115399
|
+
config: config2,
|
|
115400
|
+
metrics: metrics3,
|
|
115401
|
+
features
|
|
115402
|
+
};
|
|
115403
|
+
}
|
|
115404
|
+
};
|
|
115405
|
+
__decorateClass([
|
|
115406
|
+
traced(TRACE_NAME9)
|
|
115407
|
+
], NotificationRecordsController.prototype, "getApplicationServerKey", 1);
|
|
115408
|
+
__decorateClass([
|
|
115409
|
+
traced(TRACE_NAME9)
|
|
115410
|
+
], NotificationRecordsController.prototype, "subscribeToNotification", 1);
|
|
115411
|
+
__decorateClass([
|
|
115412
|
+
traced(TRACE_NAME9)
|
|
115413
|
+
], NotificationRecordsController.prototype, "unsubscribeFromNotification", 1);
|
|
115414
|
+
__decorateClass([
|
|
115415
|
+
traced(TRACE_NAME9)
|
|
115416
|
+
], NotificationRecordsController.prototype, "registerPushSubscription", 1);
|
|
115417
|
+
__decorateClass([
|
|
115418
|
+
traced(TRACE_NAME9)
|
|
115419
|
+
], NotificationRecordsController.prototype, "sendNotification", 1);
|
|
115420
|
+
__decorateClass([
|
|
115421
|
+
traced(TRACE_NAME9)
|
|
115422
|
+
], NotificationRecordsController.prototype, "listSubscriptionsForUser", 1);
|
|
115423
|
+
__decorateClass([
|
|
115424
|
+
traced(TRACE_NAME9)
|
|
115425
|
+
], NotificationRecordsController.prototype, "listSubscriptions", 1);
|
|
115426
|
+
|
|
115427
|
+
// ../aux-records/crud/MemoryCrudRecordsStore.ts
|
|
114044
115428
|
var import_lodash21 = __toESM(require_lodash());
|
|
115429
|
+
|
|
115430
|
+
// ../aux-records/notifications/MemoryNotificationRecordsStore.ts
|
|
115431
|
+
var import_lodash22 = __toESM(require_lodash());
|
|
115432
|
+
|
|
115433
|
+
// ../aux-records/RecordsServer.ts
|
|
114045
115434
|
var NOT_LOGGED_IN_RESULT = {
|
|
114046
115435
|
success: false,
|
|
114047
115436
|
errorCode: "not_logged_in",
|
|
@@ -114117,7 +115506,8 @@ var RecordsServer = class {
|
|
|
114117
115506
|
aiController,
|
|
114118
115507
|
moderationController,
|
|
114119
115508
|
loomController,
|
|
114120
|
-
webhooksController
|
|
115509
|
+
webhooksController,
|
|
115510
|
+
notificationsController
|
|
114121
115511
|
}) {
|
|
114122
115512
|
/**
|
|
114123
115513
|
* The map of paths to routes that they match.
|
|
@@ -114141,9 +115531,10 @@ var RecordsServer = class {
|
|
|
114141
115531
|
this._moderationController = moderationController;
|
|
114142
115532
|
this._loomController = loomController;
|
|
114143
115533
|
this._webhooksController = webhooksController;
|
|
115534
|
+
this._notificationsController = notificationsController;
|
|
114144
115535
|
this._tracer = trace.getTracer(
|
|
114145
115536
|
"RecordsServer",
|
|
114146
|
-
false ? void 0 : "v3.3.11
|
|
115537
|
+
false ? void 0 : "v3.3.11"
|
|
114147
115538
|
);
|
|
114148
115539
|
this._procedures = this._createProcedures();
|
|
114149
115540
|
this._setupRoutes();
|
|
@@ -114383,6 +115774,21 @@ var RecordsServer = class {
|
|
|
114383
115774
|
return result;
|
|
114384
115775
|
}
|
|
114385
115776
|
),
|
|
115777
|
+
requestPrivacyFeaturesChange: procedure().origins("account").http("POST", "/api/v2/privacyFeatures/change").inputs(
|
|
115778
|
+
z.object({
|
|
115779
|
+
userId: z.string()
|
|
115780
|
+
})
|
|
115781
|
+
).handler(async ({ userId }, context) => {
|
|
115782
|
+
const sessionKey = context.sessionKey;
|
|
115783
|
+
if (!sessionKey) {
|
|
115784
|
+
return NOT_LOGGED_IN_RESULT;
|
|
115785
|
+
}
|
|
115786
|
+
const result = await this._auth.requestPrivacyFeaturesChange({
|
|
115787
|
+
userId,
|
|
115788
|
+
sessionKey
|
|
115789
|
+
});
|
|
115790
|
+
return result;
|
|
115791
|
+
}),
|
|
114386
115792
|
getWebAuthnRegistrationOptions: procedure().origins(true).http("GET", "/api/v2/webauthn/register/options").handler(async (_3, context) => {
|
|
114387
115793
|
const validation = await this._validateSessionKey(
|
|
114388
115794
|
context.sessionKey
|
|
@@ -114901,7 +116307,7 @@ var RecordsServer = class {
|
|
|
114901
116307
|
ipAddress: context.httpRequest.ipAddress,
|
|
114902
116308
|
path: "/api/v2/records/webhook/run",
|
|
114903
116309
|
body: JSON.stringify(data),
|
|
114904
|
-
headers: (0,
|
|
116310
|
+
headers: (0, import_lodash23.omit)(
|
|
114905
116311
|
context.httpRequest.headers,
|
|
114906
116312
|
...bannedHeaders
|
|
114907
116313
|
),
|
|
@@ -115010,6 +116416,246 @@ var RecordsServer = class {
|
|
|
115010
116416
|
);
|
|
115011
116417
|
return result;
|
|
115012
116418
|
}),
|
|
116419
|
+
recordNotification: recordItemProcedure(
|
|
116420
|
+
this._auth,
|
|
116421
|
+
this._notificationsController,
|
|
116422
|
+
z.object({
|
|
116423
|
+
address: ADDRESS_VALIDATION,
|
|
116424
|
+
description: z.string().min(1),
|
|
116425
|
+
markers: MARKERS_VALIDATION.optional().default([
|
|
116426
|
+
PRIVATE_MARKER
|
|
116427
|
+
])
|
|
116428
|
+
}),
|
|
116429
|
+
procedure().origins("api").http("POST", "/api/v2/records/notification")
|
|
116430
|
+
),
|
|
116431
|
+
getNotification: getItemProcedure(
|
|
116432
|
+
this._auth,
|
|
116433
|
+
this._notificationsController,
|
|
116434
|
+
procedure().origins("api").http("GET", "/api/v2/records/notification")
|
|
116435
|
+
),
|
|
116436
|
+
listNotifications: listItemsProcedure(
|
|
116437
|
+
this._auth,
|
|
116438
|
+
this._notificationsController,
|
|
116439
|
+
procedure().origins("api").http("GET", "/api/v2/records/notification/list")
|
|
116440
|
+
),
|
|
116441
|
+
listNotificationSubscriptions: procedure().origins("api").http("GET", "/api/v2/records/notification/list/subscriptions").inputs(
|
|
116442
|
+
z.object({
|
|
116443
|
+
recordName: RECORD_NAME_VALIDATION,
|
|
116444
|
+
address: ADDRESS_VALIDATION,
|
|
116445
|
+
instances: INSTANCES_ARRAY_VALIDATION.optional()
|
|
116446
|
+
})
|
|
116447
|
+
).handler(
|
|
116448
|
+
async ({ recordName, address, instances }, context) => {
|
|
116449
|
+
if (!this._notificationsController) {
|
|
116450
|
+
return {
|
|
116451
|
+
success: false,
|
|
116452
|
+
errorCode: "not_supported",
|
|
116453
|
+
errorMessage: "This feature is not supported."
|
|
116454
|
+
};
|
|
116455
|
+
}
|
|
116456
|
+
const validation = await this._validateSessionKey(
|
|
116457
|
+
context.sessionKey
|
|
116458
|
+
);
|
|
116459
|
+
if (validation.success === false) {
|
|
116460
|
+
if (validation.errorCode === "no_session_key") {
|
|
116461
|
+
return NOT_LOGGED_IN_RESULT;
|
|
116462
|
+
}
|
|
116463
|
+
return validation;
|
|
116464
|
+
}
|
|
116465
|
+
const result = await this._notificationsController.listSubscriptions(
|
|
116466
|
+
{
|
|
116467
|
+
recordName,
|
|
116468
|
+
address,
|
|
116469
|
+
userId: validation.userId,
|
|
116470
|
+
instances
|
|
116471
|
+
}
|
|
116472
|
+
);
|
|
116473
|
+
return result;
|
|
116474
|
+
}
|
|
116475
|
+
),
|
|
116476
|
+
listUserNotificationSubscriptions: procedure().origins("api").http(
|
|
116477
|
+
"GET",
|
|
116478
|
+
"/api/v2/records/notification/list/user/subscriptions"
|
|
116479
|
+
).inputs(
|
|
116480
|
+
z.object({
|
|
116481
|
+
instances: INSTANCES_ARRAY_VALIDATION.optional()
|
|
116482
|
+
})
|
|
116483
|
+
).handler(async ({ instances }, context) => {
|
|
116484
|
+
if (!this._notificationsController) {
|
|
116485
|
+
return {
|
|
116486
|
+
success: false,
|
|
116487
|
+
errorCode: "not_supported",
|
|
116488
|
+
errorMessage: "This feature is not supported."
|
|
116489
|
+
};
|
|
116490
|
+
}
|
|
116491
|
+
const validation = await this._validateSessionKey(
|
|
116492
|
+
context.sessionKey
|
|
116493
|
+
);
|
|
116494
|
+
if (validation.success === false) {
|
|
116495
|
+
if (validation.errorCode === "no_session_key") {
|
|
116496
|
+
return NOT_LOGGED_IN_RESULT;
|
|
116497
|
+
}
|
|
116498
|
+
return validation;
|
|
116499
|
+
}
|
|
116500
|
+
const result = await this._notificationsController.listSubscriptionsForUser(
|
|
116501
|
+
{
|
|
116502
|
+
userId: validation.userId,
|
|
116503
|
+
instances
|
|
116504
|
+
}
|
|
116505
|
+
);
|
|
116506
|
+
return result;
|
|
116507
|
+
}),
|
|
116508
|
+
eraseNotification: eraseItemProcedure(
|
|
116509
|
+
this._auth,
|
|
116510
|
+
this._notificationsController,
|
|
116511
|
+
procedure().origins("api").http("DELETE", "/api/v2/records/notification")
|
|
116512
|
+
),
|
|
116513
|
+
registerPushSubscription: procedure().origins("api").http("POST", "/api/v2/records/notification/register").inputs(
|
|
116514
|
+
z.object({
|
|
116515
|
+
pushSubscription: PUSH_SUBSCRIPTION_SCHEMA,
|
|
116516
|
+
instances: INSTANCES_ARRAY_VALIDATION.optional()
|
|
116517
|
+
})
|
|
116518
|
+
).handler(async ({ pushSubscription, instances }, context) => {
|
|
116519
|
+
if (!this._notificationsController) {
|
|
116520
|
+
return {
|
|
116521
|
+
success: false,
|
|
116522
|
+
errorCode: "not_supported",
|
|
116523
|
+
errorMessage: "This feature is not supported."
|
|
116524
|
+
};
|
|
116525
|
+
}
|
|
116526
|
+
const validation = await this._validateSessionKey(
|
|
116527
|
+
context.sessionKey
|
|
116528
|
+
);
|
|
116529
|
+
if (validation.success === false && validation.errorCode !== "no_session_key") {
|
|
116530
|
+
return validation;
|
|
116531
|
+
}
|
|
116532
|
+
const result = await this._notificationsController.registerPushSubscription(
|
|
116533
|
+
{
|
|
116534
|
+
userId: validation.userId,
|
|
116535
|
+
pushSubscription,
|
|
116536
|
+
instances
|
|
116537
|
+
}
|
|
116538
|
+
);
|
|
116539
|
+
return result;
|
|
116540
|
+
}),
|
|
116541
|
+
subscribeToNotification: procedure().origins("api").http("POST", "/api/v2/records/notification/subscribe").inputs(
|
|
116542
|
+
z.object({
|
|
116543
|
+
recordName: RECORD_NAME_VALIDATION,
|
|
116544
|
+
address: ADDRESS_VALIDATION,
|
|
116545
|
+
instances: INSTANCES_ARRAY_VALIDATION.optional(),
|
|
116546
|
+
pushSubscription: PUSH_SUBSCRIPTION_SCHEMA
|
|
116547
|
+
})
|
|
116548
|
+
).handler(
|
|
116549
|
+
async ({ recordName, address, instances, pushSubscription }, context) => {
|
|
116550
|
+
if (!this._notificationsController) {
|
|
116551
|
+
return {
|
|
116552
|
+
success: false,
|
|
116553
|
+
errorCode: "not_supported",
|
|
116554
|
+
errorMessage: "This feature is not supported."
|
|
116555
|
+
};
|
|
116556
|
+
}
|
|
116557
|
+
const validation = await this._validateSessionKey(
|
|
116558
|
+
context.sessionKey
|
|
116559
|
+
);
|
|
116560
|
+
if (validation.success === false && validation.errorCode !== "no_session_key") {
|
|
116561
|
+
return validation;
|
|
116562
|
+
}
|
|
116563
|
+
const result = await this._notificationsController.subscribeToNotification(
|
|
116564
|
+
{
|
|
116565
|
+
recordName,
|
|
116566
|
+
address,
|
|
116567
|
+
userId: validation.userId,
|
|
116568
|
+
pushSubscription,
|
|
116569
|
+
instances
|
|
116570
|
+
}
|
|
116571
|
+
);
|
|
116572
|
+
return result;
|
|
116573
|
+
}
|
|
116574
|
+
),
|
|
116575
|
+
unsubscribeFromNotification: procedure().origins("api").http("POST", "/api/v2/records/notification/unsubscribe").inputs(
|
|
116576
|
+
z.object({
|
|
116577
|
+
subscriptionId: z.string(),
|
|
116578
|
+
instances: INSTANCES_ARRAY_VALIDATION.optional()
|
|
116579
|
+
})
|
|
116580
|
+
).handler(async ({ subscriptionId, instances }, context) => {
|
|
116581
|
+
if (!this._notificationsController) {
|
|
116582
|
+
return {
|
|
116583
|
+
success: false,
|
|
116584
|
+
errorCode: "not_supported",
|
|
116585
|
+
errorMessage: "This feature is not supported."
|
|
116586
|
+
};
|
|
116587
|
+
}
|
|
116588
|
+
const validation = await this._validateSessionKey(
|
|
116589
|
+
context.sessionKey
|
|
116590
|
+
);
|
|
116591
|
+
if (validation.success === false) {
|
|
116592
|
+
if (validation.errorCode === "no_session_key") {
|
|
116593
|
+
return NOT_LOGGED_IN_RESULT;
|
|
116594
|
+
}
|
|
116595
|
+
return validation;
|
|
116596
|
+
}
|
|
116597
|
+
const result = await this._notificationsController.unsubscribeFromNotification(
|
|
116598
|
+
{
|
|
116599
|
+
subscriptionId,
|
|
116600
|
+
userId: validation.userId,
|
|
116601
|
+
instances
|
|
116602
|
+
}
|
|
116603
|
+
);
|
|
116604
|
+
return result;
|
|
116605
|
+
}),
|
|
116606
|
+
sendNotification: procedure().origins("api").http("POST", "/api/v2/records/notification/send").inputs(
|
|
116607
|
+
z.object({
|
|
116608
|
+
recordName: RECORD_NAME_VALIDATION,
|
|
116609
|
+
address: ADDRESS_VALIDATION,
|
|
116610
|
+
instances: INSTANCES_ARRAY_VALIDATION.optional(),
|
|
116611
|
+
payload: PUSH_NOTIFICATION_PAYLOAD,
|
|
116612
|
+
topic: z.string().optional()
|
|
116613
|
+
})
|
|
116614
|
+
).handler(
|
|
116615
|
+
async ({ recordName, address, instances, payload, topic }, context) => {
|
|
116616
|
+
if (!this._notificationsController) {
|
|
116617
|
+
return {
|
|
116618
|
+
success: false,
|
|
116619
|
+
errorCode: "not_supported",
|
|
116620
|
+
errorMessage: "This feature is not supported."
|
|
116621
|
+
};
|
|
116622
|
+
}
|
|
116623
|
+
const validation = await this._validateSessionKey(
|
|
116624
|
+
context.sessionKey
|
|
116625
|
+
);
|
|
116626
|
+
if (validation.success === false) {
|
|
116627
|
+
if (validation.errorCode === "no_session_key") {
|
|
116628
|
+
return NOT_LOGGED_IN_RESULT;
|
|
116629
|
+
}
|
|
116630
|
+
return validation;
|
|
116631
|
+
}
|
|
116632
|
+
const result = await this._notificationsController.sendNotification(
|
|
116633
|
+
{
|
|
116634
|
+
recordName,
|
|
116635
|
+
address,
|
|
116636
|
+
userId: validation.userId,
|
|
116637
|
+
payload,
|
|
116638
|
+
topic,
|
|
116639
|
+
instances
|
|
116640
|
+
}
|
|
116641
|
+
);
|
|
116642
|
+
return result;
|
|
116643
|
+
}
|
|
116644
|
+
),
|
|
116645
|
+
getNotificationsApplicationServerKey: procedure().origins("api").http(
|
|
116646
|
+
"GET",
|
|
116647
|
+
"/api/v2/records/notification/applicationServerKey"
|
|
116648
|
+
).handler(async () => {
|
|
116649
|
+
if (!this._notificationsController) {
|
|
116650
|
+
return {
|
|
116651
|
+
success: false,
|
|
116652
|
+
errorCode: "not_supported",
|
|
116653
|
+
errorMessage: "This feature is not supported."
|
|
116654
|
+
};
|
|
116655
|
+
}
|
|
116656
|
+
const result = await this._notificationsController.getApplicationServerKey();
|
|
116657
|
+
return result;
|
|
116658
|
+
}),
|
|
115013
116659
|
listRecords: procedure().origins("api").http("GET", "/api/v2/records/list").inputs(
|
|
115014
116660
|
z.object({
|
|
115015
116661
|
studioId: z.string().nonempty().optional(),
|
|
@@ -116222,8 +117868,8 @@ var RecordsServer = class {
|
|
|
116222
117868
|
return {
|
|
116223
117869
|
success: true,
|
|
116224
117870
|
...metadata,
|
|
116225
|
-
version: true ? "v3.3.11
|
|
116226
|
-
versionHash: true ? "
|
|
117871
|
+
version: true ? "v3.3.11" : void 0,
|
|
117872
|
+
versionHash: true ? "8e5ee8f33c196328a1c90dbbd799d2ddf248f31d" : void 0
|
|
116227
117873
|
};
|
|
116228
117874
|
})
|
|
116229
117875
|
};
|
|
@@ -116369,7 +118015,7 @@ var RecordsServer = class {
|
|
|
116369
118015
|
result,
|
|
116370
118016
|
context
|
|
116371
118017
|
);
|
|
116372
|
-
return (0,
|
|
118018
|
+
return (0, import_lodash23.merge)(response, procedureResponse);
|
|
116373
118019
|
}
|
|
116374
118020
|
return response;
|
|
116375
118021
|
},
|
|
@@ -119592,7 +121238,7 @@ var STRIPE_EVENT_INVOICE_PAID_SCHEMA = z.object({
|
|
|
119592
121238
|
});
|
|
119593
121239
|
|
|
119594
121240
|
// ../aux-records/SubscriptionController.ts
|
|
119595
|
-
var
|
|
121241
|
+
var TRACE_NAME10 = "SubscriptionController";
|
|
119596
121242
|
var SubscriptionController = class {
|
|
119597
121243
|
constructor(stripe, auth7, authStore, recordsStore, config2) {
|
|
119598
121244
|
this._stripe = stripe;
|
|
@@ -120470,19 +122116,19 @@ var SubscriptionController = class {
|
|
|
120470
122116
|
}
|
|
120471
122117
|
};
|
|
120472
122118
|
__decorateClass([
|
|
120473
|
-
traced(
|
|
122119
|
+
traced(TRACE_NAME10)
|
|
120474
122120
|
], SubscriptionController.prototype, "getSubscriptionStatus", 1);
|
|
120475
122121
|
__decorateClass([
|
|
120476
|
-
traced(
|
|
122122
|
+
traced(TRACE_NAME10)
|
|
120477
122123
|
], SubscriptionController.prototype, "updateSubscription", 1);
|
|
120478
122124
|
__decorateClass([
|
|
120479
|
-
traced(
|
|
122125
|
+
traced(TRACE_NAME10)
|
|
120480
122126
|
], SubscriptionController.prototype, "createManageSubscriptionLink", 1);
|
|
120481
122127
|
__decorateClass([
|
|
120482
|
-
traced(
|
|
122128
|
+
traced(TRACE_NAME10)
|
|
120483
122129
|
], SubscriptionController.prototype, "_createCheckoutSession", 1);
|
|
120484
122130
|
__decorateClass([
|
|
120485
|
-
traced(
|
|
122131
|
+
traced(TRACE_NAME10)
|
|
120486
122132
|
], SubscriptionController.prototype, "handleStripeWebhook", 1);
|
|
120487
122133
|
function returnRoute(basePath, user, studio) {
|
|
120488
122134
|
if (user) {
|
|
@@ -120501,7 +122147,7 @@ function studiosRoute(basePath, studioId, studioName) {
|
|
|
120501
122147
|
}
|
|
120502
122148
|
|
|
120503
122149
|
// ../aux-records/RateLimitController.ts
|
|
120504
|
-
var
|
|
122150
|
+
var TRACE_NAME11 = "RateLimitController";
|
|
120505
122151
|
var RateLimitController = class {
|
|
120506
122152
|
constructor(rateLimiter, config2) {
|
|
120507
122153
|
this._rateLimiter = rateLimiter;
|
|
@@ -120548,7 +122194,7 @@ var RateLimitController = class {
|
|
|
120548
122194
|
}
|
|
120549
122195
|
};
|
|
120550
122196
|
__decorateClass([
|
|
120551
|
-
traced(
|
|
122197
|
+
traced(TRACE_NAME11)
|
|
120552
122198
|
], RateLimitController.prototype, "checkRateLimit", 1);
|
|
120553
122199
|
|
|
120554
122200
|
// ../../node_modules/.pnpm/openai@4.47.1/node_modules/openai/version.mjs
|
|
@@ -125168,7 +126814,7 @@ var { OpenAIError: OpenAIError2, APIError: APIError2, APIConnectionError: APICon
|
|
|
125168
126814
|
var openai_default = OpenAI;
|
|
125169
126815
|
|
|
125170
126816
|
// ../aux-records/OpenAIChatInterface.ts
|
|
125171
|
-
var
|
|
126817
|
+
var TRACE_NAME12 = "OpenAIChatInterface";
|
|
125172
126818
|
var SPAN_OPTIONS = {
|
|
125173
126819
|
kind: SpanKind.CLIENT,
|
|
125174
126820
|
attributes: {
|
|
@@ -125305,14 +126951,14 @@ var OpenAIChatInterface = class {
|
|
|
125305
126951
|
}
|
|
125306
126952
|
};
|
|
125307
126953
|
__decorateClass([
|
|
125308
|
-
traced(
|
|
126954
|
+
traced(TRACE_NAME12, SPAN_OPTIONS)
|
|
125309
126955
|
], OpenAIChatInterface.prototype, "chat", 1);
|
|
125310
126956
|
__decorateClass([
|
|
125311
|
-
traced(
|
|
126957
|
+
traced(TRACE_NAME12, SPAN_OPTIONS)
|
|
125312
126958
|
], OpenAIChatInterface.prototype, "chatStream", 1);
|
|
125313
126959
|
|
|
125314
126960
|
// ../aux-records/BlockadeLabsGenerateSkyboxInterface.ts
|
|
125315
|
-
var
|
|
126961
|
+
var TRACE_NAME13 = "BlockadeLabsGenerateSkyboxInterface";
|
|
125316
126962
|
var SPAN_OPTIONS2 = {
|
|
125317
126963
|
kind: SpanKind.CLIENT,
|
|
125318
126964
|
attributes: {
|
|
@@ -125410,17 +127056,17 @@ var BlockadeLabsGenerateSkyboxInterface = class {
|
|
|
125410
127056
|
}
|
|
125411
127057
|
};
|
|
125412
127058
|
__decorateClass([
|
|
125413
|
-
traced(
|
|
127059
|
+
traced(TRACE_NAME13, SPAN_OPTIONS2)
|
|
125414
127060
|
], BlockadeLabsGenerateSkyboxInterface.prototype, "generateSkybox", 1);
|
|
125415
127061
|
__decorateClass([
|
|
125416
|
-
traced(
|
|
127062
|
+
traced(TRACE_NAME13, SPAN_OPTIONS2)
|
|
125417
127063
|
], BlockadeLabsGenerateSkyboxInterface.prototype, "getSkybox", 1);
|
|
125418
127064
|
function isFinished(status) {
|
|
125419
127065
|
return status.status === "complete" || status.status === "abort" || status.status === "error";
|
|
125420
127066
|
}
|
|
125421
127067
|
|
|
125422
127068
|
// ../aux-records/OpenAIImageInterface.ts
|
|
125423
|
-
var
|
|
127069
|
+
var TRACE_NAME14 = "OpenAIImageInterface";
|
|
125424
127070
|
var SPAN_OPTIONS3 = {
|
|
125425
127071
|
kind: SpanKind.CLIENT,
|
|
125426
127072
|
attributes: {
|
|
@@ -125472,12 +127118,12 @@ var OpenAIImageInterface = class {
|
|
|
125472
127118
|
}
|
|
125473
127119
|
};
|
|
125474
127120
|
__decorateClass([
|
|
125475
|
-
traced(
|
|
127121
|
+
traced(TRACE_NAME14, SPAN_OPTIONS3)
|
|
125476
127122
|
], OpenAIImageInterface.prototype, "generateImage", 1);
|
|
125477
127123
|
|
|
125478
127124
|
// ../aux-records/StabilityAIImageInterface.ts
|
|
125479
|
-
var
|
|
125480
|
-
var
|
|
127125
|
+
var import_lodash24 = __toESM(require_lodash());
|
|
127126
|
+
var TRACE_NAME15 = "StabilityAIImageInterface";
|
|
125481
127127
|
var StabilityAIImageInterface = class {
|
|
125482
127128
|
constructor(options) {
|
|
125483
127129
|
this._options = options;
|
|
@@ -125533,7 +127179,7 @@ var StabilityAIImageInterface = class {
|
|
|
125533
127179
|
console.log(
|
|
125534
127180
|
`[StabilityAIImageInterface] [${request2.userId}] [generateImage]: Done!`
|
|
125535
127181
|
);
|
|
125536
|
-
const images = (0,
|
|
127182
|
+
const images = (0, import_lodash24.flatMap)(
|
|
125537
127183
|
result.data,
|
|
125538
127184
|
(a3) => a3.map((d2) => ({
|
|
125539
127185
|
base64: d2.base64,
|
|
@@ -125668,16 +127314,16 @@ var StabilityAIImageInterface = class {
|
|
|
125668
127314
|
}
|
|
125669
127315
|
};
|
|
125670
127316
|
__decorateClass([
|
|
125671
|
-
traced(
|
|
127317
|
+
traced(TRACE_NAME15)
|
|
125672
127318
|
], StabilityAIImageInterface.prototype, "generateImage", 1);
|
|
125673
127319
|
__decorateClass([
|
|
125674
|
-
traced(
|
|
127320
|
+
traced(TRACE_NAME15)
|
|
125675
127321
|
], StabilityAIImageInterface.prototype, "_stableImageUltra", 1);
|
|
125676
127322
|
__decorateClass([
|
|
125677
|
-
traced(
|
|
127323
|
+
traced(TRACE_NAME15)
|
|
125678
127324
|
], StabilityAIImageInterface.prototype, "_stableImageCore", 1);
|
|
125679
127325
|
__decorateClass([
|
|
125680
|
-
traced(
|
|
127326
|
+
traced(TRACE_NAME15)
|
|
125681
127327
|
], StabilityAIImageInterface.prototype, "_sd3", 1);
|
|
125682
127328
|
function getStableImageAspectRatio(width, height) {
|
|
125683
127329
|
if (!width || !height) {
|
|
@@ -126517,7 +128163,7 @@ var GoogleGenerativeAI = class {
|
|
|
126517
128163
|
};
|
|
126518
128164
|
|
|
126519
128165
|
// ../aux-records/GoogleAIChatInterface.ts
|
|
126520
|
-
var
|
|
128166
|
+
var TRACE_NAME16 = "GoogleAIChatInterface";
|
|
126521
128167
|
var SPAN_OPTIONS4 = {
|
|
126522
128168
|
kind: SpanKind.CLIENT,
|
|
126523
128169
|
attributes: {
|
|
@@ -126697,10 +128343,10 @@ var GoogleAIChatInterface = class {
|
|
|
126697
128343
|
}
|
|
126698
128344
|
};
|
|
126699
128345
|
__decorateClass([
|
|
126700
|
-
traced(
|
|
128346
|
+
traced(TRACE_NAME16, SPAN_OPTIONS4)
|
|
126701
128347
|
], GoogleAIChatInterface.prototype, "chat", 1);
|
|
126702
128348
|
__decorateClass([
|
|
126703
|
-
traced(
|
|
128349
|
+
traced(TRACE_NAME16, SPAN_OPTIONS4)
|
|
126704
128350
|
], GoogleAIChatInterface.prototype, "chatStream", 1);
|
|
126705
128351
|
function mapMessage(message2) {
|
|
126706
128352
|
return {
|
|
@@ -128871,7 +130517,7 @@ var { AnthropicError: AnthropicError2, APIError: APIError4, APIConnectionError:
|
|
|
128871
130517
|
var sdk_default = Anthropic;
|
|
128872
130518
|
|
|
128873
130519
|
// ../aux-records/AnthropicAIChatInterface.ts
|
|
128874
|
-
var
|
|
130520
|
+
var TRACE_NAME17 = "AnthropicAIChatInterface";
|
|
128875
130521
|
var SPAN_OPTIONS5 = {
|
|
128876
130522
|
kind: SpanKind.CLIENT,
|
|
128877
130523
|
attributes: {
|
|
@@ -128991,10 +130637,10 @@ var AnthropicAIChatInterface = class {
|
|
|
128991
130637
|
}
|
|
128992
130638
|
};
|
|
128993
130639
|
__decorateClass([
|
|
128994
|
-
traced(
|
|
130640
|
+
traced(TRACE_NAME17, SPAN_OPTIONS5)
|
|
128995
130641
|
], AnthropicAIChatInterface.prototype, "chat", 1);
|
|
128996
130642
|
__decorateClass([
|
|
128997
|
-
traced(
|
|
130643
|
+
traced(TRACE_NAME17, SPAN_OPTIONS5)
|
|
128998
130644
|
], AnthropicAIChatInterface.prototype, "chatStream", 1);
|
|
128999
130645
|
function mapMessage2(message2) {
|
|
129000
130646
|
return {
|
|
@@ -129041,13 +130687,13 @@ function mapOutputContent(content) {
|
|
|
129041
130687
|
}
|
|
129042
130688
|
|
|
129043
130689
|
// ../aux-records/MemoryStore.ts
|
|
129044
|
-
var
|
|
130690
|
+
var import_lodash25 = __toESM(require_lodash());
|
|
129045
130691
|
|
|
129046
130692
|
// ../aux-records/MemoryFileRecordsLookup.ts
|
|
129047
|
-
var
|
|
130693
|
+
var import_lodash26 = __toESM(require_lodash());
|
|
129048
130694
|
|
|
129049
130695
|
// ../aux-records/CachingConfigStore.ts
|
|
129050
|
-
var
|
|
130696
|
+
var TRACE_NAME18 = "CachingConfigStore";
|
|
129051
130697
|
var CachingConfigStore = class {
|
|
129052
130698
|
/**
|
|
129053
130699
|
* Creates a new CachingConfigStore.
|
|
@@ -129103,17 +130749,17 @@ var CachingConfigStore = class {
|
|
|
129103
130749
|
}
|
|
129104
130750
|
};
|
|
129105
130751
|
__decorateClass([
|
|
129106
|
-
traced(
|
|
130752
|
+
traced(TRACE_NAME18)
|
|
129107
130753
|
], CachingConfigStore.prototype, "getSubscriptionConfiguration", 1);
|
|
129108
130754
|
__decorateClass([
|
|
129109
|
-
traced(
|
|
130755
|
+
traced(TRACE_NAME18)
|
|
129110
130756
|
], CachingConfigStore.prototype, "getPrivoConfiguration", 1);
|
|
129111
130757
|
__decorateClass([
|
|
129112
|
-
traced(
|
|
130758
|
+
traced(TRACE_NAME18)
|
|
129113
130759
|
], CachingConfigStore.prototype, "getModerationConfig", 1);
|
|
129114
130760
|
|
|
129115
130761
|
// ../aux-records/ModerationController.ts
|
|
129116
|
-
var
|
|
130762
|
+
var TRACE_NAME19 = "ModerationController";
|
|
129117
130763
|
var ModerationController = class {
|
|
129118
130764
|
constructor(store, config2, messenger, jobProvider) {
|
|
129119
130765
|
this._store = store;
|
|
@@ -129347,13 +130993,13 @@ var ModerationController = class {
|
|
|
129347
130993
|
}
|
|
129348
130994
|
};
|
|
129349
130995
|
__decorateClass([
|
|
129350
|
-
traced(
|
|
130996
|
+
traced(TRACE_NAME19)
|
|
129351
130997
|
], ModerationController.prototype, "reportInst", 1);
|
|
129352
130998
|
__decorateClass([
|
|
129353
|
-
traced(
|
|
130999
|
+
traced(TRACE_NAME19)
|
|
129354
131000
|
], ModerationController.prototype, "scheduleModerationScans", 1);
|
|
129355
131001
|
__decorateClass([
|
|
129356
|
-
traced(
|
|
131002
|
+
traced(TRACE_NAME19)
|
|
129357
131003
|
], ModerationController.prototype, "scanFile", 1);
|
|
129358
131004
|
|
|
129359
131005
|
// ../aux-records/ModerationConfiguration.ts
|
|
@@ -129440,7 +131086,7 @@ var moderationSchema = z.object({
|
|
|
129440
131086
|
}).describe("The moderation jobs that are enabled.").optional()
|
|
129441
131087
|
});
|
|
129442
131088
|
|
|
129443
|
-
// ../aux-records/
|
|
131089
|
+
// ../aux-records/SystemNotificationMessenger.ts
|
|
129444
131090
|
var slackSchema = z.object({
|
|
129445
131091
|
webhookUrl: z.string().describe(
|
|
129446
131092
|
"The Slack webhook URL that should be used to send records notification messages."
|
|
@@ -129539,9 +131185,9 @@ var util3 = __toESM(require("node:util"), 1);
|
|
|
129539
131185
|
var is_key_object_default = (obj) => util3.types.isKeyObject(obj);
|
|
129540
131186
|
|
|
129541
131187
|
// ../../node_modules/.pnpm/jose@5.4.0/node_modules/jose/dist/node/esm/runtime/webcrypto.js
|
|
129542
|
-
var
|
|
131188
|
+
var crypto5 = __toESM(require("node:crypto"), 1);
|
|
129543
131189
|
var util4 = __toESM(require("node:util"), 1);
|
|
129544
|
-
var webcrypto3 =
|
|
131190
|
+
var webcrypto3 = crypto5.webcrypto;
|
|
129545
131191
|
var webcrypto_default = webcrypto3;
|
|
129546
131192
|
var isCryptoKey = (key) => util4.types.isCryptoKey(key);
|
|
129547
131193
|
|
|
@@ -129717,11 +131363,11 @@ function isObject4(input2) {
|
|
|
129717
131363
|
}
|
|
129718
131364
|
|
|
129719
131365
|
// ../../node_modules/.pnpm/jose@5.4.0/node_modules/jose/dist/node/esm/runtime/ecdhes.js
|
|
129720
|
-
var
|
|
131366
|
+
var import_node_crypto7 = require("node:crypto");
|
|
129721
131367
|
var import_node_util3 = require("node:util");
|
|
129722
131368
|
|
|
129723
131369
|
// ../../node_modules/.pnpm/jose@5.4.0/node_modules/jose/dist/node/esm/runtime/get_named_curve.js
|
|
129724
|
-
var
|
|
131370
|
+
var import_node_crypto6 = require("node:crypto");
|
|
129725
131371
|
var namedCurveToJOSE = (namedCurve) => {
|
|
129726
131372
|
switch (namedCurve) {
|
|
129727
131373
|
case "prime256v1":
|
|
@@ -129739,7 +131385,7 @@ var namedCurveToJOSE = (namedCurve) => {
|
|
|
129739
131385
|
var getNamedCurve2 = (kee, raw) => {
|
|
129740
131386
|
let key;
|
|
129741
131387
|
if (isCryptoKey(kee)) {
|
|
129742
|
-
key =
|
|
131388
|
+
key = import_node_crypto6.KeyObject.from(kee);
|
|
129743
131389
|
} else if (is_key_object_default(kee)) {
|
|
129744
131390
|
key = kee;
|
|
129745
131391
|
} else {
|
|
@@ -129769,15 +131415,15 @@ var getNamedCurve2 = (kee, raw) => {
|
|
|
129769
131415
|
var get_named_curve_default = getNamedCurve2;
|
|
129770
131416
|
|
|
129771
131417
|
// ../../node_modules/.pnpm/jose@5.4.0/node_modules/jose/dist/node/esm/runtime/ecdhes.js
|
|
129772
|
-
var generateKeyPair = (0, import_node_util3.promisify)(
|
|
131418
|
+
var generateKeyPair = (0, import_node_util3.promisify)(import_node_crypto7.generateKeyPair);
|
|
129773
131419
|
|
|
129774
131420
|
// ../../node_modules/.pnpm/jose@5.4.0/node_modules/jose/dist/node/esm/runtime/pbes2kw.js
|
|
129775
131421
|
var import_node_util4 = require("node:util");
|
|
129776
|
-
var
|
|
129777
|
-
var pbkdf2 = (0, import_node_util4.promisify)(
|
|
131422
|
+
var import_node_crypto8 = require("node:crypto");
|
|
131423
|
+
var pbkdf2 = (0, import_node_util4.promisify)(import_node_crypto8.pbkdf2);
|
|
129778
131424
|
|
|
129779
131425
|
// ../../node_modules/.pnpm/jose@5.4.0/node_modules/jose/dist/node/esm/runtime/rsaes.js
|
|
129780
|
-
var
|
|
131426
|
+
var import_node_crypto9 = require("node:crypto");
|
|
129781
131427
|
var import_node_util5 = require("node:util");
|
|
129782
131428
|
|
|
129783
131429
|
// ../../node_modules/.pnpm/jose@5.4.0/node_modules/jose/dist/node/esm/runtime/check_key_length.js
|
|
@@ -129789,12 +131435,12 @@ var check_key_length_default = (key, alg) => {
|
|
|
129789
131435
|
};
|
|
129790
131436
|
|
|
129791
131437
|
// ../../node_modules/.pnpm/jose@5.4.0/node_modules/jose/dist/node/esm/runtime/rsaes.js
|
|
129792
|
-
var RSA1_5 = (0, import_node_util5.deprecate)(() =>
|
|
131438
|
+
var RSA1_5 = (0, import_node_util5.deprecate)(() => import_node_crypto9.constants.RSA_PKCS1_PADDING, 'The RSA1_5 "alg" (JWE Algorithm) is deprecated and will be removed in the next major revision.');
|
|
129793
131439
|
|
|
129794
131440
|
// ../../node_modules/.pnpm/jose@5.4.0/node_modules/jose/dist/node/esm/runtime/asn1.js
|
|
129795
|
-
var
|
|
131441
|
+
var import_node_crypto10 = require("node:crypto");
|
|
129796
131442
|
var import_node_buffer2 = require("node:buffer");
|
|
129797
|
-
var fromPKCS8 = (pem) => (0,
|
|
131443
|
+
var fromPKCS8 = (pem) => (0, import_node_crypto10.createPrivateKey)({
|
|
129798
131444
|
key: import_node_buffer2.Buffer.from(pem.replace(/(?:-----(?:BEGIN|END) PRIVATE KEY-----|\s)/g, ""), "base64"),
|
|
129799
131445
|
type: "pkcs8",
|
|
129800
131446
|
format: "der"
|
|
@@ -129885,7 +131531,7 @@ var validate_crit_default = validateCrit;
|
|
|
129885
131531
|
var unprotected = Symbol();
|
|
129886
131532
|
|
|
129887
131533
|
// ../../node_modules/.pnpm/jose@5.4.0/node_modules/jose/dist/node/esm/runtime/verify.js
|
|
129888
|
-
var
|
|
131534
|
+
var crypto7 = __toESM(require("node:crypto"), 1);
|
|
129889
131535
|
var import_node_util7 = require("node:util");
|
|
129890
131536
|
|
|
129891
131537
|
// ../../node_modules/.pnpm/jose@5.4.0/node_modules/jose/dist/node/esm/runtime/dsa_digest.js
|
|
@@ -129912,10 +131558,10 @@ function dsaDigest(alg) {
|
|
|
129912
131558
|
}
|
|
129913
131559
|
|
|
129914
131560
|
// ../../node_modules/.pnpm/jose@5.4.0/node_modules/jose/dist/node/esm/runtime/node_key.js
|
|
129915
|
-
var
|
|
131561
|
+
var import_node_crypto11 = require("node:crypto");
|
|
129916
131562
|
var PSS = {
|
|
129917
|
-
padding:
|
|
129918
|
-
saltLength:
|
|
131563
|
+
padding: import_node_crypto11.constants.RSA_PKCS1_PSS_PADDING,
|
|
131564
|
+
saltLength: import_node_crypto11.constants.RSA_PSS_SALTLEN_DIGEST
|
|
129919
131565
|
};
|
|
129920
131566
|
var ecCurveAlgMap = /* @__PURE__ */ new Map([
|
|
129921
131567
|
["ES256", "P-256"],
|
|
@@ -129975,7 +131621,7 @@ function keyForCrypto(alg, key) {
|
|
|
129975
131621
|
}
|
|
129976
131622
|
|
|
129977
131623
|
// ../../node_modules/.pnpm/jose@5.4.0/node_modules/jose/dist/node/esm/runtime/sign.js
|
|
129978
|
-
var
|
|
131624
|
+
var crypto6 = __toESM(require("node:crypto"), 1);
|
|
129979
131625
|
var import_node_util6 = require("node:util");
|
|
129980
131626
|
|
|
129981
131627
|
// ../../node_modules/.pnpm/jose@5.4.0/node_modules/jose/dist/node/esm/runtime/hmac_digest.js
|
|
@@ -129993,30 +131639,30 @@ function hmacDigest(alg) {
|
|
|
129993
131639
|
}
|
|
129994
131640
|
|
|
129995
131641
|
// ../../node_modules/.pnpm/jose@5.4.0/node_modules/jose/dist/node/esm/runtime/get_sign_verify_key.js
|
|
129996
|
-
var
|
|
131642
|
+
var import_node_crypto12 = require("node:crypto");
|
|
129997
131643
|
function getSignVerifyKey(alg, key, usage) {
|
|
129998
131644
|
if (key instanceof Uint8Array) {
|
|
129999
131645
|
if (!alg.startsWith("HS")) {
|
|
130000
131646
|
throw new TypeError(invalid_key_input_default(key, ...types3));
|
|
130001
131647
|
}
|
|
130002
|
-
return (0,
|
|
131648
|
+
return (0, import_node_crypto12.createSecretKey)(key);
|
|
130003
131649
|
}
|
|
130004
|
-
if (key instanceof
|
|
131650
|
+
if (key instanceof import_node_crypto12.KeyObject) {
|
|
130005
131651
|
return key;
|
|
130006
131652
|
}
|
|
130007
131653
|
if (isCryptoKey(key)) {
|
|
130008
131654
|
checkSigCryptoKey(key, alg, usage);
|
|
130009
|
-
return
|
|
131655
|
+
return import_node_crypto12.KeyObject.from(key);
|
|
130010
131656
|
}
|
|
130011
131657
|
throw new TypeError(invalid_key_input_default(key, ...types3, "Uint8Array"));
|
|
130012
131658
|
}
|
|
130013
131659
|
|
|
130014
131660
|
// ../../node_modules/.pnpm/jose@5.4.0/node_modules/jose/dist/node/esm/runtime/sign.js
|
|
130015
|
-
var oneShotSign = (0, import_node_util6.promisify)(
|
|
131661
|
+
var oneShotSign = (0, import_node_util6.promisify)(crypto6.sign);
|
|
130016
131662
|
var sign2 = async (alg, key, data) => {
|
|
130017
131663
|
const keyObject = getSignVerifyKey(alg, key, "sign");
|
|
130018
131664
|
if (alg.startsWith("HS")) {
|
|
130019
|
-
const hmac6 =
|
|
131665
|
+
const hmac6 = crypto6.createHmac(hmacDigest(alg), keyObject);
|
|
130020
131666
|
hmac6.update(data);
|
|
130021
131667
|
return hmac6.digest();
|
|
130022
131668
|
}
|
|
@@ -130025,7 +131671,7 @@ var sign2 = async (alg, key, data) => {
|
|
|
130025
131671
|
var sign_default = sign2;
|
|
130026
131672
|
|
|
130027
131673
|
// ../../node_modules/.pnpm/jose@5.4.0/node_modules/jose/dist/node/esm/runtime/verify.js
|
|
130028
|
-
var oneShotVerify = (0, import_node_util7.promisify)(
|
|
131674
|
+
var oneShotVerify = (0, import_node_util7.promisify)(crypto7.verify);
|
|
130029
131675
|
|
|
130030
131676
|
// ../../node_modules/.pnpm/jose@5.4.0/node_modules/jose/dist/node/esm/lib/epoch.js
|
|
130031
131677
|
var epoch_default = (date) => Math.floor(date.getTime() / 1e3);
|
|
@@ -130278,12 +131924,12 @@ if (typeof navigator === "undefined" || !navigator.userAgent?.startsWith?.("Mozi
|
|
|
130278
131924
|
}
|
|
130279
131925
|
|
|
130280
131926
|
// ../../node_modules/.pnpm/jose@5.4.0/node_modules/jose/dist/node/esm/runtime/generate.js
|
|
130281
|
-
var
|
|
131927
|
+
var import_node_crypto13 = require("node:crypto");
|
|
130282
131928
|
var import_node_util8 = require("node:util");
|
|
130283
|
-
var generate2 = (0, import_node_util8.promisify)(
|
|
131929
|
+
var generate2 = (0, import_node_util8.promisify)(import_node_crypto13.generateKeyPair);
|
|
130284
131930
|
|
|
130285
131931
|
// ../aux-records/LoomController.ts
|
|
130286
|
-
var
|
|
131932
|
+
var TRACE_NAME20 = "LoomController";
|
|
130287
131933
|
var LoomController = class {
|
|
130288
131934
|
constructor(options) {
|
|
130289
131935
|
this._policies = options.policies;
|
|
@@ -130368,7 +132014,7 @@ var LoomController = class {
|
|
|
130368
132014
|
}
|
|
130369
132015
|
};
|
|
130370
132016
|
__decorateClass([
|
|
130371
|
-
traced(
|
|
132017
|
+
traced(TRACE_NAME20)
|
|
130372
132018
|
], LoomController.prototype, "getToken", 1);
|
|
130373
132019
|
|
|
130374
132020
|
// ../aux-records/PrivoConfiguration.ts
|
|
@@ -130915,10 +132561,6 @@ var serverConfigSchema = z.object({
|
|
|
130915
132561
|
telemetry: telemetrySchema.describe(
|
|
130916
132562
|
"Options for configuring telemetry. If omitted, then telemetry will not be enabled."
|
|
130917
132563
|
).optional(),
|
|
130918
|
-
// auth: authSchema
|
|
130919
|
-
// .describe('Authentication configuration options.')
|
|
130920
|
-
// .optional()
|
|
130921
|
-
// .default({}),
|
|
130922
132564
|
subscriptions: subscriptionConfigSchema.describe(
|
|
130923
132565
|
"The default subscription configuration. If omitted, then subscription features will be disabled."
|
|
130924
132566
|
).optional(),
|
|
@@ -130926,7 +132568,7 @@ var serverConfigSchema = z.object({
|
|
|
130926
132568
|
"Stripe options. If omitted, then Stripe features will be disabled."
|
|
130927
132569
|
).optional(),
|
|
130928
132570
|
notifications: notificationsSchema.describe(
|
|
130929
|
-
"
|
|
132571
|
+
"System notification configuration options. Used to send messages for various events like user inst reports and com ID requests. If omitted, then server notifications will be disabled."
|
|
130930
132572
|
).optional(),
|
|
130931
132573
|
moderation: moderationSchema.describe(
|
|
130932
132574
|
"Moderation configuration options. If omitted, then moderation features will be disabled unless overridden in the database."
|
|
@@ -130934,6 +132576,19 @@ var serverConfigSchema = z.object({
|
|
|
130934
132576
|
webhooks: webhooksSchema.describe(
|
|
130935
132577
|
"Webhook configuration options. If omitted, then webhook features will be disabled."
|
|
130936
132578
|
).optional(),
|
|
132579
|
+
webPush: z.object({
|
|
132580
|
+
vapidSubject: z.string().describe(
|
|
132581
|
+
"The subject that should be used for sending web push notifications. You can generate VAPID keys using https://www.npmjs.com/package/web-push"
|
|
132582
|
+
).min(1),
|
|
132583
|
+
vapidPublicKey: z.string().describe(
|
|
132584
|
+
"The public key that should be used for sending web push notifications. You can generate VAPID keys using https://www.npmjs.com/package/web-push"
|
|
132585
|
+
).min(1),
|
|
132586
|
+
vapidPrivateKey: z.string().describe(
|
|
132587
|
+
"The private key that should be used for sending web push notifications. You can generate VAPID keys using https://www.npmjs.com/package/web-push"
|
|
132588
|
+
).min(1)
|
|
132589
|
+
}).describe(
|
|
132590
|
+
"Web Push configuration options. If omitted, then web push notifications will be disabled."
|
|
132591
|
+
).optional(),
|
|
130937
132592
|
meta: z.object({
|
|
130938
132593
|
apiOrigin: z.string().describe("The HTTP origin that the API is available at."),
|
|
130939
132594
|
websocketOrigin: z.string().describe(
|
|
@@ -130947,391 +132602,6 @@ var serverConfigSchema = z.object({
|
|
|
130947
132602
|
).optional()
|
|
130948
132603
|
});
|
|
130949
132604
|
|
|
130950
|
-
// ../aux-records/crud/CrudRecordsController.ts
|
|
130951
|
-
var TRACE_NAME19 = "CrudRecordsController";
|
|
130952
|
-
var CrudRecordsController = class {
|
|
130953
|
-
get config() {
|
|
130954
|
-
return this._config;
|
|
130955
|
-
}
|
|
130956
|
-
/**
|
|
130957
|
-
* Gets the name of the controller.
|
|
130958
|
-
*/
|
|
130959
|
-
get name() {
|
|
130960
|
-
return this._name;
|
|
130961
|
-
}
|
|
130962
|
-
get policies() {
|
|
130963
|
-
return this._policies;
|
|
130964
|
-
}
|
|
130965
|
-
get store() {
|
|
130966
|
-
return this._store;
|
|
130967
|
-
}
|
|
130968
|
-
/**
|
|
130969
|
-
* Gets the kind of resources that this controller is for.
|
|
130970
|
-
*/
|
|
130971
|
-
get resourceKind() {
|
|
130972
|
-
return this._resourceKind;
|
|
130973
|
-
}
|
|
130974
|
-
constructor(config2) {
|
|
130975
|
-
this._name = config2.name;
|
|
130976
|
-
this._store = config2.store;
|
|
130977
|
-
this._policies = config2.policies;
|
|
130978
|
-
this._config = config2.config;
|
|
130979
|
-
this._resourceKind = config2.resourceKind;
|
|
130980
|
-
}
|
|
130981
|
-
async recordItem(request2) {
|
|
130982
|
-
try {
|
|
130983
|
-
const contextResult = await this._policies.constructAuthorizationContext({
|
|
130984
|
-
recordKeyOrRecordName: request2.recordKeyOrRecordName,
|
|
130985
|
-
userId: request2.userId
|
|
130986
|
-
});
|
|
130987
|
-
if (contextResult.success === false) {
|
|
130988
|
-
return contextResult;
|
|
130989
|
-
}
|
|
130990
|
-
const recordName = contextResult.context.recordName;
|
|
130991
|
-
const existingItem = await this._store.getItemByAddress(
|
|
130992
|
-
recordName,
|
|
130993
|
-
request2.item.address
|
|
130994
|
-
);
|
|
130995
|
-
let resourceMarkers;
|
|
130996
|
-
let action2 = existingItem ? "update" : "create";
|
|
130997
|
-
let authorization;
|
|
130998
|
-
if (action2 === "update") {
|
|
130999
|
-
const existingMarkers = existingItem.markers;
|
|
131000
|
-
resourceMarkers = request2.item.markers ?? existingMarkers;
|
|
131001
|
-
action2 = "update";
|
|
131002
|
-
authorization = await this._policies.authorizeUserAndInstancesForResources(
|
|
131003
|
-
contextResult.context,
|
|
131004
|
-
{
|
|
131005
|
-
userId: request2.userId,
|
|
131006
|
-
instances: request2.instances,
|
|
131007
|
-
resources: [
|
|
131008
|
-
{
|
|
131009
|
-
resourceKind: this._resourceKind,
|
|
131010
|
-
resourceId: existingItem.address,
|
|
131011
|
-
action: action2,
|
|
131012
|
-
markers: resourceMarkers
|
|
131013
|
-
},
|
|
131014
|
-
...getMarkerResourcesForUpdate(
|
|
131015
|
-
existingMarkers,
|
|
131016
|
-
request2.item.markers
|
|
131017
|
-
)
|
|
131018
|
-
]
|
|
131019
|
-
}
|
|
131020
|
-
);
|
|
131021
|
-
if (authorization.success === false) {
|
|
131022
|
-
return authorization;
|
|
131023
|
-
}
|
|
131024
|
-
} else {
|
|
131025
|
-
resourceMarkers = request2.item.markers;
|
|
131026
|
-
authorization = await this._policies.authorizeUserAndInstancesForResources(
|
|
131027
|
-
contextResult.context,
|
|
131028
|
-
{
|
|
131029
|
-
userId: request2.userId,
|
|
131030
|
-
instances: request2.instances,
|
|
131031
|
-
resources: [
|
|
131032
|
-
{
|
|
131033
|
-
resourceKind: this._resourceKind,
|
|
131034
|
-
resourceId: request2.item.address,
|
|
131035
|
-
action: action2,
|
|
131036
|
-
markers: resourceMarkers
|
|
131037
|
-
},
|
|
131038
|
-
...getMarkerResourcesForCreation(
|
|
131039
|
-
resourceMarkers
|
|
131040
|
-
)
|
|
131041
|
-
]
|
|
131042
|
-
}
|
|
131043
|
-
);
|
|
131044
|
-
if (authorization.success === false) {
|
|
131045
|
-
return authorization;
|
|
131046
|
-
}
|
|
131047
|
-
}
|
|
131048
|
-
if (!resourceMarkers) {
|
|
131049
|
-
return {
|
|
131050
|
-
success: false,
|
|
131051
|
-
errorCode: "invalid_request",
|
|
131052
|
-
errorMessage: "The item must have markers."
|
|
131053
|
-
};
|
|
131054
|
-
}
|
|
131055
|
-
const item = this._transformInputItem(request2.item);
|
|
131056
|
-
const subscriptionResult = await this._checkSubscriptionMetrics(
|
|
131057
|
-
action2,
|
|
131058
|
-
contextResult.context,
|
|
131059
|
-
authorization,
|
|
131060
|
-
item
|
|
131061
|
-
);
|
|
131062
|
-
if (subscriptionResult.success === false) {
|
|
131063
|
-
return subscriptionResult;
|
|
131064
|
-
}
|
|
131065
|
-
await this._store.putItem(recordName, item);
|
|
131066
|
-
return {
|
|
131067
|
-
success: true,
|
|
131068
|
-
recordName,
|
|
131069
|
-
address: item.address
|
|
131070
|
-
};
|
|
131071
|
-
} catch (err) {
|
|
131072
|
-
const span = trace.getActiveSpan();
|
|
131073
|
-
span?.recordException(err);
|
|
131074
|
-
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
131075
|
-
console.error(`[${this._name}] Error recording item:`, err);
|
|
131076
|
-
return {
|
|
131077
|
-
success: false,
|
|
131078
|
-
errorCode: "server_error",
|
|
131079
|
-
errorMessage: "A server error occurred."
|
|
131080
|
-
};
|
|
131081
|
-
}
|
|
131082
|
-
}
|
|
131083
|
-
async getItem(request2) {
|
|
131084
|
-
try {
|
|
131085
|
-
const baseRequest = {
|
|
131086
|
-
recordKeyOrRecordName: request2.recordName,
|
|
131087
|
-
userId: request2.userId,
|
|
131088
|
-
instances: request2.instances
|
|
131089
|
-
};
|
|
131090
|
-
const context = await this._policies.constructAuthorizationContext(
|
|
131091
|
-
baseRequest
|
|
131092
|
-
);
|
|
131093
|
-
if (context.success === false) {
|
|
131094
|
-
return context;
|
|
131095
|
-
}
|
|
131096
|
-
const result = await this._store.getItemByAddress(
|
|
131097
|
-
context.context.recordName,
|
|
131098
|
-
request2.address
|
|
131099
|
-
);
|
|
131100
|
-
if (!result) {
|
|
131101
|
-
return {
|
|
131102
|
-
success: false,
|
|
131103
|
-
errorCode: "data_not_found",
|
|
131104
|
-
errorMessage: "The item was not found."
|
|
131105
|
-
};
|
|
131106
|
-
}
|
|
131107
|
-
const markers = result.markers;
|
|
131108
|
-
const authorization = await this._policies.authorizeUserAndInstances(
|
|
131109
|
-
context.context,
|
|
131110
|
-
{
|
|
131111
|
-
userId: request2.userId,
|
|
131112
|
-
instances: request2.instances,
|
|
131113
|
-
resourceKind: this._resourceKind,
|
|
131114
|
-
resourceId: request2.address,
|
|
131115
|
-
action: "read",
|
|
131116
|
-
markers
|
|
131117
|
-
}
|
|
131118
|
-
);
|
|
131119
|
-
if (authorization.success === false) {
|
|
131120
|
-
return authorization;
|
|
131121
|
-
}
|
|
131122
|
-
return {
|
|
131123
|
-
success: true,
|
|
131124
|
-
item: this._convertItemToResult(result, context.context)
|
|
131125
|
-
};
|
|
131126
|
-
} catch (err) {
|
|
131127
|
-
const span = trace.getActiveSpan();
|
|
131128
|
-
span?.recordException(err);
|
|
131129
|
-
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
131130
|
-
console.error(`[${this._name}] Error getting item:`, err);
|
|
131131
|
-
return {
|
|
131132
|
-
success: false,
|
|
131133
|
-
errorCode: "server_error",
|
|
131134
|
-
errorMessage: "A server error occurred."
|
|
131135
|
-
};
|
|
131136
|
-
}
|
|
131137
|
-
}
|
|
131138
|
-
async eraseItem(request2) {
|
|
131139
|
-
try {
|
|
131140
|
-
const context = await this._policies.constructAuthorizationContext({
|
|
131141
|
-
recordKeyOrRecordName: request2.recordName,
|
|
131142
|
-
userId: request2.userId
|
|
131143
|
-
});
|
|
131144
|
-
if (context.success === false) {
|
|
131145
|
-
return context;
|
|
131146
|
-
}
|
|
131147
|
-
const result = await this._store.getItemByAddress(
|
|
131148
|
-
context.context.recordName,
|
|
131149
|
-
request2.address
|
|
131150
|
-
);
|
|
131151
|
-
if (!result) {
|
|
131152
|
-
return {
|
|
131153
|
-
success: false,
|
|
131154
|
-
errorCode: "data_not_found",
|
|
131155
|
-
errorMessage: "The item was not found."
|
|
131156
|
-
};
|
|
131157
|
-
}
|
|
131158
|
-
const markers = result.markers;
|
|
131159
|
-
const authorization = await this._policies.authorizeUserAndInstances(
|
|
131160
|
-
context.context,
|
|
131161
|
-
{
|
|
131162
|
-
userId: request2.userId,
|
|
131163
|
-
instances: request2.instances,
|
|
131164
|
-
resourceKind: this._resourceKind,
|
|
131165
|
-
resourceId: request2.address,
|
|
131166
|
-
action: "delete",
|
|
131167
|
-
markers
|
|
131168
|
-
}
|
|
131169
|
-
);
|
|
131170
|
-
if (authorization.success === false) {
|
|
131171
|
-
return authorization;
|
|
131172
|
-
}
|
|
131173
|
-
const recordName = context.context.recordName;
|
|
131174
|
-
const subscriptionResult = await this._checkSubscriptionMetrics(
|
|
131175
|
-
"delete",
|
|
131176
|
-
context.context,
|
|
131177
|
-
authorization
|
|
131178
|
-
);
|
|
131179
|
-
if (subscriptionResult.success === false) {
|
|
131180
|
-
return subscriptionResult;
|
|
131181
|
-
}
|
|
131182
|
-
await this._store.deleteItem(recordName, request2.address);
|
|
131183
|
-
return {
|
|
131184
|
-
success: true
|
|
131185
|
-
};
|
|
131186
|
-
} catch (err) {
|
|
131187
|
-
const span = trace.getActiveSpan();
|
|
131188
|
-
span?.recordException(err);
|
|
131189
|
-
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
131190
|
-
console.error(`[${this._name}] Error erasing item:`, err);
|
|
131191
|
-
return {
|
|
131192
|
-
success: false,
|
|
131193
|
-
errorCode: "server_error",
|
|
131194
|
-
errorMessage: "A server error occurred."
|
|
131195
|
-
};
|
|
131196
|
-
}
|
|
131197
|
-
}
|
|
131198
|
-
async listItems(request2) {
|
|
131199
|
-
try {
|
|
131200
|
-
const baseRequest = {
|
|
131201
|
-
recordKeyOrRecordName: request2.recordName,
|
|
131202
|
-
userId: request2.userId,
|
|
131203
|
-
instances: request2.instances
|
|
131204
|
-
};
|
|
131205
|
-
const context = await this._policies.constructAuthorizationContext(
|
|
131206
|
-
baseRequest
|
|
131207
|
-
);
|
|
131208
|
-
if (context.success === false) {
|
|
131209
|
-
return context;
|
|
131210
|
-
}
|
|
131211
|
-
const authorization = await this._policies.authorizeUserAndInstances(
|
|
131212
|
-
context.context,
|
|
131213
|
-
{
|
|
131214
|
-
userId: request2.userId,
|
|
131215
|
-
instances: request2.instances,
|
|
131216
|
-
resourceKind: this._resourceKind,
|
|
131217
|
-
action: "list",
|
|
131218
|
-
markers: [ACCOUNT_MARKER]
|
|
131219
|
-
}
|
|
131220
|
-
);
|
|
131221
|
-
if (authorization.success === false) {
|
|
131222
|
-
return authorization;
|
|
131223
|
-
}
|
|
131224
|
-
const result2 = await this._store.listItems(
|
|
131225
|
-
context.context.recordName,
|
|
131226
|
-
request2.startingAddress
|
|
131227
|
-
);
|
|
131228
|
-
return {
|
|
131229
|
-
success: true,
|
|
131230
|
-
recordName: context.context.recordName,
|
|
131231
|
-
items: result2.items.map(
|
|
131232
|
-
(item) => this._convertItemToResult(item, context.context)
|
|
131233
|
-
),
|
|
131234
|
-
totalCount: result2.totalCount
|
|
131235
|
-
};
|
|
131236
|
-
} catch (err) {
|
|
131237
|
-
const span = trace.getActiveSpan();
|
|
131238
|
-
span?.recordException(err);
|
|
131239
|
-
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
131240
|
-
console.error(`[${this._name}] Error listing items:`, err);
|
|
131241
|
-
return {
|
|
131242
|
-
success: false,
|
|
131243
|
-
errorCode: "server_error",
|
|
131244
|
-
errorMessage: "A server error occurred."
|
|
131245
|
-
};
|
|
131246
|
-
}
|
|
131247
|
-
}
|
|
131248
|
-
async listItemsByMarker(request2) {
|
|
131249
|
-
try {
|
|
131250
|
-
const baseRequest = {
|
|
131251
|
-
recordKeyOrRecordName: request2.recordName,
|
|
131252
|
-
userId: request2.userId,
|
|
131253
|
-
instances: request2.instances
|
|
131254
|
-
};
|
|
131255
|
-
const context = await this._policies.constructAuthorizationContext(
|
|
131256
|
-
baseRequest
|
|
131257
|
-
);
|
|
131258
|
-
if (context.success === false) {
|
|
131259
|
-
return context;
|
|
131260
|
-
}
|
|
131261
|
-
const authorization = await this._policies.authorizeUserAndInstances(
|
|
131262
|
-
context.context,
|
|
131263
|
-
{
|
|
131264
|
-
userId: request2.userId,
|
|
131265
|
-
instances: request2.instances,
|
|
131266
|
-
resourceKind: this._resourceKind,
|
|
131267
|
-
action: "list",
|
|
131268
|
-
markers: [request2.marker]
|
|
131269
|
-
}
|
|
131270
|
-
);
|
|
131271
|
-
if (authorization.success === false) {
|
|
131272
|
-
return authorization;
|
|
131273
|
-
}
|
|
131274
|
-
const result2 = await this._store.listItemsByMarker({
|
|
131275
|
-
recordName: context.context.recordName,
|
|
131276
|
-
startingAddress: request2.startingAddress,
|
|
131277
|
-
marker: request2.marker,
|
|
131278
|
-
sort: request2.sort
|
|
131279
|
-
});
|
|
131280
|
-
return {
|
|
131281
|
-
success: true,
|
|
131282
|
-
recordName: context.context.recordName,
|
|
131283
|
-
items: result2.items.map(
|
|
131284
|
-
(item) => this._convertItemToResult(item, context.context)
|
|
131285
|
-
),
|
|
131286
|
-
totalCount: result2.totalCount
|
|
131287
|
-
};
|
|
131288
|
-
} catch (err) {
|
|
131289
|
-
const span = trace.getActiveSpan();
|
|
131290
|
-
span?.recordException(err);
|
|
131291
|
-
span?.setStatus({ code: SpanStatusCode.ERROR });
|
|
131292
|
-
console.error(`[${this._name}] Error listing items:`, err);
|
|
131293
|
-
return {
|
|
131294
|
-
success: false,
|
|
131295
|
-
errorCode: "server_error",
|
|
131296
|
-
errorMessage: "A server error occurred."
|
|
131297
|
-
};
|
|
131298
|
-
}
|
|
131299
|
-
}
|
|
131300
|
-
/**
|
|
131301
|
-
* Converts the given item to a version that is able to be returned to clients.
|
|
131302
|
-
* Can be overriden to ensure that some fields are not returned.
|
|
131303
|
-
* @param item The item that should be converted.
|
|
131304
|
-
* @param context The authorization context.
|
|
131305
|
-
* @returns The converted item.
|
|
131306
|
-
*/
|
|
131307
|
-
_convertItemToResult(item, context) {
|
|
131308
|
-
return item;
|
|
131309
|
-
}
|
|
131310
|
-
/**
|
|
131311
|
-
* Transforms the given input item and returns the transformed item.
|
|
131312
|
-
* Useful for transforming items before they are stored.
|
|
131313
|
-
* @param item The item that should be transformed.
|
|
131314
|
-
*/
|
|
131315
|
-
_transformInputItem(item) {
|
|
131316
|
-
return item;
|
|
131317
|
-
}
|
|
131318
|
-
};
|
|
131319
|
-
__decorateClass([
|
|
131320
|
-
traced(TRACE_NAME19)
|
|
131321
|
-
], CrudRecordsController.prototype, "recordItem", 1);
|
|
131322
|
-
__decorateClass([
|
|
131323
|
-
traced(TRACE_NAME19)
|
|
131324
|
-
], CrudRecordsController.prototype, "getItem", 1);
|
|
131325
|
-
__decorateClass([
|
|
131326
|
-
traced(TRACE_NAME19)
|
|
131327
|
-
], CrudRecordsController.prototype, "eraseItem", 1);
|
|
131328
|
-
__decorateClass([
|
|
131329
|
-
traced(TRACE_NAME19)
|
|
131330
|
-
], CrudRecordsController.prototype, "listItems", 1);
|
|
131331
|
-
__decorateClass([
|
|
131332
|
-
traced(TRACE_NAME19)
|
|
131333
|
-
], CrudRecordsController.prototype, "listItemsByMarker", 1);
|
|
131334
|
-
|
|
131335
132605
|
// ../aux-records/webhooks/WebhookEnvironment.ts
|
|
131336
132606
|
var STORED_AUX_VERSION_1_SCHEMA = z.object({
|
|
131337
132607
|
version: z.literal(1),
|
|
@@ -131395,7 +132665,7 @@ var import_tweetnacl8 = __toESM(require_nacl_fast());
|
|
|
131395
132665
|
var import_base64_js14 = __toESM(require_base64_js());
|
|
131396
132666
|
|
|
131397
132667
|
// ../aux-records/webhooks/WebhookRecordsController.ts
|
|
131398
|
-
var
|
|
132668
|
+
var TRACE_NAME21 = "WebhookRecordsController";
|
|
131399
132669
|
var WebhookRecordsController = class extends CrudRecordsController {
|
|
131400
132670
|
constructor(config2) {
|
|
131401
132671
|
super({
|
|
@@ -131568,6 +132838,7 @@ var WebhookRecordsController = class extends CrudRecordsController {
|
|
|
131568
132838
|
errorMessage: "Invalid webhook target. The targeted record does not contain a valid AUX."
|
|
131569
132839
|
};
|
|
131570
132840
|
}
|
|
132841
|
+
let sessionUserId;
|
|
131571
132842
|
let sessionKey;
|
|
131572
132843
|
let connectionKey;
|
|
131573
132844
|
if (webhook.userId) {
|
|
@@ -131579,6 +132850,7 @@ var WebhookRecordsController = class extends CrudRecordsController {
|
|
|
131579
132850
|
lifetimeMs: checkMetrics.features.tokenLifetimeMs ?? 5 * 60 * 1e3
|
|
131580
132851
|
});
|
|
131581
132852
|
if (issueSessionResult.success === true) {
|
|
132853
|
+
sessionUserId = issueSessionResult.userId;
|
|
131582
132854
|
sessionKey = issueSessionResult.sessionKey;
|
|
131583
132855
|
connectionKey = issueSessionResult.connectionKey;
|
|
131584
132856
|
} else {
|
|
@@ -131599,6 +132871,8 @@ var WebhookRecordsController = class extends CrudRecordsController {
|
|
|
131599
132871
|
recordName: stateRecordName,
|
|
131600
132872
|
inst: stateInstName,
|
|
131601
132873
|
request: request2.request,
|
|
132874
|
+
requestUserId: request2.userId,
|
|
132875
|
+
sessionUserId,
|
|
131602
132876
|
sessionKey,
|
|
131603
132877
|
connectionKey,
|
|
131604
132878
|
options
|
|
@@ -131614,6 +132888,7 @@ var WebhookRecordsController = class extends CrudRecordsController {
|
|
|
131614
132888
|
runId,
|
|
131615
132889
|
version: 1,
|
|
131616
132890
|
request: request2.request,
|
|
132891
|
+
requestUserId: request2.userId,
|
|
131617
132892
|
response: result.success === true ? result.response : null,
|
|
131618
132893
|
logs: result.success === true ? result.logs : [],
|
|
131619
132894
|
state,
|
|
@@ -131890,23 +133165,20 @@ var WebhookRecordsController = class extends CrudRecordsController {
|
|
|
131890
133165
|
}
|
|
131891
133166
|
};
|
|
131892
133167
|
__decorateClass([
|
|
131893
|
-
traced(
|
|
133168
|
+
traced(TRACE_NAME21)
|
|
131894
133169
|
], WebhookRecordsController.prototype, "handleWebhook", 1);
|
|
131895
133170
|
__decorateClass([
|
|
131896
|
-
traced(
|
|
133171
|
+
traced(TRACE_NAME21)
|
|
131897
133172
|
], WebhookRecordsController.prototype, "listWebhookRuns", 1);
|
|
131898
133173
|
__decorateClass([
|
|
131899
|
-
traced(
|
|
133174
|
+
traced(TRACE_NAME21)
|
|
131900
133175
|
], WebhookRecordsController.prototype, "getWebhookRun", 1);
|
|
131901
133176
|
__decorateClass([
|
|
131902
|
-
traced(
|
|
133177
|
+
traced(TRACE_NAME21)
|
|
131903
133178
|
], WebhookRecordsController.prototype, "_checkSubscriptionMetrics", 1);
|
|
131904
133179
|
|
|
131905
|
-
// ../aux-records/crud/MemoryCrudRecordsStore.ts
|
|
131906
|
-
var import_lodash25 = __toESM(require_lodash());
|
|
131907
|
-
|
|
131908
133180
|
// ../aux-records/webhooks/MemoryWebhookRecordsStore.ts
|
|
131909
|
-
var
|
|
133181
|
+
var import_lodash27 = __toESM(require_lodash());
|
|
131910
133182
|
|
|
131911
133183
|
// cli.ts
|
|
131912
133184
|
var import_node_stream3 = require("node:stream");
|
|
@@ -132169,7 +133441,7 @@ function expand(template, context) {
|
|
|
132169
133441
|
return template.replace(/\/$/, "");
|
|
132170
133442
|
}
|
|
132171
133443
|
}
|
|
132172
|
-
function
|
|
133444
|
+
function parse3(options) {
|
|
132173
133445
|
let method = options.method.toUpperCase();
|
|
132174
133446
|
let url2 = (options.url || "/").replace(/:([a-z]\w+)/g, "{$1}");
|
|
132175
133447
|
let headers = Object.assign({}, options.headers);
|
|
@@ -132233,7 +133505,7 @@ function parse2(options) {
|
|
|
132233
133505
|
);
|
|
132234
133506
|
}
|
|
132235
133507
|
function endpointWithDefaults(defaults2, route, options) {
|
|
132236
|
-
return
|
|
133508
|
+
return parse3(merge5(defaults2, route, options));
|
|
132237
133509
|
}
|
|
132238
133510
|
function withDefaults(oldDefaults, newDefaults) {
|
|
132239
133511
|
const DEFAULTS2 = merge5(oldDefaults, newDefaults);
|
|
@@ -132242,7 +133514,7 @@ function withDefaults(oldDefaults, newDefaults) {
|
|
|
132242
133514
|
DEFAULTS: DEFAULTS2,
|
|
132243
133515
|
defaults: withDefaults.bind(null, DEFAULTS2),
|
|
132244
133516
|
merge: merge5.bind(null, DEFAULTS2),
|
|
132245
|
-
parse:
|
|
133517
|
+
parse: parse3
|
|
132246
133518
|
});
|
|
132247
133519
|
}
|
|
132248
133520
|
var endpoint = withDefaults(null, DEFAULTS);
|
|
@@ -136211,11 +137483,11 @@ __export(crypto_node_exports, {
|
|
|
136211
137483
|
convertPrivateKey: () => convertPrivateKey
|
|
136212
137484
|
});
|
|
136213
137485
|
__reExport(crypto_node_exports, require("node:crypto"));
|
|
136214
|
-
var
|
|
137486
|
+
var import_node_crypto14 = require("node:crypto");
|
|
136215
137487
|
function convertPrivateKey(privateKey) {
|
|
136216
137488
|
if (!isPkcs1(privateKey))
|
|
136217
137489
|
return privateKey;
|
|
136218
|
-
return (0,
|
|
137490
|
+
return (0, import_node_crypto14.createPrivateKey)(privateKey).export({
|
|
136219
137491
|
type: "pkcs8",
|
|
136220
137492
|
format: "pem"
|
|
136221
137493
|
});
|
|
@@ -138417,8 +139689,8 @@ var OAuthApp = class {
|
|
|
138417
139689
|
};
|
|
138418
139690
|
|
|
138419
139691
|
// ../../node_modules/.pnpm/@octokit+webhooks-methods@5.1.0/node_modules/@octokit/webhooks-methods/dist-node/index.js
|
|
138420
|
-
var import_node_crypto14 = require("node:crypto");
|
|
138421
139692
|
var import_node_crypto15 = require("node:crypto");
|
|
139693
|
+
var import_node_crypto16 = require("node:crypto");
|
|
138422
139694
|
var import_node_buffer3 = require("node:buffer");
|
|
138423
139695
|
var VERSION19 = "5.1.0";
|
|
138424
139696
|
async function sign3(secret, payload) {
|
|
@@ -138431,7 +139703,7 @@ async function sign3(secret, payload) {
|
|
|
138431
139703
|
throw new TypeError("[@octokit/webhooks-methods] payload must be a string");
|
|
138432
139704
|
}
|
|
138433
139705
|
const algorithm = "sha256";
|
|
138434
|
-
return `${algorithm}=${(0,
|
|
139706
|
+
return `${algorithm}=${(0, import_node_crypto15.createHmac)(algorithm, secret).update(payload).digest("hex")}`;
|
|
138435
139707
|
}
|
|
138436
139708
|
sign3.VERSION = VERSION19;
|
|
138437
139709
|
async function verify3(secret, eventPayload, signature) {
|
|
@@ -138450,7 +139722,7 @@ async function verify3(secret, eventPayload, signature) {
|
|
|
138450
139722
|
if (signatureBuffer.length !== verificationBuffer.length) {
|
|
138451
139723
|
return false;
|
|
138452
139724
|
}
|
|
138453
|
-
return (0,
|
|
139725
|
+
return (0, import_node_crypto16.timingSafeEqual)(signatureBuffer, verificationBuffer);
|
|
138454
139726
|
}
|
|
138455
139727
|
verify3.VERSION = VERSION19;
|
|
138456
139728
|
|
|
@@ -139706,7 +140978,7 @@ function parseStringResponse(result, parsers12, texts, trim2 = true) {
|
|
|
139706
140978
|
}
|
|
139707
140979
|
return lines[i2 + offset2];
|
|
139708
140980
|
};
|
|
139709
|
-
parsers12.some(({ parse:
|
|
140981
|
+
parsers12.some(({ parse: parse4 }) => parse4(line, result));
|
|
139710
140982
|
}
|
|
139711
140983
|
});
|
|
139712
140984
|
return result;
|
|
@@ -144036,7 +145308,7 @@ var config = new Conf({
|
|
|
144036
145308
|
projectName: "casualos-cli"
|
|
144037
145309
|
});
|
|
144038
145310
|
var program2 = new Command();
|
|
144039
|
-
program2.name("casualos").description("A CLI for CasualOS").version("v3.3.11
|
|
145311
|
+
program2.name("casualos").description("A CLI for CasualOS").version("v3.3.11").option(
|
|
144040
145312
|
"-e, --endpoint <url>",
|
|
144041
145313
|
"The endpoint to use for queries. Can be used to override the current endpoint."
|
|
144042
145314
|
);
|