@reopt-ai/brandapp-sdk 4.6.0 → 4.7.0-rc.1

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 (76) hide show
  1. package/CHANGELOG.md +49 -1
  2. package/README.md +13 -13
  3. package/dist/ai/index.d.ts +1 -1
  4. package/dist/ai/index.js +1 -1
  5. package/dist/ai-provider/index.d.ts +1 -1
  6. package/dist/ai-provider/index.js +1 -1
  7. package/dist/analytics/index.d.ts +1 -1
  8. package/dist/analytics/index.js +1 -1
  9. package/dist/auth/index.d.ts +1 -1
  10. package/dist/auth/index.js +1 -1
  11. package/dist/better-auth/index.d.ts +8 -2
  12. package/dist/better-auth/index.js +19 -5
  13. package/dist/{client-CI2Y00Qx.js → client-BFl6cDAE.js} +23 -2
  14. package/dist/{client-tJq0U_jn.js → client-BJQzInqD.js} +4 -4
  15. package/dist/{client-IUSZDJio.d.ts → client-BQJepjoD.d.ts} +44 -4
  16. package/dist/{client-C2xE9HGZ.js → client-BZ8-vFjk.js} +4 -4
  17. package/dist/{client-DjLhTNsZ.js → client-Bf8mW6uO.js} +3 -3
  18. package/dist/client-C-LdW4gY.js +194 -0
  19. package/dist/{client-C6OXGMMV.d.ts → client-C2W4RAZV.d.ts} +2 -2
  20. package/dist/{client-7I-mz3Dw.d.ts → client-C6lx3RUQ.d.ts} +2 -2
  21. package/dist/{client-Ce0gs5Ma.js → client-CLZie3Ym.js} +2 -2
  22. package/dist/{client-yKeRJnIB.d.ts → client-CSl3o0s3.d.ts} +2 -2
  23. package/dist/{client-D1AFtJRw.d.ts → client-Cnq_X3Wp.d.ts} +2 -2
  24. package/dist/{client-Bfutv3LK.d.ts → client-Cod87ThY.d.ts} +2 -2
  25. package/dist/{client-BSW0Ncjj.d.ts → client-CsWSxMhB.d.ts} +2 -2
  26. package/dist/{client-eDd4aWDs.js → client-CslasnqK.js} +2 -2
  27. package/dist/{client-FM6_YJbr.js → client-DGKq4Ml5.js} +3 -3
  28. package/dist/{client-BzAgabAs.js → client-Db6Etco9.js} +2 -2
  29. package/dist/{client-Dmvtr1nS.d.ts → client-DfnaH99z.d.ts} +2 -2
  30. package/dist/{client-COKDtHO9.d.ts → client-MDNS9Ubf.d.ts} +2 -2
  31. package/dist/{client-DCqp0Bis.js → client-VKEJtLH0.js} +2 -2
  32. package/dist/{client-DeC127BD.js → client-_2Avom0q.js} +2 -2
  33. package/dist/{client-CniCGdmi.d.ts → client-xblzWFAL.d.ts} +2 -2
  34. package/dist/cms/index.d.ts +1 -1
  35. package/dist/cms/index.js +1 -1
  36. package/dist/{config-D3SblxWt.d.ts → config-CnFnzh7Q.d.ts} +21 -6
  37. package/dist/{config-BeOelISH.js → config-Dy2oBn1a.js} +13 -10
  38. package/dist/dev/index.d.ts +1 -1
  39. package/dist/eav/index.d.ts +2 -2
  40. package/dist/eav/index.js +2 -2
  41. package/dist/eav/migrate.d.ts +2 -2
  42. package/dist/eav/schema.d.ts +2 -2
  43. package/dist/feedback/index.d.ts +1 -1
  44. package/dist/feedback/index.js +1 -1
  45. package/dist/files/index.d.ts +1 -1
  46. package/dist/files/index.js +1 -1
  47. package/dist/{http-client-Bl8u1vHN.js → http-client-CW9wXANY.js} +9 -3
  48. package/dist/{index-BnAYxnwq.d.ts → index-Bkci7euU.d.ts} +14 -12
  49. package/dist/{index-C6fyJTud.d.ts → index-Dh8XMVFF.d.ts} +2 -2
  50. package/dist/index.d.ts +4 -4
  51. package/dist/index.js +12 -12
  52. package/dist/keys-B2pA8EkU.d.ts +44 -0
  53. package/dist/keys-B_R_lsyF.js +102 -0
  54. package/dist/logout/index.d.ts +1 -1
  55. package/dist/logout/index.js +1 -1
  56. package/dist/machine/index.d.ts +72 -0
  57. package/dist/machine/index.js +4 -0
  58. package/dist/machine/keygen-cli.d.ts +7 -0
  59. package/dist/machine/keygen-cli.js +57 -0
  60. package/dist/plans/index.d.ts +2 -2
  61. package/dist/plans/index.js +1 -1
  62. package/dist/push/index.d.ts +1 -1
  63. package/dist/push/index.js +1 -1
  64. package/dist/{query-JPVK_8N5.js → query-DPD0WYlB.js} +2 -2
  65. package/dist/react/hooks.d.ts +4 -4
  66. package/dist/terms/index.d.ts +1 -1
  67. package/dist/terms/index.js +1 -1
  68. package/dist/testing/index.d.ts +2 -2
  69. package/dist/workspace/index.d.ts +39 -9
  70. package/dist/workspace/index.js +51 -9
  71. package/docs/api-reference.md +43 -24
  72. package/docs/dev-server.md +2 -2
  73. package/docs/environment.md +4 -4
  74. package/docs/machine.md +104 -0
  75. package/docs/workspace.md +12 -0
  76. package/package.json +17 -3
