@reopt-ai/brandapp-sdk 3.5.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 (64) hide show
  1. package/CHANGELOG.md +65 -0
  2. package/README.md +14 -13
  3. package/dist/ai/index.d.ts +1 -1
  4. package/dist/ai/index.js +1 -1
  5. package/dist/ai-provider/index.js +1 -1
  6. package/dist/auth/index.d.ts +1 -1
  7. package/dist/auth/index.js +1 -1
  8. package/dist/better-auth/client.d.ts +56 -12
  9. package/dist/better-auth/client.js +27 -11
  10. package/dist/better-auth/index.d.ts +30 -2
  11. package/dist/better-auth/index.js +22 -3
  12. package/dist/{client-7PCoxVhZ.js → client-2qKKpHVy.js} +2 -2
  13. package/dist/{client-B7rZQ8Zi.d.ts → client-A4YrHjDc.d.ts} +2 -2
  14. package/dist/{client-wEVKLdly.js → client-B0uRUF3T.js} +3 -3
  15. package/dist/{client-aMR4CRB8.d.ts → client-BGLDrf3N.d.ts} +3 -3
  16. package/dist/{client-DDw5yz_h.d.ts → client-BTS6Ewv_.d.ts} +2 -2
  17. package/dist/{client-BoIuyx4S.js → client-C6USfykM.js} +3 -3
  18. package/dist/{client-BGGd_cpV.d.ts → client-CAGo56KO.d.ts} +2 -2
  19. package/dist/{client-61ldOHMz.js → client-CAjqKz8i.js} +3 -3
  20. package/dist/{client-BruP5_nU.d.ts → client-Ckm-i_Du.d.ts} +2 -2
  21. package/dist/{client-BxtZt405.js → client-D72MLGRY.js} +4 -4
  22. package/dist/{client-CAghoGD_.js → client-D9MGqXbn.js} +2 -2
  23. package/dist/{client-lk6wBu_0.d.ts → client-DHZ484kb.d.ts} +3 -3
  24. package/dist/{client-D0eBxh8j.d.ts → client-DPbXH8tr.d.ts} +2 -2
  25. package/dist/{client-zF1RG2uA.js → client-DTWpLo8X.js} +2 -2
  26. package/dist/{client-ByN3EQdk.js → client-DUvf9x_b.js} +2 -2
  27. package/dist/{client-D6gs61w8.d.ts → client-DfEeaOsQ.d.ts} +2 -2
  28. package/dist/{client-C_pHsPlj.js → client-Djlg4STl.js} +2 -2
  29. package/dist/{client-Dxg8_DIH.d.ts → client-yBQen4Yi.d.ts} +2 -2
  30. package/dist/cms/index.d.ts +1 -1
  31. package/dist/cms/index.js +1 -1
  32. package/dist/{config-CRytOPPl.d.ts → config-C7WQtC3l.d.ts} +3 -1
  33. package/dist/{config-aml9oQpX.js → config-D31PK7eu.js} +2 -2
  34. package/dist/dev/index.d.ts +1 -1
  35. package/dist/dev/index.js +33 -4
  36. package/dist/eav/index.d.ts +2 -2
  37. package/dist/eav/index.js +2 -2
  38. package/dist/eav/migrate.d.ts +2 -2
  39. package/dist/eav/schema.d.ts +2 -2
  40. package/dist/feedback/index.d.ts +1 -1
  41. package/dist/feedback/index.js +1 -1
  42. package/dist/files/index.d.ts +1 -1
  43. package/dist/files/index.js +1 -1
  44. package/dist/{http-client-BZc2mngq.js → http-client-D1vuc20o.js} +2 -2
  45. package/dist/{index-CeOLGdyL.d.ts → index-CvNJ8zp1.d.ts} +11 -11
  46. package/dist/{index-1j_738qk.d.ts → index-DV_OWwx5.d.ts} +2 -2
  47. package/dist/index.d.ts +4 -4
  48. package/dist/index.js +11 -11
  49. package/dist/logout/index.d.ts +1 -1
  50. package/dist/logout/index.js +1 -1
  51. package/dist/plans/index.d.ts +1 -1
  52. package/dist/plans/index.js +1 -1
  53. package/dist/push/index.d.ts +1 -1
  54. package/dist/push/index.js +1 -1
  55. package/dist/{query-xWqtfkvR.js → query-DyiwJX92.js} +2 -2
  56. package/dist/react/hooks.d.ts +4 -4
  57. package/dist/terms/index.d.ts +2 -2
  58. package/dist/terms/index.js +1 -1
  59. package/dist/testing/index.d.ts +2 -2
  60. package/dist/{types-BrghN2rJ.d.ts → types-C69OzBn6.d.ts} +2 -2
  61. package/dist/{types-B-SMkH6s.d.ts → types-MXLudLBP.d.ts} +6 -2
  62. package/docs/api-reference.md +7 -0
  63. package/docs/errors.md +5 -5
  64. package/package.json +5 -5
