@themoltnet/node-red-contrib-core 0.12.1 → 0.12.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/dist/nodes/src.js +180 -21
- package/package.json +2 -2
package/dist/nodes/src.js
CHANGED
|
@@ -620,6 +620,102 @@ var getNetworkInfo = (options) => (options?.client ?? client).get({
|
|
|
620
620
|
...options
|
|
621
621
|
});
|
|
622
622
|
/**
|
|
623
|
+
* List agent API keys bound to the active team. Team credential managers may list every agent.
|
|
624
|
+
*/
|
|
625
|
+
var listAgentKeys = (options) => (options.client ?? client).get({
|
|
626
|
+
security: [
|
|
627
|
+
{
|
|
628
|
+
scheme: "bearer",
|
|
629
|
+
type: "http"
|
|
630
|
+
},
|
|
631
|
+
{
|
|
632
|
+
name: "X-Moltnet-Session-Token",
|
|
633
|
+
type: "apiKey"
|
|
634
|
+
},
|
|
635
|
+
{
|
|
636
|
+
in: "cookie",
|
|
637
|
+
name: "ory_kratos_session",
|
|
638
|
+
type: "apiKey"
|
|
639
|
+
}
|
|
640
|
+
],
|
|
641
|
+
url: "/agent-keys",
|
|
642
|
+
...options
|
|
643
|
+
});
|
|
644
|
+
/**
|
|
645
|
+
* Issue a secret API key bound to one agent and the active team.
|
|
646
|
+
*/
|
|
647
|
+
var createAgentKey = (options) => (options.client ?? client).post({
|
|
648
|
+
security: [
|
|
649
|
+
{
|
|
650
|
+
scheme: "bearer",
|
|
651
|
+
type: "http"
|
|
652
|
+
},
|
|
653
|
+
{
|
|
654
|
+
name: "X-Moltnet-Session-Token",
|
|
655
|
+
type: "apiKey"
|
|
656
|
+
},
|
|
657
|
+
{
|
|
658
|
+
in: "cookie",
|
|
659
|
+
name: "ory_kratos_session",
|
|
660
|
+
type: "apiKey"
|
|
661
|
+
}
|
|
662
|
+
],
|
|
663
|
+
url: "/agent-keys",
|
|
664
|
+
...options,
|
|
665
|
+
headers: {
|
|
666
|
+
"Content-Type": "application/json",
|
|
667
|
+
...options.headers
|
|
668
|
+
}
|
|
669
|
+
});
|
|
670
|
+
/**
|
|
671
|
+
* Permanently revoke an agent API key.
|
|
672
|
+
*/
|
|
673
|
+
var revokeAgentKey = (options) => (options.client ?? client).post({
|
|
674
|
+
security: [
|
|
675
|
+
{
|
|
676
|
+
scheme: "bearer",
|
|
677
|
+
type: "http"
|
|
678
|
+
},
|
|
679
|
+
{
|
|
680
|
+
name: "X-Moltnet-Session-Token",
|
|
681
|
+
type: "apiKey"
|
|
682
|
+
},
|
|
683
|
+
{
|
|
684
|
+
in: "cookie",
|
|
685
|
+
name: "ory_kratos_session",
|
|
686
|
+
type: "apiKey"
|
|
687
|
+
}
|
|
688
|
+
],
|
|
689
|
+
url: "/agent-keys/{keyId}/revoke",
|
|
690
|
+
...options,
|
|
691
|
+
headers: {
|
|
692
|
+
"Content-Type": "application/json",
|
|
693
|
+
...options.headers
|
|
694
|
+
}
|
|
695
|
+
});
|
|
696
|
+
/**
|
|
697
|
+
* Rotate an agent API key immediately. The previous secret is revoked and expiry is unchanged.
|
|
698
|
+
*/
|
|
699
|
+
var rotateAgentKey = (options) => (options.client ?? client).post({
|
|
700
|
+
security: [
|
|
701
|
+
{
|
|
702
|
+
scheme: "bearer",
|
|
703
|
+
type: "http"
|
|
704
|
+
},
|
|
705
|
+
{
|
|
706
|
+
name: "X-Moltnet-Session-Token",
|
|
707
|
+
type: "apiKey"
|
|
708
|
+
},
|
|
709
|
+
{
|
|
710
|
+
in: "cookie",
|
|
711
|
+
name: "ory_kratos_session",
|
|
712
|
+
type: "apiKey"
|
|
713
|
+
}
|
|
714
|
+
],
|
|
715
|
+
url: "/agent-keys/{keyId}/rotate",
|
|
716
|
+
...options
|
|
717
|
+
});
|
|
718
|
+
/**
|
|
623
719
|
* Get the authenticated agent identity (requires bearer token).
|
|
624
720
|
*/
|
|
625
721
|
var getWhoami = (options) => (options?.client ?? client).get({
|
|
@@ -2903,6 +2999,82 @@ function unwrapRequired(result, message, code) {
|
|
|
2903
2999
|
return result.data;
|
|
2904
3000
|
}
|
|
2905
3001
|
//#endregion
|
|
3002
|
+
//#region ../sdk/src/namespaces/query.ts
|
|
3003
|
+
/**
|
|
3004
|
+
* Remove `undefined`-valued keys from a query object before it is serialized.
|
|
3005
|
+
*
|
|
3006
|
+
* Returns `undefined` when no defined keys remain, so an all-`undefined` query
|
|
3007
|
+
* (`{ agentId: undefined }`) and an omitted query (`undefined`) serialize
|
|
3008
|
+
* identically — both send no query params — instead of the former collapsing to
|
|
3009
|
+
* an empty `{}` that still reaches the client.
|
|
3010
|
+
*/
|
|
3011
|
+
function stripUndefinedQuery(query) {
|
|
3012
|
+
if (!query) return;
|
|
3013
|
+
const entries = Object.entries(query).filter(([, value]) => value !== void 0);
|
|
3014
|
+
return entries.length ? Object.fromEntries(entries) : void 0;
|
|
3015
|
+
}
|
|
3016
|
+
//#endregion
|
|
3017
|
+
//#region ../sdk/src/namespaces/team-headers.ts
|
|
3018
|
+
/**
|
|
3019
|
+
* Build the team header from an optional option, or `undefined` when no team
|
|
3020
|
+
* context was supplied. Used by diaries and runtime-profiles, whose endpoints
|
|
3021
|
+
* accept the header optionally.
|
|
3022
|
+
*/
|
|
3023
|
+
function teamHeaders(options) {
|
|
3024
|
+
return options?.teamId ? { "x-moltnet-team-id": options.teamId } : void 0;
|
|
3025
|
+
}
|
|
3026
|
+
/**
|
|
3027
|
+
* Build the team header from a required option. Used by tasks and
|
|
3028
|
+
* runtime-slots, whose endpoints mandate the header.
|
|
3029
|
+
*/
|
|
3030
|
+
function requiredTeamHeaders(options) {
|
|
3031
|
+
return { "x-moltnet-team-id": options.teamId };
|
|
3032
|
+
}
|
|
3033
|
+
//#endregion
|
|
3034
|
+
//#region ../sdk/src/namespaces/agent-keys.ts
|
|
3035
|
+
function createAgentKeysNamespace(context) {
|
|
3036
|
+
const { client, auth } = context;
|
|
3037
|
+
return {
|
|
3038
|
+
async list(query, options) {
|
|
3039
|
+
return unwrapResult(await listAgentKeys({
|
|
3040
|
+
client,
|
|
3041
|
+
auth,
|
|
3042
|
+
headers: requiredTeamHeaders(options),
|
|
3043
|
+
query: stripUndefinedQuery(query)
|
|
3044
|
+
}));
|
|
3045
|
+
},
|
|
3046
|
+
async create(body, options) {
|
|
3047
|
+
return unwrapResult(await createAgentKey({
|
|
3048
|
+
client,
|
|
3049
|
+
auth,
|
|
3050
|
+
headers: {
|
|
3051
|
+
...requiredTeamHeaders(options),
|
|
3052
|
+
"idempotency-key": options.idempotencyKey
|
|
3053
|
+
},
|
|
3054
|
+
body
|
|
3055
|
+
}));
|
|
3056
|
+
},
|
|
3057
|
+
async rotate(keyId, options) {
|
|
3058
|
+
return unwrapResult(await rotateAgentKey({
|
|
3059
|
+
client,
|
|
3060
|
+
auth,
|
|
3061
|
+
headers: requiredTeamHeaders(options),
|
|
3062
|
+
path: { keyId }
|
|
3063
|
+
}));
|
|
3064
|
+
},
|
|
3065
|
+
async revoke(keyId, body, options) {
|
|
3066
|
+
const result = await revokeAgentKey({
|
|
3067
|
+
client,
|
|
3068
|
+
auth,
|
|
3069
|
+
headers: requiredTeamHeaders(options),
|
|
3070
|
+
path: { keyId },
|
|
3071
|
+
body
|
|
3072
|
+
});
|
|
3073
|
+
if (result.error) unwrapResult(result);
|
|
3074
|
+
}
|
|
3075
|
+
};
|
|
3076
|
+
}
|
|
3077
|
+
//#endregion
|
|
2906
3078
|
//#region ../sdk/src/namespaces/agents.ts
|
|
2907
3079
|
function createAgentsNamespace(context) {
|
|
2908
3080
|
const { client, auth } = context;
|
|
@@ -2960,23 +3132,6 @@ function createCryptoNamespace(context, signingRequests) {
|
|
|
2960
3132
|
};
|
|
2961
3133
|
}
|
|
2962
3134
|
//#endregion
|
|
2963
|
-
//#region ../sdk/src/namespaces/team-headers.ts
|
|
2964
|
-
/**
|
|
2965
|
-
* Build the team header from an optional option, or `undefined` when no team
|
|
2966
|
-
* context was supplied. Used by diaries and runtime-profiles, whose endpoints
|
|
2967
|
-
* accept the header optionally.
|
|
2968
|
-
*/
|
|
2969
|
-
function teamHeaders(options) {
|
|
2970
|
-
return options?.teamId ? { "x-moltnet-team-id": options.teamId } : void 0;
|
|
2971
|
-
}
|
|
2972
|
-
/**
|
|
2973
|
-
* Build the team header from a required option. Used by tasks and
|
|
2974
|
-
* runtime-slots, whose endpoints mandate the header.
|
|
2975
|
-
*/
|
|
2976
|
-
function requiredTeamHeaders(options) {
|
|
2977
|
-
return { "x-moltnet-team-id": options.teamId };
|
|
2978
|
-
}
|
|
2979
|
-
//#endregion
|
|
2980
3135
|
//#region ../sdk/src/namespaces/diaries.ts
|
|
2981
3136
|
function createDiariesNamespace(context) {
|
|
2982
3137
|
const { client, auth } = context;
|
|
@@ -4887,7 +5042,10 @@ function createEntriesNamespace(context) {
|
|
|
4887
5042
|
const signingRequest = unwrapResult(await createSigningRequest({
|
|
4888
5043
|
client,
|
|
4889
5044
|
auth,
|
|
4890
|
-
body: {
|
|
5045
|
+
body: {
|
|
5046
|
+
message: computeContentCid(body.entryType ?? "semantic", body.title ?? null, body.content, body.tags ?? null),
|
|
5047
|
+
verificationMethod: "agent-ed25519"
|
|
5048
|
+
}
|
|
4891
5049
|
}));
|
|
4892
5050
|
const privateKeyBytes = new Uint8Array(Buffer.from(privateKey, "base64"));
|
|
4893
5051
|
const signature = await signAsync(new Uint8Array(Buffer.from(signingRequest.signingInput, "base64")), privateKeyBytes);
|
|
@@ -5252,12 +5410,11 @@ function createRuntimeSlotsNamespace(context) {
|
|
|
5252
5410
|
}
|
|
5253
5411
|
},
|
|
5254
5412
|
async list(query, options) {
|
|
5255
|
-
const filteredQuery = Object.fromEntries(Object.entries(query).filter(([, value]) => value !== void 0));
|
|
5256
5413
|
return unwrapResult(await listRuntimeSlots({
|
|
5257
5414
|
auth,
|
|
5258
5415
|
client,
|
|
5259
5416
|
headers: requiredTeamHeaders(options),
|
|
5260
|
-
query:
|
|
5417
|
+
query: stripUndefinedQuery(query)
|
|
5261
5418
|
})).items;
|
|
5262
5419
|
}
|
|
5263
5420
|
};
|
|
@@ -15498,8 +15655,10 @@ function createAgent(options) {
|
|
|
15498
15655
|
client,
|
|
15499
15656
|
auth
|
|
15500
15657
|
};
|
|
15658
|
+
const diaries = createDiariesNamespace(context);
|
|
15501
15659
|
return {
|
|
15502
|
-
|
|
15660
|
+
agentKeys: createAgentKeysNamespace(context),
|
|
15661
|
+
diaries,
|
|
15503
15662
|
diaryGrants: createDiaryGrantsNamespace(context),
|
|
15504
15663
|
diaryTransfers: createDiaryTransfersNamespace(context),
|
|
15505
15664
|
packs: createPacksNamespace(context),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@themoltnet/node-red-contrib-core",
|
|
3
|
-
"version": "0.12.
|
|
3
|
+
"version": "0.12.3",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Node-RED nodes for the MoltNet API",
|
|
6
6
|
"keywords": [
|
|
@@ -46,7 +46,7 @@
|
|
|
46
46
|
},
|
|
47
47
|
"main": "dist/nodes/agent.js",
|
|
48
48
|
"dependencies": {
|
|
49
|
-
"@themoltnet/sdk": "0.
|
|
49
|
+
"@themoltnet/sdk": "0.123.0"
|
|
50
50
|
},
|
|
51
51
|
"devDependencies": {
|
|
52
52
|
"@types/node": "^22.19.0",
|