@studiocms/auth0 0.1.0-beta.24 → 0.1.0-beta.26

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/verify-email").VerifyEmail, Error, never>, import("effect/Layer").Layer<Platform.HttpClient.HttpClient, never, never>];
51
50
  readonly effect: Effect.Effect<{
52
- 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>;
51
+ initSession: (context: APIContext) => Effect.Effect<Response, import("@withstudiocms/auth-kit/errors").SessionError, never>;
52
+ initCallback: (context: APIContext) => Effect.Effect<Response, import("@withstudiocms/auth-kit/errors").SessionError, never>;
53
+ }, import("@withstudiocms/auth-kit/errors").SessionError | import("@withstudiocms/auth-kit/errors").UserError, import("studiocms/lib/auth/verify-email").VerifyEmail | Platform.HttpClient.HttpClient>;
55
54
  }>;
56
55
  /**
57
56
  * Provides Auth0 OAuth authentication effects for the StudioCMS API.
@@ -3,9 +3,9 @@ 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 { LinkNewOAuthCookieName } from "studiocms/consts";
8
+ import { Effect, genLogger, Platform, pipe, Schema } from "studiocms/effect";
9
9
  import { getCookie, getUrlParam, ValidateAuthCodeError } from "studiocms/oAuthUtils";
10
10
  class Auth0User extends Schema.Class("Auth0User")({
11
11
  sub: Schema.String,
@@ -28,7 +28,7 @@ const AUTH0 = {
28
28
  REDIRECT_URI: getSecret("CMS_AUTH0_REDIRECT_URI") || ""
29
29
  };
30
30
  class Auth0OAuthAPI extends Effect.Service()("Auth0OAuthAPI", {
31
- dependencies: [Session.Default, VerifyEmail.Default, User.Default, FetchHttpClient.layer],
31
+ dependencies: [VerifyEmail.Default, Platform.FetchHttpClient.layer],
32
32
  effect: genLogger("studiocms/routes/api/auth/auth0/effect")(function* () {
33
33
  const [
34
34
  sdk,
@@ -36,7 +36,7 @@ class Auth0OAuthAPI extends Effect.Service()("Auth0OAuthAPI", {
36
36
  { setOAuthSessionTokenCookie, createUserSession },
37
37
  { isEmailVerified, sendVerificationEmail },
38
38
  { getUserData, createOAuthUser }
39
- ] = yield* Effect.all([SDKCore, HttpClient.HttpClient, Session, VerifyEmail, User]);
39
+ ] = yield* Effect.all([SDKCore, Platform.HttpClient.HttpClient, Session, VerifyEmail, User]);
40
40
  const { CLIENT_ID, CLIENT_SECRET, DOMAIN, REDIRECT_URI } = AUTH0;
41
41
  const CLIENT_DOMAIN = cleanDomain(DOMAIN);
42
42
  const auth0 = new Auth0(CLIENT_DOMAIN, CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
@@ -47,7 +47,7 @@ class Auth0OAuthAPI extends Effect.Service()("Auth0OAuthAPI", {
47
47
  return yield* fetchClient.get(`${CLIENT_DOMAIN}/userinfo`, {
48
48
  headers: { Authorization: `Bearer ${tokens.accessToken()}` }
49
49
  }).pipe(
50
- Effect.flatMap(HttpClientResponse.schemaBodyJson(Auth0User)),
50
+ Effect.flatMap(Platform.HttpClientResponse.schemaBodyJson(Auth0User)),
51
51
  Effect.catchAll(
52
52
  (error) => Effect.fail(
53
53
  new ValidateAuthCodeError({
@@ -104,7 +104,7 @@ class Auth0OAuthAPI extends Effect.Service()("Auth0OAuthAPI", {
104
104
  return redirect(StudioCMSRoutes.mainLinks.dashboardIndex);
105
105
  }
106
106
  const loggedInUser = yield* getUserData(context);
107
- const linkNewOAuth = !!cookies.get(User.LinkNewOAuthCookieName)?.value;
107
+ const linkNewOAuth = !!cookies.get(LinkNewOAuthCookieName)?.value;
108
108
  if (loggedInUser.user && linkNewOAuth) {
109
109
  const existingUser2 = yield* sdk.GET.users.byId(loggedInUser.user.id);
110
110
  if (existingUser2) {
@@ -130,7 +130,12 @@ class Auth0OAuthAPI extends Effect.Service()("Auth0OAuthAPI", {
130
130
  name: auth0User.name,
131
131
  email: auth0User.email,
132
132
  avatar: auth0User.picture,
133
- createdAt: /* @__PURE__ */ new Date()
133
+ createdAt: /* @__PURE__ */ new Date(),
134
+ emailVerified: false,
135
+ notifications: null,
136
+ password: null,
137
+ updatedAt: /* @__PURE__ */ new Date(),
138
+ url: null
134
139
  },
135
140
  { provider: Auth0OAuthAPI.ProviderID, providerUserId: auth0UserId }
136
141
  );
@@ -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.24",
3
+ "version": "0.1.0-beta.26",
4
4
  "description": "Add Auth0 OAuth Support into your StudioCMS project.",
5
5
  "author": {
6
6
  "name": "withstudiocms",
@@ -47,18 +47,17 @@
47
47
  },
48
48
  "type": "module",
49
49
  "dependencies": {
50
- "astro-integration-kit": "^0.18",
50
+ "astro-integration-kit": "^0.19.0",
51
51
  "arctic": "^3.7.0"
52
52
  },
53
53
  "devDependencies": {
54
54
  "@types/node": "^22.0.0"
55
55
  },
56
56
  "peerDependencies": {
57
- "@effect/platform": "^0.90.1",
58
- "astro": "^5.12.8",
59
- "effect": "^3.17.7",
57
+ "astro": "^5.12.9",
58
+ "effect": "^3.17.13",
60
59
  "vite": "^6.3.4",
61
- "studiocms": "0.1.0-beta.24"
60
+ "studiocms": "0.1.0-beta.26"
62
61
  },
63
62
  "scripts": {
64
63
  "build": "buildkit build 'src/**/*.{ts,astro,css,json,png}'",