package/CHANGELOG.md CHANGED
@@ -7,6 +7,71 @@ 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
+
61
+ ## [3.6.0] — 2026-08-08
62
+
63
+ EAV 목록에서 필요한 값만 받을 수 있는 응답 projection을 추가했다. 기존 호출은
64
+ 모든 값을 그대로 받으므로 backward-compatible(minor)이다.
65
+
66
+ ### Added — EAV records projection
67
+
68
+ - **`sdk.eav.records.list(entityId, { select })`** — attribute ID 배열을 넘기면 각
69
+ `record.values`에 선택한 값만 포함한다. pagination·filter·sort 결과는 동일하고,
70
+ continuation token이나 큰 본문처럼 목록에 불필요한 값을 네트워크 응답에서 제외할 수 있다.
71
+ - **`records.listAll` / typed entity client / 사용자 레코드 목록**에도 같은 `select` 옵션이
72
+ 전달된다.
73
+ - production API와 SDK dev server가 같은 projection 및 입력 검증 계약을 제공한다.
74
+
10
75
  ## [3.5.0] — 2026-08-02
11
76
 
12
77
  파일 매니저를 만들 수 있게 됐다 — 폴더 계층, rename/move, 텍스트 미리보기,
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
@@ -229,6 +228,8 @@ const sdk = getReoptSDK();
229
228
  // Iterate all records across pages
230
229
  for await (const record of sdk.eav.records.listAll("entity-id", {
231
230
  limit: 100,
231
+ // Optional: return only these attribute IDs in record.values
232
+ select: [titleAttributeId, statusAttributeId],
232
233
  })) {
233
234
  console.log(record.values);
234
235
  }
@@ -284,7 +285,7 @@ const meta = asJson<Meta>(record.values.meta); // Meta | undefined
284
285
  | ---------------------------- | -------------------------------------------------------------------------------------- | ---------------------- |
285
286
  | `"."` | `createReoptSDK`, `createLazySDK`, `initReoptSDK`, `getReoptSDK`, errors | No |
286
287
  | `"./better-auth"` | `createReoptBetterAuth`, `createReoptAdapter`, `createReoptOAuth` | Yes |
287
- | `"./better-auth/client"` | `createReoptOAuthClient`, `REOPT_PROVIDER_ID` | Yes |
288
+ | `"./better-auth/client"` | `signInWithReopt`, `linkReoptAccount`, `REOPT_PROVIDER_ID` | Yes |
288
289
  | `"./eav"` | `createReoptEavClient`, `collectAll`, EAV types, `TypedEavRecord`, `EntityClient` | No |
289
290
  | `"./eav/schema"` | `defineEntity`, `defineSchema`, `syncSchema`, `computeDiff`, schema/sync types | No |
290
291
  | `"./eav/coerce"` | `asString`, `asNumber`, `asBoolean`, `asDate`, `asJson`, `asStringArray` | No |
@@ -1,2 +1,2 @@
1
- import { a as CompletionOptions, c as FinishReason, d as MessageRole, f as ModelInfo, i as ChatMessage, l as ImageGenerateOptions, m as StreamEvent, n as createReoptAiClient, o as CompletionResult, p as StreamDoneData, r as AgentInfo, s as CreditInfo, t as ReoptAiClient, u as ImageGenerateResult } from "../client-D0eBxh8j.js";
1
+ import { a as CompletionOptions, c as FinishReason, d as MessageRole, f as ModelInfo, i as ChatMessage, l as ImageGenerateOptions, m as StreamEvent, n as createReoptAiClient, o as CompletionResult, p as StreamDoneData, r as AgentInfo, s as CreditInfo, t as ReoptAiClient, u as ImageGenerateResult } from "../client-DPbXH8tr.js";
2
2
  export { type AgentInfo, type ChatMessage, type CompletionOptions, type CompletionResult, type CreditInfo, type FinishReason, type ImageGenerateOptions, type ImageGenerateResult, type MessageRole, type ModelInfo, ReoptAiClient, type StreamDoneData, type StreamEvent, createReoptAiClient };
