@reopt-ai/brandapp-sdk 3.6.0 → 4.0.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 (32) hide show
  1. package/CHANGELOG.md +51 -0
  2. package/README.md +12 -13
  3. package/dist/ai/index.js +1 -1
  4. package/dist/ai-provider/index.js +1 -1
  5. package/dist/auth/index.js +1 -1
  6. package/dist/better-auth/client.d.ts +56 -12
  7. package/dist/better-auth/client.js +27 -11
  8. package/dist/better-auth/index.d.ts +29 -1
  9. package/dist/better-auth/index.js +22 -3
  10. package/dist/{client-B84P9y2F.js → client-2qKKpHVy.js} +2 -2
  11. package/dist/{client-CiCPE2MW.js → client-B0uRUF3T.js} +3 -3
  12. package/dist/{client-m29R8F0R.js → client-C6USfykM.js} +3 -3
  13. package/dist/{client-DVydvzc2.js → client-CAjqKz8i.js} +3 -3
  14. package/dist/{client-BFM7OGqI.js → client-D72MLGRY.js} +4 -4
  15. package/dist/{client-D4Z2xj4t.js → client-D9MGqXbn.js} +2 -2
  16. package/dist/{client-CxyXO_0C.js → client-DTWpLo8X.js} +2 -2
  17. package/dist/{client-C_YUxs_X.js → client-DUvf9x_b.js} +2 -2
  18. package/dist/{client-WP3Xsxri.js → client-Djlg4STl.js} +2 -2
  19. package/dist/cms/index.js +1 -1
  20. package/dist/{config-BV8Fn7Uo.js → config-D31PK7eu.js} +2 -2
  21. package/dist/eav/index.js +2 -2
  22. package/dist/feedback/index.js +1 -1
  23. package/dist/files/index.js +1 -1
  24. package/dist/{http-client-6XUgrg3k.js → http-client-D1vuc20o.js} +2 -2
  25. package/dist/index.js +11 -11
  26. package/dist/logout/index.js +1 -1
  27. package/dist/plans/index.js +1 -1
  28. package/dist/push/index.js +1 -1
  29. package/dist/{query-C98fDfVW.js → query-DyiwJX92.js} +2 -2
  30. package/dist/terms/index.js +1 -1
  31. package/dist/{types-B-SMkH6s.d.ts → types-MXLudLBP.d.ts} +6 -2
  32. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -7,6 +7,57 @@ This project adheres to [Semantic Versioning](https://semver.org/).
7
7
 
8
8
  ## [Unreleased]
9
9
 
10
+ ## [4.0.0] — 2026-08-21
11
+
12
+ Better Auth **1.7** 이행. 1.7이 generic OAuth를 소셜 제공자 경로로 재작성하고
13
+ 커스텀 어댑터에 원자 연산 두 개를 필수화하면서 공개 표면이 바뀌어 major다.
14
+ `better-auth` peer는 `^1.7.1`이며 1.6 이하와 함께 쓸 수 없다.
15
+
16
+ ### Breaking — `./better-auth/client`
17
+
18
+ - **`createReoptOAuthClient()` 제거.** 1.7에 `genericOAuthClient`가 없다 — 클라이언트
19
+ 플러그인 없이 표준 `signIn.social({ provider: "reopt" })`를 쓴다. 헬퍼
20
+ **`signInWithReopt(authClient, { callbackURL })`** / **`linkReoptAccount(authClient)`**가
21
+ provider id를 고정해 준다.
22
+ - **`authClient.signIn.oauth2({ providerId })` → `signIn.social({ provider })`**,
23
+ `oauth2.link()` → `linkSocial()` (better-auth 변경).
24
+
25
+ ### Breaking — 콜백 경로
26
+
27
+ - Reopt 로그인 콜백이 **`${baseURL}/api/auth/callback/reopt`**로 옮겨졌다
28
+ (1.6: `/api/auth/oauth2/callback/reopt`). Reopt 시스템 브랜드앱 클라이언트는 두 경로가
29
+ 모두 등록돼 있어 바로 동작한다. 직접 등록한 redirect URI가 있으면 **업그레이드 전에**
30
+ 새 경로를 추가할 것(exact-match).
31
+
32
+ ### Breaking — 토큰 엔드포인트 인증 방식
33
+
34
+ - 1.7 Reopt 인가 서버는 클라이언트가 **등록된** `token_endpoint_auth_method`와 다른
35
+ 방식으로 보낸 자격을 거절한다. SDK는 Reopt 브랜드앱 클라이언트의 기본값인
36
+ `client_secret_post`를 명시해 보내며, 다르게 등록된 클라이언트는
37
+ `createReoptOAuth({ tokenEndpointAuthMethod: "client_secret_basic" })`로 맞춘다.
38
+
39
+ ### Added — 원격 어댑터
40
+
41
+ - `createReoptAdapter()`가 1.7 필수 원자 연산 **`consumeOne`**(단일 행 읽고 지우기 —
42
+ 1회용 토큰)과 **`incrementOne`**(guard 달린 카운터 증가)을 Reopt API에 위임한다.
43
+ Reopt API가 같은 날 배포한 어댑터 엔드포인트를 요구하므로, 서버 응답에
44
+ `Unsupported operation`이 보이면 Reopt 쪽 배포가 아직인 것이다.
45
+ - 소비자 앱의 1.7이 계정을 `(issuer, accountId)`로 찾는다. 1.6 시절 만들어진 계정 행은
46
+ Reopt API가 **첫 조회에서 issuer를 기록**해 주므로 기존 사용자의 로그인이 끊기지
47
+ 않는다(소비자 쪽 백필 불필요).
48
+
49
+ ### Changed
50
+
51
+ - **`signOut()`은 계속 앱 세션만 끝낸다.** better-auth 1.7은 generic OAuth `signOut()`을
52
+ OP의 `end_session_endpoint`로 자동 리다이렉트하는데(RP-Initiated Logout), Reopt
53
+ 클라이언트 대부분은 로그아웃 개시 권한이 없어 "The client is not allowed to initiate
54
+ logout"으로 끝난다. SDK는 `disableProviderLogout`을 기본으로 켜고, Reopt 세션까지
55
+ 끝내려면 `createReoptOAuth({ providerLogout: true | { postLogoutRedirectURI } })`로
56
+ 옵트인한다(클라이언트에 `enableEndSession`·post-logout URI 등록 필요).
57
+ - `pkce`는 better-auth 기본값(켜짐)을 따르고, discovery가 돌려주는 `issuer`가 계정
58
+ 네임스페이스(`account.issuer`)가 된다 — `idBaseUrl`을 배포 간에 바꾸면 같은 사용자가
59
+ 새 계정으로 보이므로 고정할 것.
60
+
10
61
  ## [3.6.0] — 2026-08-08
11
62
 
12
63
  EAV 목록에서 필요한 값만 받을 수 있는 응답 projection을 추가했다. 기존 호출은
package/README.md CHANGED
@@ -38,23 +38,22 @@ export const auth = betterAuth({
38
38
  ```
39
39
 
40
40
  ```typescript
41
- // auth-client.ts
41
+ // auth-client.ts — better-auth ≥1.7: no client plugin needed
42
42
  import { createAuthClient } from "better-auth/client";
43
- import {
44
- createReoptOAuthClient,
45
- REOPT_PROVIDER_ID,
46
- } from "@reopt-ai/brandapp-sdk/better-auth/client";
43
+ import { signInWithReopt } from "@reopt-ai/brandapp-sdk/better-auth/client";
47
44
 
48
- export const authClient = createAuthClient({
49
- plugins: [createReoptOAuthClient()],
50
- });
45
+ export const authClient = createAuthClient();
51
46
 
52
- authClient.signIn.oauth2({
53
- providerId: REOPT_PROVIDER_ID,
54
- callbackURL: "/dashboard",
55
- });
47
+ // = authClient.signIn.social({ provider: "reopt", callbackURL: "/dashboard" })
48
+ signInWithReopt(authClient, { callbackURL: "/dashboard" });
56
49
  ```
57
50
 
51
+ > **Callback URL.** Better Auth 1.7 serves the Reopt callback at
52
+ > `${baseURL}/api/auth/callback/reopt` (1.6 used
53
+ > `/api/auth/oauth2/callback/reopt`). Reopt's own system clients have both
54
+ > registered; if you registered a custom redirect URI, add the new path in the
55
+ > studio before upgrading.
56
+
58
57
  ### Unified SDK
59
58
 
60
59
  ```typescript
@@ -286,7 +285,7 @@ const meta = asJson<Meta>(record.values.meta); // Meta | undefined
286
285
  | ---------------------------- | -------------------------------------------------------------------------------------- | ---------------------- |
287
286
  | `"."` | `createReoptSDK`, `createLazySDK`, `initReoptSDK`, `getReoptSDK`, errors | No |
288
287
  | `"./better-auth"` | `createReoptBetterAuth`, `createReoptAdapter`, `createReoptOAuth` | Yes |
289
- | `"./better-auth/client"` | `createReoptOAuthClient`, `REOPT_PROVIDER_ID` | Yes |
288
+ | `"./better-auth/client"` | `signInWithReopt`, `linkReoptAccount`, `REOPT_PROVIDER_ID` | Yes |
290
289
  | `"./eav"` | `createReoptEavClient`, `collectAll`, EAV types, `TypedEavRecord`, `EntityClient` | No |
291
290
  | `"./eav/schema"` | `defineEntity`, `defineSchema`, `syncSchema`, `computeDiff`, schema/sync types | No |
292
291
  | `"./eav/coerce"` | `asString`, `asNumber`, `asBoolean`, `asDate`, `asJson`, `asStringArray` | No |
package/dist/ai/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { n as createReoptAiClient, t as ReoptAiClient } from "../client-BFM7OGqI.js";
1
+ import { n as createReoptAiClient, t as ReoptAiClient } from "../client-D72MLGRY.js";
2
2
 
3
3
  export { ReoptAiClient, createReoptAiClient };
@@ -1,4 +1,4 @@
1
- import { A as mapHttpStatusToError, i as resolveBaseUrl, n as SDK_VERSION, o as validateConfig, r as assertBrowserSafe } from "../config-BV8Fn7Uo.js";
1
+ import { A as mapHttpStatusToError, i as resolveBaseUrl, n as SDK_VERSION, o as validateConfig, r as assertBrowserSafe } from "../config-D31PK7eu.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-FMjxM7sY.js";
@@ -1,4 +1,4 @@
1
- import { n as createReoptAuthClient, t as ReoptAuthClient } from "../client-D4Z2xj4t.js";
1
+ import { n as createReoptAuthClient, t as ReoptAuthClient } from "../client-D9MGqXbn.js";
2
2
 
3
3
  //#region src/auth/session.ts
4
4
  /**
@@ -1,16 +1,58 @@
1
- import { i as REOPT_PROVIDER_ID } from "../types-B-SMkH6s.js";
2
- import { genericOAuthClient } from "better-auth/client/plugins";
1
+ import { i as REOPT_PROVIDER_ID } from "../types-MXLudLBP.js";
3
2
  //#region src/better-auth/client.d.ts
4
- type GenericOAuthClientPlugin = ReturnType<typeof genericOAuthClient>;
5
3
  /**
6
- * Reopt OAuth Client Plugin
4
+ * Minimal shape of a Better Auth client that can start a social sign-in /
5
+ * account link. Structural on purpose: the SDK must not pin the consumer's
6
+ * `createAuthClient` plugin inference (which leaks zod internals into the
7
+ * DTS bundle) — any Better Auth ≥1.7 client satisfies this.
8
+ */
9
+ type ReoptSocialAuthClient = {
10
+ signIn: {
11
+ social: (input: {
12
+ provider: string;
13
+ callbackURL?: string;
14
+ errorCallbackURL?: string;
15
+ newUserCallbackURL?: string;
16
+ disableRedirect?: boolean;
17
+ requestSignUp?: boolean;
18
+ loginHint?: string;
19
+ additionalData?: Record<string, unknown>;
20
+ }) => Promise<unknown>;
21
+ };
22
+ linkSocial?: (input: {
23
+ provider: string;
24
+ callbackURL?: string;
25
+ errorCallbackURL?: string;
26
+ disableRedirect?: boolean;
27
+ }) => Promise<unknown>;
28
+ };
29
+ type ReoptSignInOptions = {
30
+ /** Where the browser lands after a successful sign-in (relative or absolute). */
31
+ callbackURL?: string;
32
+ /** Where the browser lands when the provider returns an error. */
33
+ errorCallbackURL?: string;
34
+ /** Where first-time users land after sign-up. */
35
+ newUserCallbackURL?: string;
36
+ /** Resolve with the redirect URL instead of navigating (e.g. for a popup). */
37
+ disableRedirect?: boolean;
38
+ /** Opaque client data round-tripped through the flow (read back server-side, treat as untrusted). */
39
+ additionalData?: Record<string, unknown>;
40
+ };
41
+ /**
42
+ * Start Reopt sign-in through a Better Auth client.
43
+ *
44
+ * Better Auth 1.7 rebuilt generic OAuth on the social-provider path, so there
45
+ * is no client plugin to install any more: `genericOAuthClient()` and
46
+ * `signIn.oauth2()` are gone, and Reopt is reached through the standard
47
+ * `signIn.social({ provider: "reopt" })`. This helper only fixes the provider
48
+ * id so call sites don't repeat the string.
7
49
  *
8
50
  * @example
9
51
  * ```ts
10
- * import { createReoptOAuthClient, REOPT_PROVIDER_ID } from "@reopt-ai/brandapp-sdk/better-auth/client";
52
+ * import { createAuthClient } from "better-auth/react";
53
+ * import { signInWithReopt } from "@reopt-ai/brandapp-sdk/better-auth/client";
11
54
  *
12
55
  * const authClient = createAuthClient({
13
- * plugins: [createReoptOAuthClient()],
14
56
  * // ⚡ 탭 포커스마다 /api/auth/get-session을 재요청하는 better-auth 기본
15
57
  * // 동작(refetchOnWindowFocus: true)을 끈다. 세션은 cross-subdomain 쿠키로
16
58
  * // 공유되고 로그인/로그아웃은 명시적 전환·브로드캐스트로 동기화되므로
@@ -18,13 +60,15 @@ type GenericOAuthClientPlugin = ReturnType<typeof genericOAuthClient>;
18
60
  * sessionOptions: { refetchOnWindowFocus: false },
19
61
  * });
20
62
  *
21
- * authClient.signIn.oauth2({
22
- * providerId: REOPT_PROVIDER_ID,
23
- * callbackURL: "/dashboard",
24
- * });
63
+ * await signInWithReopt(authClient, { callbackURL: "/dashboard" });
25
64
  * ```
26
65
  */
27
- declare function createReoptOAuthClient(): GenericOAuthClientPlugin;
66
+ declare function signInWithReopt(authClient: ReoptSocialAuthClient, options?: ReoptSignInOptions): Promise<unknown>;
67
+ /**
68
+ * Link the current Better Auth user to their Reopt account
69
+ * (`linkSocial({ provider: "reopt" })`).
70
+ */
71
+ declare function linkReoptAccount(authClient: ReoptSocialAuthClient, options?: Pick<ReoptSignInOptions, "callbackURL" | "errorCallbackURL" | "disableRedirect">): Promise<unknown>;
28
72
  //#endregion
29
- export { REOPT_PROVIDER_ID, createReoptOAuthClient };
73
+ export { REOPT_PROVIDER_ID, ReoptSignInOptions, ReoptSocialAuthClient, linkReoptAccount, signInWithReopt };
30
74
  //# sourceMappingURL=client.d.ts.map
@@ -1,16 +1,21 @@
1
1
  import { n as REOPT_PROVIDER_ID } from "../types-DjDRszNj.js";
2
- import { genericOAuthClient } from "better-auth/client/plugins";
3
2
 
4
3
  //#region src/better-auth/client.ts
5
4
  /**
6
- * Reopt OAuth Client Plugin
5
+ * Start Reopt sign-in through a Better Auth client.
6
+ *
7
+ * Better Auth 1.7 rebuilt generic OAuth on the social-provider path, so there
8
+ * is no client plugin to install any more: `genericOAuthClient()` and
9
+ * `signIn.oauth2()` are gone, and Reopt is reached through the standard
10
+ * `signIn.social({ provider: "reopt" })`. This helper only fixes the provider
11
+ * id so call sites don't repeat the string.
7
12
  *
8
13
  * @example
9
14
  * ```ts
10
- * import { createReoptOAuthClient, REOPT_PROVIDER_ID } from "@reopt-ai/brandapp-sdk/better-auth/client";
15
+ * import { createAuthClient } from "better-auth/react";
16
+ * import { signInWithReopt } from "@reopt-ai/brandapp-sdk/better-auth/client";
11
17
  *
12
18
  * const authClient = createAuthClient({
13
- * plugins: [createReoptOAuthClient()],
14
19
  * // ⚡ 탭 포커스마다 /api/auth/get-session을 재요청하는 better-auth 기본
15
20
  * // 동작(refetchOnWindowFocus: true)을 끈다. 세션은 cross-subdomain 쿠키로
16
21
  * // 공유되고 로그인/로그아웃은 명시적 전환·브로드캐스트로 동기화되므로
@@ -18,16 +23,27 @@ import { genericOAuthClient } from "better-auth/client/plugins";
18
23
  * sessionOptions: { refetchOnWindowFocus: false },
19
24
  * });
20
25
  *
21
- * authClient.signIn.oauth2({
22
- * providerId: REOPT_PROVIDER_ID,
23
- * callbackURL: "/dashboard",
24
- * });
26
+ * await signInWithReopt(authClient, { callbackURL: "/dashboard" });
25
27
  * ```
26
28
  */
27
- function createReoptOAuthClient() {
28
- return genericOAuthClient();
29
+ function signInWithReopt(authClient, options = {}) {
30
+ return authClient.signIn.social({
31
+ provider: "reopt",
32
+ ...options
33
+ });
34
+ }
35
+ /**
36
+ * Link the current Better Auth user to their Reopt account
37
+ * (`linkSocial({ provider: "reopt" })`).
38
+ */
39
+ function linkReoptAccount(authClient, options = {}) {
40
+ if (!authClient.linkSocial) throw new Error("[@reopt-ai/brandapp-sdk] linkReoptAccount() needs a Better Auth client with linkSocial().");
41
+ return authClient.linkSocial({
42
+ provider: "reopt",
43
+ ...options
44
+ });
29
45
  }
30
46
 
31
47
  //#endregion
32
- export { REOPT_PROVIDER_ID, createReoptOAuthClient };
48
+ export { REOPT_PROVIDER_ID, linkReoptAccount, signInWithReopt };
33
49
  //# sourceMappingURL=client.js.map
@@ -1,5 +1,5 @@
1
1
  import { n as ReoptSDKConfig, t as REOPT_BASE_URLS } from "../config-C7WQtC3l.js";
2
- import { i as REOPT_PROVIDER_ID, n as AdapterRequestBody, r as REOPT_DEFAULT_SCOPES, t as AdapterOperation } from "../types-B-SMkH6s.js";
2
+ import { i as REOPT_PROVIDER_ID, n as AdapterRequestBody, r as REOPT_DEFAULT_SCOPES, t as AdapterOperation } from "../types-MXLudLBP.js";
3
3
  import { _ as ReoptSDKError, b as ServerError, g as RateLimitError, t as AuthError, w as isReoptSDKError } from "../errors-CRCcErNC.js";
4
4
  import { AdapterFactory } from "better-auth/adapters";
5
5
  import { BetterAuthOptions, BetterAuthPlugin } from "better-auth";
@@ -25,6 +25,34 @@ declare function createReoptAdapter(config: ReoptSDKConfig): AdapterFactory<Bett
25
25
  type ReoptOAuthOptions = ReoptSDKConfig & {
26
26
  /** Additional OAuth scopes */
27
27
  additionalScopes?: string[];
28
+ /**
29
+ * How this client authenticates at Reopt's token endpoint. Must equal the
30
+ * `token_endpoint_auth_method` the client was **registered** with — Better
31
+ * Auth 1.7's OAuth provider rejects credentials sent through any other
32
+ * method (`invalid_client`). Reopt brandapp clients are registered with
33
+ * `client_secret_post` unless noted otherwise in the studio.
34
+ *
35
+ * @default "client_secret_post"
36
+ */
37
+ tokenEndpointAuthMethod?: "client_secret_post" | "client_secret_basic";
38
+ /**
39
+ * Also end the user's Reopt (identity provider) session when your app calls
40
+ * `authClient.signOut()` — OIDC RP-Initiated Logout through Reopt's
41
+ * `end_session_endpoint`.
42
+ *
43
+ * Off by default: sign-out only clears your app's own session, which is
44
+ * what Better Auth ≤1.6 did. Turning it on requires the Reopt OAuth client
45
+ * to be allowed to initiate logout (`enableEndSession`) and, if you pass
46
+ * `postLogoutRedirectURI`, that URL to be registered as a post-logout
47
+ * redirect URI — otherwise Reopt answers "The client is not allowed to
48
+ * initiate logout".
49
+ *
50
+ * @default false
51
+ */
52
+ providerLogout?: boolean | {
53
+ /** Where Reopt sends the browser after ending its session (must be registered). */
54
+ postLogoutRedirectURI?: string;
55
+ };
28
56
  };
29
57
  /**
30
58
  * Reopt OAuth Login Plugin
@@ -1,5 +1,5 @@
1
- import { C as ServerError, D as isReoptSDKError, a as resolveIdBaseUrl, b as RateLimitError, s as AuthError, t as REOPT_BASE_URLS, x as ReoptSDKError } from "../config-BV8Fn7Uo.js";
2
- import { t as BaseHttpClient } from "../http-client-6XUgrg3k.js";
1
+ import { C as ServerError, D as isReoptSDKError, a as resolveIdBaseUrl, b as RateLimitError, s as AuthError, t as REOPT_BASE_URLS, x as ReoptSDKError } from "../config-D31PK7eu.js";
2
+ import { t as BaseHttpClient } from "../http-client-D1vuc20o.js";
3
3
  import { n as REOPT_PROVIDER_ID, t as REOPT_DEFAULT_SCOPES } from "../types-DjDRszNj.js";
4
4
  import { createAdapterFactory } from "better-auth/adapters";
5
5
  import { genericOAuth } from "better-auth/plugins";
@@ -116,6 +116,22 @@ function createReoptAdapter(config) {
116
116
  model,
117
117
  where
118
118
  });
119
+ },
120
+ async consumeOne({ model, where }) {
121
+ return request({
122
+ operation: "consumeOne",
123
+ model,
124
+ where
125
+ });
126
+ },
127
+ async incrementOne({ model, where, increment, set }) {
128
+ return request({
129
+ operation: "incrementOne",
130
+ model,
131
+ where,
132
+ increment,
133
+ set
134
+ });
119
135
  }
120
136
  };
121
137
  }
@@ -142,13 +158,16 @@ function createReoptAdapter(config) {
142
158
  * ```
143
159
  */
144
160
  function createReoptOAuth(options) {
145
- if (typeof window !== "undefined") throw new Error("[@reopt-ai/brandapp-sdk] createReoptOAuth() must be called on the server. It uses clientSecret — exposing it to the browser is a security risk. For client-side OAuth sign-in, use createReoptOAuthClient() from '@reopt-ai/brandapp-sdk/better-auth/client' instead.");
161
+ if (typeof window !== "undefined") throw new Error("[@reopt-ai/brandapp-sdk] createReoptOAuth() must be called on the server. It uses clientSecret — exposing it to the browser is a security risk. For client-side OAuth sign-in, use signInWithReopt() from '@reopt-ai/brandapp-sdk/better-auth/client' instead.");
146
162
  if (!options.clientId || !options.clientSecret) throw new Error("[@reopt-ai/brandapp-sdk] createReoptOAuth() requires clientId and clientSecret.");
147
163
  return genericOAuth({ config: [{
148
164
  providerId: REOPT_PROVIDER_ID,
149
165
  discoveryUrl: `${resolveIdBaseUrl(options)}/api/auth/.well-known/openid-configuration`,
150
166
  clientId: options.clientId,
151
167
  clientSecret: options.clientSecret,
168
+ tokenEndpointAuth: { method: options.tokenEndpointAuthMethod ?? "client_secret_post" },
169
+ disableProviderLogout: !options.providerLogout,
170
+ ...typeof options.providerLogout === "object" && options.providerLogout.postLogoutRedirectURI ? { postLogoutRedirectURI: options.providerLogout.postLogoutRedirectURI } : {},
152
171
  scopes: Array.from(/* @__PURE__ */ new Set([...REOPT_DEFAULT_SCOPES, ...options.additionalScopes ?? []])),
153
172
  pkce: true
154
173
  }] });
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-6XUgrg3k.js";
1
+ import { t as BaseHttpClient } from "./http-client-D1vuc20o.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-B84P9y2F.js.map
28
+ //# sourceMappingURL=client-2qKKpHVy.js.map
@@ -1,5 +1,5 @@
1
- import { t as BaseHttpClient } from "./http-client-6XUgrg3k.js";
2
- import { t as buildQuery } from "./query-C98fDfVW.js";
1
+ import { t as BaseHttpClient } from "./http-client-D1vuc20o.js";
2
+ import { t as buildQuery } from "./query-DyiwJX92.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-CiCPE2MW.js.map
55
+ //# sourceMappingURL=client-B0uRUF3T.js.map
@@ -1,6 +1,6 @@
1
- import { A as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, x as ReoptSDKError } from "./config-BV8Fn7Uo.js";
1
+ import { A as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, x as ReoptSDKError } from "./config-D31PK7eu.js";
2
2
  import { t as createManagedAbort } from "./abort--nOBFN4M.js";
3
- import { n as parseFieldErrors, t as BaseHttpClient } from "./http-client-6XUgrg3k.js";
3
+ import { n as parseFieldErrors, t as BaseHttpClient } from "./http-client-D1vuc20o.js";
4
4
 
5
5
  //#region src/files/client.ts
6
6
  var ReoptFileClient = class {
@@ -270,4 +270,4 @@ function createReoptFileClient(config) {
270
270
 
271
271
  //#endregion
272
272
  export { createReoptFileClient as n, ReoptFileClient as t };
273
- //# sourceMappingURL=client-m29R8F0R.js.map
273
+ //# sourceMappingURL=client-C6USfykM.js.map
@@ -1,5 +1,5 @@
1
- import { t as BaseHttpClient } from "./http-client-6XUgrg3k.js";
2
- import { t as buildQuery } from "./query-C98fDfVW.js";
1
+ import { t as BaseHttpClient } from "./http-client-D1vuc20o.js";
2
+ import { t as buildQuery } from "./query-DyiwJX92.js";
3
3
 
4
4
  //#region src/eav/cache.ts
5
5
  var SchemaCache = class {
@@ -500,4 +500,4 @@ function createReoptEavClient(config) {
500
500
 
501
501
  //#endregion
502
502
  export { createReoptEavClient as t };
503
- //# sourceMappingURL=client-DVydvzc2.js.map
503
+ //# sourceMappingURL=client-CAjqKz8i.js.map
@@ -1,6 +1,6 @@
1
- import { A as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, x as ReoptSDKError } from "./config-BV8Fn7Uo.js";
1
+ import { A as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, x as ReoptSDKError } from "./config-D31PK7eu.js";
2
2
  import { t as createManagedAbort } from "./abort--nOBFN4M.js";
3
- import { t as BaseHttpClient } from "./http-client-6XUgrg3k.js";
3
+ import { t as BaseHttpClient } from "./http-client-D1vuc20o.js";
4
4
  import { n as parseSSEStream } from "./sse-parser-FMjxM7sY.js";
5
5
 
6
6
  //#region src/ai/client.ts
@@ -224,7 +224,7 @@ var ReoptAiClient = class {
224
224
  }
225
225
  async fetchSSE(options) {
226
226
  const url = `${this.http.requestBaseUrl}/chat/completions`;
227
- const requestId = globalThis.crypto?.randomUUID?.() ?? `sdk-${"3.6.0"}-${url.length}`;
227
+ const requestId = globalThis.crypto?.randomUUID?.() ?? `sdk-${"4.0.0"}-${url.length}`;
228
228
  const ctx = {
229
229
  method: "POST",
230
230
  url,
@@ -302,4 +302,4 @@ function createReoptAiClient(config) {
302
302
 
303
303
  //#endregion
304
304
  export { createReoptAiClient as n, ReoptAiClient as t };
305
- //# sourceMappingURL=client-BFM7OGqI.js.map
305
+ //# sourceMappingURL=client-D72MLGRY.js.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-6XUgrg3k.js";
1
+ import { t as BaseHttpClient } from "./http-client-D1vuc20o.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-D4Z2xj4t.js.map
53
+ //# sourceMappingURL=client-D9MGqXbn.js.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-6XUgrg3k.js";
1
+ import { t as BaseHttpClient } from "./http-client-D1vuc20o.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-CxyXO_0C.js.map
86
+ //# sourceMappingURL=client-DTWpLo8X.js.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-6XUgrg3k.js";
1
+ import { t as BaseHttpClient } from "./http-client-D1vuc20o.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-C_YUxs_X.js.map
83
+ //# sourceMappingURL=client-DUvf9x_b.js.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-6XUgrg3k.js";
1
+ import { t as BaseHttpClient } from "./http-client-D1vuc20o.js";
2
2
 
3
3
  //#region src/plans/client.ts
4
4
  function unwrap(body) {
@@ -78,4 +78,4 @@ function createReoptPlansClient(config) {
78
78
 
79
79
  //#endregion
80
80
  export { createReoptPlansClient as n, ReoptPlansClient as t };
81
- //# sourceMappingURL=client-WP3Xsxri.js.map
81
+ //# sourceMappingURL=client-Djlg4STl.js.map
package/dist/cms/index.js CHANGED
@@ -1,4 +1,4 @@
1
- import { t as createReoptCmsClient } from "../client-CiCPE2MW.js";
1
+ import { t as createReoptCmsClient } from "../client-B0uRUF3T.js";
2
2
 
3
3
  //#region src/cms/helpers.ts
4
4
  function joinUrl(siteUrl, path) {
@@ -305,7 +305,7 @@ function mapHttpStatusToError(status, code, message, ctx, fieldErrors) {
305
305
 
306
306
  //#endregion
307
307
  //#region src/core/config.ts
308
- const SDK_VERSION = "3.6.0";
308
+ const SDK_VERSION = "4.0.0";
309
309
  /**
310
310
  * Default API host for EAV / AI / Files / CMS / Terms. Consumers can override
311
311
  * via `config.baseUrl` or the `REOPT_BASE_URL` env var.
@@ -484,4 +484,4 @@ function deriveIdFromBaseUrl(baseUrl) {
484
484
 
485
485
  //#endregion
486
486
  export { mapHttpStatusToError as A, ServerError as C, isReoptSDKError as D, isModelAccessError as E, isRequiredTermsError as O, RequiredTermsError as S, isCreditLimitError as T, ModelAccessError as _, resolveIdBaseUrl as a, RateLimitError as b, AuthUserNotFoundError as c, ConflictError as d, ContentFilterError as f, LimitExceededError as g, ForbiddenError as h, resolveBaseUrl as i, isValidationError 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, ValidationError as w, ReoptSDKError as x, NotFoundError as y };
487
- //# sourceMappingURL=config-BV8Fn7Uo.js.map
487
+ //# sourceMappingURL=config-D31PK7eu.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-BV8Fn7Uo.js";
2
- import { t as createReoptEavClient } from "../client-DVydvzc2.js";
1
+ import { c as AuthUserNotFoundError, g as LimitExceededError, l as AuthUserRecordExistsError, m as DuplicateAuthUserError } from "../config-D31PK7eu.js";
2
+ import { t as createReoptEavClient } from "../client-CAjqKz8i.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-CxyXO_0C.js";
1
+ import { n as createReoptFeedbackClient, t as ReoptFeedbackClient } from "../client-DTWpLo8X.js";
2
2
 
3
3
  export { ReoptFeedbackClient, createReoptFeedbackClient };
@@ -1,4 +1,4 @@
1
- import { n as createReoptFileClient, t as ReoptFileClient } from "../client-m29R8F0R.js";
1
+ import { n as createReoptFileClient, t as ReoptFileClient } from "../client-C6USfykM.js";
2
2
 
3
3
  //#region src/files/helpers.ts
4
4
  const REOPT_IMAGE_REMOTE_PATTERNS = [{
@@ -1,4 +1,4 @@
1
- import { A as mapHttpStatusToError, C as ServerError, a as resolveIdBaseUrl, b as RateLimitError, i as resolveBaseUrl, n as SDK_VERSION, o as validateConfig, x as ReoptSDKError } from "./config-BV8Fn7Uo.js";
1
+ import { A as mapHttpStatusToError, C as ServerError, a as resolveIdBaseUrl, b as RateLimitError, i as resolveBaseUrl, n as SDK_VERSION, o as validateConfig, x as ReoptSDKError } from "./config-D31PK7eu.js";
2
2
  import { t as createAuthHeader } from "./encoding-Bwfm3iaE.js";
3
3
 
4
4
  //#region src/core/debug.ts
@@ -383,4 +383,4 @@ function parseFieldErrors(body) {
383
383
 
384
384
  //#endregion
385
385
  export { parseFieldErrors as n, BaseHttpClient as t };
386
- //# sourceMappingURL=http-client-6XUgrg3k.js.map
386
+ //# sourceMappingURL=http-client-D1vuc20o.js.map
package/dist/index.js CHANGED
@@ -1,14 +1,14 @@
1
- import { A as mapHttpStatusToError, C as ServerError, D as isReoptSDKError, E as isModelAccessError, O as isRequiredTermsError, S as RequiredTermsError, T as isCreditLimitError, _ as ModelAccessError, b as RateLimitError, c as AuthUserNotFoundError, d as ConflictError, f as ContentFilterError, g as LimitExceededError, h as ForbiddenError, i as resolveBaseUrl, k as isValidationError, 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 ValidationError, x as ReoptSDKError, y as NotFoundError } from "./config-BV8Fn7Uo.js";
2
- import { t as BaseHttpClient } from "./http-client-6XUgrg3k.js";
3
- import { n as createReoptAiClient } from "./client-BFM7OGqI.js";
4
- import { n as createReoptAuthClient } from "./client-D4Z2xj4t.js";
5
- import { t as createReoptCmsClient } from "./client-CiCPE2MW.js";
6
- import { t as createReoptEavClient } from "./client-DVydvzc2.js";
7
- import { n as createReoptFeedbackClient } from "./client-CxyXO_0C.js";
8
- import { n as createReoptFileClient } from "./client-m29R8F0R.js";
9
- import { n as createReoptPlansClient } from "./client-WP3Xsxri.js";
10
- import { n as createReoptPushClient } from "./client-B84P9y2F.js";
11
- import { n as createReoptTermsClient } from "./client-C_YUxs_X.js";
1
+ import { A as mapHttpStatusToError, C as ServerError, D as isReoptSDKError, E as isModelAccessError, O as isRequiredTermsError, S as RequiredTermsError, T as isCreditLimitError, _ as ModelAccessError, b as RateLimitError, c as AuthUserNotFoundError, d as ConflictError, f as ContentFilterError, g as LimitExceededError, h as ForbiddenError, i as resolveBaseUrl, k as isValidationError, 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 ValidationError, x as ReoptSDKError, y as NotFoundError } from "./config-D31PK7eu.js";
2
+ import { t as BaseHttpClient } from "./http-client-D1vuc20o.js";
3
+ import { n as createReoptAiClient } from "./client-D72MLGRY.js";
4
+ import { n as createReoptAuthClient } from "./client-D9MGqXbn.js";
5
+ import { t as createReoptCmsClient } from "./client-B0uRUF3T.js";
6
+ import { t as createReoptEavClient } from "./client-CAjqKz8i.js";
7
+ import { n as createReoptFeedbackClient } from "./client-DTWpLo8X.js";
8
+ import { n as createReoptFileClient } from "./client-C6USfykM.js";
9
+ import { n as createReoptPlansClient } from "./client-Djlg4STl.js";
10
+ import { n as createReoptPushClient } from "./client-2qKKpHVy.js";
11
+ import { n as createReoptTermsClient } from "./client-DUvf9x_b.js";
12
12
 
13
13
  //#region src/singleton.ts
14
14
  let _instance;
@@ -1,4 +1,4 @@
1
- import { a as resolveIdBaseUrl, x as ReoptSDKError } from "../config-BV8Fn7Uo.js";
1
+ import { a as resolveIdBaseUrl, x as ReoptSDKError } from "../config-D31PK7eu.js";
2
2
 
3
3
  //#region src/logout/verify.ts
4
4
  /**
@@ -1,3 +1,3 @@
1
- import { n as createReoptPlansClient, t as ReoptPlansClient } from "../client-WP3Xsxri.js";
1
+ import { n as createReoptPlansClient, t as ReoptPlansClient } from "../client-Djlg4STl.js";
2
2
 
3
3
  export { ReoptPlansClient, createReoptPlansClient };
@@ -1,3 +1,3 @@
1
- import { n as createReoptPushClient, t as ReoptPushClient } from "../client-B84P9y2F.js";
1
+ import { n as createReoptPushClient, t as ReoptPushClient } from "../client-2qKKpHVy.js";
2
2
 
3
3
  export { ReoptPushClient, createReoptPushClient };
@@ -1,4 +1,4 @@
1
- import { x as ReoptSDKError } from "./config-BV8Fn7Uo.js";
1
+ import { x as ReoptSDKError } from "./config-D31PK7eu.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-C98fDfVW.js.map
35
+ //# sourceMappingURL=query-DyiwJX92.js.map
@@ -1,3 +1,3 @@
1
- import { n as createReoptTermsClient, t as ReoptTermsClient } from "../client-C_YUxs_X.js";
1
+ import { n as createReoptTermsClient, t as ReoptTermsClient } from "../client-DUvf9x_b.js";
2
2
 
3
3
  export { ReoptTermsClient, createReoptTermsClient };
@@ -1,7 +1,7 @@
1
1
  //#region src/better-auth/types.d.ts
2
2
  declare const REOPT_PROVIDER_ID: "reopt";
3
3
  declare const REOPT_DEFAULT_SCOPES: readonly ["openid", "profile", "email"];
4
- type AdapterOperation = "create" | "findOne" | "findMany" | "update" | "updateMany" | "delete" | "deleteMany" | "count";
4
+ type AdapterOperation = "create" | "findOne" | "findMany" | "update" | "updateMany" | "delete" | "deleteMany" | "count" | "consumeOne" | "incrementOne";
5
5
  type AdapterRequestBody = {
6
6
  operation: AdapterOperation;
7
7
  model: "user" | "session" | "account" | "verification";
@@ -13,6 +13,10 @@ type AdapterRequestBody = {
13
13
  connector?: "AND" | "OR";
14
14
  }>;
15
15
  update?: Record<string, unknown>;
16
+ /** incrementOne: signed per-field deltas (`field = field + delta`) */
17
+ increment?: Record<string, number>;
18
+ /** incrementOne: absolute assignments applied in the same atomic step */
19
+ set?: Record<string, unknown>;
16
20
  select?: string[];
17
21
  limit?: number;
18
22
  offset?: number;
@@ -23,4 +27,4 @@ type AdapterRequestBody = {
23
27
  };
24
28
  //#endregion
25
29
  export { REOPT_PROVIDER_ID as i, AdapterRequestBody as n, REOPT_DEFAULT_SCOPES as r, AdapterOperation as t };
26
- //# sourceMappingURL=types-B-SMkH6s.d.ts.map
30
+ //# sourceMappingURL=types-MXLudLBP.d.ts.map
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@reopt-ai/brandapp-sdk",
3
- "version": "3.6.0",
3
+ "version": "4.0.0",
4
4
  "description": "Reopt Brandapp SDK — Better Auth adapter, OAuth login, and EAV client",
5
5
  "author": "Reopt",
6
6
  "license": "MIT",
@@ -111,7 +111,7 @@
111
111
  "@ai-sdk/provider": ">=4.0.0",
112
112
  "@reopt-ai/opt-editor": ">=1.0.0",
113
113
  "@tanstack/react-query": ">=5.0.0",
114
- "better-auth": "^1.6.0",
114
+ "better-auth": "^1.7.1",
115
115
  "hono": ">=4.0.0",
116
116
  "react": ">=18.0.0"
117
117
  },
@@ -136,11 +136,11 @@
136
136
  }
137
137
  },
138
138
  "devDependencies": {
139
- "@ai-sdk/provider": "4.0.4",
140
- "@reopt-ai/opt-editor": "1.1.2",
139
+ "@ai-sdk/provider": "4.0.7",
140
+ "@reopt-ai/opt-editor": "2.0.0",
141
141
  "@testing-library/react": "^16.3.2",
142
142
  "@types/node": "22.13.9",
143
- "better-auth": "^1.4.0",
143
+ "better-auth": "^1.7.1",
144
144
  "happy-dom": "^20.8.9",
145
145
  "hono": "^4.7.0",
146
146
  "tsdown": "^0.22.14",