@studiocms/google 0.1.0-beta.25 → 0.1.0-beta.27

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.
package/README.md CHANGED
@@ -1,5 +1,7 @@
1
1
  # @studiocms/google Plugin
2
2
 
3
+ [![codecov](https://codecov.io/github/withstudiocms/studiocms/graph/badge.svg?token=RN8LT1O5E2&component=studiocms_google)](https://codecov.io/github/withstudiocms/studiocms)
4
+
3
5
  This plugin integrates Google OAuth authentication into StudioCMS. It defines the necessary configuration, including the required environment variables, OAuth provider details, and the endpoint paths for authentication.
4
6
 
5
7
  ## Usage
@@ -30,11 +30,11 @@ declare const GoogleUser_base: Schema.Class<GoogleUser, {
30
30
  export declare class GoogleUser extends GoogleUser_base {
31
31
  }
32
32
  declare const GoogleOAuthAPI_base: Effect.Service.Class<GoogleOAuthAPI, "GoogleOAuthAPI", {
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>];
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>];
34
34
  readonly effect: Effect.Effect<{
35
- initSession: (context: APIContext) => Effect.Effect<Response, import("studiocms/lib/auth/session").SessionError, never>;
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>;
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>;
38
38
  }>;
39
39
  /**
40
40
  * Provides Google OAuth authentication effects for the StudioCMS API.
@@ -4,6 +4,7 @@ import config from "studiocms:config";
4
4
  import { StudioCMSRoutes } from "studiocms:lib";
5
5
  import { SDKCore } from "studiocms:sdk";
6
6
  import { Google, generateCodeVerifier, generateState } from "arctic";
7
+ import { LinkNewOAuthCookieName } from "studiocms/consts";
7
8
  import { Effect, genLogger, Platform, Schema } from "studiocms/effect";
8
9
  import { getCookie, getUrlParam, ValidateAuthCodeError } from "studiocms/oAuthUtils";
9
10
  class GoogleUser extends Schema.Class("GoogleUser")({
@@ -19,12 +20,7 @@ const GOOGLE = {
19
20
  REDIRECT_URI: getSecret("GOOGLE_REDIRECT_URI") ?? ""
20
21
  };
21
22
  class GoogleOAuthAPI extends Effect.Service()("GoogleOAuthAPI", {
22
- dependencies: [
23
- Session.Default,
24
- VerifyEmail.Default,
25
- User.Default,
26
- Platform.FetchHttpClient.layer
27
- ],
23
+ dependencies: [VerifyEmail.Default, Platform.FetchHttpClient.layer],
28
24
  effect: genLogger("studiocms/routes/api/auth/google/effect")(function* () {
29
25
  const [
30
26
  sdk,
@@ -101,7 +97,7 @@ class GoogleOAuthAPI extends Effect.Service()("GoogleOAuthAPI", {
101
97
  return redirect(StudioCMSRoutes.mainLinks.dashboardIndex);
102
98
  }
103
99
  const loggedInUser = yield* getUserData(context);
104
- const linkNewOAuth = !!cookies.get(User.LinkNewOAuthCookieName)?.value;
100
+ const linkNewOAuth = !!cookies.get(LinkNewOAuthCookieName)?.value;
105
101
  if (loggedInUser.user && linkNewOAuth) {
106
102
  const existingUser2 = yield* sdk.GET.users.byId(loggedInUser.user.id);
107
103
  if (existingUser2) {
@@ -127,7 +123,12 @@ class GoogleOAuthAPI extends Effect.Service()("GoogleOAuthAPI", {
127
123
  email: googleUser.email,
128
124
  name: googleUser.name,
129
125
  avatar: googleUser.picture,
130
- 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
131
132
  },
132
133
  { provider: GoogleOAuthAPI.ProviderID, providerUserId: googleUserId }
133
134
  );
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studiocms/google",
3
- "version": "0.1.0-beta.25",
3
+ "version": "0.1.0-beta.27",
4
4
  "description": "Add Google OAuth Support to your StudioCMS project with ease!",
5
5
  "author": {
6
6
  "name": "withstudiocms",
@@ -55,13 +55,14 @@
55
55
  },
56
56
  "peerDependencies": {
57
57
  "astro": "^5.12.9",
58
- "effect": "^3.17.9",
58
+ "effect": "^3.17.14",
59
59
  "vite": "^6.3.4",
60
- "studiocms": "0.1.0-beta.25"
60
+ "studiocms": "0.1.0-beta.27"
61
61
  },
62
62
  "scripts": {
63
63
  "build": "buildkit build 'src/**/*.{ts,astro,css,json,png}'",
64
64
  "dev": "buildkit dev 'src/**/*.{ts,astro,css,json,png}'",
65
- "typecheck": "tspc -p tsconfig.tspc.json"
65
+ "typecheck": "tspc -p tsconfig.tspc.json",
66
+ "test": "vitest"
66
67
  }
67
68
  }