@isnap/sdk 0.0.0-next.3

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 (93) hide show
  1. package/CHANGELOG.md +15 -0
  2. package/LICENSE +21 -0
  3. package/README.md +242 -0
  4. package/dist/client.d.ts +50 -0
  5. package/dist/client.d.ts.map +1 -0
  6. package/dist/client.js +242 -0
  7. package/dist/client.js.map +1 -0
  8. package/dist/config.d.ts +43 -0
  9. package/dist/config.d.ts.map +1 -0
  10. package/dist/config.js +55 -0
  11. package/dist/config.js.map +1 -0
  12. package/dist/errors.d.ts +53 -0
  13. package/dist/errors.d.ts.map +1 -0
  14. package/dist/errors.js +100 -0
  15. package/dist/errors.js.map +1 -0
  16. package/dist/generated/openapi.d.ts +7963 -0
  17. package/dist/idempotency.d.ts +2 -0
  18. package/dist/idempotency.d.ts.map +1 -0
  19. package/dist/idempotency.js +4 -0
  20. package/dist/idempotency.js.map +1 -0
  21. package/dist/index.d.ts +28 -0
  22. package/dist/index.d.ts.map +1 -0
  23. package/dist/index.js +14 -0
  24. package/dist/index.js.map +1 -0
  25. package/dist/internal/sleep.d.ts +10 -0
  26. package/dist/internal/sleep.d.ts.map +1 -0
  27. package/dist/internal/sleep.js +37 -0
  28. package/dist/internal/sleep.js.map +1 -0
  29. package/dist/pagination.d.ts +10 -0
  30. package/dist/pagination.d.ts.map +1 -0
  31. package/dist/pagination.js +16 -0
  32. package/dist/pagination.js.map +1 -0
  33. package/dist/resources/attachments.d.ts +45 -0
  34. package/dist/resources/attachments.d.ts.map +1 -0
  35. package/dist/resources/attachments.js +120 -0
  36. package/dist/resources/attachments.js.map +1 -0
  37. package/dist/resources/base.d.ts +6 -0
  38. package/dist/resources/base.d.ts.map +1 -0
  39. package/dist/resources/base.js +7 -0
  40. package/dist/resources/base.js.map +1 -0
  41. package/dist/resources/byod.d.ts +15 -0
  42. package/dist/resources/byod.d.ts.map +1 -0
  43. package/dist/resources/byod.js +13 -0
  44. package/dist/resources/byod.js.map +1 -0
  45. package/dist/resources/chats.d.ts +29 -0
  46. package/dist/resources/chats.d.ts.map +1 -0
  47. package/dist/resources/chats.js +28 -0
  48. package/dist/resources/chats.js.map +1 -0
  49. package/dist/resources/lines.d.ts +70 -0
  50. package/dist/resources/lines.d.ts.map +1 -0
  51. package/dist/resources/lines.js +86 -0
  52. package/dist/resources/lines.js.map +1 -0
  53. package/dist/resources/lookup.d.ts +15 -0
  54. package/dist/resources/lookup.d.ts.map +1 -0
  55. package/dist/resources/lookup.js +13 -0
  56. package/dist/resources/lookup.js.map +1 -0
  57. package/dist/resources/messages.d.ts +42 -0
  58. package/dist/resources/messages.d.ts.map +1 -0
  59. package/dist/resources/messages.js +41 -0
  60. package/dist/resources/messages.js.map +1 -0
  61. package/dist/resources/trial.d.ts +28 -0
  62. package/dist/resources/trial.d.ts.map +1 -0
  63. package/dist/resources/trial.js +31 -0
  64. package/dist/resources/trial.js.map +1 -0
  65. package/dist/resources/webhooks.d.ts +58 -0
  66. package/dist/resources/webhooks.d.ts.map +1 -0
  67. package/dist/resources/webhooks.js +65 -0
  68. package/dist/resources/webhooks.js.map +1 -0
  69. package/dist/retry.d.ts +14 -0
  70. package/dist/retry.d.ts.map +1 -0
  71. package/dist/retry.js +47 -0
  72. package/dist/retry.js.map +1 -0
  73. package/dist/types.d.ts +33 -0
  74. package/dist/types.d.ts.map +1 -0
  75. package/dist/types.js +2 -0
  76. package/dist/types.js.map +1 -0
  77. package/dist/version.d.ts +2 -0
  78. package/dist/version.d.ts.map +1 -0
  79. package/dist/version.js +4 -0
  80. package/dist/version.js.map +1 -0
  81. package/dist/webhooks/parse.d.ts +15 -0
  82. package/dist/webhooks/parse.d.ts.map +1 -0
  83. package/dist/webhooks/parse.js +47 -0
  84. package/dist/webhooks/parse.js.map +1 -0
  85. package/dist/webhooks/types.d.ts +80 -0
  86. package/dist/webhooks/types.d.ts.map +1 -0
  87. package/dist/webhooks/types.js +17 -0
  88. package/dist/webhooks/types.js.map +1 -0
  89. package/dist/webhooks/verify.d.ts +41 -0
  90. package/dist/webhooks/verify.d.ts.map +1 -0
  91. package/dist/webhooks/verify.js +110 -0
  92. package/dist/webhooks/verify.js.map +1 -0
  93. package/package.json +65 -0
