@reopt-ai/brandapp-sdk 4.7.0-rc.10 → 4.7.0-rc.12

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 (37) hide show
  1. package/CHANGELOG.md +34 -0
  2. package/README.md +67 -1
  3. package/dist/ai/index.js +2 -2
  4. package/dist/ai-provider/index.js +1 -1
  5. package/dist/analytics/index.js +1 -1
  6. package/dist/auth/index.js +1 -1
  7. package/dist/better-auth/index.d.ts +102 -1
  8. package/dist/better-auth/index.js +219 -4
  9. package/dist/{client-m4e-HwMX.js → client-BHX14FpH.js} +2 -2
  10. package/dist/{client-Brv0KsDM.js → client-BHoS1dGr.js} +2 -2
  11. package/dist/{client-CGy4Z0JO.js → client-BL7vOv_M.js} +2 -2
  12. package/dist/{client-Dv7WwJr-.js → client-BUfDFULW.js} +2 -2
  13. package/dist/{client-CmV48bW0.js → client-BtFoViKj.js} +3 -3
  14. package/dist/{client-BPcoDnOd.js → client-BvLrx0Ai.js} +2 -2
  15. package/dist/{client-B281w6RL.js → client-BvUK6AxL.js} +2 -2
  16. package/dist/{client-C7z5-izC.js → client-Bzk7eqy5.js} +3 -3
  17. package/dist/{client-BxrWT0mi.js → client-CB1A7gg4.js} +2 -2
  18. package/dist/{client-D8d3xsYm.js → client-Ccw-FJlt.js} +4 -4
  19. package/dist/{client-ey80gKM_.js → client-l7dQ_fLm.js} +3 -3
  20. package/dist/{client-D97Ylva1.js → client-tFChmi6z.js} +4 -4
  21. package/dist/cms/index.js +1 -1
  22. package/dist/{config-DaSeKofC.js → config-D21ZcDET.js} +2 -2
  23. package/dist/eav/index.js +2 -2
  24. package/dist/feedback/index.js +1 -1
  25. package/dist/files/index.js +1 -1
  26. package/dist/{http-client-BCZhLtY5.js → http-client-CVwg2EAl.js} +2 -2
  27. package/dist/index.js +12 -12
  28. package/dist/installation/index.js +3 -3
  29. package/dist/logout/index.js +1 -1
  30. package/dist/machine/index.js +1 -1
  31. package/dist/plans/index.js +1 -1
  32. package/dist/push/index.js +1 -1
  33. package/dist/{query-B8Hg9bub.js → query-C_qce1vC.js} +2 -2
  34. package/dist/social/index.js +1 -1
  35. package/dist/terms/index.js +1 -1
  36. package/dist/workspace/index.js +1 -1
  37. package/package.json +1 -1
