@studiocms/google 0.1.0-beta.30 → 0.1.0
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/dist/effect/google.d.ts +4 -4
- package/dist/effect/google.js +14 -16
- package/dist/index.js +1 -1
- package/package.json +5 -3
package/dist/effect/google.d.ts
CHANGED
|
@@ -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/verify-email").VerifyEmail,
|
|
33
|
+
readonly dependencies: readonly [import("effect/Layer").Layer<import("studiocms/lib/auth/verify-email").VerifyEmail, import("studiocms/sdk/base").DBClientInitializationError | import("studiocms/sdk/base").SDKInitializationError | import("@withstudiocms/kysely/client").DBCallbackFailure | import("@withstudiocms/kysely/core/errors").DatabaseError | import("effect/Cause").UnknownException | import("effect/ConfigError").ConfigError | import("@withstudiocms/effect/smtp").SMTPError, never>, import("effect/Layer").Layer<Platform.HttpClient.HttpClient, never, never>];
|
|
34
34
|
readonly effect: Effect.Effect<{
|
|
35
|
-
initSession: (context: APIContext) => Effect.Effect<Response, import("@withstudiocms/auth-kit/errors").SessionError, never>;
|
|
36
|
-
initCallback: (context: APIContext) => Effect.Effect<Response,
|
|
37
|
-
}, import("@withstudiocms/auth-kit/errors").SessionError | import("@withstudiocms/auth-kit/errors").UserError, import("studiocms/lib/auth/verify-email").VerifyEmail | Platform.HttpClient.HttpClient>;
|
|
35
|
+
initSession: (context: APIContext) => Effect.Effect<Response, import("effect/ConfigError").ConfigError | import("@withstudiocms/auth-kit/errors").SessionError, never>;
|
|
36
|
+
initCallback: (context: APIContext) => Effect.Effect<Response, any, never>;
|
|
37
|
+
}, import("studiocms/sdk/base").DBClientInitializationError | import("studiocms/sdk/base").SDKInitializationError | import("effect/ConfigError").ConfigError | 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.
|
package/dist/effect/google.js
CHANGED
|
@@ -15,9 +15,9 @@ class GoogleUser extends Schema.Class("GoogleUser")({
|
|
|
15
15
|
}) {
|
|
16
16
|
}
|
|
17
17
|
const GOOGLE = {
|
|
18
|
-
CLIENT_ID: getSecret("
|
|
19
|
-
CLIENT_SECRET: getSecret("
|
|
20
|
-
REDIRECT_URI: getSecret("
|
|
18
|
+
CLIENT_ID: getSecret("CMS_GOOGLE_CLIENT_ID") ?? "",
|
|
19
|
+
CLIENT_SECRET: getSecret("CMS_GOOGLE_CLIENT_SECRET") ?? "",
|
|
20
|
+
REDIRECT_URI: getSecret("CMS_GOOGLE_REDIRECT_URI") ?? ""
|
|
21
21
|
};
|
|
22
22
|
class GoogleOAuthAPI extends Effect.Service()("GoogleOAuthAPI", {
|
|
23
23
|
dependencies: [VerifyEmail.Default, Platform.FetchHttpClient.layer],
|
|
@@ -41,13 +41,11 @@ class GoogleOAuthAPI extends Effect.Service()("GoogleOAuthAPI", {
|
|
|
41
41
|
}
|
|
42
42
|
}).pipe(
|
|
43
43
|
Effect.flatMap(Platform.HttpClientResponse.schemaBodyJson(GoogleUser)),
|
|
44
|
-
Effect.
|
|
45
|
-
(error) =>
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
})
|
|
50
|
-
)
|
|
44
|
+
Effect.mapError(
|
|
45
|
+
(error) => new ValidateAuthCodeError({
|
|
46
|
+
provider: GoogleOAuthAPI.ProviderID,
|
|
47
|
+
message: `Failed to fetch user info: ${error.message}`
|
|
48
|
+
})
|
|
51
49
|
)
|
|
52
50
|
);
|
|
53
51
|
});
|
|
@@ -78,10 +76,10 @@ class GoogleOAuthAPI extends Effect.Service()("GoogleOAuthAPI", {
|
|
|
78
76
|
}
|
|
79
77
|
const googleUser = yield* validateAuthCode(code, codeVerifier);
|
|
80
78
|
const { sub: googleUserId, name: googleUsername } = googleUser;
|
|
81
|
-
const existingOAuthAccount = yield* sdk.AUTH.oAuth.searchProvidersForId(
|
|
82
|
-
GoogleOAuthAPI.ProviderID,
|
|
83
|
-
googleUserId
|
|
84
|
-
);
|
|
79
|
+
const existingOAuthAccount = yield* sdk.AUTH.oAuth.searchProvidersForId({
|
|
80
|
+
providerId: GoogleOAuthAPI.ProviderID,
|
|
81
|
+
userId: googleUserId
|
|
82
|
+
});
|
|
85
83
|
if (existingOAuthAccount) {
|
|
86
84
|
const user = yield* sdk.GET.users.byId(existingOAuthAccount.userId);
|
|
87
85
|
if (!user) {
|
|
@@ -123,11 +121,11 @@ class GoogleOAuthAPI extends Effect.Service()("GoogleOAuthAPI", {
|
|
|
123
121
|
email: googleUser.email,
|
|
124
122
|
name: googleUser.name,
|
|
125
123
|
avatar: googleUser.picture,
|
|
126
|
-
createdAt: /* @__PURE__ */ new Date(),
|
|
124
|
+
createdAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
127
125
|
emailVerified: false,
|
|
128
126
|
notifications: null,
|
|
129
127
|
password: null,
|
|
130
|
-
updatedAt: /* @__PURE__ */ new Date(),
|
|
128
|
+
updatedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
131
129
|
url: null
|
|
132
130
|
},
|
|
133
131
|
{ provider: GoogleOAuthAPI.ProviderID, providerUserId: googleUserId }
|
package/dist/index.js
CHANGED
|
@@ -8,7 +8,7 @@ function studiocmsGoogle() {
|
|
|
8
8
|
name: "StudioCMS Google Plugin",
|
|
9
9
|
studiocmsMinimumVersion: "0.1.0-beta.22",
|
|
10
10
|
hooks: {
|
|
11
|
-
"studiocms:
|
|
11
|
+
"studiocms:auth": ({ setAuthService }) => {
|
|
12
12
|
setAuthService({
|
|
13
13
|
oAuthProvider: {
|
|
14
14
|
name: "google",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiocms/google",
|
|
3
|
-
"version": "0.1.0
|
|
3
|
+
"version": "0.1.0",
|
|
4
4
|
"description": "Add Google OAuth Support to your StudioCMS project with ease!",
|
|
5
5
|
"author": {
|
|
6
6
|
"name": "withstudiocms",
|
|
@@ -55,14 +55,16 @@
|
|
|
55
55
|
},
|
|
56
56
|
"peerDependencies": {
|
|
57
57
|
"astro": "^5.12.9",
|
|
58
|
-
"effect": "^3.19.
|
|
58
|
+
"effect": "^3.19.14",
|
|
59
59
|
"vite": "^6.3.4",
|
|
60
|
-
"studiocms": "0.1.0
|
|
60
|
+
"studiocms": "0.1.0"
|
|
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
65
|
"typecheck": "tspc -p tsconfig.tspc.json",
|
|
66
|
+
"effect-check": "pnpm effect-language-service diagnostics --project tsconfig.tspc.json",
|
|
67
|
+
"ci:effect-check": "pnpm effect-check --format github-actions",
|
|
66
68
|
"test": "vitest"
|
|
67
69
|
}
|
|
68
70
|
}
|