@zbruceli/openclaw-dchat 0.1.2 → 0.1.4

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/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zbruceli/openclaw-dchat",
3
- "version": "0.1.2",
3
+ "version": "0.1.4",
4
4
  "description": "OpenClaw D-Chat/nMobile channel plugin — decentralized E2E encrypted messaging over the NKN relay network",
5
5
  "type": "module",
6
6
  "main": "index.ts",
package/src/channel.ts CHANGED
@@ -12,7 +12,7 @@ import {
12
12
  } from "openclaw/plugin-sdk";
13
13
  import {
14
14
  type CoreConfig,
15
- DchatConfigSchema,
15
+ dchatAccountSchema,
16
16
  listDchatAccountIds,
17
17
  resolveDchatAccount,
18
18
  resolveDchatAccountConfig,
@@ -66,7 +66,7 @@ export const dchatPlugin: ChannelPlugin<ResolvedDchatAccount> = {
66
66
  polls: false,
67
67
  },
68
68
  reload: { configPrefixes: ["channels.dchat"] },
69
- configSchema: buildChannelConfigSchema(DchatConfigSchema),
69
+ configSchema: buildChannelConfigSchema(dchatAccountSchema),
70
70
  pairing: {
71
71
  idLabel: "nknAddress",
72
72
  normalizeAllowEntry: (entry) => entry.replace(/^dchat:/i, ""),
@@ -106,7 +106,7 @@ export const dchatPlugin: ChannelPlugin<ResolvedDchatAccount> = {
106
106
  }),
107
107
  resolveAllowFrom: ({ cfg, accountId }) => {
108
108
  const dchatConfig = resolveDchatAccountConfig({ cfg: cfg as CoreConfig, accountId });
109
- return (dchatConfig.dm?.allowFrom ?? []).map((entry) => String(entry));
109
+ return (dchatConfig.allowFrom ?? []).map((entry) => String(entry));
110
110
  },
111
111
  formatAllowFrom: ({ allowFrom }) =>
112
112
  allowFrom.map((entry) => String(entry).replace(/^dchat:/i, "")),
@@ -116,12 +116,12 @@ export const dchatPlugin: ChannelPlugin<ResolvedDchatAccount> = {
116
116
  const accountId = account.accountId;
117
117
  const prefix =
118
118
  accountId && accountId !== "default"
119
- ? `channels.dchat.accounts.${accountId}.dm`
120
- : "channels.dchat.dm";
119
+ ? `channels.dchat.accounts.${accountId}`
120
+ : "channels.dchat";
121
121
  return {
122
- policy: account.config.dm?.policy ?? "pairing",
123
- allowFrom: account.config.dm?.allowFrom ?? [],
124
- policyPath: `${prefix}.policy`,
122
+ policy: account.config.dmPolicy ?? "pairing",
123
+ allowFrom: account.config.allowFrom ?? [],
124
+ policyPath: `${prefix}.dmPolicy`,
125
125
  allowFromPath: `${prefix}.allowFrom`,
126
126
  approveHint: formatPairingApproveHint("dchat"),
127
127
  normalizeEntry: (raw: string) => raw.replace(/^dchat:/i, ""),
@@ -383,8 +383,8 @@ export const dchatPlugin: ChannelPlugin<ResolvedDchatAccount> = {
383
383
 
384
384
  // Resolve command authorization for slash commands (/status, /stop, etc.)
385
385
  const isGroup = inbound.chatType === "group";
386
- const dmPolicy = account.config.dm?.policy ?? "pairing";
387
- const configAllowFrom = (account.config.dm?.allowFrom ?? []).map((v) => String(v));
386
+ const dmPolicy = account.config.dmPolicy ?? "pairing";
387
+ const configAllowFrom = (account.config.allowFrom ?? []).map((v) => String(v));
388
388
 
389
389
  const isSenderAllowed = (senderId: string, allowFrom: string[]) => {
390
390
  const lower = senderId.toLowerCase();
@@ -17,7 +17,7 @@ const DEFAULT_ACCOUNT_ID = "default";
17
17
 
18
18
  /* ── Zod config schema (powers web UI form via buildChannelConfigSchema) ── */
19
19
 
20
- const dchatAccountSchema = z.object({
20
+ export const dchatAccountSchema = z.object({
21
21
  name: z.string().optional(),
22
22
  enabled: z.boolean().optional(),
23
23
  seed: z.string().optional(),
@@ -25,12 +25,8 @@ const dchatAccountSchema = z.object({
25
25
  keystorePassword: z.string().optional(),
26
26
  numSubClients: z.number().optional(),
27
27
  ipfsGateway: z.string().optional(),
28
- dm: z
29
- .object({
30
- policy: z.enum(["pairing", "allowlist", "open", "disabled"]).optional(),
31
- allowFrom: z.array(z.string()).optional(),
32
- })
33
- .optional(),
28
+ dmPolicy: z.enum(["pairing", "allowlist", "open", "disabled"]).optional(),
29
+ allowFrom: z.array(z.string()).optional(),
34
30
  });
35
31
 
36
32
  export const DchatConfigSchema = dchatAccountSchema.extend({
@@ -91,7 +87,8 @@ export function resolveDchatAccountConfig(params: {
91
87
  return {
92
88
  ...dchatConfig,
93
89
  ...acct,
94
- dm: { ...dchatConfig.dm, ...acct.dm },
90
+ dmPolicy: acct.dmPolicy ?? dchatConfig.dmPolicy,
91
+ allowFrom: acct.allowFrom ?? dchatConfig.allowFrom,
95
92
  };
96
93
  }
97
94
 
package/src/onboarding.ts CHANGED
@@ -12,7 +12,7 @@ import { listDchatAccountIds, resolveDchatAccount, type CoreConfig } from "./con
12
12
  const channel = "dchat" as const;
13
13
 
14
14
  function setDchatDmPolicy(cfg: CoreConfig, policy: DmPolicy) {
15
- const existingAllowFrom = cfg.channels?.dchat?.dm?.allowFrom ?? [];
15
+ const existingAllowFrom = cfg.channels?.dchat?.allowFrom ?? [];
16
16
  const allowFrom =
17
17
  policy === "open"
18
18
  ? addWildcardAllowFrom(existingAllowFrom)
@@ -23,11 +23,8 @@ function setDchatDmPolicy(cfg: CoreConfig, policy: DmPolicy) {
23
23
  ...cfg.channels,
24
24
  dchat: {
25
25
  ...cfg.channels?.dchat,
26
- dm: {
27
- ...cfg.channels?.dchat?.dm,
28
- policy,
29
- allowFrom,
30
- },
26
+ dmPolicy: policy,
27
+ allowFrom,
31
28
  },
32
29
  },
33
30
  };
@@ -38,7 +35,7 @@ async function promptDchatAllowFrom(params: {
38
35
  prompter: WizardPrompter;
39
36
  }): Promise<CoreConfig> {
40
37
  const { cfg, prompter } = params;
41
- const existingAllowFrom = cfg.channels?.dchat?.dm?.allowFrom ?? [];
38
+ const existingAllowFrom = cfg.channels?.dchat?.allowFrom ?? [];
42
39
 
43
40
  const entry = await prompter.text({
44
41
  message: "NKN address to allow (full public key hex)",
@@ -60,11 +57,8 @@ async function promptDchatAllowFrom(params: {
60
57
  dchat: {
61
58
  ...cfg.channels?.dchat,
62
59
  enabled: true,
63
- dm: {
64
- ...cfg.channels?.dchat?.dm,
65
- policy: "allowlist",
66
- allowFrom: unique,
67
- },
60
+ dmPolicy: "allowlist",
61
+ allowFrom: unique,
68
62
  },
69
63
  },
70
64
  };
@@ -73,9 +67,9 @@ async function promptDchatAllowFrom(params: {
73
67
  const dmPolicy: ChannelOnboardingDmPolicy = {
74
68
  label: "D-Chat",
75
69
  channel,
76
- policyKey: "channels.dchat.dm.policy",
77
- allowFromKey: "channels.dchat.dm.allowFrom",
78
- getCurrent: (cfg) => ((cfg as CoreConfig).channels?.dchat?.dm?.policy as DmPolicy) ?? "pairing",
70
+ policyKey: "channels.dchat.dmPolicy",
71
+ allowFromKey: "channels.dchat.allowFrom",
72
+ getCurrent: (cfg) => ((cfg as CoreConfig).channels?.dchat?.dmPolicy as DmPolicy) ?? "pairing",
79
73
  setPolicy: (cfg, policy) => setDchatDmPolicy(cfg as CoreConfig, policy),
80
74
  promptAllowFrom: promptDchatAllowFrom,
81
75
  };
package/src/types.ts CHANGED
@@ -118,10 +118,8 @@ export interface DchatAccountConfig {
118
118
  ipfsGateway?: string; // default: "64.225.88.71:80"
119
119
  enabled?: boolean;
120
120
  name?: string;
121
- dm?: {
122
- allowFrom?: string[];
123
- policy?: string;
124
- };
121
+ dmPolicy?: string;
122
+ allowFrom?: string[];
125
123
  }
126
124
 
127
125
  export interface ResolvedDchatAccount {