@reopt-ai/brandapp-sdk 3.3.0 → 3.5.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.
Files changed (104) hide show
  1. package/CHANGELOG.md +115 -0
  2. package/README.md +10 -1
  3. package/dist/abort--nOBFN4M.js +50 -0
  4. package/dist/ai/index.d.ts +2 -314
  5. package/dist/ai/index.js +3 -8
  6. package/dist/ai-provider/index.d.ts +79 -163
  7. package/dist/ai-provider/index.js +752 -685
  8. package/dist/auth/index.d.ts +27 -27
  9. package/dist/auth/index.js +41 -34
  10. package/dist/better-auth/client.d.ts +6 -5
  11. package/dist/better-auth/client.js +28 -5
  12. package/dist/better-auth/index.d.ts +19 -17
  13. package/dist/better-auth/index.js +180 -144
  14. package/dist/client-61ldOHMz.js +503 -0
  15. package/dist/client-7PCoxVhZ.js +28 -0
  16. package/dist/client-B7rZQ8Zi.d.ts +272 -0
  17. package/dist/client-BGGd_cpV.d.ts +103 -0
  18. package/dist/client-BoIuyx4S.js +273 -0
  19. package/dist/client-BruP5_nU.d.ts +147 -0
  20. package/dist/client-BxtZt405.js +305 -0
  21. package/dist/client-ByN3EQdk.js +83 -0
  22. package/dist/client-CAghoGD_.js +53 -0
  23. package/dist/client-C_pHsPlj.js +81 -0
  24. package/dist/client-D0eBxh8j.d.ts +284 -0
  25. package/dist/client-D6gs61w8.d.ts +53 -0
  26. package/dist/client-DDw5yz_h.d.ts +53 -0
  27. package/dist/client-Dxg8_DIH.d.ts +71 -0
  28. package/dist/client-aMR4CRB8.d.ts +211 -0
  29. package/dist/client-lk6wBu_0.d.ts +48 -0
  30. package/dist/client-wEVKLdly.js +55 -0
  31. package/dist/client-zF1RG2uA.js +86 -0
  32. package/dist/cms/index.d.ts +52 -108
  33. package/dist/cms/index.js +103 -86
  34. package/dist/config-CRytOPPl.d.ts +394 -0
  35. package/dist/config-aml9oQpX.js +487 -0
  36. package/dist/dev/index.d.ts +2 -528
  37. package/dist/dev/index.js +3047 -2967
  38. package/dist/eav/coerce.d.ts +3 -1
  39. package/dist/eav/coerce.js +72 -46
  40. package/dist/eav/index.d.ts +72 -100
  41. package/dist/eav/index.js +158 -126
  42. package/dist/eav/migrate.d.ts +112 -109
  43. package/dist/eav/migrate.js +230 -196
  44. package/dist/eav/schema.d.ts +111 -150
  45. package/dist/eav/schema.js +624 -603
  46. package/dist/encoding-Bwfm3iaE.js +21 -0
  47. package/dist/{errors-BjDFIyA6.d.ts → errors-CRCcErNC.d.ts} +55 -53
  48. package/dist/feedback/index.d.ts +2 -132
  49. package/dist/feedback/index.js +3 -6
  50. package/dist/files/index.d.ts +14 -14
  51. package/dist/files/index.js +41 -25
  52. package/dist/http-client-BZc2mngq.js +386 -0
  53. package/dist/index-1j_738qk.d.ts +470 -0
  54. package/dist/index-CeOLGdyL.d.ts +169 -0
  55. package/dist/index.d.ts +6 -230
  56. package/dist/index.js +119 -71
  57. package/dist/logout/index.d.ts +56 -53
  58. package/dist/logout/index.js +232 -289
  59. package/dist/plans/index.d.ts +2 -236
  60. package/dist/plans/index.js +3 -6
  61. package/dist/push/index.d.ts +2 -79
  62. package/dist/push/index.js +3 -6
  63. package/dist/query-xWqtfkvR.js +35 -0
  64. package/dist/react/hooks.d.ts +157 -100
  65. package/dist/react/hooks.js +862 -406
  66. package/dist/sse-parser-FMjxM7sY.js +86 -0
  67. package/dist/terms/index.d.ts +3 -79
  68. package/dist/terms/index.js +3 -6
  69. package/dist/testing/index.d.ts +52 -104
  70. package/dist/testing/index.js +94 -72
  71. package/dist/types-B-SMkH6s.d.ts +26 -0
  72. package/dist/types-BXDcoJHG.d.ts +131 -0
  73. package/dist/types-BrghN2rJ.d.ts +105 -0
  74. package/dist/types-DjDRszNj.js +11 -0
  75. package/dist/webhooks/index.d.ts +77 -50
  76. package/dist/webhooks/index.js +150 -127
  77. package/docs/api-reference.md +121 -8
  78. package/docs/errors.md +19 -0
  79. package/docs/files.md +165 -7
  80. package/package.json +7 -6
  81. package/dist/chunk-2LSCQHAU.js +0 -21
  82. package/dist/chunk-4U4ZPPL4.js +0 -599
  83. package/dist/chunk-55KHY5GH.js +0 -96
  84. package/dist/chunk-C5VTRZWX.js +0 -458
  85. package/dist/chunk-F7BXBTZI.js +0 -54
  86. package/dist/chunk-FJUCWXX3.js +0 -350
  87. package/dist/chunk-H33OTQEN.js +0 -112
  88. package/dist/chunk-L4DHB36G.js +0 -75
  89. package/dist/chunk-OG7R3UAR.js +0 -105
  90. package/dist/chunk-PF24XU54.js +0 -32
  91. package/dist/chunk-QN3QD67K.js +0 -49
  92. package/dist/chunk-REIKXSMY.js +0 -7
  93. package/dist/chunk-UGBBXCZE.js +0 -157
  94. package/dist/chunk-UVT2E6KD.js +0 -81
  95. package/dist/chunk-YPLT3RFL.js +0 -63
  96. package/dist/chunk-YTKSAWV2.js +0 -463
  97. package/dist/client-BkcO-0C2.d.ts +0 -216
  98. package/dist/client-CN5_tNOC.d.ts +0 -147
  99. package/dist/client-DttyeM_h.d.ts +0 -102
  100. package/dist/config-CtxyJsDR.d.ts +0 -397
  101. package/dist/typed-client-BxOVIiMU.d.ts +0 -40
  102. package/dist/types-6E3ZLL9X.d.ts +0 -24
  103. package/dist/types-DskYLVb8.d.ts +0 -104
  104. package/dist/types-ckmDDW3N.d.ts +0 -129
