@alchemy.run/better-auth 0.0.0 → 0.6.4

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.
@@ -0,0 +1,12 @@
1
+ import type { HttpEffect } from "alchemy-effect/Http";
2
+ import { type Auth } from "better-auth";
3
+ import * as Effect from "effect/Effect";
4
+ import * as ServiceMap from "effect/ServiceMap";
5
+ declare const BetterAuth_base: ServiceMap.ServiceClass<BetterAuth, "BetterAuth", {
6
+ auth: Effect.Effect<Auth<any>>;
7
+ fetch: HttpEffect;
8
+ }>;
9
+ export declare class BetterAuth extends BetterAuth_base {
10
+ }
11
+ export {};
12
+ //# sourceMappingURL=BetterAuth.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BetterAuth.d.ts","sourceRoot":"","sources":["../src/BetterAuth.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,qBAAqB,CAAC;AACtD,OAAO,EAAE,KAAK,IAAI,EAAE,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;;UAKtC,MAAM,CAAC,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;WACvB,UAAU;;AAJrB,qBAAa,UAAW,SAAQ,eAMf;CAAG"}
@@ -0,0 +1,6 @@
1
+ import {} from "better-auth";
2
+ import * as Effect from "effect/Effect";
3
+ import * as ServiceMap from "effect/ServiceMap";
4
+ export class BetterAuth extends ServiceMap.Service()("BetterAuth") {
5
+ }
6
+ //# sourceMappingURL=BetterAuth.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"BetterAuth.js","sourceRoot":"","sources":["../src/BetterAuth.ts"],"names":[],"mappings":"AACA,OAAO,EAAa,MAAM,aAAa,CAAC;AACxC,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,mBAAmB,CAAC;AAEhD,MAAM,OAAO,UAAW,SAAQ,UAAU,CAAC,OAAO,EAM/C,CAAC,YAAY,CAAC;CAAG"}
@@ -0,0 +1,6 @@
1
+ import { Random } from "alchemy-effect";
2
+ import * as Cloudflare from "alchemy-effect/Cloudflare";
3
+ import * as Layer from "effect/Layer";
4
+ import { BetterAuth } from "./BetterAuth.ts";
5
+ export declare const CloudflareD1: Layer.Layer<BetterAuth, never, import("alchemy-effect").Provider<Cloudflare.D1Database> | import("alchemy-effect").Provider<Random> | import("alchemy-effect/ExecutionContext").ExecutionContext<import("alchemy-effect/ExecutionContext").BaseExecutionContext> | Cloudflare.D1ConnectionPolicy>;
6
+ //# sourceMappingURL=CloudflareD1.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CloudflareD1.d.ts","sourceRoot":"","sources":["../src/CloudflareD1.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,2BAA2B,CAAC;AAGxD,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AAItC,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,eAAO,MAAM,YAAY,mSA+ByB,CAAC"}
@@ -0,0 +1,31 @@
1
+ import { Random } from "alchemy-effect";
2
+ import * as Cloudflare from "alchemy-effect/Cloudflare";
3
+ import { betterAuth as makeBetterAuth } from "better-auth";
4
+ import * as Effect from "effect/Effect";
5
+ import * as Layer from "effect/Layer";
6
+ import * as Redacted from "effect/Redacted";
7
+ import { HttpServerRequest } from "effect/unstable/http/HttpServerRequest";
8
+ import * as HttpServerResponse from "effect/unstable/http/HttpServerResponse";
9
+ import { BetterAuth } from "./BetterAuth.js";
10
+ export const CloudflareD1 = Layer.effect(BetterAuth, Effect.gen(function* () {
11
+ const d1 = yield* Cloudflare.D1Database("BetterAuth");
12
+ const connection = yield* Cloudflare.D1Connection.bind(d1);
13
+ const BETTER_AUTH_SECRET = yield* Random("BETTER_AUTH_SECRET");
14
+ const betterAuthSecret = yield* BETTER_AUTH_SECRET.text;
15
+ const betterAuth = yield* Effect.gen(function* () {
16
+ return makeBetterAuth({
17
+ database: yield* connection.raw,
18
+ secret: yield* betterAuthSecret.pipe(Effect.map(Redacted.value)),
19
+ });
20
+ }).pipe(Effect.cached);
21
+ return {
22
+ auth: betterAuth,
23
+ fetch: Effect.gen(function* () {
24
+ const request = yield* HttpServerRequest;
25
+ const auth = yield* betterAuth;
26
+ const response = yield* Effect.promise(() => auth.handler(request.source));
27
+ return HttpServerResponse.fromWeb(response);
28
+ }),
29
+ };
30
+ })).pipe(Layer.provide(Cloudflare.D1ConnectionLive));
31
+ //# sourceMappingURL=CloudflareD1.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CloudflareD1.js","sourceRoot":"","sources":["../src/CloudflareD1.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,MAAM,EAAE,MAAM,gBAAgB,CAAC;AACxC,OAAO,KAAK,UAAU,MAAM,2BAA2B,CAAC;AACxD,OAAO,EAAE,UAAU,IAAI,cAAc,EAAE,MAAM,aAAa,CAAC;AAC3D,OAAO,KAAK,MAAM,MAAM,eAAe,CAAC;AACxC,OAAO,KAAK,KAAK,MAAM,cAAc,CAAC;AACtC,OAAO,KAAK,QAAQ,MAAM,iBAAiB,CAAC;AAC5C,OAAO,EAAE,iBAAiB,EAAE,MAAM,wCAAwC,CAAC;AAC3E,OAAO,KAAK,kBAAkB,MAAM,yCAAyC,CAAC;AAC9E,OAAO,EAAE,UAAU,EAAE,MAAM,iBAAiB,CAAC;AAE7C,MAAM,CAAC,MAAM,YAAY,GAAG,KAAK,CAAC,MAAM,CACtC,UAAU,EACV,MAAM,CAAC,GAAG,CAAC,QAAQ,CAAC;IAClB,MAAM,EAAE,GAAG,KAAK,CAAC,CAAC,UAAU,CAAC,UAAU,CAAC,YAAY,CAAC,CAAC;IAEtD,MAAM,UAAU,GAAG,KAAK,CAAC,CAAC,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0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC"}
package/lib/index.js ADDED
@@ -0,0 +1,3 @@
1
+ export * from "./BetterAuth.js";
2
+ export * from "./CloudflareD1.js";
3
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,iBAAiB,CAAC;AAChC,cAAc,mBAAmB,CAAC"}
package/package.json CHANGED
@@ -1,17 +1,32 @@
1
1
  {
2
2
  "name": "@alchemy.run/better-auth",
3
- "version": "0.0.0",
4
- "module": "index.ts",
5
- "type": "module",
6
- "devDependencies": {
7
- "@types/bun": "latest"
8
- },
9
- "peerDependencies": {
10
- "typescript": "^5"
3
+ "version": "0.6.4",
4
+ "license": "Apache-2.0",
5
+ "publishConfig": {
6
+ "access": "public"
11
7
  },
12
8
  "repository": {
13
9
  "type": "git",
14
- "url": "https://github.com/alchemy-run/distilled",
15
- "directory": "packages/prisma-postgres"
10
+ "url": "https://github.com/alchemy-run/alchemy-effect"
11
+ },
12
+ "files": [
13
+ "lib",
14
+ "src"
15
+ ],
16
+ "scripts": {
17
+ "build": "tsc -b"
18
+ },
19
+ "type": "module",
20
+ "exports": {
21
+ ".": {
22
+ "bun": "./src/index.ts",
23
+ "default": "./lib/index.js",
24
+ "types": "./lib/index.d.ts"
25
+ }
26
+ },
27
+ "dependencies": {
28
+ "alchemy-effect": "0.6.2",
29
+ "better-auth": "^1.6.2",
30
+ "effect": "4.0.0-beta.43"
16
31
  }
17
32
  }
@@ -0,0 +1,12 @@
1
+ import type { HttpEffect } from "alchemy-effect/Http";
2
+ import { type Auth } from "better-auth";
3
+ import * as Effect from "effect/Effect";
4
+ import * as ServiceMap from "effect/ServiceMap";
5
+
6
+ export class BetterAuth extends ServiceMap.Service<
7
+ BetterAuth,
8
+ {
9
+ auth: Effect.Effect<Auth<any>>;
10
+ fetch: HttpEffect;
11
+ }
12
+ >()("BetterAuth") {}
@@ -0,0 +1,42 @@
1
+ import { Random } from "alchemy-effect";
2
+ import * as Cloudflare from "alchemy-effect/Cloudflare";
3
+ import { betterAuth as makeBetterAuth } from "better-auth";
4
+ import * as Effect from "effect/Effect";
5
+ import * as Layer from "effect/Layer";
6
+ import * as Redacted from "effect/Redacted";
7
+ import { HttpServerRequest } from "effect/unstable/http/HttpServerRequest";
8
+ import * as HttpServerResponse from "effect/unstable/http/HttpServerResponse";
9
+ import { BetterAuth } from "./BetterAuth.ts";
10
+
11
+ export const CloudflareD1 = Layer.effect(
12
+ BetterAuth,
13
+ Effect.gen(function* () {
14
+ const d1 = yield* Cloudflare.D1Database("BetterAuth");
15
+
16
+ const connection = yield* Cloudflare.D1Connection.bind(d1);
17
+
18
+ const BETTER_AUTH_SECRET = yield* Random("BETTER_AUTH_SECRET");
19
+
20
+ const betterAuthSecret = yield* BETTER_AUTH_SECRET.text;
21
+
22
+ const betterAuth = yield* Effect.gen(function* () {
23
+ return makeBetterAuth({
24
+ database: yield* connection.raw,
25
+ secret: yield* betterAuthSecret.pipe(Effect.map(Redacted.value)),
26
+ });
27
+ }).pipe(Effect.cached);
28
+
29
+ return {
30
+ auth: betterAuth,
31
+ fetch: Effect.gen(function* () {
32
+ const request = yield* HttpServerRequest;
33
+ const auth = yield* betterAuth;
34
+
35
+ const response = yield* Effect.promise(() =>
36
+ auth.handler(request.source as Request),
37
+ );
38
+ return HttpServerResponse.fromWeb(response);
39
+ }),
40
+ };
41
+ }),
42
+ ).pipe(Layer.provide(Cloudflare.D1ConnectionLive));
package/src/index.ts ADDED
@@ -0,0 +1,2 @@
1
+ export * from "./BetterAuth.ts";
2
+ export * from "./CloudflareD1.ts";
package/README.md DELETED
@@ -1,15 +0,0 @@
1
- # tesst
2
-
3
- To install dependencies:
4
-
5
- ```bash
6
- bun install
7
- ```
8
-
9
- To run:
10
-
11
- ```bash
12
- bun run index.ts
13
- ```
14
-
15
- This project was created using `bun init` in bun v1.3.10. [Bun](https://bun.com) is a fast all-in-one JavaScript runtime.
package/bun.lock DELETED
@@ -1,26 +0,0 @@
1
- {
2
- "lockfileVersion": 1,
3
- "configVersion": 1,
4
- "workspaces": {
5
- "": {
6
- "name": "tesst",
7
- "devDependencies": {
8
- "@types/bun": "latest",
9
- },
10
- "peerDependencies": {
11
- "typescript": "^5",
12
- },
13
- },
14
- },
15
- "packages": {
16
- "@types/bun": ["@types/bun@1.3.10", "", { "dependencies": { "bun-types": "1.3.10" } }, "sha512-0+rlrUrOrTSskibryHbvQkDOWRJwJZqZlxrUs1u4oOoTln8+WIXBPmAuCF35SWB2z4Zl3E84Nl/D0P7803nigQ=="],
17
-
18
- "@types/node": ["@types/node@25.4.0", "", { "dependencies": { "undici-types": "~7.18.0" } }, "sha512-9wLpoeWuBlcbBpOY3XmzSTG3oscB6xjBEEtn+pYXTfhyXhIxC5FsBer2KTopBlvKEiW9l13po9fq+SJY/5lkhw=="],
19
-
20
- "bun-types": ["bun-types@1.3.10", "", { "dependencies": { "@types/node": "*" } }, "sha512-tcpfCCl6XWo6nCVnpcVrxQ+9AYN1iqMIzgrSKYMB/fjLtV2eyAVEg7AxQJuCq/26R6HpKWykQXuSOq/21RYcbg=="],
21
-
22
- "typescript": ["typescript@5.9.3", "", { "bin": { "tsc": "bin/tsc", "tsserver": "bin/tsserver" } }, "sha512-jl1vZzPDinLr9eUt3J/t7V6FgNEw9QjvBPdysz9KfQDD41fQrC2Y4vKQdiaUpFT4bXlb1RHhLpp8wtm6M5TgSw=="],
23
-
24
- "undici-types": ["undici-types@7.18.2", "", {}, "sha512-AsuCzffGHJybSaRrmr5eHr81mwJU3kjw6M+uprWvCXiNeN9SOGwQ3Jn8jb8m3Z6izVgknn1R0FTCEAP2QrLY/w=="],
25
- }
26
- }
package/index.ts DELETED
@@ -1 +0,0 @@
1
- console.log("Hello via Bun!");
package/tsconfig.json DELETED
@@ -1,29 +0,0 @@
1
- {
2
- "compilerOptions": {
3
- // Environment setup & latest features
4
- "lib": ["ESNext"],
5
- "target": "ESNext",
6
- "module": "Preserve",
7
- "moduleDetection": "force",
8
- "jsx": "react-jsx",
9
- "allowJs": true,
10
-
11
- // Bundler mode
12
- "moduleResolution": "bundler",
13
- "allowImportingTsExtensions": true,
14
- "verbatimModuleSyntax": true,
15
- "noEmit": true,
16
-
17
- // Best practices
18
- "strict": true,
19
- "skipLibCheck": true,
20
- "noFallthroughCasesInSwitch": true,
21
- "noUncheckedIndexedAccess": true,
22
- "noImplicitOverride": true,
23
-
24
- // Some stricter flags (disabled by default)
25
- "noUnusedLocals": false,
26
- "noUnusedParameters": false,
27
- "noPropertyAccessFromIndexSignature": false
28
- }
29
- }