@studiocms/google 0.1.0-beta.24 → 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.
- package/dist/effect/google.d.ts +4 -5
- package/dist/effect/google.js +9 -5
- package/dist/endpoint.d.ts +1 -1
- package/dist/endpoint.js +3 -3
- package/package.json +5 -6
package/dist/effect/google.d.ts
CHANGED
|
@@ -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,
|
|
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
|
|
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.
|
package/dist/effect/google.js
CHANGED
|
@@ -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: [
|
|
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({
|
package/dist/endpoint.d.ts
CHANGED
|
@@ -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 `
|
|
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 {
|
|
1
|
+
import { Effect, runEffect } from "studiocms/effect";
|
|
2
2
|
import { GoogleOAuthAPI } from "./effect/google.js";
|
|
3
|
-
const initSession = async (context) => await
|
|
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
|
|
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.
|
|
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",
|
|
@@ -47,18 +47,17 @@
|
|
|
47
47
|
},
|
|
48
48
|
"type": "module",
|
|
49
49
|
"dependencies": {
|
|
50
|
-
"astro-integration-kit": "^0.
|
|
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
|
-
"
|
|
58
|
-
"
|
|
59
|
-
"effect": "^3.17.7",
|
|
57
|
+
"astro": "^5.12.9",
|
|
58
|
+
"effect": "^3.17.9",
|
|
60
59
|
"vite": "^6.3.4",
|
|
61
|
-
"studiocms": "0.1.0-beta.
|
|
60
|
+
"studiocms": "0.1.0-beta.25"
|
|
62
61
|
},
|
|
63
62
|
"scripts": {
|
|
64
63
|
"build": "buildkit build 'src/**/*.{ts,astro,css,json,png}'",
|