@@ -0,0 +1,102 @@
1
+ import * as jose from "jose";
2
+
3
+ //#region src/machine/keys.ts
4
+ /**
5
+ * 기계 클라이언트 키 자재 (RFC-0034 §3.3) — 생성 · 공개키 추출 · JWKS 문서 · env 읽기.
6
+ *
7
+ * 서브 제품은 키쌍을 **자기 쪽에서** 만들고 개인키는 env(`REOPT_CLIENT_PRIVATE_KEY_JWK`)에만 둔다.
8
+ * 리옵트에는 공개키 주소(`jwksUri`)만 등록되므로 비밀이 전송되는 순간이 없다. 회전은 2단계다:
9
+ * ① `REOPT_CLIENT_PRIVATE_KEY_JWK_NEXT`에 새 키를 두면 JWKS에 두 키가 실리고 서명은 NEXT로 간다
10
+ * ② 리옵트가 새 kid로 토큰을 발급하면(JWKS 캐시 5분) NEXT를 본 키로 승격하고 옛 키를 지운다.
11
+ *
12
+ * 🔑 kid는 **JWK 지문(RFC 7638)**이다 — 사람이 이름을 짓지 않고, 같은 키는 어디서 만들어도 같은 kid다.
13
+ */
14
+ const DEFAULT_CLIENT_KEY_ALGORITHM = "EdDSA";
15
+ const PRIVATE_FIELDS = [
16
+ "d",
17
+ "p",
18
+ "q",
19
+ "dp",
20
+ "dq",
21
+ "qi",
22
+ "oth"
23
+ ];
24
+ function assertAlgorithm(value) {
25
+ if (value !== "EdDSA" && value !== "ES256" && value !== "RS256") throw new Error(`[@reopt-ai/brandapp-sdk/machine] unsupported client key algorithm: ${String(value)} (EdDSA · ES256 · RS256)`);
26
+ }
27
+ /** 새 키쌍 — 개인키 JWK(kid·alg 포함)와 공개키 JWK. 개인키는 env로만 가고 로그에 찍지 않는다. */
28
+ async function generateClientKeyPair(options = {}) {
29
+ const algorithm = options.algorithm ?? "EdDSA";
30
+ const pair = await jose.generateKeyPair(algorithm, algorithm === "EdDSA" ? {
31
+ crv: "Ed25519",
32
+ extractable: true
33
+ } : { extractable: true });
34
+ const privateJwk = await jose.exportJWK(pair.privateKey);
35
+ const publicJwk = await jose.exportJWK(pair.publicKey);
36
+ const kid = await jose.calculateJwkThumbprint(publicJwk);
37
+ return {
38
+ privateKeyJwk: {
39
+ ...privateJwk,
40
+ kid,
41
+ alg: algorithm,
42
+ use: "sig"
43
+ },
44
+ publicKeyJwk: {
45
+ ...publicJwk,
46
+ kid,
47
+ alg: algorithm,
48
+ use: "sig"
49
+ },
50
+ kid
51
+ };
52
+ }
53
+ /** 개인키 JWK에서 공개키만 — JWKS 응답·DPoP 증명 헤더(`jwk`)에 싣는 값. */
54
+ function toPublicJwk(privateKeyJwk) {
55
+ const copy = { ...privateKeyJwk };
56
+ for (const field of PRIVATE_FIELDS) delete copy[field];
57
+ return copy;
58
+ }
59
+ /** JSON 문자열(env 값)을 개인키 JWK로 — 모양이 틀리면 **어디가** 틀렸는지 말하고 값은 절대 되풀이하지 않는다. */
60
+ function parseClientPrivateJwk(raw, envName = "REOPT_CLIENT_PRIVATE_KEY_JWK") {
61
+ let parsed;
62
+ try {
63
+ parsed = JSON.parse(raw);
64
+ } catch {
65
+ throw new Error(`[@reopt-ai/brandapp-sdk/machine] ${envName} is not valid JSON`);
66
+ }
67
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) throw new Error(`[@reopt-ai/brandapp-sdk/machine] ${envName} must be a JWK object`);
68
+ const jwk = parsed;
69
+ if (typeof jwk.kty !== "string") throw new Error(`[@reopt-ai/brandapp-sdk/machine] ${envName} is missing "kty"`);
70
+ if (typeof jwk.d !== "string") throw new Error(`[@reopt-ai/brandapp-sdk/machine] ${envName} is a public key — the private JWK (with "d") is required`);
71
+ if (typeof jwk.kid !== "string" || jwk.kid.length === 0) throw new Error(`[@reopt-ai/brandapp-sdk/machine] ${envName} is missing "kid" (use generateClientKeyPair())`);
72
+ assertAlgorithm(jwk.alg);
73
+ return jwk;
74
+ }
75
+ /**
76
+ * env에서 키 링을 읽는다 — `REOPT_CLIENT_PRIVATE_KEY_JWK`(필수) + `REOPT_CLIENT_PRIVATE_KEY_JWK_NEXT`(회전 중에만).
77
+ * 없으면 null(호출자가 "설정 안 됨"을 fail-closed로 다룬다).
78
+ */
79
+ function readClientKeyRing(env = typeof process === "undefined" ? {} : process.env, names = {}) {
80
+ const currentName = names.current ?? "REOPT_CLIENT_PRIVATE_KEY_JWK";
81
+ const nextName = names.next ?? "REOPT_CLIENT_PRIVATE_KEY_JWK_NEXT";
82
+ const currentRaw = env[currentName]?.trim();
83
+ if (!currentRaw) return null;
84
+ const current = parseClientPrivateJwk(currentRaw, currentName);
85
+ const nextRaw = env[nextName]?.trim();
86
+ const next = nextRaw ? parseClientPrivateJwk(nextRaw, nextName) : null;
87
+ if (next && next.kid === current.kid) throw new Error(`[@reopt-ai/brandapp-sdk/machine] ${nextName} has the same kid as ${currentName} — generate a new key for rotation`);
88
+ return {
89
+ signing: next ?? current,
90
+ published: next ? [current, next] : [current]
91
+ };
92
+ }
93
+ /** `/.well-known/reopt-client-jwks.json` 응답 본문 — 공개키만. */
94
+ function buildClientJwks(keys) {
95
+ return { keys: keys.map(toPublicJwk) };
96
+ }
97
+ /** JWKS 응답의 정본 경로 — 리옵트에 등록하는 `jwksUri`는 `${origin}${CLIENT_JWKS_PATH}`다. */
98
+ const CLIENT_JWKS_PATH = "/.well-known/reopt-client-jwks.json";
99
+
100
+ //#endregion
101
+ export { parseClientPrivateJwk as a, generateClientKeyPair as i, DEFAULT_CLIENT_KEY_ALGORITHM as n, readClientKeyRing as o, buildClientJwks as r, toPublicJwk as s, CLIENT_JWKS_PATH as t };
102
+ //# sourceMappingURL=keys-B_R_lsyF.js.map
@@ -1,4 +1,4 @@
1
- import { n as ReoptSDKConfig } from "../config-D3SblxWt.js";
1
+ import { n as ReoptSDKConfig } from "../config-CnFnzh7Q.js";
2
2
  //#region src/logout/verify.d.ts