package/dist/ai/index.js CHANGED
@@ -1,3 +1,3 @@
1
- import { n as createReoptAiClient, t as ReoptAiClient } from "../client-BxtZt405.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-aml9oQpX.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 { i as UserInfoClaims, n as createReoptAuthClient, r as LinkCurrentUserResult, t as ReoptAuthClient } from "../client-Dxg8_DIH.js";
1
+ import { i as UserInfoClaims, n as createReoptAuthClient, r as LinkCurrentUserResult, t as ReoptAuthClient } from "../client-yBQen4Yi.js";
2
2
  //#region src/auth/session.d.ts
3
3
  /**
4
4
  * 세션 쿠키 검증 — apps/id의 Better Auth `/api/auth/get-session`을 호출해
@@ -1,4 +1,4 @@
1
- import { n as createReoptAuthClient, t as ReoptAuthClient } from "../client-CAghoGD_.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
- import { n as ReoptSDKConfig, t as REOPT_BASE_URLS } from "../config-CRytOPPl.js";
2
- import { i as REOPT_PROVIDER_ID, n as AdapterRequestBody, r as REOPT_DEFAULT_SCOPES, t as AdapterOperation } from "../types-B-SMkH6s.js";
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-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-aml9oQpX.js";
2
- import { t as BaseHttpClient } from "../http-client-BZc2mngq.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-BZc2mngq.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-7PCoxVhZ.js.map
28
+ //# sourceMappingURL=client-2qKKpHVy.js.map
@@ -1,4 +1,4 @@
1
- import { n as ReoptSDKConfig } from "./config-CRytOPPl.js";
1
+ import { n as ReoptSDKConfig } from "./config-C7WQtC3l.js";
2
2
  //#region src/files/types.d.ts
3
3
  /** 파일 정보 */
