@studiocms/auth0 0.1.0-beta.23 → 0.1.0-beta.25

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.
@@ -1,6 +1,5 @@
1
- import { HttpClient } from '@effect/platform';
2
1
  import type { APIContext } from 'astro';
3
- import { Effect, Schema } from 'studiocms/effect';
2
+ import { Effect, Platform, Schema } from 'studiocms/effect';
4
3
  declare const Auth0User_base: Schema.Class<Auth0User, {
5
4
  sub: typeof Schema.String;
6
5
  name: typeof Schema.String;
@@ -47,11 +46,11 @@ export declare class Auth0User extends Auth0User_base {
47
46
  */
48
47
  export declare const cleanDomain: (domain: string) => string;
49
48
  declare const Auth0OAuthAPI_base: Effect.Service.Class<Auth0OAuthAPI, "Auth0OAuthAPI", {
50
- readonly dependencies: readonly [import("effect/Layer").Layer<import("studiocms/lib/auth/session").Session, never, never>, import("effect/Layer").Layer<import("studiocms/lib/auth/verify-email").VerifyEmail, import("studiocms/lib/effects/smtp").SMTPError | import("effect/Cause").UnknownException, never>, import("effect/Layer").Layer<import("studiocms/lib/auth/user").User, import("studiocms/lib/effects/smtp").SMTPError | import("effect/Cause").UnknownException, never>, import("effect/Layer").Layer<HttpClient.HttpClient, never, never>];
49
+ readonly dependencies: readonly [import("effect/Layer").Layer<import("studiocms/lib/auth/session").Session, never, never>, import("effect/Layer").Layer<import("studiocms/lib/auth/verify-email").VerifyEmail, Error, never>, import("effect/Layer").Layer<import("studiocms/lib/auth/user").User, Error, never>, import("effect/Layer").Layer<Platform.HttpClient.HttpClient, never, never>];
51
50
  readonly effect: Effect.Effect<{
52
51
  initSession: (context: APIContext) => Effect.Effect<Response, import("studiocms/lib/auth/session").SessionError, never>;
53
- initCallback: (context: APIContext) => Effect.Effect<Response, import("studiocms/sdk/effect/db").LibSQLDatabaseError | import("studiocms/sdk/errors").SDKCoreError | Error, never>;
54
- }, never, import("studiocms/lib/auth/session").Session | import("studiocms/lib/auth/verify-email").VerifyEmail | import("studiocms/lib/auth/user").User | HttpClient.HttpClient>;
52
+ initCallback: (context: APIContext) => Effect.Effect<Response, Error | import("studiocms/sdk/effect/db").LibSQLDatabaseError | import("studiocms/sdk/errors").SDKCoreError, never>;
53
+ }, never, import("studiocms/lib/auth/session").Session | import("studiocms/lib/auth/verify-email").VerifyEmail | import("studiocms/lib/auth/user").User | Platform.HttpClient.HttpClient>;
55
54
  }>;
56
55
  /**
57
56
  * Provides Auth0 OAuth authentication effects for the StudioCMS API.
@@ -3,9 +3,8 @@ import { Session, User, VerifyEmail } from "studiocms:auth/lib";
3
3
  import config from "studiocms:config";
4
4
  import { StudioCMSRoutes } from "studiocms:lib";
5
5
  import { SDKCore } from "studiocms:sdk";
6
- import { FetchHttpClient, HttpClient, HttpClientResponse } from "@effect/platform";
7
6
  import { Auth0, generateCodeVerifier, generateState } from "arctic";
8
- import { Effect, genLogger, pipe, Schema } from "studiocms/effect";
7
+ import { Effect, genLogger, Platform, pipe, Schema } from "studiocms/effect";
9
8
  import { getCookie, getUrlParam, ValidateAuthCodeError } from "studiocms/oAuthUtils";
10
9
  class Auth0User extends Schema.Class("Auth0User")({
11
10
  sub: Schema.String,
@@ -28,7 +27,12 @@ const AUTH0 = {
28
27
  REDIRECT_URI: getSecret("CMS_AUTH0_REDIRECT_URI") || ""
29
28
  };
30
29
  class Auth0OAuthAPI extends Effect.Service()("Auth0OAuthAPI", {
31
- dependencies: [Session.Default, VerifyEmail.Default, User.Default, FetchHttpClient.layer],
30
+ dependencies: [
31
+ Session.Default,
32
+ VerifyEmail.Default,
33
+ User.Default,
34
+ Platform.FetchHttpClient.layer
35
+ ],
32
36
  effect: genLogger("studiocms/routes/api/auth/auth0/effect")(function* () {
33
37
  const [
34
38
  sdk,
@@ -36,7 +40,7 @@ class Auth0OAuthAPI extends Effect.Service()("Auth0OAuthAPI", {
36
40
  { setOAuthSessionTokenCookie, createUserSession },
37
41
  { isEmailVerified, sendVerificationEmail },
38
42
  { getUserData, createOAuthUser }
39
- ] = yield* Effect.all([SDKCore, HttpClient.HttpClient, Session, VerifyEmail, User]);
43
+ ] = yield* Effect.all([SDKCore, Platform.HttpClient.HttpClient, Session, VerifyEmail, User]);
40
44
  const { CLIENT_ID, CLIENT_SECRET, DOMAIN, REDIRECT_URI } = AUTH0;
41
45
  const CLIENT_DOMAIN = cleanDomain(DOMAIN);
42
46
  const auth0 = new Auth0(CLIENT_DOMAIN, CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
@@ -47,7 +51,7 @@ class Auth0OAuthAPI extends Effect.Service()("Auth0OAuthAPI", {
47
51
  return yield* fetchClient.get(`${CLIENT_DOMAIN}/userinfo`, {
48
52
  headers: { Authorization: `Bearer ${tokens.accessToken()}` }
49
53
  }).pipe(
50
- Effect.flatMap(HttpClientResponse.schemaBodyJson(Auth0User)),
54
+ Effect.flatMap(Platform.HttpClientResponse.schemaBodyJson(Auth0User)),
51
55
  Effect.catchAll(
52
56
  (error) => Effect.fail(
53
57
  new ValidateAuthCodeError({
@@ -125,7 +129,6 @@ class Auth0OAuthAPI extends Effect.Service()("Auth0OAuthAPI", {
125
129
  }
126
130
  const newUser = yield* createOAuthUser(
127
131
  {
128
- // @ts-expect-error drizzle broke the id variable...
129
132
  id: crypto.randomUUID(),
130
133
  username: auth0Username,
131
134
  name: auth0User.name,
@@ -5,7 +5,7 @@ import type { APIRoute } from 'astro';
5
5
  * This function uses the Effect system to compose asynchronous operations,
6
6
  * retrieving the `initSession` method from the `Auth0OAuthAPI` and invoking it
7
7
  * with the provided API context. The result is converted to a vanilla response
8
- * using `convertToVanilla`.
8
+ * using `runEffect`.
9
9
  *
10
10
  * @param context - The API context containing request and environment information.
11
11
  * @returns A promise resolving to the API response after session initialization.
package/dist/endpoint.js CHANGED
@@ -1,12 +1,12 @@
1
- import { convertToVanilla, Effect } from "studiocms/effect";
1
+ import { Effect, runEffect } from "studiocms/effect";
2
2
  import { Auth0OAuthAPI } from "./effect/auth0.js";
3
- const initSession = async (context) => await convertToVanilla(
3
+ const initSession = async (context) => await runEffect(
4
4
  Effect.gen(function* () {
5
5
  const { initSession: initSession2 } = yield* Auth0OAuthAPI;
6
6
  return yield* initSession2(context);
7
7
  }).pipe(Effect.provide(Auth0OAuthAPI.Default))
8
8
  );
9
- const initCallback = async (context) => await convertToVanilla(
9
+ const initCallback = async (context) => await runEffect(
10
10
  Effect.gen(function* () {
11
11
  const { initCallback: initCallback2 } = yield* Auth0OAuthAPI;
12
12
  return yield* initCallback2(context);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studiocms/auth0",
3
- "version": "0.1.0-beta.23",
3
+ "version": "0.1.0-beta.25",
4
4
  "description": "Add Auth0 OAuth Support into your StudioCMS project.",
5
5
  "author": {
6
6
  "name": "withstudiocms",
@@ -23,12 +23,10 @@
23
23
  "astrocms",
24
24
  "astrodb",
25
25
  "astrostudio",
26
- "astro-integration",
27
26
  "astro-studio",
28
27
  "astro-studiocms",
29
28
  "cms",
30
29
  "studiocms",
31
- "withastro",
32
30
  "plugin",
33
31
  "studiocms-plugin"
34
32
  ],
@@ -49,18 +47,17 @@
49
47
  },
50
48
  "type": "module",
51
49
  "dependencies": {
52
- "astro-integration-kit": "^0.18",
50
+ "astro-integration-kit": "^0.19.0",
53
51
  "arctic": "^3.7.0"
54
52
  },
55
53
  "devDependencies": {
56
54
  "@types/node": "^22.0.0"
57
55
  },
58
56
  "peerDependencies": {
59
- "@effect/platform": "^0.90.0",
60
- "astro": "^5.12.6",
61
- "effect": "^3.17.3",
57
+ "astro": "^5.12.9",
58
+ "effect": "^3.17.9",
62
59
  "vite": "^6.3.4",
63
- "studiocms": "0.1.0-beta.23"
60
+ "studiocms": "0.1.0-beta.25"
64
61
  },
65
62
  "scripts": {
66
63
  "build": "buildkit build 'src/**/*.{ts,astro,css,json,png}'",