better-call 1.0.17 → 1.0.19
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/README.md +41 -2
- package/dist/client.d.cts +1 -1
- package/dist/client.d.ts +1 -1
- package/dist/index.cjs +32 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +1 -1
- package/dist/index.d.ts +1 -1
- package/dist/index.js +33 -5
- package/dist/index.js.map +1 -1
- package/dist/node.d.cts +1 -1
- package/dist/node.d.ts +1 -1
- package/dist/{router-CLKBSbjV.d.cts → router-DcqXHY8X.d.cts} +1 -1
- package/dist/{router-CLKBSbjV.d.ts → router-DcqXHY8X.d.ts} +1 -1
- package/package.json +2 -1
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as APIError, k as CookieOptions, C as CookiePrefixOptions, b as Endpoint, a as EndpointContext, E as EndpointOptions, H as HTTPMethod, W as HasRequiredKeys, v as InferBody, I as InferBodyInput, J as InferHeaders, K as InferHeadersInput, z as InferInputMethod, y as InferMethod, N as InferMiddlewareBody, Q as InferMiddlewareQuery, B as InferParam, D as InferParamInput, a0 as InferParamPath, a1 as InferParamWildCard, x as InferQuery, w as InferQueryInput, F as InferRequest, G as InferRequestInput, L as InferUse, T as InputContext, Y as IsEmptyObject, $ as MergeObject, u as Method, h as Middleware, e as MiddlewareContext, g as MiddlewareInputContext, M as MiddlewareOptions, d as MiddlewareResponse, n as OpenAPIParameter, O as OpenAPISchemaType, P as Path, X as Prettify, V as RequiredKeysOf, j as Router, R as RouterConfig, a2 as StandardSchemaV1, S as Status, Z as UnionToIntersection, _ as _statusCode, c as createEndpoint, U as createInternalContext, f as createMiddleware, i as createRouter, o as generator, l as getCookieKey, q as getHTML, r as hideInternalStackFrames, t as makeErrorForHideStackFrame, p as parseCookies, s as serializeCookie, m as serializeSignedCookie } from './router-
|
|
1
|
+
export { A as APIError, k as CookieOptions, C as CookiePrefixOptions, b as Endpoint, a as EndpointContext, E as EndpointOptions, H as HTTPMethod, W as HasRequiredKeys, v as InferBody, I as InferBodyInput, J as InferHeaders, K as InferHeadersInput, z as InferInputMethod, y as InferMethod, N as InferMiddlewareBody, Q as InferMiddlewareQuery, B as InferParam, D as InferParamInput, a0 as InferParamPath, a1 as InferParamWildCard, x as InferQuery, w as InferQueryInput, F as InferRequest, G as InferRequestInput, L as InferUse, T as InputContext, Y as IsEmptyObject, $ as MergeObject, u as Method, h as Middleware, e as MiddlewareContext, g as MiddlewareInputContext, M as MiddlewareOptions, d as MiddlewareResponse, n as OpenAPIParameter, O as OpenAPISchemaType, P as Path, X as Prettify, V as RequiredKeysOf, j as Router, R as RouterConfig, a2 as StandardSchemaV1, S as Status, Z as UnionToIntersection, _ as _statusCode, c as createEndpoint, U as createInternalContext, f as createMiddleware, i as createRouter, o as generator, l as getCookieKey, q as getHTML, r as hideInternalStackFrames, t as makeErrorForHideStackFrame, p as parseCookies, s as serializeCookie, m as serializeSignedCookie } from './router-DcqXHY8X.cjs';
|
|
2
2
|
|
|
3
3
|
type JSONResponse = {
|
|
4
4
|
body: Record<string, any>;
|
package/dist/index.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
export { A as APIError, k as CookieOptions, C as CookiePrefixOptions, b as Endpoint, a as EndpointContext, E as EndpointOptions, H as HTTPMethod, W as HasRequiredKeys, v as InferBody, I as InferBodyInput, J as InferHeaders, K as InferHeadersInput, z as InferInputMethod, y as InferMethod, N as InferMiddlewareBody, Q as InferMiddlewareQuery, B as InferParam, D as InferParamInput, a0 as InferParamPath, a1 as InferParamWildCard, x as InferQuery, w as InferQueryInput, F as InferRequest, G as InferRequestInput, L as InferUse, T as InputContext, Y as IsEmptyObject, $ as MergeObject, u as Method, h as Middleware, e as MiddlewareContext, g as MiddlewareInputContext, M as MiddlewareOptions, d as MiddlewareResponse, n as OpenAPIParameter, O as OpenAPISchemaType, P as Path, X as Prettify, V as RequiredKeysOf, j as Router, R as RouterConfig, a2 as StandardSchemaV1, S as Status, Z as UnionToIntersection, _ as _statusCode, c as createEndpoint, U as createInternalContext, f as createMiddleware, i as createRouter, o as generator, l as getCookieKey, q as getHTML, r as hideInternalStackFrames, t as makeErrorForHideStackFrame, p as parseCookies, s as serializeCookie, m as serializeSignedCookie } from './router-
|
|
1
|
+
export { A as APIError, k as CookieOptions, C as CookiePrefixOptions, b as Endpoint, a as EndpointContext, E as EndpointOptions, H as HTTPMethod, W as HasRequiredKeys, v as InferBody, I as InferBodyInput, J as InferHeaders, K as InferHeadersInput, z as InferInputMethod, y as InferMethod, N as InferMiddlewareBody, Q as InferMiddlewareQuery, B as InferParam, D as InferParamInput, a0 as InferParamPath, a1 as InferParamWildCard, x as InferQuery, w as InferQueryInput, F as InferRequest, G as InferRequestInput, L as InferUse, T as InputContext, Y as IsEmptyObject, $ as MergeObject, u as Method, h as Middleware, e as MiddlewareContext, g as MiddlewareInputContext, M as MiddlewareOptions, d as MiddlewareResponse, n as OpenAPIParameter, O as OpenAPISchemaType, P as Path, X as Prettify, V as RequiredKeysOf, j as Router, R as RouterConfig, a2 as StandardSchemaV1, S as Status, Z as UnionToIntersection, _ as _statusCode, c as createEndpoint, U as createInternalContext, f as createMiddleware, i as createRouter, o as generator, l as getCookieKey, q as getHTML, r as hideInternalStackFrames, t as makeErrorForHideStackFrame, p as parseCookies, s as serializeCookie, m as serializeSignedCookie } from './router-DcqXHY8X.js';
|
|
2
2
|
|
|
3
3
|
type JSONResponse = {
|
|
4
4
|
body: Record<string, any>;
|
package/dist/index.js
CHANGED
|
@@ -349,11 +349,14 @@ function fromError(error, validating) {
|
|
|
349
349
|
}
|
|
350
350
|
|
|
351
351
|
// src/crypto.ts
|
|
352
|
-
import {
|
|
352
|
+
import { getWebcryptoSubtle } from "@better-auth/utils";
|
|
353
353
|
var algorithm = { name: "HMAC", hash: "SHA-256" };
|
|
354
354
|
var getCryptoKey = async (secret) => {
|
|
355
355
|
const secretBuf = typeof secret === "string" ? new TextEncoder().encode(secret) : secret;
|
|
356
|
-
return await
|
|
356
|
+
return await getWebcryptoSubtle().importKey("raw", secretBuf, algorithm, false, [
|
|
357
|
+
"sign",
|
|
358
|
+
"verify"
|
|
359
|
+
]);
|
|
357
360
|
};
|
|
358
361
|
var verifySignature = async (base64Signature, value, secret) => {
|
|
359
362
|
try {
|
|
@@ -362,14 +365,23 @@ var verifySignature = async (base64Signature, value, secret) => {
|
|
|
362
365
|
for (let i = 0, len = signatureBinStr.length; i < len; i++) {
|
|
363
366
|
signature[i] = signatureBinStr.charCodeAt(i);
|
|
364
367
|
}
|
|
365
|
-
return await
|
|
368
|
+
return await getWebcryptoSubtle().verify(
|
|
369
|
+
algorithm,
|
|
370
|
+
secret,
|
|
371
|
+
signature,
|
|
372
|
+
new TextEncoder().encode(value)
|
|
373
|
+
);
|
|
366
374
|
} catch (e) {
|
|
367
375
|
return false;
|
|
368
376
|
}
|
|
369
377
|
};
|
|
370
378
|
var makeSignature = async (value, secret) => {
|
|
371
379
|
const key = await getCryptoKey(secret);
|
|
372
|
-
const signature = await
|
|
380
|
+
const signature = await getWebcryptoSubtle().sign(
|
|
381
|
+
algorithm.name,
|
|
382
|
+
key,
|
|
383
|
+
new TextEncoder().encode(value)
|
|
384
|
+
);
|
|
373
385
|
return btoa(String.fromCharCode(...new Uint8Array(signature)));
|
|
374
386
|
};
|
|
375
387
|
var signCookieValue = async (value, secret) => {
|
|
@@ -699,7 +711,7 @@ createEndpoint2.create = (opts) => {
|
|
|
699
711
|
};
|
|
700
712
|
|
|
701
713
|
// src/router.ts
|
|
702
|
-
import { createRouter as createRou3Router,
|
|
714
|
+
import { addRoute, createRouter as createRou3Router, findAllRoutes, findRoute } from "rou3";
|
|
703
715
|
|
|
704
716
|
// node_modules/.pnpm/zod@4.0.1/node_modules/zod/v4/core/core.js
|
|
705
717
|
var NEVER = Object.freeze({
|
|
@@ -3140,6 +3152,22 @@ var createRouter = (endpoints, config2) => {
|
|
|
3140
3152
|
const response = await handler(context);
|
|
3141
3153
|
return response;
|
|
3142
3154
|
} catch (error) {
|
|
3155
|
+
if (config2?.onError) {
|
|
3156
|
+
try {
|
|
3157
|
+
const errorResponse = await config2.onError(error);
|
|
3158
|
+
if (errorResponse instanceof Response) {
|
|
3159
|
+
return toResponse(errorResponse);
|
|
3160
|
+
}
|
|
3161
|
+
} catch (error2) {
|
|
3162
|
+
if (isAPIError(error2)) {
|
|
3163
|
+
return toResponse(error2);
|
|
3164
|
+
}
|
|
3165
|
+
throw error2;
|
|
3166
|
+
}
|
|
3167
|
+
}
|
|
3168
|
+
if (config2?.throwError) {
|
|
3169
|
+
throw error;
|
|
3170
|
+
}
|
|
3143
3171
|
if (isAPIError(error)) {
|
|
3144
3172
|
return toResponse(error);
|
|
3145
3173
|
}
|