3
3
  type VerifyLogoutTokenOptions = {
4
4
  /** 자기 OAuth client_id — logout_token `aud` 검증. 미지정 시 config/env에서 유도. */
@@ -1,4 +1,4 @@
1
- import { S as ReoptSDKError, a as resolveIdBaseUrl } from "../config-BeOelISH.js";
1
+ import { S as ReoptSDKError, a as resolveIdBaseUrl } from "../config-Dy2oBn1a.js";
2
2
 
3
3
  //#region src/logout/verify.ts
4
4
  /**
@@ -0,0 +1,72 @@
1
+ import { a as ClientPublicJwk, c as generateClientKeyPair, d as toPublicJwk, i as ClientPrivateJwk, l as parseClientPrivateJwk, n as ClientKeyAlgorithm, o as DEFAULT_CLIENT_KEY_ALGORITHM, r as ClientKeyRing, s as buildClientJwks, t as CLIENT_JWKS_PATH, u as readClientKeyRing } from "../keys-B2pA8EkU.js";
2
+ //#region src/machine/client.d.ts
3
+ type MachineClientConfig = {
4
+ /** `purpose: machine`(또는 `adapter`) 클라이언트의 client_id */
5
+ clientId: string;
6
+ /**
7
+ * 개인키 JWK(kid·alg 포함) 또는 키 링. 생략하면 env `REOPT_CLIENT_PRIVATE_KEY_JWK`(+`_NEXT`)를 읽는다.
8
+ * 🔴 브라우저에서 호출하면 throw — 개인키는 서버에만 있다.
9
+ */
10
+ privateKeyJwk?: ClientPrivateJwk;
11
+ keyRing?: ClientKeyRing;
12
+ /**
13
+ * 토큰 audience — 부를 서비스의 origin(RFC 8707 `resource`). 플랫폼 API `https://platform.reopt.ai`,
14
+ * 브랜드앱 API `https://brandapp.reopt.ai`, reopt-data `https://data.reopt.ai`. 하나만(여러 resource는
15
+ * 서버가 scope 교집합으로 좁혀 거절될 수 있다).
16
+ */
17
+ resource: string;
18
+ /** 요청 scope — 클라이언트 행의 `clientCredentialsScopes`·리소스 `allowedScopes` 안이어야 한다 */
19
+ scopes: readonly string[];
20
+ /** id 서버 origin — 생략하면 `REOPT_ID_BASE_URL` / `REOPT_BASE_URL` 유도 */
21
+ idBaseUrl?: string;
22
+ /** DPoP 바인딩 — 기본 true(불변식 2). false면 Bearer 토큰(리소스가 허용할 때만) */
23
+ dpop?: boolean;
24
+ fetch?: typeof globalThis.fetch;
25
+ timeoutMs?: number;
26
+ /** 테스트용 시계 */
27
+ now?: () => number;
28
+ };
29
+ type MachineTokenState = {
30
+ accessToken: string;
31
+ tokenType: "DPoP" | "Bearer";
32
+ expiresAt: number;
33
+ scope: string;
34
+ };
35
+ type MachineClient = {
36
+ readonly clientId: string;
37
+ readonly resource: string;
38
+ /** 현재 서명·DPoP 키의 kid(회전 관측용) */
39
+ readonly kid: string;
40
+ /** 유효한 access token(만료 60초 전 재발급). `force`면 캐시를 버리고 새로 받는다 */
41
+ getToken(force?: boolean): Promise<string>;
42
+ /** 요청 하나에 붙일 인증 헤더 — `Authorization` + (`DPoP`). URL·메서드가 증명에 묶이므로 요청마다 새로 만든다 */
43
+ headers(request: {
44
+ method: string;
45
+ url: string;
46
+ }): Promise<Record<string, string>>;
47
+ /** `fetch`에 인증 헤더를 붙이고, 401이면 토큰을 한 번 재발급해 재시도한다 */
48
+ fetch(input: string | URL, init?: RequestInit): Promise<Response>;
49
+ /** 캐시된 토큰을 버린다(진단·테스트) */
50
+ invalidateToken(): void;
51
+ };
52
+ declare class MachineTokenError extends Error {
53
+ readonly status: number;
54
+ readonly code: string;
55
+ constructor(input: {
56
+ status: number;
57
+ code: string;
58
+ message: string;
59
+ });
60
+ }
61
+ /** DPoP 증명(RFC 9449 §4) — htm·htu(쿼리·프래그먼트 제거)·jti·iat, 리소스 요청이면 ath. */
62
+ declare function createDpopProof(input: {
63
+ key: ClientPrivateJwk;
64
+ method: string;
65
+ url: string;
66
+ accessToken?: string;
67
+ now?: number;
68
+ }): Promise<string>;
69
+ declare function createMachineClient(config: MachineClientConfig): MachineClient;
70
+ //#endregion
71
+ export { CLIENT_JWKS_PATH, type ClientKeyAlgorithm, type ClientKeyRing, type ClientPrivateJwk, type ClientPublicJwk, DEFAULT_CLIENT_KEY_ALGORITHM, type MachineClient, type MachineClientConfig, MachineTokenError, type MachineTokenState, buildClientJwks, createDpopProof, createMachineClient, generateClientKeyPair, parseClientPrivateJwk, readClientKeyRing, toPublicJwk };
72
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1,4 @@
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-C-LdW4gY.js";
3
+
4
+ export { CLIENT_JWKS_PATH, DEFAULT_CLIENT_KEY_ALGORITHM, MachineTokenError, buildClientJwks, createDpopProof, createMachineClient, generateClientKeyPair, parseClientPrivateJwk, readClientKeyRing, toPublicJwk };
@@ -0,0 +1,7 @@
1
+ //#region src/machine/keygen-cli.d.ts
2
+ declare function runKeygen(argv: string[], out?: {
3
+ log: (line: string) => void;
4
+ }): Promise<number>;
5
+ //#endregion
6
+ export { runKeygen };
7
+ //# sourceMappingURL=keygen-cli.d.ts.map
@@ -0,0 +1,57 @@
1
+ #!/usr/bin/env node
2
+ import { i as generateClientKeyPair, t as CLIENT_JWKS_PATH } from "../keys-B_R_lsyF.js";
3
+
4
+ //#region src/machine/keygen-cli.ts
5
+ /**
6
+ * `npx @reopt-ai/brandapp-sdk reopt-keygen` — 기계 클라이언트 키쌍을 만들고 **개인키는 stdout 한 줄**로만 낸다.
7
+ *
8
+ * 콘솔(platform.reopt.ai)이 개인키를 만들지 않는 이유가 여기 있다(RFC-0034 §6.5): 키가 화면을 한 번이라도
9
+ * 지나면 "한 번만 보이는 값"이 된다. 이 명령은 개발자의 터미널에서 돌고 출력은 env 파일로만 간다.
10
+ *
11
+ * --alg EdDSA|ES256|RS256 (기본 EdDSA)
12
+ * --next 회전 ①용 — env 이름을 REOPT_CLIENT_PRIVATE_KEY_JWK_NEXT로 낸다
13
+ * --json { privateKeyJwk, publicKeyJwk, kid }를 JSON으로(스크립트용)
14
+ */
15
+ function readFlag(argv, name) {
16
+ const index = argv.indexOf(name);
17
+ if (index === -1) return void 0;
18
+ return argv[index + 1];
19
+ }
20
+ async function runKeygen(argv, out = console) {
21
+ const alg = readFlag(argv, "--alg") ?? "EdDSA";
22
+ if (alg !== "EdDSA" && alg !== "ES256" && alg !== "RS256") {
23
+ out.log(`reopt-keygen: unsupported --alg ${alg} (EdDSA · ES256 · RS256)`);
24
+ return 2;
25
+ }
26
+ const next = argv.includes("--next");
27
+ const json = argv.includes("--json");
28
+ const { privateKeyJwk, publicKeyJwk, kid } = await generateClientKeyPair({ algorithm: alg });
29
+ if (json) {
30
+ out.log(JSON.stringify({
31
+ privateKeyJwk,
32
+ publicKeyJwk,
33
+ kid
34
+ }));
35
+ return 0;
36
+ }
37
+ const envName = next ? "REOPT_CLIENT_PRIVATE_KEY_JWK_NEXT" : "REOPT_CLIENT_PRIVATE_KEY_JWK";
38
+ out.log(`# reopt machine client key — kid ${kid} (${alg})`);
39
+ out.log(`# 1) 아래 한 줄을 서버 env에 넣는다 (브라우저 번들·로그·커밋 금지)`);
40
+ out.log(`${envName}='${JSON.stringify(privateKeyJwk)}'`);
41
+ out.log(`# 2) 공개키를 게시한다 — GET ${CLIENT_JWKS_PATH}`);
42
+ out.log(`# import { buildClientJwks, readClientKeyRing } from "@reopt-ai/brandapp-sdk/machine";`);
43
+ out.log(`# export const GET = () => Response.json(buildClientJwks(readClientKeyRing()!.published));`);
44
+ out.log(`# 3) 리옵트 콘솔(연동 › 자격)의 jwksUri에 https://<your-host>${CLIENT_JWKS_PATH} 를 적는다`);
45
+ if (next) {
46
+ out.log(`# 회전 ①: 두 키가 JWKS에 함께 실리고 서명은 NEXT로 간다. 리옵트가 새 kid로 토큰을 주면(최대 5분)`);
47
+ out.log(`# NEXT 값을 REOPT_CLIENT_PRIVATE_KEY_JWK로 옮기고 NEXT를 지운다(회전 ②).`);
48
+ }
49
+ return 0;
50
+ }
51
+ if (typeof process !== "undefined" && Array.isArray(process.argv) && /reopt-keygen|keygen-cli/.test(process.argv[1] ?? "")) runKeygen(process.argv.slice(2)).then((code) => {
52
+ process.exitCode = code;
53
+ });
54
+
55
+ //#endregion
56
+ export { runKeygen };
57
+ //# sourceMappingURL=keygen-cli.js.map
@@ -1,2 +1,2 @@
1
- import { a as CheckoutStatus, c as MeterPricingMode, d as PlanInterval, f as PlanMeter, i as CheckoutSession, l as Plan, m as PlanRequiredTerms, n as createReoptPlansClient, o as CreateCheckoutInput, p as PlanMeterTier, r as CancelSubscriptionResult, s as CurrentPlan, t as ReoptPlansClient, u as PlanBillingModel } from "../client-IUSZDJio.js";
2
- export { type CancelSubscriptionResult, type CheckoutSession, type CheckoutStatus, type CreateCheckoutInput, type CurrentPlan, type MeterPricingMode, type Plan, type PlanBillingModel, type PlanInterval, type PlanMeter, type PlanMeterTier, type PlanRequiredTerms, ReoptPlansClient, createReoptPlansClient };
1
+ import { a as CheckoutStatus, c as MeterPricingMode, d as PlanInterval, f as PlanMeter, h as PlanRequiredTerms, i as CheckoutSession, l as Plan, m as PlanPaymentEnvironment, n as createReoptPlansClient, o as CreateCheckoutInput, p as PlanMeterTier, r as CancelSubscriptionResult, s as CurrentPlan, t as ReoptPlansClient, u as PlanBillingModel } from "../client-BQJepjoD.js";
2
+ export { type CancelSubscriptionResult, type CheckoutSession, type CheckoutStatus, type CreateCheckoutInput, type CurrentPlan, type MeterPricingMode, type Plan, type PlanBillingModel, type PlanInterval, type PlanMeter, type PlanMeterTier, type PlanPaymentEnvironment, type PlanRequiredTerms, ReoptPlansClient, createReoptPlansClient };
@@ -1,3 +1,3 @@
1
- import { n as createReoptPlansClient, t as ReoptPlansClient } from "../client-CI2Y00Qx.js";
1
+ import { n as createReoptPlansClient, t as ReoptPlansClient } from "../client-BFl6cDAE.js";
2
2
 
