@dot-skill/registry 0.4.1
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/LICENSE +21 -0
- package/dist/index.d.ts +53 -0
- package/dist/index.js +115 -0
- package/package.json +43 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Bharat Dudeja
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @dot-skill/registry — free append-only transparency log for `.skill` packages.
|
|
3
|
+
*
|
|
4
|
+
* Default log path: ~/.dot-skill/registry/log.jsonl
|
|
5
|
+
* Each line is a JSON object with a publish record.
|
|
6
|
+
* Lookup and verify confirm a package_digest is anchored in the log.
|
|
7
|
+
*/
|
|
8
|
+
import type { PermanenceAnchor } from "@dot-skill/protocol";
|
|
9
|
+
export interface RegistryEntry {
|
|
10
|
+
kind: "registry_entry";
|
|
11
|
+
digest: string;
|
|
12
|
+
published_at: string;
|
|
13
|
+
metadata: Record<string, unknown>;
|
|
14
|
+
}
|
|
15
|
+
export interface RegistryPublishResult {
|
|
16
|
+
ok: boolean;
|
|
17
|
+
entry: RegistryEntry;
|
|
18
|
+
log_path: string;
|
|
19
|
+
}
|
|
20
|
+
export interface RegistryLookupResult {
|
|
21
|
+
found: boolean;
|
|
22
|
+
entries: RegistryEntry[];
|
|
23
|
+
}
|
|
24
|
+
export interface RegistryVerifyResult {
|
|
25
|
+
ok: boolean;
|
|
26
|
+
anchored: boolean;
|
|
27
|
+
entries: RegistryEntry[];
|
|
28
|
+
anchor?: PermanenceAnchor;
|
|
29
|
+
issues: string[];
|
|
30
|
+
}
|
|
31
|
+
/**
|
|
32
|
+
* Publish a package digest to the local transparency log.
|
|
33
|
+
* Creates the log file and parent directories if they do not exist.
|
|
34
|
+
*/
|
|
35
|
+
export declare function publish(digest: string, metadata?: Record<string, unknown>, logPath?: string): Promise<RegistryPublishResult>;
|
|
36
|
+
/**
|
|
37
|
+
* Look up all log entries for a given digest.
|
|
38
|
+
*/
|
|
39
|
+
export declare function lookup(digest: string, logPath?: string): Promise<RegistryLookupResult>;
|
|
40
|
+
/**
|
|
41
|
+
* List all entries in the log (most recent last).
|
|
42
|
+
*/
|
|
43
|
+
export declare function list(logPath?: string, limit?: number): Promise<RegistryEntry[]>;
|
|
44
|
+
/**
|
|
45
|
+
* Verify that a `.skill` package archive has a matching entry in the transparency log
|
|
46
|
+
* and/or a PermanenceAnchor of kind "transparency_log" or "registry".
|
|
47
|
+
*/
|
|
48
|
+
export declare function verify(archive: Uint8Array, logPath?: string): Promise<RegistryVerifyResult>;
|
|
49
|
+
/**
|
|
50
|
+
* Build a PermanenceAnchor pointing to the local transparency log.
|
|
51
|
+
* Use with addPermanenceAnchor from @dot-skill/core to embed the anchor in the package.
|
|
52
|
+
*/
|
|
53
|
+
export declare function buildTransparencyLogAnchor(digest: string, logPath?: string): Omit<PermanenceAnchor, "package_digest">;
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,115 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @dot-skill/registry — free append-only transparency log for `.skill` packages.
|
|
3
|
+
*
|
|
4
|
+
* Default log path: ~/.dot-skill/registry/log.jsonl
|
|
5
|
+
* Each line is a JSON object with a publish record.
|
|
6
|
+
* Lookup and verify confirm a package_digest is anchored in the log.
|
|
7
|
+
*/
|
|
8
|
+
import { appendFile, readFile, mkdir } from "node:fs/promises";
|
|
9
|
+
import { existsSync } from "node:fs";
|
|
10
|
+
import { join } from "node:path";
|
|
11
|
+
import { homedir } from "node:os";
|
|
12
|
+
import { unpackSkill } from "@dot-skill/core";
|
|
13
|
+
function defaultLogPath() {
|
|
14
|
+
return join(homedir(), ".dot-skill", "registry", "log.jsonl");
|
|
15
|
+
}
|
|
16
|
+
async function ensureDir(filePath) {
|
|
17
|
+
const dir = filePath.slice(0, filePath.lastIndexOf("/"));
|
|
18
|
+
if (!existsSync(dir)) {
|
|
19
|
+
await mkdir(dir, { recursive: true });
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Publish a package digest to the local transparency log.
|
|
24
|
+
* Creates the log file and parent directories if they do not exist.
|
|
25
|
+
*/
|
|
26
|
+
export async function publish(digest, metadata = {}, logPath) {
|
|
27
|
+
const path = logPath ?? defaultLogPath();
|
|
28
|
+
await ensureDir(path);
|
|
29
|
+
const entry = {
|
|
30
|
+
kind: "registry_entry",
|
|
31
|
+
digest,
|
|
32
|
+
published_at: new Date().toISOString(),
|
|
33
|
+
metadata,
|
|
34
|
+
};
|
|
35
|
+
await appendFile(path, JSON.stringify(entry) + "\n", "utf8");
|
|
36
|
+
return { ok: true, entry, log_path: path };
|
|
37
|
+
}
|
|
38
|
+
/**
|
|
39
|
+
* Look up all log entries for a given digest.
|
|
40
|
+
*/
|
|
41
|
+
export async function lookup(digest, logPath) {
|
|
42
|
+
const path = logPath ?? defaultLogPath();
|
|
43
|
+
if (!existsSync(path)) {
|
|
44
|
+
return { found: false, entries: [] };
|
|
45
|
+
}
|
|
46
|
+
const raw = await readFile(path, "utf8");
|
|
47
|
+
const entries = raw
|
|
48
|
+
.split("\n")
|
|
49
|
+
.filter(Boolean)
|
|
50
|
+
.map((line) => JSON.parse(line))
|
|
51
|
+
.filter((e) => e.digest === digest);
|
|
52
|
+
return { found: entries.length > 0, entries };
|
|
53
|
+
}
|
|
54
|
+
/**
|
|
55
|
+
* List all entries in the log (most recent last).
|
|
56
|
+
*/
|
|
57
|
+
export async function list(logPath, limit = 50) {
|
|
58
|
+
const path = logPath ?? defaultLogPath();
|
|
59
|
+
if (!existsSync(path))
|
|
60
|
+
return [];
|
|
61
|
+
const raw = await readFile(path, "utf8");
|
|
62
|
+
const all = raw
|
|
63
|
+
.split("\n")
|
|
64
|
+
.filter(Boolean)
|
|
65
|
+
.map((line) => JSON.parse(line));
|
|
66
|
+
return all.slice(-limit);
|
|
67
|
+
}
|
|
68
|
+
/**
|
|
69
|
+
* Verify that a `.skill` package archive has a matching entry in the transparency log
|
|
70
|
+
* and/or a PermanenceAnchor of kind "transparency_log" or "registry".
|
|
71
|
+
*/
|
|
72
|
+
export async function verify(archive, logPath) {
|
|
73
|
+
const issues = [];
|
|
74
|
+
let unpacked;
|
|
75
|
+
try {
|
|
76
|
+
unpacked = unpackSkill(archive);
|
|
77
|
+
}
|
|
78
|
+
catch (e) {
|
|
79
|
+
return {
|
|
80
|
+
ok: false,
|
|
81
|
+
anchored: false,
|
|
82
|
+
entries: [],
|
|
83
|
+
issues: [e instanceof Error ? e.message : String(e)],
|
|
84
|
+
};
|
|
85
|
+
}
|
|
86
|
+
const digest = unpacked.manifest.package_digest;
|
|
87
|
+
const { found, entries } = await lookup(digest, logPath);
|
|
88
|
+
const anchors = unpacked.manifest.anchors ?? [];
|
|
89
|
+
const registryAnchor = anchors.find((a) => a.kind === "transparency_log" || a.kind === "registry");
|
|
90
|
+
if (!found) {
|
|
91
|
+
issues.push(`Digest ${digest} not found in transparency log`);
|
|
92
|
+
}
|
|
93
|
+
if (!registryAnchor) {
|
|
94
|
+
issues.push("No transparency_log or registry PermanenceAnchor in manifest");
|
|
95
|
+
}
|
|
96
|
+
return {
|
|
97
|
+
ok: found && Boolean(registryAnchor),
|
|
98
|
+
anchored: found || Boolean(registryAnchor),
|
|
99
|
+
entries,
|
|
100
|
+
anchor: registryAnchor,
|
|
101
|
+
issues,
|
|
102
|
+
};
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Build a PermanenceAnchor pointing to the local transparency log.
|
|
106
|
+
* Use with addPermanenceAnchor from @dot-skill/core to embed the anchor in the package.
|
|
107
|
+
*/
|
|
108
|
+
export function buildTransparencyLogAnchor(digest, logPath) {
|
|
109
|
+
return {
|
|
110
|
+
kind: "transparency_log",
|
|
111
|
+
located_at: `file://${logPath ?? defaultLogPath()}`,
|
|
112
|
+
anchored_at: new Date().toISOString(),
|
|
113
|
+
issuer: "@dot-skill/registry",
|
|
114
|
+
};
|
|
115
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@dot-skill/registry",
|
|
3
|
+
"version": "0.4.1",
|
|
4
|
+
"description": "Optional local transparency log (not a marketplace)",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"author": {
|
|
7
|
+
"name": "Bharat Dudeja",
|
|
8
|
+
"url": "https://github.com/bharatdudeja13-cmd"
|
|
9
|
+
},
|
|
10
|
+
"type": "module",
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"publishConfig": {
|
|
14
|
+
"access": "public"
|
|
15
|
+
},
|
|
16
|
+
"repository": {
|
|
17
|
+
"type": "git",
|
|
18
|
+
"url": "https://github.com/dot-skill/dot-skill.git",
|
|
19
|
+
"directory": "packages/registry"
|
|
20
|
+
},
|
|
21
|
+
"files": [
|
|
22
|
+
"dist"
|
|
23
|
+
],
|
|
24
|
+
"exports": {
|
|
25
|
+
".": {
|
|
26
|
+
"import": "./dist/index.js",
|
|
27
|
+
"types": "./dist/index.d.ts"
|
|
28
|
+
}
|
|
29
|
+
},
|
|
30
|
+
"scripts": {
|
|
31
|
+
"build": "rm -rf dist && tsc",
|
|
32
|
+
"prepack": "npm run build",
|
|
33
|
+
"clean": "rm -rf dist"
|
|
34
|
+
},
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@dot-skill/core": "^0.4.1",
|
|
37
|
+
"@dot-skill/protocol": "^0.4.1"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"@types/node": "^26.1.1",
|
|
41
|
+
"typescript": "^5.4.5"
|
|
42
|
+
}
|
|
43
|
+
}
|