sweetlink 0.2.0 → 0.2.2
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/CHANGELOG.md +21 -2
- package/LICENSE +1 -1
- package/README.md +6 -6
- package/dist/daemon/src/cli.d.ts +3 -0
- package/dist/daemon/src/cli.d.ts.map +1 -0
- package/dist/daemon/src/cli.js +14 -0
- package/dist/daemon/src/cli.js.map +1 -0
- package/dist/daemon/src/codename.d.ts.map +1 -1
- package/dist/daemon/src/codename.js +11 -11
- package/dist/daemon/src/codename.js.map +1 -1
- package/dist/daemon/src/index.d.ts +1 -1
- package/dist/daemon/src/index.js +143 -128
- package/dist/daemon/src/index.js.map +1 -1
- package/dist/shared/src/env.d.ts.map +1 -1
- package/dist/shared/src/env.js +12 -12
- package/dist/shared/src/env.js.map +1 -1
- package/dist/shared/src/index.d.ts +30 -30
- package/dist/shared/src/index.d.ts.map +1 -1
- package/dist/shared/src/index.js +17 -17
- package/dist/shared/src/index.js.map +1 -1
- package/dist/shared/src/node.d.ts +1 -1
- package/dist/shared/src/node.d.ts.map +1 -1
- package/dist/shared/src/node.js +18 -18
- package/dist/shared/src/node.js.map +1 -1
- package/dist/src/codex.d.ts +1 -1
- package/dist/src/codex.js +19 -19
- package/dist/src/codex.js.map +1 -1
- package/dist/src/commands/click.d.ts +1 -1
- package/dist/src/commands/click.d.ts.map +1 -1
- package/dist/src/commands/click.js +32 -24
- package/dist/src/commands/click.js.map +1 -1
- package/dist/src/commands/run-js.d.ts +1 -1
- package/dist/src/commands/run-js.d.ts.map +1 -1
- package/dist/src/commands/run-js.js +10 -10
- package/dist/src/commands/run-js.js.map +1 -1
- package/dist/src/commands/trust-ca.d.ts +1 -1
- package/dist/src/commands/trust-ca.js +15 -15
- package/dist/src/core/config-file.d.ts.map +1 -1
- package/dist/src/core/config-file.js +49 -41
- package/dist/src/core/config-file.js.map +1 -1
- package/dist/src/core/config.d.ts +2 -2
- package/dist/src/core/config.d.ts.map +1 -1
- package/dist/src/core/config.js +22 -18
- package/dist/src/core/config.js.map +1 -1
- package/dist/src/core/dev-bootstrap.d.ts +1 -1
- package/dist/src/core/dev-bootstrap.d.ts.map +1 -1
- package/dist/src/core/dev-bootstrap.js +12 -12
- package/dist/src/core/dev-bootstrap.js.map +1 -1
- package/dist/src/core/env.d.ts +1 -1
- package/dist/src/core/env.d.ts.map +1 -1
- package/dist/src/core/env.js +3 -3
- package/dist/src/core/env.js.map +1 -1
- package/dist/src/devtools-registry.d.ts.map +1 -1
- package/dist/src/devtools-registry.js +48 -46
- package/dist/src/devtools-registry.js.map +1 -1
- package/dist/src/env.d.ts +1 -1
- package/dist/src/env.js +1 -1
- package/dist/src/http.d.ts.map +1 -1
- package/dist/src/http.js +7 -6
- package/dist/src/http.js.map +1 -1
- package/dist/src/index.d.ts +7 -7
- package/dist/src/index.d.ts.map +1 -1
- package/dist/src/index.js +399 -367
- package/dist/src/index.js.map +1 -1
- package/dist/src/runtime/browser/client.d.ts +5 -4
- package/dist/src/runtime/browser/client.d.ts.map +1 -1
- package/dist/src/runtime/browser/client.js +79 -72
- package/dist/src/runtime/browser/client.js.map +1 -1
- package/dist/src/runtime/browser/commands/index.d.ts +2 -2
- package/dist/src/runtime/browser/commands/index.js +17 -17
- package/dist/src/runtime/browser/commands/index.js.map +1 -1
- package/dist/src/runtime/browser/dom-to-image-loader.d.ts.map +1 -1
- package/dist/src/runtime/browser/dom-to-image-loader.js +7 -7
- package/dist/src/runtime/browser/dom-to-image-loader.js.map +1 -1
- package/dist/src/runtime/browser/index.d.ts +3 -3
- package/dist/src/runtime/browser/index.js +2 -2
- package/dist/src/runtime/browser/module-loader.js +2 -2
- package/dist/src/runtime/browser/screenshot/hooks.d.ts +5 -5
- package/dist/src/runtime/browser/screenshot/hooks.d.ts.map +1 -1
- package/dist/src/runtime/browser/screenshot/hooks.js +32 -29
- package/dist/src/runtime/browser/screenshot/hooks.js.map +1 -1
- package/dist/src/runtime/browser/screenshot/index.d.ts +3 -3
- package/dist/src/runtime/browser/screenshot/index.d.ts.map +1 -1
- package/dist/src/runtime/browser/screenshot/index.js +17 -15
- package/dist/src/runtime/browser/screenshot/index.js.map +1 -1
- package/dist/src/runtime/browser/screenshot/renderers/dom-to-image.d.ts +1 -1
- package/dist/src/runtime/browser/screenshot/renderers/dom-to-image.js +13 -13
- package/dist/src/runtime/browser/screenshot/renderers/dom-to-image.js.map +1 -1
- package/dist/src/runtime/browser/screenshot/renderers/html2canvas.d.ts +1 -1
- package/dist/src/runtime/browser/screenshot/renderers/html2canvas.d.ts.map +1 -1
- package/dist/src/runtime/browser/screenshot/renderers/html2canvas.js +24 -24
- package/dist/src/runtime/browser/screenshot/renderers/html2canvas.js.map +1 -1
- package/dist/src/runtime/browser/screenshot/targets.d.ts +2 -2
- package/dist/src/runtime/browser/screenshot/targets.js +9 -9
- package/dist/src/runtime/browser/screenshot/utils.d.ts +1 -1
- package/dist/src/runtime/browser/screenshot/utils.d.ts.map +1 -1
- package/dist/src/runtime/browser/screenshot/utils.js +73 -71
- package/dist/src/runtime/browser/screenshot/utils.js.map +1 -1
- package/dist/src/runtime/browser/selector-discovery.d.ts +1 -1
- package/dist/src/runtime/browser/selector-discovery.d.ts.map +1 -1
- package/dist/src/runtime/browser/selector-discovery.js +24 -22
- package/dist/src/runtime/browser/selector-discovery.js.map +1 -1
- package/dist/src/runtime/browser/storage/session-storage.d.ts +10 -5
- package/dist/src/runtime/browser/storage/session-storage.d.ts.map +1 -1
- package/dist/src/runtime/browser/storage/session-storage.js +12 -10
- package/dist/src/runtime/browser/storage/session-storage.js.map +1 -1
- package/dist/src/runtime/browser/types.d.ts +7 -7
- package/dist/src/runtime/browser/types.js +1 -1
- package/dist/src/runtime/browser/utils/console.d.ts +1 -1
- package/dist/src/runtime/browser/utils/console.js +16 -16
- package/dist/src/runtime/browser/utils/console.js.map +1 -1
- package/dist/src/runtime/browser/utils/environment.js +2 -2
- package/dist/src/runtime/browser/utils/errors.d.ts.map +1 -1
- package/dist/src/runtime/browser/utils/errors.js +11 -11
- package/dist/src/runtime/browser/utils/number.d.ts.map +1 -1
- package/dist/src/runtime/browser/utils/number.js.map +1 -1
- package/dist/src/runtime/browser/utils/object.d.ts.map +1 -1
- package/dist/src/runtime/browser/utils/object.js +2 -2
- package/dist/src/runtime/browser/utils/object.js.map +1 -1
- package/dist/src/runtime/browser/utils/sanitize.js +2 -2
- package/dist/src/runtime/browser/utils/time.d.ts.map +1 -1
- package/dist/src/runtime/browser/utils/time.js +1 -1
- package/dist/src/runtime/chrome/cookies.d.ts +4 -4
- package/dist/src/runtime/chrome/cookies.d.ts.map +1 -1
- package/dist/src/runtime/chrome/cookies.js +31 -31
- package/dist/src/runtime/chrome/cookies.js.map +1 -1
- package/dist/src/runtime/chrome/deep-link.d.ts +1 -1
- package/dist/src/runtime/chrome/deep-link.d.ts.map +1 -1
- package/dist/src/runtime/chrome/deep-link.js +46 -36
- package/dist/src/runtime/chrome/deep-link.js.map +1 -1
- package/dist/src/runtime/chrome/diagnostics.d.ts.map +1 -1
- package/dist/src/runtime/chrome/diagnostics.js +13 -11
- package/dist/src/runtime/chrome/diagnostics.js.map +1 -1
- package/dist/src/runtime/chrome/focus.d.ts.map +1 -1
- package/dist/src/runtime/chrome/focus.js +5 -5
- package/dist/src/runtime/chrome/focus.js.map +1 -1
- package/dist/src/runtime/chrome/launch.d.ts.map +1 -1
- package/dist/src/runtime/chrome/launch.js +30 -30
- package/dist/src/runtime/chrome/launch.js.map +1 -1
- package/dist/src/runtime/chrome/puppeteer.d.ts +2 -2
- package/dist/src/runtime/chrome/puppeteer.d.ts.map +1 -1
- package/dist/src/runtime/chrome/puppeteer.js +16 -11
- package/dist/src/runtime/chrome/puppeteer.js.map +1 -1
- package/dist/src/runtime/chrome/reuse.d.ts.map +1 -1
- package/dist/src/runtime/chrome/reuse.js +38 -35
- package/dist/src/runtime/chrome/reuse.js.map +1 -1
- package/dist/src/runtime/chrome/session.d.ts +1 -1
- package/dist/src/runtime/chrome/session.d.ts.map +1 -1
- package/dist/src/runtime/chrome/session.js +12 -10
- package/dist/src/runtime/chrome/session.js.map +1 -1
- package/dist/src/runtime/chrome.d.ts +8 -8
- package/dist/src/runtime/chrome.js +8 -8
- package/dist/src/runtime/cookies.d.ts +1 -16
- package/dist/src/runtime/cookies.d.ts.map +1 -1
- package/dist/src/runtime/cookies.js +175 -286
- package/dist/src/runtime/cookies.js.map +1 -1
- package/dist/src/runtime/devstack.d.ts +1 -1
- package/dist/src/runtime/devstack.d.ts.map +1 -1
- package/dist/src/runtime/devstack.js +31 -28
- package/dist/src/runtime/devstack.js.map +1 -1
- package/dist/src/runtime/devtools/background.js +22 -22
- package/dist/src/runtime/devtools/cdp.d.ts +3 -3
- package/dist/src/runtime/devtools/cdp.d.ts.map +1 -1
- package/dist/src/runtime/devtools/cdp.js +59 -55
- package/dist/src/runtime/devtools/cdp.js.map +1 -1
- package/dist/src/runtime/devtools/config.d.ts.map +1 -1
- package/dist/src/runtime/devtools/config.js +15 -15
- package/dist/src/runtime/devtools/config.js.map +1 -1
- package/dist/src/runtime/devtools/constants.d.ts.map +1 -1
- package/dist/src/runtime/devtools/constants.js +18 -10
- package/dist/src/runtime/devtools/constants.js.map +1 -1
- package/dist/src/runtime/devtools/diagnostics.d.ts +4 -4
- package/dist/src/runtime/devtools/diagnostics.d.ts.map +1 -1
- package/dist/src/runtime/devtools/diagnostics.js +40 -38
- package/dist/src/runtime/devtools/diagnostics.js.map +1 -1
- package/dist/src/runtime/devtools/oauth.d.ts +1 -1
- package/dist/src/runtime/devtools/oauth.d.ts.map +1 -1
- package/dist/src/runtime/devtools/oauth.js +35 -28
- package/dist/src/runtime/devtools/oauth.js.map +1 -1
- package/dist/src/runtime/devtools/types.d.ts +3 -3
- package/dist/src/runtime/devtools/types.d.ts.map +1 -1
- package/dist/src/runtime/devtools.d.ts +7 -7
- package/dist/src/runtime/devtools.js +7 -7
- package/dist/src/runtime/next-devtools.d.ts.map +1 -1
- package/dist/src/runtime/next-devtools.js +12 -12
- package/dist/src/runtime/next-devtools.js.map +1 -1
- package/dist/src/runtime/screenshot.d.ts +9 -9
- package/dist/src/runtime/screenshot.d.ts.map +1 -1
- package/dist/src/runtime/screenshot.js +65 -46
- package/dist/src/runtime/screenshot.js.map +1 -1
- package/dist/src/runtime/scripts.d.ts +1 -1
- package/dist/src/runtime/scripts.d.ts.map +1 -1
- package/dist/src/runtime/scripts.js +28 -28
- package/dist/src/runtime/scripts.js.map +1 -1
- package/dist/src/runtime/session.d.ts +6 -6
- package/dist/src/runtime/session.d.ts.map +1 -1
- package/dist/src/runtime/session.js +35 -35
- package/dist/src/runtime/session.js.map +1 -1
- package/dist/src/runtime/smoke.d.ts +3 -3
- package/dist/src/runtime/smoke.d.ts.map +1 -1
- package/dist/src/runtime/smoke.js +85 -79
- package/dist/src/runtime/smoke.js.map +1 -1
- package/dist/src/runtime/url.d.ts +2 -2
- package/dist/src/runtime/url.d.ts.map +1 -1
- package/dist/src/runtime/url.js +20 -20
- package/dist/src/runtime/url.js.map +1 -1
- package/dist/src/screenshot-hooks.d.ts +1 -1
- package/dist/src/screenshot-hooks.d.ts.map +1 -1
- package/dist/src/screenshot-hooks.js +12 -12
- package/dist/src/screenshot-hooks.js.map +1 -1
- package/dist/src/shared/env.d.ts.map +1 -1
- package/dist/src/shared/env.js +11 -11
- package/dist/src/shared/env.js.map +1 -1
- package/dist/src/shared/index.d.ts +30 -30
- package/dist/src/shared/index.d.ts.map +1 -1
- package/dist/src/shared/index.js +17 -17
- package/dist/src/shared/index.js.map +1 -1
- package/dist/src/shared/node.d.ts +1 -1
- package/dist/src/shared/node.d.ts.map +1 -1
- package/dist/src/shared/node.js +18 -18
- package/dist/src/shared/node.js.map +1 -1
- package/dist/src/token.d.ts +1 -1
- package/dist/src/token.d.ts.map +1 -1
- package/dist/src/token.js +16 -16
- package/dist/src/token.js.map +1 -1
- package/dist/src/types.d.ts +1 -1
- package/dist/src/util/app-label.js +4 -4
- package/dist/src/util/errors.d.ts.map +1 -1
- package/dist/src/util/errors.js +12 -10
- package/dist/src/util/errors.js.map +1 -1
- package/dist/src/util/path.js +2 -2
- package/dist/src/util/regex.js +4 -4
- package/package.json +53 -45
package/CHANGELOG.md
CHANGED
|
@@ -1,8 +1,27 @@
|
|
|
1
1
|
# Changelog
|
|
2
2
|
|
|
3
|
-
## 0.2.
|
|
3
|
+
## 0.2.2 — 2026-08-10
|
|
4
4
|
|
|
5
|
-
|
|
5
|
+
**Highlight:** `sweetlinkd --help` no longer starts the daemon, and this
|
|
6
|
+
release clears seven security advisories — the vulnerable undici 7.28.0 leaves
|
|
7
|
+
the dependency graph entirely.
|
|
8
|
+
|
|
9
|
+
### Fixes
|
|
10
|
+
|
|
11
|
+
- **Standalone daemon help fixed**: `sweetlinkd --help` now prints usage and exits instead of starting the daemon.
|
|
12
|
+
- **Example handshake fixed**: the basic web example now converts HTTP daemon origins to browser-compatible WebSocket URLs and permits the configured socket origin plus SweetLink command modules through its content security policy.
|
|
13
|
+
|
|
14
|
+
### Security and maintenance
|
|
15
|
+
|
|
16
|
+
- Refresh the dependency graph, clearing seven advisories: vulnerable `undici` 7.28.0 is removed entirely, and playwright-core, puppeteer-core, jsdom 30, ws, and the oxc toolchain move to current releases.
|
|
17
|
+
|
|
18
|
+
## 0.2.1 — 2026-06-11
|
|
19
|
+
|
|
20
|
+
- **Click defaults restored**: `sweetlink click` now scrolls targets into view and dispatches bubbling clicks by default again, with explicit `--no-scroll` and `--no-bubbles` opt-outs. Thanks @devYRPauli.
|
|
21
|
+
- **Cookie collection modernized**: Chrome cookie sync now uses `@steipete/sweet-cookie`, preserves the `~/.oracle` inline fallback, and drops the old native SQLite/keytar dependency path.
|
|
22
|
+
- **Smoke route corrected**: the built-in `main` preset now targets `/timeline` and no longer treats the removed `/timeline/home` route as equivalent.
|
|
23
|
+
- **Node 24 baseline**: package metadata, CI, TypeScript builds, linting, and runtime dependencies now target Node.js 24 or newer.
|
|
24
|
+
- **Runtime maintenance**: updated Commander, Puppeteer Core, Playwright Core, WebSocket, Vite, and supporting dependencies.
|
|
6
25
|
|
|
7
26
|
## 0.2.0 — 2025-12-26
|
|
8
27
|
|
package/LICENSE
CHANGED
package/README.md
CHANGED
|
@@ -23,7 +23,7 @@ SweetLink is the agent-ready way to "connect your agent to your web app. Like Pl
|
|
|
23
23
|
|
|
24
24
|
## Prerequisites
|
|
25
25
|
|
|
26
|
-
- Node.js
|
|
26
|
+
- Node.js 24+
|
|
27
27
|
- `pnpm` (managed via Corepack)
|
|
28
28
|
- TLS requirements: `brew install mkcert nss`
|
|
29
29
|
- SweetLink daemon running locally (`pnpm exec sweetlink daemon` or `pnpm exec sweetlinkd`)
|
|
@@ -150,11 +150,11 @@ Place the config file in your project root (or any parent directory). With the f
|
|
|
150
150
|
- `oauthScript` – Absolute or relative path to an OAuth automation script (ESM module). When set, SweetLink loads the module at runtime and calls its `authorize(context)` export to approve third-party consent dialogs.
|
|
151
151
|
|
|
152
152
|
SweetLink reads the config once at start-up. When you edit `sweetlink.json` rerun the CLI command to pick up the new defaults. Multiple projects on the same machine can keep their own config files; SweetLink stops at the first file it finds while walking up the directory tree, so place project-specific configs as close to the repo root as possible.
|
|
153
|
-
See `
|
|
153
|
+
See `docs/config.md` for a full configuration reference (including environment overrides).
|
|
154
154
|
|
|
155
155
|
### OAuth automation scripts
|
|
156
156
|
|
|
157
|
-
Out of the box SweetLink no longer ships opinionated OAuth heuristics. Instead you can point `oauthScript` at a small ESM module that exports an `authorize(context)` function. The helper receives a `SweetLinkOauthAuthorizeContext` with DevTools and Puppeteer helpers, so you can fully control how SweetLink approves third-party consent prompts. A ready-to-use implementation for Twitter/X lives at `
|
|
157
|
+
Out of the box SweetLink no longer ships opinionated OAuth heuristics. Instead you can point `oauthScript` at a small ESM module that exports an `authorize(context)` function. The helper receives a `SweetLinkOauthAuthorizeContext` with DevTools and Puppeteer helpers, so you can fully control how SweetLink approves third-party consent prompts. A ready-to-use implementation for Twitter/X lives at `examples/oauth/twitter-oauth-automation.ts`; copy it into your project (or tweak it) and set `oauthScript` to that path to re-enable the previous behaviour. If the script is omitted, SweetLink will log that auto-authorization is disabled and leave the prompt untouched.
|
|
158
158
|
|
|
159
159
|
You can also specify the script through runtime inputs:
|
|
160
160
|
|
|
@@ -204,11 +204,11 @@ export const sweetLinkClient = createSweetLinkClient({
|
|
|
204
204
|
|
|
205
205
|
The runtime mirrors everything we ship in production: websocket lifecycle, console buffering, screenshot hooks/renderers, selector discovery, and auto-reconnect with stored-session resume. Tests can import `sweetLinkBrowserTestHelpers` to reuse `createHookRunner`, `stripDataUrlPrefix`, and `commandSelectorSummary` without reaching into private modules.
|
|
206
206
|
|
|
207
|
-
👉 See [`
|
|
207
|
+
👉 See [`browser.md`](./browser.md) for a step-by-step integration guide (handshake endpoint, custom storage adapters, DOM events) plus a reference implementation you can copy into other apps.
|
|
208
208
|
|
|
209
209
|
## Example App
|
|
210
210
|
|
|
211
|
-
Looking for a minimal integration? Launch the demo web app under `
|
|
211
|
+
Looking for a minimal integration? Launch the demo web app under `examples/basic-web`:
|
|
212
212
|
|
|
213
213
|
```bash
|
|
214
214
|
cd examples/basic-web
|
|
@@ -239,7 +239,7 @@ pnpm test
|
|
|
239
239
|
|
|
240
240
|
## License
|
|
241
241
|
|
|
242
|
-
SweetLink (CLI, daemon, and shared packages) is licensed under the MIT License. See `
|
|
242
|
+
SweetLink (CLI, daemon, and shared packages) is licensed under the MIT License. See `LICENSE` for the full text.
|
|
243
243
|
|
|
244
244
|
## TLS Onboarding
|
|
245
245
|
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.d.ts","sourceRoot":"","sources":["../../../daemon/src/cli.ts"],"names":[],"mappings":"AAAA,wBAAgB,mBAAmB,CAAC,IAAI,EAAE,SAAS,MAAM,EAAE,GAAG,OAAO,CAEpE;AAED,wBAAgB,gBAAgB,IAAI,MAAM,CASzC"}
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export function isDaemonHelpRequest(args) {
|
|
2
|
+
return args.includes("--help") || args.includes("-h");
|
|
3
|
+
}
|
|
4
|
+
export function formatDaemonHelp() {
|
|
5
|
+
return [
|
|
6
|
+
"Usage: sweetlinkd [options]",
|
|
7
|
+
"",
|
|
8
|
+
"Launch the SweetLink daemon process",
|
|
9
|
+
"",
|
|
10
|
+
"Options:",
|
|
11
|
+
" -h, --help display help for command",
|
|
12
|
+
].join("\n");
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=cli.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../../../daemon/src/cli.ts"],"names":[],"mappings":"AAAA,MAAM,UAAU,mBAAmB,CAAC,IAAuB;IACzD,OAAO,IAAI,CAAC,QAAQ,CAAC,QAAQ,CAAC,IAAI,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC;AACxD,CAAC;AAED,MAAM,UAAU,gBAAgB;IAC9B,OAAO;QACL,6BAA6B;QAC7B,EAAE;QACF,qCAAqC;QACrC,EAAE;QACF,UAAU;QACV,wCAAwC;KACzC,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;AACf,CAAC"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codename.d.ts","sourceRoot":"","sources":["../../../daemon/src/codename.ts"],"names":[],"mappings":"AAGA,UAAU,eAAe;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC;IACpC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC;IACpC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,MAAM,CAAC;CAC1C;AA0BD,wBAAgB,uBAAuB,
|
|
1
|
+
{"version":3,"file":"codename.d.ts","sourceRoot":"","sources":["../../../daemon/src/codename.ts"],"names":[],"mappings":"AAGA,UAAU,eAAe;IACvB,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC;IACpC,QAAQ,CAAC,WAAW,CAAC,EAAE,MAAM,MAAM,CAAC;IACpC,QAAQ,CAAC,gBAAgB,CAAC,EAAE,MAAM,MAAM,CAAC;CAC1C;AA0BD,wBAAgB,uBAAuB,CACrC,QAAQ,EAAE,QAAQ,CAAC,MAAM,CAAC,EAC1B,OAAO,GAAE,eAAoB,GAC5B,MAAM,CA0BR"}
|
|
@@ -1,22 +1,22 @@
|
|
|
1
|
-
import { randomInt } from
|
|
2
|
-
import { generateSlug } from
|
|
1
|
+
import { randomInt } from "node:crypto";
|
|
2
|
+
import { generateSlug } from "random-word-slugs";
|
|
3
3
|
const MAX_ATTEMPTS = 12;
|
|
4
4
|
const ensureNonEmptyString = (value, label) => {
|
|
5
|
-
if (typeof value !==
|
|
5
|
+
if (typeof value !== "string" || value.trim().length === 0) {
|
|
6
6
|
throw new TypeError(`${label} must return a non-empty string`);
|
|
7
7
|
}
|
|
8
8
|
return value;
|
|
9
9
|
};
|
|
10
10
|
const defaultSlugFactory = () => {
|
|
11
11
|
const slug = generateSlug(2, {
|
|
12
|
-
partsOfSpeech: [
|
|
13
|
-
format:
|
|
12
|
+
partsOfSpeech: ["adjective", "noun"],
|
|
13
|
+
format: "kebab",
|
|
14
14
|
});
|
|
15
|
-
return ensureNonEmptyString(slug,
|
|
15
|
+
return ensureNonEmptyString(slug, "slugFactory");
|
|
16
16
|
};
|
|
17
17
|
const defaultSaltFactory = () => randomInt(36 ** 2)
|
|
18
18
|
.toString(36)
|
|
19
|
-
.padStart(2,
|
|
19
|
+
.padStart(2, "0");
|
|
20
20
|
const defaultTimestampFactory = () => Date.now();
|
|
21
21
|
export function generateSessionCodename(existing, options = {}) {
|
|
22
22
|
const used = new Set(existing);
|
|
@@ -24,18 +24,18 @@ export function generateSessionCodename(existing, options = {}) {
|
|
|
24
24
|
const saltFactory = options.saltFactory ?? defaultSaltFactory;
|
|
25
25
|
const timestampFactory = options.timestampFactory ?? defaultTimestampFactory;
|
|
26
26
|
for (let attempt = 0; attempt < MAX_ATTEMPTS; attempt += 1) {
|
|
27
|
-
const candidate = ensureNonEmptyString(slugFactory(),
|
|
27
|
+
const candidate = ensureNonEmptyString(slugFactory(), "slugFactory");
|
|
28
28
|
if (!used.has(candidate)) {
|
|
29
29
|
return candidate;
|
|
30
30
|
}
|
|
31
31
|
}
|
|
32
|
-
const withSalt = `${ensureNonEmptyString(slugFactory(),
|
|
32
|
+
const withSalt = `${ensureNonEmptyString(slugFactory(), "slugFactory")}-${ensureNonEmptyString(saltFactory(), "saltFactory")}`;
|
|
33
33
|
if (!used.has(withSalt)) {
|
|
34
34
|
return withSalt;
|
|
35
35
|
}
|
|
36
36
|
const timestamp = timestampFactory();
|
|
37
|
-
if (typeof timestamp !==
|
|
38
|
-
throw new TypeError(
|
|
37
|
+
if (typeof timestamp !== "number" || Number.isNaN(timestamp)) {
|
|
38
|
+
throw new TypeError("timestampFactory must return a numeric timestamp");
|
|
39
39
|
}
|
|
40
40
|
return `${withSalt}-${Math.abs(timestamp).toString(36).slice(-2)}`;
|
|
41
41
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"codename.js","sourceRoot":"","sources":["../../../daemon/src/codename.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,SAAS,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,EAAE,YAAY,EAAE,MAAM,mBAAmB,CAAC;AAQjD,MAAM,YAAY,GAAG,EAAE,CAAC;AAExB,MAAM,oBAAoB,GAAG,CAAC,KAAc,EAAE,KAAa,EAAU,EAAE;IACrE,IAAI,OAAO,KAAK,KAAK,QAAQ,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC,MAAM,KAAK,CAAC,EAAE,CAAC;QAC3D,MAAM,IAAI,SAAS,CAAC,GAAG,KAAK,iCAAiC,CAAC,CAAC;IACjE,CAAC;IACD,OAAO,KAAK,CAAC;AACf,CAAC,CAAC;AAEF,MAAM,kBAAkB,GAAG,GAAW,EAAE;IACtC,MAAM,IAAI,GAAG,YAAY,CAA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