4
4
  type FileInfo = {
@@ -269,4 +269,4 @@ declare class ReoptFileClient {
269
269
  declare function createReoptFileClient(config: ReoptSDKConfig): ReoptFileClient;
270
270
  //#endregion
271
271
  export { FileListQuery as a, FolderInfo as c, UpdateFolderInput as d, UploadOptions as f, FileInfo as i, FolderListQuery as l, createReoptFileClient as n, FileListResponse as o, CreateFolderInput as r, FileUsageInfo as s, ReoptFileClient as t, UpdateFileInput as u };
272
- //# sourceMappingURL=client-B7rZQ8Zi.d.ts.map
272
+ //# sourceMappingURL=client-A4YrHjDc.d.ts.map
@@ -1,5 +1,5 @@
1
- import { t as BaseHttpClient } from "./http-client-BZc2mngq.js";
2
- import { t as buildQuery } from "./query-xWqtfkvR.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-wEVKLdly.js.map
55
+ //# sourceMappingURL=client-B0uRUF3T.js.map
@@ -1,4 +1,4 @@
1
- import { n as ReoptSDKConfig } from "./config-CRytOPPl.js";
1
+ import { n as ReoptSDKConfig } from "./config-C7WQtC3l.js";
2
2
  //#region src/plans/types.d.ts
3
3
  /**
4
4
  * Brandapp Plans types.
@@ -43,7 +43,7 @@ type PlanMeter = {
43
43
  type PlanRequiredTerms = {
44
44
  id: string;
45
45
  title: string;
46
- /** Prisma `BrandappTermsType` (termsOfService/privacyPolicy/marketingConsent/custom). */
46
+ /** Prisma `BrandTermsType` (termsOfService/privacyPolicy/marketingConsent/custom). */
47
47
  type: string;
48
48
  };
49
49
  type Plan = {
@@ -208,4 +208,4 @@ declare class ReoptPlansClient {
208
208
  declare function createReoptPlansClient(config: ReoptSDKConfig): ReoptPlansClient;
209
209
  //#endregion
210
210
  export { CheckoutStatus as a, MeterPricingMode as c, PlanInterval as d, PlanMeter as f, CheckoutSession as i, Plan as l, PlanRequiredTerms as m, createReoptPlansClient as n, CreateCheckoutInput as o, PlanMeterTier as p, CancelSubscriptionResult as r, CurrentPlan as s, ReoptPlansClient as t, PlanBillingModel as u };
211
- //# sourceMappingURL=client-aMR4CRB8.d.ts.map
211
+ //# sourceMappingURL=client-BGLDrf3N.d.ts.map
@@ -1,4 +1,4 @@
1
- import { n as ReoptSDKConfig } from "./config-CRytOPPl.js";
1
+ import { n as ReoptSDKConfig } from "./config-C7WQtC3l.js";
2
2
  import { a as ListTagsQuery, c as PostGroup, d as Tag, i as ListPostsQuery, o as Post, r as ListPostGroupsQuery, s as PostDetail, t as CmsPaginatedResponse } from "./types-BXDcoJHG.js";
3
3
  //#region src/cms/client.d.ts
4
4
  /**
@@ -50,4 +50,4 @@ declare function createReoptCmsClient(config: ReoptSDKConfig): {
50
50
  };
51
51
  //#endregion
52
52
  export { createReoptCmsClient as n, ReoptCmsClient as t };
53
- //# sourceMappingURL=client-DDw5yz_h.d.ts.map
53
+ //# sourceMappingURL=client-BTS6Ewv_.d.ts.map
@@ -1,6 +1,6 @@
1
- import { A as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, x as ReoptSDKError } from "./config-aml9oQpX.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-BZc2mngq.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-BoIuyx4S.js.map
273
+ //# sourceMappingURL=client-C6USfykM.js.map
@@ -1,4 +1,4 @@
1
- import { A as UpdateEntityInput, C as EavEntity, D as ListRecordsQuery, M as UpsertRecordInput, N as UpsertRecordResult, O as PaginatedResponse, _ as CreateEntityInput, b as EavAttribute, c as InferValues, f as BackfillOptions, g as CreateAttributeInput, h as CountRecordsQuery, j as UpdateRecordInput, k as UpdateAttributeInput, l as SchemaDef, m as BulkUpdateItem, n as ReoptSDKConfig, p as BackfillResult, s as EntityDef, u as AttributeFilter, v as CreateRecordInput, w as EavRecord, y as DeleteWhereInput } from "./config-CRytOPPl.js";
1
+ import { A as UpdateEntityInput, C as EavEntity, D as ListRecordsQuery, M as UpsertRecordInput, N as UpsertRecordResult, O as PaginatedResponse, _ as CreateEntityInput, b as EavAttribute, c as InferValues, f as BackfillOptions, g as CreateAttributeInput, h as CountRecordsQuery, j as UpdateRecordInput, k as UpdateAttributeInput, l as SchemaDef, m as BulkUpdateItem, n as ReoptSDKConfig, p as BackfillResult, s as EntityDef, u as AttributeFilter, v as CreateRecordInput, w as EavRecord, y as DeleteWhereInput } from "./config-C7WQtC3l.js";
2
2
  //#region src/eav/typed-client.d.ts
3
3
  /** EavRecord with typed values instead of Record<string, unknown> */
4
4
  type TypedEavRecord<V> = Omit<EavRecord, "values"> & {
@@ -100,4 +100,4 @@ type ReoptEavClient<S extends SchemaDef = SchemaDef> = {
100
100
  declare function createReoptEavClient<S extends SchemaDef = SchemaDef>(config: ReoptSDKConfig<S>): ReoptEavClient<S>;
101
101
  //#endregion
102
102
  export { TypedEavRecord as i, createReoptEavClient as n, EntityClient as r, ReoptEavClient as t };
103
- //# sourceMappingURL=client-BGGd_cpV.d.ts.map
103
+ //# sourceMappingURL=client-CAGo56KO.d.ts.map
@@ -1,5 +1,5 @@
1
- import { t as BaseHttpClient } from "./http-client-BZc2mngq.js";
2
- import { t as buildQuery } from "./query-xWqtfkvR.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-61ldOHMz.js.map
503
+ //# sourceMappingURL=client-CAjqKz8i.js.map
@@ -1,4 +1,4 @@
1
- import { n as ReoptSDKConfig } from "./config-CRytOPPl.js";
1
+ import { n as ReoptSDKConfig } from "./config-C7WQtC3l.js";
2
2
  //#region src/feedback/types.d.ts
3
3
  /**
4
4
  * Feedback processing status. `reopened` means the customer replied after the
@@ -144,4 +144,4 @@ declare class ReoptFeedbackClient {
144
144
  declare function createReoptFeedbackClient(config: ReoptSDKConfig): ReoptFeedbackClient;
145
145
  //#endregion
146
146
  export { CreateFeedbackResult as a, FeedbackListMeta as c, FeedbackReplyAuthor as d, FeedbackStatus as f, CreateFeedbackReplyResult as i, FeedbackListResult as l, RateFeedbackReplyResult as m, createReoptFeedbackClient as n, Feedback as o, ListFeedbackQuery as p, CreateFeedbackInput as r, FeedbackDetail as s, ReoptFeedbackClient as t, FeedbackReply as u };
147
- //# sourceMappingURL=client-BruP5_nU.d.ts.map
147
+ //# sourceMappingURL=client-Ckm-i_Du.d.ts.map
@@ -1,6 +1,6 @@
1
- import { A as mapHttpStatusToError, n as SDK_VERSION, o as validateConfig, x as ReoptSDKError } from "./config-aml9oQpX.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-BZc2mngq.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.5.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-BxtZt405.js.map
305
+ //# sourceMappingURL=client-D72MLGRY.js.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-BZc2mngq.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-CAghoGD_.js.map
53
+ //# sourceMappingURL=client-D9MGqXbn.js.map
@@ -1,5 +1,5 @@
1
- import { n as ReoptSDKConfig } from "./config-CRytOPPl.js";
2
- import { a as CreateConsentsResult, f as WithdrawConsentResult, i as CreateConsentsRequest, l as TermsListResponse, n as ConsentRecord, o as ListTermsOptions, s as TermsItem } from "./types-BrghN2rJ.js";
1
+ import { n as ReoptSDKConfig } from "./config-C7WQtC3l.js";
2
+ import { a as CreateConsentsResult, f as WithdrawConsentResult, i as CreateConsentsRequest, l as TermsListResponse, n as ConsentRecord, o as ListTermsOptions, s as TermsItem } from "./types-C69OzBn6.js";
3
3
  //#region src/terms/client.d.ts
4
4
  declare class ReoptTermsClient {
5
5
  private readonly http;
@@ -45,4 +45,4 @@ declare class ReoptTermsClient {
45
45
  declare function createReoptTermsClient(config: ReoptSDKConfig): ReoptTermsClient;
46
46
  //#endregion
47
47
  export { createReoptTermsClient as n, ReoptTermsClient as t };
48
- //# sourceMappingURL=client-lk6wBu_0.d.ts.map
48
+ //# sourceMappingURL=client-DHZ484kb.d.ts.map
@@ -1,4 +1,4 @@
1
- import { n as ReoptSDKConfig } from "./config-CRytOPPl.js";
1
+ import { n as ReoptSDKConfig } from "./config-C7WQtC3l.js";
2
2
  //#region src/ai/types.d.ts
3
3
  /** 메시지 역할 */
4
4
  type MessageRole = "system" | "user" | "assistant";
@@ -281,4 +281,4 @@ declare class ReoptAiClient {
281
281
  declare function createReoptAiClient(config: ReoptSDKConfig): ReoptAiClient;
282
282
  //#endregion
283
283
  export { CompletionOptions as a, FinishReason as c, MessageRole as d, ModelInfo as f, ChatMessage as i, ImageGenerateOptions as l, StreamEvent as m, createReoptAiClient as n, CompletionResult as o, StreamDoneData as p, AgentInfo as r, CreditInfo as s, ReoptAiClient as t, ImageGenerateResult as u };
284
- //# sourceMappingURL=client-D0eBxh8j.d.ts.map
284
+ //# sourceMappingURL=client-DPbXH8tr.d.ts.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-BZc2mngq.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-zF1RG2uA.js.map
86
+ //# sourceMappingURL=client-DTWpLo8X.js.map
@@ -1,4 +1,4 @@
1
- import { t as BaseHttpClient } from "./http-client-BZc2mngq.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-ByN3EQdk.js.map
83
+ //# sourceMappingURL=client-DUvf9x_b.js.map
@@ -1,4 +1,4 @@
1
- import { n as ReoptSDKConfig } from "./config-CRytOPPl.js";
1
+ import { n as ReoptSDKConfig } from "./config-C7WQtC3l.js";
2
2
  //#region src/push/types.d.ts
3
3
  /** Push provider — native token kind. */
4
4
  type PushProvider = "fcm" | "apns";
@@ -50,4 +50,4 @@ declare class ReoptPushClient {
50
50
  declare function createReoptPushClient(config: ReoptSDKConfig): ReoptPushClient;
51
51
  //#endregion
52
52
  export { RegisterPushTokenInput as a, UnregisterPushTokenInput as c, PushProvider as i, UnregisterPushTokenResult as l, createReoptPushClient as n, RegisterPushTokenResult as o, PushPlatform as r, RegisteredPushDevice as s, ReoptPushClient as t };
53
- //# sourceMappingURL=client-D6gs61w8.d.ts.map
53
+ //# sourceMappingURL=client-DfEeaOsQ.d.ts.map