@scrthq/runlog 0.0.24

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.
@@ -0,0 +1,16 @@
1
+ /**
2
+ * Base64url, the unpadded kind, for the salt and IV in a container header.
3
+ *
4
+ * Written out rather than pulled in: it is nine lines each way, and this
5
+ * package's whole point is to have nothing underneath it.
6
+ */
7
+ export declare function toBase64Url(bytes: Uint8Array): string;
8
+ /**
9
+ * Backed by a plain `ArrayBuffer` on purpose.
10
+ *
11
+ * `Uint8Array.from` produces one typed as `ArrayBufferLike`, which since
12
+ * TypeScript 5.7 includes `SharedArrayBuffer` and so is not accepted where
13
+ * Web Crypto wants bytes. Allocating the buffer explicitly says what is
14
+ * actually true here and avoids a cast at every call site.
15
+ */
16
+ export declare function fromBase64Url(text: string): Uint8Array<ArrayBuffer>;
@@ -0,0 +1,48 @@
1
+ /** What travels in the clear, so a seller can act on a leak without the key. */
2
+ export interface ContainerHeader {
3
+ v: 1;
4
+ alg: "aes-256-gcm";
5
+ kdf: "pbkdf2-sha256";
6
+ iterations: number;
7
+ salt: string;
8
+ iv: string;
9
+ /**
10
+ * The seller's own reference for the sale, if they set one.
11
+ *
12
+ * Deliberately not the buyer's name. A leaked file should let the seller
13
+ * trace the sale through their own records; it should not publish somebody's
14
+ * name to everyone who downloads it.
15
+ */
16
+ ref?: string;
17
+ /** Shown before asking for a key, so the prompt can say what it is for. */
18
+ title?: string;
19
+ }
20
+ /**
21
+ * A license key a person can be given and can type.
22
+ *
23
+ * Grouped and from an alphabet without the characters people confuse, because
24
+ * this gets pasted out of a receipt email by someone who wants to play.
25
+ */
26
+ export declare function generateLicenseKey(): string;
27
+ /**
28
+ * Seal a document.
29
+ *
30
+ * The whole document goes in, including its signature: verification happens
31
+ * after opening, against the same bytes the author signed.
32
+ */
33
+ export declare function seal(document: unknown, licenseKey: string, extra?: {
34
+ ref?: string;
35
+ title?: string;
36
+ }): Promise<Uint8Array<ArrayBuffer>>;
37
+ export declare function isSealed(data: Uint8Array): boolean;
38
+ /** Read the clear header without needing a key. */
39
+ export declare function readHeader(data: Uint8Array): ContainerHeader | null;
40
+ export type OpenResult = {
41
+ ok: true;
42
+ document: unknown;
43
+ } | {
44
+ ok: false;
45
+ reason: "not-sealed" | "unsupported" | "wrong-key" | "damaged";
46
+ message: string;
47
+ };
48
+ export declare function open(data: Uint8Array, licenseKey: string): Promise<OpenResult>;
@@ -0,0 +1,16 @@
1
+ /**
2
+ * The sealed-copy container, on its own.
3
+ *
4
+ * This is the part of Runlog a seller's backend needs and nothing else: seal
5
+ * a pack behind a license key, read a sealed file's clear header, open one
6
+ * with its key, and make keys people can type. It has no idea what a pack
7
+ * is — it seals a JSON document — and no opinion about who is selling, so
8
+ * it depends on nothing and runs wherever Web Crypto does: Node 20 and up,
9
+ * and every current browser.
10
+ *
11
+ * The format is documented in docs/selling.md, and the promise the app makes
12
+ * about it is the reason this package exists: any file in this shape opens
13
+ * with its key, on any address, with nothing checked online.
14
+ */
15
+ export { generateLicenseKey, isSealed, open, readHeader, seal, type ContainerHeader, type OpenResult, } from "./container.ts";
16
+ export { fromBase64Url, toBase64Url } from "./base64url.ts";
package/package.json ADDED
@@ -0,0 +1,43 @@
1
+ {
2
+ "name": "@scrthq/runlog",
3
+ "version": "0.0.24",
4
+ "description": "Validate, lint, bundle and test Runlog rule packs.",
5
+ "type": "module",
6
+ "license": "MIT",
7
+ "repository": {
8
+ "type": "git",
9
+ "url": "git+https://github.com/SCRT-HQ/runlog.git"
10
+ },
11
+ "homepage": "https://github.com/SCRT-HQ/runlog#readme",
12
+ "bugs": "https://github.com/SCRT-HQ/runlog/issues",
13
+ "engines": {
14
+ "node": ">=20"
15
+ },
16
+ "publishConfig": {
17
+ "access": "public"
18
+ },
19
+ "bin": {
20
+ "runlog": "./dist/runlog.js"
21
+ },
22
+ "exports": {
23
+ ".": {
24
+ "types": "./dist/types/index.d.ts",
25
+ "default": "./dist/index.js"
26
+ }
27
+ },
28
+ "main": "./dist/index.js",
29
+ "types": "./dist/types/index.d.ts",
30
+ "files": [
31
+ "dist",
32
+ "README.md"
33
+ ],
34
+ "keywords": [
35
+ "runlog",
36
+ "tabletop",
37
+ "rule-pack",
38
+ "cli",
39
+ "rlpack",
40
+ "seal",
41
+ "license"
42
+ ]
43
+ }