@g3nomaly/core 0.1.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (77) hide show
  1. package/dist/config/config.d.ts +26 -0
  2. package/dist/config/config.d.ts.map +1 -0
  3. package/dist/config/config.js +67 -0
  4. package/dist/config/config.js.map +1 -0
  5. package/dist/config/index.d.ts +4 -0
  6. package/dist/config/index.d.ts.map +1 -0
  7. package/dist/config/index.js +3 -0
  8. package/dist/config/index.js.map +1 -0
  9. package/dist/config/types.d.ts +141 -0
  10. package/dist/config/types.d.ts.map +1 -0
  11. package/dist/config/types.js +66 -0
  12. package/dist/config/types.js.map +1 -0
  13. package/dist/hash/hash.d.ts +25 -0
  14. package/dist/hash/hash.d.ts.map +1 -0
  15. package/dist/hash/hash.js +44 -0
  16. package/dist/hash/hash.js.map +1 -0
  17. package/dist/hash/index.d.ts +2 -0
  18. package/dist/hash/index.d.ts.map +1 -0
  19. package/dist/hash/index.js +2 -0
  20. package/dist/hash/index.js.map +1 -0
  21. package/dist/index.d.ts +1 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +2 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/paths/index.d.ts +2 -0
  26. package/dist/paths/index.d.ts.map +1 -0
  27. package/dist/paths/index.js +3 -0
  28. package/dist/paths/index.js.map +1 -0
  29. package/dist/paths/paths.d.ts +9 -0
  30. package/dist/paths/paths.d.ts.map +1 -0
  31. package/dist/paths/paths.js +21 -0
  32. package/dist/paths/paths.js.map +1 -0
  33. package/dist/registry/index.d.ts +12 -0
  34. package/dist/registry/index.d.ts.map +1 -0
  35. package/dist/registry/index.js +12 -0
  36. package/dist/registry/index.js.map +1 -0
  37. package/dist/registry/registry.handlers.d.ts +9 -0
  38. package/dist/registry/registry.handlers.d.ts.map +1 -0
  39. package/dist/registry/registry.handlers.js +13 -0
  40. package/dist/registry/registry.handlers.js.map +1 -0
  41. package/dist/registry/registry.io.d.ts +22 -0
  42. package/dist/registry/registry.io.d.ts.map +1 -0
  43. package/dist/registry/registry.io.js +78 -0
  44. package/dist/registry/registry.io.js.map +1 -0
  45. package/dist/registry/registry.mutations.d.ts +12 -0
  46. package/dist/registry/registry.mutations.d.ts.map +1 -0
  47. package/dist/registry/registry.mutations.js +22 -0
  48. package/dist/registry/registry.mutations.js.map +1 -0
  49. package/dist/registry/registry.selectors.d.ts +27 -0
  50. package/dist/registry/registry.selectors.d.ts.map +1 -0
  51. package/dist/registry/registry.selectors.js +37 -0
  52. package/dist/registry/registry.selectors.js.map +1 -0
  53. package/dist/registry/registry.store.d.ts +34 -0
  54. package/dist/registry/registry.store.d.ts.map +1 -0
  55. package/dist/registry/registry.store.js +27 -0
  56. package/dist/registry/registry.store.js.map +1 -0
  57. package/dist/registry/registry.template.d.ts +23 -0
  58. package/dist/registry/registry.template.d.ts.map +1 -0
  59. package/dist/registry/registry.template.js +63 -0
  60. package/dist/registry/registry.template.js.map +1 -0
  61. package/dist/registry/types.d.ts +31 -0
  62. package/dist/registry/types.d.ts.map +1 -0
  63. package/dist/registry/types.js +20 -0
  64. package/dist/registry/types.js.map +1 -0
  65. package/dist/security/index.d.ts +2 -0
  66. package/dist/security/index.d.ts.map +1 -0
  67. package/dist/security/index.js +2 -0
  68. package/dist/security/index.js.map +1 -0
  69. package/dist/security/securityParser.d.ts +14 -0
  70. package/dist/security/securityParser.d.ts.map +1 -0
  71. package/dist/security/securityParser.js +88 -0
  72. package/dist/security/securityParser.js.map +1 -0
  73. package/dist/security/securityWorker.d.ts +8 -0
  74. package/dist/security/securityWorker.d.ts.map +1 -0
  75. package/dist/security/securityWorker.js +158 -0
  76. package/dist/security/securityWorker.js.map +1 -0
  77. package/package.json +64 -0
