keri-ts 0.2.1 → 0.2.3

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 CHANGED
@@ -1,150 +1,25 @@
1
- # keri-ts : KERI TypeScript Library
1
+ # keri-ts
2
2
 
3
- An aspiring full implementation of the KERI, ACDC, CESR, and PTEL specifications
4
- in TypeScript.
3
+ KERI TypeScript runtime package with the `tufa` CLI and foundational
4
+ database/runtime modules.
5
5
 
6
- ### Usage
6
+ ## Install
7
7
 
8
8
  ```bash
9
- # Run the CLI
10
- deno task tufa --help
11
-
12
- # Initialize a keystore
13
- deno task tufa init --name mykeystore
14
-
15
- # Get help for specific commands
16
- deno task tufa init --help
17
-
18
- # Show CLI version
19
- deno task tufa version
20
- deno task tufa --version
21
-
22
- # Annotate a CESR file
23
- deno task tufa annotate --in samples/cesr-streams/CESR_1_0-oor-auth-vc.cesr
24
-
25
- # Annotate CESR from stdin
26
- cat samples/cesr-streams/CESR_1_0-oor-auth-vc.cesr | deno task tufa annotate
27
- ```
28
-
29
- ### Install CLI (`tufa`)
30
-
31
- ```bash
32
- # npm (global)
33
- npm install -g keri-ts
34
- tufa --help
35
-
36
- # Deno (global)
37
- deno install --global --allow-all --unstable-ffi --name tufa mod.ts
38
- tufa --help
39
-
40
- # make sure to add the Deno bin path to your PATH var
41
- export PATH="$HOME/.deno/bin:$PATH"
42
- ```
43
-
44
- ### Features
45
-
46
- - TODO Fully integrates with KERIpy, KERIA, and SignifyTS, both CESR 1.0 and
47
- CESR 2.0
48
- - TODO Creates and manages keystores
49
- - TODO Parses and packs CESR streams
50
- - ✅ Provides CLI for interaction with KERI keystores (basic implementation)
51
- - TODO Provides a mailbox agent, controller agent, direct mode, and indirect
52
- mode agents.
53
- - TODO Creates, Issues, and Verifies ACDC credentials.
54
- - TODO Provides a JSON Schema server to host ACDC schemas.
55
-
56
- ### Importing library
57
-
58
- TBD
59
-
60
- ### Build scripts (Deno)
61
-
62
- ```bash
63
- # Run CLI commands
64
- deno task tufa init --name test
65
-
66
- # Start server (legacy)
67
- deno task start
68
- ```
69
-
70
- ### Versioning and Releases
71
-
72
- - `keri-ts` and `cesr-ts` are versioned independently with Changesets.
73
- - Runtime CLI version strings are generated from package manifest versions.
74
- - CI builds automatically append build metadata to CLI display versions.
75
-
76
- ```bash
77
- # Add a patch/minor/major release intent file
78
- deno task release:changeset
79
-
80
- # Apply version bumps/changelog updates from pending changesets
81
- deno task release:version
82
-
83
- # Regenerate and verify runtime version modules
84
- deno task version:generate
85
- deno task version:check
9
+ npm install keri-ts
86
10
  ```
87
11
 
88
- ### LMDB v1 Format Requirement
89
-
90
- **KERIpy Compatibility**: This project requires LMDB data format v1 for
91
- interoperability with KERIpy databases. The `lmdb-js` package defaults to LMDB
92
- v2 format, using v0.9.90 of LMDB, which is incompatible with databases created
93
- by KERIpy (which uses `py-lmdb` with LMDB 0.9.33).
94
-
95
- **Rebuilding lmdb with v1 support**:
96
-
97
- After installing dependencies, rebuild the `lmdb` package with v1 data format
98
- support:
12
+ ## CLI
99
13
 
100
14
  ```bash
101
- cd node_modules/lmdb
102
- export LMDB_DATA_V1=true
103
- npm run recompile
104
- cd ../..
15
+ npx tufa --help
16
+ npx tufa version
105
17
  ```
106
18
 
107
- **When to rebuild**:
108
-
109
- - After initial `npm install`
110
- - After updating the `lmdb` package
111
- - If you encounter `malloc` errors or database format incompatibility errors
112
- when opening KERIpy-created databases
113
-
114
- The `malloc` error looks like the following:
19
+ ## Deno tasks (package-local)
115
20
 
