@krak-stack/auth 0.1.10 → 0.1.12
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/dist/better-auth/api.d.ts +2 -2
- package/dist/better-auth/api.js +2 -3
- package/dist/better-auth/index.d.ts +1 -1
- package/dist/client.d.ts +3 -5
- package/dist/client.js +19 -1
- package/package.json +1 -1
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { HttpApi } from "effect/unstable/httpapi";
|
|
2
2
|
import { HttpApiEndpoint, HttpApiError, HttpApiGroup } from "effect/unstable/httpapi";
|
|
3
3
|
import { TooManyRequests } from "./schema";
|
|
4
|
-
export declare const BetterAuthApiGroup: HttpApiGroup.HttpApiGroup<"betterAuth", HttpApiEndpoint.HttpApiEndpoint<"getSession", "
|
|
4
|
+
export declare const BetterAuthApiGroup: HttpApiGroup.HttpApiGroup<"betterAuth", HttpApiEndpoint.HttpApiEndpoint<"getSession", "GET", "/get-session", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").NullOr<import("effect/Schema").Struct<{
|
|
5
5
|
readonly session: import("effect/Schema").Struct<{
|
|
6
6
|
readonly id: import("effect/Schema").String;
|
|
7
7
|
readonly expiresAt: import("effect/Schema").Date;
|
|
@@ -26,7 +26,7 @@ export declare const BetterAuthApiGroup: HttpApiGroup.HttpApiGroup<"betterAuth",
|
|
|
26
26
|
readonly updatedAt: import("effect/Schema").Date;
|
|
27
27
|
}>;
|
|
28
28
|
}>>>, HttpApiEndpoint.Json<typeof TooManyRequests | typeof HttpApiError.BadRequest | typeof HttpApiError.Unauthorized | typeof HttpApiError.Forbidden | typeof HttpApiError.NotFound | typeof HttpApiError.InternalServerError>, never, never>, false>;
|
|
29
|
-
export declare const BetterAuthApi: HttpApi.HttpApi<"BetterAuthApi", HttpApiGroup.HttpApiGroup<"betterAuth", HttpApiEndpoint.HttpApiEndpoint<"getSession", "
|
|
29
|
+
export declare const BetterAuthApi: HttpApi.HttpApi<"BetterAuthApi", HttpApiGroup.HttpApiGroup<"betterAuth", HttpApiEndpoint.HttpApiEndpoint<"getSession", "GET", "/api/auth/get-session", HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.StringTree<never>, HttpApiEndpoint.Json<import("effect/Schema").NullOr<import("effect/Schema").Struct<{
|
|
30
30
|
readonly session: import("effect/Schema").Struct<{
|
|
31
31
|
readonly id: import("effect/Schema").String;
|
|
32
32
|
readonly expiresAt: import("effect/Schema").Date;
|
package/dist/better-auth/api.js
CHANGED
|
@@ -1,9 +1,8 @@
|
|
|
1
1
|
import { HttpApi, OpenApi } from "effect/unstable/httpapi";
|
|
2
2
|
import { HttpApiEndpoint, HttpApiError, HttpApiGroup, } from "effect/unstable/httpapi";
|
|
3
|
-
import {
|
|
3
|
+
import { GetSessionResponse, TooManyRequests, } from "./schema";
|
|
4
4
|
export const BetterAuthApiGroup = HttpApiGroup.make("betterAuth")
|
|
5
|
-
.add(HttpApiEndpoint.
|
|
6
|
-
payload: GetSessionPayload,
|
|
5
|
+
.add(HttpApiEndpoint.get("getSession", "/get-session", {
|
|
7
6
|
success: GetSessionResponse,
|
|
8
7
|
error: [
|
|
9
8
|
HttpApiError.BadRequest,
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { AtomHttpApi } from "effect/unstable/reactivity";
|
|
2
|
-
declare const BetterAuthApiClient_base: AtomHttpApi.AtomHttpApiClient<BetterAuthApiClient, "BetterAuthApiClient", import("effect/unstable/httpapi/HttpApiGroup").HttpApiGroup<"betterAuth", import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"getSession", "
|
|
2
|
+
declare const BetterAuthApiClient_base: AtomHttpApi.AtomHttpApiClient<BetterAuthApiClient, "BetterAuthApiClient", import("effect/unstable/httpapi/HttpApiGroup").HttpApiGroup<"betterAuth", import("effect/unstable/httpapi/HttpApiEndpoint").HttpApiEndpoint<"getSession", "GET", "/api/auth/get-session", import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").StringTree<never>, import("effect/unstable/httpapi/HttpApiEndpoint").Json<import("effect/Schema").NullOr<import("effect/Schema").Struct<{
|
|
3
3
|
readonly session: import("effect/Schema").Struct<{
|
|
4
4
|
readonly id: import("effect/Schema").String;
|
|
5
5
|
readonly expiresAt: import("effect/Schema").Date;
|
package/dist/client.d.ts
CHANGED
|
@@ -236,8 +236,7 @@ declare const AuthClient_base: Context.ServiceClass<AuthClient, "@krak-stack/aut
|
|
|
236
236
|
readonly url: string;
|
|
237
237
|
}, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : import("effect/Schema").SchemaError | import("effect/unstable/httpapi/HttpApiError").BadRequest | import("effect/unstable/httpapi/HttpApiError").Unauthorized | import("effect/unstable/httpapi/HttpApiError").Forbidden | import("effect/unstable/httpapi/HttpApiError").InternalServerError), [Mode] extends ["response-only"] ? never : never>;
|
|
238
238
|
};
|
|
239
|
-
getSession: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
240
|
-
readonly payload: {};
|
|
239
|
+
getSession: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: void | {
|
|
241
240
|
readonly responseMode?: Mode;
|
|
242
241
|
}) => Effect.Effect<HttpApiClient.Client.Response<{
|
|
243
242
|
readonly session: {
|
|
@@ -488,8 +487,7 @@ declare const AuthClient_base: Context.ServiceClass<AuthClient, "@krak-stack/aut
|
|
|
488
487
|
readonly url: string;
|
|
489
488
|
}, Mode>, import("effect/unstable/http/HttpClientError").HttpClientError | ([Mode] extends ["response-only"] ? never : import("effect/Schema").SchemaError | import("effect/unstable/httpapi/HttpApiError").BadRequest | import("effect/unstable/httpapi/HttpApiError").Unauthorized | import("effect/unstable/httpapi/HttpApiError").Forbidden | import("effect/unstable/httpapi/HttpApiError").InternalServerError), [Mode] extends ["response-only"] ? never : never>;
|
|
490
489
|
};
|
|
491
|
-
getSession: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: {
|
|
492
|
-
readonly payload: {};
|
|
490
|
+
getSession: <Mode extends HttpApiClient.Client.ResponseMode = import("effect/unstable/httpapi/HttpApiEndpoint").ClientResponseMode>(request: void | {
|
|
493
491
|
readonly responseMode?: Mode;
|
|
494
492
|
}) => Effect.Effect<HttpApiClient.Client.Response<{
|
|
495
493
|
readonly session: {
|
|
@@ -519,6 +517,6 @@ declare const AuthClient_base: Context.ServiceClass<AuthClient, "@krak-stack/aut
|
|
|
519
517
|
}, never, AuthClientConfig | HttpClient.HttpClient>;
|
|
520
518
|
};
|
|
521
519
|
export declare class AuthClient extends AuthClient_base {
|
|
522
|
-
static readonly layer: Layer.Layer<AuthClient, import("effect/Config").ConfigError, never>;
|
|
520
|
+
static readonly layer: (headers?: Record<string, string>) => Layer.Layer<AuthClient, import("effect/Config").ConfigError, never>;
|
|
523
521
|
}
|
|
524
522
|
export {};
|
package/dist/client.js
CHANGED
|
@@ -5,6 +5,24 @@ import { BetterAuthApi } from "./better-auth/api";
|
|
|
5
5
|
import { readClientConfig } from "./config";
|
|
6
6
|
import { ExtraApi } from "./extra/api";
|
|
7
7
|
import { ServerApi } from "./server/api";
|
|
8
|
+
const forwardedAuthHeaderNames = [
|
|
9
|
+
"accept-language",
|
|
10
|
+
"cookie",
|
|
11
|
+
"user-agent",
|
|
12
|
+
];
|
|
13
|
+
const forwardedAuthHeaders = (headers) => {
|
|
14
|
+
const forwarded = {};
|
|
15
|
+
for (const name of forwardedAuthHeaderNames) {
|
|
16
|
+
const value = headers[name];
|
|
17
|
+
if (value)
|
|
18
|
+
forwarded[name] = value;
|
|
19
|
+
}
|
|
20
|
+
return forwarded;
|
|
21
|
+
};
|
|
22
|
+
const authHttpClientLayer = (headers) => Layer.effect(HttpClient.HttpClient, Effect.gen(function* () {
|
|
23
|
+
const http = yield* HttpClient.HttpClient;
|
|
24
|
+
return HttpClient.mapRequest(http, (request) => HttpClientRequest.setHeaders(request, forwardedAuthHeaders(headers)));
|
|
25
|
+
})).pipe(Layer.provide(FetchHttpClient.layer));
|
|
8
26
|
export class AuthClientConfig extends Context.Service()("@krak-stack/auth/AuthClientConfig", { make: readClientConfig }) {
|
|
9
27
|
static layer = Layer.effect(this, this.make);
|
|
10
28
|
}
|
|
@@ -43,5 +61,5 @@ export class AuthClient extends Context.Service()("@krak-stack/auth/AuthClient",
|
|
|
43
61
|
};
|
|
44
62
|
}),
|
|
45
63
|
}) {
|
|
46
|
-
static layer = Layer.effect(this, this.make).pipe(Layer.provide(AuthClientConfig.layer), Layer.provide(
|
|
64
|
+
static layer = (headers = {}) => Layer.effect(this, this.make).pipe(Layer.provide(AuthClientConfig.layer), Layer.provide(authHttpClientLayer(headers)));
|
|
47
65
|
}
|