@themoltnet/sdk 0.6.0 → 0.8.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/dist/credentials.d.ts +1 -1
- package/dist/credentials.d.ts.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -3
- package/dist/info.d.ts +6 -0
- package/dist/info.d.ts.map +1 -0
- package/dist/sign.d.ts +9 -0
- package/dist/sign.d.ts.map +1 -0
- package/package.json +3 -3
package/dist/credentials.d.ts
CHANGED
|
@@ -19,5 +19,5 @@ export interface CredentialsFile {
|
|
|
19
19
|
export declare function getConfigDir(): string;
|
|
20
20
|
export declare function getCredentialsPath(): string;
|
|
21
21
|
export declare function writeCredentials(result: RegisterResult): Promise<string>;
|
|
22
|
-
export declare function readCredentials(): Promise<CredentialsFile | null>;
|
|
22
|
+
export declare function readCredentials(path?: string): Promise<CredentialsFile | null>;
|
|
23
23
|
//# sourceMappingURL=credentials.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE;QACN,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,IAAI,EAAE;QACJ,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,SAAS,EAAE;QACT,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,MAAM,CAAC,CA6BjB;AAED,wBAAsB,eAAe,IAAI,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,
|
|
1
|
+
{"version":3,"file":"credentials.d.ts","sourceRoot":"","sources":["../src/credentials.ts"],"names":[],"mappings":"AAIA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,eAAe,CAAC;AAEpD,MAAM,WAAW,eAAe;IAC9B,WAAW,EAAE,MAAM,CAAC;IACpB,MAAM,EAAE;QACN,SAAS,EAAE,MAAM,CAAC;QAClB,aAAa,EAAE,MAAM,CAAC;KACvB,CAAC;IACF,IAAI,EAAE;QACJ,UAAU,EAAE,MAAM,CAAC;QACnB,WAAW,EAAE,MAAM,CAAC;QACpB,WAAW,EAAE,MAAM,CAAC;KACrB,CAAC;IACF,SAAS,EAAE;QACT,GAAG,EAAE,MAAM,CAAC;QACZ,GAAG,EAAE,MAAM,CAAC;KACb,CAAC;IACF,aAAa,EAAE,MAAM,CAAC;CACvB;AAED,wBAAgB,YAAY,IAAI,MAAM,CAErC;AAED,wBAAgB,kBAAkB,IAAI,MAAM,CAE3C;AAED,wBAAsB,gBAAgB,CACpC,MAAM,EAAE,cAAc,GACrB,OAAO,CAAC,MAAM,CAAC,CA6BjB;AAED,wBAAsB,eAAe,CACnC,IAAI,CAAC,EAAE,MAAM,GACZ,OAAO,CAAC,eAAe,GAAG,IAAI,CAAC,CAOjC"}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,9 +1,15 @@
|
|
|
1
1
|
export { writeMcpConfig } from './config.js';
|
|
2
2
|
export { type CredentialsFile, getConfigDir, getCredentialsPath, readCredentials, writeCredentials, } from './credentials.js';
|
|
3
3
|
export { MoltNetError, NetworkError, problemToError, RegistrationError, } from './errors.js';
|
|
4
|
+
export { info, type InfoOptions } from './info.js';
|
|
4
5
|
export { buildMcpConfig, type McpConfig, register, type RegisterOptions, type RegisterResult, } from './register.js';
|
|
6
|
+
export { sign } from './sign.js';
|
|
7
|
+
import { info } from './info.js';
|
|
5
8
|
import { register } from './register.js';
|
|
9
|
+
import { sign } from './sign.js';
|
|
6
10
|
export declare const MoltNet: {
|
|
7
11
|
readonly register: typeof register;
|
|
12
|
+
readonly info: typeof info;
|
|
13
|
+
readonly sign: typeof sign;
|
|
8
14
|
};
|
|
9
15
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,KAAK,eAAe,EACpB,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,cAAc,EACd,KAAK,SAAS,EACd,QAAQ,EACR,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,cAAc,EAAE,MAAM,aAAa,CAAC;AAC7C,OAAO,EACL,KAAK,eAAe,EACpB,YAAY,EACZ,kBAAkB,EAClB,eAAe,EACf,gBAAgB,GACjB,MAAM,kBAAkB,CAAC;AAC1B,OAAO,EACL,YAAY,EACZ,YAAY,EACZ,cAAc,EACd,iBAAiB,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EAAE,IAAI,EAAE,KAAK,WAAW,EAAE,MAAM,WAAW,CAAC;AACnD,OAAO,EACL,cAAc,EACd,KAAK,SAAS,EACd,QAAQ,EACR,KAAK,eAAe,EACpB,KAAK,cAAc,GACpB,MAAM,eAAe,CAAC;AACvB,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AACjC,OAAO,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAC;AACzC,OAAO,EAAE,IAAI,EAAE,MAAM,WAAW,CAAC;AAEjC,eAAO,MAAM,OAAO;;;;CAAoC,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -58,9 +58,9 @@ async function writeCredentials(result) {
|
|
|
58
58
|
await chmod(filePath, 384);
|
|
59
59
|
return filePath;
|
|
60
60
|
}
|
|
61
|
-
async function readCredentials() {
|
|
61
|
+
async function readCredentials(path) {
|
|
62
62
|
try {
|
|
63
|
-
const content = await readFile(getCredentialsPath(), "utf-8");
|
|
63
|
+
const content = await readFile(path ?? getCredentialsPath(), "utf-8");
|
|
64
64
|
return JSON.parse(content);
|
|
65
65
|
} catch {
|
|
66
66
|
return null;
|
|
@@ -915,6 +915,20 @@ const registerAgent = (options) => (options.client ?? client).post({
|
|
|
915
915
|
...options.headers
|
|
916
916
|
}
|
|
917
917
|
});
|
|
918
|
+
const getNetworkInfo = (options) => ((options == null ? void 0 : options.client) ?? client).get({ url: "/.well-known/moltnet.json", ...options });
|
|
919
|
+
const DEFAULT_API_URL$1 = "https://api.themolt.net";
|
|
920
|
+
async function info(options) {
|
|
921
|
+
const apiUrl = ((options == null ? void 0 : options.apiUrl) ?? DEFAULT_API_URL$1).replace(/\/$/, "");
|
|
922
|
+
const client2 = createClient({ baseUrl: apiUrl });
|
|
923
|
+
const { data, error } = await getNetworkInfo({ client: client2 });
|
|
924
|
+
if (error) {
|
|
925
|
+
throw new NetworkError("Failed to fetch network info");
|
|
926
|
+
}
|
|
927
|
+
if (!data) {
|
|
928
|
+
throw new NetworkError("Empty response from network info endpoint");
|
|
929
|
+
}
|
|
930
|
+
return data;
|
|
931
|
+
}
|
|
918
932
|
ed.etc.sha512Sync = (...m) => {
|
|
919
933
|
const hash = createHash("sha512");
|
|
920
934
|
m.forEach((msg) => hash.update(msg));
|
|
@@ -1107,7 +1121,16 @@ async function register(options) {
|
|
|
1107
1121
|
apiUrl
|
|
1108
1122
|
};
|
|
1109
1123
|
}
|
|
1110
|
-
|
|
1124
|
+
async function sign(payload, credentialsPath) {
|
|
1125
|
+
const credentials = await readCredentials(credentialsPath);
|
|
1126
|
+
if (!credentials) {
|
|
1127
|
+
throw new Error(
|
|
1128
|
+
"No credentials found — run `moltnet register` or `npx @themoltnet/cli register` first"
|
|
1129
|
+
);
|
|
1130
|
+
}
|
|
1131
|
+
return cryptoService.sign(payload, credentials.keys.private_key);
|
|
1132
|
+
}
|
|
1133
|
+
const MoltNet = { register, info, sign };
|
|
1111
1134
|
export {
|
|
1112
1135
|
MoltNet,
|
|
1113
1136
|
MoltNetError,
|
|
@@ -1116,9 +1139,11 @@ export {
|
|
|
1116
1139
|
buildMcpConfig,
|
|
1117
1140
|
getConfigDir,
|
|
1118
1141
|
getCredentialsPath,
|
|
1142
|
+
info,
|
|
1119
1143
|
problemToError,
|
|
1120
1144
|
readCredentials,
|
|
1121
1145
|
register,
|
|
1146
|
+
sign,
|
|
1122
1147
|
writeCredentials,
|
|
1123
1148
|
writeMcpConfig
|
|
1124
1149
|
};
|
package/dist/info.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"info.d.ts","sourceRoot":"","sources":["../src/info.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,sBAAsB,EAAE,MAAM,qBAAqB,CAAC;AAOlE,MAAM,WAAW,WAAW;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,wBAAsB,IAAI,CACxB,OAAO,CAAC,EAAE,WAAW,GACpB,OAAO,CAAC,sBAAsB,CAAC,CAYjC"}
|
package/dist/sign.d.ts
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Sign a payload using the private key from the local credentials file.
|
|
3
|
+
*
|
|
4
|
+
* @param payload - The string to sign
|
|
5
|
+
* @param credentialsPath - Optional path to credentials.json (defaults to ~/.config/moltnet/credentials.json)
|
|
6
|
+
* @returns Base64-encoded Ed25519 signature
|
|
7
|
+
*/
|
|
8
|
+
export declare function sign(payload: string, credentialsPath?: string): Promise<string>;
|
|
9
|
+
//# sourceMappingURL=sign.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"sign.d.ts","sourceRoot":"","sources":["../src/sign.ts"],"names":[],"mappings":"AAIA;;;;;;GAMG;AACH,wBAAsB,IAAI,CACxB,OAAO,EAAE,MAAM,EACf,eAAe,CAAC,EAAE,MAAM,GACvB,OAAO,CAAC,MAAM,CAAC,CAQjB"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@themoltnet/sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "MoltNet Agent SDK — register identity, store credentials, configure MCP",
|
|
6
6
|
"main": "./dist/index.js",
|
|
@@ -23,8 +23,8 @@
|
|
|
23
23
|
"typescript": "^5.3.3",
|
|
24
24
|
"vite": "^6.0.0",
|
|
25
25
|
"vitest": "^3.0.0",
|
|
26
|
-
"@moltnet/
|
|
27
|
-
"@moltnet/
|
|
26
|
+
"@moltnet/crypto-service": "0.1.0",
|
|
27
|
+
"@moltnet/api-client": "0.1.0"
|
|
28
28
|
},
|
|
29
29
|
"repository": {
|
|
30
30
|
"type": "git",
|