116
21
  ```bash
117
- node(42074,0x1f6bde0c0) malloc: *** error for object 0x3c7e805c00e0: pointer being freed was not allocated
118
- node(42074,0x1f6bde0c0) malloc: *** set a breakpoint in malloc_error_break to debug
119
- ```
120
-
121
- **Note**: The v1 format uses LMDB 0.9.29 (via `lmdb-data-v1`), which is
122
- compatible with KERIpy's LMDB 0.9.33. Some newer LMDB features (encryption,
123
- remapping) are not available with v1 format.
124
-
125
- ## Development Notes
126
-
127
- ### Deno install locally
128
-
129
- `tufa` will show a few warnings locally unless you install it with the
130
- `--allow-scripts` option like below:
131
-
132
- ```zsh
133
- deno install --global \
134
- --config /Users/kbull/code/keri/kentbull/keri-ts/deno.json \
135
- --node-modules-dir=auto \
136
- --allow-scripts=npm:lmdb,npm:msgpackr-extract \
137
- --allow-all \
138
- --unstable-ffi \
139
- --name tufa \
140
- /Users/kbull/code/keri/kentbull/keri-ts/mod.ts
141
- ```
142
-
143
- This is because of how Deno blocks build/install scripts for installed
144
- dependencies unless explicitly allowed.
145
-
146
- You may need to warm dependencies once with the following command:
147
-
148
- ```zsh
149
- deno install --node-modules-dir=auto --allow-scripts=npm:lmdb,npm:msgpackr-extract
22
+ deno task tufa --help
23
+ deno task test:quality
24
+ deno task build:npm
150
25
  ```
@@ -1,6 +1,6 @@
1
1
  import * as dntShim from "../../_dnt.shims.js";
2
- import { spawnSync } from "node:child_process";
3
- import { AppError } from "../../core/errors.js";
2
+ import { annotate } from "cesr-ts";
3
+ const TEXT_DECODER = new TextDecoder();
4
4
  function readAllStdinSync() {
5
5
  const chunks = [];
6
6
  let total = 0;
@@ -22,80 +22,6 @@ function readAllStdinSync() {
22
22
  }
23
23
  return output;
24
24
  }
25
- function buildDenoAnnotateArgs(options) {
26
- const args = [
27
- "run",
28
- "--allow-read",
29
- "--allow-write",
30
- "packages/cesr/src/annotate/cli-deno.ts",
31
- "--in",
32
- options.inPath,
33
- ];
34
- if (options.outPath) {
35
- args.push("--out", options.outPath);
36
- }
37
- if (options.qb2) {
38
- args.push("--qb2");
39
- }
40
- if (options.pretty) {
41
- args.push("--pretty");
42
- }
43
- return args;
44
- }
45
- function buildNodeAnnotateArgs(options) {
46
- const nodeScript = [
47
- "import { annotate } from 'cesr-ts';",
48
- "import fs from 'node:fs';",
49
- "const [inPath, outPath, qb2, pretty] = process.argv.slice(1);",
50
- "const input = fs.readFileSync(inPath);",
51
- "const output = qb2 === '1'",
52
- " ? annotate(new Uint8Array(input), { domainHint: 'bny', pretty: pretty === '1' })",
53
- " : annotate(input.toString('utf8'), { domainHint: 'txt', pretty: pretty === '1' });",
54
- "if (outPath) {",
55
- " fs.writeFileSync(outPath, output, 'utf8');",
56
- "} else {",
57
- " process.stdout.write(output + '\\n');",
58
- "}",
59
- ].join("\n");
60
- return [
61
- "--input-type=module",
62
- "--eval",
63
- nodeScript,
64
- options.inPath,
65
- options.outPath ?? "",
66
- options.qb2 ? "1" : "0",
67
- options.pretty ? "1" : "0",
68
- ];
69
- }
70
- function forwardChildOutput(output) {
71
- if (output.stdout.length > 0) {
72
- dntShim.Deno.stdout.writeSync(output.stdout);
73
- }
74
- if (output.stderr.length > 0) {
75
- dntShim.Deno.stderr.writeSync(output.stderr);
76
- }
77
- }
78
- function runDenoAnnotator(options) {
79
- const child = new dntShim.Deno.Command(dntShim.Deno.execPath(), {
80
- args: buildDenoAnnotateArgs(options),
81
- stdout: "piped",
82
- stderr: "piped",
83
- });
84
- return child.outputSync();
85
- }
86
- function runNodeAnnotator(options) {
87
- const maybeProcess = dntShim.dntGlobalThis;
88
- const executable = maybeProcess.process?.execPath || "node";
89
- const output = spawnSync(executable, buildNodeAnnotateArgs(options), {
90
- stdio: "pipe",
91
- });
92
- return {
93
- success: output.status === 0,
94
- code: output.status ?? 1,
95
- stdout: output.stdout ? new Uint8Array(output.stdout) : new Uint8Array(),
96
- stderr: output.stderr ? new Uint8Array(output.stderr) : new Uint8Array(),
97
- };
98
- }
99
25
  // deno-lint-ignore require-yield
