@studiocms/google 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 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/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>];
35
34
  readonly effect: Effect.Effect<{
36
35
  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>;
36
+ initCallback: (context: APIContext) => Effect.Effect<Response, Error | import("studiocms/sdk/effect/db").LibSQLDatabaseError | import("studiocms/sdk/errors").SDKCoreError, never>;
37
+ }, never, import("studiocms/lib/auth/session").Session | import("studiocms/lib/auth/verify-email").VerifyEmail | import("studiocms/lib/auth/user").User | Platform.HttpClient.HttpClient>;
39
38
  }>;
40
39
  /**
41
40
  * Provides Google 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 { Google, generateCodeVerifier, generateState } from "arctic";
8
- import { Effect, genLogger, Schema } from "studiocms/effect";
7
+ import { Effect, genLogger, Platform, Schema } from "studiocms/effect";
9
8
  import { getCookie, getUrlParam, ValidateAuthCodeError } from "studiocms/oAuthUtils";
10
9
  class GoogleUser extends Schema.Class("GoogleUser")({
11
10
  sub: Schema.String,
@@ -20,7 +19,12 @@ const GOOGLE = {
20
19
  REDIRECT_URI: getSecret("GOOGLE_REDIRECT_URI") ?? ""
21
20
  };
22
21
  class GoogleOAuthAPI extends Effect.Service()("GoogleOAuthAPI", {
23
- dependencies: [Session.Default, VerifyEmail.Default, User.Default, FetchHttpClient.layer],
22
+ dependencies: [
23
+ Session.Default,
24
+ VerifyEmail.Default,
25
+ User.Default,
26
+ Platform.FetchHttpClient.layer
27
+ ],
24
28
  effect: genLogger("studiocms/routes/api/auth/google/effect")(function* () {
25
29
  const [
26
30
  sdk,
@@ -28,7 +32,7 @@ class GoogleOAuthAPI extends Effect.Service()("GoogleOAuthAPI", {
28
32
  { setOAuthSessionTokenCookie, createUserSession },
29
33
  { isEmailVerified, sendVerificationEmail },
30
34
  { getUserData, createOAuthUser }
31
- ] = yield* Effect.all([SDKCore, HttpClient.HttpClient, Session, VerifyEmail, User]);
35
+ ] = yield* Effect.all([SDKCore, Platform.HttpClient.HttpClient, Session, VerifyEmail, User]);
32
36
  const { CLIENT_ID, CLIENT_SECRET, REDIRECT_URI } = GOOGLE;
33
37
  const google = new Google(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
34
38
  const validateAuthCode = (code, codeVerifier) => genLogger("studiocms/routes/api/auth/google/effect.validateAuthCode")(function* () {
@@ -40,7 +44,7 @@ class GoogleOAuthAPI extends Effect.Service()("GoogleOAuthAPI", {
40
44
  Authorization: `Bearer ${tokens.accessToken}`
41
45
  }
42
46
  }).pipe(
43
- Effect.flatMap(HttpClientResponse.schemaBodyJson(GoogleUser)),
47
+ Effect.flatMap(Platform.HttpClientResponse.schemaBodyJson(GoogleUser)),
44
48
  Effect.catchAll(
45
49
  (error) => Effect.fail(
46
50
  new ValidateAuthCodeError({
@@ -118,7 +122,6 @@ class GoogleOAuthAPI extends Effect.Service()("GoogleOAuthAPI", {
118
122
  }
119
123
  const newUser = yield* createOAuthUser(
120
124
  {
121
- // @ts-expect-error drizzle broke the id variable...
122
125
  id: crypto.randomUUID(),
123
126
  username: googleUsername,
124
127
  email: googleUser.email,
@@ -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.23",
3
+ "version": "0.1.0-beta.25",
4
4
  "description": "Add Google OAuth Support to your StudioCMS project with ease!",
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}'",