@reopt-ai/brandapp-sdk 3.1.0 → 3.3.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.
- package/CHANGELOG.md +80 -0
- package/README.md +29 -13
- package/dist/ai/index.js +4 -3
- package/dist/ai-provider/index.js +16 -2
- package/dist/auth/index.js +4 -3
- package/dist/better-auth/index.d.ts +1 -1
- package/dist/better-auth/index.js +35 -24
- package/dist/chunk-2LSCQHAU.js +21 -0
- package/dist/{chunk-IJOXTBIE.js → chunk-4U4ZPPL4.js} +4 -4
- package/dist/{chunk-RBHP7IZF.js → chunk-55KHY5GH.js} +3 -3
- package/dist/{chunk-MRQY45U5.js → chunk-C5VTRZWX.js} +21 -28
- package/dist/{chunk-2Q654O63.js → chunk-FJUCWXX3.js} +4 -4
- package/dist/{chunk-T7YTITRJ.js → chunk-H33OTQEN.js} +3 -3
- package/dist/{chunk-O3PUWIDJ.js → chunk-OG7R3UAR.js} +3 -3
- package/dist/{chunk-VRNBYSWU.js → chunk-PF24XU54.js} +3 -3
- package/dist/{chunk-R5CCGDUH.js → chunk-QN3QD67K.js} +3 -3
- package/dist/{chunk-JWXUVQRC.js → chunk-UGBBXCZE.js} +6 -6
- package/dist/{chunk-V73GORO3.js → chunk-UVT2E6KD.js} +6 -6
- package/dist/{chunk-POLKEOYH.js → chunk-YPLT3RFL.js} +3 -3
- package/dist/{chunk-N5JVE4WX.js → chunk-YTKSAWV2.js} +20 -6
- package/dist/cms/index.js +10 -6
- package/dist/dev/index.d.ts +19 -0
- package/dist/dev/index.js +107 -4
- package/dist/eav/index.d.ts +1 -1
- package/dist/eav/index.js +5 -4
- package/dist/{errors-DIAS8Rsl.d.ts → errors-BjDFIyA6.d.ts} +2 -2
- package/dist/feedback/index.js +4 -3
- package/dist/files/index.js +4 -3
- package/dist/index.d.ts +10 -1
- package/dist/index.js +14 -13
- package/dist/logout/index.d.ts +106 -0
- package/dist/logout/index.js +321 -0
- package/dist/plans/index.js +4 -3
- package/dist/push/index.js +4 -3
- package/dist/react/hooks.d.ts +5 -1
- package/dist/react/hooks.js +63 -15
- package/dist/terms/index.js +4 -3
- package/dist/testing/index.d.ts +1 -1
- package/dist/webhooks/index.d.ts +6 -3
- package/docs/api-reference.md +98 -2
- package/docs/dev-server.md +19 -18
- package/docs/errors.md +72 -15
- package/docs/logout.md +166 -0
- package/package.json +5 -1
|
@@ -0,0 +1,321 @@
|
|
|
1
|
+
import { resolveIdBaseUrl, ReoptSDKError } from '../chunk-C5VTRZWX.js';
|
|
2
|
+
|
|
3
|
+
// src/logout/verify.ts
|
|
4
|
+
var BACKCHANNEL_LOGOUT_EVENT = "http://schemas.openid.net/event/backchannel-logout";
|
|
5
|
+
var JWKS_CACHE_TTL_MS = 10 * 60 * 1e3;
|
|
6
|
+
var DEFAULT_MAX_TOKEN_AGE_MS = 5 * 60 * 1e3;
|
|
7
|
+
var VERIFICATION_FETCH_TIMEOUT_MS = 5 * 1e3;
|
|
8
|
+
var JWKS_MIN_FORCED_REFETCH_INTERVAL_MS = 30 * 1e3;
|
|
9
|
+
var jwksCache = /* @__PURE__ */ new Map();
|
|
10
|
+
var jwksInflight = /* @__PURE__ */ new Map();
|
|
11
|
+
var jwksLastForcedRefetch = /* @__PURE__ */ new Map();
|
|
12
|
+
var discoveryCache = /* @__PURE__ */ new Map();
|
|
13
|
+
function base64UrlDecode(input) {
|
|
14
|
+
const pad = input.length % 4 === 0 ? "" : "=".repeat(4 - input.length % 4);
|
|
15
|
+
const base64 = (input + pad).replace(/-/g, "+").replace(/_/g, "/");
|
|
16
|
+
const binary = atob(base64);
|
|
17
|
+
const bytes = new Uint8Array(binary.length);
|
|
18
|
+
for (let i = 0; i < binary.length; i++) bytes[i] = binary.charCodeAt(i);
|
|
19
|
+
return bytes;
|
|
20
|
+
}
|
|
21
|
+
function decodeJson(segment) {
|
|
22
|
+
return JSON.parse(new TextDecoder().decode(base64UrlDecode(segment)));
|
|
23
|
+
}
|
|
24
|
+
function fail(message, cause) {
|
|
25
|
+
throw new ReoptSDKError(message, 400, "invalid_logout_token", void 0, {
|
|
26
|
+
cause,
|
|
27
|
+
fix: "reopt\uAC00 \uBCF4\uB0B8 logout_token\uB9CC \uC774 \uD578\uB4E4\uB7EC\uB85C \uC804\uB2EC\uB418\uB294\uC9C0, client_id\xB7idBaseUrl \uC124\uC815\uC774 \uB9DE\uB294\uC9C0 \uD655\uC778\uD558\uC138\uC694.",
|
|
28
|
+
doc: "logout.md"
|
|
29
|
+
});
|
|
30
|
+
}
|
|
31
|
+
function failUnavailable(message, cause) {
|
|
32
|
+
throw new ReoptSDKError(
|
|
33
|
+
message,
|
|
34
|
+
503,
|
|
35
|
+
"logout_verification_unavailable",
|
|
36
|
+
void 0,
|
|
37
|
+
{
|
|
38
|
+
cause,
|
|
39
|
+
fix: "reopt IdP\uC758 discovery/JWKS \uC5D4\uB4DC\uD3EC\uC778\uD2B8\uAC00 \uC77C\uC2DC\uC801\uC73C\uB85C \uC751\uB2F5\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4. \uC7A0\uC2DC \uD6C4 \uC7AC\uC2DC\uB3C4\uD558\uC138\uC694.",
|
|
40
|
+
doc: "logout.md"
|
|
41
|
+
}
|
|
42
|
+
);
|
|
43
|
+
}
|
|
44
|
+
async function fetchDiscovery(idBaseUrl) {
|
|
45
|
+
const cached = discoveryCache.get(idBaseUrl);
|
|
46
|
+
if (cached && Date.now() - cached.fetchedAt < JWKS_CACHE_TTL_MS) {
|
|
47
|
+
return { issuer: cached.issuer, jwksUri: cached.jwksUri };
|
|
48
|
+
}
|
|
49
|
+
const discoveryUrl = `${idBaseUrl}/api/auth/.well-known/openid-configuration`;
|
|
50
|
+
let res;
|
|
51
|
+
try {
|
|
52
|
+
res = await fetch(discoveryUrl, {
|
|
53
|
+
cache: "no-store",
|
|
54
|
+
signal: AbortSignal.timeout(VERIFICATION_FETCH_TIMEOUT_MS)
|
|
55
|
+
});
|
|
56
|
+
} catch (error) {
|
|
57
|
+
failUnavailable(
|
|
58
|
+
"OIDC discovery\uB97C \uBD88\uB7EC\uC624\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4.",
|
|
59
|
+
`discovery fetch \uC2E4\uD328: ${String(error)}`
|
|
60
|
+
);
|
|
61
|
+
}
|
|
62
|
+
if (!res.ok) {
|
|
63
|
+
failUnavailable(
|
|
64
|
+
"OIDC discovery \uC751\uB2F5\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.",
|
|
65
|
+
`discovery HTTP ${res.status}`
|
|
66
|
+
);
|
|
67
|
+
}
|
|
68
|
+
const doc = await res.json();
|
|
69
|
+
if (!doc.issuer || !doc.jwks_uri) {
|
|
70
|
+
failUnavailable(
|
|
71
|
+
"OIDC discovery\uC5D0 issuer/jwks_uri\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.",
|
|
72
|
+
"discovery \uD544\uB4DC \uB204\uB77D"
|
|
73
|
+
);
|
|
74
|
+
}
|
|
75
|
+
discoveryCache.set(idBaseUrl, {
|
|
76
|
+
issuer: doc.issuer,
|
|
77
|
+
jwksUri: doc.jwks_uri,
|
|
78
|
+
fetchedAt: Date.now()
|
|
79
|
+
});
|
|
80
|
+
return { issuer: doc.issuer, jwksUri: doc.jwks_uri };
|
|
81
|
+
}
|
|
82
|
+
async function fetchJwks(jwksUri, forceRefresh) {
|
|
83
|
+
const cached = jwksCache.get(jwksUri);
|
|
84
|
+
const now = Date.now();
|
|
85
|
+
if (!forceRefresh && cached && now - cached.fetchedAt < JWKS_CACHE_TTL_MS) {
|
|
86
|
+
return cached.keys;
|
|
87
|
+
}
|
|
88
|
+
const inflight = jwksInflight.get(jwksUri);
|
|
89
|
+
if (inflight) return inflight;
|
|
90
|
+
if (forceRefresh && cached) {
|
|
91
|
+
const lastForced = jwksLastForcedRefetch.get(jwksUri) ?? 0;
|
|
92
|
+
if (now - lastForced < JWKS_MIN_FORCED_REFETCH_INTERVAL_MS) {
|
|
93
|
+
return cached.keys;
|
|
94
|
+
}
|
|
95
|
+
}
|
|
96
|
+
if (forceRefresh) jwksLastForcedRefetch.set(jwksUri, now);
|
|
97
|
+
const promise = fetchJwksUncached(jwksUri).finally(() => {
|
|
98
|
+
jwksInflight.delete(jwksUri);
|
|
99
|
+
});
|
|
100
|
+
jwksInflight.set(jwksUri, promise);
|
|
101
|
+
return promise;
|
|
102
|
+
}
|
|
103
|
+
async function fetchJwksUncached(jwksUri) {
|
|
104
|
+
let res;
|
|
105
|
+
try {
|
|
106
|
+
res = await fetch(jwksUri, {
|
|
107
|
+
cache: "no-store",
|
|
108
|
+
signal: AbortSignal.timeout(VERIFICATION_FETCH_TIMEOUT_MS)
|
|
109
|
+
});
|
|
110
|
+
} catch (error) {
|
|
111
|
+
failUnavailable(
|
|
112
|
+
"JWKS\uB97C \uBD88\uB7EC\uC624\uC9C0 \uBABB\uD588\uC2B5\uB2C8\uB2E4.",
|
|
113
|
+
`jwks fetch \uC2E4\uD328: ${String(error)}`
|
|
114
|
+
);
|
|
115
|
+
}
|
|
116
|
+
if (!res.ok) {
|
|
117
|
+
failUnavailable(
|
|
118
|
+
"JWKS \uC751\uB2F5\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.",
|
|
119
|
+
`jwks HTTP ${res.status}`
|
|
120
|
+
);
|
|
121
|
+
}
|
|
122
|
+
const doc = await res.json();
|
|
123
|
+
const keys = (doc.keys ?? []).filter(
|
|
124
|
+
(k) => k.kty === "OKP" && k.crv === "Ed25519" && typeof k.x === "string"
|
|
125
|
+
);
|
|
126
|
+
jwksCache.set(jwksUri, { keys, fetchedAt: Date.now(), jwksUri });
|
|
127
|
+
return keys;
|
|
128
|
+
}
|
|
129
|
+
async function verifyEd25519(jwk, signingInput, signature) {
|
|
130
|
+
try {
|
|
131
|
+
const key = await crypto.subtle.importKey(
|
|
132
|
+
"jwk",
|
|
133
|
+
{ kty: jwk.kty, crv: jwk.crv, x: jwk.x },
|
|
134
|
+
{ name: "Ed25519" },
|
|
135
|
+
false,
|
|
136
|
+
["verify"]
|
|
137
|
+
);
|
|
138
|
+
return await crypto.subtle.verify(
|
|
139
|
+
{ name: "Ed25519" },
|
|
140
|
+
key,
|
|
141
|
+
// TS 5.7의 Uint8Array<ArrayBufferLike>는 BufferSource와 직접 호환되지
|
|
142
|
+
// 않아 캐스팅한다(런타임 값은 표준 Uint8Array).
|
|
143
|
+
signature,
|
|
144
|
+
new TextEncoder().encode(signingInput)
|
|
145
|
+
);
|
|
146
|
+
} catch {
|
|
147
|
+
return false;
|
|
148
|
+
}
|
|
149
|
+
}
|
|
150
|
+
async function verifyBackchannelLogoutToken(logoutToken, options = {}) {
|
|
151
|
+
const config = options.config ?? {};
|
|
152
|
+
const clientId = options.clientId ?? config.clientId ?? (typeof process !== "undefined" ? process.env?.BRANDAPP_CLIENT_ID : void 0);
|
|
153
|
+
if (!clientId) {
|
|
154
|
+
fail(
|
|
155
|
+
"client_id\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4.",
|
|
156
|
+
"clientId \uBBF8\uC124\uC815 \u2014 options.clientId \uB610\uB294 BRANDAPP_CLIENT_ID env \uD544\uC694"
|
|
157
|
+
);
|
|
158
|
+
}
|
|
159
|
+
const idBaseUrl = (options.idBaseUrl ?? resolveIdBaseUrl(config)).replace(
|
|
160
|
+
/\/$/,
|
|
161
|
+
""
|
|
162
|
+
);
|
|
163
|
+
const parts = logoutToken.split(".");
|
|
164
|
+
if (parts.length !== 3) {
|
|
165
|
+
fail("logout_token \uD615\uC2DD\uC774 \uC62C\uBC14\uB974\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.", "JWT \uC138\uADF8\uBA3C\uD2B8 \uAC1C\uC218 \uC624\uB958");
|
|
166
|
+
}
|
|
167
|
+
const [headerB64, payloadB64, sigB64] = parts;
|
|
168
|
+
let header;
|
|
169
|
+
let payload;
|
|
170
|
+
try {
|
|
171
|
+
header = decodeJson(headerB64);
|
|
172
|
+
payload = decodeJson(payloadB64);
|
|
173
|
+
} catch {
|
|
174
|
+
fail("logout_token \uB514\uCF54\uB4DC\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.", "base64url/JSON \uD30C\uC2F1 \uC624\uB958");
|
|
175
|
+
}
|
|
176
|
+
if (header.alg !== "EdDSA") {
|
|
177
|
+
fail(
|
|
178
|
+
"\uC9C0\uC6D0\uD558\uC9C0 \uC54A\uB294 \uC11C\uBA85 \uC54C\uACE0\uB9AC\uC998\uC785\uB2C8\uB2E4.",
|
|
179
|
+
`alg=${header.alg ?? "none"} (EdDSA\uB9CC \uD5C8\uC6A9)`
|
|
180
|
+
);
|
|
181
|
+
}
|
|
182
|
+
const { issuer, jwksUri } = await fetchDiscovery(idBaseUrl);
|
|
183
|
+
const signature = base64UrlDecode(sigB64);
|
|
184
|
+
const signingInput = `${headerB64}.${payloadB64}`;
|
|
185
|
+
const tryVerify = async (forceRefresh) => {
|
|
186
|
+
const keys = await fetchJwks(jwksUri, forceRefresh);
|
|
187
|
+
const candidates = header.kid ? keys.filter((k) => k.kid === header.kid) : keys;
|
|
188
|
+
const pool = candidates.length > 0 ? candidates : keys;
|
|
189
|
+
for (const jwk of pool) {
|
|
190
|
+
if (await verifyEd25519(jwk, signingInput, signature)) return true;
|
|
191
|
+
}
|
|
192
|
+
return false;
|
|
193
|
+
};
|
|
194
|
+
let verified = await tryVerify(false);
|
|
195
|
+
if (!verified) verified = await tryVerify(true);
|
|
196
|
+
if (!verified) {
|
|
197
|
+
fail("logout_token \uC11C\uBA85 \uAC80\uC99D\uC5D0 \uC2E4\uD328\uD588\uC2B5\uB2C8\uB2E4.", "\uC11C\uBA85 \uBD88\uC77C\uCE58 \uB610\uB294 \uD0A4 \uC5C6\uC74C");
|
|
198
|
+
}
|
|
199
|
+
if (payload.iss !== issuer) {
|
|
200
|
+
fail("issuer\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.", `iss=${payload.iss} != ${issuer}`);
|
|
201
|
+
}
|
|
202
|
+
const aud = Array.isArray(payload.aud) ? payload.aud : payload.aud ? [payload.aud] : [];
|
|
203
|
+
if (!aud.includes(clientId)) {
|
|
204
|
+
fail("audience\uAC00 \uC77C\uCE58\uD558\uC9C0 \uC54A\uC2B5\uB2C8\uB2E4.", "aud\uC5D0 client_id \uC5C6\uC74C");
|
|
205
|
+
}
|
|
206
|
+
if (typeof payload.iat !== "number") {
|
|
207
|
+
fail("iat\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.", "iat \uD074\uB808\uC784 \uB204\uB77D");
|
|
208
|
+
}
|
|
209
|
+
const maxAge = options.maxTokenAgeMs ?? DEFAULT_MAX_TOKEN_AGE_MS;
|
|
210
|
+
if (Date.now() - payload.iat * 1e3 > maxAge) {
|
|
211
|
+
fail("logout_token\uC774 \uB9CC\uB8CC\uB418\uC5C8\uC2B5\uB2C8\uB2E4.", "iat\uAC00 \uD5C8\uC6A9 \uB098\uC774\uB97C \uCD08\uACFC");
|
|
212
|
+
}
|
|
213
|
+
if (payload.exp && Date.now() > payload.exp * 1e3) {
|
|
214
|
+
fail("logout_token\uC774 \uB9CC\uB8CC\uB418\uC5C8\uC2B5\uB2C8\uB2E4(exp).", "exp \uACBD\uACFC");
|
|
215
|
+
}
|
|
216
|
+
if (payload.nonce !== void 0) {
|
|
217
|
+
fail("logout_token\uC5D0 nonce\uAC00 \uC788\uC73C\uBA74 \uC548 \uB429\uB2C8\uB2E4.", "nonce \uD074\uB808\uC784 \uC874\uC7AC");
|
|
218
|
+
}
|
|
219
|
+
const hasEvent = !!payload.events && Object.prototype.hasOwnProperty.call(
|
|
220
|
+
payload.events,
|
|
221
|
+
BACKCHANNEL_LOGOUT_EVENT
|
|
222
|
+
);
|
|
223
|
+
if (!hasEvent) {
|
|
224
|
+
fail(
|
|
225
|
+
"back-channel logout \uC774\uBCA4\uD2B8\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.",
|
|
226
|
+
"events\uC5D0 backchannel-logout \uBA64\uBC84 \uC5C6\uC74C"
|
|
227
|
+
);
|
|
228
|
+
}
|
|
229
|
+
if (!payload.sid && !payload.sub) {
|
|
230
|
+
fail("sid \uB610\uB294 sub\uAC00 \uD544\uC694\uD569\uB2C8\uB2E4.", "sid/sub \uBAA8\uB450 \uC5C6\uC74C");
|
|
231
|
+
}
|
|
232
|
+
if (!payload.sid) {
|
|
233
|
+
fail("sid\uAC00 \uC5C6\uC2B5\uB2C8\uB2E4.", "reopt logout_token\uC740 sid \uD544\uC218");
|
|
234
|
+
}
|
|
235
|
+
return {
|
|
236
|
+
sid: payload.sid,
|
|
237
|
+
sub: payload.sub,
|
|
238
|
+
iss: issuer,
|
|
239
|
+
aud
|
|
240
|
+
};
|
|
241
|
+
}
|
|
242
|
+
function clearLogoutTokenCaches() {
|
|
243
|
+
jwksCache.clear();
|
|
244
|
+
jwksInflight.clear();
|
|
245
|
+
jwksLastForcedRefetch.clear();
|
|
246
|
+
discoveryCache.clear();
|
|
247
|
+
}
|
|
248
|
+
|
|
249
|
+
// src/logout/handler.ts
|
|
250
|
+
function response(body, status) {
|
|
251
|
+
return new Response(JSON.stringify(body), {
|
|
252
|
+
status,
|
|
253
|
+
headers: {
|
|
254
|
+
"Content-Type": "application/json",
|
|
255
|
+
"Cache-Control": "no-store"
|
|
256
|
+
}
|
|
257
|
+
});
|
|
258
|
+
}
|
|
259
|
+
function createBackchannelLogoutHandler(config) {
|
|
260
|
+
return async (request) => {
|
|
261
|
+
if (request.method !== "POST") {
|
|
262
|
+
return response({ error: "Method not allowed" }, 405);
|
|
263
|
+
}
|
|
264
|
+
let logoutToken = null;
|
|
265
|
+
try {
|
|
266
|
+
const form = await request.formData();
|
|
267
|
+
const value = form.get("logout_token");
|
|
268
|
+
logoutToken = typeof value === "string" ? value : null;
|
|
269
|
+
} catch {
|
|
270
|
+
return response({ error: "invalid_request" }, 400);
|
|
271
|
+
}
|
|
272
|
+
if (!logoutToken) {
|
|
273
|
+
return response({ error: "invalid_request" }, 400);
|
|
274
|
+
}
|
|
275
|
+
let claims;
|
|
276
|
+
try {
|
|
277
|
+
claims = await verifyBackchannelLogoutToken(logoutToken, {
|
|
278
|
+
clientId: config.clientId,
|
|
279
|
+
idBaseUrl: config.idBaseUrl,
|
|
280
|
+
config: config.config,
|
|
281
|
+
maxTokenAgeMs: config.maxTokenAgeMs
|
|
282
|
+
});
|
|
283
|
+
} catch (error) {
|
|
284
|
+
if (error instanceof ReoptSDKError && error.status >= 500) {
|
|
285
|
+
return response({ error: error.code }, 503);
|
|
286
|
+
}
|
|
287
|
+
const code = error instanceof ReoptSDKError ? error.code : "invalid_logout_token";
|
|
288
|
+
return response({ error: code }, 400);
|
|
289
|
+
}
|
|
290
|
+
try {
|
|
291
|
+
await config.onLogout(claims);
|
|
292
|
+
} catch {
|
|
293
|
+
return response({ error: "logout_processing_failed" }, 501);
|
|
294
|
+
}
|
|
295
|
+
return response({ ok: true }, 200);
|
|
296
|
+
};
|
|
297
|
+
}
|
|
298
|
+
|
|
299
|
+
// src/logout/end-session.ts
|
|
300
|
+
function buildEndSessionUrl(options) {
|
|
301
|
+
const idBaseUrl = (options.idBaseUrl ?? resolveIdBaseUrl(options.config ?? {})).replace(/\/$/, "");
|
|
302
|
+
const url = new URL(`${idBaseUrl}/api/auth/oauth2/end-session`);
|
|
303
|
+
url.searchParams.set("id_token_hint", options.idToken);
|
|
304
|
+
if (options.clientId) {
|
|
305
|
+
url.searchParams.set("client_id", options.clientId);
|
|
306
|
+
}
|
|
307
|
+
if (options.postLogoutRedirectUri) {
|
|
308
|
+
url.searchParams.set(
|
|
309
|
+
"post_logout_redirect_uri",
|
|
310
|
+
options.postLogoutRedirectUri
|
|
311
|
+
);
|
|
312
|
+
}
|
|
313
|
+
if (options.state) {
|
|
314
|
+
url.searchParams.set("state", options.state);
|
|
315
|
+
}
|
|
316
|
+
return url.toString();
|
|
317
|
+
}
|
|
318
|
+
|
|
319
|
+
export { buildEndSessionUrl, clearLogoutTokenCaches, createBackchannelLogoutHandler, verifyBackchannelLogoutToken };
|
|
320
|
+
//# sourceMappingURL=index.js.map
|
|
321
|
+
//# sourceMappingURL=index.js.map
|
package/dist/plans/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { ReoptPlansClient, createReoptPlansClient } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
export { ReoptPlansClient, createReoptPlansClient } from '../chunk-OG7R3UAR.js';
|
|
2
|
+
import '../chunk-YTKSAWV2.js';
|
|
3
|
+
import '../chunk-2LSCQHAU.js';
|
|
4
|
+
import '../chunk-C5VTRZWX.js';
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
package/dist/push/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { ReoptPushClient, createReoptPushClient } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
export { ReoptPushClient, createReoptPushClient } from '../chunk-QN3QD67K.js';
|
|
2
|
+
import '../chunk-YTKSAWV2.js';
|
|
3
|
+
import '../chunk-2LSCQHAU.js';
|
|
4
|
+
import '../chunk-C5VTRZWX.js';
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
package/dist/react/hooks.d.ts
CHANGED
|
@@ -2,7 +2,7 @@ import * as _tanstack_react_query from '@tanstack/react-query';
|
|
|
2
2
|
import { UseQueryOptions, UseMutationOptions, UseInfiniteQueryOptions } from '@tanstack/react-query';
|
|
3
3
|
import { ReoptSDK } from '../index.js';
|
|
4
4
|
import { StreamDoneData, CompletionOptions, AgentInfo, CompletionResult, CreditInfo, ImageGenerateResult, ImageGenerateOptions, ModelInfo } from '../ai/index.js';
|
|
5
|
-
import { g as ReoptSDKError } from '../errors-
|
|
5
|
+
import { g as ReoptSDKError } from '../errors-BjDFIyA6.js';
|
|
6
6
|
import { L as ListRecordsQuery, m as EavRecord, g as CreateRecordInput, d as BulkUpdateItem, i as DeleteWhereInput, l as EavEntity, P as PaginatedResponse, s as UpdateRecordInput, u as UpsertRecordResult, t as UpsertRecordInput } from '../config-CtxyJsDR.js';
|
|
7
7
|
import { a as ListPostsQuery, L as ListPostGroupsQuery, b as ListTagsQuery, T as Tag, c as PostDetail, d as PostGroup, C as CmsPaginatedResponse, P as Post } from '../types-ckmDDW3N.js';
|
|
8
8
|
import { a as FileListQuery, F as FileInfo, b as FileListResponse, U as UploadOptions } from '../client-CN5_tNOC.js';
|
|
@@ -45,8 +45,12 @@ declare const keys: {
|
|
|
45
45
|
entities: (brandappId?: string) => readonly ["reopt", "entities", string | undefined];
|
|
46
46
|
entity: (entityId: string) => readonly ["reopt", "entity", string];
|
|
47
47
|
records: (entityId: string, query?: ListRecordsQuery) => readonly ["reopt", "records", string, ListRecordsQuery | undefined];
|
|
48
|
+
recordsInfinite: (entityId: string, query?: ListRecordsQuery) => readonly ["reopt", "recordsInfinite", string, ListRecordsQuery | undefined];
|
|
48
49
|
record: (entityId: string, recordId: string) => readonly ["reopt", "record", string, string];
|
|
49
50
|
recordCount: (entityId: string, query?: Pick<ListRecordsQuery, "filters" | "authUserId">) => readonly ["reopt", "recordCount", string, Pick<ListRecordsQuery, "filters" | "authUserId"> | undefined];
|
|
51
|
+
recordsPrefix: (entityId: string) => readonly ["reopt", "records", string];
|
|
52
|
+
recordsInfinitePrefix: (entityId: string) => readonly ["reopt", "recordsInfinite", string];
|
|
53
|
+
recordCountPrefix: (entityId: string) => readonly ["reopt", "recordCount", string];
|
|
50
54
|
aiCredits: (brandappId?: string) => readonly ["reopt", "ai", "credits", string | undefined];
|
|
51
55
|
aiModels: (brandappId?: string) => readonly ["reopt", "ai", "models", string | undefined];
|
|
52
56
|
aiAgents: (brandappId?: string) => readonly ["reopt", "ai", "agents", string | undefined];
|
package/dist/react/hooks.js
CHANGED
|
@@ -109,8 +109,20 @@ var keys = {
|
|
|
109
109
|
entities: (brandappId) => [...keys.all, "entities", brandappId],
|
|
110
110
|
entity: (entityId) => [...keys.all, "entity", entityId],
|
|
111
111
|
records: (entityId, query) => [...keys.all, "records", entityId, query],
|
|
112
|
+
// Infinite lists get a DISTINCT namespace: in TanStack v5 useQuery and
|
|
113
|
+
// useInfiniteQuery share one QueryCache keyed by queryHash, so a shared key
|
|
114
|
+
// would collide (PaginatedResponse vs InfiniteData) if both hooks mount for
|
|
115
|
+
// the same entity+query.
|
|
116
|
+
recordsInfinite: (entityId, query) => [...keys.all, "recordsInfinite", entityId, query],
|
|
112
117
|
record: (entityId, recordId) => [...keys.all, "record", entityId, recordId],
|
|
113
118
|
recordCount: (entityId, query) => [...keys.all, "recordCount", entityId, query],
|
|
119
|
+
// Length-3 invalidation prefixes. partialMatchKey only prefix-matches a
|
|
120
|
+
// SHORTER key, so `keys.records(entityId)` (trailing `undefined`) fails to
|
|
121
|
+
// match a list queried WITH a query object. These match every finite /
|
|
122
|
+
// infinite record list + count for an entity regardless of its query object.
|
|
123
|
+
recordsPrefix: (entityId) => [...keys.all, "records", entityId],
|
|
124
|
+
recordsInfinitePrefix: (entityId) => [...keys.all, "recordsInfinite", entityId],
|
|
125
|
+
recordCountPrefix: (entityId) => [...keys.all, "recordCount", entityId],
|
|
114
126
|
aiCredits: (brandappId) => [...keys.all, "ai", "credits", brandappId],
|
|
115
127
|
aiModels: (brandappId) => [...keys.all, "ai", "models", brandappId],
|
|
116
128
|
aiAgents: (brandappId) => [...keys.all, "ai", "agents", brandappId],
|
|
@@ -150,7 +162,7 @@ function useEavRecords(sdk, entityId, query, options) {
|
|
|
150
162
|
}
|
|
151
163
|
function useEavRecordsInfinite(sdk, entityId, query, options) {
|
|
152
164
|
return useInfiniteQuery({
|
|
153
|
-
queryKey: keys.
|
|
165
|
+
queryKey: keys.recordsInfinite(entityId, query),
|
|
154
166
|
queryFn: ({ pageParam }) => sdk.eav.records.list(entityId, { ...query, page: pageParam }),
|
|
155
167
|
initialPageParam: 1,
|
|
156
168
|
getNextPageParam: (lastPage) => lastPage.page < lastPage.totalPages ? lastPage.page + 1 : void 0,
|
|
@@ -179,8 +191,13 @@ function useCreateRecord(sdk, entityId, options) {
|
|
|
179
191
|
return useMutation({
|
|
180
192
|
mutationFn: (input) => sdk.eav.records.create(entityId, input),
|
|
181
193
|
onSuccess: () => {
|
|
182
|
-
queryClient.invalidateQueries({ queryKey: keys.
|
|
183
|
-
queryClient.invalidateQueries({
|
|
194
|
+
queryClient.invalidateQueries({ queryKey: keys.recordsPrefix(entityId) });
|
|
195
|
+
queryClient.invalidateQueries({
|
|
196
|
+
queryKey: keys.recordsInfinitePrefix(entityId)
|
|
197
|
+
});
|
|
198
|
+
queryClient.invalidateQueries({
|
|
199
|
+
queryKey: keys.recordCountPrefix(entityId)
|
|
200
|
+
});
|
|
184
201
|
},
|
|
185
202
|
...options
|
|
186
203
|
});
|
|
@@ -193,7 +210,10 @@ function useUpdateRecord(sdk, entityId, options) {
|
|
|
193
210
|
input
|
|
194
211
|
}) => sdk.eav.records.update(entityId, recordId, input),
|
|
195
212
|
onSuccess: (_, variables) => {
|
|
196
|
-
queryClient.invalidateQueries({ queryKey: keys.
|
|
213
|
+
queryClient.invalidateQueries({ queryKey: keys.recordsPrefix(entityId) });
|
|
214
|
+
queryClient.invalidateQueries({
|
|
215
|
+
queryKey: keys.recordsInfinitePrefix(entityId)
|
|
216
|
+
});
|
|
197
217
|
queryClient.invalidateQueries({
|
|
198
218
|
queryKey: keys.record(entityId, variables.recordId)
|
|
199
219
|
});
|
|
@@ -206,8 +226,13 @@ function useDeleteRecord(sdk, entityId, options) {
|
|
|
206
226
|
return useMutation({
|
|
207
227
|
mutationFn: (recordId) => sdk.eav.records.delete(entityId, recordId),
|
|
208
228
|
onSuccess: () => {
|
|
209
|
-
queryClient.invalidateQueries({ queryKey: keys.
|
|
210
|
-
queryClient.invalidateQueries({
|
|
229
|
+
queryClient.invalidateQueries({ queryKey: keys.recordsPrefix(entityId) });
|
|
230
|
+
queryClient.invalidateQueries({
|
|
231
|
+
queryKey: keys.recordsInfinitePrefix(entityId)
|
|
232
|
+
});
|
|
233
|
+
queryClient.invalidateQueries({
|
|
234
|
+
queryKey: keys.recordCountPrefix(entityId)
|
|
235
|
+
});
|
|
211
236
|
},
|
|
212
237
|
...options
|
|
213
238
|
});
|
|
@@ -217,8 +242,13 @@ function useUpsertRecord(sdk, entityId, options) {
|
|
|
217
242
|
return useMutation({
|
|
218
243
|
mutationFn: (input) => sdk.eav.records.upsert(entityId, input),
|
|
219
244
|
onSuccess: () => {
|
|
220
|
-
queryClient.invalidateQueries({ queryKey: keys.
|
|
221
|
-
queryClient.invalidateQueries({
|
|
245
|
+
queryClient.invalidateQueries({ queryKey: keys.recordsPrefix(entityId) });
|
|
246
|
+
queryClient.invalidateQueries({
|
|
247
|
+
queryKey: keys.recordsInfinitePrefix(entityId)
|
|
248
|
+
});
|
|
249
|
+
queryClient.invalidateQueries({
|
|
250
|
+
queryKey: keys.recordCountPrefix(entityId)
|
|
251
|
+
});
|
|
222
252
|
},
|
|
223
253
|
...options
|
|
224
254
|
});
|
|
@@ -228,8 +258,13 @@ function useBulkCreateRecords(sdk, entityId, options) {
|
|
|
228
258
|
return useMutation({
|
|
229
259
|
mutationFn: (records) => sdk.eav.records.bulkCreate(entityId, records),
|
|
230
260
|
onSuccess: () => {
|
|
231
|
-
queryClient.invalidateQueries({ queryKey: keys.
|
|
232
|
-
queryClient.invalidateQueries({
|
|
261
|
+
queryClient.invalidateQueries({ queryKey: keys.recordsPrefix(entityId) });
|
|
262
|
+
queryClient.invalidateQueries({
|
|
263
|
+
queryKey: keys.recordsInfinitePrefix(entityId)
|
|
264
|
+
});
|
|
265
|
+
queryClient.invalidateQueries({
|
|
266
|
+
queryKey: keys.recordCountPrefix(entityId)
|
|
267
|
+
});
|
|
233
268
|
},
|
|
234
269
|
...options
|
|
235
270
|
});
|
|
@@ -239,7 +274,10 @@ function useBulkUpdateRecords(sdk, entityId, options) {
|
|
|
239
274
|
return useMutation({
|
|
240
275
|
mutationFn: (updates) => sdk.eav.records.bulkUpdate(entityId, updates),
|
|
241
276
|
onSuccess: (_data, variables) => {
|
|
242
|
-
queryClient.invalidateQueries({ queryKey: keys.
|
|
277
|
+
queryClient.invalidateQueries({ queryKey: keys.recordsPrefix(entityId) });
|
|
278
|
+
queryClient.invalidateQueries({
|
|
279
|
+
queryKey: keys.recordsInfinitePrefix(entityId)
|
|
280
|
+
});
|
|
243
281
|
for (const { id } of variables) {
|
|
244
282
|
queryClient.invalidateQueries({
|
|
245
283
|
queryKey: keys.record(entityId, id)
|
|
@@ -254,8 +292,13 @@ function useBulkDeleteRecords(sdk, entityId, options) {
|
|
|
254
292
|
return useMutation({
|
|
255
293
|
mutationFn: (ids) => sdk.eav.records.bulkDelete(entityId, ids),
|
|
256
294
|
onSuccess: () => {
|
|
257
|
-
queryClient.invalidateQueries({ queryKey: keys.
|
|
258
|
-
queryClient.invalidateQueries({
|
|
295
|
+
queryClient.invalidateQueries({ queryKey: keys.recordsPrefix(entityId) });
|
|
296
|
+
queryClient.invalidateQueries({
|
|
297
|
+
queryKey: keys.recordsInfinitePrefix(entityId)
|
|
298
|
+
});
|
|
299
|
+
queryClient.invalidateQueries({
|
|
300
|
+
queryKey: keys.recordCountPrefix(entityId)
|
|
301
|
+
});
|
|
259
302
|
},
|
|
260
303
|
...options
|
|
261
304
|
});
|
|
@@ -265,8 +308,13 @@ function useDeleteRecordsWhere(sdk, entityId, options) {
|
|
|
265
308
|
return useMutation({
|
|
266
309
|
mutationFn: (input) => sdk.eav.records.deleteWhere(entityId, input),
|
|
267
310
|
onSuccess: () => {
|
|
268
|
-
queryClient.invalidateQueries({ queryKey: keys.
|
|
269
|
-
queryClient.invalidateQueries({
|
|
311
|
+
queryClient.invalidateQueries({ queryKey: keys.recordsPrefix(entityId) });
|
|
312
|
+
queryClient.invalidateQueries({
|
|
313
|
+
queryKey: keys.recordsInfinitePrefix(entityId)
|
|
314
|
+
});
|
|
315
|
+
queryClient.invalidateQueries({
|
|
316
|
+
queryKey: keys.recordCountPrefix(entityId)
|
|
317
|
+
});
|
|
270
318
|
},
|
|
271
319
|
...options
|
|
272
320
|
});
|
package/dist/terms/index.js
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
|
-
export { ReoptTermsClient, createReoptTermsClient } from '../chunk-
|
|
2
|
-
import '../chunk-
|
|
3
|
-
import '../chunk-
|
|
1
|
+
export { ReoptTermsClient, createReoptTermsClient } from '../chunk-H33OTQEN.js';
|
|
2
|
+
import '../chunk-YTKSAWV2.js';
|
|
3
|
+
import '../chunk-2LSCQHAU.js';
|
|
4
|
+
import '../chunk-C5VTRZWX.js';
|
|
4
5
|
//# sourceMappingURL=index.js.map
|
|
5
6
|
//# sourceMappingURL=index.js.map
|
package/dist/testing/index.d.ts
CHANGED
package/dist/webhooks/index.d.ts
CHANGED
|
@@ -87,9 +87,12 @@ declare function createWebhookHandler(config: {
|
|
|
87
87
|
secret: string;
|
|
88
88
|
handlers: WebhookHandlers;
|
|
89
89
|
/**
|
|
90
|
-
* Called when a handler throws.
|
|
91
|
-
*
|
|
92
|
-
*
|
|
90
|
+
* Called when a handler throws. The handler still returns 500 to the caller.
|
|
91
|
+
* `meta.attempt` reflects the `x-reopt-delivery-attempt` header when the
|
|
92
|
+
* sender provides one; the current reopt sender is best-effort with no retry
|
|
93
|
+
* queue (it does not send that header), so `attempt` is `1` in practice —
|
|
94
|
+
* treat it as advisory, not a reliable retry counter. Deliveries are
|
|
95
|
+
* at-least-once, so dedupe on `payload.id` (see `idempotency`).
|
|
93
96
|
*/
|
|
94
97
|
onError?: (error: Error, payload: WebhookPayload, meta: {
|
|
95
98
|
attempt: number;
|