3
3
  export { ReoptPlansClient, createReoptPlansClient };
@@ -1,2 +1,2 @@
1
- import { a as RegisterPushTokenInput, c as UnregisterPushTokenInput, i as PushProvider, l as UnregisterPushTokenResult, n as createReoptPushClient, o as RegisterPushTokenResult, r as PushPlatform, s as RegisteredPushDevice, t as ReoptPushClient } from "../client-BSW0Ncjj.js";
1
+ import { a as RegisterPushTokenInput, c as UnregisterPushTokenInput, i as PushProvider, l as UnregisterPushTokenResult, n as createReoptPushClient, o as RegisterPushTokenResult, r as PushPlatform, s as RegisteredPushDevice, t as ReoptPushClient } from "../client-CsWSxMhB.js";
2
2
  export { type PushPlatform, type PushProvider, type RegisterPushTokenInput, type RegisterPushTokenResult, type RegisteredPushDevice, ReoptPushClient, type UnregisterPushTokenInput, type UnregisterPushTokenResult, createReoptPushClient };
@@ -1,3 +1,3 @@
1
- import { n as createReoptPushClient, t as ReoptPushClient } from "../client-DeC127BD.js";
1
+ import { n as createReoptPushClient, t as ReoptPushClient } from "../client-_2Avom0q.js";
2
2
 
