@studiocms/google 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 GoogleUser_base: Schema.Class<GoogleUser, {
5
4
  sub: typeof Schema.String;
6
5
  picture: typeof Schema.String;
@@ -31,11 +30,11 @@ declare const GoogleUser_base: Schema.Class<GoogleUser, {
31
30
  export declare class GoogleUser extends GoogleUser_base {
32
31
  }
33
32
  declare const GoogleOAuthAPI_base: Effect.Service.Class<GoogleOAuthAPI, "GoogleOAuthAPI", {
34
- 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>];
33
+ 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>];
35
34
  readonly effect: Effect.Effect<{
36
- initSession: (context: APIContext) => Effect.Effect<Response, import("studiocms/lib/auth/session").SessionError, never>;
37
- initCallback: (context: APIContext) => Effect.Effect<Response, import("studiocms/sdk/effect/db").LibSQLDatabaseError | import("studiocms/sdk/errors").SDKCoreError | Error, never>;
38
- }, never, import("studiocms/lib/auth/session").Session | import("studiocms/lib/auth/verify-email").VerifyEmail | import("studiocms/lib/auth/user").User | HttpClient.HttpClient>;
35
+ initSession: (context: APIContext) => Effect.Effect<Response, import("@withstudiocms/auth-kit/errors").SessionError, never>;
36
+ initCallback: (context: APIContext) => Effect.Effect<Response, import("@withstudiocms/auth-kit/errors").SessionError, never>;
37
+ }, import("@withstudiocms/auth-kit/errors").SessionError | import("@withstudiocms/auth-kit/errors").UserError, import("studiocms/lib/auth/verify-email").VerifyEmail | Platform.HttpClient.HttpClient>;
39
38
  }>;
40
39
  /**
41
40
  * Provides Google 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 { Google, generateCodeVerifier, generateState } from "arctic";
8
- import { Effect, genLogger, Schema } from "studiocms/effect";
7
+ import { LinkNewOAuthCookieName } from "studiocms/consts";
8
+ import { Effect, genLogger, Platform, Schema } from "studiocms/effect";
9
9
  import { getCookie, getUrlParam, ValidateAuthCodeError } from "studiocms/oAuthUtils";
10
10
  class GoogleUser extends Schema.Class("GoogleUser")({
11
11
  sub: Schema.String,
@@ -20,7 +20,7 @@ const GOOGLE = {
20
20
  REDIRECT_URI: getSecret("GOOGLE_REDIRECT_URI") ?? ""
21
21
  };
22
22
  class GoogleOAuthAPI extends Effect.Service()("GoogleOAuthAPI", {
23
- dependencies: [Session.Default, VerifyEmail.Default, User.Default, FetchHttpClient.layer],
23
+ dependencies: [VerifyEmail.Default, Platform.FetchHttpClient.layer],
24
24
  effect: genLogger("studiocms/routes/api/auth/google/effect")(function* () {
25
25
  const [
26
26
  sdk,
@@ -28,7 +28,7 @@ class GoogleOAuthAPI extends Effect.Service()("GoogleOAuthAPI", {
28
28
  { setOAuthSessionTokenCookie, createUserSession },
29
29
  { isEmailVerified, sendVerificationEmail },
30
30
  { getUserData, createOAuthUser }
31
- ] = yield* Effect.all([SDKCore, HttpClient.HttpClient, Session, VerifyEmail, User]);
31
+ ] = yield* Effect.all([SDKCore, Platform.HttpClient.HttpClient, Session, VerifyEmail, User]);
32
32
  const { CLIENT_ID, CLIENT_SECRET, REDIRECT_URI } = GOOGLE;
33
33
  const google = new Google(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
34
34
  const validateAuthCode = (code, codeVerifier) => genLogger("studiocms/routes/api/auth/google/effect.validateAuthCode")(function* () {
@@ -40,7 +40,7 @@ class GoogleOAuthAPI extends Effect.Service()("GoogleOAuthAPI", {
40
40
  Authorization: `Bearer ${tokens.accessToken}`
41
41
  }
42
42
  }).pipe(
43
- Effect.flatMap(HttpClientResponse.schemaBodyJson(GoogleUser)),
43
+ Effect.flatMap(Platform.HttpClientResponse.schemaBodyJson(GoogleUser)),
44
44
  Effect.catchAll(
45
45
  (error) => Effect.fail(
46
46
  new ValidateAuthCodeError({
@@ -97,7 +97,7 @@ class GoogleOAuthAPI extends Effect.Service()("GoogleOAuthAPI", {
97
97
  return redirect(StudioCMSRoutes.mainLinks.dashboardIndex);
98
98
  }
99
99
  const loggedInUser = yield* getUserData(context);
100
- const linkNewOAuth = !!cookies.get(User.LinkNewOAuthCookieName)?.value;
100
+ const linkNewOAuth = !!cookies.get(LinkNewOAuthCookieName)?.value;
101
101
  if (loggedInUser.user && linkNewOAuth) {
102
102
  const existingUser2 = yield* sdk.GET.users.byId(loggedInUser.user.id);
103
103
  if (existingUser2) {
@@ -123,7 +123,12 @@ class GoogleOAuthAPI extends Effect.Service()("GoogleOAuthAPI", {
123
123
  email: googleUser.email,
124
124
  name: googleUser.name,
125
125
  avatar: googleUser.picture,
126
- createdAt: /* @__PURE__ */ new Date()
126
+ createdAt: /* @__PURE__ */ new Date(),
127
+ emailVerified: false,
128
+ notifications: null,
129
+ password: null,
130
+ updatedAt: /* @__PURE__ */ new Date(),
131
+ url: null
127
132
  },
128
133
  { provider: GoogleOAuthAPI.ProviderID, providerUserId: googleUserId }
129
134
  );
@@ -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 `GoogleOAuthAPI` 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 { GoogleOAuthAPI } from "./effect/google.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* GoogleOAuthAPI;
6
6
  return yield* initSession2(context);
7
7
  }).pipe(Effect.provide(GoogleOAuthAPI.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* GoogleOAuthAPI;
12
12
  return yield* initCallback2(context);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studiocms/google",
3
- "version": "0.1.0-beta.24",
3
+ "version": "0.1.0-beta.26",
4
4
  "description": "Add Google OAuth Support to your StudioCMS project with ease!",
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}'",