@openclaw/line 2026.5.2-beta.2 → 2026.5.3-beta.2

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 (109) hide show
  1. package/dist/accounts-UXAvdBo_.js +105 -0
  2. package/dist/api.js +11 -0
  3. package/dist/basic-cards-7DTG6E-A.js +307 -0
  4. package/dist/card-command-UlPc6Vuc.js +240 -0
  5. package/dist/channel-Rls9s60K.js +601 -0
  6. package/dist/channel-plugin-api.js +2 -0
  7. package/dist/channel.runtime-bXoj8_Sl.js +4 -0
  8. package/dist/contract-api.js +2 -0
  9. package/dist/index.js +45 -0
  10. package/dist/markdown-to-line-CCWK6PJh.js +789 -0
  11. package/dist/monitor-B4_RxHc0.js +1523 -0
  12. package/dist/monitor.runtime-DyxYlrM9.js +2 -0
  13. package/dist/outbound-media-BfhBmWq5.js +55 -0
  14. package/dist/outbound.runtime-B-luYwEB.js +2 -0
  15. package/dist/probe-D9BPzb2n.js +30 -0
  16. package/dist/probe.runtime-N91OWW1J.js +2 -0
  17. package/dist/quick-reply-fallback-HskUUWsn.js +55 -0
  18. package/dist/reply-payload-transform-CFGTs9ln.js +713 -0
  19. package/dist/runtime-api.js +277 -0
  20. package/dist/schedule-cards-BwQChTdM.js +359 -0
  21. package/dist/secret-contract-api.js +5 -0
  22. package/dist/setup-api.js +2 -0
  23. package/dist/setup-entry.js +11 -0
  24. package/dist/setup-surface-DCH7CE-y.js +281 -0
  25. package/package.json +14 -6
  26. package/api.ts +0 -11
  27. package/channel-plugin-api.ts +0 -1
  28. package/contract-api.ts +0 -5
  29. package/index.ts +0 -54
  30. package/runtime-api.ts +0 -187
  31. package/secret-contract-api.ts +0 -4
  32. package/setup-api.ts +0 -2
  33. package/setup-entry.ts +0 -9
  34. package/src/account-helpers.ts +0 -16
  35. package/src/accounts.test.ts +0 -290
  36. package/src/accounts.ts +0 -187
  37. package/src/actions.ts +0 -61
  38. package/src/auto-reply-delivery.test.ts +0 -248
  39. package/src/auto-reply-delivery.ts +0 -200
  40. package/src/bindings.ts +0 -65
  41. package/src/bot-access.ts +0 -48
  42. package/src/bot-handlers.test.ts +0 -1089
  43. package/src/bot-handlers.ts +0 -642
  44. package/src/bot-message-context.test.ts +0 -405
  45. package/src/bot-message-context.ts +0 -581
  46. package/src/bot.ts +0 -70
  47. package/src/card-command.ts +0 -347
  48. package/src/channel-access-token.ts +0 -14
  49. package/src/channel-api.ts +0 -17
  50. package/src/channel-setup-status.contract.test.ts +0 -70
  51. package/src/channel-shared.ts +0 -48
  52. package/src/channel.logout.test.ts +0 -145
  53. package/src/channel.runtime.ts +0 -3
  54. package/src/channel.sendPayload.test.ts +0 -514
  55. package/src/channel.setup.ts +0 -11
  56. package/src/channel.status.test.ts +0 -63
  57. package/src/channel.ts +0 -154
  58. package/src/config-adapter.ts +0 -29
  59. package/src/config-schema.ts +0 -57
  60. package/src/download.test.ts +0 -133
  61. package/src/download.ts +0 -87
  62. package/src/flex-templates/basic-cards.ts +0 -395
  63. package/src/flex-templates/common.ts +0 -20
  64. package/src/flex-templates/media-control-cards.ts +0 -555
  65. package/src/flex-templates/message.ts +0 -13
  66. package/src/flex-templates/schedule-cards.ts +0 -467
  67. package/src/flex-templates/types.ts +0 -22
  68. package/src/flex-templates.ts +0 -32
  69. package/src/gateway.ts +0 -129
  70. package/src/group-keys.test.ts +0 -123
  71. package/src/group-keys.ts +0 -65
  72. package/src/group-policy.ts +0 -22
  73. package/src/markdown-to-line.test.ts +0 -348
  74. package/src/markdown-to-line.ts +0 -416
  75. package/src/message-cards.test.ts +0 -204
  76. package/src/monitor.lifecycle.test.ts +0 -421
  77. package/src/monitor.runtime.ts +0 -1
  78. package/src/monitor.ts +0 -506
  79. package/src/outbound-media.test.ts +0 -189
  80. package/src/outbound-media.ts +0 -120
  81. package/src/outbound.runtime.ts +0 -12
  82. package/src/outbound.ts +0 -356
  83. package/src/probe.contract.test.ts +0 -9
  84. package/src/probe.runtime.ts +0 -1
  85. package/src/probe.ts +0 -34
  86. package/src/quick-reply-fallback.ts +0 -10
  87. package/src/reply-chunks.test.ts +0 -179
  88. package/src/reply-chunks.ts +0 -110
  89. package/src/reply-payload-transform.test.ts +0 -387
  90. package/src/reply-payload-transform.ts +0 -317
  91. package/src/rich-menu.test.ts +0 -310
  92. package/src/rich-menu.ts +0 -326
  93. package/src/runtime.ts +0 -32
  94. package/src/send.test.ts +0 -346
  95. package/src/send.ts +0 -489
  96. package/src/setup-core.ts +0 -149
  97. package/src/setup-runtime-api.ts +0 -9
  98. package/src/setup-surface.test.ts +0 -474
  99. package/src/setup-surface.ts +0 -227
  100. package/src/signature.test.ts +0 -34
  101. package/src/signature.ts +0 -24
  102. package/src/status.ts +0 -37
  103. package/src/template-messages.ts +0 -333
  104. package/src/types.ts +0 -128
  105. package/src/webhook-node.test.ts +0 -513
  106. package/src/webhook-node.ts +0 -131
  107. package/src/webhook-utils.ts +0 -10
  108. package/src/webhook.ts +0 -111
  109. package/tsconfig.json +0 -16