@@ -0,0 +1,131 @@
1
+ //#region src/cms/types.d.ts
2
+ /**
3
+ * Reopt Editor 본문 형식 (post/document `contentRich`).
4
+ *
5
+ * `@reopt-ai/opt-editor`의 `EditorSpec`과 구조적으로 호환되는 minimal 타입.
6
+ * SDK는 opt-editor에 직접 의존하지 않으므로(외부 GitHub Packages 의존을 피하기 위함),
7
+ * 외부 앱은 이 값을 그대로 `<StaticRenderer spec={post.document.contentRich} ... />`에
8
+ * 넘길 수 있다.
9
+ *
10
+ * @example
11
+ * ```tsx
12
+ * import { StaticRenderer } from "@reopt-ai/opt-editor";
13
+ * import type { EditorSpec } from "@reopt-ai/brandapp-sdk/cms";
14
+ *
15
+ * const post = await sdk.cms.posts.getBySlug(slug);
16
+ * return <StaticRenderer spec={post.document.contentRich} />;
17
+ * ```
18
+ */
19
+ type EditorSpec = {
20
+ /** Top-level element IDs in display order. */
21
+ root: string[];
22
+ /** Flat map of all elements by ID. */
23
+ elements: Record<string, unknown>;
24
+ /** Optimistic concurrency version. Incremented on every mutation. */
25
+ version: number;
26
+ };
27
+ type PostStatus = "draft" | "scheduled" | "published" | "archived";
28
+ type PostSeo = {
29
+ metaTitle: string | null;
30
+ metaDescription: string | null;
31
+ metaKeywords: string | null;
32
+ };
33
+ type Post = {
34
+ id: string;
35
+ slug: string;
36
+ title: string;
37
+ status: PostStatus;
38
+ publishedAt: string | null;
39
+ createdAt: string;
40
+ updatedAt: string;
41
+ author: {
42
+ id: string;
43
+ name: string;
44
+ image: string | null;
45
+ };
46
+ icon: string | null;
47
+ coverImage: {
48
+ id: string;
49
+ url: string | null;
50
+ } | null;
51
+ group: {
52
+ id: string;
53
+ name: string;
54
+ };
55
+ tags: {
56
+ id: string;
57
+ text: string;
58
+ }[];
59
+ seo: PostSeo;
60
+ };
61
+ type PostDetail = Post & {
62
+ document: {
63
+ id: string;
64
+ /** Plain-text 본문 (검색용). */
65
+ content: string;
66
+ /** Rich 본문 — opt-editor `EditorSpec`과 구조적으로 호환. */
67
+ contentRich: EditorSpec;
68
+ };
69
+ };
70
+ type ListPostsQuery = {
71
+ page?: number;
72
+ limit?: number;
73
+ sortBy?: "createdAt" | "updatedAt" | "title" | "publishedAt";
74
+ sortOrder?: "asc" | "desc";
75
+ status?: PostStatus;
76
+ groupId?: string;
77
+ /**
78
+ * 브랜드 범위 내 안정적 그룹 식별자. 신규 코드는 env 기반 groupId 대신 slug 사용 권장.
79
+ * `groupId`와 동시에 지정되면 둘 다 AND 필터로 적용됨.
80
+ */
81
+ groupSlug?: string;
82
+ search?: string;
83
+ tags?: string[];
84
+ };
85
+ type PostGroup = {
86
+ id: string;
87
+ name: string;
88
+ /**
89
+ * 브랜드 범위 내 안정적 식별자. legacy row 또는 미설정 시 null.
90
+ * SDK consumer는 slug 기반 조회를 권장하나, null 가능성을 고려해야 한다.
91
+ */
92
+ slug: string | null;
93
+ color: string;
94
+ createdAt: string;
95
+ updatedAt: string;
96
+ brand: {
97
+ id: string;
98
+ name: string;
99
+ } | null;
100
+ postCount: number;
101
+ };
102
+ type ListPostGroupsQuery = {
103
+ page?: number;
104
+ limit?: number;
105
+ sortBy?: "createdAt" | "name";
106
+ sortOrder?: "asc" | "desc";
107
+ brandId?: string;
108
+ search?: string;
109
+ };
110
+ type Tag = {
111
+ id: string;
112
+ text: string;
113
+ /** Brand 범위 내에서 이 태그가 붙은 포스트 수. */
114
+ postCount: number;
115
+ };
116
+ type ListTagsQuery = {
117
+ /** 특정 그룹으로 필터 (id 기반). 미지정 시 brand 내 전체. */
118
+ groupId?: string;
119
+ /** 특정 그룹으로 필터 (slug 기반). `groupId`와 동시 지정 가능. */
120
+ groupSlug?: string;
121
+ };
122
+ type CmsPaginatedResponse<T> = {
123
+ records: T[];
124
+ page: number;
125
+ limit: number;
126
+ total: number;
127
+ totalPages: number;
128
+ };
129
+ //#endregion
130
+ export { ListTagsQuery as a, PostGroup as c, Tag as d, ListPostsQuery as i, PostSeo as l, EditorSpec as n, Post as o, ListPostGroupsQuery as r, PostDetail as s, CmsPaginatedResponse as t, PostStatus as u };
131
+ //# sourceMappingURL=types-BXDcoJHG.d.ts.map
@@ -0,0 +1,105 @@
1
+ import { n as EditorSpec } from "./types-BXDcoJHG.js";
2
+ //#region src/terms/types.d.ts
3
+ /**
4
+ * Brandapp Terms types.
5
+ *
6
+ * Mirrors the response shape of `/api/v1/brandapp/{brandappId}/terms/*`.
7
+ */
8
+ type TermsType = "termsOfService" | "privacyPolicy" | "marketingConsent" | "custom";
9
+ /** Mirrors the Prisma `BrandappTermsJurisdiction` enum. */
10
+ type TermsJurisdiction = "global" | "KR" | "US" | "EU" | "GB" | "JP" | "CN" | "BR" | "CA" | "AU";
11
+ type TermsVersion = {
12
+ id: string;
13
+ version: number;
14
+ /** 본문 언어 (BCP 47, "ko-KR", "en-US"). */
15
+ locale: string;
16
+ /** Plain-text 본문 — 검색/법적 보존용. */
17
+ content: string;
18
+ /**
19
+ * Rich 본문 — opt-editor `EditorSpec`과 호환되는 minimal shape.
20
+ * 마이그레이션 이전에 작성된 약관은 plain text가 paragraph 1개로 자동 wrap되어 들어있다.
21
+ * `null`은 백엔드 응답에 contentRich 필드가 빠진 구버전 호환을 위해 허용.
22
+ */
23
+ contentRich: EditorSpec | null;
24
+ publishedAt: string;
25
+ changeSummary: string | null;
26
+ reConsentDeadline: string | null;
27
+ };
28
+ type TermsItem = {
29
+ id: string;
30
+ title: string;
31
+ type: TermsType;
32
+ /** 법적 관할권 */
33
+ jurisdiction: TermsJurisdiction;
34
+ isRequired: boolean;
35
+ sortOrder: number;
36
+ /** Null when no matching version exists for the requested locale. */
37
+ currentVersion: TermsVersion | null;
38
+ };
39
+ /** Wrapper response with jurisdiction/locale matching metadata. */
40
+ type TermsListResponse = {
41
+ /** 매칭된 jurisdiction (사용자가 받은 약관 셋의 법적 관할권) */
42
+ jurisdiction: TermsJurisdiction;
43
+ /** 매칭 결정 출처 — geo / user_locale / accept_language / explicit / brandapp_default */
44
+ jurisdictionSource: string;
45
+ /** 매칭에 사용된 country (ISO 3166-1 alpha-2). null이면 brandapp default만 사용. */
46
+ country: string | null;
47
+ /** 매칭에 사용된 locale (BCP 47). */
48
+ locale: string | null;
49
+ /** 매칭된 약관 목록 */
50
+ terms: TermsItem[];
51
+ };
52
+ type ConsentStatus = "granted" | "withdrawn" | "pendingReConsent";
53
+ type ConsentRecord = {
54
+ id: string;
55
+ status: ConsentStatus;
56
+ consentedAt: string;
57
+ withdrawnAt: string | null;
58
+ source: string | null;
59
+ versionId: string;
60
+ termsId: string;
61
+ /** 동의 시점의 국가 (법적 증거) */
62
+ consentCountry: string | null;
63
+ /** 동의 시점의 locale (법적 증거) */
64
+ consentLocale: string | null;
65
+ };
66
+ type ConsentInput = {
67
+ versionId: string;
68
+ consented: boolean;
69
+ };
70
+ type CreateConsentsRequest = {
71
+ consents: ConsentInput[];
72
+ /** Origin tag stored alongside each consent (e.g. "web", "mobile-app"). Defaults to "sdk". */
73
+ source?: string;
74
+ /** Optional caller IP, kept for legal evidence. Server falls back to undefined when omitted. */
75
+ ipAddress?: string;
76
+ /** 동의 시점의 사용자 국가 (ISO 3166-1 alpha-2). 미제공 시 서버가 헤더에서 추정. */
77
+ country?: string;
78
+ /** 동의 시점에 사용자가 본 locale (BCP 47). 미제공 시 서버가 헤더에서 추정. */
79
+ locale?: string;
80
+ /** User-Agent. 미제공 시 서버가 요청 헤더에서 추정. */
81
+ userAgent?: string;
82
+ };
83
+ type CreateConsentsResult = {
84
+ count: number;
85
+ };
86
+ type WithdrawConsentResult = {
87
+ id: string;
88
+ };
89
+ /**
90
+ * `list()` 호출 옵션. country/locale을 지정하면 백엔드가 매칭 약관 셋을 반환한다.
91
+ * 미지정 시 백엔드가 요청 헤더 (`x-vercel-ip-country`, `Accept-Language`)에서 추정한다.
92
+ */
93
+ type ListTermsOptions = {
94
+ /** ISO 3166-1 alpha-2 ("KR", "DE", "US"). */
95
+ country?: string;
96
+ /** BCP 47 ("ko-KR", "en-US"). */
97
+ locale?: string;
98
+ /** Explicit jurisdiction override. */
99
+ jurisdiction?: TermsJurisdiction;
100
+ /** Bearer token. 없으면 Basic Auth. */
101
+ accessToken?: string;
102
+ };
103
+ //#endregion
104
+ export { CreateConsentsResult as a, TermsJurisdiction as c, TermsVersion as d, WithdrawConsentResult as f, CreateConsentsRequest as i, TermsListResponse as l, ConsentRecord as n, ListTermsOptions as o, ConsentStatus as r, TermsItem as s, ConsentInput as t, TermsType as u };
105
+ //# sourceMappingURL=types-BrghN2rJ.d.ts.map
@@ -0,0 +1,11 @@
1
+ //#region src/better-auth/types.ts
2
+ const REOPT_PROVIDER_ID = "reopt";
3
+ const REOPT_DEFAULT_SCOPES = [
4
+ "openid",
5
+ "profile",
6
+ "email"
7
+ ];
8
+
9
+ //#endregion
10
+ export { REOPT_PROVIDER_ID as n, REOPT_DEFAULT_SCOPES as t };
11
+ //# sourceMappingURL=types-DjDRszNj.js.map
@@ -1,3 +1,4 @@
1
+ //#region src/webhooks/index.d.ts
1
2
  /**
2
3
  * Reopt 발신 웹훅 수신 헬퍼.
3
4
  *
@@ -14,21 +15,46 @@
14
15
  * 실제 플랫폼 송신부와 불일치해 모든 프로덕션 웹훅을 401 거부했다. 이 모듈은 송신부에
15
16
  * 정렬되어 있다.)
16
17
  */