3
3
  export { ReoptPushClient, createReoptPushClient };
@@ -1,4 +1,4 @@
1
- import { S as ReoptSDKError } from "./config-BeOelISH.js";
1
+ import { S as ReoptSDKError } from "./config-Dy2oBn1a.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-JPVK_8N5.js.map
35
+ //# sourceMappingURL=query-DPD0WYlB.js.map
@@ -1,9 +1,9 @@
1
- import { A as ListRecordsQuery, C as EavAttribute, D as EavRecord, E as EavEntity, F as UpdateRecordInput, I as UpsertRecordInput, L as UpsertRecordResult, S as DeleteWhereInput, _ as BulkUpdateItem, j as PaginatedResponse, x as CreateRecordInput } from "../config-D3SblxWt.js";
2
- import { a as CompletionOptions, f as ModelInfo, l as ImageGenerateOptions, o as CompletionResult, p as StreamDoneData, r as AgentInfo, s as CreditInfo, u as ImageGenerateResult } from "../client-D1AFtJRw.js";
1
+ import { A as ListRecordsQuery, C as EavAttribute, D as EavRecord, E as EavEntity, F as UpdateRecordInput, I as UpsertRecordInput, L as UpsertRecordResult, S as DeleteWhereInput, _ as BulkUpdateItem, j as PaginatedResponse, x as CreateRecordInput } from "../config-CnFnzh7Q.js";
2
+ import { a as CompletionOptions, f as ModelInfo, l as ImageGenerateOptions, o as CompletionResult, p as StreamDoneData, r as AgentInfo, s as CreditInfo, u as ImageGenerateResult } from "../client-Cnq_X3Wp.js";
3
3
  import { v as ReoptSDKError } from "../errors-U3TsyWVq.js";
4
4
  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";
5
- import { a as FileListQuery, c as FolderInfo, d as UpdateFolderInput, f as UploadOptions, i as FileInfo, l as FolderListQuery, o as FileListResponse, r as CreateFolderInput, s as FileUsageInfo, u as UpdateFileInput } from "../client-CniCGdmi.js";
6
- import { t as ReoptSDK } from "../index-BnAYxnwq.js";
5
+ import { a as FileListQuery, c as FolderInfo, d as UpdateFolderInput, f as UploadOptions, i as FileInfo, l as FolderListQuery, o as FileListResponse, r as CreateFolderInput, s as FileUsageInfo, u as UpdateFileInput } from "../client-xblzWFAL.js";
6
+ import { t as ReoptSDK } from "../index-Bkci7euU.js";
7
7
  import { UseInfiniteQueryOptions, UseInfiniteQueryResult, UseMutationOptions, UseMutationResult, UseQueryOptions, UseQueryResult } from "@tanstack/react-query";
8
8
  //#region src/react/use-ai-stream.d.ts
