@byokit/accounts 0.2.2 → 0.3.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.
- package/README.md +2 -1
- package/dist/testing/index.d.ts +2 -1
- package/dist/testing/index.js +3 -3
- package/package.json +1 -1
package/README.md
CHANGED
|
@@ -72,7 +72,8 @@ doesn't answer other web pages), so a PWA's model calls go through the app's own
|
|
|
72
72
|
doesn't include this use, and signs out only a sign-in that no longer refreshes. `ladder()` picks the next usable
|
|
73
73
|
account; `keepFresh()` refreshes ahead of expiry. Limits come from errors only; no undocumented usage endpoint is read.
|
|
74
74
|
- **Isolation**: ambient discovery is off (no environment variable or credential file is ever consulted), and
|
|
75
|
-
`@byokit/accounts/testing` has the decoy-HOME harness and fs tracer to prove it in your own tests.
|
|
75
|
+
`@byokit/accounts/testing` has the decoy-HOME harness and fs tracer to prove it in your own tests. `decoy(root)`
|
|
76
|
+
writes only under the caller-supplied root; the caller owns its creation and cleanup.
|
|
76
77
|
- **A stand-in OpenAI**: `mockOpenAI()` from `@byokit/accounts/testing` (or `node .../testing/mock-openai.ts [port]`)
|
|
77
78
|
answers device code, its page where a person types the code, token exchange, refresh and revoke, so tests and demos
|
|
78
79
|
sign in end to end with no account. Point the kit at it with `new Accounts({ authBase })`.
|
package/dist/testing/index.d.ts
CHANGED
|
@@ -1,7 +1,8 @@
|
|
|
1
1
|
export declare const CANARY = "canary-byokit-7f3a9c";
|
|
2
2
|
/** Preload this with `node --import` to record touches under `TRACE_ROOTS` in `TRACE_LOG` (both set in `decoy().env`). */
|
|
3
3
|
export declare const traceFs: string;
|
|
4
|
-
|
|
4
|
+
/** Build decoy files under a caller-owned directory; this function does not create or remove its root. */
|
|
5
|
+
export declare function decoy(root: string): {
|
|
5
6
|
root: string;
|
|
6
7
|
home: string;
|
|
7
8
|
roots: string[];
|
package/dist/testing/index.js
CHANGED
|
@@ -3,8 +3,7 @@
|
|
|
3
3
|
// shell inside one of them hands down, and an fs tracer. A run must leave the decoys byte for byte as they were, never
|
|
4
4
|
// touch them at all, and never carry a canary into the app's own files.
|
|
5
5
|
import { createHash } from 'node:crypto';
|
|
6
|
-
import { existsSync, mkdirSync,
|
|
7
|
-
import { tmpdir } from 'node:os';
|
|
6
|
+
import { existsSync, mkdirSync, readdirSync, readFileSync, statSync, writeFileSync } from 'node:fs';
|
|
8
7
|
import { dirname, join } from 'node:path';
|
|
9
8
|
import { fileURLToPath } from 'node:url';
|
|
10
9
|
export const CANARY = 'canary-byokit-7f3a9c';
|
|
@@ -14,7 +13,8 @@ const put = (p, text) => { mkdirSync(dirname(p), { recursive: true }); writeFile
|
|
|
14
13
|
const files = (dir) => existsSync(dir)
|
|
15
14
|
? readdirSync(dir, { recursive: true, withFileTypes: true }).filter((e) => e.isFile()).map((e) => join(e.parentPath, e.name)) : [];
|
|
16
15
|
const hashes = (dirs) => Object.fromEntries(dirs.flatMap(files).map((p) => [p, createHash('sha256').update(readFileSync(p)).digest('hex') + statSync(p).mtimeMs]));
|
|
17
|
-
|
|
16
|
+
/** Build decoy files under a caller-owned directory; this function does not create or remove its root. */
|
|
17
|
+
export function decoy(root) {
|
|
18
18
|
const home = join(root, 'home');
|
|
19
19
|
const marks = join(root, 'marks');
|
|
20
20
|
const trace = join(root, 'trace.log');
|