17
- type WebhookEventType = "contactCreated" | "contactUpdated" | "contactDeleted" | "workflowRunCompleted" | "workflowRunFailed";
18
+ type WebhookEventType = "contactCreated" | "contactUpdated" | "contactDeleted" | "workflowRunCompleted" | "workflowRunFailed" | "subscriptionActivated" | "subscriptionRenewed" | "subscriptionCanceled" | "subscriptionPaymentFailed";
19
+ /**
20
+ * 구독 이벤트 4종의 공통 페이로드(`WebhookPayload<SubscriptionWebhookData>`).
21
+ *
22
+ * 웹훅은 **워크스페이스 단위**로 등록되므로 한 워크스페이스에 브랜드앱이 여럿이면
23
+ * 같은 엔드포인트로 전부 도착한다 — `brandappId`로 반드시 필터링할 것.
24
+ *
25
+ * 용도별 처리:
26
+ * - `subscriptionActivated` — 엔타이틀먼트 부여 (체크아웃 완료)
27
+ * - `subscriptionRenewed` — 접근 만료일 연장 (`accessUntil` 갱신)
28
+ * - `subscriptionPaymentFailed` — 결제 실패(past due). 유예 안내·독촉 트리거
29
+ * - `subscriptionCanceled` — 해지. `accessUntil`까지는 접근을 유지해야 한다
30
+ */
31
+ type SubscriptionWebhookData = {
32
+ brandappId: string;
33
+ brandappCustomerId: string;
34
+ /** 브랜드 고객 id. 링크가 없으면 null. */
35
+ customerId: string | null;
36
+ planId: string | null;
37
+ /** 이벤트 출처에 따라 null일 수 있다(갱신 웹훅 등). */
38
+ planName: string | null;
39
+ /** sandbox | paddle | toss | apple | google */
40
+ provider: string;
41
+ /** 이 시각(ISO-8601)까지 이용 가능. null이면 무기한. */
42
+ accessUntil: string | null;
43
+ };
18
44
  /**
19
45
  * 플랫폼이 전달하는 웹훅 envelope. 모든 이벤트 타입이 같은 형태를 공유한다.
20
46
  */