100
26
  export function* annotateCommand(args) {
101
27
  const options = {
@@ -104,40 +30,18 @@ export function* annotateCommand(args) {
104
30
  qb2: args.qb2,
105
31
  pretty: args.pretty,
106
32
  };
107
- let tempInPath;
108
- if (!options.inPath) {
109
- tempInPath = dntShim.Deno.makeTempFileSync({ suffix: ".cesr" });
110
- dntShim.Deno.writeFileSync(tempInPath, readAllStdinSync());
111
- options.inPath = tempInPath;
112
- }
113
- try {
114
- let output;
115
- try {
116
- output = runDenoAnnotator(options);
117
- }
118
- catch (error) {
119
- const isDenoMissing = error instanceof Error &&
120
- (error.message.includes("not found: deno") ||
121
- (typeof error.code === "string" &&
122
- error.code === "ENOENT"));
123
- if (!isDenoMissing) {
124
- throw error;
125
- }
126
- output = runNodeAnnotator(options);
127
- }
128
- forwardChildOutput(output);
129
- if (!output.success) {
130
- throw new AppError(`annotate command failed with exit code ${output.code}`);
131
- }
132
- }
133
- finally {
134
- if (tempInPath) {
135
- try {
136
- dntShim.Deno.removeSync(tempInPath);
137
- }
138
- catch {
139
- // best-effort cleanup
140
- }
141
- }
33
+ const inputBytes = options.inPath
34
+ ? dntShim.Deno.readFileSync(options.inPath)
35
+ : readAllStdinSync();
36
+ const annotated = options.qb2
37
+ ? annotate(inputBytes, { domainHint: "bny", pretty: options.pretty })
38
+ : annotate(TEXT_DECODER.decode(inputBytes), {
39
+ domainHint: "txt",
40
+ pretty: options.pretty,
41
+ });
42
+ if (options.outPath) {
43
+ dntShim.Deno.writeTextFileSync(options.outPath, annotated);
44
+ return;
142
45
  }
46
+ console.log(annotated);
143
47
  }
@@ -0,0 +1,7 @@
1
+ /**
2
+ * CLI module - public API
3
+ *
4
+ * This module provides the KERI TypeScript CLI interface.
5
+ */
6
+ export { tufa } from "./cli.js";
7
+ export { initCommand } from "./init.js";
@@ -0,0 +1,7 @@
1
+ /**
2
+ * Application module - public API
3
+ *
4
+ * This module provides application-level functionality including CLI and server.
5
+ */
6
+ export * from "./cli/index.js";
7
+ export { startServer } from "./server.js";
@@ -2,8 +2,8 @@
2
2
  * Generated by scripts/generate_versions.ts.
3
3
  * Do not edit by hand.
4
4
  */
5
- export const PACKAGE_VERSION = "0.2.1";
6
- export const BUILD_METADATA = "";
5
+ export const PACKAGE_VERSION = "0.2.3";
6
+ export const BUILD_METADATA = "build.2.ae619744";
7
7
  export const DISPLAY_VERSION = BUILD_METADATA
8
8
  ? `${PACKAGE_VERSION}+${BUILD_METADATA}`
9
9
  : PACKAGE_VERSION;
package/esm/npm/index.js CHANGED
@@ -1,5 +1,10 @@
1
+ /**
2
+ * npm package root entrypoint.
3
+ *
4
+ * Keep this file stable because build_npm.ts and package export paths
5
+ * are wired to ./src/npm/index.ts -> ./esm/npm/index.js.
6
+ */
1
7
  import "../_dnt.polyfills.js";
2
8
  export * from "../core/index.js";
3
9
  export * from "../db/index.js";
4
- export { tufa } from "../app/cli/cli.js";
5
- export * from "../app/version.js";
10
+ export * from "../app/index.js";
package/package.json CHANGED
@@ -1,11 +1,12 @@
1
1
  {
2
2
  "name": "keri-ts",
3
- "version": "0.2.1",
3
+ "version": "0.2.3",
4
4
  "description": "KERI TypeScript package with database primitives and CLI runtime",
5
5
  "homepage": "https://github.com/kentbull/keri-ts",
6
6
  "repository": {
7
7
  "type": "git",
8
- "url": "git+https://github.com/kentbull/keri-ts.git"
8
+ "url": "git+https://github.com/kentbull/keri-ts.git",
9
+ "directory": "packages/keri"
9
10
  },
10
11
  "license": "Apache-2.0",
11
12
  "bugs": {
@@ -45,11 +46,11 @@
45
46
  "node": ">=18"
46
47
  },
47
48
  "dependencies": {
49
+ "cesr-ts": ">=0.2.0 <0.3.0",
48
50
  "commander": "^10.0.1",
49
51
  "effection": "^3.6.0",
50
52
  "lmdb": "^3.4.4",
51
- "@deno/shim-deno": "~0.18.0",
52
- "cesr-ts": ">=0.2.0 <0.3.0"
53
+ "@deno/shim-deno": "~0.18.0"
53
54
  },
54
55
  "devDependencies": {
55
56
  "@types/node": "^20.9.0"
@@ -1 +1 @@
1
- {"version":3,"file":"annotate.d.ts","sourceRoot":"","sources":["../../../src/app/cli/annotate.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAkI3C,wBAAiB,eAAe,CAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,SAAS,CAAC,IAAI,CAAC,CA+CjB"}
1
+ {"version":3,"file":"annotate.d.ts","sourceRoot":"","sources":["../../../src/app/cli/annotate.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,KAAK,SAAS,EAAE,MAAM,WAAW,CAAC;AAsC3C,wBAAiB,eAAe,CAC9B,IAAI,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAC5B,SAAS,CAAC,IAAI,CAAC,CAyBjB"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * CLI module - public API
3
+ *
4
+ * This module provides the KERI TypeScript CLI interface.
5
+ */
6
+ export { tufa } from "./cli.js";
7
+ export { initCommand } from "./init.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/app/cli/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAE,IAAI,EAAE,MAAM,UAAU,CAAC;AAChC,OAAO,EAAE,WAAW,EAAE,MAAM,WAAW,CAAC"}
@@ -0,0 +1,8 @@
1
+ /**
2
+ * Application module - public API
3
+ *
4
+ * This module provides application-level functionality including CLI and server.
5
+ */
6
+ export * from "./cli/index.js";
7
+ export { startServer } from "./server.js";
8
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/app/index.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,WAAW,EAAE,MAAM,aAAa,CAAC"}
@@ -2,7 +2,7 @@
2
2
  * Generated by scripts/generate_versions.ts.
3
3
  * Do not edit by hand.
4
4
  */
5
- export declare const PACKAGE_VERSION = "0.2.1";
6
- export declare const BUILD_METADATA = "";
5
+ export declare const PACKAGE_VERSION = "0.2.3";
6
+ export declare const BUILD_METADATA = "build.2.ae619744";
7
7
  export declare const DISPLAY_VERSION: string;
8
8
  //# sourceMappingURL=version.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/app/version.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,cAAc,KAAK,CAAC;AACjC,eAAO,MAAM,eAAe,QAET,CAAC"}
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../../src/app/version.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,eAAO,MAAM,eAAe,UAAU,CAAC;AACvC,eAAO,MAAM,cAAc,qBAAqB,CAAC;AACjD,eAAO,MAAM,eAAe,QAET,CAAC"}
@@ -1,6 +1,11 @@
1
+ /**
2
+ * npm package root entrypoint.
3
+ *
4
+ * Keep this file stable because build_npm.ts and package export paths
5
+ * are wired to ./src/npm/index.ts -> ./esm/npm/index.js.
6
+ */
1
7
  import "../_dnt.polyfills.js";
2
8
  export * from "../core/index.js";
3
9
  export * from "../db/index.js";
4
- export { tufa } from "../app/cli/cli.js";
5
- export * from "../app/version.js";
10
+ export * from "../app/index.js";
6
11
  //# sourceMappingURL=index.d.ts.map
@@ -1 +1 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/npm/index.ts"],"names":[],"mappings":"AAAA,OAAO,sBAAsB,CAAC;AAC9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,OAAO,EAAE,IAAI,EAAE,MAAM,mBAAmB,CAAC;AACzC,cAAc,mBAAmB,CAAC"}
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/npm/index.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AACH,OAAO,sBAAsB,CAAC;AAE9B,cAAc,kBAAkB,CAAC;AACjC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC"}