@@ -0,0 +1,78 @@
1
+ import { writeFileSync, readFileSync } from "node:fs";
2
+ import { tsHandler } from "./registry.handlers";
3
+ // ---------------------------------------------------------------------------
4
+ // Helpers
5
+ // ---------------------------------------------------------------------------
6
+ function resolveHandler(registry, override) {
7
+ return override ?? registry.handler ?? tsHandler;
8
+ }
9
+ function sortedEntries(registry) {
10
+ return Object.fromEntries(Object.entries(registry.store.state).sort(([a], [b]) => a.localeCompare(b)));
11
+ }
12
+ // ---------------------------------------------------------------------------
13
+ // loadFrom (file → store)
14
+ // ---------------------------------------------------------------------------
15
+ /**
16
+ * name alias for load() when you want to specify an explicit filePath. Otherwise identical behavior.
17
+ */
18
+ export async function loadFrom(registry, filePath) {
19
+ return load(registry, filePath);
20
+ }
21
+ // ---------------------------------------------------------------------------
22
+ // load (file → store)
23
+ //
24
+ // Hydrates the store from its bound filePath.
25
+ // - .ts files: uses dynamic import (handler is not called — TS files export
26
+ // a `registry` object directly at runtime via Bun/tsx)
27
+ // - other files: uses readFileSync + handler.deserialize
28
+ //
29
+ // No-op if the store has no filePath or the file does not exist yet.
30
+ // ---------------------------------------------------------------------------
31
+ export async function load(registry, filePath) {
32
+ const target = filePath ?? registry.filePath;
33
+ if (!target)
34
+ return;
35
+ try {
36
+ if (target.endsWith(".ts")) {
37
+ const mod = (await import(`file://${target}`));
38
+ registry.store.setState(() => ({ ...mod.registry }));
39
+ }
40
+ else {
41
+ const h = resolveHandler(registry);
42
+ const raw = readFileSync(target, "utf-8");
43
+ registry.store.setState(() => ({ ...h.deserialize(raw) }));
44
+ }
45
+ }
46
+ catch {
47
+ // File doesn't exist yet — store stays empty
48
+ }
49
+ }
50
+ // ---------------------------------------------------------------------------
51
+ // flush (store → bound filePath)
52
+ // ---------------------------------------------------------------------------
53
+ /**
54
+ * Flushes the store to its already-bound filePath.
55
+ * Sorts entries alphabetically for deterministic output.
56
+ *
57
+ * @throws If the store has no bound filePath.
58
+ */
59
+ export function flush(registry, handler) {
60
+ if (!registry.filePath) {
61
+ throw new Error("flush() requires a bound filePath. Use createRegistryStore({ filePath }) to bind one.");
62
+ }
63
+ const h = resolveHandler(registry, handler);
64
+ writeFileSync(registry.filePath, h.serialize(sortedEntries(registry)), "utf-8");
65
+ }
66
+ // ---------------------------------------------------------------------------
67
+ // writeTo (store → explicit path)
68
+ // ---------------------------------------------------------------------------
69
+ /**
70
+ * Writes the store to an explicit path.
71
+ * Sorts entries alphabetically for deterministic output.
72
+ * Does not affect the store's bound filePath.
73
+ */
74
+ export function writeTo(registry, filePath, handler) {
75
+ const h = resolveHandler(registry, handler);
76
+ writeFileSync(filePath, h.serialize(sortedEntries(registry)), "utf-8");
77
+ }
78
+ //# sourceMappingURL=registry.io.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.io.js","sourceRoot":"","sources":["../../src/registry/registry.io.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,YAAY,EAAE,MAAM,SAAS,CAAA;AAIrD,OAAO,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAA;AAE/C,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E,SAAS,cAAc,CACrB,QAA0B,EAC1B,QAA6B;IAE7B,OAAO,QAAQ,IAAI,QAAQ,CAAC,OAAO,IAAI,SAAS,CAAA;AAClD,CAAC;AAED,SAAS,aAAa,CAA8B,QAA0B;IAC5E,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,aAAa,CAAC,CAAC,CAAC,CAAC,CAC5E,CAAA;AACH,CAAC;AAED,8EAA8E;AAC9E,0BAA0B;AAC1B,8EAA8E;AAE9E;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,QAAQ,CAC5B,QAA0B,EAC1B,QAAgB;IAEhB,OAAO,IAAI,CAAC,QAAQ,EAAE,QAAQ,CAAC,CAAC;AAClC,CAAC;AAED,8EAA8E;AAC9E,sBAAsB;AACtB,EAAE;AACF,8CAA8C;AAC9C,6EAA6E;AAC7E,qEAAqE;AACrE,yDAAyD;AACzD,E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,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;AACjF,CAAC;AAED,8EAA8E;AAC9E,kCAAkC;AAClC,8EAA8E;AAE9E;;;;GAIG;AACH,MAAM,UAAU,OAAO,CACrB,QAA0B,EAC1B,QAAgB,EAChB,OAA4B;IAE5B,MAAM,CAAC,GAAG,cAAc,CAAC,QAAQ,EAAE,OAAO,CAAC,CAAA;IAC3C,aAAa,CAAC,QAAQ,EAAE,CAAC,CAAC,SAAS,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC,EAAE,OAAO,CAAC,CAAA;AACxE,CAAC"}
@@ -0,0 +1,12 @@
1
+ import type { BaseRegistryEntry } from "./types";
2
+ import type { RegistryStore } from "./registry.store";
3
+ /**
4
+ * Register or overwrite an entry in the store.
5
+ */
6
+ export declare function register<T extends BaseRegistryEntry>(registry: RegistryStore<T>, key: string, entry: T): void;
7
+ /**
8
+ * Remove an entry from the store.
9
+ * Returns true if the entry existed, false if it was already absent.
10
+ */
11
+ export declare function unregister<T extends BaseRegistryEntry>(registry: RegistryStore<T>, key: string): boolean;
12
+ //# sourceMappingURL=registry.mutations.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.mutations.d.ts","sourceRoot":"","sources":["../../src/registry/registry.mutations.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAChD,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD;;GAEG;AACH,wBAAgB,QAAQ,CAAC,CAAC,SAAS,iBAAiB,EAClD,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,CAAC,GACP,IAAI,CAEN;AAED;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,iBAAiB,EACpD,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,GAAG,EAAE,MAAM,GACV,OAAO,CAYT"}
@@ -0,0 +1,22 @@
1
+ /**
2
+ * Register or overwrite an entry in the store.
3
+ */
4
+ export function register(registry, key, entry) {
5
+ registry.store.setState((s) => ({ ...s, [key]: entry }));
6
+ }
7
+ /**
8
+ * Remove an entry from the store.
9
+ * Returns true if the entry existed, false if it was already absent.
10
+ */
11
+ export function unregister(registry, key) {
12
+ const existed = key in registry.store.state;
13
+ if (existed) {
14
+ registry.store.setState((s) => {
15
+ const next = { ...s };
16
+ delete next[key];
17
+ return next;
18
+ });
19
+ }
20
+ return existed;
21
+ }
22
+ //# sourceMappingURL=registry.mutations.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.mutations.js","sourceRoot":"","sources":["../../src/registry/registry.mutations.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,UAAU,QAAQ,CACtB,QAA0B,EAC1B,GAAW,EACX,KAAQ;IAER,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,EAAE,GAAG,CAAC,EAAE,CAAC,GAAG,CAAC,EAAE,KAAK,EAAE,CAAC,CAAC,CAAA;AAC1D,CAAC;AAED;;;GAGG;AACH,MAAM,UAAU,UAAU,CACxB,QAA0B,EAC1B,GAAW;IAEX,MAAM,OAAO,GAAG,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAA;IAE3C,IAAI,OAAO,EAAE,CAAC;QACZ,QAAQ,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAC,EAAE,EAAE;YAC5B,MAAM,IAAI,GAAG,EAAE,GAAG,CAAC,EAAE,CAAA;YACrB,OAAO,IAAI,CAAC,GAAG,CAAC,CAAA;YAChB,OAAO,IAAI,CAAA;QACb,CAAC,CAAC,CAAA;IACJ,CAAC;IAED,OAAO,OAAO,CAAA;AAChB,CAAC"}
@@ -0,0 +1,27 @@
1
+ import type { BaseRegistry, BaseRegistryEntry } from "./types";
2
+ import type { RegistryStore } from "./registry.store";
3
+ /**
4
+ * Get a single entry by key. Returns undefined if not found.
5
+ */
6
+ export declare function get<T extends BaseRegistryEntry>(registry: RegistryStore<T>, key: string): T | undefined;
7
+ /**
8
+ * Check whether a key exists in the store.
9
+ */
10
+ export declare function has<T extends BaseRegistryEntry>(registry: RegistryStore<T>, key: string): boolean;
11
+ /**
12
+ * Return all entries as a plain record.
13
+ */
14
+ export declare function entries<T extends BaseRegistryEntry>(registry: RegistryStore<T>): BaseRegistry<T>;
15
+ /**
16
+ * Return all registered keys.
17
+ */
18
+ export declare function keys<T extends BaseRegistryEntry>(registry: RegistryStore<T>): string[];
19
+ /**
20
+ * Return all entries that match a given version string.
21
+ */
22
+ export declare function getByVersion<T extends BaseRegistryEntry>(registry: RegistryStore<T>, version: string): BaseRegistry<T>;
23
+ /**
24
+ * Return the count of registered entries.
25
+ */
26
+ export declare function size<T extends BaseRegistryEntry>(registry: RegistryStore<T>): number;
27
+ //# sourceMappingURL=registry.selectors.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.selectors.d.ts","sourceRoot":"","sources":["../../src/registry/registry.selectors.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC9D,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAA;AAErD;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,iBAAiB,EAC7C,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,GAAG,EAAE,MAAM,GACV,CAAC,GAAG,SAAS,CAEf;AAED;;GAEG;AACH,wBAAgB,GAAG,CAAC,CAAC,SAAS,iBAAiB,EAC7C,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,GAAG,EAAE,MAAM,GACV,OAAO,CAET;AAED;;GAEG;AACH,wBAAgB,OAAO,CAAC,CAAC,SAAS,iBAAiB,EACjD,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,GACzB,YAAY,CAAC,CAAC,CAAC,CAEjB;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,iBAAiB,EAC9C,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,GACzB,MAAM,EAAE,CAEV;AAED;;GAEG;AACH,wBAAgB,YAAY,CAAC,CAAC,SAAS,iBAAiB,EACtD,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,OAAO,EAAE,MAAM,GACd,YAAY,CAAC,CAAC,CAAC,CAIjB;AAED;;GAEG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,iBAAiB,EAC9C,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,GACzB,MAAM,CAER"}
@@ -0,0 +1,37 @@
1
+ /**
2
+ * Get a single entry by key. Returns undefined if not found.
3
+ */
4
+ export function get(registry, key) {
5
+ return registry.store.state[key];
6
+ }
7
+ /**
8
+ * Check whether a key exists in the store.
9
+ */
10
+ export function has(registry, key) {
11
+ return key in registry.store.state;
12
+ }
13
+ /**
14
+ * Return all entries as a plain record.
15
+ */
16
+ export function entries(registry) {
17
+ return registry.store.state;
18
+ }
19
+ /**
20
+ * Return all registered keys.
21
+ */
22
+ export function keys(registry) {
23
+ return Object.keys(registry.store.state);
24
+ }
25
+ /**
26
+ * Return all entries that match a given version string.
27
+ */
28
+ export function getByVersion(registry, version) {
29
+ return Object.fromEntries(Object.entries(registry.store.state).filter(([, entry]) => entry.version === version));
30
+ }
31
+ /**
32
+ * Return the count of registered entries.
33
+ */
34
+ export function size(registry) {
35
+ return Object.keys(registry.store.state).length;
36
+ }
37
+ //# sourceMappingURL=registry.selectors.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.selectors.js","sourceRoot":"","sources":["../../src/registry/registry.selectors.ts"],"names":[],"mappings":"AAGA;;GAEG;AACH,MAAM,UAAU,GAAG,CACjB,QAA0B,EAC1B,GAAW;IAEX,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAA;AAClC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,GAAG,CACjB,QAA0B,EAC1B,GAAW;IAEX,OAAO,GAAG,IAAI,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAA;AACpC,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,OAAO,CACrB,QAA0B;IAE1B,OAAO,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAA;AAC7B,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,IAAI,CAClB,QAA0B;IAE1B,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAA;AAC1C,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,YAAY,CAC1B,QAA0B,EAC1B,OAAe;IAEf,OAAO,MAAM,CAAC,WAAW,CACvB,MAAM,CAAC,OAAO,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,KAAK,CAAC,EAAE,EAAE,CAAC,KAAK,CAAC,OAAO,KAAK,OAAO,CAAC,CACtF,CAAA;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,IAAI,CAClB,QAA0B;IAE1B,OAAO,MAAM,CAAC,IAAI,CAAC,QAAQ,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,MAAM,CAAA;AACjD,CAAC"}
@@ -0,0 +1,34 @@
1
+ import { Store } from "@tanstack/store";
2
+ import type { BaseRegistry, BaseRegistryEntry } from "./types";
3
+ import type { RegistryHandler } from "./registry.handlers";
4
+ export interface RegistryStoreOptions<T extends BaseRegistryEntry = BaseRegistryEntry> {
5
+ /** Absolute path to the manifest file. Used by load() and flush(). */
6
+ filePath?: string;
7
+ /** Default handler for serialization/deserialization. Defaults to tsHandler. */
8
+ handler?: RegistryHandler<T>;
9
+ }
10
+ /**
11
+ * The registry store instance — passed to mutations, selectors, and io helpers.
12
+ */
13
+ export interface RegistryStore<T extends BaseRegistryEntry = BaseRegistryEntry> {
14
+ /** The underlying TanStack Store. Subscribe, derive, or read .state directly. */
15
+ store: Store<BaseRegistry<T>>;
16
+ /** Absolute path this store is bound to (if any). */
17
+ filePath?: string;
18
+ /** Default handler for serialization/deserialization. */
19
+ handler?: RegistryHandler<T>;
20
+ }
21
+ /**
22
+ * Creates a RegistryStore backed by TanStack Store.
23
+ * State starts empty — call load() to hydrate from disk.
24
+ *
25
+ * @example
26
+ * const registry = createRegistryStore<MyEntry>({ filePath: "/abs/.g3nerate-manifest.ts" })
27
+ * await load(registry)
28
+ */
29
+ export declare function createRegistryStore<T extends BaseRegistryEntry = BaseRegistryEntry>(options?: RegistryStoreOptions<T>): RegistryStore<T>;
30
+ /**
31
+ * Sets the default handler on the store. Returns the store for chaining.
32
+ */
33
+ export declare function useHandler<T extends BaseRegistryEntry>(registry: RegistryStore<T>, handler: RegistryHandler<T>): RegistryStore<T>;
34
+ //# sourceMappingURL=registry.store.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.store.d.ts","sourceRoot":"","sources":["../../src/registry/registry.store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AACvC,OAAO,KAAK,EAAE,YAAY,EAAE,iBAAiB,EAAE,MAAM,SAAS,CAAA;AAC9D,OAAO,KAAK,EAAE,eAAe,EAAE,MAAM,qBAAqB,CAAA;AAM1D,MAAM,WAAW,oBAAoB,CAAC,CAAC,SAAS,iBAAiB,GAAG,iBAAiB;IACnF,sEAAsE;IACtE,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,gFAAgF;IAChF,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAA;CAC7B;AAED;;GAEG;AACH,MAAM,WAAW,aAAa,CAAC,CAAC,SAAS,iBAAiB,GAAG,iBAAiB;IAC5E,iFAAiF;IACjF,KAAK,EAAE,KAAK,CAAC,YAAY,CAAC,CAAC,CAAC,CAAC,CAAA;IAC7B,qDAAqD;IACrD,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,yDAAyD;IACzD,OAAO,CAAC,EAAE,eAAe,CAAC,CAAC,CAAC,CAAA;CAC7B;AAMD;;;;;;;GAOG;AACH,wBAAgB,mBAAmB,CAAC,CAAC,SAAS,iBAAiB,GAAG,iBAAiB,EACjF,OAAO,GAAE,oBAAoB,CAAC,CAAC,CAAM,GACpC,aAAa,CAAC,CAAC,CAAC,CAMlB;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,CAAC,SAAS,iBAAiB,EACpD,QAAQ,EAAE,aAAa,CAAC,CAAC,CAAC,EAC1B,OAAO,EAAE,eAAe,CAAC,CAAC,CAAC,GAC1B,aAAa,CAAC,CAAC,CAAC,CAGlB"}
@@ -0,0 +1,27 @@
1
+ import { Store } from "@tanstack/store";
2
+ // ---------------------------------------------------------------------------
3
+ // Factory
4
+ // ---------------------------------------------------------------------------
5
+ /**
6
+ * Creates a RegistryStore backed by TanStack Store.
7
+ * State starts empty — call load() to hydrate from disk.
8
+ *
9
+ * @example
10
+ * const registry = createRegistryStore<MyEntry>({ filePath: "/abs/.g3nerate-manifest.ts" })
11
+ * await load(registry)
12
+ */
13
+ export function createRegistryStore(options = {}) {
14
+ return {
15
+ store: new Store({}),
16
+ filePath: options.filePath,
17
+ handler: options.handler,
18
+ };
19
+ }
20
+ /**
21
+ * Sets the default handler on the store. Returns the store for chaining.
22
+ */
23
+ export function useHandler(registry, handler) {
24
+ registry.handler = handler;
25
+ return registry;
26
+ }
27
+ //# sourceMappingURL=registry.store.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.store.js","sourceRoot":"","sources":["../../src/registry/registry.store.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,KAAK,EAAE,MAAM,iBAAiB,CAAA;AA2BvC,8EAA8E;AAC9E,UAAU;AACV,8EAA8E;AAE9E;;;;;;;GAOG;AACH,MAAM,UAAU,mBAAmB,CACjC,UAAmC,EAAE;IAErC,OAAO;QACL,KAAK,EAAE,IAAI,KAAK,CAAkB,EAAE,CAAC;QACrC,QAAQ,EAAE,OAAO,CAAC,QAAQ;QAC1B,OAAO,EAAE,OAAO,CAAC,OAAO;KACzB,CAAA;AACH,CAAC;AAED;;GAEG;AACH,MAAM,UAAU,UAAU,CACxB,QAA0B,EAC1B,OAA2B;IAE3B,QAAQ,CAAC,OAAO,GAAG,OAAO,CAAA;IAC1B,OAAO,QAAQ,CAAA;AACjB,CAAC"}
@@ -0,0 +1,23 @@
1
+ /**
2
+ * Recursively serializes a value to a TypeScript object literal string.
3
+ * Used by generateRegistryFile to produce human-readable .ts output.
4
+ */
5
+ export declare function stringifyValue(value: unknown, depth?: number): string;
6
+ /**
7
+ * Generates the full content of a typed .ts registry manifest file.
8
+ *
9
+ * @param entries - The registry entries to serialize
10
+ * @param typeName - TypeScript type name for the `satisfies` clause
11
+ * @param importFrom - Package to import the type from
12
+ *
13
+ * @example
14
+ * generateRegistryFile(entries, "G3nerateRegistry", "@g3nomaly/g3nerate")
15
+ * // →
16
+ * // import type { G3nerateRegistry } from "@g3nomaly/g3nerate"
17
+ * //
18
+ * // export const registry = {
19
+ * // "my-schema": { ... },
20
+ * // } as const satisfies G3nerateRegistry
21
+ */
22
+ export declare function generateRegistryFile(entries: Record<string, unknown>, typeName: string, importFrom: string): string;
23
+ //# sourceMappingURL=registry.template.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.template.d.ts","sourceRoot":"","sources":["../../src/registry/registry.template.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,wBAAgB,cAAc,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAAI,GAAG,MAAM,CA2BhE;AAED;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,oBAAoB,CAClC,OAAO,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,EAChC,QAAQ,EAAE,MAAM,EAChB,UAAU,EAAE,MAAM,GACjB,MAAM,CAeR"}
@@ -0,0 +1,63 @@
1
+ /**
2
+ * Recursively serializes a value to a TypeScript object literal string.
3
+ * Used by generateRegistryFile to produce human-readable .ts output.
4
+ */
5
+ export function stringifyValue(value, depth = 0) {
6
+ const indent = " ".repeat(depth);
7
+ const innerIndent = " ".repeat(depth + 1);
8
+ if (value === null)
9
+ return "null";
10
+ if (value === undefined)
11
+ return "undefined";
12
+ if (typeof value === "string")
13
+ return JSON.stringify(value);
14
+ if (typeof value === "number" || typeof value === "boolean")
15
+ return String(value);
16
+ if (Array.isArray(value)) {
17
+ if (value.length === 0)
18
+ return "[]";
19
+ const items = value
20
+ .map((v) => `${innerIndent}${stringifyValue(v, depth + 1)}`)
21
+ .join(",\n");
22
+ return `[\n${items},\n${indent}]`;
23
+ }
24
+ if (typeof value === "object") {
25
+ const entries = Object.entries(value);
26
+ if (entries.length === 0)
27
+ return "{}";
28
+ const lines = entries
29
+ .map(([k, v]) => `${innerIndent}${JSON.stringify(k)}: ${stringifyValue(v, depth + 1)}`)
30
+ .join(",\n");
31
+ return `{\n${lines},\n${indent}}`;
32
+ }
33
+ return String(value);
34
+ }
35
+ /**
36
+ * Generates the full content of a typed .ts registry manifest file.
37
+ *
38
+ * @param entries - The registry entries to serialize
39
+ * @param typeName - TypeScript type name for the `satisfies` clause
40
+ * @param importFrom - Package to import the type from
41
+ *
42
+ * @example
43
+ * generateRegistryFile(entries, "G3nerateRegistry", "@g3nomaly/g3nerate")
44
+ * // →
45
+ * // import type { G3nerateRegistry } from "@g3nomaly/g3nerate"
46
+ * //
47
+ * // export const registry = {
48
+ * // "my-schema": { ... },
49
+ * // } as const satisfies G3nerateRegistry
50
+ */
51
+ export function generateRegistryFile(entries, typeName, importFrom) {
52
+ const lines = [];
53
+ lines.push(`import type { ${typeName} } from "${importFrom}"`);
54
+ lines.push("");
55
+ lines.push("export const registry = {");
56
+ for (const [key, value] of Object.entries(entries)) {
57
+ lines.push(` ${JSON.stringify(key)}: ${stringifyValue(value, 1)},`);
58
+ }
59
+ lines.push(`} as const satisfies ${typeName}`);
60
+ lines.push("");
61
+ return lines.join("\n");
62
+ }
63
+ //# sourceMappingURL=registry.template.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"registry.template.js","sourceRoot":"","sources":["../../src/registry/registry.template.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,UAAU,cAAc,CAAC,KAAc,EAAE,KAAK,GAAG,CAAC;IACtD,MAAM,MAAM,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,CAAC,CAAA;IACjC,MAAM,WAAW,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,GAAG,CAAC,CAAC,CAAA;IAE1C,IAAI,KAAK,KAAK,IAAI;QAAE,OAAO,MAAM,CAAA;IACjC,IAAI,KAAK,KAAK,SAAS;QAAE,OAAO,WAAW,CAAA;IAC3C,IAAI,OAAO,KAAK,KAAK,QAAQ;QAAE,OAAO,IAAI,CAAC,SAAS,CAAC,KAAK,CAAC,CAAA;IAC3D,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,OAAO,KAAK,KAAK,SAAS;QAAE,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;IAEjF,IAAI,KAAK,CAAC,OAAO,CAAC,KAAK,CAAC,EAAE,CAAC;QACzB,IAAI,KAAK,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAA;QACnC,MAAM,KAAK,GAAG,KAAK;aAChB,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,WAAW,GAAG,cAAc,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;aAC3D,IAAI,CAAC,KAAK,CAAC,CAAA;QACd,OAAO,MAAM,KAAK,MAAM,MAAM,GAAG,CAAA;IACnC,CAAC;IAED,IAAI,OAAO,KAAK,KAAK,QAAQ,EAAE,CAAC;QAC9B,MAAM,OAAO,GAAG,MAAM,CAAC,OAAO,CAAC,KAAgC,CAAC,CAAA;QAChE,IAAI,OAAO,CAAC,MAAM,KAAK,CAAC;YAAE,OAAO,IAAI,CAAA;QACrC,MAAM,KAAK,GAAG,OAAO;aAClB,GAAG,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,EAAE,EAAE,CAAC,GAAG,WAAW,GAAG,IAAI,CAAC,SAAS,CAAC,CAAC,CAAC,KAAK,cAAc,CAAC,CAAC,EAAE,KAAK,GAAG,CAAC,CAAC,EAAE,CAAC;aACtF,IAAI,CAAC,KAAK,CAAC,CAAA;QACd,OAAO,MAAM,KAAK,MAAM,MAAM,GAAG,CAAA;IACnC,CAAC;IAED,OAAO,MAAM,CAAC,KAAK,CAAC,CAAA;AACtB,CAAC;AAED;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,oBAAoB,CAClC,OAAgC,EAChC,QAAgB,EAChB,UAAkB;IAElB,MAAM,KAAK,GAAa,EAAE,CAAA;IAE1B,KAAK,CAAC,IAAI,CAAC,iBAAiB,QAAQ,YAAY,UAAU,GAAG,CAAC,CAAA;IAC9D,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IACd,KAAK,CAAC,IAAI,CAAC,2BAA2B,CAAC,CAAA;IAEvC,KAAK,MAAM,CAAC,GAAG,EAAE,KAAK,CAAC,IAAI,MAAM,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE,CAAC;QACnD,KAAK,CAAC,IAAI,CAAC,KAAK,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,KAAK,cAAc,CAAC,KAAK,EAAE,CAAC,CAAC,GAAG,CAAC,CAAA;IACtE,CAAC;IAED,KAAK,CAAC,IAAI,CAAC,wBAAwB,QAAQ,EAAE,CAAC,CAAA;IAC9C,KAAK,CAAC,IAAI,CAAC,EAAE,CAAC,CAAA;IAEd,OAAO,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;AACzB,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Base file entry — extended by each package with their own `type` enum.
4
+ */
5
+ export declare const BaseFileEntrySchema: z.ZodObject<{
6
+ path: z.ZodString;
7
+ type: z.ZodString;
8
+ hash: z.ZodOptional<z.ZodString>;
9
+ version: z.ZodOptional<z.ZodString>;
10
+ }, z.core.$strip>;
11
+ export type BaseFileEntry = z.infer<typeof BaseFileEntrySchema>;
12
+ /**
13
+ * Base registry entry — extended by each package with their own fields.
14
+ */
15
+ export declare const BaseRegistryEntrySchema: z.ZodObject<{
16
+ name: z.ZodString;
17
+ description: z.ZodOptional<z.ZodString>;
18
+ version: z.ZodOptional<z.ZodString>;
19
+ files: z.ZodArray<z.ZodObject<{
20
+ path: z.ZodString;
21
+ type: z.ZodString;
22
+ hash: z.ZodOptional<z.ZodString>;
23
+ version: z.ZodOptional<z.ZodString>;
24
+ }, z.core.$strip>>;
25
+ }, z.core.$strip>;
26
+ export type BaseRegistryEntry = z.infer<typeof BaseRegistryEntrySchema>;
27
+ /**
28
+ * Generic registry map — key → entry.
29
+ */
30
+ export type BaseRegistry<T extends BaseRegistryEntry = BaseRegistryEntry> = Record<string, T>;
31
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../src/registry/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;GAEG;AACH,eAAO,MAAM,mBAAmB;;;;;iBAK9B,CAAA;AAEF,MAAM,MAAM,aAAa,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,mBAAmB,CAAC,CAAA;AAE/D;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;iBAKlC,CAAA;AAEF,MAAM,MAAM,iBAAiB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,uBAAuB,CAAC,CAAA;AAEvE;;GAEG;AACH,MAAM,MAAM,YAAY,CAAC,CAAC,SAAS,iBAAiB,GAAG,iBAAiB,IAAI,MAAM,CAAC,MAAM,EAAE,CAAC,CAAC,CAAA"}
@@ -0,0 +1,20 @@
1
+ import { z } from "zod";
2
+ /**
3
+ * Base file entry — extended by each package with their own `type` enum.
4
+ */
5
+ export const BaseFileEntrySchema = z.object({
6
+ path: z.string().min(1),
7
+ type: z.string(),
8
+ hash: z.string().min(1).optional(), // populated at build/install time, absent in unbuilt source meta files
9
+ version: z.string().min(1).optional(), // populated at build/install time, absent in unbuilt source meta files
10
+ });
11
+ /**
12
+ * Base registry entry — extended by each package with their own fields.
13
+ */
14
+ export const BaseRegistryEntrySchema = z.object({
15
+ name: z.string().min(1),
16
+ description: z.string().optional(),
17
+ version: z.string().optional(),
18
+ files: z.array(BaseFileEntrySchema).min(1),
19
+ });
20
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../../src/registry/types.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAA;AAEvB;;GAEG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC1C,IAAI,EAAK,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IAC1B,IAAI,EAAK,CAAC,CAAC,MAAM,EAAE;IACnB,IAAI,EAAK,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,uEAAuE;IAC9G,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,QAAQ,EAAE,EAAE,uEAAuE;CAC/G,CAAC,CAAA;AAIF;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,IAAI,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,GAAG,CAAC,CAAC,CAAC;IACvB,WAAW,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAClC,OAAO,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC9B,KAAK,EAAE,CAAC,CAAC,KAAK,CAAC,mBAAmB,CAAC,CAAC,GAAG,CAAC,CAAC,CAAC;CAC3C,CAAC,CAAA"}
@@ -0,0 +1,2 @@
1
+ export { getSafeObject } from "./securityParser";
2
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/security/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,2 @@
1
+ export { getSafeObject } from "./securityParser";
2
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/security/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,aAAa,EAAE,MAAM,kBAAkB,CAAC"}
@@ -0,0 +1,14 @@
1
+ import type { ZodType, z } from "zod";
2
+ /**
3
+ * Safely parses a TypeScript file that has a default export object literal.
4
+ * Transpiles the file, extracts the object literal via regex, evaluates it
5
+ * inside a sandboxed Worker with a timeout, then validates with the provided
6
+ * Zod schema.
7
+ *
8
+ * @param filePath - Absolute path to the .ts file to parse
9
+ * @param schema - Zod schema to validate the extracted object against
10
+ * @param timeoutMs - Worker timeout in milliseconds (default: 1000)
11
+ * @returns Validated, typed object
12
+ */
13
+ export declare function getSafeObject<TSchema extends ZodType>(filePath: string, schema: TSchema, timeoutMs?: number): Promise<z.infer<TSchema>>;
14
+ //# sourceMappingURL=securityParser.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"securityParser.d.ts","sourceRoot":"","sources":["../../src/security/securityParser.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAEtC;;;;;;;;;;GAUG;AACH,wBAAsB,aAAa,CAAC,OAAO,SAAS,OAAO,EACzD,QAAQ,EAAE,MAAM,EAChB,MAAM,EAAE,OAAO,EACf,SAAS,SAAO,GACf,OAAO,CAAC,CAAC,CAAC,KAAK,CAAC,OAAO,CAAC,CAAC,CAiG3B"}
@@ -0,0 +1,88 @@
1
+ import { resolve } from "path";
2
+ import { Transpiler } from "bun";
3
+ /**
4
+ * Safely parses a TypeScript file that has a default export object literal.
5
+ * Transpiles the file, extracts the object literal via regex, evaluates it
6
+ * inside a sandboxed Worker with a timeout, then validates with the provided
7
+ * Zod schema.
8
+ *
9
+ * @param filePath - Absolute path to the .ts file to parse
10
+ * @param schema - Zod schema to validate the extracted object against
11
+ * @param timeoutMs - Worker timeout in milliseconds (default: 1000)
12
+ * @returns Validated, typed object
13
+ */
14
+ export async function getSafeObject(filePath, schema, timeoutMs = 1000) {
15
+ const file = Bun.file(filePath);
16
+ const rawContent = await file.text();
17
+ const transpiler = new Transpiler({ loader: "ts" });
18
+ const jsCode = transpiler.transformSync(rawContent);
19
+ // ---------------------------------------------------------------------------
20
+ // Pre-eval static analysis
21
+ // Catches attacks that are undetectable at runtime because they complete
22
+ // successfully before the sanitiser sees any output.
23
+ // ---------------------------------------------------------------------------
24
+ const DANGEROUS_PATTERNS = [
25
+ [/\bimport\s*\(/, "dynamic import()"],
26
+ [/\bimport\.meta\b/, "import.meta"],
27
+ [/\bnew\s+Worker\b/, "Worker construction"],
28
+ [/\beval\s*\(/, "eval()"],
29
+ [/\.constructor\s*\.\s*constructor/, "constructor.constructor chain"],
30
+ // deep-object.meta.ts: IIFE builds 100k nested object literals in a loop.
31
+ // Object literal construction bypasses any runtime stub (the Object()
32
+ // constructor is not called for `{}`), so the only reliable catch is
33
+ // source-level: reject any for/while loop that contains an object literal.
34
+ // Pattern: a for(...) or while(...) body that contains `{` (object/block).
35
+ [/\bfor\s*\([\s\S]{0,200}?\)\s*\{[\s\S]{0,500}?\bnested\b/,
36
+ "deep object construction loop"],
37
+ // Broader: any loop body that reassigns via `= {` (obj = { ... })
38
+ [/\bfor\s*\([^)]*\)[^{]*\{[^}]*=\s*\{/,
39
+ "object-building loop"],
40
+ [/\bwhile\s*\([^)]*\)[^{]*\{[^}]*=\s*\{/,
41
+ "object-building loop"],
42
+ // regex-bomb.meta.ts: uses a regex *literal* /(a+)+$/ — the RegExp constructor
43
+ // stub in the worker never fires for literals. Detect nested quantifiers
44
+ // statically: pattern (x+)+ or (x*)* or (x+)* are canonical ReDoS forms.
45
+ [/\/[^/]*\([^)]*[+*]\)[+*]/, "catastrophic regex literal (nested quantifier)"],
46
+ ];
47
+ for (const [pattern, label] of DANGEROUS_PATTERNS) {
48
+ if (pattern.test(jsCode)) {
49
+ throw new Error(`Static analysis blocked [${label}] in: ${filePath}`);
50
+ }
51
+ }
52
+ const match = jsCode.match(/(?:export default|const \w+ =)\s*(\{[\s\S]*\})/);
53
+ if (!match) {
54
+ throw new Error(`No valid object literal found in: ${filePath}`);
55
+ }
56
+ const objectString = match[1];
57
+ const workerPath = resolve(import.meta.dir, "securityWorker.ts");
58
+ const worker = new Worker(workerPath);
59
+ const result = await new Promise((res, rej) => {
60
+ const timeout = setTimeout(() => {
61
+ worker.terminate();
62
+ rej(new Error(`Security Error: Evaluation timed out after ${timeoutMs}ms — possible infinite loop in ${filePath}`));
63
+ }, timeoutMs);
64
+ worker.onmessage = (event) => {
65
+ clearTimeout(timeout);
66
+ worker.terminate();
67
+ const { success, data, error } = event.data;
68
+ if (success) {
69
+ res(data);
70
+ }
71
+ else {
72
+ rej(new Error(`Security or Format Error in ${filePath}: ${error}`));
73
+ }
74
+ };
75
+ worker.onerror = (err) => {
76
+ clearTimeout(timeout);
77
+ worker.terminate();
78
+ rej(new Error(`Worker Error for ${filePath}: ${err.message}`));
79
+ };
80
+ worker.postMessage({ objectString });
81
+ });
82
+ const parsed = schema.safeParse(result);
83
+ if (!parsed.success) {
84
+ throw new Error(`Schema validation failed for ${filePath}:\n${parsed.error.message}`);
85
+ }
86
+ return parsed.data;
87
+ }
88
+ //# sourceMappingURL=securityParser.js.map
@@ -0,0 +1 @@
1
+ {"version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AC,CAAC;YACtE,CAAC;QACH,CAAC,CAAC;QAEF,MAAM,CAAC,OAAO,GAAG,CAAC,GAAe,EAAE,EAAE;YACnC,YAAY,CAAC,OAAO,CAAC,CAAC;YACtB,MAAM,CAAC,SAAS,EAAE,CAAC;YACnB,GAAG,CAAC,IAAI,KAAK,CAAC,oBAAoB,QAAQ,KAAK,GAAG,CAAC,OAAO,EAAE,CAAC,CAAC,CAAC;QACjE,CAAC,CAAC;QAEF,MAAM,CAAC,WAAW,CAAC,EAAE,YAAY,EAAE,CAAC,CAAC;IACvC,CAAC,CAAC,CAAC;IAEH,MAAM,MAAM,GAAG,MAAM,CAAC,SAAS,CAAC,MAAM,CAAC,CAAC;IACxC,IAAI,CAAC,MAAM,CAAC,OAAO,EAAE,CAAC;QACpB,MAAM,IAAI,KAAK,CACb,gCAAgC,QAAQ,MAAM,MAAM,CAAC,KAAK,CAAC,OAAO,EAAE,CACrE,CAAC;IACJ,CAAC;IAED,OAAO,MAAM,CAAC,IAAwB,CAAC;AACzC,CAAC"}
@@ -0,0 +1,8 @@
1
+ declare const worker: DedicatedWorkerGlobalScope;
2
+ declare const MAX_DEPTH = 20;
3
+ declare const MAX_KEYS = 1000;
4
+ declare const MAX_STRLEN = 100000;
5
+ declare let totalKeys: number;
6
+ declare function sanitise(value: unknown, depth?: number): unknown;
7
+ declare const SANDBOX_PREAMBLE = "\n \"use strict\";\n\n const process = undefined;\n const global = undefined;\n const globalThis = Object.create(null); // isolated dummy \u2014 writes succeed but go nowhere\n const module = undefined;\n const require = undefined;\n const __dirname = undefined;\n const __filename = undefined;\n const importScripts = undefined;\n const Function = undefined;\n const Reflect = undefined;\n const Proxy = undefined;\n\n // Stub ArrayBuffer \u2014 catches IIFE allocation bombs before they run.\n const ArrayBuffer = function() {\n throw new RangeError(\"ArrayBuffer construction is not allowed in meta files\");\n };\n\n // Stub RegExp constructor \u2014 catches IIFE regex bombs constructed via\n // new RegExp(...) or RegExp(...). Regex *literals* are a different path\n // (they don't call the RegExp constructor at parse time) but executing\n // .match()/.exec() on them still goes through the engine's regex executor.\n // The Worker timeout is the backstop for literal-based regex bombs.\n const RegExp = function() {\n throw new Error(\"RegExp construction is not allowed in meta files\");\n };\n";
8
+ //# sourceMappingURL=securityWorker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"securityWorker.d.ts","sourceRoot":"","sources":["../../src/security/securityWorker.ts"],"names":[],"mappings":"AAAA,QAAA,MAAM,MAAM,EAAsB,0BAA0B,CAAC;AAM7D,QAAA,MAAM,SAAS,KAAM,CAAC;AACtB,QAAA,MAAM,QAAQ,OAAU,CAAC;AACzB,QAAA,MAAM,UAAU,SAAU,CAAC;AAC3B,QAAA,IAAM,SAAS,QAAK,CAAC;AAErB,iBAAS,QAAQ,CAAC,KAAK,EAAE,OAAO,EAAE,KAAK,SAAI,GAAG,OAAO,CAwEpD;AAwCD,QAAA,MAAM,gBAAgB,uqCA4BrB,CAAC"}