@studiocms/github 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.
- package/dist/effect/github.d.ts +5 -6
- package/dist/effect/github.js +12 -8
- package/dist/endpoint.d.ts +1 -1
- package/dist/endpoint.js +3 -3
- package/package.json +5 -6
package/dist/effect/github.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 GitHubUser_base: Schema.Class<GitHubUser, {
|
|
5
4
|
id: typeof Schema.Number;
|
|
6
5
|
html_url: typeof Schema.String;
|
|
@@ -46,11 +45,11 @@ declare const GitHubUser_base: Schema.Class<GitHubUser, {
|
|
|
46
45
|
export declare class GitHubUser extends GitHubUser_base {
|
|
47
46
|
}
|
|
48
47
|
declare const GitHubOAuthAPI_base: Effect.Service.Class<GitHubOAuthAPI, "GitHubOAuthAPI", {
|
|
49
|
-
readonly dependencies: readonly [import("effect/Layer").Layer<import("studiocms/lib/auth/
|
|
48
|
+
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>];
|
|
50
49
|
readonly effect: Effect.Effect<{
|
|
51
|
-
initSession: (context: APIContext) => Effect.Effect<Response, import("
|
|
52
|
-
initCallback: (context: APIContext) => Effect.Effect<Response, import("
|
|
53
|
-
},
|
|
50
|
+
initSession: (context: APIContext) => Effect.Effect<Response, import("@withstudiocms/auth-kit/errors").SessionError, never>;
|
|
51
|
+
initCallback: (context: APIContext) => Effect.Effect<Response, import("@withstudiocms/auth-kit/errors").SessionError, never>;
|
|
52
|
+
}, import("@withstudiocms/auth-kit/errors").SessionError | import("@withstudiocms/auth-kit/errors").UserError, import("studiocms/lib/auth/verify-email").VerifyEmail | Platform.HttpClient.HttpClient>;
|
|
54
53
|
}>;
|
|
55
54
|
/**
|
|
56
55
|
* Provides GitHub OAuth authentication effects for the StudioCMS API.
|
package/dist/effect/github.js
CHANGED
|
@@ -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 { GitHub, generateState } from "arctic";
|
|
8
|
-
import {
|
|
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 GitHubUser extends Schema.Class("GitHubUser")({
|
|
11
11
|
id: Schema.Number,
|
|
@@ -23,7 +23,7 @@ const GITHUB = {
|
|
|
23
23
|
REDIRECT_URI: getSecret("GITHUB_REDIRECT_URI") ?? null
|
|
24
24
|
};
|
|
25
25
|
class GitHubOAuthAPI extends Effect.Service()("GitHubOAuthAPI", {
|
|
26
|
-
dependencies: [
|
|
26
|
+
dependencies: [VerifyEmail.Default, Platform.FetchHttpClient.layer],
|
|
27
27
|
effect: genLogger("studiocms/routes/api/auth/github/effect")(function* () {
|
|
28
28
|
const [
|
|
29
29
|
sdk,
|
|
@@ -31,7 +31,7 @@ class GitHubOAuthAPI extends Effect.Service()("GitHubOAuthAPI", {
|
|
|
31
31
|
{ setOAuthSessionTokenCookie, createUserSession },
|
|
32
32
|
{ isEmailVerified, sendVerificationEmail },
|
|
33
33
|
{ getUserData, createOAuthUser }
|
|
34
|
-
] = yield* Effect.all([SDKCore, HttpClient.HttpClient, Session, VerifyEmail, User]);
|
|
34
|
+
] = yield* Effect.all([SDKCore, Platform.HttpClient.HttpClient, Session, VerifyEmail, User]);
|
|
35
35
|
const { CLIENT_ID, CLIENT_SECRET, REDIRECT_URI } = GITHUB;
|
|
36
36
|
const github = new GitHub(CLIENT_ID, CLIENT_SECRET, REDIRECT_URI);
|
|
37
37
|
const validateAuthCode = (code) => genLogger("studiocms/routes/api/auth/github/effect.validateAuthCode")(function* () {
|
|
@@ -41,7 +41,7 @@ class GitHubOAuthAPI extends Effect.Service()("GitHubOAuthAPI", {
|
|
|
41
41
|
Authorization: `Bearer ${tokens.accessToken}`
|
|
42
42
|
}
|
|
43
43
|
}).pipe(
|
|
44
|
-
Effect.flatMap(HttpClientResponse.schemaBodyJson(GitHubUser)),
|
|
44
|
+
Effect.flatMap(Platform.HttpClientResponse.schemaBodyJson(GitHubUser)),
|
|
45
45
|
Effect.catchAll(
|
|
46
46
|
(error) => Effect.fail(
|
|
47
47
|
new ValidateAuthCodeError({
|
|
@@ -91,7 +91,7 @@ class GitHubOAuthAPI extends Effect.Service()("GitHubOAuthAPI", {
|
|
|
91
91
|
return redirect(StudioCMSRoutes.mainLinks.dashboardIndex);
|
|
92
92
|
}
|
|
93
93
|
const loggedInUser = yield* getUserData(context);
|
|
94
|
-
const linkNewOAuth = !!cookies.get(
|
|
94
|
+
const linkNewOAuth = !!cookies.get(LinkNewOAuthCookieName)?.value;
|
|
95
95
|
if (loggedInUser.user && linkNewOAuth) {
|
|
96
96
|
const existingUser2 = yield* sdk.GET.users.byId(loggedInUser.user.id);
|
|
97
97
|
if (existingUser2) {
|
|
@@ -114,11 +114,15 @@ class GitHubOAuthAPI extends Effect.Service()("GitHubOAuthAPI", {
|
|
|
114
114
|
{
|
|
115
115
|
id: crypto.randomUUID(),
|
|
116
116
|
username: githubUsername,
|
|
117
|
-
email: githubUser.email,
|
|
117
|
+
email: githubUser.email || null,
|
|
118
118
|
name: githubUser.name || githubUsername,
|
|
119
119
|
avatar: githubUser.avatar_url,
|
|
120
120
|
createdAt: /* @__PURE__ */ new Date(),
|
|
121
|
-
url: githubUser.blog
|
|
121
|
+
url: githubUser.blog || null,
|
|
122
|
+
emailVerified: false,
|
|
123
|
+
notifications: null,
|
|
124
|
+
password: null,
|
|
125
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
122
126
|
},
|
|
123
127
|
{ provider: GitHubOAuthAPI.ProviderID, providerUserId: `${githubUserId}` }
|
|
124
128
|
);
|
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 `GitHubOAuthAPI` 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 { GitHubOAuthAPI } from "./effect/github.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* GitHubOAuthAPI;
|
|
6
6
|
return yield* initSession2(context);
|
|
7
7
|
}).pipe(Effect.provide(GitHubOAuthAPI.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* GitHubOAuthAPI;
|
|
12
12
|
return yield* initCallback2(context);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiocms/github",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.26",
|
|
4
4
|
"description": "Add GitHub OAuth Support to your StudioCMS project.",
|
|
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.13",
|
|
60
59
|
"vite": "^6.3.4",
|
|
61
|
-
"studiocms": "0.1.0-beta.
|
|
60
|
+
"studiocms": "0.1.0-beta.26"
|
|
62
61
|
},
|
|
63
62
|
"scripts": {
|
|
64
63
|
"build": "buildkit build 'src/**/*.{ts,astro,css,json,png}'",
|