9
9
  type UseAiStreamOptions = {
@@ -1,3 +1,3 @@
1
1
  import { a as CreateConsentsResult, c as TermsJurisdiction, d as TermsVersion, f as WithdrawConsentResult, i as CreateConsentsRequest, l as TermsListResponse, n as ConsentRecord, o as ListTermsOptions, r as ConsentStatus, s as TermsItem, t as ConsentInput, u as TermsType } from "../types-C69OzBn6.js";
2
- import { n as createReoptTermsClient, t as ReoptTermsClient } from "../client-yKeRJnIB.js";
2
+ import { n as createReoptTermsClient, t as ReoptTermsClient } from "../client-CSl3o0s3.js";
3
3
  export { type ConsentInput, type ConsentRecord, type ConsentStatus, type CreateConsentsRequest, type CreateConsentsResult, type ListTermsOptions, ReoptTermsClient, type TermsItem, type TermsJurisdiction, type TermsListResponse, type TermsType, type TermsVersion, type WithdrawConsentResult, createReoptTermsClient };
@@ -1,3 +1,3 @@
1
- import { n as createReoptTermsClient, t as ReoptTermsClient } from "../client-DCqp0Bis.js";
1
+ import { n as createReoptTermsClient, t as ReoptTermsClient } from "../client-VKEJtLH0.js";
2
2
 
3
3
  export { ReoptTermsClient, createReoptTermsClient };
@@ -1,5 +1,5 @@
1
- import { a as SeedAllInput, c as SeedPostGroupInput, d as SeedTermsItem, l as SeedPostInput, n as DevServer, o as SeedData, t as DevSchema } from "../index-C6fyJTud.js";
2
- import { t as ReoptSDK } from "../index-BnAYxnwq.js";
1
+ import { a as SeedAllInput, c as SeedPostGroupInput, d as SeedTermsItem, l as SeedPostInput, n as DevServer, o as SeedData, t as DevSchema } from "../index-Dh8XMVFF.js";
2
+ import { t as ReoptSDK } from "../index-Bkci7euU.js";
3
3
  //#region src/testing/index.d.ts
4
4
  type TestSDKOptions = {
5
5
  /** EAV schema to seed entities and attributes */
@@ -1,3 +1,4 @@
1
+ import { i as ClientPrivateJwk, r as ClientKeyRing } from "../keys-B2pA8EkU.js";
1
2
  import { z } from "zod";
2
3
  //#region src/workspace/schemas.d.ts
3
4
  /**
@@ -328,7 +329,14 @@ type PlatformBrandappUpsertInput = {
328
329
  /** 생략 = 유지. 주면 통째로 교체 */
329
330
  settings?: Record<string, unknown>;
330
331
  };
331
- declare const PLATFORM_TOKEN_ENDPOINT_AUTH_METHODS: readonly ["client_secret_post", "client_secret_basic", "none"];
332
+ declare const PLATFORM_TOKEN_ENDPOINT_AUTH_METHODS: readonly ["client_secret_post", "client_secret_basic", "private_key_jwt", "none"];
333
+ /**
334
+ * RFC-0034 §2.2 — 클라이언트 용도. 한 브랜드앱에 용도당 하나.
335
+ * - `web`: 사람 로그인(authorization_code) · `connect`: 사용자 위임 연동(동의 화면)
336
+ * - `adapter`: 원격 auth 어댑터 · `machine`: 서버 간 기계 호출 — 둘 다 `private_key_jwt` + DPoP 기본
337
+ */
338
+ declare const PLATFORM_OAUTH_CLIENT_PURPOSES: readonly ["web", "adapter", "machine", "connect"];
339
+ type PlatformOAuthClientPurpose = (typeof PLATFORM_OAUTH_CLIENT_PURPOSES)[number];
332
340
  declare const PLATFORM_OAUTH_GRANT_TYPES: readonly ["authorization_code", "refresh_token", "client_credentials"];
333
341
  declare const PLATFORM_OAUTH_APPLICATION_TYPES: readonly ["web", "native"];
334
342
  type PlatformOAuthClientResource = {
@@ -336,8 +344,14 @@ type PlatformOAuthClientResource = {
336
344
  key: string | null;
337
345
  clientId: string;
338
346
  name: string | null;
339
- /** 결속된 브랜드앱 slug(metadata.brandappId) — 없으면 플랫폼 API가 거절하는 클라이언트 */
347
+ /** 결속된 브랜드앱 slug(`brandappId` FK — RFC-0034 §6.4) — 없으면 플랫폼 API가 거절하는 클라이언트 */
340
348
  brandappSlug: string | null;
349
+ /** RFC-0034 §2.2 — null은 용도 분리 전 행 */
350
+ purpose: PlatformOAuthClientPurpose | null;
351
+ /** RFC-0034 §3.3 — `private_key_jwt` 클라이언트의 공개키 주소 */
352
+ jwksUri: string | null;
353
+ /** RFC-0034 §3 — 발급 토큰에 DPoP 바인딩을 요구하는가 */
354
+ dpopBoundAccessTokens: boolean;
341
355
  disabled: boolean;
342
356
  scopes: string[];
343
357
  clientCredentialsScopes: string[];
@@ -353,20 +367,29 @@ type PlatformOAuthClientResource = {
353
367
  managedBy: PlatformManagedBy | null;
354
368
  /**
355
369
  * 🔴 **생성·회전 응답에만** 실린다 — 서버는 해시만 저장하므로 다시 읽을 수 없다. CLI가 마스킹하거나
356
- * `--secrets-out`(0600)으로 쓴다.
370
+ * `--secrets-out`(0600)으로 쓴다. `private_key_jwt` 클라이언트에는 없다.
357
371
  */
358
372
  clientSecret?: string;
359
373
  };
360
374
  type PlatformOAuthClientUpsertInput = {
361
- /** 브랜드앱 slug — 워크스페이스·source 도출 축(metadata.brandappId) */
375
+ /** 브랜드앱 slug — 워크스페이스·source 도출 축(`brandappId` FK) */
362
376
  brandapp: string;
377
+ /** 생략 = 그랜트에서 추정(client_credentials만 → machine, 그 밖엔 web) */
378
+ purpose?: PlatformOAuthClientPurpose;
363
379
  name?: string;
364
380
  scopes: string[];
365
381
  grantTypes: string[];
366
382
  redirectUris?: string[];
367
383
  postLogoutRedirectUris?: string[];
368
- /** 생략 = 생성 시 client_secret_post / 갱신 시 유지. `none`은 public client(시크릿 없음) */
384
+ /**
385
+ * 생략 = 로그인 용도는 client_secret_post, 기계·어댑터 용도는 private_key_jwt.
386
+ * `none`은 public client(시크릿 없음). `private_key_jwt`면 `jwksUri` 필수.
387
+ */
369
388
  tokenEndpointAuthMethod?: (typeof PLATFORM_TOKEN_ENDPOINT_AUTH_METHODS)[number];
389
+ /** `private_key_jwt`의 공개키 주소(HTTPS) — 서브 제품이 `/.well-known/reopt-client-jwks.json`에 게시 */
390
+ jwksUri?: string;
391
+ /** 기계 토큰 DPoP 바인딩 — 기계·어댑터 용도 기본 true */
392
+ dpopBoundAccessTokens?: boolean;
370
393
  requirePKCE?: boolean;
371
394
  skipConsent?: boolean;
372
395
  enableEndSession?: boolean;
@@ -490,16 +513,23 @@ declare const platformResourcesV2Schema: z.ZodType<PlatformResourcesV2>;
490
513
  */
491
514
  declare const REOPT_PLATFORM_URLS: {
492
515
  readonly production: "https://platform.reopt.ai";
493
- readonly development: "https://platform.reopt.de:3443";
516
+ readonly development: "https://platform.local.reopt.io";
494
517
  };
495
518
  declare const REOPT_PLATFORM_ID_URLS: {
496
519
  readonly production: "https://id.reopt.ai";
497
- readonly development: "https://id.reopt.de:3443";
520
+ readonly development: "https://id.local.reopt.io";
498
521
  };
499
522
  declare const DEFAULT_PLATFORM_SCOPES: readonly ["works:read", "works:write"];
500
523
  type PlatformClientConfig = {
501
524
  clientId: string;
502
- clientSecret: string;
525
+ /**
526
+ * 공유 시크릿(client_secret_post) — RFC-0034 뒤에는 **PaC 부트스트랩 자격만** 이 길을 쓴다. 기계 클라이언트는
527
+ * `privateKeyJwk`/`keyRing`(또는 env `REOPT_CLIENT_PRIVATE_KEY_JWK`)로 private_key_jwt + DPoP를 쓴다.
528
+ */
529
+ clientSecret?: string;
530
+ /** RFC-0034 §3 — 비대칭 인증. 주면(또는 env에 있으면) clientSecret 없이 private_key_jwt + DPoP로 간다 */
531
+ privateKeyJwk?: ClientPrivateJwk;
532
+ keyRing?: ClientKeyRing;
503
533
  /** 플랫폼 API origin. 생략 시 `REOPT_PLATFORM_URL` env → `isProduction` 기본값 */
504
534
  platformUrl?: string;
505
535
  /** 토큰 발급(id 서버) origin. 생략 시 `REOPT_ID_BASE_URL` env → `isProduction` 기본값 */
@@ -620,5 +650,5 @@ type PlatformClient = {
620
650
  };
621
651
  declare function createPlatformClient(config: PlatformClientConfig): PlatformClient;
622
652
  //#endregion
623
- export { DEFAULT_PLATFORM_SCOPES, PLATFORM_ADMIN_SCOPE, PLATFORM_BRANDAPP_STATUSES, PLATFORM_DOMAIN_STATUSES, PLATFORM_MANAGED_BY_VALUES, PLATFORM_OAUTH_APPLICATION_TYPES, PLATFORM_OAUTH_GRANT_TYPES, PLATFORM_STAGE_COLORS, PLATFORM_TASK_OUTCOMES, PLATFORM_TASK_PRIORITIES, PLATFORM_TOKEN_ENDPOINT_AUTH_METHODS, PLATFORM_WEBHOOK_TRIGGERS, PlatformApiError, type PlatformBrandImportInput, type PlatformBrandResource, type PlatformBrandUpsertInput, type PlatformBrandappResource, type PlatformBrandappUpsertInput, type PlatformClient, type PlatformClientConfig, type PlatformCustomerUpsertInput, type PlatformDomainStatus, type PlatformEavBrandappResources, type PlatformEavEntityResource, type PlatformEavSchemaApplyInput, type PlatformEavSchemaApplyResult, type PlatformEavSchemaOperation, type PlatformErrorBody, type PlatformLockAcquired, type PlatformLockReleased, type PlatformManagedBy, type PlatformMe, type PlatformOAuthClientImportInput, type PlatformOAuthClientResource, type PlatformOAuthClientUpsertInput, type PlatformPipeline, type PlatformPipelineImportInput, type PlatformPipelineResource, type PlatformPipelineStageInput, type PlatformPipelineUpsertInput, type PlatformResources, type PlatformResourcesV2, type PlatformStageColor, type PlatformTask, type PlatformTaskOutcome, type PlatformTaskPriority, type PlatformTaskStage, type PlatformTaskStageInput, type PlatformTaskUpsertInput, type PlatformUrls, type PlatformWebhook, type PlatformWebhookResource, type PlatformWebhookTrigger, type PlatformWebhookUpsertInput, type PlatformWorkTaskStageChangedEvent, type PlatformWriteMeta, type PlatformWriteResult, 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 };
653
+ 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, type PlatformBrandImportInput, type PlatformBrandResource, type PlatformBrandUpsertInput, type PlatformBrandappResource, type PlatformBrandappUpsertInput, type PlatformClient, type PlatformClientConfig, type PlatformCustomerUpsertInput, type PlatformDomainStatus, type PlatformEavBrandappResources, type PlatformEavEntityResource, type PlatformEavSchemaApplyInput, type PlatformEavSchemaApplyResult, type PlatformEavSchemaOperation, type PlatformErrorBody, type PlatformLockAcquired, type PlatformLockReleased, type PlatformManagedBy, type PlatformMe, type PlatformOAuthClientImportInput, type PlatformOAuthClientPurpose, type PlatformOAuthClientResource, type PlatformOAuthClientUpsertInput, type PlatformPipeline, type PlatformPipelineImportInput, type PlatformPipelineResource, type PlatformPipelineStageInput, type PlatformPipelineUpsertInput, type PlatformResources, type PlatformResourcesV2, type PlatformStageColor, type PlatformTask, type PlatformTaskOutcome, type PlatformTaskPriority, type PlatformTaskStage, type PlatformTaskStageInput, type PlatformTaskUpsertInput, type PlatformUrls, type PlatformWebhook, type PlatformWebhookResource, type PlatformWebhookTrigger, type PlatformWebhookUpsertInput, type PlatformWorkTaskStageChangedEvent, type PlatformWriteMeta, type PlatformWriteResult, 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 };
624
654
  //# sourceMappingURL=index.d.ts.map
@@ -1,4 +1,6 @@
1
- import { n as SDK_VERSION } from "../config-BeOelISH.js";
1
+ import { n as SDK_VERSION } from "../config-Dy2oBn1a.js";
2
+ import { o as readClientKeyRing } from "../keys-B_R_lsyF.js";
3
+ import { r as createMachineClient } from "../client-C-LdW4gY.js";
2
4
  import { z } from "zod";
3
5
 
4
6
  //#region src/workspace/schemas.ts
@@ -240,8 +242,20 @@ const PLATFORM_BRANDAPP_STATUSES = [
240
242
  const PLATFORM_TOKEN_ENDPOINT_AUTH_METHODS = [
241
243
  "client_secret_post",
242
244
  "client_secret_basic",
245
+ "private_key_jwt",
243
246
  "none"
244
247
  ];
248
+ /**
249
+ * RFC-0034 §2.2 — 클라이언트 용도. 한 브랜드앱에 용도당 하나.
250
+ * - `web`: 사람 로그인(authorization_code) · `connect`: 사용자 위임 연동(동의 화면)
251
+ * - `adapter`: 원격 auth 어댑터 · `machine`: 서버 간 기계 호출 — 둘 다 `private_key_jwt` + DPoP 기본
252
+ */
253
+ const PLATFORM_OAUTH_CLIENT_PURPOSES = [
254
+ "web",
255
+ "adapter",
256
+ "machine",
257
+ "connect"
258
+ ];
245
259
  const PLATFORM_OAUTH_GRANT_TYPES = [
246
260
  "authorization_code",
247
261
  "refresh_token",
@@ -300,6 +314,9 @@ const platformBrandappResourceSchema = z.object({
300
314
  });
301
315
  const platformOAuthClientUpsertInputSchema = z.object({
302
316
  brandapp: platformResourceKeySchema,
317
+ purpose: z.enum(PLATFORM_OAUTH_CLIENT_PURPOSES).optional(),
318
+ jwksUri: z.url().max(500).startsWith("https://").optional(),
319
+ dpopBoundAccessTokens: z.boolean().optional(),
303
320
  name: z.string().trim().min(1).max(255).optional(),
304
321
  scopes: z.array(z.string().trim().min(1).max(64)).min(1).max(32),
305
322
  grantTypes: z.array(z.enum(PLATFORM_OAUTH_GRANT_TYPES)).min(1),
@@ -319,6 +336,9 @@ const platformOAuthClientResourceSchema = z.object({
319
336
  clientId: z.string(),
320
337
  name: z.string().nullable(),
321
338
  brandappSlug: z.string().nullable(),
339
+ purpose: z.enum(PLATFORM_OAUTH_CLIENT_PURPOSES).nullable(),
340
+ jwksUri: z.string().nullable(),
341
+ dpopBoundAccessTokens: z.boolean(),
322
342
  disabled: z.boolean(),
323
343
  scopes: z.array(z.string()),
324
344
  clientCredentialsScopes: z.array(z.string()),
@@ -440,11 +460,11 @@ const platformResourcesV2Schema = z.object({
440
460
  */
441
461
  const REOPT_PLATFORM_URLS = {
442
462
  production: "https://platform.reopt.ai",
443
- development: "https://platform.reopt.de:3443"
463
+ development: "https://platform.local.reopt.io"
444
464
  };
445
465
  const REOPT_PLATFORM_ID_URLS = {
446
466
  production: "https://id.reopt.ai",
447
- development: "https://id.reopt.de:3443"
467
+ development: "https://id.local.reopt.io"
448
468
  };
449
469
  const DEFAULT_PLATFORM_SCOPES = ["works:read", "works:write"];
450
470
  var PlatformApiError = class PlatformApiError extends Error {
@@ -484,19 +504,33 @@ function resolvePlatformUrls(config) {
484
504
  }
485
505
  function createPlatformClient(config) {
486
506
  assertServerRuntime();
487
- if (!config.clientId || !config.clientSecret) throw new Error("createPlatformClient: clientId and clientSecret are required");
507
+ if (!config.clientId) throw new Error("createPlatformClient: clientId is required");
488
508
  const { platformUrl, idBaseUrl } = resolvePlatformUrls(config);
489
509
  const scopes = config.scopes ?? DEFAULT_PLATFORM_SCOPES;
490
510
  const fetchImpl = config.fetch ?? globalThis.fetch;
491
511
  const timeoutMs = config.timeoutMs ?? 1e4;
492
512
  const nextRequestId = config.requestId ?? (() => crypto.randomUUID());
513
+ const keyRing = config.keyRing ?? (config.privateKeyJwk ? {
514
+ signing: config.privateKeyJwk,
515
+ published: [config.privateKeyJwk]
516
+ } : null) ?? (config.clientSecret ? null : readClientKeyRing());
517
+ const machine = keyRing ? createMachineClient({
518
+ clientId: config.clientId,
519
+ keyRing,
520
+ resource: platformUrl,
521
+ scopes,
522
+ idBaseUrl,
523
+ fetch: fetchImpl,
524
+ timeoutMs
525
+ }) : null;
526
+ if (!machine && !config.clientSecret) throw new Error("createPlatformClient: clientSecret or a private key (privateKeyJwk / REOPT_CLIENT_PRIVATE_KEY_JWK) is required");
493
527
  let token = null;
494
528
  let inflight = null;
495
529
  async function fetchToken() {
496
530
  const body = new URLSearchParams({
497
531
  grant_type: "client_credentials",
498
532
  client_id: config.clientId,
499
- client_secret: config.clientSecret,
533
+ client_secret: config.clientSecret ?? "",
500
534
  scope: scopes.join(" "),
501
535
  resource: platformUrl
502
536
  });
@@ -532,12 +566,19 @@ function createPlatformClient(config) {
532
566
  return token.accessToken;
533
567
  }
534
568
  async function request(method, path, options) {
535
- const accessToken = await getToken(options.retried === true);
569
+ const url = `${platformUrl}${path}`;
570
+ const authHeaders = machine ? await (async () => {
571
+ if (options.retried) machine.invalidateToken();
572
+ return machine.headers({
573
+ method,
574
+ url
575
+ });
576
+ })() : { authorization: `Bearer ${await getToken(options.retried === true)}` };
536
577
  const requestId = nextRequestId();
537
- const res = await fetchImpl(`${platformUrl}${path}`, {
578
+ const res = await fetchImpl(url, {
538
579
  method,
539
580
  headers: {
540
- authorization: `Bearer ${accessToken}`,
581
+ ...authHeaders,
541
582
  accept: "application/json",
542
583
  "x-request-id": requestId,
543
584
  "x-sdk-version": SDK_VERSION,
@@ -681,6 +722,7 @@ function createPlatformClient(config) {
681
722
  /** 테스트·진단용 — 캐시된 토큰을 버린다 */
682
723
  invalidateToken: () => {
683
724
  token = null;
725
+ machine?.invalidateToken();
684
726
  },
685
727
  urls: {
686
728
  platformUrl,
@@ -690,5 +732,5 @@ function createPlatformClient(config) {
690
732
  }
691
733
 
692
734
  //#endregion
693
- export { DEFAULT_PLATFORM_SCOPES, PLATFORM_ADMIN_SCOPE, PLATFORM_BRANDAPP_STATUSES, PLATFORM_DOMAIN_STATUSES, PLATFORM_MANAGED_BY_VALUES, PLATFORM_OAUTH_APPLICATION_TYPES, 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 };
735
+ 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 };
694
736
  //# sourceMappingURL=index.js.map