@zcloak/ai-agent 1.0.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 +5 -0
- package/dist/bind.d.ts +22 -0
- package/dist/bind.js +145 -0
- package/dist/bind.js.map +1 -0
- package/dist/cli.d.ts +31 -0
- package/dist/cli.js +126 -0
- package/dist/cli.js.map +1 -0
- package/dist/config.d.ts +14 -0
- package/dist/config.js +34 -0
- package/dist/config.js.map +1 -0
- package/dist/crypto.d.ts +113 -0
- package/dist/crypto.js +252 -0
- package/dist/crypto.js.map +1 -0
- package/dist/daemon.d.ts +94 -0
- package/dist/daemon.js +271 -0
- package/dist/daemon.js.map +1 -0
- package/dist/delete.d.ts +22 -0
- package/dist/delete.js +231 -0
- package/dist/delete.js.map +1 -0
- package/dist/doc.d.ts +23 -0
- package/dist/doc.js +180 -0
- package/dist/doc.js.map +1 -0
- package/dist/error.d.ts +45 -0
- package/dist/error.js +79 -0
- package/dist/error.js.map +1 -0
- package/dist/feed.d.ts +20 -0
- package/dist/feed.js +83 -0
- package/dist/feed.js.map +1 -0
- package/dist/identity.d.ts +50 -0
- package/dist/identity.js +99 -0
- package/dist/identity.js.map +1 -0
- package/dist/identity_cmd.d.ts +23 -0
- package/dist/identity_cmd.js +136 -0
- package/dist/identity_cmd.js.map +1 -0
- package/dist/idl.d.ts +99 -0
- package/dist/idl.js +213 -0
- package/dist/idl.js.map +1 -0
- package/dist/key-store.d.ts +88 -0
- package/dist/key-store.js +171 -0
- package/dist/key-store.js.map +1 -0
- package/dist/pow.d.ts +24 -0
- package/dist/pow.js +86 -0
- package/dist/pow.js.map +1 -0
- package/dist/register.d.ts +24 -0
- package/dist/register.js +191 -0
- package/dist/register.js.map +1 -0
- package/dist/rpc.d.ts +107 -0
- package/dist/rpc.js +60 -0
- package/dist/rpc.js.map +1 -0
- package/dist/serve.d.ts +55 -0
- package/dist/serve.js +455 -0
- package/dist/serve.js.map +1 -0
- package/dist/session.d.ts +104 -0
- package/dist/session.js +189 -0
- package/dist/session.js.map +1 -0
- package/dist/sign.d.ts +33 -0
- package/dist/sign.js +355 -0
- package/dist/sign.js.map +1 -0
- package/dist/types/common.d.ts +63 -0
- package/dist/types/common.js +8 -0
- package/dist/types/common.js.map +1 -0
- package/dist/types/config.d.ts +28 -0
- package/dist/types/config.js +8 -0
- package/dist/types/config.js.map +1 -0
- package/dist/types/registry.d.ts +72 -0
- package/dist/types/registry.js +13 -0
- package/dist/types/registry.js.map +1 -0
- package/dist/types/sign-event.d.ts +134 -0
- package/dist/types/sign-event.js +13 -0
- package/dist/types/sign-event.js.map +1 -0
- package/dist/utils.d.ts +113 -0
- package/dist/utils.js +382 -0
- package/dist/utils.js.map +1 -0
- package/dist/verify.d.ts +23 -0
- package/dist/verify.js +207 -0
- package/dist/verify.js.map +1 -0
- package/dist/vetkey.d.ts +27 -0
- package/dist/vetkey.js +507 -0
- package/dist/vetkey.js.map +1 -0
- package/package.json +55 -0
package/README.md
ADDED
package/dist/bind.d.ts
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* zCloak.ai Agent-Owner Binding Tool
|
|
4
|
+
*
|
|
5
|
+
* Executes the agent-owner WebAuthn/passkey binding flow.
|
|
6
|
+
* Automatically calls agent_prepare_bond and generates browser authentication URL.
|
|
7
|
+
* Includes passkey pre-check to ensure the target user has a registered passkey.
|
|
8
|
+
* Uses @dfinity JS SDK to interact directly with ICP canister, no dfx required.
|
|
9
|
+
*
|
|
10
|
+
* Usage:
|
|
11
|
+
* zcloak-ai bind prepare <user_principal> Prepare binding and generate authentication URL
|
|
12
|
+
* zcloak-ai bind check-passkey <user_principal> Check if a principal has a registered passkey
|
|
13
|
+
*
|
|
14
|
+
* All commands support --identity=<pem_path> to specify identity file.
|
|
15
|
+
*/
|
|
16
|
+
import { Session } from './session';
|
|
17
|
+
/**
|
|
18
|
+
* Entry point when invoked via cli.ts.
|
|
19
|
+
* Receives a Session instance with pre-parsed arguments.
|
|
20
|
+
*/
|
|
21
|
+
export declare function run(session: Session): Promise<void>;
|
|
22
|
+
//# sourceMappingURL=bind.d.ts.map
|
package/dist/bind.js
ADDED
|
@@ -0,0 +1,145 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* zCloak.ai Agent-Owner Binding Tool
|
|
5
|
+
*
|
|
6
|
+
* Executes the agent-owner WebAuthn/passkey binding flow.
|
|
7
|
+
* Automatically calls agent_prepare_bond and generates browser authentication URL.
|
|
8
|
+
* Includes passkey pre-check to ensure the target user has a registered passkey.
|
|
9
|
+
* Uses @dfinity JS SDK to interact directly with ICP canister, no dfx required.
|
|
10
|
+
*
|
|
11
|
+
* Usage:
|
|
12
|
+
* zcloak-ai bind prepare <user_principal> Prepare binding and generate authentication URL
|
|
13
|
+
* zcloak-ai bind check-passkey <user_principal> Check if a principal has a registered passkey
|
|
14
|
+
*
|
|
15
|
+
* All commands support --identity=<pem_path> to specify identity file.
|
|
16
|
+
*/
|
|
17
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
18
|
+
exports.run = run;
|
|
19
|
+
// ========== Help Information ==========
|
|
20
|
+
function showHelp() {
|
|
21
|
+
console.log('zCloak.ai Agent-Owner Binding Tool');
|
|
22
|
+
console.log('');
|
|
23
|
+
console.log('Usage:');
|
|
24
|
+
console.log(' zcloak-ai bind prepare <user_principal> Prepare binding and generate authentication URL');
|
|
25
|
+
console.log(' zcloak-ai bind check-passkey <user_principal> Check if a principal has a registered passkey');
|
|
26
|
+
console.log('');
|
|
27
|
+
console.log('Options:');
|
|
28
|
+
console.log(' --identity=<pem_path> Specify identity PEM file');
|
|
29
|
+
console.log('');
|
|
30
|
+
console.log('Flow:');
|
|
31
|
+
console.log(' 1. Script checks if target principal has a registered passkey (pre-check)');
|
|
32
|
+
console.log(' 2. Script calls agent_prepare_bond to get WebAuthn challenge');
|
|
33
|
+
console.log(' 3. Script generates authentication URL');
|
|
34
|
+
console.log(' 4. User opens the URL in browser and completes authentication with passkey');
|
|
35
|
+
console.log('');
|
|
36
|
+
console.log('Examples:');
|
|
37
|
+
console.log(' zcloak-ai bind prepare "57odc-ymip7-b7edu-aevpq-nu54m-q4paq-vsrtd-nlnmm-lkos3-d4h3t-7qe"');
|
|
38
|
+
console.log(' zcloak-ai bind check-passkey "57odc-ymip7-b7edu-aevpq-nu54m-q4paq-vsrtd-nlnmm-lkos3-d4h3t-7qe"');
|
|
39
|
+
}
|
|
40
|
+
// ========== Passkey Pre-check Helper ==========
|
|
41
|
+
/**
|
|
42
|
+
* Check if a principal has a registered passkey via user_profile_get_by_principal.
|
|
43
|
+
* Returns true if the user has at least one passkey, false otherwise.
|
|
44
|
+
* Throws if the principal is not found in the registry.
|
|
45
|
+
*/
|
|
46
|
+
async function hasPasskey(session, userPrincipal) {
|
|
47
|
+
const actor = await session.getAnonymousRegistryActor();
|
|
48
|
+
const profile = await actor.user_profile_get_by_principal(userPrincipal);
|
|
49
|
+
// opt UserProfile — empty array means no profile found
|
|
50
|
+
if (!profile || profile.length === 0) {
|
|
51
|
+
throw new Error(`No user profile found for principal: ${userPrincipal}`);
|
|
52
|
+
}
|
|
53
|
+
const user = profile[0];
|
|
54
|
+
// passkey_name is a vec text — empty vec means no passkey registered
|
|
55
|
+
return user.passkey_name.length > 0;
|
|
56
|
+
}
|
|
57
|
+
// ========== Command Implementations ==========
|
|
58
|
+
/** Check if a principal has a registered passkey (standalone command) */
|
|
59
|
+
async function cmdCheckPasskey(session, userPrincipal) {
|
|
60
|
+
if (!userPrincipal) {
|
|
61
|
+
console.error('Error: user principal ID is required');
|
|
62
|
+
console.error('Usage: zcloak-ai bind check-passkey <user_principal>');
|
|
63
|
+
process.exit(1);
|
|
64
|
+
}
|
|
65
|
+
console.error('Checking passkey status...');
|
|
66
|
+
const result = await hasPasskey(session, userPrincipal);
|
|
67
|
+
if (result) {
|
|
68
|
+
console.log('Passkey registered: yes');
|
|
69
|
+
console.log('This principal is ready for agent binding.');
|
|
70
|
+
}
|
|
71
|
+
else {
|
|
72
|
+
console.log('Passkey registered: no');
|
|
73
|
+
console.log('');
|
|
74
|
+
console.log('This principal was created via OAuth and has no passkey yet.');
|
|
75
|
+
console.log('Please go to https://id.zcloak.xyz/setting and bind a passkey first.');
|
|
76
|
+
}
|
|
77
|
+
}
|
|
78
|
+
/** Prepare binding and generate authentication URL */
|
|
79
|
+
async function cmdPrepare(session, userPrincipal) {
|
|
80
|
+
if (!userPrincipal) {
|
|
81
|
+
console.error('Error: user principal ID is required');
|
|
82
|
+
console.error('Usage: zcloak-ai bind prepare <user_principal>');
|
|
83
|
+
process.exit(1);
|
|
84
|
+
}
|
|
85
|
+
// Pre-check: ensure the target principal has a passkey before proceeding
|
|
86
|
+
console.error('Pre-check: verifying passkey status...');
|
|
87
|
+
const passkeyOk = await hasPasskey(session, userPrincipal);
|
|
88
|
+
if (!passkeyOk) {
|
|
89
|
+
console.error('Error: target principal has no passkey registered.');
|
|
90
|
+
console.error('This principal was created via OAuth and has no passkey yet.');
|
|
91
|
+
console.error('Please go to https://id.zcloak.xyz/setting and bind a passkey for this user first.');
|
|
92
|
+
process.exit(1);
|
|
93
|
+
}
|
|
94
|
+
console.error('Pre-check passed: passkey found.');
|
|
95
|
+
const bindBase = session.getBindUrl();
|
|
96
|
+
// Step 1: Call agent_prepare_bond (requires identity, update call)
|
|
97
|
+
console.error('Calling agent_prepare_bond...');
|
|
98
|
+
const actor = await session.getRegistryActor();
|
|
99
|
+
const result = await actor.agent_prepare_bond(userPrincipal);
|
|
100
|
+
// Check return result — variant { Ok: text } | { Err: text }
|
|
101
|
+
if ('Err' in result) {
|
|
102
|
+
console.error('Binding preparation failed:');
|
|
103
|
+
console.log(`(variant { Err = "${result.Err}" })`);
|
|
104
|
+
process.exit(1);
|
|
105
|
+
}
|
|
106
|
+
// Step 2: Extract JSON and generate URL
|
|
107
|
+
const authContent = result.Ok;
|
|
108
|
+
// Step 3: Build URL
|
|
109
|
+
const url = `${bindBase}?auth_content=${encodeURIComponent(authContent)}`;
|
|
110
|
+
console.log('');
|
|
111
|
+
console.log('=== Binding Authentication URL ===');
|
|
112
|
+
console.log('');
|
|
113
|
+
console.log(url);
|
|
114
|
+
console.log('');
|
|
115
|
+
console.log('Please open the URL above in your browser and complete authentication with passkey.');
|
|
116
|
+
}
|
|
117
|
+
// ========== Exported run() — called by cli.ts ==========
|
|
118
|
+
/**
|
|
119
|
+
* Entry point when invoked via cli.ts.
|
|
120
|
+
* Receives a Session instance with pre-parsed arguments.
|
|
121
|
+
*/
|
|
122
|
+
async function run(session) {
|
|
123
|
+
const command = session.args._args[0];
|
|
124
|
+
try {
|
|
125
|
+
switch (command) {
|
|
126
|
+
case 'prepare':
|
|
127
|
+
await cmdPrepare(session, session.args._args[1]);
|
|
128
|
+
break;
|
|
129
|
+
case 'check-passkey':
|
|
130
|
+
await cmdCheckPasskey(session, session.args._args[1]);
|
|
131
|
+
break;
|
|
132
|
+
default:
|
|
133
|
+
showHelp();
|
|
134
|
+
if (command) {
|
|
135
|
+
console.error(`\nUnknown command: ${command}`);
|
|
136
|
+
}
|
|
137
|
+
process.exit(1);
|
|
138
|
+
}
|
|
139
|
+
}
|
|
140
|
+
catch (err) {
|
|
141
|
+
console.error(`Operation failed: ${err instanceof Error ? err.message : String(err)}`);
|
|
142
|
+
process.exit(1);
|
|
143
|
+
}
|
|
144
|
+
}
|
|
145
|
+
//# sourceMappingURL=bind.js.map
|
package/dist/bind.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"bind.js","sourceRoot":"","sources":["../src/bind.ts"],"names":[],"mappings":";;AACA;;;;;;;;;;;;;GAaG;;AA4HH,kBAsBC;AA9ID,yCAAyC;AACzC,SAAS,QAAQ;IACf,OAAO,CAAC,GAAG,CAAC,oCAAoC,CAAC,CAAC;IAClD,OAAO,CAAC,GAAG,CAAC,EAAE,CAAC,CAA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CAAC,EAAE,CAAC,CAAC;IAChB,OAAO,CAAC,GAAG,CAAC,qFAAqF,CAAC,CAAC;AACrG,CAAC;AAED,0DAA0D;AAE1D;;;GAGG;AACI,KAAK,UAAU,GAAG,CAAC,OAAgB;IACxC,MAAM,OAAO,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;IAEtC,IAAI,CAAC;QACH,QAAQ,OAAO,EAAE,CAAC;YAChB,KAAK,SAAS;gBACZ,MAAM,UAAU,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBACjD,MAAM;YACR,KAAK,eAAe;gBAClB,MAAM,eAAe,CAAC,OAAO,EAAE,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;gBACtD,MAAM;YACR;gBACE,QAAQ,EAAE,CAAC;gBACX,IAAI,OAAO,EAAE,CAAC;oBACZ,OAAO,CAAC,KAAK,CAAC,sBAAsB,OAAO,EAAE,CAAC,CAAC;gBACjD,CAAC;gBACD,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;QACpB,CAAC;IACH,CAAC;IAAC,OAAO,GAAG,EAAE,CAAC;QACb,OAAO,CAAC,KAAK,CAAC,qBAAqB,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;QACvF,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;AACH,CAAC"}
|
package/dist/cli.d.ts
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
/**
|
|
3
|
+
* zCloak.ai Agent CLI
|
|
4
|
+
*
|
|
5
|
+
* Unified command entry point. After installation, invoke via `zcloak-ai <module> <command> [args]`.
|
|
6
|
+
*
|
|
7
|
+
* Usage:
|
|
8
|
+
* zcloak-ai identity <command> [args] Identity key management (generate PEM, show principal)
|
|
9
|
+
* zcloak-ai register <command> [args] Registration management
|
|
10
|
+
* zcloak-ai sign <command> [args] Signing operations
|
|
11
|
+
* zcloak-ai verify <command> [args] Verification operations
|
|
12
|
+
* zcloak-ai feed <command> [args] Event queries
|
|
13
|
+
* zcloak-ai bind <command> [args] Agent-Owner binding
|
|
14
|
+
* zcloak-ai doc <command> [args] Document tools
|
|
15
|
+
* zcloak-ai pow <base> <zeros> PoW computation
|
|
16
|
+
* zcloak-ai vetkey <command> [args] VetKey encryption/decryption and daemon
|
|
17
|
+
*
|
|
18
|
+
* Architecture:
|
|
19
|
+
* cli.ts creates a Session from a constructed sub-argv array and passes it
|
|
20
|
+
* to the sub-script's run(session) function. This eliminates the previous
|
|
21
|
+
* process.argv rewriting (global mutable state) while preserving the same
|
|
22
|
+
* argument-parsing behavior in each sub-script.
|
|
23
|
+
*
|
|
24
|
+
* Examples:
|
|
25
|
+
* zcloak-ai register get-principal
|
|
26
|
+
* zcloak-ai sign post "Hello world!" --sub=web3
|
|
27
|
+
* zcloak-ai feed counter
|
|
28
|
+
* zcloak-ai verify file ./report.pdf
|
|
29
|
+
*/
|
|
30
|
+
export {};
|
|
31
|
+
//# sourceMappingURL=cli.d.ts.map
|
package/dist/cli.js
ADDED
|
@@ -0,0 +1,126 @@
|
|
|
1
|
+
#!/usr/bin/env node
|
|
2
|
+
"use strict";
|
|
3
|
+
/**
|
|
4
|
+
* zCloak.ai Agent CLI
|
|
5
|
+
*
|
|
6
|
+
* Unified command entry point. After installation, invoke via `zcloak-ai <module> <command> [args]`.
|
|
7
|
+
*
|
|
8
|
+
* Usage:
|
|
9
|
+
* zcloak-ai identity <command> [args] Identity key management (generate PEM, show principal)
|
|
10
|
+
* zcloak-ai register <command> [args] Registration management
|
|
11
|
+
* zcloak-ai sign <command> [args] Signing operations
|
|
12
|
+
* zcloak-ai verify <command> [args] Verification operations
|
|
13
|
+
* zcloak-ai feed <command> [args] Event queries
|
|
14
|
+
* zcloak-ai bind <command> [args] Agent-Owner binding
|
|
15
|
+
* zcloak-ai doc <command> [args] Document tools
|
|
16
|
+
* zcloak-ai pow <base> <zeros> PoW computation
|
|
17
|
+
* zcloak-ai vetkey <command> [args] VetKey encryption/decryption and daemon
|
|
18
|
+
*
|
|
19
|
+
* Architecture:
|
|
20
|
+
* cli.ts creates a Session from a constructed sub-argv array and passes it
|
|
21
|
+
* to the sub-script's run(session) function. This eliminates the previous
|
|
22
|
+
* process.argv rewriting (global mutable state) while preserving the same
|
|
23
|
+
* argument-parsing behavior in each sub-script.
|
|
24
|
+
*
|
|
25
|
+
* Examples:
|
|
26
|
+
* zcloak-ai register get-principal
|
|
27
|
+
* zcloak-ai sign post "Hello world!" --sub=web3
|
|
28
|
+
* zcloak-ai feed counter
|
|
29
|
+
* zcloak-ai verify file ./report.pdf
|
|
30
|
+
*/
|
|
31
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
32
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
33
|
+
};
|
|
34
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
35
|
+
const path_1 = __importDefault(require("path"));
|
|
36
|
+
const session_1 = require("./session");
|
|
37
|
+
/** Supported modules and their corresponding script files (compiled in dist/ directory) */
|
|
38
|
+
const MODULES = {
|
|
39
|
+
identity: 'identity_cmd',
|
|
40
|
+
register: 'register',
|
|
41
|
+
sign: 'sign',
|
|
42
|
+
verify: 'verify',
|
|
43
|
+
feed: 'feed',
|
|
44
|
+
bind: 'bind',
|
|
45
|
+
delete: 'delete',
|
|
46
|
+
doc: 'doc',
|
|
47
|
+
pow: 'pow',
|
|
48
|
+
vetkey: 'vetkey',
|
|
49
|
+
};
|
|
50
|
+
function showHelp() {
|
|
51
|
+
console.log('zCloak.ai Agent CLI');
|
|
52
|
+
console.log('');
|
|
53
|
+
console.log('Usage: zcloak-ai <module> <command> [args] [options]');
|
|
54
|
+
console.log('');
|
|
55
|
+
console.log('Modules:');
|
|
56
|
+
console.log(' identity Identity key management (generate, show)');
|
|
57
|
+
console.log(' register Registration management (get-principal, lookup, register, ...)');
|
|
58
|
+
console.log(' sign Signing operations (post, like, reply, profile, sign-file, ...)');
|
|
59
|
+
console.log(' verify Verification operations (message, file, folder, profile)');
|
|
60
|
+
console.log(' feed Event queries (counter, fetch)');
|
|
61
|
+
console.log(' bind Agent-Owner binding (prepare, check-passkey)');
|
|
62
|
+
console.log(' delete File deletion with 2FA verification (prepare, check, confirm)');
|
|
63
|
+
console.log(' doc Document tools (manifest, verify-manifest, hash, info)');
|
|
64
|
+
console.log(' pow PoW computation (<base_string> <zeros>)');
|
|
65
|
+
console.log(' vetkey VetKey encryption/decryption (encrypt-sign, decrypt, serve, ...)');
|
|
66
|
+
console.log('');
|
|
67
|
+
console.log('Global options:');
|
|
68
|
+
console.log(' --identity=<pem_path> Specify identity PEM file');
|
|
69
|
+
console.log('');
|
|
70
|
+
console.log('Examples:');
|
|
71
|
+
console.log(' zcloak-ai register get-principal');
|
|
72
|
+
console.log(' zcloak-ai sign post "Hello world!" --sub=web3 --tags=t:crypto');
|
|
73
|
+
console.log(' zcloak-ai feed counter');
|
|
74
|
+
console.log(' zcloak-ai verify file ./report.pdf');
|
|
75
|
+
console.log(' zcloak-ai doc hash ./report.pdf');
|
|
76
|
+
console.log('');
|
|
77
|
+
console.log('Module help:');
|
|
78
|
+
console.log(' zcloak-ai <module> (run without command to show module help)');
|
|
79
|
+
}
|
|
80
|
+
/**
|
|
81
|
+
* CLI entry point.
|
|
82
|
+
*
|
|
83
|
+
* Instead of rewriting process.argv (global mutable state), we construct a
|
|
84
|
+
* synthetic sub-argv array that looks like what the sub-script would see if
|
|
85
|
+
* invoked directly, and pass it via a Session instance.
|
|
86
|
+
*
|
|
87
|
+
* Original process.argv: ['node', 'cli.js', 'register', 'get-principal']
|
|
88
|
+
* Constructed sub-argv: ['node', 'register.js', 'get-principal']
|
|
89
|
+
*
|
|
90
|
+
* The Session constructor calls parseArgs(subArgv) which skips [0] and [1],
|
|
91
|
+
* so the sub-script receives the same parsed arguments as before.
|
|
92
|
+
*/
|
|
93
|
+
async function main() {
|
|
94
|
+
// Get module name (skip node and script path)
|
|
95
|
+
const moduleName = process.argv[2];
|
|
96
|
+
if (!moduleName || moduleName === '--help' || moduleName === '-h') {
|
|
97
|
+
showHelp();
|
|
98
|
+
process.exit(0);
|
|
99
|
+
}
|
|
100
|
+
// Find the corresponding script
|
|
101
|
+
const scriptFile = MODULES[moduleName];
|
|
102
|
+
if (!scriptFile) {
|
|
103
|
+
console.error(`Unknown module: ${moduleName}`);
|
|
104
|
+
console.error('');
|
|
105
|
+
console.error('Available modules: ' + Object.keys(MODULES).join(', '));
|
|
106
|
+
console.error('Run zcloak-ai --help for help');
|
|
107
|
+
process.exit(1);
|
|
108
|
+
}
|
|
109
|
+
// Construct sub-argv without mutating process.argv.
|
|
110
|
+
// Format: [node_binary, script_path, ...remaining_args]
|
|
111
|
+
// This preserves the same index layout that parseArgs() expects (skips first 2 elements).
|
|
112
|
+
const scriptPath = path_1.default.join(__dirname, scriptFile);
|
|
113
|
+
const subArgv = [process.argv[0], scriptPath, ...process.argv.slice(3)];
|
|
114
|
+
// Create a Session from the constructed argv
|
|
115
|
+
const session = new session_1.Session(subArgv);
|
|
116
|
+
// Load and execute sub-script's run() function.
|
|
117
|
+
// After compilation, __dirname points to dist/, sub-scripts are in the same directory.
|
|
118
|
+
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
119
|
+
const mod = require(scriptPath);
|
|
120
|
+
await mod.run(session);
|
|
121
|
+
}
|
|
122
|
+
main().catch((err) => {
|
|
123
|
+
console.error(`Error: ${err instanceof Error ? err.message : String(err)}`);
|
|
124
|
+
process.exit(1);
|
|
125
|
+
});
|
|
126
|
+
//# sourceMappingURL=cli.js.map
|
package/dist/cli.js.map
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cli.js","sourceRoot":"","sources":["../src/cli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CAAC;QACvE,OAAO,CAAC,KAAK,CAAC,+BAA+B,CAAC,CAAC;QAC/C,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;IAClB,CAAC;IAED,oDAAoD;IACpD,wDAAwD;IACxD,0FAA0F;IAC1F,MAAM,UAAU,GAAG,cAAI,CAAC,IAAI,CAAC,SAAS,EAAE,UAAU,CAAC,CAAC;IACpD,MAAM,OAAO,GAAG,CAAC,OAAO,CAAC,IAAI,CAAC,CAAC,CAAE,EAAE,UAAU,EAAE,GAAG,OAAO,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;IAEzE,6CAA6C;IAC7C,MAAM,OAAO,GAAG,IAAI,iBAAO,CAAC,OAAO,CAAC,CAAC;IAErC,gDAAgD;IAChD,uFAAuF;IACvF,iEAAiE;IACjE,MAAM,GAAG,GAAG,OAAO,CAAC,UAAU,CAAC,CAAC;IAChC,MAAM,GAAG,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;AACzB,CAAC;AAED,IAAI,EAAE,CAAC,KAAK,CAAC,CAAC,GAAY,EAAE,EAAE;IAC5B,OAAO,CAAC,KAAK,CAAC,UAAU,GAAG,YAAY,KAAK,CAAC,CAAC,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC,CAAC,MAAM,CAAC,GAAG,CAAC,EAAE,CAAC,CAAC;IAC5E,OAAO,CAAC,IAAI,CAAC,CAAC,CAAC,CAAC;AAClB,CAAC,CAAC,CAAC"}
|
package/dist/config.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* zCloak.ai Application Configuration
|
|
3
|
+
*
|
|
4
|
+
* Contains canister IDs and related URL configurations.
|
|
5
|
+
* All scripts obtain configuration through this file.
|
|
6
|
+
*/
|
|
7
|
+
import type { AppConfig, CanisterIds } from './types/config';
|
|
8
|
+
declare const config: AppConfig;
|
|
9
|
+
export default config;
|
|
10
|
+
/**
|
|
11
|
+
* Get canister ID configuration.
|
|
12
|
+
*/
|
|
13
|
+
export declare function getCanisterIds(): CanisterIds;
|
|
14
|
+
//# sourceMappingURL=config.d.ts.map
|
package/dist/config.js
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* zCloak.ai Application Configuration
|
|
4
|
+
*
|
|
5
|
+
* Contains canister IDs and related URL configurations.
|
|
6
|
+
* All scripts obtain configuration through this file.
|
|
7
|
+
*/
|
|
8
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
+
exports.getCanisterIds = getCanisterIds;
|
|
10
|
+
const config = {
|
|
11
|
+
// Canister IDs
|
|
12
|
+
canisterIds: {
|
|
13
|
+
registry: '3spie-caaaa-aaaam-ae3sa-cai', // Registry canister
|
|
14
|
+
signatures: 'zpbbm-piaaa-aaaaj-a3dsq-cai', // Signatures canister
|
|
15
|
+
},
|
|
16
|
+
// PoW required leading zeros count
|
|
17
|
+
pow_zeros: 5,
|
|
18
|
+
// Agent binding page URL
|
|
19
|
+
bind_url: 'https://id.zcloak.xyz/agent/bind',
|
|
20
|
+
// Agent profile page URL prefix
|
|
21
|
+
profile_url: 'https://id.zcloak.xyz/profile/',
|
|
22
|
+
// 2FA verification page URL
|
|
23
|
+
twofa_url: 'https://id.zcloak.xyz/agent/2fa',
|
|
24
|
+
// Event view page URL prefix (append event ID to form the full URL)
|
|
25
|
+
event_url: 'https://social.zcloak.xyz/post/',
|
|
26
|
+
};
|
|
27
|
+
exports.default = config;
|
|
28
|
+
/**
|
|
29
|
+
* Get canister ID configuration.
|
|
30
|
+
*/
|
|
31
|
+
function getCanisterIds() {
|
|
32
|
+
return config.canisterIds;
|
|
33
|
+
}
|
|
34
|
+
//# sourceMappingURL=config.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"config.js","sourceRoot":"","sources":["../src/config.ts"],"names":[],"mappings":";AAAA;;;;;GAKG;;AA2BH,wCAEC;AAzBD,MAAM,MAAM,GAAc;IACxB,eAAe;IACf,WAAW,EAAE;QACX,QAAQ,EAAE,6BAA6B,EAAK,oBAAoB;QAChE,UAAU,EAAE,6BAA6B,EAAG,sBAAsB;KACnE;IACD,mCAAmC;IACnC,SAAS,EAAE,CAAC;IACZ,yBAAyB;IACzB,QAAQ,EAAE,kCAAkC;IAC5C,gCAAgC;IAChC,WAAW,EAAE,gCAAgC;IAC7C,4BAA4B;IAC5B,SAAS,EAAE,iCAAiC;IAC5C,oEAAoE;IACpE,SAAS,EAAE,iCAAiC;CAC7C,CAAC;AAEF,kBAAe,MAAM,CAAC;AAEtB;;GAEG;AACH,SAAgB,cAAc;IAC5B,OAAO,MAAM,CAAC,WAAW,CAAC;AAC5B,CAAC"}
|
package/dist/crypto.d.ts
ADDED
|
@@ -0,0 +1,113 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Cryptographic Primitives for VetKey Operations
|
|
3
|
+
*
|
|
4
|
+
* Two categories of operations:
|
|
5
|
+
*
|
|
6
|
+
* 1. IBE (Identity-Based Encryption) — Uses @dfinity/vetkeys for BLS12-381 operations.
|
|
7
|
+
* Used for per-operation Kind5 PrivatePost encryption.
|
|
8
|
+
*
|
|
9
|
+
* 2. AES-256-GCM — Uses Node.js built-in crypto module.
|
|
10
|
+
* Used for daemon mode fast file encryption/decryption.
|
|
11
|
+
* VKDA binary format: [magic "VKDA":4B][version:1B][nonce:12B][ciphertext+GCM tag]
|
|
12
|
+
*
|
|
13
|
+
* All formats are byte-level compatible with the Rust vetkey-tool implementation.
|
|
14
|
+
*/
|
|
15
|
+
import { TransportSecretKey } from '@dfinity/vetkeys';
|
|
16
|
+
/**
|
|
17
|
+
* Generate an ephemeral transport key pair for secure VetKey delivery.
|
|
18
|
+
*
|
|
19
|
+
* The transport secret key is used to decrypt the EncryptedVetKey received
|
|
20
|
+
* from the canister. The public key is sent to the canister so it can
|
|
21
|
+
* encrypt the VetKey for this specific requester.
|
|
22
|
+
*
|
|
23
|
+
* @returns [transportSecretKey, transportPublicKeyBytes (48 bytes, compressed G1)]
|
|
24
|
+
*/
|
|
25
|
+
export declare function generateTransportKeypair(): [TransportSecretKey, Uint8Array];
|
|
26
|
+
/**
|
|
27
|
+
* IBE-encrypt plaintext using the derived public key and identity string.
|
|
28
|
+
*
|
|
29
|
+
* Uses the Fujisaki-Okamoto transform internally (handled by @dfinity/vetkeys).
|
|
30
|
+
* Output format: [header:8B][C1:96B][C2:32B][C3:plaintext_len+16B] (152 bytes overhead)
|
|
31
|
+
*
|
|
32
|
+
* @param dpkBytes - IBE derived public key (96 bytes, compressed G2 point)
|
|
33
|
+
* @param ibeIdentity - IBE identity string (e.g. "{principal}:{hash}:{timestamp}")
|
|
34
|
+
* @param plaintext - Data to encrypt
|
|
35
|
+
* @returns IBE ciphertext bytes
|
|
36
|
+
*/
|
|
37
|
+
export declare function ibeEncrypt(dpkBytes: Uint8Array, ibeIdentity: string, plaintext: Uint8Array): Uint8Array;
|
|
38
|
+
/**
|
|
39
|
+
* Full IBE decrypt: transport-decrypt VetKey, then IBE-decrypt ciphertext.
|
|
40
|
+
*
|
|
41
|
+
* Complete flow:
|
|
42
|
+
* 1. Deserialize EncryptedVetKey (192 bytes)
|
|
43
|
+
* 2. Transport-decrypt and verify BLS signature → VetKey
|
|
44
|
+
* 3. Deserialize IBE ciphertext
|
|
45
|
+
* 4. IBE-decrypt using VetKey → plaintext
|
|
46
|
+
*
|
|
47
|
+
* @param encryptedKeyBytes - Transport-encrypted VetKey (192 bytes)
|
|
48
|
+
* @param dpkBytes - IBE derived public key (96 bytes)
|
|
49
|
+
* @param ibeIdentity - IBE identity string
|
|
50
|
+
* @param ciphertextBytes - IBE ciphertext
|
|
51
|
+
* @param transportSecret - Transport secret key (for decrypting the VetKey)
|
|
52
|
+
* @returns Decrypted plaintext
|
|
53
|
+
*/
|
|
54
|
+
export declare function ibeDecrypt(encryptedKeyBytes: Uint8Array, dpkBytes: Uint8Array, ibeIdentity: string, ciphertextBytes: Uint8Array, transportSecret: TransportSecretKey): Uint8Array;
|
|
55
|
+
/**
|
|
56
|
+
* Transport-decrypt an EncryptedVetKey and return raw VetKey bytes.
|
|
57
|
+
*
|
|
58
|
+
* Used by daemon mode to obtain the VetKey for AES-256 key derivation.
|
|
59
|
+
* The derivation ID serves as the IBE identity in this context.
|
|
60
|
+
*
|
|
61
|
+
* @param encryptedKeyBytes - Transport-encrypted VetKey (192 bytes)
|
|
62
|
+
* @param dpkBytes - IBE derived public key (96 bytes)
|
|
63
|
+
* @param derivationId - Derivation ID string (used as IBE identity)
|
|
64
|
+
* @param transportSecret - Transport secret key
|
|
65
|
+
* @returns Raw VetKey bytes (48 bytes, compressed G1 point)
|
|
66
|
+
*/
|
|
67
|
+
export declare function decryptVetkey(encryptedKeyBytes: Uint8Array, dpkBytes: Uint8Array, derivationId: string, transportSecret: TransportSecretKey): Uint8Array;
|
|
68
|
+
/**
|
|
69
|
+
* Generate an IBE identity string for Kind5 PrivatePost.
|
|
70
|
+
*
|
|
71
|
+
* Format: "{principal}:{short_hash_16_hex}:{timestamp_ms}"
|
|
72
|
+
* - short_hash: first 16 hex chars of SHA-256(content)
|
|
73
|
+
* - timestamp_ms: current time in milliseconds
|
|
74
|
+
*
|
|
75
|
+
* Must match the Rust implementation exactly for cross-compatibility.
|
|
76
|
+
*
|
|
77
|
+
* @param principal - ICP principal text
|
|
78
|
+
* @param content - Content bytes to hash
|
|
79
|
+
* @returns IBE identity string
|
|
80
|
+
*/
|
|
81
|
+
export declare function makeIbeIdentity(principal: string, content: Uint8Array): string;
|
|
82
|
+
/**
|
|
83
|
+
* Derive an AES-256 key from VetKey bytes using HKDF-SHA256.
|
|
84
|
+
*
|
|
85
|
+
* Domain separator: "vetkey-aes256-file-encryption" (must match Rust implementation)
|
|
86
|
+
*
|
|
87
|
+
* @param vetkeyBytes - Raw VetKey bytes (48 bytes, compressed G1 point)
|
|
88
|
+
* @returns AES-256 key (32 bytes)
|
|
89
|
+
*/
|
|
90
|
+
export declare function vetkeyToAes256(vetkeyBytes: Uint8Array): Buffer;
|
|
91
|
+
/**
|
|
92
|
+
* Encrypt plaintext using AES-256-GCM in VKDA format.
|
|
93
|
+
*
|
|
94
|
+
* Output format: [magic "VKDA":4B][version 0x01:1B][nonce:12B][ciphertext+GCM tag]
|
|
95
|
+
* This format is byte-level compatible with the Rust vetkey-tool implementation.
|
|
96
|
+
*
|
|
97
|
+
* @param key - AES-256 key (32 bytes)
|
|
98
|
+
* @param plaintext - Data to encrypt
|
|
99
|
+
* @returns VKDA-formatted ciphertext
|
|
100
|
+
*/
|
|
101
|
+
export declare function aes256Encrypt(key: Buffer, plaintext: Uint8Array): Buffer;
|
|
102
|
+
/**
|
|
103
|
+
* Decrypt VKDA-formatted ciphertext using AES-256-GCM.
|
|
104
|
+
*
|
|
105
|
+
* Validates the VKDA magic header and version, then performs
|
|
106
|
+
* authenticated GCM decryption.
|
|
107
|
+
*
|
|
108
|
+
* @param key - AES-256 key (32 bytes)
|
|
109
|
+
* @param data - VKDA-formatted ciphertext
|
|
110
|
+
* @returns Decrypted plaintext
|
|
111
|
+
*/
|
|
112
|
+
export declare function aes256Decrypt(key: Buffer, data: Uint8Array): Buffer;
|
|
113
|
+
//# sourceMappingURL=crypto.d.ts.map
|