package/CHANGELOG.md CHANGED
@@ -7,6 +7,40 @@ This project adheres to [Semantic Versioning](https://semver.org/).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [4.7.0-rc.12] — 2026-11-07
11
+
12
+ Pre-release (`npm i @reopt-ai/brandapp-sdk@next`) — 전화번호 로그인 앱 심사 계정.
13
+
14
+ ### Added
15
+
16
+ - `createReoptPhoneNumber(config, { reviewAccounts: { phoneNumbers, code } })` — 문자를 받을 수 없는
17
+ 앱스토어·플레이 심사자를 위한 고정 번호·고정 코드. 목록 번호는 리옵트를 부르지 않고(문자·비용 없음)
18
+ 플러그인이 저장한 이번 코드를 `code`로 바꾼다. 검증·시도 횟수·만료·가입은 다른 번호와 같다. 번호는 국내
19
+ 휴대폰으로 정본화되고 `code`는 `otpLength` 자리 숫자여야 한다(아니면 만들 때 던진다). 실제 개통된 번호를
20
+ 넣지 말 것 — 그 주인은 로그인할 수 없고 코드를 아는 사람이 그 계정에 들어간다. 타입
21
+ `ReoptPhoneReviewAccounts`.
22
+
23
+ ## [4.7.0-rc.11] — 2026-11-07
24
+
25
+ Pre-release (`npm i @reopt-ai/brandapp-sdk@next`) — 전화번호 로그인. 어댑터 모드 앱(앱이 Better Auth를 직접
26
+ 돌리는 앱)이 리옵트 계정이나 소셜 API 키 없이 문자 인증번호로 가입·로그인할 수 있다. `better-auth` 1.7.16 이상 필요.
27
+
28
+ ### Added
29
+
30
+ - 전화번호 로그인 — `createReoptPhoneNumber(config, options?)`(`/better-auth`)가 Better Auth `phoneNumber`
31
+ 플러그인을 리옵트 문자 발송(`POST /api/v1/brandapp/{id}/auth/otp/sms`, 어댑터 자격)과 함께 돌려준다.
32
+ `createReoptBetterAuth()` 번들에도 `phoneNumber`가 실린다. 번호만으로 가입하면 임시 이메일이 들어가고,
33
+ 리옵트 콘솔은 그 사용자를 번호로 보이며 **인증된** 번호가 같은 CRM 고객에 잇는다.
34
+ 플러그인 없이 발송만 쓰려면 `createReoptOtpSmsSender(config)`. 서버가 워크스페이스 Solapi 연결이 없으면
35
+ `409 SMS_NOT_CONNECTED`로 거절한다(리옵트 시스템 브랜드·데모·테스트 조직은 리옵트 번호로 대신 보낸다).
36
+ 번호 정본화·형식 판정 `canonicalizeReoptPhoneNumber`·`isValidReoptPhoneNumber`는 서버와 같은 규칙이다.
37
+ - 보안: **국내 휴대폰만** 받고 `/phone-number/*` 요청의 번호를 플러그인이 보기 전에 `01012345678`로 맞춘다
38
+ (플러그인은 입력 문자열 그대로 사용자를 찾아, 표기만 다른 같은 번호가 두 계정이 될 수 있었다). 임시 이메일은
39
+ `<숫자>.<난수>@phone-login.reopt.app`(번호가 다른 사람에게 넘어가도 유일). 최종 사용자 IP를 함께 보내 리옵트가
40
+ IP 단위 상한을 건다. 리옵트의 거절은 Better Auth 오류로 바꿔 앱 사용자에게 429·503·400이 간다. `better-auth`
41
+ 1.7.16 미만이면 만들 때 던진다(그 전 판은 가입 때 미인증 번호를 저장한다). `otpLength` 4~8·`expiresIn` 60~1800.
42
+ `createReoptBetterAuth().phoneNumber`는 접근할 때 만든다.
43
+
10
44
  ## [4.7.0-rc.10] — 2026-11-02
11
45
 
12
46
  Pre-release (`npm i @reopt-ai/brandapp-sdk@next`) — 스트리밍 줄바꿈 결함 수정. rc.9에서 `sdk.ai.stream`으로 받은
package/README.md CHANGED
@@ -163,7 +163,8 @@ signInWithReopt(authClient, { callbackURL: "/dashboard" });
163
163
  > `${baseURL}/api/auth/callback/reopt` (1.6 used
164
164
  > `/api/auth/oauth2/callback/reopt`). Reopt's own system clients have both
165
165
  > registered; if you registered a custom redirect URI, add the new path in the
166
- > studio before upgrading.
166
+ > platform console (brandapp settings → OAuth → 수정) before upgrading — the
167
+ > client id and secret stay the same.
167
168
 
168
169
  > **Shared secret (transitional).** `createReoptSDK({ clientId, clientSecret })`
169
170
  > and `createReoptBetterAuth({ clientId, clientSecret })` still work for login
@@ -171,6 +172,71 @@ signInWithReopt(authClient, { callbackURL: "/dashboard" });
171
172
  > app has moved to a key — new integrations should start with server
172
173
  > credentials.
173
174
 
175
+ ### Phone-number login (no provider keys)
176
+
177
+ Users sign up and sign in with a phone number and an SMS code — no Reopt
178
+ account, no Google/Apple keys. This is Better Auth's `phoneNumber` plugin;
179
+ Reopt sends the SMS through the workspace's connected Solapi account and brand
180
+ sender number (Studio → workspace settings → 연동). It uses the same `adapter`
181
+ credential as the remote adapter.
182
+
183
+ ```typescript
184
+ import { betterAuth } from "better-auth";
185
+ import { createReoptBetterAuth } from "@reopt-ai/brandapp-sdk/better-auth";
186
+
187
+ const reopt = createReoptBetterAuth({
188
+ brandappId: process.env.BRANDAPP_ID!,
189
+ clientId: adapter.clientId, // adapter credential (brandapp:auth-adapter)
190
+ authorization: adapter.headers,
191
+ phoneNumber: { otpLength: 6, expiresIn: 300 },
192
+ });
193
+
194
+ export const auth = betterAuth({
195
+ database: reopt.database,
196
+ plugins: [reopt.phoneNumber],
197
+ });
198
+
199
+ // client (phoneNumberClient from "better-auth/client/plugins"):
200
+ // await authClient.phoneNumber.sendOtp({ phoneNumber: "010-1234-5678" });
201
+ // await authClient.phoneNumber.verify({ phoneNumber: "010-1234-5678", code });
202
+ ```
203
+
204
+ - **Korean mobile numbers only.** Every `/phone-number/*` request is
205
+ canonicalized to `01012345678` before the plugin sees it, so different
206
+ formats never split one person into two accounts; other numbers get a 400
207
+ (`INVALID_PHONE_NUMBER`). Foreign numbers are the main SMS-pumping vector.
208
+ - Without an SMS connection the send fails with `SMS_NOT_CONNECTED` (Better
209
+ Auth 503 to your client). Reopt's own system brands and test workspaces fall
210
+ back to Reopt's number (test workspaces: 30/hour, 100/day).
211
+ - Limits (Better Auth 429 to your client): 3/min and 10/hour per number,
212
+ 5/min and 20/hour per end-user IP (forwarded per your
213
+ `advanced.ipAddress` settings), 60/min and 1,000/hour per app. Keep Better
214
+ Auth's own rate limiter on with shared storage too.
215
+ - Phone-only users get a placeholder email
216
+ `<digits>.<random>@phone-login.reopt.app` (unique even when a number moves
217
+ to someone else). Reopt shows them by number and links a **verified** number
218
+ to the CRM customer with the same number.
219
+ - The code is generated and verified by your Better Auth; Reopt only delivers
220
+ it and never stores it. Requires `better-auth >= 1.7.16` (older versions
221
+ store unverified numbers on sign-up; the factory throws).
222
+ - Already wiring the plugin yourself? `createReoptOtpSmsSender(config)` returns
223
+ just the sender for your own `sendOTP` — pass canonical numbers
224
+ (`canonicalizeReoptPhoneNumber`) and `clientIp`.
225
+ - **App-store review accounts** — reviewers cannot receive texts. Give them a
226
+ number and a fixed code:
227
+
228
+ ```ts
229
+ createReoptPhoneNumber(config, {
230
+ reviewAccounts: { phoneNumbers: ["010-0000-1234"], code: "246810" },
231
+ });
232
+ ```
233
+
234
+ Those numbers never reach Reopt (no SMS, no cost); the stored code becomes
235
+ `code`, and verification, attempt limits, expiry and sign-up run as usual.
236
+ `code` must be `otpLength` digits. Use numbers that are **not in service** —
237
+ a real number would lock its owner out and let anyone with the code into the
238
+ account. Read both values from env and omit the option to turn it off.
239
+
174
240
  ### External marketing site (1.8+)
175
241
 
176
242
  블로그·약관·sitemap·RSS·세션 인식까지 SDK 호출만으로 외부 Next.js
package/dist/ai/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { S as ReoptSDKError } from "../config-DaSeKofC.js";
2
- import { n as createReoptAiClient, t as ReoptAiClient } from "../client-D97Ylva1.js";
1
+ import { S as ReoptSDKError } from "../config-D21ZcDET.js";
2
+ import { n as createReoptAiClient, t as ReoptAiClient } from "../client-tFChmi6z.js";
3
3
 
4
4
  //#region src/ai/evaluator.ts
5
5
  function createBrandappEvaluator(source, options = {}) {
@@ -1,4 +1,4 @@
1
- import { i as resolveBaseUrl, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, r as assertBrowserSafe } from "../config-DaSeKofC.js";
1
+ import { i as resolveBaseUrl, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, r as assertBrowserSafe } from "../config-D21ZcDET.js";
2
2
  import { t as createManagedAbort } from "../abort--nOBFN4M.js";
3
3
  import { t as createAuthHeader } from "../encoding-Bwfm3iaE.js";
4
4
  import { t as createSSELineProcessor } from "../sse-parser-D65dmL4A.js";
@@ -1,4 +1,4 @@
1
- import { n as createReoptAnalyticsClient, t as ReoptAnalyticsClient } from "../client-Dv7WwJr-.js";
1
+ import { n as createReoptAnalyticsClient, t as ReoptAnalyticsClient } from "../client-BUfDFULW.js";
2
2
  import { getInstance, identify, init, pageView, setConsent, track } from "@reopt-ai/data-sdk";
3
3
 
4
4
  //#region src/analytics/browser.ts
@@ -1,4 +1,4 @@
1
- import { n as createReoptAuthClient, t as ReoptAuthClient } from "../client-BxrWT0mi.js";
1
+ import { n as createReoptAuthClient, t as ReoptAuthClient } from "../client-CB1A7gg4.js";
2
2
 
3
3
  //#region src/auth/session.ts
4
4
  /**
@@ -3,6 +3,7 @@ import { a as REOPT_PROVIDER_IDS, i as REOPT_PROVIDER_ID, n as AdapterRequestBod
3
3
  import { i as ClientPrivateJwk } from "../keys-B2pA8EkU.js";
4
4
  import { T as isReoptSDKError, _ as RateLimitError, t as AuthError, v as ReoptSDKError, x as ServerError } from "../errors-D-Va8oeC.js";
5
5
  import { AdapterFactory } from "better-auth/adapters";
6
+ import { PhoneNumberOptions } from "better-auth/plugins/phone-number";
6
7
  import { BetterAuthOptions, BetterAuthPlugin } from "better-auth";
7
8
  //#region src/better-auth/adapter.d.ts
8
9
  /**
@@ -107,14 +108,114 @@ type ReoptOAuthOptions = ReoptSDKConfig & {
107
108
  */
108
109
  declare function createReoptOAuth(options: ReoptOAuthOptions): BetterAuthPlugin;
109
110
  //#endregion
111
+ //#region src/better-auth/phone-number.d.ts
112
+ /**
113
+ * Phone-number login vocabulary. Mirrors `@reopt/constants/brandapp-phone-login` on reopt's
114
+ * server (the SDK cannot import it) — a reopt web test compares the two.
115
+ *
116
+ * Only **Korean mobile numbers** are accepted, and the canonical form is the domestic digits
117
+ * (`01012345678`): Better Auth's plugin looks users up by the exact input string, so without a
118
+ * canonical form `010-1234-5678` and `01012345678` would become two accounts; reopt's SMS route
119
+ * sends domestic numbers only; foreign numbers are the main SMS-pumping (toll fraud) vector.
120
+ */
121
+ declare const REOPT_PHONE_LOGIN_TEMP_EMAIL_DOMAIN = "phone-login.reopt.app";
122
+ declare const DEFAULT_REOPT_PHONE_OTP_EXPIRES_IN = 300;
123
+ /** Canonical Korean mobile digits (`01012345678`) or null. `+82 10-…`, `82-10-…`, `010.…` all canonicalize. */
124
+ declare function canonicalizeReoptPhoneNumber(raw: string | null | undefined): string | null;
125
+ declare function isValidReoptPhoneNumber(raw: string): boolean;
126
+ /**
127
+ * Placeholder email for phone-only sign-ups: `<digits>.<random>@phone-login.reopt.app`. The random part
128
+ * keeps it unique when a number moves to another person after its first owner changed numbers.
129
+ * reopt reads this domain as "no email" (CRM linking, console).
130
+ */
131
+ declare function buildReoptPhoneLoginTempEmail(raw: string): string;
132
+ type ReoptPhoneNumberOptions = {
133
+ /** OTP length, 4–8. Default 6. */
134
+ otpLength?: number;
135
+ /** OTP lifetime in seconds, 60–1800. Default 300. Sent to reopt only for the "enter within N minutes" copy. */
136
+ expiresIn?: number;
137
+ /** Wrong-code attempts before the code is invalidated. Default 5. */
138
+ allowedAttempts?: number;
139
+ /** Require a verified number before sign-in. Default true. */
140
+ requireVerification?: boolean;
141
+ /**
142
+ * Whether a verified number may create an account on its own (`signUpOnVerification`).
143
+ * Default true — the temp email/name are derived from the number.
144
+ */
145
+ signUpOnVerification?: boolean;
146
+ /** Override the generated display name for phone-only sign-ups. Default: `010-1234-5678`. */
147
+ getTempName?: (phoneNumber: string) => string;
148
+ /** Called after a verification succeeds (`callbackOnVerification` of the plugin). */
149
+ callbackOnVerification?: PhoneNumberOptions["callbackOnVerification"];
150
+ /**
151
+ * App-store review accounts — numbers that never get an SMS and accept one fixed code, so a
152
+ * reviewer (who cannot receive texts) can sign in. Omit to disable.
153
+ *
154
+ * For these numbers reopt is not called (no SMS, no cost); the code the plugin just stored is
155
+ * replaced with `code`. Verification, attempt limits, expiry and sign-up then run exactly as for
156
+ * any other number.
157
+ *
158
+ * 🔴 Use numbers that are **not in service**. A real number here locks its owner out (they never
159
+ * get a text) and lets anyone who knows `code` into that account.
160
+ */
161
+ reviewAccounts?: ReoptPhoneReviewAccounts;
162
+ };
163
+ type ReoptPhoneReviewAccounts = {
164
+ /** Any format — canonicalized like every other number. Must not be empty. */
165
+ phoneNumbers: readonly string[];
166
+ /** Digits only, exactly `otpLength` long. */
167
+ code: string;
168
+ };
169
+ type ReoptOtpSmsResult = {
170
+ sent: true;
171
+ via: "workspace";
172
+ } | {
173
+ sent: true;
174
+ via: "reopt";
175
+ reason: string;
176
+ };
177
+ /**
178
+ * Sends one OTP SMS through reopt (`POST /auth/otp/sms`). Exposed for apps that wire the
179
+ * `phoneNumber` plugin themselves and only want reopt as the SMS sender. Pass `clientIp`
180
+ * (the end user's IP as your server sees it) so reopt can rate-limit per user, not per server.
181
+ */
182
+ declare function createReoptOtpSmsSender(config: ReoptSDKConfig): (input: {
183
+ phoneNumber: string;
184
+ code: string;
185
+ expiresInSeconds?: number;
186
+ clientIp?: string | null;
187
+ }) => Promise<ReoptOtpSmsResult>;
188
+ /**
189
+ * Phone-number login for a brandapp — Better Auth's `phoneNumber` plugin with reopt as the SMS
190
+ * sender. The app never holds an SMS provider key: reopt sends through the workspace's connected
191
+ * Solapi account (or, for reopt's own system brands and test workspaces, through reopt's own
192
+ * number). If the workspace has no SMS connection the send fails with `SMS_NOT_CONNECTED`.
193
+ *
194
+ * - Korean mobile numbers only; every `/phone-number/*` request is canonicalized to `01012345678`
195
+ * before the plugin sees it (so formats never split one person into two accounts).
196
+ * - The end user's IP (per your Better Auth `advanced.ipAddress` settings) is forwarded so reopt can
197
+ * rate-limit per user. Keep Better Auth's own rate limiter on with shared storage as well.
198
+ * - Requires better-auth >= 1.7.16.
199
+ *
200
+ * Needs the same adapter credential as `createReoptAdapter` (scope `brandapp:auth-adapter`).
201
+ */
202
+ declare function createReoptPhoneNumber(config: ReoptSDKConfig, options?: ReoptPhoneNumberOptions): BetterAuthPlugin;
203
+ //#endregion
110
204
  //#region src/better-auth/helper.d.ts
111
205
  type ReoptBetterAuthOptions = ReoptSDKConfig & {
112
206
  /** Additional OAuth scopes */
113
207
  additionalScopes?: string[];
208
+ /** Phone-number login (OTP SMS sent by reopt). See `createReoptPhoneNumber`. */
209
+ phoneNumber?: ReoptPhoneNumberOptions;
114
210
  };
115
211
  type ReoptBetterAuthBundle = {
116
212
  database: AdapterFactory<BetterAuthOptions>;
117
213
  oauth: BetterAuthPlugin;
214
+ /**
215
+ * Better Auth `phoneNumber` plugin with reopt as the SMS sender — add to `plugins` to let users
216
+ * sign in with a phone number and no reopt account. Needs the adapter credential (same as `database`).
217
+ */
218
+ phoneNumber: BetterAuthPlugin;
118
219
  };
119
220
  /**
120
221
  * Config 한 번으로 adapter + OAuth plugin을 함께 생성
@@ -145,5 +246,5 @@ type ReoptBetterAuthBundle = {
145
246
  */
146
247
  declare function createReoptBetterAuth(options: ReoptBetterAuthOptions): ReoptBetterAuthBundle;
147
248
  //#endregion
148
- export { type AdapterOperation, type AdapterRequestBody, AuthError, REOPT_BASE_URLS, REOPT_DEFAULT_SCOPES, REOPT_PROVIDER_ID, REOPT_PROVIDER_IDS, REOPT_STEP_UP_PROVIDER_ID, RateLimitError, type ReoptBetterAuthOptions, type ReoptOAuthOptions, type ReoptSDKConfig, ReoptSDKError, STEP_UP_MAX_AUTH_AGE_SECONDS, ServerError, createReoptAdapter, createReoptBetterAuth, createReoptOAuth, isReoptSDKError };
249
+ export { type AdapterOperation, type AdapterRequestBody, AuthError, DEFAULT_REOPT_PHONE_OTP_EXPIRES_IN, REOPT_BASE_URLS, REOPT_DEFAULT_SCOPES, REOPT_PHONE_LOGIN_TEMP_EMAIL_DOMAIN, REOPT_PROVIDER_ID, REOPT_PROVIDER_IDS, REOPT_STEP_UP_PROVIDER_ID, RateLimitError, type ReoptBetterAuthOptions, type ReoptOAuthOptions, type ReoptOtpSmsResult, type ReoptPhoneNumberOptions, type ReoptPhoneReviewAccounts, type ReoptSDKConfig, ReoptSDKError, STEP_UP_MAX_AUTH_AGE_SECONDS, ServerError, buildReoptPhoneLoginTempEmail, canonicalizeReoptPhoneNumber, createReoptAdapter, createReoptBetterAuth, createReoptOAuth, createReoptOtpSmsSender, createReoptPhoneNumber, isReoptSDKError, isValidReoptPhoneNumber };
149
250
  //# sourceMappingURL=index.d.ts.map
@@ -1,10 +1,12 @@
1
- import { O as isReoptSDKError, S as ReoptSDKError, a as resolveIdBaseUrl, s as AuthError, t as REOPT_BASE_URLS, w as ServerError, x as RateLimitError } from "../config-DaSeKofC.js";
2
- import { t as BaseHttpClient } from "../http-client-BCZhLtY5.js";
1
+ import { O as isReoptSDKError, S as ReoptSDKError, a as resolveIdBaseUrl, s as AuthError, t as REOPT_BASE_URLS, w as ServerError, x as RateLimitError } from "../config-D21ZcDET.js";
2
+ import { t as BaseHttpClient } from "../http-client-CVwg2EAl.js";
3
3
  import { o as readClientKeyRing } from "../keys-B_R_lsyF.js";
4
4
  import { a as STEP_UP_MAX_AUTH_AGE_SECONDS, i as REOPT_STEP_UP_PROVIDER_ID, n as REOPT_PROVIDER_ID, r as REOPT_PROVIDER_IDS, t as REOPT_DEFAULT_SCOPES } from "../types-DGAVaUCc.js";
5
5
  import { createAdapterFactory } from "better-auth/adapters";
6
6
  import { createPrivateKeyJwtClientAssertionGetter } from "@better-auth/core/oauth2";
7
7
  import { genericOAuth } from "better-auth/plugins";
8
+ import { phoneNumber } from "better-auth/plugins/phone-number";
9
+ import { APIError, createAuthMiddleware, getIP } from "better-auth/api";
8
10
 
9
11
  //#region src/better-auth/adapter.ts
10
12
  /**
@@ -209,6 +211,214 @@ function createReoptOAuth(options) {
209
211
  }]] });
210
212
  }
211
213
 
214
+ //#endregion
215
+ //#region src/better-auth/phone-number.ts
216
+ /**
217
+ * Phone-number login vocabulary. Mirrors `@reopt/constants/brandapp-phone-login` on reopt's
218
+ * server (the SDK cannot import it) — a reopt web test compares the two.
219
+ *
220
+ * Only **Korean mobile numbers** are accepted, and the canonical form is the domestic digits
221
+ * (`01012345678`): Better Auth's plugin looks users up by the exact input string, so without a
222
+ * canonical form `010-1234-5678` and `01012345678` would become two accounts; reopt's SMS route
223
+ * sends domestic numbers only; foreign numbers are the main SMS-pumping (toll fraud) vector.
224
+ */
225
+ const REOPT_PHONE_LOGIN_TEMP_EMAIL_DOMAIN = "phone-login.reopt.app";
226
+ const DEFAULT_REOPT_PHONE_OTP_EXPIRES_IN = 300;
227
+ /** better-auth 1.7.16 stopped storing unverified phone numbers on sign-up — older plugins must not be used. */
228
+ const MIN_BETTER_AUTH_VERSION = [
229
+ 1,
230
+ 7,
231
+ 16
232
+ ];
233
+ const PHONE_INPUT_PATTERN = /^\+?[0-9 ().-]+$/;
234
+ const KOREAN_MOBILE_PATTERN = /^01[016789][0-9]{7,8}$/;
235
+ /** Canonical Korean mobile digits (`01012345678`) or null. `+82 10-…`, `82-10-…`, `010.…` all canonicalize. */
236
+ function canonicalizeReoptPhoneNumber(raw) {
237
+ if (typeof raw !== "string") return null;
238
+ const trimmed = raw.trim();
239
+ if (!trimmed || !PHONE_INPUT_PATTERN.test(trimmed)) return null;
240
+ let digits = trimmed.replace(/\D/g, "");
241
+ if (trimmed.startsWith("+") || digits.startsWith("82")) {
242
+ if (!digits.startsWith("82")) return null;
243
+ digits = digits.slice(2);
244
+ if (!digits.startsWith("0")) digits = `0${digits}`;
245
+ }
246
+ return KOREAN_MOBILE_PATTERN.test(digits) ? digits : null;
247
+ }
248
+ function isValidReoptPhoneNumber(raw) {
249
+ return canonicalizeReoptPhoneNumber(raw) !== null;
250
+ }
251
+ function randomNonce() {
252
+ const bytes = /* @__PURE__ */ new Uint8Array(6);
253
+ globalThis.crypto.getRandomValues(bytes);
254
+ return Array.from(bytes, (b) => b.toString(16).padStart(2, "0")).join("");
255
+ }
256
+ /**
257
+ * Placeholder email for phone-only sign-ups: `<digits>.<random>@phone-login.reopt.app`. The random part
258
+ * keeps it unique when a number moves to another person after its first owner changed numbers.
259
+ * reopt reads this domain as "no email" (CRM linking, console).
260
+ */
261
+ function buildReoptPhoneLoginTempEmail(raw) {
262
+ return `${canonicalizeReoptPhoneNumber(raw) ?? raw.replace(/\D/g, "")}.${randomNonce()}@${REOPT_PHONE_LOGIN_TEMP_EMAIL_DOMAIN}`;
263
+ }
264
+ function formatKoreanMobile(canonical) {
265
+ return /^010\d{8}$/.test(canonical) ? `${canonical.slice(0, 3)}-${canonical.slice(3, 7)}-${canonical.slice(7)}` : canonical;
266
+ }
267
+ /**
268
+ * Sends one OTP SMS through reopt (`POST /auth/otp/sms`). Exposed for apps that wire the
269
+ * `phoneNumber` plugin themselves and only want reopt as the SMS sender. Pass `clientIp`
270
+ * (the end user's IP as your server sees it) so reopt can rate-limit per user, not per server.
271
+ */
272
+ function createReoptOtpSmsSender(config) {
273
+ const http = new BaseHttpClient(config, `/api/v1/brandapp/${config.brandappId}/auth`);
274
+ return async function sendOtpSms(input) {
275
+ return (await http.fetch("POST", "/otp/sms", {
276
+ phoneNumber: input.phoneNumber,
277
+ code: input.code,
278
+ expiresInSeconds: input.expiresInSeconds ?? 300,
279
+ ...input.clientIp ? { clientIp: input.clientIp } : {}
280
+ })).data;
281
+ };
282
+ }
283
+ /** reopt's refusals → Better Auth errors, so the app's client sees a meaningful status instead of a 500. */
284
+ function toAuthError(error) {
285
+ if (!(error instanceof ReoptSDKError)) return error;
286
+ if (error.status === 429) return new APIError("TOO_MANY_REQUESTS", {
287
+ code: "OTP_RATE_LIMITED",
288
+ message: error.message
289
+ });
290
+ if (error.status === 409 && error.code === "SMS_NOT_CONNECTED") return new APIError("SERVICE_UNAVAILABLE", {
291
+ code: "SMS_NOT_CONNECTED",
292
+ message: "Phone login is not available for this app yet."
293
+ });
294
+ if (error.status === 503) return new APIError("SERVICE_UNAVAILABLE", {
295
+ code: "OTP_UNAVAILABLE",
296
+ message: error.message
297
+ });
298
+ if (error.status === 400) return new APIError("BAD_REQUEST", {
299
+ code: "INVALID_PHONE_NUMBER",
300
+ message: "Enter a Korean mobile number."
301
+ });
302
+ return error;
303
+ }
304
+ function assertBetterAuthVersion(version) {
305
+ const parts = typeof version === "string" ? version.split(/[.-]/).slice(0, 3).map((part) => Number.parseInt(part, 10)) : [];
306
+ if (!(parts.length === 3 && parts.every(Number.isFinite) && (parts[0] > MIN_BETTER_AUTH_VERSION[0] || parts[0] === MIN_BETTER_AUTH_VERSION[0] && (parts[1] > MIN_BETTER_AUTH_VERSION[1] || parts[1] === MIN_BETTER_AUTH_VERSION[1] && parts[2] >= MIN_BETTER_AUTH_VERSION[2])))) throw new Error(`[@reopt-ai/brandapp-sdk] Phone login needs better-auth >= ${MIN_BETTER_AUTH_VERSION.join(".")} (found ${String(version ?? "unknown")}). Older versions store unverified phone numbers on sign-up.`);
307
+ }
308
+ function resolveReviewAccounts(review, otpLength) {
309
+ if (!review) return null;
310
+ if (review.phoneNumbers.length === 0) throw new Error("[@reopt-ai/brandapp-sdk] reviewAccounts.phoneNumbers is empty — omit reviewAccounts to disable it.");
311
+ const numbers = /* @__PURE__ */ new Set();
312
+ for (const raw of review.phoneNumbers) {
313
+ const canonical = canonicalizeReoptPhoneNumber(raw);
314
+ if (!canonical) throw new Error(`[@reopt-ai/brandapp-sdk] reviewAccounts.phoneNumbers has a value that is not a Korean mobile number.`);
315
+ numbers.add(canonical);
316
+ }
317
+ if (!/^[0-9]+$/.test(review.code) || review.code.length !== otpLength) throw new Error(`[@reopt-ai/brandapp-sdk] reviewAccounts.code must be ${otpLength} digits (otpLength).`);
318
+ return {
319
+ numbers,
320
+ code: review.code
321
+ };
322
+ }
323
+ /**
324
+ * The plugin's verification row for a phone OTP. Mirrors `phoneNumberOTPIdentifier` in
325
+ * better-auth's phone-number plugin (not exported) — the review round-trip test runs the real plugin
326
+ * so a format change upstream fails there first.
327
+ */
328
+ function phoneOtpIdentifier(phone) {
329
+ return `phone-number-otp-${phone}`;
330
+ }
331
+ async function pinReviewCode(ctx, phone, code, expiresIn) {
332
+ const adapter = ctx?.context?.internalAdapter;
333
+ if (!adapter) throw new Error("[@reopt-ai/brandapp-sdk] reviewAccounts needs the Better Auth endpoint context in sendOTP.");
334
+ const identifier = phoneOtpIdentifier(phone);
335
+ await adapter.deleteVerificationByIdentifier(identifier);
336
+ await adapter.createVerificationValue({
337
+ value: `${code}:0`,
338
+ identifier,
339
+ expiresAt: new Date(Date.now() + expiresIn * 1e3)
340
+ });
341
+ }
342
+ function assertRange(name, value, min, max) {
343
+ if (!Number.isInteger(value) || value < min || value > max) throw new Error(`[@reopt-ai/brandapp-sdk] ${name} must be an integer between ${min} and ${max} (got ${value}).`);
344
+ }
345
+ /**
346
+ * Phone-number login for a brandapp — Better Auth's `phoneNumber` plugin with reopt as the SMS
347
+ * sender. The app never holds an SMS provider key: reopt sends through the workspace's connected
348
+ * Solapi account (or, for reopt's own system brands and test workspaces, through reopt's own
349
+ * number). If the workspace has no SMS connection the send fails with `SMS_NOT_CONNECTED`.
350
+ *
351
+ * - Korean mobile numbers only; every `/phone-number/*` request is canonicalized to `01012345678`
352
+ * before the plugin sees it (so formats never split one person into two accounts).
353
+ * - The end user's IP (per your Better Auth `advanced.ipAddress` settings) is forwarded so reopt can
354
+ * rate-limit per user. Keep Better Auth's own rate limiter on with shared storage as well.
355
+ * - Requires better-auth >= 1.7.16.
356
+ *
357
+ * Needs the same adapter credential as `createReoptAdapter` (scope `brandapp:auth-adapter`).
358
+ */
359
+ function createReoptPhoneNumber(config, options = {}) {
360
+ const otpLength = options.otpLength ?? 6;
361
+ const expiresIn = options.expiresIn ?? 300;
362
+ assertRange("otpLength", otpLength, 4, 8);
363
+ assertRange("expiresIn", expiresIn, 60, 1800);
364
+ const review = resolveReviewAccounts(options.reviewAccounts, otpLength);
365
+ const sendOtpSms = createReoptOtpSmsSender(config);
366
+ const getTempName = options.getTempName ?? ((phone) => formatKoreanMobile(canonicalizeReoptPhoneNumber(phone) ?? phone));
367
+ const base = phoneNumber({
368
+ otpLength,
369
+ expiresIn,
370
+ allowedAttempts: options.allowedAttempts ?? 5,
371
+ requireVerification: options.requireVerification ?? true,
372
+ phoneNumberValidator: (phone) => isValidReoptPhoneNumber(phone),
373
+ sendOTP: async ({ phoneNumber: phone, code }, ctx) => {
374
+ if (review?.numbers.has(phone)) {
375
+ await pinReviewCode(ctx, phone, review.code, expiresIn);
376
+ return;
377
+ }
378
+ const clientIp = ctx?.request || ctx?.headers ? getIP(ctx.request ?? ctx.headers, ctx.context.options) : null;
379
+ try {
380
+ await sendOtpSms({
381
+ phoneNumber: phone,
382
+ code,
383
+ expiresInSeconds: expiresIn,
384
+ clientIp
385
+ });
386
+ } catch (error) {
387
+ throw toAuthError(error);
388
+ }
389
+ },
390
+ ...options.signUpOnVerification === false ? {} : { signUpOnVerification: {
391
+ getTempEmail: (phone) => buildReoptPhoneLoginTempEmail(phone),
392
+ getTempName
393
+ } },
394
+ ...options.callbackOnVerification ? { callbackOnVerification: options.callbackOnVerification } : {}
395
+ });
396
+ assertBetterAuthVersion(base.version);
397
+ const canonicalize = {
398
+ matcher: (ctx) => typeof ctx.path === "string" && ctx.path.startsWith("/phone-number/") && typeof ctx.body?.phoneNumber === "string",
399
+ handler: createAuthMiddleware(async (ctx) => {
400
+ const body = ctx.body;
401
+ const canonical = canonicalizeReoptPhoneNumber(body.phoneNumber);
402
+ if (!canonical) throw new APIError("BAD_REQUEST", {
403
+ code: "INVALID_PHONE_NUMBER",
404
+ message: "Enter a Korean mobile number."
405
+ });
406
+ return { context: { body: {
407
+ ...body,
408
+ phoneNumber: canonical
409
+ } } };
410
+ })
411
+ };
412
+ const baseHooks = base.hooks;
413
+ return {
414
+ ...base,
415
+ hooks: {
416
+ ...baseHooks,
417
+ before: [canonicalize, ...baseHooks?.before ?? []]
418
+ }
419
+ };
420
+ }
421
+
212
422
  //#endregion
213
423
  //#region src/better-auth/helper.ts
214
424
  /**
@@ -239,12 +449,17 @@ function createReoptOAuth(options) {
239
449
  * ```
240
450
  */
241
451
  function createReoptBetterAuth(options) {
452
+ let phonePlugin;
242
453
  return {
243
454
  database: createReoptAdapter(options),
244
- oauth: createReoptOAuth(options)
455
+ oauth: createReoptOAuth(options),
456
+ get phoneNumber() {
457
+ phonePlugin ??= createReoptPhoneNumber(options, options.phoneNumber);
458
+ return phonePlugin;
459
+ }
245
460
  };
246
461
  }
247
462
 
248
463
  //#endregion
249
- export { AuthError, REOPT_BASE_URLS, REOPT_DEFAULT_SCOPES, REOPT_PROVIDER_ID, REOPT_PROVIDER_IDS, REOPT_STEP_UP_PROVIDER_ID, RateLimitError, ReoptSDKError, STEP_UP_MAX_AUTH_AGE_SECONDS, ServerError, createReoptAdapter, createReoptBetterAuth, createReoptOAuth, isReoptSDKError };
464
+ export { AuthError, DEFAULT_REOPT_PHONE_OTP_EXPIRES_IN, REOPT_BASE_URLS, REOPT_DEFAULT_SCOPES, REOPT_PHONE_LOGIN_TEMP_EMAIL_DOMAIN, REOPT_PROVIDER_ID, REOPT_PROVIDER_IDS, REOPT_STEP_UP_PROVIDER_ID, RateLimitError, ReoptSDKError, STEP_UP_MAX_AUTH_AGE_SECONDS, ServerError, buildReoptPhoneLoginTempEmail, canonicalizeReoptPhoneNumber, createReoptAdapter, createReoptBetterAuth, createReoptOAuth, createReoptOtpSmsSender, createReoptPhoneNumber, isReoptSDKError, isValidReoptPhoneNumber };
250
465
  //# sourceMappingURL=index.js.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-BCZhLtY5.js";
1
+ import { t as BaseHttpClient } from "./http-client-CVwg2EAl.js";
2
2
 
3
3
  //#region src/push/client.ts
4
4
  var ReoptPushClient = class {
@@ -25,4 +25,4 @@ function createReoptPushClient(config) {
25
25
 
26
26
  //#endregion
27
27
  export { createReoptPushClient as n, ReoptPushClient as t };
28
- //# sourceMappingURL=client-m4e-HwMX.js.map
28
+ //# sourceMappingURL=client-BHX14FpH.js.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-BCZhLtY5.js";
1
+ import { t as BaseHttpClient } from "./http-client-CVwg2EAl.js";
2
2
 
3
3
  //#region src/feedback/client.ts
4
4
  function buildListQuery(query) {
@@ -83,4 +83,4 @@ function createReoptFeedbackClient(config) {
83
83
 
84
84
  //#endregion
85
85
  export { createReoptFeedbackClient as n, ReoptFeedbackClient as t };
86
- //# sourceMappingURL=client-Brv0KsDM.js.map
86
+ //# sourceMappingURL=client-BHoS1dGr.js.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-BCZhLtY5.js";
1
+ import { t as BaseHttpClient } from "./http-client-CVwg2EAl.js";
2
2
 
3
3
  //#region src/plans/client.ts
4
4
  function unwrap(body) {
@@ -143,4 +143,4 @@ function createReoptPlansClient(config) {
143
143
 
144
144
  //#endregion
145
145
  export { createReoptPlansClient as n, ReoptPlansClient as t };
146
- //# sourceMappingURL=client-CGy4Z0JO.js.map
146
+ //# sourceMappingURL=client-BL7vOv_M.js.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-BCZhLtY5.js";
1
+ import { t as BaseHttpClient } from "./http-client-CVwg2EAl.js";
2
2
 
3
3
  //#region src/analytics/client.ts
4
4
  var ReoptAnalyticsClient = class {
@@ -17,4 +17,4 @@ function createReoptAnalyticsClient(config) {
17
17
 
18
18
  //#endregion
19
19
  export { createReoptAnalyticsClient as n, ReoptAnalyticsClient as t };
20
- //# sourceMappingURL=client-Dv7WwJr-.js.map
20
+ //# sourceMappingURL=client-BUfDFULW.js.map
@@ -1,5 +1,5 @@
1
- import { t as BaseHttpClient } from "./http-client-BCZhLtY5.js";
2
- import { t as buildQuery } from "./query-B8Hg9bub.js";
1
+ import { t as BaseHttpClient } from "./http-client-CVwg2EAl.js";
2
+ import { t as buildQuery } from "./query-C_qce1vC.js";
3
3
 
4
4
  //#region src/cms/client.ts
5
5
  function createReoptCmsClient(config) {
@@ -52,4 +52,4 @@ async list(query) {
52
52
 
53
53
  //#endregion
54
54
  export { createReoptCmsClient as t };
55
- //# sourceMappingURL=client-CmV48bW0.js.map
55
+ //# sourceMappingURL=client-BtFoViKj.js.map
@@ -1,4 +1,4 @@
1
- import { a as resolveIdBaseUrl } from "./config-DaSeKofC.js";
1
+ import { a as resolveIdBaseUrl } from "./config-D21ZcDET.js";
2
2
  import { o as readClientKeyRing, s as toPublicJwk } from "./keys-B_R_lsyF.js";
3
3
  import { createPrivateKeyJwtClientAssertionGetter } from "@better-auth/core/oauth2";
4
4
  import * as jose from "jose";
@@ -191,4 +191,4 @@ function createMachineClient(config) {
191
191
 
192
192
  //#endregion
193
193
  export { createDpopProof as n, createMachineClient as r, MachineTokenError as t };
194
- //# sourceMappingURL=client-BPcoDnOd.js.map
194
+ //# sourceMappingURL=client-BvLrx0Ai.js.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-BCZhLtY5.js";
1
+ import { t as BaseHttpClient } from "./http-client-CVwg2EAl.js";
2
2
 
3
3
  //#region src/terms/client.ts
4
4
  function unwrap(body) {
@@ -80,4 +80,4 @@ function createReoptTermsClient(config) {
80
80
 
81
81
  //#endregion
82
82
  export { createReoptTermsClient as n, ReoptTermsClient as t };
83
- //# sourceMappingURL=client-B281w6RL.js.map
83
+ //# sourceMappingURL=client-BvUK6AxL.js.map
@@ -1,6 +1,6 @@
1
- import { n as SDK_VERSION } from "./config-DaSeKofC.js";
1
+ import { n as SDK_VERSION } from "./config-D21ZcDET.js";
2
2
  import { o as readClientKeyRing } from "./keys-B_R_lsyF.js";
3
- import { r as createMachineClient } from "./client-BPcoDnOd.js";
3
+ import { r as createMachineClient } from "./client-BvLrx0Ai.js";
4
4
  import { z } from "zod";
5
5
 
6
6
  //#region src/workspace/schemas.ts
@@ -742,4 +742,4 @@ function createPlatformClient(config) {
742
742
 
743
743
  //#endregion
744
744
  export { platformWebhookUpsertInputSchema as $, platformEavSchemaOperationSchema as A, platformPipelineResourceSchema as B, platformBrandappResourceSchema as C, platformEavEntityResourceSchema as D, platformEavBrandappResourcesSchema as E, platformMeSchema as F, platformResourcesSchema as G, platformPipelineStageInputSchema as H, platformOAuthClientImportInputSchema as I, platformTaskStageInputSchema as J, platformResourcesV2Schema as K, platformOAuthClientResourceSchema as L, platformExternalIdSchema as M, platformLockAcquiredSchema as N, platformEavSchemaApplyInputSchema as O, platformLockReleasedSchema as P, platformWebhookSchema as Q, platformOAuthClientUpsertInputSchema as R, platformBrandUpsertInputSchema as S, platformCustomerUpsertInputSchema as T, platformPipelineUpsertInputSchema as U, platformPipelineSchema as V, platformResourceKeySchema as W, platformTaskUpsertInputSchema as X, platformTaskStageSchema as Y, platformWebhookResourceSchema as Z, PLATFORM_TASK_PRIORITIES as _, createPlatformClient as a, platformBrandImportInputSchema as b, PLATFORM_ADMIN_SCOPE as c, PLATFORM_MANAGED_BY_VALUES as d, platformWorkTaskStageChangedEventSchema as et, PLATFORM_OAUTH_APPLICATION_TYPES as f, PLATFORM_TASK_OUTCOMES as g, PLATFORM_STAGE_COLORS as h, REOPT_PLATFORM_URLS as i, platformErrorSchema as j, platformEavSchemaApplyResultSchema as k, PLATFORM_BRANDAPP_STATUSES as l, PLATFORM_OAUTH_GRANT_TYPES as m, PlatformApiError as n, createPlatformRequester as o, PLATFORM_OAUTH_CLIENT_PURPOSES as p, platformTaskSchema as q, REOPT_PLATFORM_ID_URLS as r, resolvePlatformUrls as s, DEFAULT_PLATFORM_SCOPES as t, platformWriteMetaSchema as tt, PLATFORM_DOMAIN_STATUSES as u, PLATFORM_TOKEN_ENDPOINT_AUTH_METHODS as v, platformBrandappUpsertInputSchema as w, platformBrandResourceSchema as x, PLATFORM_WEBHOOK_TRIGGERS as y, platformPipelineImportInputSchema as z };
745
- //# sourceMappingURL=client-C7z5-izC.js.map
745
+ //# sourceMappingURL=client-Bzk7eqy5.js.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-BCZhLtY5.js";
1
+ import { t as BaseHttpClient } from "./http-client-CVwg2EAl.js";
2
2
 
3
3
  //#region src/auth/client.ts
4
4
  function unwrap(body) {
@@ -50,4 +50,4 @@ function createReoptAuthClient(config) {
50
50
 
51
51
  //#endregion
52
52
  export { createReoptAuthClient as n, ReoptAuthClient as t };
53
- //# sourceMappingURL=client-BxrWT0mi.js.map
53
+ //# sourceMappingURL=client-CB1A7gg4.js.map
@@ -1,6 +1,6 @@
1
- import { S as ReoptSDKError, u as BadRequestError } from "./config-DaSeKofC.js";
2
- import { t as BaseHttpClient } from "./http-client-BCZhLtY5.js";
3
- import { t as buildQuery } from "./query-B8Hg9bub.js";
1
+ import { S as ReoptSDKError, u as BadRequestError } from "./config-D21ZcDET.js";
2
+ import { t as BaseHttpClient } from "./http-client-CVwg2EAl.js";
3
+ import { t as buildQuery } from "./query-C_qce1vC.js";
4
4
 
5
5
  //#region src/eav/cache.ts
6
6
  var SchemaCache = class {
@@ -603,4 +603,4 @@ function createReoptEavClient(config) {
603
603
 
604
604
  //#endregion
605
605
  export { RECORDS_PAGE_LIMIT_MAX as i, ATTRIBUTE_FILTER_LIST_MAX as n, ATTRIBUTE_FILTER_OPERATORS as r, createReoptEavClient as t };
606
- //# sourceMappingURL=client-D8d3xsYm.js.map
606
+ //# sourceMappingURL=client-Ccw-FJlt.js.map
@@ -1,6 +1,6 @@
1
- import { S as ReoptSDKError, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig } from "./config-DaSeKofC.js";
1
+ import { S as ReoptSDKError, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig } from "./config-D21ZcDET.js";
2
2
  import { t as createManagedAbort } from "./abort--nOBFN4M.js";
3
- import { n as parseFieldErrors, t as BaseHttpClient } from "./http-client-BCZhLtY5.js";
3
+ import { n as parseFieldErrors, t as BaseHttpClient } from "./http-client-CVwg2EAl.js";
4
4
 
5
5
  //#region src/files/client.ts
6
6
  var ReoptFileClient = class {
@@ -276,4 +276,4 @@ function createReoptFileClient(config) {
276
276
 
277
277
  //#endregion
278
278
  export { createReoptFileClient as n, ReoptFileClient as t };
279
- //# sourceMappingURL=client-ey80gKM_.js.map
279
+ //# sourceMappingURL=client-l7dQ_fLm.js.map
@@ -1,6 +1,6 @@
1
- import { S as ReoptSDKError, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig } from "./config-DaSeKofC.js";
1
+ import { S as ReoptSDKError, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig } from "./config-D21ZcDET.js";
2
2
  import { t as createManagedAbort } from "./abort--nOBFN4M.js";
3
- import { t as BaseHttpClient } from "./http-client-BCZhLtY5.js";
3
+ import { t as BaseHttpClient } from "./http-client-CVwg2EAl.js";
4
4
  import { n as parseSSEStream } from "./sse-parser-D65dmL4A.js";
5
5
 
6
6
  //#region src/ai/client.ts
@@ -262,7 +262,7 @@ var ReoptAiClient = class {
262
262
  }
263
263
  async fetchSSE(options) {
264
264
  const url = `${this.http.requestBaseUrl}/chat/completions`;
265
- const requestId = globalThis.crypto?.randomUUID?.() ?? `sdk-${"4.7.0-rc.10"}-${url.length}`;
265
+ const requestId = globalThis.crypto?.randomUUID?.() ?? `sdk-${"4.7.0-rc.12"}-${url.length}`;
266
266
  const ctx = {
267
267
  method: "POST",
268
268
  url,
@@ -343,4 +343,4 @@ function createReoptAiClient(config) {
343
343
 
344
344
  //#endregion
345
345
  export { createReoptAiClient as n, ReoptAiClient as t };
346
- //# sourceMappingURL=client-D97Ylva1.js.map
346
+ //# sourceMappingURL=client-tFChmi6z.js.map
package/dist/cms/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createReoptCmsClient } from "../client-CmV48bW0.js";
1
+ import { t as createReoptCmsClient } from "../client-BtFoViKj.js";
2
2
 
3
3
  //#region src/cms/helpers.ts
4
4
  function joinUrl(siteUrl, path) {
@@ -370,7 +370,7 @@ function mapHttpStatusToError(status, code, message, ctx, fieldErrors) {
370
370
 
371
371
  //#endregion
372
372
  //#region src/core/config.ts
373
- const SDK_VERSION = "4.7.0-rc.10";
373
+ const SDK_VERSION = "4.7.0-rc.12";
374
374
  /**
375
375
  * Default API host for EAV / AI / Files / CMS / Terms. Consumers can override
376
376
  * via `config.baseUrl` or the `REOPT_BASE_URL` env var.
@@ -552,4 +552,4 @@ function deriveIdFromBaseUrl(baseUrl) {
552
552
 
553
553
  //#endregion
554
554
  export { isValidationError as A, RequiredTermsError as C, isModelAccessError as D, isCreditLimitError as E, isReoptSDKError as O, ReoptSDKError as S, ValidationError as T, ModelAccessError as _, resolveIdBaseUrl as a, PreconditionFailedError as b, AuthUserNotFoundError as c, ConflictError as d, ContentFilterError as f, LimitExceededError as g, ForbiddenError as h, resolveBaseUrl as i, mapHttpStatusToError as j, isRequiredTermsError as k, AuthUserRecordExistsError as l, DuplicateAuthUserError as m, SDK_VERSION as n, validateConfig as o, CreditLimitError as p, assertBrowserSafe as r, AuthError as s, REOPT_BASE_URLS as t, BadRequestError as u, ModelNotFoundError as v, ServerError as w, RateLimitError as x, NotFoundError as y };
555
- //# sourceMappingURL=config-DaSeKofC.js.map
555
+ //# sourceMappingURL=config-D21ZcDET.js.map
package/dist/eav/index.js CHANGED
@@ -1,5 +1,5 @@
1
- import { c as AuthUserNotFoundError, g as LimitExceededError, l as AuthUserRecordExistsError, m as DuplicateAuthUserError } from "../config-DaSeKofC.js";
2
- import { i as RECORDS_PAGE_LIMIT_MAX, n as ATTRIBUTE_FILTER_LIST_MAX, r as ATTRIBUTE_FILTER_OPERATORS, t as createReoptEavClient } from "../client-D8d3xsYm.js";
1
+ import { c as AuthUserNotFoundError, g as LimitExceededError, l as AuthUserRecordExistsError, m as DuplicateAuthUserError } from "../config-D21ZcDET.js";
2
+ import { i as RECORDS_PAGE_LIMIT_MAX, n as ATTRIBUTE_FILTER_LIST_MAX, r as ATTRIBUTE_FILTER_OPERATORS, t as createReoptEavClient } from "../client-Ccw-FJlt.js";
3
3
 
4
4
  //#region src/eav/verify.ts
5
5
  async function verifyEavSchema(input) {
@@ -1,3 +1,3 @@
1
- import { n as createReoptFeedbackClient, t as ReoptFeedbackClient } from "../client-Brv0KsDM.js";
1
+ import { n as createReoptFeedbackClient, t as ReoptFeedbackClient } from "../client-BHoS1dGr.js";
2
2
 
3
3
  export { ReoptFeedbackClient, createReoptFeedbackClient };
@@ -1,4 +1,4 @@
1
- import { n as createReoptFileClient, t as ReoptFileClient } from "../client-ey80gKM_.js";
1
+ import { n as createReoptFileClient, t as ReoptFileClient } from "../client-l7dQ_fLm.js";
2
2
 
3
3
  //#region src/files/helpers.ts
4
4
  const REOPT_IMAGE_REMOTE_PATTERNS = [{
@@ -1,4 +1,4 @@
1
- import { S as ReoptSDKError, a as resolveIdBaseUrl, i as resolveBaseUrl, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, w as ServerError, x as RateLimitError } from "./config-DaSeKofC.js";
1
+ import { S as ReoptSDKError, a as resolveIdBaseUrl, i as resolveBaseUrl, j as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, w as ServerError, x as RateLimitError } from "./config-D21ZcDET.js";
2
2
  import { t as createAuthHeader } from "./encoding-Bwfm3iaE.js";
3
3
 
4
4
  //#region src/core/debug.ts
@@ -412,4 +412,4 @@ function parseFieldErrors(body) {
412
412
 
413
413
  //#endregion
414
414
  export { parseFieldErrors as n, BaseHttpClient as t };
415
- //# sourceMappingURL=http-client-BCZhLtY5.js.map
415
+ //# sourceMappingURL=http-client-CVwg2EAl.js.map
package/dist/index.js CHANGED
@@ -1,15 +1,15 @@
1
- import { A as isValidationError, C as RequiredTermsError, D as isModelAccessError, E as isCreditLimitError, O as isReoptSDKError, S as ReoptSDKError, T as ValidationError, _ as ModelAccessError, b as PreconditionFailedError, c as AuthUserNotFoundError, d as ConflictError, f as ContentFilterError, g as LimitExceededError, h as ForbiddenError, i as resolveBaseUrl, j as mapHttpStatusToError, k as isRequiredTermsError, l as AuthUserRecordExistsError, m as DuplicateAuthUserError, p as CreditLimitError, r as assertBrowserSafe, s as AuthError, t as REOPT_BASE_URLS, u as BadRequestError, v as ModelNotFoundError, w as ServerError, x as RateLimitError, y as NotFoundError } from "./config-DaSeKofC.js";
2
- import { t as BaseHttpClient } from "./http-client-BCZhLtY5.js";
3
- import { n as createReoptAiClient } from "./client-D97Ylva1.js";
4
- import { n as createReoptAuthClient } from "./client-BxrWT0mi.js";
5
- import { t as createReoptCmsClient } from "./client-CmV48bW0.js";
6
- import { t as createReoptEavClient } from "./client-D8d3xsYm.js";
7
- import { n as createReoptFeedbackClient } from "./client-Brv0KsDM.js";
8
- import { n as createReoptFileClient } from "./client-ey80gKM_.js";
9
- import { n as createReoptAnalyticsClient } from "./client-Dv7WwJr-.js";
10
- import { n as createReoptPlansClient } from "./client-CGy4Z0JO.js";
11
- import { n as createReoptPushClient } from "./client-m4e-HwMX.js";
12
- import { n as createReoptTermsClient } from "./client-B281w6RL.js";
1
+ import { A as isValidationError, C as RequiredTermsError, D as isModelAccessError, E as isCreditLimitError, O as isReoptSDKError, S as ReoptSDKError, T as ValidationError, _ as ModelAccessError, b as PreconditionFailedError, c as AuthUserNotFoundError, d as ConflictError, f as ContentFilterError, g as LimitExceededError, h as ForbiddenError, i as resolveBaseUrl, j as mapHttpStatusToError, k as isRequiredTermsError, l as AuthUserRecordExistsError, m as DuplicateAuthUserError, p as CreditLimitError, r as assertBrowserSafe, s as AuthError, t as REOPT_BASE_URLS, u as BadRequestError, v as ModelNotFoundError, w as ServerError, x as RateLimitError, y as NotFoundError } from "./config-D21ZcDET.js";
2
+ import { t as BaseHttpClient } from "./http-client-CVwg2EAl.js";
3
+ import { n as createReoptAiClient } from "./client-tFChmi6z.js";
4
+ import { n as createReoptAuthClient } from "./client-CB1A7gg4.js";
5
+ import { t as createReoptCmsClient } from "./client-BtFoViKj.js";
6
+ import { t as createReoptEavClient } from "./client-Ccw-FJlt.js";
7
+ import { n as createReoptFeedbackClient } from "./client-BHoS1dGr.js";
8
+ import { n as createReoptFileClient } from "./client-l7dQ_fLm.js";
9
+ import { n as createReoptAnalyticsClient } from "./client-BUfDFULW.js";
10
+ import { n as createReoptPlansClient } from "./client-BL7vOv_M.js";
11
+ import { n as createReoptPushClient } from "./client-BHX14FpH.js";
12
+ import { n as createReoptTermsClient } from "./client-BvUK6AxL.js";
13
13
 
14
14
  //#region src/singleton.ts
15
15
  let _instance;
@@ -1,7 +1,7 @@
1
- import { n as SDK_VERSION } from "../config-DaSeKofC.js";
1
+ import { n as SDK_VERSION } from "../config-D21ZcDET.js";
2
2
  import { o as readClientKeyRing } from "../keys-B_R_lsyF.js";
3
- import { r as createMachineClient } from "../client-BPcoDnOd.js";
4
- import { S as platformBrandUpsertInputSchema, U as platformPipelineUpsertInputSchema, W as platformResourceKeySchema, j as platformErrorSchema, n as PlatformApiError, p as PLATFORM_OAUTH_CLIENT_PURPOSES, s as resolvePlatformUrls, w as platformBrandappUpsertInputSchema, y as PLATFORM_WEBHOOK_TRIGGERS } from "../client-C7z5-izC.js";
3
+ import { r as createMachineClient } from "../client-BvLrx0Ai.js";
4
+ import { S as platformBrandUpsertInputSchema, U as platformPipelineUpsertInputSchema, W as platformResourceKeySchema, j as platformErrorSchema, n as PlatformApiError, p as PLATFORM_OAUTH_CLIENT_PURPOSES, s as resolvePlatformUrls, w as platformBrandappUpsertInputSchema, y as PLATFORM_WEBHOOK_TRIGGERS } from "../client-Bzk7eqy5.js";
5
5
  import * as jose from "jose";
6
6
  import { z } from "zod";
7
7
 
@@ -1,4 +1,4 @@
1
- import { S as ReoptSDKError, a as resolveIdBaseUrl } from "../config-DaSeKofC.js";
1
+ import { S as ReoptSDKError, a as resolveIdBaseUrl } from "../config-D21ZcDET.js";
2
2
 
3
3
  //#region src/logout/verify.ts
4
4
  /**
@@ -1,4 +1,4 @@
1
1
  import { a as parseClientPrivateJwk, i as generateClientKeyPair, n as DEFAULT_CLIENT_KEY_ALGORITHM, o as readClientKeyRing, r as buildClientJwks, s as toPublicJwk, t as CLIENT_JWKS_PATH } from "../keys-B_R_lsyF.js";
2
- import { n as createDpopProof, r as createMachineClient, t as MachineTokenError } from "../client-BPcoDnOd.js";
2
+ import { n as createDpopProof, r as createMachineClient, t as MachineTokenError } from "../client-BvLrx0Ai.js";
3
3
 
4
4
  export { CLIENT_JWKS_PATH, DEFAULT_CLIENT_KEY_ALGORITHM, MachineTokenError, buildClientJwks, createDpopProof, createMachineClient, generateClientKeyPair, parseClientPrivateJwk, readClientKeyRing, toPublicJwk };
@@ -1,3 +1,3 @@
1
- import { n as createReoptPlansClient, t as ReoptPlansClient } from "../client-CGy4Z0JO.js";
1
+ import { n as createReoptPlansClient, t as ReoptPlansClient } from "../client-BL7vOv_M.js";
2
2
 
3
3
  export { ReoptPlansClient, createReoptPlansClient };
@@ -1,3 +1,3 @@
1
- import { n as createReoptPushClient, t as ReoptPushClient } from "../client-m4e-HwMX.js";
1
+ import { n as createReoptPushClient, t as ReoptPushClient } from "../client-BHX14FpH.js";
2
2
 
3
3
  export { ReoptPushClient, createReoptPushClient };
@@ -1,4 +1,4 @@
1
- import { S as ReoptSDKError } from "./config-DaSeKofC.js";
1
+ import { S as ReoptSDKError } from "./config-D21ZcDET.js";
2
2
 
3
3
  //#region src/core/query.ts
4
4
  /**
@@ -32,4 +32,4 @@ function buildQuery(params) {
32
32
 
33
33
  //#endregion
34
34
  export { buildQuery as t };
35
- //# sourceMappingURL=query-B8Hg9bub.js.map
35
+ //# sourceMappingURL=query-C_qce1vC.js.map
@@ -1,4 +1,4 @@
1
- import { i as REOPT_PLATFORM_URLS, n as PlatformApiError, o as createPlatformRequester, r as REOPT_PLATFORM_ID_URLS, s as resolvePlatformUrls } from "../client-C7z5-izC.js";
1
+ import { i as REOPT_PLATFORM_URLS, n as PlatformApiError, o as createPlatformRequester, r as REOPT_PLATFORM_ID_URLS, s as resolvePlatformUrls } from "../client-Bzk7eqy5.js";
2
2
  import { z } from "zod";
3
3
 
4
4
  //#region src/social/schemas.ts
@@ -1,3 +1,3 @@
1
- import { n as createReoptTermsClient, t as ReoptTermsClient } from "../client-B281w6RL.js";
1
+ import { n as createReoptTermsClient, t as ReoptTermsClient } from "../client-BvUK6AxL.js";
2
2
 
3
3
  export { ReoptTermsClient, createReoptTermsClient };
@@ -1,3 +1,3 @@
1
- import { $ as platformWebhookUpsertInputSchema, A as platformEavSchemaOperationSchema, B as platformPipelineResourceSchema, C as platformBrandappResourceSchema, D as platformEavEntityResourceSchema, E as platformEavBrandappResourcesSchema, F as platformMeSchema, G as platformResourcesSchema, H as platformPipelineStageInputSchema, I as platformOAuthClientImportInputSchema, J as platformTaskStageInputSchema, K as platformResourcesV2Schema, L as platformOAuthClientResourceSchema, M as platformExternalIdSchema, N as platformLockAcquiredSchema, O as platformEavSchemaApplyInputSchema, P as platformLockReleasedSchema, Q as platformWebhookSchema, R as platformOAuthClientUpsertInputSchema, S as platformBrandUpsertInputSchema, T as platformCustomerUpsertInputSchema, U as platformPipelineUpsertInputSchema, V as platformPipelineSchema, W as platformResourceKeySchema, X as platformTaskUpsertInputSchema, Y as platformTaskStageSchema, Z as platformWebhookResourceSchema, _ as PLATFORM_TASK_PRIORITIES, a as createPlatformClient, b as platformBrandImportInputSchema, c as PLATFORM_ADMIN_SCOPE, d as PLATFORM_MANAGED_BY_VALUES, et as platformWorkTaskStageChangedEventSchema, f as PLATFORM_OAUTH_APPLICATION_TYPES, g as PLATFORM_TASK_OUTCOMES, h as PLATFORM_STAGE_COLORS, i as REOPT_PLATFORM_URLS, j as platformErrorSchema, k as platformEavSchemaApplyResultSchema, l as PLATFORM_BRANDAPP_STATUSES, m as PLATFORM_OAUTH_GRANT_TYPES, n as PlatformApiError, p as PLATFORM_OAUTH_CLIENT_PURPOSES, q as platformTaskSchema, r as REOPT_PLATFORM_ID_URLS, s as resolvePlatformUrls, t as DEFAULT_PLATFORM_SCOPES, tt as platformWriteMetaSchema, u as PLATFORM_DOMAIN_STATUSES, v as PLATFORM_TOKEN_ENDPOINT_AUTH_METHODS, w as platformBrandappUpsertInputSchema, x as platformBrandResourceSchema, y as PLATFORM_WEBHOOK_TRIGGERS, z as platformPipelineImportInputSchema } from "../client-C7z5-izC.js";
1
+ import { $ as platformWebhookUpsertInputSchema, A as platformEavSchemaOperationSchema, B as platformPipelineResourceSchema, C as platformBrandappResourceSchema, D as platformEavEntityResourceSchema, E as platformEavBrandappResourcesSchema, F as platformMeSchema, G as platformResourcesSchema, H as platformPipelineStageInputSchema, I as platformOAuthClientImportInputSchema, J as platformTaskStageInputSchema, K as platformResourcesV2Schema, L as platformOAuthClientResourceSchema, M as platformExternalIdSchema, N as platformLockAcquiredSchema, O as platformEavSchemaApplyInputSchema, P as platformLockReleasedSchema, Q as platformWebhookSchema, R as platformOAuthClientUpsertInputSchema, S as platformBrandUpsertInputSchema, T as platformCustomerUpsertInputSchema, U as platformPipelineUpsertInputSchema, V as platformPipelineSchema, W as platformResourceKeySchema, X as platformTaskUpsertInputSchema, Y as platformTaskStageSchema, Z as platformWebhookResourceSchema, _ as PLATFORM_TASK_PRIORITIES, a as createPlatformClient, b as platformBrandImportInputSchema, c as PLATFORM_ADMIN_SCOPE, d as PLATFORM_MANAGED_BY_VALUES, et as platformWorkTaskStageChangedEventSchema, f as PLATFORM_OAUTH_APPLICATION_TYPES, g as PLATFORM_TASK_OUTCOMES, h as PLATFORM_STAGE_COLORS, i as REOPT_PLATFORM_URLS, j as platformErrorSchema, k as platformEavSchemaApplyResultSchema, l as PLATFORM_BRANDAPP_STATUSES, m as PLATFORM_OAUTH_GRANT_TYPES, n as PlatformApiError, p as PLATFORM_OAUTH_CLIENT_PURPOSES, q as platformTaskSchema, r as REOPT_PLATFORM_ID_URLS, s as resolvePlatformUrls, t as DEFAULT_PLATFORM_SCOPES, tt as platformWriteMetaSchema, u as PLATFORM_DOMAIN_STATUSES, v as PLATFORM_TOKEN_ENDPOINT_AUTH_METHODS, w as platformBrandappUpsertInputSchema, x as platformBrandResourceSchema, y as PLATFORM_WEBHOOK_TRIGGERS, z as platformPipelineImportInputSchema } from "../client-Bzk7eqy5.js";
2
2
 
3
3
  export { DEFAULT_PLATFORM_SCOPES, PLATFORM_ADMIN_SCOPE, PLATFORM_BRANDAPP_STATUSES, PLATFORM_DOMAIN_STATUSES, PLATFORM_MANAGED_BY_VALUES, PLATFORM_OAUTH_APPLICATION_TYPES, PLATFORM_OAUTH_CLIENT_PURPOSES, PLATFORM_OAUTH_GRANT_TYPES, PLATFORM_STAGE_COLORS, PLATFORM_TASK_OUTCOMES, PLATFORM_TASK_PRIORITIES, PLATFORM_TOKEN_ENDPOINT_AUTH_METHODS, PLATFORM_WEBHOOK_TRIGGERS, PlatformApiError, REOPT_PLATFORM_ID_URLS, REOPT_PLATFORM_URLS, createPlatformClient, platformBrandImportInputSchema, platformBrandResourceSchema, platformBrandUpsertInputSchema, platformBrandappResourceSchema, platformBrandappUpsertInputSchema, platformCustomerUpsertInputSchema, platformEavBrandappResourcesSchema, platformEavEntityResourceSchema, platformEavSchemaApplyInputSchema, platformEavSchemaApplyResultSchema, platformEavSchemaOperationSchema, platformErrorSchema, platformExternalIdSchema, platformLockAcquiredSchema, platformLockReleasedSchema, platformMeSchema, platformOAuthClientImportInputSchema, platformOAuthClientResourceSchema, platformOAuthClientUpsertInputSchema, platformPipelineImportInputSchema, platformPipelineResourceSchema, platformPipelineSchema, platformPipelineStageInputSchema, platformPipelineUpsertInputSchema, platformResourceKeySchema, platformResourcesSchema, platformResourcesV2Schema, platformTaskSchema, platformTaskStageInputSchema, platformTaskStageSchema, platformTaskUpsertInputSchema, platformWebhookResourceSchema, platformWebhookSchema, platformWebhookUpsertInputSchema, platformWorkTaskStageChangedEventSchema, platformWriteMetaSchema, resolvePlatformUrls };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reopt-ai/brandapp-sdk",
3
- "version": "4.7.0-rc.10",
3
+ "version": "4.7.0-rc.12",
4
4
  "description": "Reopt Brandapp SDK — Better Auth adapter, OAuth login, and EAV client",
5
5
  "author": "Reopt",
6
6
  "license": "MIT",