21
47
  type WebhookPayload<T = unknown> = {
22
- /** 멱등 처리용 고유 이벤트 ID (재시도 시 동일) */
23
- id: string;
24
- type: WebhookEventType;
25
- /** 이벤트가 가리키는 엔티티 종류 (예: "contact", "workflowRun") */
26
- entityType: string;
27
- /** 엔티티 ID (없을 수 있음) */
28
- entityId: string | null;
29
- /** 발신 시각 (ISO 8601) */
30
- createdAt: string;
31
- data: T;
48
+ /** 멱등 처리용 고유 이벤트 ID (재시도 시 동일) */
49
+ id: string;
50
+ type: WebhookEventType;
51
+ /** 이벤트가 가리키는 엔티티 종류 (예: "contact", "workflowRun") */
52
+ entityType: string;
53
+ /** 엔티티 ID (없을 수 있음) */
54
+ entityId: string | null;
55
+ /** 발신 시각 (ISO 8601) */
56
+ createdAt: string;
57
+ data: T;
32
58
  };
33
59
  type WebhookHandlers = Partial<Record<WebhookEventType, (payload: WebhookPayload) => void | Promise<void>>>;
34
60
  /**
@@ -51,10 +77,10 @@ declare const DEFAULT_IDEMPOTENCY_TTL_MS: number;
51
77
  * multi-instance deployments.
52
78
  */
