stitchkit 0.70.6 → 0.72.0
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 +1 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts +11 -1
- package/dist/agent-runtime/coding-tool-contract.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-files.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-listing.d.ts +15 -0
- package/dist/agent-runtime/coding-tool-listing.d.ts.map +1 -0
- package/dist/agent-runtime/coding-tool-paths.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tool-refusals.d.ts +59 -0
- package/dist/agent-runtime/coding-tool-refusals.d.ts.map +1 -0
- package/dist/agent-runtime/coding-tool-search-patch.d.ts.map +1 -1
- package/dist/agent-runtime/coding-tools.d.ts +3 -1
- package/dist/agent-runtime/coding-tools.d.ts.map +1 -1
- package/dist/agent-runtime/compaction.d.ts +35 -0
- package/dist/agent-runtime/compaction.d.ts.map +1 -1
- package/dist/agent-runtime/contained-files.d.ts +21 -2
- package/dist/agent-runtime/contained-files.d.ts.map +1 -1
- package/dist/agent-runtime/provider-failure.d.ts +66 -0
- package/dist/agent-runtime/provider-failure.d.ts.map +1 -0
- package/dist/agent-runtime/run-execution.d.ts.map +1 -1
- package/dist/agent-runtime/runtime.d.ts +31 -1
- package/dist/agent-runtime/runtime.d.ts.map +1 -1
- package/dist/agent-runtime/schemas.d.ts +1 -0
- package/dist/agent-runtime/schemas.d.ts.map +1 -1
- package/dist/agent-runtime-coding-tools.js +438 -124
- package/dist/agent-runtime-harness.js +4 -4
- package/dist/agent-runtime-openrouter.d.ts +19 -0
- package/dist/agent-runtime-openrouter.d.ts.map +1 -1
- package/dist/agent-runtime-openrouter.js +2 -1
- package/dist/agent-runtime.d.ts +3 -2
- package/dist/agent-runtime.d.ts.map +1 -1
- package/dist/agent-runtime.js +118 -14
- package/dist/application/admission.d.ts +22 -2
- package/dist/application/admission.d.ts.map +1 -1
- package/dist/application/channel.d.ts +28 -0
- package/dist/application/channel.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-contract.d.ts +20 -0
- package/dist/application/diagnostic-journal-contract.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-lock.d.ts +17 -0
- package/dist/application/diagnostic-journal-lock.d.ts.map +1 -0
- package/dist/application/diagnostic-journal-manager.d.ts +2 -1
- package/dist/application/diagnostic-journal-manager.d.ts.map +1 -1
- package/dist/application/diagnostic-journal-storage.d.ts +4 -1
- package/dist/application/diagnostic-journal-storage.d.ts.map +1 -1
- package/dist/application/diagnostic-journal.d.ts +4 -2
- package/dist/application/diagnostic-journal.d.ts.map +1 -1
- package/dist/application-opentelemetry.js +1 -1
- package/dist/application.d.ts +3 -3
- package/dist/application.d.ts.map +1 -1
- package/dist/application.js +134 -21
- package/dist/browser/resumable.d.ts +56 -0
- package/dist/browser/resumable.d.ts.map +1 -0
- package/dist/cli.js +5 -5
- package/dist/{index-cx84zg25.js → index-118v0z41.js} +1 -1
- package/dist/{index-zpyj7hsv.js → index-3cwck0rm.js} +98 -33
- package/dist/{index-ejv31h14.js → index-7qy2ex0m.js} +1 -1
- package/dist/{index-trrf7nch.js → index-ezmn6ac6.js} +3 -3
- package/dist/{index-ekkt4gy9.js → index-jqtsc9mj.js} +2 -2
- package/dist/{index-hxtm2xr2.js → index-k2zczx1g.js} +1 -1
- package/dist/{index-by57nwhc.js → index-m668wzyc.js} +10 -2
- package/dist/{index-w9m1wznn.js → index-nemjkxjp.js} +118 -1
- package/dist/{index-tnazr5tc.js → index-pz7ytdga.js} +3 -3
- package/dist/{index-1z5xxfst.js → index-rqpdar1e.js} +102 -5
- package/dist/{index-qm87g51s.js → index-s4c8wy8m.js} +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +103 -14
- package/dist/node.js +2 -2
- package/dist/observability/index.js +1 -1
- package/dist/primitives/audit.d.ts +52 -0
- package/dist/primitives/audit.d.ts.map +1 -0
- package/dist/primitives/deadline.d.ts +39 -0
- package/dist/primitives/deadline.d.ts.map +1 -0
- package/dist/primitives/decimal.d.ts +10 -0
- package/dist/primitives/decimal.d.ts.map +1 -0
- package/dist/primitives/delivery.d.ts +96 -0
- package/dist/primitives/delivery.d.ts.map +1 -0
- package/dist/primitives/event.d.ts +42 -0
- package/dist/primitives/event.d.ts.map +1 -0
- package/dist/primitives/export-operation.d.ts +89 -0
- package/dist/primitives/export-operation.d.ts.map +1 -0
- package/dist/primitives/index.d.ts +12 -0
- package/dist/primitives/index.d.ts.map +1 -0
- package/dist/primitives/lifecycle.d.ts +90 -0
- package/dist/primitives/lifecycle.d.ts.map +1 -0
- package/dist/primitives/migration-checks.d.ts +15 -0
- package/dist/primitives/migration-checks.d.ts.map +1 -0
- package/dist/primitives/money.d.ts +43 -0
- package/dist/primitives/money.d.ts.map +1 -0
- package/dist/primitives/owner-scope.d.ts +30 -0
- package/dist/primitives/owner-scope.d.ts.map +1 -0
- package/dist/primitives/permission.d.ts +28 -0
- package/dist/primitives/permission.d.ts.map +1 -0
- package/dist/primitives/quantity.d.ts +57 -0
- package/dist/primitives/quantity.d.ts.map +1 -0
- package/dist/primitives.d.ts +3 -0
- package/dist/primitives.d.ts.map +1 -0
- package/dist/primitives.js +750 -0
- package/dist/server/index.d.ts +1 -1
- package/dist/server/index.d.ts.map +1 -1
- package/dist/server/index.js +4 -2
- package/dist/server/request.d.ts +19 -0
- package/dist/server/request.d.ts.map +1 -1
- package/dist/telegram/init-data.d.ts +134 -0
- package/dist/telegram/init-data.d.ts.map +1 -0
- package/dist/telegram/send-failure.d.ts +73 -0
- package/dist/telegram/send-failure.d.ts.map +1 -0
- package/dist/telegram.d.ts +3 -0
- package/dist/telegram.d.ts.map +1 -0
- package/dist/telegram.js +224 -0
- package/dist/tool-invoker.js +4 -4
- package/dist/tools.js +7 -7
- package/llms-full.txt +510 -10
- package/llms.txt +1 -0
- package/native/darwin-arm64.node +0 -0
- package/native/darwin-x64.node +0 -0
- package/package.json +11 -3
package/dist/server/index.d.ts
CHANGED
|
@@ -20,7 +20,7 @@ export { bindProcessSignals, type ProcessSignalName, type ProcessSignalsBinding,
|
|
|
20
20
|
export { createRateLimiter, type RateLimitConfig } from './rate-limit.js';
|
|
21
21
|
export { errorResponse, parseBody, respondJson } from './raw.js';
|
|
22
22
|
export { bindRealtimeServer, type RealtimeServer, type RealtimeServerConnection, type RealtimeServerHandle, } from './realtime.js';
|
|
23
|
-
export { type ClientIpOptions, extractIp, generateTraceId, getClientInfo, resolveSocketIp, resolveTraceId, } from './request.js';
|
|
23
|
+
export { type ClientIpOptions, extractIp, generateTraceId, getClientInfo, isPublicIp, resolveSocketIp, resolveTraceId, } from './request.js';
|
|
24
24
|
export { type ManagedServerHandle, type ShutdownOptions, ShutdownOptionsSchema, type ShutdownResult, ShutdownResultSchema, type ShutdownState, ShutdownStateSchema, type ShutdownStatus, ShutdownStatusSchema, } from './shutdown.js';
|
|
25
25
|
export type { SocketIOHandshakeConfig, SocketIOPeerLoaders, SocketIORequestPolicy, SocketIOServerConfig, SocketIOServerHandle, SocketIOServerLifecycle, } from './socket-io.js';
|
|
26
26
|
export { createSocketIOServer, socketIoLane } from './socket-io.js';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,KAAK,eAAe,EACpB,YAAY,GACb,MAAM,aAAa,CAAC;AAIrB,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,KAAK,eAAe,EACpB,SAAS,GACV,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACL,KAAK,mBAAmB,IAAI,gBAAgB,EAC5C,KA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MAAM,aAAa,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/server/index.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EACR,QAAQ,EACR,UAAU,EACV,QAAQ,EACR,SAAS,EACT,iBAAiB,EACjB,QAAQ,EACR,WAAW,EACX,mBAAmB,EACnB,KAAK,eAAe,EACpB,YAAY,GACb,MAAM,aAAa,CAAC;AAIrB,OAAO,EACL,SAAS,EACT,cAAc,EACd,cAAc,EACd,KAAK,eAAe,EACpB,SAAS,GACV,MAAM,oBAAoB,CAAC;AAG5B,OAAO,EAAE,WAAW,EAAE,MAAM,wBAAwB,CAAC;AACrD,OAAO,EACL,KAAK,mBAAmB,IAAI,gBAAgB,EAC5C,KAAK,eAAe,IAAI,YAAY,EACpC,KAAK,gBAAgB,IAAI,aAAa,EACtC,KAAK,WAAW,IAAI,QAAQ,EAC5B,KAAK,kBAAkB,IAAI,eAAe,EAC1C,KAAK,SAAS,EACd,KAAK,eAAe,EACpB,KAAK,eAAe,EACpB,YAAY,EACZ,KAAK,iBAAiB,EACtB,KAAK,gBAAgB,GACtB,MAAM,OAAO,CAAC;AACf,OAAO,EAAE,KAAK,YAAY,EAAE,YAAY,EAAE,WAAW,EAAE,MAAM,SAAS,CAAC;AACvE,OAAO,EAAE,aAAa,EAAE,MAAM,UAAU,CAAC;AACzC,OAAO,EACL,eAAe,EACf,KAAK,eAAe,EACpB,KAAK,aAAa,GACnB,MAAM,cAAc,CAAC;AACtB,OAAO,EACL,cAAc,EACd,KAAK,eAAe,EACpB,KAAK,QAAQ,EACb,KAAK,eAAe,EACpB,KAAK,YAAY,GAClB,MAAM,aAAa,CAAC;AACrB,OAAO,EACL,KAAK,SAAS,EACd,cAAc,EACd,KAAK,gBAAgB,EACrB,SAAS,EACT,WAAW,EACX,QAAQ,GACT,MAAM,QAAQ,CAAC;AAChB,OAAO,EACL,eAAe,EACf,uBAAuB,EACvB,qBAAqB,EACrB,qBAAq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d,sBAAsB,EACtB,QAAQ,EACR,cAAc,EACd,aAAa,EACb,UAAU,EACV,SAAS,EACT,qBAAqB,EACrB,iBAAiB,EACjB,uBAAuB,EACvB,iBAAiB,EACjB,UAAU,EACV,aAAa,EACb,cAAc,EACd,UAAU,EACV,YAAY,EACZ,gCAAgC,GACjC,MAAM,SAAS,CAAC;AACjB,OAAO,EACL,yBAAyB,EACzB,KAAK,uBAAuB,EAC5B,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,EAC9B,wBAAwB,EACxB,KAAK,4BAA4B,EACjC,KAAK,oBAAoB,GAC1B,MAAM,eAAe,CAAC;AACvB,OAAO,EACL,KAAK,YAAY,EACjB,wBAAwB,EACxB,KAAK,sBAAsB,EAC3B,KAAK,aAAa,EAClB,aAAa,GACd,MAAM,aAAa,CAAC"}
|
package/dist/server/index.js
CHANGED
|
@@ -13,7 +13,7 @@ import {
|
|
|
13
13
|
sseRoute,
|
|
14
14
|
streamingRoute,
|
|
15
15
|
webSocketLane
|
|
16
|
-
} from "../index-
|
|
16
|
+
} from "../index-118v0z41.js";
|
|
17
17
|
import {
|
|
18
18
|
composeAuthHooks,
|
|
19
19
|
createAuthHook,
|
|
@@ -46,9 +46,10 @@ import {
|
|
|
46
46
|
generateTraceId,
|
|
47
47
|
getClientInfo,
|
|
48
48
|
getTraceId,
|
|
49
|
+
isPublicIp,
|
|
49
50
|
resolveSocketIp,
|
|
50
51
|
resolveTraceId
|
|
51
|
-
} from "../index-
|
|
52
|
+
} from "../index-nemjkxjp.js";
|
|
52
53
|
import {
|
|
53
54
|
isWithinDir,
|
|
54
55
|
realPathWithinDir
|
|
@@ -1007,6 +1008,7 @@ export {
|
|
|
1007
1008
|
ndjsonRoute,
|
|
1008
1009
|
isWithinDir,
|
|
1009
1010
|
isStitchErrorCode,
|
|
1011
|
+
isPublicIp,
|
|
1010
1012
|
implementRegistry,
|
|
1011
1013
|
implement,
|
|
1012
1014
|
getClientInfo,
|
package/dist/server/request.d.ts
CHANGED
|
@@ -42,4 +42,23 @@ export declare function getClientInfo(req: Request, options?: ClientIpOptions):
|
|
|
42
42
|
};
|
|
43
43
|
/** Flatten a URL query string — repeated keys collapse to arrays. */
|
|
44
44
|
export declare function parseQueryParams(url: URL): Record<string, string | string[]>;
|
|
45
|
+
/**
|
|
46
|
+
* Whether an address belongs to the public internet.
|
|
47
|
+
*
|
|
48
|
+
* The question behind it is always the same one: *may this address be handed to
|
|
49
|
+
* something outside this process* — resolved against a third party, fetched
|
|
50
|
+
* from, recorded as where a request came from. A loopback, a private LAN
|
|
51
|
+
* address, a carrier-NAT address or a link-local one answer no, each for its
|
|
52
|
+
* own reason, and none of them identifies a host anyone else can reach.
|
|
53
|
+
*
|
|
54
|
+
* **Anything it cannot parse is not public.** An empty string, a hostname, a
|
|
55
|
+
* truncated address: the honest answer to "is this a public peer" is no, and a
|
|
56
|
+
* function that returned `true` for a value it did not understand would be
|
|
57
|
+
* safe-by-accident exactly until the first malformed header.
|
|
58
|
+
*
|
|
59
|
+
* IPv4-mapped IPv6 (`::ffff:10.0.0.1`) is judged as the IPv4 address it
|
|
60
|
+
* carries — the mapping is notation, not a different host. Pair it with
|
|
61
|
+
* `extractIp`, which produces the value this asks about.
|
|
62
|
+
*/
|
|
63
|
+
export declare function isPublicIp(value: string): boolean;
|
|
45
64
|
//# sourceMappingURL=request.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"request.d.ts","sourceRoot":"","sources":["../../src/server/request.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAKH,6EAA6E;AAC7E,wBAAgB,eAAe,IAAI,MAAM,CAExC;AAED;;;;GAIG;AACH,wBAAgB,cAAc,CAAC,GAAG,EAAE,OAAO,GAAG,MAAM,CASnD;AAED;;;;;GAKG;AACH,wBAAgB,eAAe,CAAC,GAAG,EAAE,OAAO,EAAE,MAAM,EAAE,OAAO,GAAG,MAAM,GAAG,SAAS,CAejF;AAED,iDAAiD;AACjD,MAAM,WAAW,eAA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C;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB,CAKA;AAED,qEAAqE;AACrE,wBAAgB,gBAAgB,CAAC,GAAG,EAAE,GAAG,GAAG,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,EAAE,CAAC,CAU5E;AAgGD;;;;;;;;;;;;;;;;;GAiBG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,MAAM,GAAG,OAAO,CA+BjD"}
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Who a Telegram Mini App request is from, proved rather than believed.
|
|
3
|
+
*
|
|
4
|
+
* A Mini App hands its backend an `initData` string. Telegram signs it with a
|
|
5
|
+
* key derived from the bot token, so a backend that checks the signature knows
|
|
6
|
+
* the user; a backend that reads `initDataUnsafe` and trusts it has an open
|
|
7
|
+
* door — the string is fully client-controlled, and the name Telegram gave that
|
|
8
|
+
* field is the whole warning.
|
|
9
|
+
*
|
|
10
|
+
* Three consuming applications wrote this check independently. Two of the three
|
|
11
|
+
* files agree closely enough to have shared an ancestor, and the third had
|
|
12
|
+
* drifted: the algorithm is short, published, and easy to get *almost* right.
|
|
13
|
+
* Almost right is the failure mode worth removing — a comparison that returns
|
|
14
|
+
* early on the first differing byte, an expiry checked before the signature, a
|
|
15
|
+
* `user` field read out of the string before anything proved it was ours.
|
|
16
|
+
*
|
|
17
|
+
* **This verifies; it does not phrase and it does not decide.** What a rejected
|
|
18
|
+
* request should answer, whether an expired one may re-authenticate, which
|
|
19
|
+
* fields a session keeps — those belong to the application. What the core owes
|
|
20
|
+
* is the distinction between *authentic* and *not*, and the reason when not.
|
|
21
|
+
*
|
|
22
|
+
* Not a domain model (→ ADR 0002): "Telegram signed this string" is a fact
|
|
23
|
+
* about a transport, the same kind of fact as a bearer token being well-formed.
|
|
24
|
+
*/
|
|
25
|
+
import { z } from 'zod';
|
|
26
|
+
/**
|
|
27
|
+
* The Telegram user record, as our surface names things.
|
|
28
|
+
*
|
|
29
|
+
* Telegram's wire fields are `snake_case`; every other name this package
|
|
30
|
+
* publishes is `camelCase`, and a surface that switches convention because of
|
|
31
|
+
* where a value came from makes the caller remember which is which. The
|
|
32
|
+
* untouched wire pairs stay available in `raw`.
|
|
33
|
+
*/
|
|
34
|
+
declare const TelegramInitDataUserSchema: z.ZodPipe<z.ZodObject<{
|
|
35
|
+
id: z.ZodInt;
|
|
36
|
+
is_bot: z.ZodOptional<z.ZodBoolean>;
|
|
37
|
+
first_name: z.ZodString;
|
|
38
|
+
last_name: z.ZodOptional<z.ZodString>;
|
|
39
|
+
username: z.ZodOptional<z.ZodString>;
|
|
40
|
+
language_code: z.ZodOptional<z.ZodString>;
|
|
41
|
+
is_premium: z.ZodOptional<z.ZodBoolean>;
|
|
42
|
+
allows_write_to_pm: z.ZodOptional<z.ZodBoolean>;
|
|
43
|
+
photo_url: z.ZodOptional<z.ZodString>;
|
|
44
|
+
}, z.core.$strip>, z.ZodTransform<{
|
|
45
|
+
id: number;
|
|
46
|
+
firstName: string;
|
|
47
|
+
isBot?: boolean | undefined;
|
|
48
|
+
lastName?: string | undefined;
|
|
49
|
+
username?: string | undefined;
|
|
50
|
+
languageCode?: string | undefined;
|
|
51
|
+
isPremium?: boolean | undefined;
|
|
52
|
+
allowsWriteToPm?: boolean | undefined;
|
|
53
|
+
photoUrl?: string | undefined;
|
|
54
|
+
}, {
|
|
55
|
+
id: number;
|
|
56
|
+
is_bot?: boolean | undefined;
|
|
57
|
+
first_name: string;
|
|
58
|
+
last_name?: string | undefined;
|
|
59
|
+
username?: string | undefined;
|
|
60
|
+
language_code?: string | undefined;
|
|
61
|
+
is_premium?: boolean | undefined;
|
|
62
|
+
allows_write_to_pm?: boolean | undefined;
|
|
63
|
+
photo_url?: string | undefined;
|
|
64
|
+
}>>;
|
|
65
|
+
export type TelegramInitDataUser = z.infer<typeof TelegramInitDataUserSchema>;
|
|
66
|
+
export interface TelegramInitData {
|
|
67
|
+
/** Absent when the Mini App was opened somewhere Telegram sends no user. */
|
|
68
|
+
user?: TelegramInitDataUser;
|
|
69
|
+
/** Whose chat the Mini App was opened from, when Telegram named one. */
|
|
70
|
+
receiver?: TelegramInitDataUser;
|
|
71
|
+
/** When Telegram signed this string. */
|
|
72
|
+
authDate: Date;
|
|
73
|
+
/** How old the signature was at verification time. */
|
|
74
|
+
ageSeconds: number;
|
|
75
|
+
queryId?: string;
|
|
76
|
+
startParam?: string;
|
|
77
|
+
chatType?: string;
|
|
78
|
+
chatInstance?: string;
|
|
79
|
+
/**
|
|
80
|
+
* Every signed pair exactly as Telegram sent it, `hash` excluded.
|
|
81
|
+
*
|
|
82
|
+
* Telegram adds fields without warning, and a caller that needs one this
|
|
83
|
+
* release has never heard of should not have to wait for a release to read
|
|
84
|
+
* it. Everything here was covered by the signature.
|
|
85
|
+
*/
|
|
86
|
+
raw: Readonly<Record<string, string>>;
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Why a string was not accepted.
|
|
90
|
+
*
|
|
91
|
+
* `signature-mismatch` is the only one that means someone tampered; the others
|
|
92
|
+
* are shapes a legitimate client can produce, and an application may well
|
|
93
|
+
* answer them differently — an expired string is a re-open, a malformed one is
|
|
94
|
+
* a bug report.
|
|
95
|
+
*/
|
|
96
|
+
export type TelegramInitDataRefusal = 'missing-hash' | 'signature-mismatch' | 'malformed' | 'expired';
|
|
97
|
+
export type TelegramInitDataVerification = {
|
|
98
|
+
readonly valid: true;
|
|
99
|
+
readonly data: TelegramInitData;
|
|
100
|
+
} | {
|
|
101
|
+
readonly valid: false;
|
|
102
|
+
readonly reason: TelegramInitDataRefusal;
|
|
103
|
+
/** Present on `expired`, where the number is the point of the refusal. */
|
|
104
|
+
readonly ageSeconds?: number;
|
|
105
|
+
};
|
|
106
|
+
export interface VerifyTelegramInitDataOptions {
|
|
107
|
+
/** The raw query-string Telegram handed the Mini App. */
|
|
108
|
+
initData: string;
|
|
109
|
+
/** The bot the Mini App belongs to. Never leaves this function. */
|
|
110
|
+
botToken: string;
|
|
111
|
+
/**
|
|
112
|
+
* Refuse a signature older than this many seconds.
|
|
113
|
+
*
|
|
114
|
+
* A signed string stays valid forever unless something bounds it, so a
|
|
115
|
+
* captured one is a permanent credential. Omitted means no bound, which is a
|
|
116
|
+
* deliberate choice rather than a default: only the application knows how
|
|
117
|
+
* long its own session is worth.
|
|
118
|
+
*/
|
|
119
|
+
maxAgeSeconds?: number;
|
|
120
|
+
/** Epoch milliseconds, for a caller that owns its own clock. */
|
|
121
|
+
now?: () => number;
|
|
122
|
+
}
|
|
123
|
+
/**
|
|
124
|
+
* Verify one `initData` string and report what it says.
|
|
125
|
+
*
|
|
126
|
+
* Never throws for anything a client can send: a string that fails is a
|
|
127
|
+
* refusal with a reason, because the caller has to answer the request either
|
|
128
|
+
* way and an exception for the ordinary case turns every handler into a
|
|
129
|
+
* `try`/`catch`. A missing bot token is not that case — it is this process
|
|
130
|
+
* being configured wrong, and it throws.
|
|
131
|
+
*/
|
|
132
|
+
export declare function verifyTelegramInitData(options: VerifyTelegramInitDataOptions): Promise<TelegramInitDataVerification>;
|
|
133
|
+
export {};
|
|
134
|
+
//# sourceMappingURL=init-data.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"init-data.d.ts","sourceRoot":"","sources":["../../src/telegram/init-data.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AAEH,OAAO,EAAE,CAAC,EAAE,MAAM,KAAK,CAAC;AAExB;;;;;;;GAOG;AACH,QAAA,MAAM,0BAA0B;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAsB3B,CAAC;AAEN,MAAM,MAAM,oBAAoB,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,0BAA0B,CAAC,CAAC;AAE9E,MAAM,WAAW,gBAAgB;IAC/B,4EAA4E;IAC5E,IAAI,CAAC,EAAE,oBAAoB,CAAC;IAC5B,wEAAwE;IACxE,QAAQ,CAAC,EAAE,oBAAoB,CAAC;IAChC,wCAAwC;IACxC,QAAQ,EAAE,IAAI,CAAC;IACf,sDAAsD;IACtD,UAAU,EAAE,MAAM,CAAC;IACnB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,UAAU,CAAC,EAAE,MAAM,CAAC;IACpB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,YAAY,CAAC,EAAE,MAAM,CAAC;IACtB;;;;;;OAMG;IACH,GAAG,EAAE,QAAQ,CAAC,MAAM,CAAC,MAAM,EAAE,MAAM,CAAC,CAAC,CAAC;CACvC;AAED;;;;;;;GAOG;AACH,MAAM,MAAM,uBAAuB,GAC/B,cAAc,GACd,oBAAoB,GACpB,WAAW,GACX,SAAS,CAAC;AAEd,MAAM,MAAM,4BAA4B,GACpC;IAAE,QAAQ,CAAC,KAAK,EAAE,IAAI,CAAC;IAAC,QAAQ,CAAC,IAAI,EAAE,gBAAgB,CAAA;CAAE,GACzD;IACE,QAAQ,CAAC,KAAK,EAAE,KAAK,CAAC;IACtB,QAAQ,CAAC,MAAM,EAAE,uBAAuB,CAAC;IACzC,0EAA0E;IAC1E,QAAQ,CAAC,UAAU,CAAC,EAAE,MAAM,CAAC;CAC9B,CAAC;AAEN,MAAM,WAAW,6BAA6B;IAC5C,yDAAyD;IACzD,QAAQ,EAAE,MAAM,CAAC;IACjB,mEAAmE;IACnE,QAAQ,EAAE,MAAM,CAAC;IACjB;;;;;;;OAOG;IACH,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,gEAAgE;IAChE,GAAG,CAAC,EAAE,MAAM,MAAM,CAAC;CACpB;AAiDD;;;;;;;;GAQG;AACH,wBAAsB,sBAAsB,CAC1C,OAAO,EAAE,6BAA6B,GACrC,OAAO,CAAC,4BAA4B,CAAC,CAuEvC"}
|
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* What a refused Telegram send was, as a fact rather than as a sentence.
|
|
3
|
+
*
|
|
4
|
+
* Two consuming applications carry the same broadcast subsystem — three of its
|
|
5
|
+
* files byte-identical — and inside it the same list of substrings: *bot was
|
|
6
|
+
* blocked*, *user is deactivated*, *chat not found*. The list exists because
|
|
7
|
+
* the Bot API answers a permanently unreachable recipient and a temporarily
|
|
8
|
+
* throttled one with the same shape, and a sender that cannot tell them apart
|
|
9
|
+
* either retries a user who will never receive anything or drops one who would
|
|
10
|
+
* have.
|
|
11
|
+
*
|
|
12
|
+
* The two questions are separate on purpose. `retryable` asks whether *this
|
|
13
|
+
* send* could work if repeated; `recipientUnreachable` asks whether *this
|
|
14
|
+
* recipient* should be addressed again at all. A rate limit is the first
|
|
15
|
+
* without the second; a blocked user is the second without the first; a
|
|
16
|
+
* message Telegram could not parse is neither — the recipient is fine and it is
|
|
17
|
+
* our payload that is wrong, which is exactly the case a substring list marks
|
|
18
|
+
* as a delivery failure and quietly counts against the wrong party.
|
|
19
|
+
*
|
|
20
|
+
* **This classifies; it does not act.** Whether to retry, how long to wait,
|
|
21
|
+
* whether a blocked user is deleted or merely flagged — the application's,
|
|
22
|
+
* along with every sentence a human reads. → ADR 0141.
|
|
23
|
+
*/
|
|
24
|
+
/**
|
|
25
|
+
* Why a send did not arrive.
|
|
26
|
+
*
|
|
27
|
+
* Each member earns its name by implying a different next move. The four that
|
|
28
|
+
* mean "not this recipient" are not folded together: a deactivated account is
|
|
29
|
+
* gone and its row can be closed, a block can be lifted and the row is kept, a
|
|
30
|
+
* user who never pressed Start needs an invitation rather than a retry, and a
|
|
31
|
+
* chat Telegram does not know is usually a bad identifier on our side — a
|
|
32
|
+
* defect in our data, not a fact about a person.
|
|
33
|
+
*/
|
|
34
|
+
export type TelegramSendFailureReason = 'blocked-by-user' | 'user-deactivated' | 'chat-not-found' | 'not-started' | 'rate-limited' | 'message-invalid' | 'server-error' | 'unknown';
|
|
35
|
+
export interface TelegramSendFailure {
|
|
36
|
+
reason: TelegramSendFailureReason;
|
|
37
|
+
/** Telegram's `error_code`, when the failure carried one. */
|
|
38
|
+
status?: number;
|
|
39
|
+
/**
|
|
40
|
+
* How long Telegram asked us to wait, from its own `parameters.retry_after`.
|
|
41
|
+
*
|
|
42
|
+
* Only ever present when Telegram said it. A sender that needs a number
|
|
43
|
+
* anyway picks its own backoff; inventing one here would put a guess and a
|
|
44
|
+
* statement in the same field.
|
|
45
|
+
*/
|
|
46
|
+
retryAfterSeconds?: number;
|
|
47
|
+
/** Repeating this same send could plausibly succeed. */
|
|
48
|
+
retryable: boolean;
|
|
49
|
+
/**
|
|
50
|
+
* This recipient will not receive this or any later message until something
|
|
51
|
+
* outside our control changes, so a broadcast should stop addressing them.
|
|
52
|
+
*
|
|
53
|
+
* Asserted only for the reasons that actually establish it. An unrecognised
|
|
54
|
+
* refusal leaves it `false`: marking a recipient unreachable on a guess is
|
|
55
|
+
* how a working subscriber is silently dropped forever, and that error is
|
|
56
|
+
* far more expensive than one wasted send.
|
|
57
|
+
*/
|
|
58
|
+
recipientUnreachable: boolean;
|
|
59
|
+
/**
|
|
60
|
+
* How the reason was reached. `parameters` and `status` are Telegram stating
|
|
61
|
+
* its own answer in a structured field; `description` is us reading its
|
|
62
|
+
* prose, which changes without notice.
|
|
63
|
+
*/
|
|
64
|
+
evidence: 'parameters' | 'status' | 'description' | 'none';
|
|
65
|
+
}
|
|
66
|
+
/**
|
|
67
|
+
* Classify one refused send.
|
|
68
|
+
*
|
|
69
|
+
* Never throws and never guesses: a refusal it does not recognise is `unknown`,
|
|
70
|
+
* which asserts nothing about the recipient and permits no retry.
|
|
71
|
+
*/
|
|
72
|
+
export declare function classifyTelegramSendFailure(error: unknown): TelegramSendFailure;
|
|
73
|
+
//# sourceMappingURL=send-failure.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"send-failure.d.ts","sourceRoot":"","sources":["../../src/telegram/send-failure.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;;;GAsBG;AAIH;;;;;;;;;GASG;AACH,MAAM,MAAM,yBAAyB,GACjC,iBAAiB,GACjB,kBAAkB,GAClB,gBAAgB,GAChB,aAAa,GACb,cAAc,GACd,iBAAiB,GACjB,cAAc,GACd,SAAS,CAAC;AAEd,MAAM,WAAW,mBAAmB;IAClC,MAAM,EAAE,yBAAyB,CAAC;IAClC,6DAA6D;IAC7D,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB;;;;;;OAMG;IACH,iBAAiB,CAAC,EAAE,MAAM,CAAC;IAC3B,wDAAwD;IACxD,SAAS,EAAE,OAAO,CAAC;IACnB;;;;;;;;OAQG;IACH,oBAAoB,EAAE,OAAO,CAAC;IAC9B;;;;OAIG;IACH,QAAQ,EAAE,YAAY,GAAG,QAAQ,GAAG,aAAa,GAAG,MAAM,CAAC;CAC5D;AAuED;;;;;GAKG;AACH,wBAAgB,2BAA2B,CAAC,KAAK,EAAE,OAAO,GAAG,mBAAmB,CA0D/E"}
|
|
@@ -0,0 +1,3 @@
|
|
|
1
|
+
export { type TelegramInitData, type TelegramInitDataRefusal, type TelegramInitDataUser, type TelegramInitDataVerification, type VerifyTelegramInitDataOptions, verifyTelegramInitData, } from './telegram/init-data.js';
|
|
2
|
+
export { classifyTelegramSendFailure, type TelegramSendFailure, type TelegramSendFailureReason, } from './telegram/send-failure.js';
|
|
3
|
+
//# sourceMappingURL=telegram.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"telegram.d.ts","sourceRoot":"","sources":["../src/telegram.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,KAAK,gBAAgB,EACrB,KAAK,uBAAuB,EAC5B,KAAK,oBAAoB,EACzB,KAAK,4BAA4B,EACjC,KAAK,6BAA6B,EAClC,sBAAsB,GACvB,MAAM,sBAAsB,CAAC;AAC9B,OAAO,EACL,2BAA2B,EAC3B,KAAK,mBAAmB,EACxB,KAAK,yBAAyB,GAC/B,MAAM,yBAAyB,CAAC"}
|
package/dist/telegram.js
ADDED
|
@@ -0,0 +1,224 @@
|
|
|
1
|
+
import {
|
|
2
|
+
isRecord
|
|
3
|
+
} from "./index-qyrqwr4c.js";
|
|
4
|
+
|
|
5
|
+
// src/telegram/init-data.ts
|
|
6
|
+
import { z } from "zod";
|
|
7
|
+
var TelegramInitDataUserSchema = z.object({
|
|
8
|
+
id: z.int(),
|
|
9
|
+
is_bot: z.boolean().optional(),
|
|
10
|
+
first_name: z.string(),
|
|
11
|
+
last_name: z.string().optional(),
|
|
12
|
+
username: z.string().optional(),
|
|
13
|
+
language_code: z.string().optional(),
|
|
14
|
+
is_premium: z.boolean().optional(),
|
|
15
|
+
allows_write_to_pm: z.boolean().optional(),
|
|
16
|
+
photo_url: z.string().optional()
|
|
17
|
+
}).transform((user) => ({
|
|
18
|
+
id: user.id,
|
|
19
|
+
firstName: user.first_name,
|
|
20
|
+
...user.is_bot !== undefined && { isBot: user.is_bot },
|
|
21
|
+
...user.last_name !== undefined && { lastName: user.last_name },
|
|
22
|
+
...user.username !== undefined && { username: user.username },
|
|
23
|
+
...user.language_code !== undefined && { languageCode: user.language_code },
|
|
24
|
+
...user.is_premium !== undefined && { isPremium: user.is_premium },
|
|
25
|
+
...user.allows_write_to_pm !== undefined && { allowsWriteToPm: user.allows_write_to_pm },
|
|
26
|
+
...user.photo_url !== undefined && { photoUrl: user.photo_url }
|
|
27
|
+
}));
|
|
28
|
+
var encoder = new TextEncoder;
|
|
29
|
+
async function hmacSha256(key, message) {
|
|
30
|
+
const imported = await crypto.subtle.importKey("raw", key, { name: "HMAC", hash: "SHA-256" }, false, ["sign"]);
|
|
31
|
+
return crypto.subtle.sign("HMAC", imported, encoder.encode(message));
|
|
32
|
+
}
|
|
33
|
+
function toHex(buffer) {
|
|
34
|
+
return Array.from(new Uint8Array(buffer), (byte) => byte.toString(16).padStart(2, "0")).join("");
|
|
35
|
+
}
|
|
36
|
+
function digestsEqual(a, b) {
|
|
37
|
+
if (a.length !== b.length)
|
|
38
|
+
return false;
|
|
39
|
+
let difference = 0;
|
|
40
|
+
for (let index = 0;index < a.length; index += 1) {
|
|
41
|
+
difference |= a.charCodeAt(index) ^ b.charCodeAt(index);
|
|
42
|
+
}
|
|
43
|
+
return difference === 0;
|
|
44
|
+
}
|
|
45
|
+
function optionalUser(raw, key) {
|
|
46
|
+
const encoded = raw[key];
|
|
47
|
+
if (encoded === undefined)
|
|
48
|
+
return;
|
|
49
|
+
return TelegramInitDataUserSchema.parse(JSON.parse(encoded));
|
|
50
|
+
}
|
|
51
|
+
async function verifyTelegramInitData(options) {
|
|
52
|
+
if (!options.botToken)
|
|
53
|
+
throw new TypeError("botToken is required to verify initData");
|
|
54
|
+
if (options.maxAgeSeconds !== undefined && (!Number.isFinite(options.maxAgeSeconds) || options.maxAgeSeconds < 0)) {
|
|
55
|
+
throw new TypeError("maxAgeSeconds must be a non-negative finite number");
|
|
56
|
+
}
|
|
57
|
+
const params = new URLSearchParams(options.initData);
|
|
58
|
+
const hash = params.get("hash");
|
|
59
|
+
if (!hash)
|
|
60
|
+
return { valid: false, reason: "missing-hash" };
|
|
61
|
+
const signed = {};
|
|
62
|
+
for (const [key, value] of params) {
|
|
63
|
+
if (key === "hash")
|
|
64
|
+
continue;
|
|
65
|
+
signed[key] = value;
|
|
66
|
+
}
|
|
67
|
+
const dataCheckString = Object.keys(signed).sort().map((key) => `${key}=${signed[key]}`).join(`
|
|
68
|
+
`);
|
|
69
|
+
const secretKey = await hmacSha256(encoder.encode("WebAppData"), options.botToken);
|
|
70
|
+
const expected = toHex(await hmacSha256(secretKey, dataCheckString));
|
|
71
|
+
if (!digestsEqual(expected, hash.toLowerCase())) {
|
|
72
|
+
return { valid: false, reason: "signature-mismatch" };
|
|
73
|
+
}
|
|
74
|
+
const authDateSeconds = Number(signed.auth_date);
|
|
75
|
+
if (!Number.isSafeInteger(authDateSeconds) || authDateSeconds <= 0) {
|
|
76
|
+
return { valid: false, reason: "malformed" };
|
|
77
|
+
}
|
|
78
|
+
const nowMs = options.now?.() ?? Date.now();
|
|
79
|
+
const ageSeconds = Math.floor(nowMs / 1000) - authDateSeconds;
|
|
80
|
+
if (options.maxAgeSeconds !== undefined && ageSeconds > options.maxAgeSeconds) {
|
|
81
|
+
return { valid: false, reason: "expired", ageSeconds };
|
|
82
|
+
}
|
|
83
|
+
let user;
|
|
84
|
+
let receiver;
|
|
85
|
+
try {
|
|
86
|
+
user = optionalUser(signed, "user");
|
|
87
|
+
receiver = optionalUser(signed, "receiver");
|
|
88
|
+
} catch {
|
|
89
|
+
return { valid: false, reason: "malformed" };
|
|
90
|
+
}
|
|
91
|
+
return {
|
|
92
|
+
valid: true,
|
|
93
|
+
data: {
|
|
94
|
+
...user !== undefined && { user },
|
|
95
|
+
...receiver !== undefined && { receiver },
|
|
96
|
+
authDate: new Date(authDateSeconds * 1000),
|
|
97
|
+
ageSeconds,
|
|
98
|
+
...signed.query_id !== undefined && { queryId: signed.query_id },
|
|
99
|
+
...signed.start_param !== undefined && { startParam: signed.start_param },
|
|
100
|
+
...signed.chat_type !== undefined && { chatType: signed.chat_type },
|
|
101
|
+
...signed.chat_instance !== undefined && { chatInstance: signed.chat_instance },
|
|
102
|
+
raw: Object.freeze({ ...signed })
|
|
103
|
+
}
|
|
104
|
+
};
|
|
105
|
+
}
|
|
106
|
+
// src/telegram/send-failure.ts
|
|
107
|
+
var BY_DESCRIPTION = [
|
|
108
|
+
[/bot was blocked by the user|bot was kicked/i, "blocked-by-user"],
|
|
109
|
+
[/user is deactivated|account is deactivated/i, "user-deactivated"],
|
|
110
|
+
[/can'?t initiate conversation|need to start a conversation/i, "not-started"],
|
|
111
|
+
[/chat not found|peer_id_invalid|user not found/i, "chat-not-found"],
|
|
112
|
+
[/too many requests|retry later|flood/i, "rate-limited"],
|
|
113
|
+
[
|
|
114
|
+
/message is too long|can'?t parse entities|message text is empty|wrong file identifier|button_url_invalid/i,
|
|
115
|
+
"message-invalid"
|
|
116
|
+
]
|
|
117
|
+
];
|
|
118
|
+
var RETRYABLE = new Set([
|
|
119
|
+
"rate-limited",
|
|
120
|
+
"server-error"
|
|
121
|
+
]);
|
|
122
|
+
var UNREACHABLE = new Set([
|
|
123
|
+
"blocked-by-user",
|
|
124
|
+
"user-deactivated",
|
|
125
|
+
"chat-not-found",
|
|
126
|
+
"not-started"
|
|
127
|
+
]);
|
|
128
|
+
function numberAt(value, keys) {
|
|
129
|
+
if (!isRecord(value))
|
|
130
|
+
return;
|
|
131
|
+
for (const key of keys) {
|
|
132
|
+
const candidate = value[key];
|
|
133
|
+
if (typeof candidate === "number" && Number.isFinite(candidate))
|
|
134
|
+
return candidate;
|
|
135
|
+
}
|
|
136
|
+
return;
|
|
137
|
+
}
|
|
138
|
+
function statusOf(value, depth = 0) {
|
|
139
|
+
if (!isRecord(value) || depth > 4)
|
|
140
|
+
return;
|
|
141
|
+
const direct = numberAt(value, ["error_code", "statusCode", "status"]);
|
|
142
|
+
if (direct !== undefined && direct >= 400 && direct < 600)
|
|
143
|
+
return direct;
|
|
144
|
+
const nested = value.cause ?? value.response ?? value.error;
|
|
145
|
+
return nested === value ? undefined : statusOf(nested, depth + 1);
|
|
146
|
+
}
|
|
147
|
+
function retryAfterOf(value, depth = 0) {
|
|
148
|
+
if (!isRecord(value) || depth > 4)
|
|
149
|
+
return;
|
|
150
|
+
const direct = numberAt(value.parameters, ["retry_after"]);
|
|
151
|
+
if (direct !== undefined)
|
|
152
|
+
return direct;
|
|
153
|
+
const nested = value.cause ?? value.response ?? value.error;
|
|
154
|
+
return nested === value ? undefined : retryAfterOf(nested, depth + 1);
|
|
155
|
+
}
|
|
156
|
+
function descriptionOf(value, depth = 0) {
|
|
157
|
+
if (typeof value === "string")
|
|
158
|
+
return value;
|
|
159
|
+
if (value instanceof Error) {
|
|
160
|
+
const nested2 = isRecord(value) ? descriptionOf(value.cause, depth + 1) : "";
|
|
161
|
+
return `${value.message} ${nested2}`.trim();
|
|
162
|
+
}
|
|
163
|
+
if (!isRecord(value) || depth > 4)
|
|
164
|
+
return "";
|
|
165
|
+
const own = typeof value.description === "string" ? value.description : "";
|
|
166
|
+
const message = typeof value.message === "string" ? value.message : "";
|
|
167
|
+
const nested = descriptionOf(value.cause ?? value.response ?? value.error, depth + 1);
|
|
168
|
+
return [own, message, nested].filter(Boolean).join(" ");
|
|
169
|
+
}
|
|
170
|
+
function classifyTelegramSendFailure(error) {
|
|
171
|
+
const status = statusOf(error);
|
|
172
|
+
const retryAfterSeconds = retryAfterOf(error);
|
|
173
|
+
const description = descriptionOf(error);
|
|
174
|
+
if (retryAfterSeconds !== undefined) {
|
|
175
|
+
return {
|
|
176
|
+
reason: "rate-limited",
|
|
177
|
+
...status !== undefined && { status },
|
|
178
|
+
retryAfterSeconds,
|
|
179
|
+
retryable: true,
|
|
180
|
+
recipientUnreachable: false,
|
|
181
|
+
evidence: "parameters"
|
|
182
|
+
};
|
|
183
|
+
}
|
|
184
|
+
for (const [pattern, reason] of BY_DESCRIPTION) {
|
|
185
|
+
if (pattern.test(description)) {
|
|
186
|
+
return {
|
|
187
|
+
reason,
|
|
188
|
+
...status !== undefined && { status },
|
|
189
|
+
retryable: RETRYABLE.has(reason),
|
|
190
|
+
recipientUnreachable: UNREACHABLE.has(reason),
|
|
191
|
+
evidence: "description"
|
|
192
|
+
};
|
|
193
|
+
}
|
|
194
|
+
}
|
|
195
|
+
if (status === 429) {
|
|
196
|
+
return {
|
|
197
|
+
reason: "rate-limited",
|
|
198
|
+
status,
|
|
199
|
+
retryable: true,
|
|
200
|
+
recipientUnreachable: false,
|
|
201
|
+
evidence: "status"
|
|
202
|
+
};
|
|
203
|
+
}
|
|
204
|
+
if (status !== undefined && status >= 500) {
|
|
205
|
+
return {
|
|
206
|
+
reason: "server-error",
|
|
207
|
+
status,
|
|
208
|
+
retryable: true,
|
|
209
|
+
recipientUnreachable: false,
|
|
210
|
+
evidence: "status"
|
|
211
|
+
};
|
|
212
|
+
}
|
|
213
|
+
return {
|
|
214
|
+
reason: "unknown",
|
|
215
|
+
...status !== undefined && { status },
|
|
216
|
+
retryable: false,
|
|
217
|
+
recipientUnreachable: false,
|
|
218
|
+
evidence: "none"
|
|
219
|
+
};
|
|
220
|
+
}
|
|
221
|
+
export {
|
|
222
|
+
verifyTelegramInitData,
|
|
223
|
+
classifyTelegramSendFailure
|
|
224
|
+
};
|
package/dist/tool-invoker.js
CHANGED
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import {
|
|
2
2
|
createToolInvoker
|
|
3
|
-
} from "./index-
|
|
4
|
-
import"./index-
|
|
5
|
-
import"./index-
|
|
6
|
-
import"./index-
|
|
3
|
+
} from "./index-jqtsc9mj.js";
|
|
4
|
+
import"./index-7qy2ex0m.js";
|
|
5
|
+
import"./index-s4c8wy8m.js";
|
|
6
|
+
import"./index-nemjkxjp.js";
|
|
7
7
|
import"./index-22by16v6.js";
|
|
8
8
|
import"./index-cby4ar3v.js";
|
|
9
9
|
import"./index-nt1mp8km.js";
|
package/dist/tools.js
CHANGED
|
@@ -4,7 +4,7 @@ import {
|
|
|
4
4
|
import {
|
|
5
5
|
buildToolManifest,
|
|
6
6
|
mountAgent
|
|
7
|
-
} from "./index-
|
|
7
|
+
} from "./index-ezmn6ac6.js";
|
|
8
8
|
import"./index-3xnq72rz.js";
|
|
9
9
|
import {
|
|
10
10
|
signJwt,
|
|
@@ -20,7 +20,7 @@ import {
|
|
|
20
20
|
} from "./index-vbf2p6me.js";
|
|
21
21
|
import {
|
|
22
22
|
createToolInvoker
|
|
23
|
-
} from "./index-
|
|
23
|
+
} from "./index-jqtsc9mj.js";
|
|
24
24
|
import {
|
|
25
25
|
WaitTimeoutError,
|
|
26
26
|
createCli,
|
|
@@ -29,10 +29,10 @@ import {
|
|
|
29
29
|
fetchPinnedDocument,
|
|
30
30
|
readCapped,
|
|
31
31
|
runWaitOperation
|
|
32
|
-
} from "./index-
|
|
32
|
+
} from "./index-pz7ytdga.js";
|
|
33
33
|
import {
|
|
34
34
|
collectToolSurface
|
|
35
|
-
} from "./index-
|
|
35
|
+
} from "./index-k2zczx1g.js";
|
|
36
36
|
import {
|
|
37
37
|
createRuntimeToolFactory,
|
|
38
38
|
defineRuntimeTool
|
|
@@ -41,19 +41,19 @@ import {
|
|
|
41
41
|
collectTools,
|
|
42
42
|
createToolRunner,
|
|
43
43
|
formatToolError
|
|
44
|
-
} from "./index-
|
|
44
|
+
} from "./index-7qy2ex0m.js";
|
|
45
45
|
import {
|
|
46
46
|
ToolExecutionControlError,
|
|
47
47
|
coerceJsonArgs,
|
|
48
48
|
executeToolMethod,
|
|
49
49
|
isToolExecutionControlError,
|
|
50
50
|
toolResultFromError
|
|
51
|
-
} from "./index-
|
|
51
|
+
} from "./index-s4c8wy8m.js";
|
|
52
52
|
import {
|
|
53
53
|
getRequestContext,
|
|
54
54
|
getTraceId,
|
|
55
55
|
runWithRequestContext
|
|
56
|
-
} from "./index-
|
|
56
|
+
} from "./index-nemjkxjp.js";
|
|
57
57
|
import {
|
|
58
58
|
ManagedFileError
|
|
59
59
|
} from "./index-bfcpjw20.js";
|