@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.
Files changed (106) hide show
  1. package/README.md +120 -0
  2. package/api.ts +9 -0
  3. package/channel-plugin-api.ts +3 -0
  4. package/contract-api.ts +2 -0
  5. package/dist/accounts-DOefD_if.js +66 -0
  6. package/dist/accounts.runtime-KT101uuu.js +2 -0
  7. package/dist/api-DSWT4Dh_.js +133 -0
  8. package/dist/api.js +7 -0
  9. package/dist/channel-pby_3Sur.js +602 -0
  10. package/dist/channel-plugin-api.js +2 -0
  11. package/dist/channel.runtime-0aJ2O7Y8.js +25 -0
  12. package/dist/channel.setup-CqyWwqcQ.js +9 -0
  13. package/dist/contract-api.js +3 -0
  14. package/dist/doctor-contract-B9EvrW0j.js +128 -0
  15. package/dist/doctor-contract-api.js +2 -0
  16. package/dist/index.js +27 -0
  17. package/dist/monitor-CVtrUqyW.js +708 -0
  18. package/dist/runtime-api.js +19 -0
  19. package/dist/secret-contract-api.js +5 -0
  20. package/dist/security-audit-D_rftvs-.js +34 -0
  21. package/dist/send-uRjUB8mG.js +542 -0
  22. package/dist/session-route-CalHiv1d.js +92 -0
  23. package/dist/setup-entry.js +11 -0
  24. package/dist/setup-plugin-api.js +2 -0
  25. package/dist/setup-surface-Cfj4GQlB.js +360 -0
  26. package/dist/shared-DjK0e2FC.js +160 -0
  27. package/dist/test-api.js +5 -0
  28. package/dist/zalo-js-B80cRyDF.js +1285 -0
  29. package/doctor-contract-api.ts +1 -0
  30. package/index.ts +34 -0
  31. package/klaw.plugin.json +3 -286
  32. package/package.json +4 -4
  33. package/runtime-api.ts +62 -0
  34. package/secret-contract-api.ts +4 -0
  35. package/setup-entry.ts +9 -0
  36. package/setup-plugin-api.ts +2 -0
  37. package/src/accounts.runtime.ts +1 -0
  38. package/src/accounts.test-mocks.ts +14 -0
  39. package/src/accounts.test.ts +298 -0
  40. package/src/accounts.ts +136 -0
  41. package/src/channel-api.ts +16 -0
  42. package/src/channel.adapters.ts +432 -0
  43. package/src/channel.directory.test.ts +59 -0
  44. package/src/channel.runtime.ts +12 -0
  45. package/src/channel.sendpayload.test.ts +311 -0
  46. package/src/channel.setup.test.ts +30 -0
  47. package/src/channel.setup.ts +12 -0
  48. package/src/channel.test.ts +424 -0
  49. package/src/channel.ts +221 -0
  50. package/src/config-schema.ts +33 -0
  51. package/src/directory.ts +54 -0
  52. package/src/doctor-contract.ts +156 -0
  53. package/src/doctor.test.ts +87 -0
  54. package/src/doctor.ts +37 -0
  55. package/src/group-policy.test.ts +61 -0
  56. package/src/group-policy.ts +83 -0
  57. package/src/message-sid.test.ts +66 -0
  58. package/src/message-sid.ts +80 -0
  59. package/src/monitor.account-scope.test.ts +122 -0
  60. package/src/monitor.group-gating.test.ts +967 -0
  61. package/src/monitor.send-mocks.ts +20 -0
  62. package/src/monitor.ts +1057 -0
  63. package/src/probe.test.ts +60 -0
  64. package/src/probe.ts +35 -0
  65. package/src/qr-temp-file.ts +19 -0
  66. package/src/reaction.test.ts +19 -0
  67. package/src/reaction.ts +32 -0
  68. package/src/runtime.ts +9 -0
  69. package/src/security-audit.test.ts +83 -0
  70. package/src/security-audit.ts +71 -0
  71. package/src/send-receipt.ts +31 -0
  72. package/src/send.test.ts +424 -0
  73. package/src/send.ts +280 -0
  74. package/src/session-route.ts +121 -0
  75. package/src/setup-core.ts +36 -0
  76. package/src/setup-surface.test.ts +367 -0
  77. package/src/setup-surface.ts +481 -0
  78. package/src/setup-test-helpers.ts +42 -0
  79. package/src/shared.ts +92 -0
  80. package/src/status-issues.test.ts +31 -0
  81. package/src/status-issues.ts +55 -0
  82. package/src/test-helpers.ts +26 -0
  83. package/src/text-styles.test.ts +203 -0
  84. package/src/text-styles.ts +540 -0
  85. package/src/tool.test.ts +212 -0
  86. package/src/tool.ts +200 -0
  87. package/src/types.ts +127 -0
  88. package/src/zalo-js.credentials.test.ts +465 -0
  89. package/src/zalo-js.test-mocks.ts +89 -0
  90. package/src/zalo-js.ts +1889 -0
  91. package/src/zca-client.test.ts +27 -0
  92. package/src/zca-client.ts +259 -0
  93. package/src/zca-constants.ts +55 -0
  94. package/src/zca-js-exports.d.ts +22 -0
  95. package/test-api.ts +21 -0
  96. package/tsconfig.json +16 -0
  97. package/api.js +0 -7
  98. package/channel-plugin-api.js +0 -7
  99. package/contract-api.js +0 -7
  100. package/doctor-contract-api.js +0 -7
  101. package/index.js +0 -7
  102. package/runtime-api.js +0 -7
  103. package/secret-contract-api.js +0 -7
  104. package/setup-entry.js +0 -7
  105. package/setup-plugin-api.js +0 -7
  106. 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 };
@@ -0,0 +1,2 @@
1
+ import { n as normalizeCompatibilityConfig, t as legacyConfigRules } from "./doctor-contract-B9EvrW0j.js";
2
+ export { legacyConfigRules, normalizeCompatibilityConfig };
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 };