53
79
  type IdempotencyStore = {
54
- /** Returns true if `id` has already been marked processed. */
55
- has(id: string): Promise<boolean> | boolean;
56
- /** Persist `id` for at least `ttlMs` so subsequent deliveries no-op. */
57
- markProcessed(id: string, ttlMs: number): Promise<void> | void;
80
+ /** Returns true if `id` has already been marked processed. */
81
+ has(id: string): Promise<boolean> | boolean;
82
+ /** Persist `id` for at least `ttlMs` so subsequent deliveries no-op. */
83
+ markProcessed(id: string, ttlMs: number): Promise<void> | void;
58
84
  };
59
85
  /**
60
86
  * In-memory idempotency store with a soft cap to avoid unbounded growth.
@@ -62,8 +88,8 @@ type IdempotencyStore = {
62
88
  * multiple replicas, supply a Redis/Postgres-backed store instead.
63
89
  */
64
90
  declare function createMemoryIdempotencyStore(options?: {
65
- /** Max number of ids to keep before evicting the oldest. Default 10_000. */
66
- maxEntries?: number;
91
+ /** Max number of ids to keep before evicting the oldest. Default 10_000. */
92
+ maxEntries?: number;
67
93
  }): IdempotencyStore;
68
94
  /**
69
95
  * Create a webhook handler for Web-standard `Request` → `Response` runtimes
@@ -84,37 +110,37 @@ declare function createMemoryIdempotencyStore(options?: {
84
110
  * ```
85
111
  */
