@kodelyth/zalouser 2026.5.39 → 2026.5.42
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 +120 -0
- package/api.ts +9 -0
- package/channel-plugin-api.ts +3 -0
- package/contract-api.ts +2 -0
- package/dist/accounts-DOefD_if.js +66 -0
- package/dist/accounts.runtime-KT101uuu.js +2 -0
- package/dist/api-DSWT4Dh_.js +133 -0
- package/dist/api.js +7 -0
- package/dist/channel-pby_3Sur.js +602 -0
- package/dist/channel-plugin-api.js +2 -0
- package/dist/channel.runtime-0aJ2O7Y8.js +25 -0
- package/dist/channel.setup-CqyWwqcQ.js +9 -0
- package/dist/contract-api.js +3 -0
- package/dist/doctor-contract-B9EvrW0j.js +128 -0
- package/dist/doctor-contract-api.js +2 -0
- package/dist/index.js +27 -0
- package/dist/monitor-CVtrUqyW.js +708 -0
- package/dist/runtime-api.js +19 -0
- package/dist/secret-contract-api.js +5 -0
- package/dist/security-audit-D_rftvs-.js +34 -0
- package/dist/send-uRjUB8mG.js +542 -0
- package/dist/session-route-CalHiv1d.js +92 -0
- package/dist/setup-entry.js +11 -0
- package/dist/setup-plugin-api.js +2 -0
- package/dist/setup-surface-Cfj4GQlB.js +360 -0
- package/dist/shared-DjK0e2FC.js +160 -0
- package/dist/test-api.js +5 -0
- package/dist/zalo-js-B80cRyDF.js +1285 -0
- package/doctor-contract-api.ts +1 -0
- package/index.ts +34 -0
- package/klaw.plugin.json +3 -286
- package/package.json +4 -4
- package/runtime-api.ts +62 -0
- package/secret-contract-api.ts +4 -0
- package/setup-entry.ts +9 -0
- package/setup-plugin-api.ts +2 -0
- package/src/accounts.runtime.ts +1 -0
- package/src/accounts.test-mocks.ts +14 -0
- package/src/accounts.test.ts +298 -0
- package/src/accounts.ts +136 -0
- package/src/channel-api.ts +16 -0
- package/src/channel.adapters.ts +432 -0
- package/src/channel.directory.test.ts +59 -0
- package/src/channel.runtime.ts +12 -0
- package/src/channel.sendpayload.test.ts +311 -0
- package/src/channel.setup.test.ts +30 -0
- package/src/channel.setup.ts +12 -0
- package/src/channel.test.ts +424 -0
- package/src/channel.ts +221 -0
- package/src/config-schema.ts +33 -0
- package/src/directory.ts +54 -0
- package/src/doctor-contract.ts +156 -0
- package/src/doctor.test.ts +87 -0
- package/src/doctor.ts +37 -0
- package/src/group-policy.test.ts +61 -0
- package/src/group-policy.ts +83 -0
- package/src/message-sid.test.ts +66 -0
- package/src/message-sid.ts +80 -0
- package/src/monitor.account-scope.test.ts +122 -0
- package/src/monitor.group-gating.test.ts +967 -0
- package/src/monitor.send-mocks.ts +20 -0
- package/src/monitor.ts +1057 -0
- package/src/probe.test.ts +60 -0
- package/src/probe.ts +35 -0
- package/src/qr-temp-file.ts +19 -0
- package/src/reaction.test.ts +19 -0
- package/src/reaction.ts +32 -0
- package/src/runtime.ts +9 -0
- package/src/security-audit.test.ts +83 -0
- package/src/security-audit.ts +71 -0
- package/src/send-receipt.ts +31 -0
- package/src/send.test.ts +424 -0
- package/src/send.ts +280 -0
- package/src/session-route.ts +121 -0
- package/src/setup-core.ts +36 -0
- package/src/setup-surface.test.ts +367 -0
- package/src/setup-surface.ts +481 -0
- package/src/setup-test-helpers.ts +42 -0
- package/src/shared.ts +92 -0
- package/src/status-issues.test.ts +31 -0
- package/src/status-issues.ts +55 -0
- package/src/test-helpers.ts +26 -0
- package/src/text-styles.test.ts +203 -0
- package/src/text-styles.ts +540 -0
- package/src/tool.test.ts +212 -0
- package/src/tool.ts +200 -0
- package/src/types.ts +127 -0
- package/src/zalo-js.credentials.test.ts +465 -0
- package/src/zalo-js.test-mocks.ts +89 -0
- package/src/zalo-js.ts +1889 -0
- package/src/zca-client.test.ts +27 -0
- package/src/zca-client.ts +259 -0
- package/src/zca-constants.ts +55 -0
- package/src/zca-js-exports.d.ts +22 -0
- package/test-api.ts +21 -0
- package/tsconfig.json +16 -0
- package/api.js +0 -7
- package/channel-plugin-api.js +0 -7
- package/contract-api.js +0 -7
- package/doctor-contract-api.js +0 -7
- package/index.js +0 -7
- package/runtime-api.js +0 -7
- package/secret-contract-api.js +0 -7
- package/setup-entry.js +0 -7
- package/setup-plugin-api.js +0 -7
- package/test-api.js +0 -7
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
//#region extensions/zalouser/src/doctor-contract.ts
|
|
2
|
+
function asObjectRecord(value) {
|
|
3
|
+
return value && typeof value === "object" && !Array.isArray(value) ? value : null;
|
|
4
|
+
}
|
|
5
|
+
function hasLegacyZalouserGroupAllowAlias(value) {
|
|
6
|
+
const group = asObjectRecord(value);
|
|
7
|
+
return Boolean(group && typeof group.allow === "boolean");
|
|
8
|
+
}
|
|
9
|
+
function hasLegacyZalouserGroupAllowAliases(value) {
|
|
10
|
+
const groups = asObjectRecord(value);
|
|
11
|
+
return Boolean(groups && Object.values(groups).some((group) => hasLegacyZalouserGroupAllowAlias(group)));
|
|
12
|
+
}
|
|
13
|
+
function hasLegacyZalouserAccountGroupAllowAliases(value) {
|
|
14
|
+
const accounts = asObjectRecord(value);
|
|
15
|
+
if (!accounts) return false;
|
|
16
|
+
return Object.values(accounts).some((account) => {
|
|
17
|
+
const accountRecord = asObjectRecord(account);
|
|
18
|
+
return Boolean(accountRecord && hasLegacyZalouserGroupAllowAliases(accountRecord.groups));
|
|
19
|
+
});
|
|
20
|
+
}
|
|
21
|
+
function normalizeZalouserGroupAllowAliases(params) {
|
|
22
|
+
let changed = false;
|
|
23
|
+
const nextGroups = { ...params.groups };
|
|
24
|
+
for (const [groupId, groupValue] of Object.entries(params.groups)) {
|
|
25
|
+
const group = asObjectRecord(groupValue);
|
|
26
|
+
if (!group || typeof group.allow !== "boolean") continue;
|
|
27
|
+
const nextGroup = { ...group };
|
|
28
|
+
if (typeof nextGroup.enabled !== "boolean") nextGroup.enabled = group.allow;
|
|
29
|
+
delete nextGroup.allow;
|
|
30
|
+
nextGroups[groupId] = nextGroup;
|
|
31
|
+
changed = true;
|
|
32
|
+
params.changes.push(`Moved ${params.pathPrefix}.${groupId}.allow → ${params.pathPrefix}.${groupId}.enabled (${String(nextGroup.enabled)}).`);
|
|
33
|
+
}
|
|
34
|
+
return {
|
|
35
|
+
groups: nextGroups,
|
|
36
|
+
changed
|
|
37
|
+
};
|
|
38
|
+
}
|
|
39
|
+
function normalizeZalouserCompatibilityConfig(cfg) {
|
|
40
|
+
const zalouser = asObjectRecord(asObjectRecord(cfg.channels)?.zalouser);
|
|
41
|
+
if (!zalouser) return {
|
|
42
|
+
config: cfg,
|
|
43
|
+
changes: []
|
|
44
|
+
};
|
|
45
|
+
const changes = [];
|
|
46
|
+
let updatedZalouser = zalouser;
|
|
47
|
+
let changed = false;
|
|
48
|
+
const groups = asObjectRecord(updatedZalouser.groups);
|
|
49
|
+
if (groups) {
|
|
50
|
+
const normalized = normalizeZalouserGroupAllowAliases({
|
|
51
|
+
groups,
|
|
52
|
+
pathPrefix: "channels.zalouser.groups",
|
|
53
|
+
changes
|
|
54
|
+
});
|
|
55
|
+
if (normalized.changed) {
|
|
56
|
+
updatedZalouser = {
|
|
57
|
+
...updatedZalouser,
|
|
58
|
+
groups: normalized.groups
|
|
59
|
+
};
|
|
60
|
+
changed = true;
|
|
61
|
+
}
|
|
62
|
+
}
|
|
63
|
+
const accounts = asObjectRecord(updatedZalouser.accounts);
|
|
64
|
+
if (accounts) {
|
|
65
|
+
let accountsChanged = false;
|
|
66
|
+
const nextAccounts = { ...accounts };
|
|
67
|
+
for (const [accountId, accountValue] of Object.entries(accounts)) {
|
|
68
|
+
const account = asObjectRecord(accountValue);
|
|
69
|
+
if (!account) continue;
|
|
70
|
+
const accountGroups = asObjectRecord(account.groups);
|
|
71
|
+
if (!accountGroups) continue;
|
|
72
|
+
const normalized = normalizeZalouserGroupAllowAliases({
|
|
73
|
+
groups: accountGroups,
|
|
74
|
+
pathPrefix: `channels.zalouser.accounts.${accountId}.groups`,
|
|
75
|
+
changes
|
|
76
|
+
});
|
|
77
|
+
if (!normalized.changed) continue;
|
|
78
|
+
nextAccounts[accountId] = {
|
|
79
|
+
...account,
|
|
80
|
+
groups: normalized.groups
|
|
81
|
+
};
|
|
82
|
+
accountsChanged = true;
|
|
83
|
+
}
|
|
84
|
+
if (accountsChanged) {
|
|
85
|
+
updatedZalouser = {
|
|
86
|
+
...updatedZalouser,
|
|
87
|
+
accounts: nextAccounts
|
|
88
|
+
};
|
|
89
|
+
changed = true;
|
|
90
|
+
}
|
|
91
|
+
}
|
|
92
|
+
if (!changed) return {
|
|
93
|
+
config: cfg,
|
|
94
|
+
changes: []
|
|
95
|
+
};
|
|
96
|
+
return {
|
|
97
|
+
config: {
|
|
98
|
+
...cfg,
|
|
99
|
+
channels: {
|
|
100
|
+
...cfg.channels,
|
|
101
|
+
zalouser: updatedZalouser
|
|
102
|
+
}
|
|
103
|
+
},
|
|
104
|
+
changes
|
|
105
|
+
};
|
|
106
|
+
}
|
|
107
|
+
const legacyConfigRules = [{
|
|
108
|
+
path: [
|
|
109
|
+
"channels",
|
|
110
|
+
"zalouser",
|
|
111
|
+
"groups"
|
|
112
|
+
],
|
|
113
|
+
message: "channels.zalouser.groups.<id>.allow is legacy; use channels.zalouser.groups.<id>.enabled instead. Run \"klaw doctor --fix\".",
|
|
114
|
+
match: hasLegacyZalouserGroupAllowAliases
|
|
115
|
+
}, {
|
|
116
|
+
path: [
|
|
117
|
+
"channels",
|
|
118
|
+
"zalouser",
|
|
119
|
+
"accounts"
|
|
120
|
+
],
|
|
121
|
+
message: "channels.zalouser.accounts.<id>.groups.<id>.allow is legacy; use channels.zalouser.accounts.<id>.groups.<id>.enabled instead. Run \"klaw doctor --fix\".",
|
|
122
|
+
match: hasLegacyZalouserAccountGroupAllowAliases
|
|
123
|
+
}];
|
|
124
|
+
function normalizeCompatibilityConfig(params) {
|
|
125
|
+
return normalizeZalouserCompatibilityConfig(params.cfg);
|
|
126
|
+
}
|
|
127
|
+
//#endregion
|
|
128
|
+
export { normalizeCompatibilityConfig as n, legacyConfigRules as t };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import { defineBundledChannelEntry, loadBundledEntryExportSync } from "klaw/plugin-sdk/channel-entry-contract";
|
|
2
|
+
//#region extensions/zalouser/index.ts
|
|
3
|
+
function createZalouserTool(context) {
|
|
4
|
+
return loadBundledEntryExportSync(import.meta.url, {
|
|
5
|
+
specifier: "./api.js",
|
|
6
|
+
exportName: "createZalouserTool"
|
|
7
|
+
})(context);
|
|
8
|
+
}
|
|
9
|
+
var zalouser_default = defineBundledChannelEntry({
|
|
10
|
+
id: "zalouser",
|
|
11
|
+
name: "Zalo Personal",
|
|
12
|
+
description: "Zalo personal account messaging via native zca-js integration",
|
|
13
|
+
importMetaUrl: import.meta.url,
|
|
14
|
+
plugin: {
|
|
15
|
+
specifier: "./channel-plugin-api.js",
|
|
16
|
+
exportName: "zalouserPlugin"
|
|
17
|
+
},
|
|
18
|
+
runtime: {
|
|
19
|
+
specifier: "./runtime-api.js",
|
|
20
|
+
exportName: "setZalouserRuntime"
|
|
21
|
+
},
|
|
22
|
+
registerFull(api) {
|
|
23
|
+
api.registerTool((ctx) => createZalouserTool(ctx), { name: "zalouser" });
|
|
24
|
+
}
|
|
25
|
+
});
|
|
26
|
+
//#endregion
|
|
27
|
+
export { zalouser_default as default };
|