@@ -0,0 +1,86 @@
1
+ import { BaseResource } from './base.js';
2
+ export class LinesResource extends BaseResource {
3
+ /**
4
+ * `GET /v1/lines` — page/limit-paginated list of lines visible to the
5
+ * caller. Returns the wire-format envelope contents (`{lines, total,
6
+ * page, limit}`); not cursor-paginated like messages because the
7
+ * marketplace UI shows real "page X of Y" pagination.
8
+ */
9
+ list(query = {}, opts) {
10
+ return this.client.request('GET', '/v1/lines', undefined, {
11
+ ...opts,
12
+ query: { ...opts?.query, ...query }
13
+ });
14
+ }
15
+ /** `GET /v1/lines/my` — list of lines owned by the calling account. */
16
+ listMine(opts) {
17
+ return this.client.request('GET', '/v1/lines/my', undefined, opts);
18
+ }
19
+ /** `GET /v1/lines/{id}` — fetch a single line by ID or `line_<base62>` public ID. */
20
+ get(id, opts) {
21
+ return this.client.request('GET', `/v1/lines/${encodeURIComponent(id)}`, undefined, opts);
22
+ }
23
+ /**
24
+ * `POST /v1/lines/assign` — atomically find an available line matching
25
+ * the requested billing tier (and optional area code), reserve it, and
26
+ * activate it on the calling account in a single round-trip.
27
+ */
28
+ assign(body, opts) {
29
+ return this.client.request('POST', '/v1/lines/assign', body, opts);
30
+ }
31
+ /** `POST /v1/lines/{id}/reserve` — soft-hold a marketplace line for 15 minutes. */
32
+ reserve(id, opts) {
33
+ return this.client.request('POST', `/v1/lines/${encodeURIComponent(id)}/reserve`, undefined, opts);
34
+ }
35
+ /** `POST /v1/lines/{id}/activate` — flip a reserved line to `active`. */
36
+ activate(id, opts) {
37
+ return this.client.request('POST', `/v1/lines/${encodeURIComponent(id)}/activate`, undefined, opts);
38
+ }
39
+ /** `POST /v1/lines/{id}/release` — release an active or reserved line back to the pool. */
40
+ release(id, opts) {
41
+ return this.client.request('POST', `/v1/lines/${encodeURIComponent(id)}/release`, undefined, opts);
42
+ }
43
+ /**
44
+ * `POST /v1/lines/{id}/transfer-ownership` — reassign a line to a
45
+ * different end-user account without re-pairing the underlying device.
46
+ */
47
+ transferOwnership(id, body, opts) {
48
+ return this.client.request('POST', `/v1/lines/${encodeURIComponent(id)}/transfer-ownership`, body, opts);
49
+ }
50
+ /**
51
+ * `PATCH /v1/lines/{id}` — merge-patch the line's free-form metadata
52
+ * object. Null-valued keys delete those keys from the stored object.
53
+ */
54
+ patch(id, body, opts) {
55
+ return this.client.request('PATCH', `/v1/lines/${encodeURIComponent(id)}`, body, opts);
56
+ }
57
+ /** `GET /v1/lines/{id}/quota` — the line's current 5-bucket quota snapshot. */
58
+ quota(id, opts) {
59
+ return this.client.request('GET', `/v1/lines/${encodeURIComponent(id)}/quota`, undefined, opts);
60
+ }
61
+ /** `GET /v1/lines/{id}/queue` — pending scheduled / queued messages for the line. */
62
+ queue(id, query = {}, opts) {
63
+ return this.client.request('GET', `/v1/lines/${encodeURIComponent(id)}/queue`, undefined, { ...opts, query: { ...opts?.query, ...query } });
64
+ }
65
+ /**
66
+ * `GET /v1/lines/{id}/health` — BYOD-only line health snapshot. Throws
67
+ * `PermissionDeniedError` (`rental_health_not_exposed`) for rental
68
+ * tiers per contract §2.13.
69
+ */
70
+ health(id, opts) {
71
+ return this.client.request('GET', `/v1/lines/${encodeURIComponent(id)}/health`, undefined, opts);
72
+ }
73
+ /** `GET /v1/lines/{id}/config` — effective per-line config (system defaults + overrides). */
74
+ getConfig(id, opts) {
75
+ return this.client.request('GET', `/v1/lines/${encodeURIComponent(id)}/config`, undefined, opts);
76
+ }
77
+ /**
78
+ * `PATCH /v1/lines/{id}/config` — partial override of the line's
79
+ * config. BYOD callers can only lower limits / raise delays per
80
+ * contract §2.13.
81
+ */
82
+ updateConfig(id, body, opts) {
83
+ return this.client.request('PATCH', `/v1/lines/${encodeURIComponent(id)}/config`, body, opts);
84
+ }
85
+ }
86
+ //# sourceMapping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ACH,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,EAAU,EAAE,IAAqB;QACtC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,KAAK,EACL,aAAa,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAC5C,SAAS,EACT,IAAI,CACL,CAAA;IACH,CAAC;IAED,6FAA6F;IAC7F,SAAS,CAAC,EAAU,EAAE,IAAqB;QACzC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,KAAK,EACL,aAAa,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAC5C,SAAS,EACT,IAAI,CACL,CAAA;IACH,CAAC;IAED;;;;OAIG;IACH,YAAY,CACV,EAAU,EACV,IAAqB,EACrB,IAAqB;QAErB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,OAAO,EACP,aAAa,kBAAkB,CAAC,EAAE,CAAC,SAAS,EAC5C,IAAI,EACJ,IAAI,CACL,CAAA;IACH,CAAC;CACF"}
@@ -0,0 +1,15 @@
1
+ import type { components } from '../generated/openapi.js';
2
+ import type { RequestOptions } from '../types.js';
3
+ import { BaseResource } from './base.js';
4
+ export type LookupRequest = components['schemas']['LookupRequest'];
5
+ export type LookupResult = components['schemas']['Lookup'];
6
+ export declare class LookupResource extends BaseResource {
7
+ /**
8
+ * `POST /v1/lookup` — check whether a handle is reachable on iMessage,
9
+ * which carrier owns the SMS line, etc. Cached server-side for 24h per
10
+ * §2.10. May return `pending: true` with `retry_after` if the lookup is
11
+ * still in flight; consumers should poll or wait that many seconds.
12
+ */
13
+ check(params: LookupRequest, opts?: RequestOptions): Promise<LookupResult>;
14
+ }
15
+ //# sourceMappingURL=lookup.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup.d.ts","sourceRoot":"","sources":["../../src/resources/lookup.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAA;AAClE,MAAM,MAAM,YAAY,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,QAAQ,CAAC,CAAA;AAE1D,qBAAa,cAAe,SAAQ,YAAY;IAC9C;;;;;OAKG;IACH,KAAK,CAAC,MAAM,EAAE,aAAa,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,YAAY,CAAC;CAG3E"}
@@ -0,0 +1,13 @@
1
+ import { BaseResource } from './base.js';
2
+ export class LookupResource extends BaseResource {
3
+ /**
4
+ * `POST /v1/lookup` — check whether a handle is reachable on iMessage,
5
+ * which carrier owns the SMS line, etc. Cached server-side for 24h per
6
+ * §2.10. May return `pending: true` with `retry_after` if the lookup is
7
+ * still in flight; consumers should poll or wait that many seconds.
8
+ */
9
+ check(params, opts) {
10
+ return this.client.request('POST', '/v1/lookup', params, opts);
11
+ }
12
+ }
13
+ //# sourceMappingURL=lookup.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"lookup.js","sourceRoot":"","sources":["../../src/resources/lookup.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAKxC,MAAM,OAAO,cAAe,SAAQ,YAAY;IAC9C;;;;;OAKG;IACH,KAAK,CAAC,MAAqB,EAAE,IAAqB;QAChD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAe,MAAM,EAAE,YAAY,EAAE,MAAM,EAAE,IAAI,CAAC,CAAA;IAC9E,CAAC;CACF"}
@@ -0,0 +1,42 @@
1
+ import type { components, paths } from '../generated/openapi.js';
2
+ import type { RequestOptions } from '../types.js';
3
+ import { BaseResource } from './base.js';
4
+ /** Full message shape returned by send/get/cancel (contract §2.2 fat shape). */
5
+ export type Message = components['schemas']['MessageV1'];
6
+ /**
7
+ * Legacy message shape returned by `GET /v1/messages` cursor list. Differs
8
+ * from the fat shape on field names (`from_number`/`to_number` vs `from`/`to`)
9
+ * and missing fields (`effect`, `reply_to_message_id`, `queue_info`, etc.).
10
+ * Backend follow-up will harmonize the list shape with `MessageV1`.
11
+ */
12
+ export type ListedMessage = components['schemas']['Message'];
13
+ export type SendMessageBody = NonNullable<paths['/v1/messages']['post']['requestBody']>['content']['application/json'];
14
+ export type ListMessagesQuery = NonNullable<paths['/v1/messages']['get']['parameters']['query']>;
15
+ export type SendReactionBody = components['schemas']['SendReactionRequest'];
16
+ export type Reaction = components['schemas']['Reaction'];
17
+ export declare class MessagesResource extends BaseResource {
18
+ /** `POST /v1/messages` — send a new outbound message (queued, returns `MessageV1`). */
19
+ send(body: SendMessageBody, opts?: RequestOptions): Promise<Message>;
20
+ /** `GET /v1/messages/{id}` — fetch the full fat-shape message by ID. */
21
+ get(id: string, opts?: RequestOptions): Promise<Message>;
22
+ /**
23
+ * `GET /v1/messages` — cursor-paginated list as an AsyncIterable. The
24
+ * iterator threads the next_cursor across pages so the consumer can
25
+ * `for await (const m of client.messages.list({...}))` and get every
26
+ * matching message. Note: items use the legacy `Message` shape (see
27
+ * `ListedMessage` JSDoc).
28
+ */
29
+ list(filters?: Omit<ListMessagesQuery, 'cursor'>, opts?: RequestOptions): AsyncIterable<ListedMessage>;
30
+ /**
31
+ * `POST /v1/messages/{id}/reactions` — add or remove an Apple-native
32
+ * tapback (love/like/dislike/laugh/emphasize/question). Only iMessage
33
+ * messages can be reacted to.
34
+ */
35
+ react(messageId: string, body: SendReactionBody, opts?: RequestOptions): Promise<Reaction>;
36
+ /**
37
+ * `DELETE /v1/messages/{id}` — cancel a queued or scheduled message before
38
+ * it dispatches. Once `status: sent` the cancel is a 409.
39
+ */
40
+ cancel(id: string, opts?: RequestOptions): Promise<Message>;
41
+ }
42
+ //# sourceMappingURL=messages.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.d.ts","s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GACpB,aAAa,CAAC,aAAa,CAAC;IAW/B;;;;OAIG;IACH,KAAK,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,QAAQ,CAAC;IAS1F;;;OAGG;IACH,MAAM,CAAC,EAAE,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,OAAO,CAAC;CAQ5D"}
@@ -0,0 +1,41 @@
1
+ import { paginate } from '../pagination.js';
2
+ import { BaseResource } from './base.js';
3
+ export class MessagesResource extends BaseResource {
4
+ /** `POST /v1/messages` — send a new outbound message (queued, returns `MessageV1`). */
5
+ send(body, opts) {
6
+ return this.client.request('POST', '/v1/messages', body, opts);
7
+ }
8
+ /** `GET /v1/messages/{id}` — fetch the full fat-shape message by ID. */
9
+ get(id, opts) {
10
+ return this.client.request('GET', `/v1/messages/${encodeURIComponent(id)}`, undefined, opts);
11
+ }
12
+ /**
13
+ * `GET /v1/messages` — cursor-paginated list as an AsyncIterable. The
14
+ * iterator threads the next_cursor across pages so the consumer can
15
+ * `for await (const m of client.messages.list({...}))` and get every
16
+ * matching message. Note: items use the legacy `Message` shape (see
17
+ * `ListedMessage` JSDoc).
18
+ */
19
+ list(filters = {}, opts) {
20
+ return paginate((cursor) => this.client.request('GET', '/v1/messages', undefined, {
21
+ ...opts,
22
+ query: { ...filters, cursor }
23
+ }), { signal: opts?.signal });
24
+ }
25
+ /**
26
+ * `POST /v1/messages/{id}/reactions` — add or remove an Apple-native
27
+ * tapback (love/like/dislike/laugh/emphasize/question). Only iMessage
28
+ * messages can be reacted to.
29
+ */
30
+ react(messageId, body, opts) {
31
+ return this.client.request('POST', `/v1/messages/${encodeURIComponent(messageId)}/reactions`, body, opts);
32
+ }
33
+ /**
34
+ * `DELETE /v1/messages/{id}` — cancel a queued or scheduled message before
35
+ * it dispatches. Once `status: sent` the cancel is a 409.
36
+ */
37
+ cancel(id, opts) {
38
+ return this.client.request('DELETE', `/v1/messages/${encodeURIComponent(id)}`, undefined, opts);
39
+ }
40
+ }
41
+ //# sourceMappingURL=messages.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"messages.js","sourceRoot":"","sources":["../../src/resources/messages.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE3C,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAkBxC,MAAM,OAAO,gBAAiB,SAAQ,YAAY;IAChD,uFAAuF;IACvF,IAAI,CAAC,IAAqB,EAAE,IAAqB;QAC/C,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAU,MAAM,EAAE,cAAc,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IACzE,CAAC;IAED,wEAAwE;IACxE,GAAG,CAAC,EAAU,EAAE,IAAqB;QACnC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAU,KAAK,EAAE,gBAAgB,kBAAkB,CAAC,EAAE,CAAC,EAAE,EAAE,SAAS,EAAE,IAAI,CAAC,CAAA;IACvG,CAAC;IAED;;;;;;OAMG;IACH,IAAI,CACF,UAA6C,EAAE,EAC/C,IAAqB;QAErB,OAAO,QAAQ,CACb,CAAC,MAAM,EAAE,EAAE,CACT,IAAI,CAAC,MAAM,CAAC,OAAO,CAA4B,KAAK,EAAE,cAAc,EAAE,SAAS,EAAE;YAC/E,GAAG,IAAI;YACP,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE;SAC9B,CAAC,EACJ,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CACzB,CAAA;IACH,CAAC;IAED;;;;OAIG;IACH,KAAK,CAAC,SAAiB,EAAE,IAAsB,EAAE,IAAqB;QACpE,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,MAAM,EACN,gBAAgB,kBAAkB,CAAC,SAAS,CAAC,YAAY,EACzD,IAAI,EACJ,IAAI,CACL,CAAA;IACH,CAAC;IAED;;;OAGG;IACH,MAAM,CAAC,EAAU,EAAE,IAAqB;QACtC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,QAAQ,EACR,gBAAgB,kBAAkB,CAAC,EAAE,CAAC,EAAE,EACxC,SAAS,EACT,IAAI,CACL,CAAA;IACH,CAAC;CACF"}
@@ -0,0 +1,28 @@
1
+ import type { components } from '../generated/openapi.js';
2
+ import type { RequestOptions } from '../types.js';
3
+ import { BaseResource } from './base.js';
4
+ export type TrialInitBody = components['schemas']['TrialInitBody'];
5
+ export type TrialInitData = components['schemas']['TrialInitData'];
6
+ export type TrialStatusData = components['schemas']['TrialStatusData'];
7
+ export type TrialActivityData = components['schemas']['TrialActivityData'];
8
+ export declare class TrialResource extends BaseResource {
9
+ /**
10
+ * `POST /v1/trial/init` — create a new trial session. Returns the pool
11
+ * line phone number the partner must text from their device to pair
12
+ * within the 15-minute window, the opaque `token` to fetch status, and
13
+ * the `instructions_url` to deep-link the user.
14
+ */
15
+ init(body?: TrialInitBody, opts?: RequestOptions): Promise<TrialInitData>;
16
+ /**
17
+ * `GET /v1/trial/status?token=...` — poll status during the
18
+ * pairing-pending window or to retrieve the trial API key after
19
+ * pairing succeeds.
20
+ */
21
+ status(token: string, opts?: RequestOptions): Promise<TrialStatusData>;
22
+ /**
23
+ * `GET /v1/trial/activity` — current send/receive counters + dormancy
24
+ * remaining. Auth-gated by the trial API key issued from `init`/`status`.
25
+ */
26
+ activity(opts?: RequestOptions): Promise<TrialActivityData>;
27
+ }
28
+ //# sourceMappingURL=trial.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trial.d.ts","sourceRoot":"","sources":["../../src/resources/trial.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACzD,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAA;AAClE,MAAM,MAAM,aAAa,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,eAAe,CAAC,CAAA;AAClE,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,iBAAiB,CAAC,CAAA;AACtE,MAAM,MAAM,iBAAiB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,mBAAmB,CAAC,CAAA;AAE1E,qBAAa,aAAc,SAAQ,YAAY;IAC7C;;;;;OAKG;IACH,IAAI,CAAC,IAAI,GAAE,aAAkB,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,aAAa,CAAC;IAI7E;;;;OAIG;IACH,MAAM,CAAC,KAAK,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,eAAe,CAAC;IAOtE;;;OAGG;IACH,QAAQ,CAAC,IAAI,CAAC,EAAE,cAAc,GAAG,OAAO,CAAC,iBAAiB,CAAC;CAG5D"}
@@ -0,0 +1,31 @@
1
+ import { BaseResource } from './base.js';
2
+ export class TrialResource extends BaseResource {
3
+ /**
4
+ * `POST /v1/trial/init` — create a new trial session. Returns the pool
5
+ * line phone number the partner must text from their device to pair
6
+ * within the 15-minute window, the opaque `token` to fetch status, and
7
+ * the `instructions_url` to deep-link the user.
8
+ */
9
+ init(body = {}, opts) {
10
+ return this.client.request('POST', '/v1/trial/init', body, opts);
11
+ }
12
+ /**
13
+ * `GET /v1/trial/status?token=...` — poll status during the
14
+ * pairing-pending window or to retrieve the trial API key after
15
+ * pairing succeeds.
16
+ */
17
+ status(token, opts) {
18
+ return this.client.request('GET', '/v1/trial/status', undefined, {
19
+ ...opts,
20
+ query: { ...opts?.query, token }
21
+ });
22
+ }
23
+ /**
24
+ * `GET /v1/trial/activity` — current send/receive counters + dormancy
25
+ * remaining. Auth-gated by the trial API key issued from `init`/`status`.
26
+ */
27
+ activity(opts) {
28
+ return this.client.request('GET', '/v1/trial/activity', undefined, opts);
29
+ }
30
+ }
31
+ //# sourceMappingURL=trial.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"trial.js","sourceRoot":"","sources":["../../src/resources/trial.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAOxC,MAAM,OAAO,aAAc,SAAQ,YAAY;IAC7C;;;;;OAKG;IACH,IAAI,CAAC,OAAsB,EAAE,EAAE,IAAqB;QAClD,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAgB,MAAM,EAAE,gBAAgB,EAAE,IAAI,EAAE,IAAI,CAAC,CAAA;IACjF,CAAC;IAED;;;;OAIG;IACH,MAAM,CAAC,KAAa,EAAE,IAAqB;QACzC,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAkB,KAAK,EAAE,kBAAkB,EAAE,SAAS,EAAE;YAChF,GAAG,IAAI;YACP,KAAK,EAAE,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,KAAK,EAAE;SACjC,CAAC,CAAA;IACJ,CAAC;IAED;;;OAGG;IACH,QAAQ,CAAC,IAAqB;QAC5B,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CAAoB,KAAK,EAAE,oBAAoB,EAAE,SAAS,EAAE,IAAI,CAAC,CAAA;IAC7F,CAAC;CACF"}
@@ -0,0 +1,58 @@
1
+ import type { components, paths } from '../generated/openapi.js';
2
+ import type { RequestOptions } from '../types.js';
3
+ import { BaseResource } from './base.js';
4
+ export type Webhook = components['schemas']['WebhookV1'];
5
+ export type WebhookList = components['schemas']['WebhookList'];
6
+ export type WebhookRotateSecret = components['schemas']['WebhookRotateSecret'];
7
+ export type WebhookDelivery = components['schemas']['WebhookDeliveryV1'];
8
+ export type WebhookDeliveryReplay = components['schemas']['WebhookDeliveryReplay'];
9
+ export type WebhookEventItem = components['schemas']['WebhookEventItem'];
10
+ export type CreateWebhookBody = NonNullable<paths['/v1/webhooks']['post']['requestBody']>['content']['application/json'];
11
+ export type UpdateWebhookBody = NonNullable<paths['/v1/webhooks/{id}']['patch']['requestBody']>['content']['application/json'];
12
+ export type ListDeliveriesQuery = NonNullable<paths['/v1/webhooks/{id}/deliveries']['get']['parameters']['query']>;
13
+ export type ListEventsQuery = paths['/v1/webhooks/events']['get']['parameters']['query'];
14
+ export declare class WebhooksResource extends BaseResource {
15
+ /** `GET /v1/webhooks` — list all webhook subscriptions for the calling account. */
16
+ list(opts?: RequestOptions): Promise<WebhookList>;
17
+ /**
18
+ * `POST /v1/webhooks` — create a subscription. Plaintext `secret` is
19
+ * returned ONCE in the create response; persist it then. Subsequent
20
+ * GETs do not include it.
21
+ */
22
+ create(body: CreateWebhookBody, opts?: RequestOptions): Promise<Webhook>;
23
+ /** `GET /v1/webhooks/{id}` — fetch a single webhook subscription. */
24
+ get(id: string, opts?: RequestOptions): Promise<Webhook>;
25
+ /** `PATCH /v1/webhooks/{id}` — partial update of url / events / line_ids / active flag. */
26
+ update(id: string, body: UpdateWebhookBody, opts?: RequestOptions): Promise<Webhook>;
27
+ /** `DELETE /v1/webhooks/{id}` — delete a subscription. Returns 204. */
28
+ delete(id: string, opts?: RequestOptions): Promise<void>;
29
+ /**
30
+ * `POST /v1/webhooks/{id}/rotate-secret` — mint a new `whs_*` secret.
31
+ * Old secret stays valid for 5 minutes (`old_secret_expires_at`) so the
32
+ * caller can roll their verification code without dropping events.
33
+ * Plaintext secret is returned ONCE.
34
+ */
35
+ rotateSecret(id: string, opts?: RequestOptions): Promise<WebhookRotateSecret>;
36
+ /**
37
+ * `GET /v1/webhooks/{id}/deliveries` — cursor-paginated AsyncIterable
38
+ * over delivery attempts for a subscription. Filters: status (pending/
39
+ * success/failed), event type, since/until timestamps.
40
+ */
41
+ deliveries(id: string, filters?: Omit<ListDeliveriesQuery, 'cursor'>, opts?: RequestOptions): AsyncIterable<WebhookDelivery>;
42
+ /**
43
+ * `POST /v1/webhooks/{id}/deliveries/{delivery_id}/replay` — re-fire a
44
+ * past delivery. Server preserves the original `event_id` so consumers
45
+ * still dedupe.
46
+ */
47
+ replay(webhookId: string, deliveryId: string, opts?: RequestOptions): Promise<WebhookDeliveryReplay>;
48
+ /**
49
+ * `GET /v1/webhooks/events` — cursor-paginated reconciliation pull.
50
+ * Returns events that would have been delivered to the caller's
51
+ * subscriptions within the 72h retention window. Used to recover from
52
+ * webhook outages without missing signal.
53
+ *
54
+ * `since` is required by the contract.
55
+ */
56
+ events(filters: Omit<NonNullable<ListEventsQuery>, 'cursor'>, opts?: RequestOptions): AsyncIterable<WebhookEventItem>;
57
+ }
58
+ //# sourceMappingURL=webhooks.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/resources/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,KAAK,EAAE,MAAM,yBAAyB,CAAA;AAGhE,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,aAAa,CAAA;AACjD,OAAO,EAAE,YAAY,EAAE,MAAM,WAAW,CAAA;AAExC,MAAM,MAAM,OAAO,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,WAAW,CAAC,CAAA;AACxD,MAAM,MAAM,WAAW,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,aAAa,CAAC,CAAA;AAC9D,MAAM,MAAM,mBAAmB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,qBAAqB,CAAC,CAAA;AAC9E,MAAM,MAAM,eAAe,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,mBAAmB,CAAC,CAAA;AACxE,MAAM,MAAM,qBAAqB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,uBAAuB,CAAC,CAAA;AAClF,MAAM,MAAM,gBAAgB,GAAG,UAAU,CAAC,SAAS,CAAC,CAAC,kBAAkB,CAAC,CAAA;AAExE,MAAM,MAAM,iBAAiB,GAAG,WAAW,CACzC,KA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IAS7E;;;;OAIG;IACH,UAAU,CACR,EAAE,EAAE,MAAM,EACV,OAAO,GAAE,IAAI,CAAC,mBAAmB,EAAE,QAAQ,CAAM,EACjD,IAAI,CAAC,EAAE,cAAc,GACpB,aAAa,CAAC,eAAe,CAAC;IAajC;;;;OAIG;IACH,MAAM,CACJ,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,IAAI,CAAC,EAAE,cAAc,GACpB,OAAO,CAAC,qBAAqB,CAAC;IASjC;;;;;;;OAOG;IACH,MAAM,CACJ,OAAO,EAAE,IAAI,CAAC,WAAW,CAAC,eAAe,CAAC,EAAE,QAAQ,CAAC,EACrD,IAAI,CAAC,EAAE,cAAc,GACpB,aAAa,CAAC,gBAAgB,CAAC;CAYnC"}
@@ -0,0 +1,65 @@
1
+ import { paginate } from '../pagination.js';
2
+ import { BaseResource } from './base.js';
3
+ export class WebhooksResource extends BaseResource {
4
+ /** `GET /v1/webhooks` — list all webhook subscriptions for the calling account. */
5
+ list(opts) {
6
+ return this.client.request('GET', '/v1/webhooks', undefined, opts);
7
+ }
8
+ /**
9
+ * `POST /v1/webhooks` — create a subscription. Plaintext `secret` is
10
+ * returned ONCE in the create response; persist it then. Subsequent
11
+ * GETs do not include it.
12
+ */
13
+ create(body, opts) {
14
+ return this.client.request('POST', '/v1/webhooks', body, opts);
15
+ }
16
+ /** `GET /v1/webhooks/{id}` — fetch a single webhook subscription. */
17
+ get(id, opts) {
18
+ return this.client.request('GET', `/v1/webhooks/${encodeURIComponent(id)}`, undefined, opts);
19
+ }
20
+ /** `PATCH /v1/webhooks/{id}` — partial update of url / events / line_ids / active flag. */
21
+ update(id, body, opts) {
22
+ return this.client.request('PATCH', `/v1/webhooks/${encodeURIComponent(id)}`, body, opts);
23
+ }
24
+ /** `DELETE /v1/webhooks/{id}` — delete a subscription. Returns 204. */
25
+ delete(id, opts) {
26
+ return this.client.request('DELETE', `/v1/webhooks/${encodeURIComponent(id)}`, undefined, opts);
27
+ }
28
+ /**
29
+ * `POST /v1/webhooks/{id}/rotate-secret` — mint a new `whs_*` secret.
30
+ * Old secret stays valid for 5 minutes (`old_secret_expires_at`) so the
31
+ * caller can roll their verification code without dropping events.
32
+ * Plaintext secret is returned ONCE.
33
+ */
34
+ rotateSecret(id, opts) {
35
+ return this.client.request('POST', `/v1/webhooks/${encodeURIComponent(id)}/rotate-secret`, undefined, opts);
36
+ }
37
+ /**
38
+ * `GET /v1/webhooks/{id}/deliveries` — cursor-paginated AsyncIterable
39
+ * over delivery attempts for a subscription. Filters: status (pending/
40
+ * success/failed), event type, since/until timestamps.
41
+ */
42
+ deliveries(id, filters = {}, opts) {
43
+ return paginate((cursor) => this.client.request('GET', `/v1/webhooks/${encodeURIComponent(id)}/deliveries`, undefined, { ...opts, query: { ...filters, cursor } }), { signal: opts?.signal });
44
+ }
45
+ /**
46
+ * `POST /v1/webhooks/{id}/deliveries/{delivery_id}/replay` — re-fire a
47
+ * past delivery. Server preserves the original `event_id` so consumers
48
+ * still dedupe.
49
+ */
50
+ replay(webhookId, deliveryId, opts) {
51
+ return this.client.request('POST', `/v1/webhooks/${encodeURIComponent(webhookId)}/deliveries/${encodeURIComponent(deliveryId)}/replay`, undefined, opts);
52
+ }
53
+ /**
54
+ * `GET /v1/webhooks/events` — cursor-paginated reconciliation pull.
55
+ * Returns events that would have been delivered to the caller's
56
+ * subscriptions within the 72h retention window. Used to recover from
57
+ * webhook outages without missing signal.
58
+ *
59
+ * `since` is required by the contract.
60
+ */
61
+ events(filters, opts) {
62
+ return paginate((cursor) => this.client.request('GET', '/v1/webhooks/events', undefined, { ...opts, query: { ...filters, cursor } }), { signal: opts?.signal });
63
+ }
64
+ }
65
+ //# sourceMappingURL=webhooks.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"webhooks.js","sourceRoot":"","sources":["../../src/resources/webhooks.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,QAAQ,EAAE,MAAM,kBAAkB,CAAA;AAE3C,OAAO,EAA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,EACV,UAA+C,EAAE,EACjD,IAAqB;QAErB,OAAO,QAAQ,CACb,CAAC,MAAM,EAAE,EAAE,CACT,IAAI,CAAC,MAAM,CAAC,OAAO,CACjB,KAAK,EACL,gBAAgB,kBAAkB,CAAC,EAAE,CAAC,aAAa,EACnD,SAAS,EACT,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,EAAE,CAC3C,EACH,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CACzB,CAAA;IACH,CAAC;IAED;;;;OAIG;IACH,MAAM,CACJ,SAAiB,EACjB,UAAkB,EAClB,IAAqB;QAErB,OAAO,IAAI,CAAC,MAAM,CAAC,OAAO,CACxB,MAAM,EACN,gBAAgB,kBAAkB,CAAC,SAAS,CAAC,eAAe,kBAAkB,CAAC,UAAU,CAAC,SAAS,EACnG,SAAS,EACT,IAAI,CACL,CAAA;IACH,CAAC;IAED;;;;;;;OAOG;IACH,MAAM,CACJ,OAAqD,EACrD,IAAqB;QAErB,OAAO,QAAQ,CACb,CAAC,MAAM,EAAE,EAAE,CACT,IAAI,CAAC,MAAM,CAAC,OAAO,CACjB,KAAK,EACL,qBAAqB,EACrB,SAAS,EACT,EAAE,GAAG,IAAI,EAAE,KAAK,EAAE,EAAE,GAAG,OAAO,EAAE,MAAM,EAAE,EAAE,CAC3C,EACH,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,CACzB,CAAA;IACH,CAAC;CACF"}
@@ -0,0 +1,14 @@
1
+ export interface RetryInfo {
2
+ attempt: number;
3
+ nextDelayMs: number;
4
+ error: unknown;
5
+ }
6
+ export interface RetryConfig {
7
+ maxRetries: number;
8
+ onRetry?: (info: RetryInfo) => void;
9
+ signal?: AbortSignal;
10
+ }
11
+ export declare function isRetryable(err: unknown): boolean;
12
+ export declare function computeBackoff(attempt: number, err: unknown): number;
13
+ export declare function withRetries<T>(fn: () => Promise<T>, config: RetryConfig): Promise<T>;
14
+ //# sourceMappingURL=retry.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.d.ts","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AASA,MAAM,WAAW,SAAS;IACxB,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,EAAE,MAAM,CAAA;IACnB,KAAK,EAAE,OAAO,CAAA;CACf;AAED,MAAM,WAAW,WAAW;IAC1B,UAAU,EAAE,MAAM,CAAA;IAClB,OAAO,CAAC,EAAE,CAAC,IAAI,EAAE,SAAS,KAAK,IAAI,CAAA;IACnC,MAAM,CAAC,EAAE,WAAW,CAAA;CACrB;AAKD,wBAAgB,WAAW,CAAC,GAAG,EAAE,OAAO,GAAG,OAAO,CAOjD;AAED,wBAAgB,cAAc,CAAC,OAAO,EAAE,MAAM,EAAE,GAAG,EAAE,OAAO,GAAG,MAAM,CAKpE;AAED,wBAAsB,WAAW,CAAC,CAAC,EAAE,EAAE,EAAE,MAAM,OAAO,CAAC,CAAC,CAAC,EAAE,MAAM,EAAE,WAAW,GAAG,OAAO,CAAC,CAAC,CAAC,CAoB1F"}
package/dist/retry.js ADDED
@@ -0,0 +1,47 @@
1
+ import { APIConnectionError, InternalServerError, QuotaExceededError, RateLimitError, ServiceUnavailableError } from './errors.js';
2
+ import { sleep } from './internal/sleep.js';
3
+ const BASE_DELAY_MS = 250;
4
+ const JITTER_MS = 100;
5
+ export function isRetryable(err) {
6
+ if (err instanceof QuotaExceededError)
7
+ return false;
8
+ if (err instanceof APIConnectionError)
9
+ return true;
10
+ if (err instanceof InternalServerError)
11
+ return true;
12
+ if (err instanceof ServiceUnavailableError)
13
+ return true;
14
+ if (err instanceof RateLimitError)
15
+ return true;
16
+ return false;
17
+ }
18
+ export function computeBackoff(attempt, err) {
19
+ if (err instanceof RateLimitError && typeof err.retryAfter === 'number' && err.retryAfter > 0) {
20
+ return err.retryAfter * 1000;
21
+ }
22
+ return BASE_DELAY_MS * Math.pow(2, attempt) + Math.random() * JITTER_MS;
23
+ }
24
+ export async function withRetries(fn, config) {
25
+ let lastError;
26
+ for (let attempt = 0; attempt <= config.maxRetries; attempt++) {
27
+ if (config.signal?.aborted) {
28
+ throw new APIConnectionError('Request aborted before attempt', {
29
+ cause: config.signal.reason
30
+ });
31
+ }
32
+ try {
33
+ return await fn();
34
+ }
35
+ catch (err) {
36
+ lastError = err;
37
+ const isLast = attempt === config.maxRetries;
38
+ if (isLast || !isRetryable(err))
39
+ throw err;
40
+ const nextDelayMs = computeBackoff(attempt, err);
41
+ config.onRetry?.({ attempt, nextDelayMs, error: err });
42
+ await sleep(nextDelayMs, config.signal, 'Request aborted during retry backoff');
43
+ }
44
+ }
45
+ throw lastError;
46
+ }
47
+ //# sourceMappingURL=retry.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"retry.js","sourceRoot":"","sources":["../src/retry.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,cAAc,EACd,uBAAuB,EACxB,MAAM,aAAa,CAAA;AACpB,OAAO,EAAE,KAAK,EAAE,MAAM,qBAAqB,CAAA;AAc3C,MAAM,aAAa,GAAG,GAAG,CAAA;AACzB,MAAM,SAAS,GAAG,GAAG,CAAA;AAErB,MAAM,UAAU,WAAW,CAAC,GAAY;IACtC,IAAI,GAAG,YAAY,kBAAkB;QAAE,OAAO,KAAK,CAAA;IACnD,IAAI,GAAG,YAAY,kBAAkB;QAAE,OAAO,IAAI,CAAA;IAClD,IAAI,GAAG,YAAY,mBAAmB;QAAE,OAAO,IAAI,CAAA;IACnD,IAAI,GAAG,YAAY,uBAAuB;QAAE,OAAO,IAAI,CAAA;IACvD,IAAI,GAAG,YAAY,cAAc;QAAE,OAAO,IAAI,CAAA;IAC9C,OAAO,KAAK,CAAA;AACd,CAAC;AAED,MAAM,UAAU,cAAc,CAAC,OAAe,EAAE,GAAY;IAC1D,IAAI,GAAG,YAAY,cAAc,IAAI,OAAO,GAAG,CAAC,UAAU,KA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ethod = 'GET' | 'POST' | 'PATCH' | 'PUT' | 'DELETE';
2
+ export interface ErrorIssue {
3
+ path: string;
4
+ message: string;
5
+ code: string;
6
+ }
7
+ export interface ErrorEnvelope {
8
+ status: number;
9
+ code: string;
10
+ message: string;
11
+ retry_after?: number;
12
+ issues?: ErrorIssue[];
13
+ }
14
+ export interface ResponseEnvelope<T = unknown> {
15
+ success: boolean;
16
+ data: T | null;
17
+ error: ErrorEnvelope | null;
18
+ trace_id?: string;
19
+ request_id?: string;
20
+ }
21
+ export interface RequestOptions {
22
+ idempotencyKey?: string;
23
+ signal?: AbortSignal;
24
+ maxRetries?: number;
25
+ query?: Record<string, string | number | boolean | undefined | null>;
26
+ /**
27
+ * Extra headers to merge into the request. SDK defaults (User-Agent,
28
+ * Accept, Content-Type) can be overridden; SDK-managed Authorization and
29
+ * Idempotency-Key always win regardless of what is set here.
30
+ */
31
+ headers?: HeadersInit;
32
+ }
33
+ //# sourceMappingURL=types.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":"AAAA,MAAM,MAAM,UAAU,GAAG,KAAK,GAAG,MAAM,GAAG,OAAO,GAAG,KAAK,GAAG,QAAQ,CAAA;AAEpE,MAAM,WAAW,UAAU;IACzB,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,IAAI,EAAE,MAAM,CAAA;CACb;AAED,MAAM,WAAW,aAAa;IAC5B,MAAM,EAAE,MAAM,CAAA;IACd,IAAI,EAAE,MAAM,CAAA;IACZ,OAAO,EAAE,MAAM,CAAA;IACf,WAAW,CAAC,EAAE,MAAM,CAAA;IACpB,MAAM,CAAC,EAAE,UAAU,EAAE,CAAA;CACtB;AAED,MAAM,WAAW,gBAAgB,CAAC,CAAC,GAAG,OAAO;IAC3C,OAAO,EAAE,OAAO,CAAA;IAChB,IAAI,EAAE,CAAC,GAAG,IAAI,CAAA;IACd,KAAK,EAAE,aAAa,GAAG,IAAI,CAAA;IAC3B,QAAQ,CAAC,EAAE,MAAM,CAAA;IACjB,UAAU,CAAC,EAAE,MAAM,CAAA;CACpB;AAED,MAAM,WAAW,cAAc;IAC7B,cAAc,CAAC,EAAE,MAAM,CAAA;IACvB,MAAM,CAAC,EAAE,WAAW,CAAA;IACpB,UAAU,CAAC,EAAE,MAAM,CAAA;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,MAAM,GAAG,MAAM,GAAG,OAAO,GAAG,SAAS,GAAG,IAAI,CAAC,CAAA;IACpE;;;;OAIG;IACH,OAAO,CAAC,EAAE,WAAW,CAAA;CACtB"}
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ export {};
2
+ //# sourceMappingURL=types.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"types.js","sourceRoot":"","sources":["../src/types.ts"],"names":[],"mappings":""}
@@ -0,0 +1,2 @@
1
+ export declare const SDK_VERSION = "0.0.0";
2
+ //# sourceMappingURL=version.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.d.ts","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAEA,eAAO,MAAM,WAAW,UAAU,CAAA"}
@@ -0,0 +1,4 @@
1
+ // Single source of truth for the SDK version. Synced with package.json by
2
+ // the release script (PR 5). Imported by client.ts to build the User-Agent.
3
+ export const SDK_VERSION = '0.0.0';
4
+ //# sourceMappingURL=version.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"version.js","sourceRoot":"","sources":["../src/version.ts"],"names":[],"mappings":"AAAA,0EAA0E;AAC1E,4EAA4E;AAC5E,MAAM,CAAC,MAAM,WAAW,GAAG,OAAO,CAAA"}
@@ -0,0 +1,15 @@
1
+ import type { WebhookEventBase } from './types.js';
2
+ /**
3
+ * Parse a raw webhook delivery body into a typed envelope. Throws
4
+ * `WebhookSignatureError` if the body is not valid JSON or doesn't carry
5
+ * the §4.1 envelope shape (`event_id`, `event_type`, `data`). Use
6
+ * `verifyWebhook` for the full HMAC + replay-window verification — this
7
+ * is the parsing-only half for cases where verification happened
8
+ * out-of-band (e.g. behind a trusted gateway).
9
+ *
10
+ * **Consumers MUST dedupe by `event.event_id`** — webhook delivery is
11
+ * at-least-once, so retries replay the same envelope. Without dedup,
12
+ * processing the same event twice produces duplicate side-effects.
13
+ */
14
+ export declare function parseWebhookEvent(rawBody: string): WebhookEventBase;
15
+ //# sourceMappingURL=parse.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"parse.d.ts","sourceRoot":"","sources":["../../src/webhooks/parse.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,gBAAgB,EAAE,MAAM,YAAY,CAAA;AAElD;;;;;;;;;;;GAWG;AACH,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,MAAM,GAAG,gBAAgB,CAiCnE"}