86
112
  declare function createWebhookHandler(config: {
87
- secret: string;
88
- handlers: WebhookHandlers;
89
- /**
90
- * Called when a handler throws. The handler still returns 500 to the caller.
91
- * `meta.attempt` reflects the `x-reopt-delivery-attempt` header when the
92
- * sender provides one; the current reopt sender is best-effort with no retry
93
- * queue (it does not send that header), so `attempt` is `1` in practice —
94
- * treat it as advisory, not a reliable retry counter. Deliveries are
95
- * at-least-once, so dedupe on `payload.id` (see `idempotency`).
96
- */
97
- onError?: (error: Error, payload: WebhookPayload, meta: {
98
- attempt: number;
99
- }) => void | Promise<void>;
100
- /**
101
- * Max allowed age (ms) of the `x-reopt-timestamp` header before the webhook
102
- * is rejected as a replay. Defaults to {@link DEFAULT_WEBHOOK_TOLERANCE_MS}.
103
- * Pass `0` to disable (not recommended in production).
104
- */
105
- toleranceMs?: number;
106
- /**
107
- * Idempotency: when set, the handler stores `payload.id` after a successful
108
- * delivery and short-circuits future deliveries of the same id with HTTP
109
- * 200. Pair with `idempotencyTtlMs` to control the dedupe window.
110
- *
111
- * Pass `true` to use an in-memory store (single-instance only) or an
112
- * {@link IdempotencyStore} backed by Redis/Postgres for multi-instance
113
- * deployments.
114
- */
115
- idempotency?: boolean | IdempotencyStore;
116
- /** Idempotency cache window. Defaults to {@link DEFAULT_IDEMPOTENCY_TTL_MS}. */
117
- idempotencyTtlMs?: number;
113
+ secret: string;
114
+ handlers: WebhookHandlers;
115
+ /**
116
+ * Called when a handler throws. The handler still returns 500 to the caller.
117
+ * `meta.attempt` reflects the `x-reopt-delivery-attempt` header when the
118
+ * sender provides one; the current reopt sender is best-effort with no retry
119
+ * queue (it does not send that header), so `attempt` is `1` in practice —
120
+ * treat it as advisory, not a reliable retry counter. Deliveries are
121
+ * at-least-once, so dedupe on `payload.id` (see `idempotency`).
122
+ */
123
+ onError?: (error: Error, payload: WebhookPayload, meta: {
124
+ attempt: number;
125
+ }) => void | Promise<void>;
126
+ /**
127
+ * Max allowed age (ms) of the `x-reopt-timestamp` header before the webhook
128
+ * is rejected as a replay. Defaults to {@link DEFAULT_WEBHOOK_TOLERANCE_MS}.
129
+ * Pass `0` to disable (not recommended in production).
130
+ */
131
+ toleranceMs?: number;
132
+ /**
133
+ * Idempotency: when set, the handler stores `payload.id` after a successful
134
+ * delivery and short-circuits future deliveries of the same id with HTTP
135
+ * 200. Pair with `idempotencyTtlMs` to control the dedupe window.
136
+ *
137
+ * Pass `true` to use an in-memory store (single-instance only) or an
138
+ * {@link IdempotencyStore} backed by Redis/Postgres for multi-instance
139
+ * deployments.
140
+ */
141
+ idempotency?: boolean | IdempotencyStore;
142
+ /** Idempotency cache window. Defaults to {@link DEFAULT_IDEMPOTENCY_TTL_MS}. */
143
+ idempotencyTtlMs?: number;
118
144
  }): (request: Request) => Promise<Response>;
119
145
  /**
120
146
  * Verify a Reopt webhook signature.
@@ -139,5 +165,6 @@ declare function createWebhookHandler(config: {
139
165
  * ```
140
166
  */
141
167
  declare function verifySignature(timestamp: string, body: string, signature: string, secret: string): Promise<boolean>;
142
-
143
- export { DEFAULT_IDEMPOTENCY_TTL_MS, DEFAULT_WEBHOOK_TOLERANCE_MS, type IdempotencyStore, type WebhookEventType, type WebhookHandlers, type WebhookPayload, createMemoryIdempotencyStore, createWebhookHandler, verifySignature };
168
+ //#endregion
169
+ export { DEFAULT_IDEMPOTENCY_TTL_MS, DEFAULT_WEBHOOK_TOLERANCE_MS, IdempotencyStore, SubscriptionWebhookData, WebhookEventType, WebhookHandlers, WebhookPayload, createMemoryIdempotencyStore, createWebhookHandler, verifySignature };
170
+ //# sourceMappingURL=index.d.ts.map