@studiocms/github 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 +2 -0
- package/dist/effect/github.d.ts +4 -4
- package/dist/effect/github.js +9 -9
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @studiocms/github Plugin
|
|
2
2
|
|
|
3
|
+
[](https://codecov.io/github/withstudiocms/studiocms)
|
|
4
|
+
|
|
3
5
|
This plugin integrates GitHub as an OAuth authentication provider for StudioCMS. It sets up the necessary authentication service, including the provider's name, endpoint paths and required environment variables.
|
|
4
6
|
|
|
5
7
|
## Usage
|
package/dist/effect/github.d.ts
CHANGED
|
@@ -45,11 +45,11 @@ declare const GitHubUser_base: Schema.Class<GitHubUser, {
|
|
|
45
45
|
export declare class GitHubUser extends GitHubUser_base {
|
|
46
46
|
}
|
|
47
47
|
declare const GitHubOAuthAPI_base: Effect.Service.Class<GitHubOAuthAPI, "GitHubOAuthAPI", {
|
|
48
|
-
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>];
|
|
49
49
|
readonly effect: Effect.Effect<{
|
|
50
|
-
initSession: (context: APIContext) => Effect.Effect<Response, import("
|
|
51
|
-
initCallback: (context: APIContext) => Effect.Effect<Response,
|
|
52
|
-
},
|
|
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>;
|
|
53
53
|
}>;
|
|
54
54
|
/**
|
|
55
55
|
* Provides GitHub OAuth authentication effects for the StudioCMS API.
|
package/dist/effect/github.js
CHANGED
|
@@ -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 { GitHub, 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 GitHubUser extends Schema.Class("GitHubUser")({
|
|
@@ -22,12 +23,7 @@ const GITHUB = {
|
|
|
22
23
|
REDIRECT_URI: getSecret("GITHUB_REDIRECT_URI") ?? null
|
|
23
24
|
};
|
|
24
25
|
class GitHubOAuthAPI extends Effect.Service()("GitHubOAuthAPI", {
|
|
25
|
-
dependencies: [
|
|
26
|
-
Session.Default,
|
|
27
|
-
VerifyEmail.Default,
|
|
28
|
-
User.Default,
|
|
29
|
-
Platform.FetchHttpClient.layer
|
|
30
|
-
],
|
|
26
|
+
dependencies: [VerifyEmail.Default, Platform.FetchHttpClient.layer],
|
|
31
27
|
effect: genLogger("studiocms/routes/api/auth/github/effect")(function* () {
|
|
32
28
|
const [
|
|
33
29
|
sdk,
|
|
@@ -95,7 +91,7 @@ class GitHubOAuthAPI extends Effect.Service()("GitHubOAuthAPI", {
|
|
|
95
91
|
return redirect(StudioCMSRoutes.mainLinks.dashboardIndex);
|
|
96
92
|
}
|
|
97
93
|
const loggedInUser = yield* getUserData(context);
|
|
98
|
-
const linkNewOAuth = !!cookies.get(
|
|
94
|
+
const linkNewOAuth = !!cookies.get(LinkNewOAuthCookieName)?.value;
|
|
99
95
|
if (loggedInUser.user && linkNewOAuth) {
|
|
100
96
|
const existingUser2 = yield* sdk.GET.users.byId(loggedInUser.user.id);
|
|
101
97
|
if (existingUser2) {
|
|
@@ -118,11 +114,15 @@ class GitHubOAuthAPI extends Effect.Service()("GitHubOAuthAPI", {
|
|
|
118
114
|
{
|
|
119
115
|
id: crypto.randomUUID(),
|
|
120
116
|
username: githubUsername,
|
|
121
|
-
email: githubUser.email,
|
|
117
|
+
email: githubUser.email || null,
|
|
122
118
|
name: githubUser.name || githubUsername,
|
|
123
119
|
avatar: githubUser.avatar_url,
|
|
124
120
|
createdAt: /* @__PURE__ */ new Date(),
|
|
125
|
-
url: githubUser.blog
|
|
121
|
+
url: githubUser.blog || null,
|
|
122
|
+
emailVerified: false,
|
|
123
|
+
notifications: null,
|
|
124
|
+
password: null,
|
|
125
|
+
updatedAt: /* @__PURE__ */ new Date()
|
|
126
126
|
},
|
|
127
127
|
{ provider: GitHubOAuthAPI.ProviderID, providerUserId: `${githubUserId}` }
|
|
128
128
|
);
|
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.27",
|
|
4
4
|
"description": "Add GitHub OAuth Support to your StudioCMS project.",
|
|
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.
|
|
58
|
+
"effect": "^3.17.14",
|
|
59
59
|
"vite": "^6.3.4",
|
|
60
|
-
"studiocms": "0.1.0-beta.
|
|
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
|
}
|