package/src/webhook.ts DELETED
@@ -1,111 +0,0 @@
1
- import type { webhook } from "@line/bot-sdk";
2
- import type { NextFunction, Request, Response } from "express";
3
- import { danger, logVerbose, type RuntimeEnv } from "openclaw/plugin-sdk/runtime-env";
4
- import { parseLineWebhookBody, validateLineSignature } from "./webhook-utils.js";
5
-
6
- const LINE_WEBHOOK_MAX_RAW_BODY_BYTES = 64 * 1024;
7
-
8
- export interface LineWebhookOptions {
9
- channelSecret: string;
10
- onEvents: (body: webhook.CallbackRequest) => Promise<void>;
11
- runtime?: RuntimeEnv;
12
- }
13
-
14
- function readRawBody(req: Request): string | null {
15
- const rawBody =
16
- (req as { rawBody?: string | Buffer }).rawBody ??
17
- (typeof req.body === "string" || Buffer.isBuffer(req.body) ? req.body : null);
18
- if (!rawBody) {
19
- return null;
20
- }
21
- return Buffer.isBuffer(rawBody) ? rawBody.toString("utf-8") : rawBody;
22
- }
23
-
24
- function parseWebhookBody(rawBody?: string | null): webhook.CallbackRequest | null {
25
- if (!rawBody) {
26
- return null;
27
- }
28
- return parseLineWebhookBody(rawBody);
29
- }
30
-
31
- export function createLineWebhookMiddleware(
32
- options: LineWebhookOptions,
33
- ): (req: Request, res: Response, _next: NextFunction) => Promise<void> {
34
- const { channelSecret, onEvents, runtime } = options;
35
-
36
- return async (req: Request, res: Response, _next: NextFunction): Promise<void> => {
37
- try {
38
- const signature = req.headers["x-line-signature"];
39
-
40
- if (!signature || typeof signature !== "string") {
41
- res.status(400).json({ error: "Missing X-Line-Signature header" });
42
- return;
43
- }
44
-
45
- const rawBody = readRawBody(req);
46
-
47
- if (!rawBody) {
48
- res.status(400).json({ error: "Missing raw request body for signature verification" });
49
- return;
50
- }
51
- if (Buffer.byteLength(rawBody, "utf-8") > LINE_WEBHOOK_MAX_RAW_BODY_BYTES) {
52
- res.status(413).json({ error: "Payload too large" });
53
- return;
54
- }
55
-
56
- if (!validateLineSignature(rawBody, signature, channelSecret)) {
57
- logVerbose("line: webhook signature validation failed");
58
- res.status(401).json({ error: "Invalid signature" });
59
- return;
60
- }
61
-
62
- const body = parseWebhookBody(rawBody);
63
-
64
- if (!body) {
65
- res.status(400).json({ error: "Invalid webhook payload" });
66
- return;
67
- }
68
-
69
- if (body.events && body.events.length > 0) {
70
- logVerbose(`line: received ${body.events.length} webhook events`);
71
- await onEvents(body);
72
- }
73
-
74
- res.status(200).json({ status: "ok" });
75
- } catch (err) {
76
- runtime?.error?.(danger(`line webhook error: ${String(err)}`));
77
- if (!res.headersSent) {
78
- res.status(500).json({ error: "Internal server error" });
79
- }
80
- }
81
- };
82
- }
83
-
84
- export interface StartLineWebhookOptions {
85
- channelSecret: string;
86
- onEvents: (body: webhook.CallbackRequest) => Promise<void>;
87
- runtime?: RuntimeEnv;
88
- path?: string;
89
- }
90
-
91
- export function startLineWebhook(options: StartLineWebhookOptions): {
92
- path: string;
93
- handler: (req: Request, res: Response, _next: NextFunction) => Promise<void>;
94
- } {
95
- const channelSecret =
96
- typeof options.channelSecret === "string" ? options.channelSecret.trim() : "";
97
- if (!channelSecret) {
98
- throw new Error(
99
- "LINE webhook mode requires a non-empty channel secret. " +
100
- "Set channels.line.channelSecret in your config.",
101
- );
102
- }
103
- const path = options.path ?? "/line/webhook";
104
- const middleware = createLineWebhookMiddleware({
105
- channelSecret,
106
- onEvents: options.onEvents,
107
- runtime: options.runtime,
108
- });
109
-
110
- return { path, handler: middleware };
111
- }
package/tsconfig.json DELETED
@@ -1,16 +0,0 @@
1
- {
2
- "extends": "../tsconfig.package-boundary.base.json",
3
- "compilerOptions": {
4
- "rootDir": "."
5
- },
6
- "include": ["./*.ts", "./src/**/*.ts"],
7
- "exclude": [
8
- "./**/*.test.ts",
9
- "./dist/**",
10
- "./node_modules/**",
11
- "./src/test-support/**",
12
- "./src/**/*test-helpers.ts",
13
- "./src/**/*test-harness.ts",
14
- "./src/**/*test-support.ts"
15
- ]
16
- }