@studiocms/github 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.
@@ -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/verify-email").VerifyEmail, Error, never>, import("effect/Layer").Layer<Platform.HttpClient.HttpClient, never, never>];
48
+ 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>];
49
49
  readonly effect: Effect.Effect<{
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>;
50
+ initSession: (context: APIContext) => Effect.Effect<Response, import("effect/ConfigError").ConfigError | import("@withstudiocms/auth-kit/errors").SessionError, never>;
51
+ initCallback: (context: APIContext) => Effect.Effect<Response, any, never>;
52
+ }, 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>;
53
53
  }>;
54
54
  /**
55
55
  * Provides GitHub OAuth authentication effects for the StudioCMS API.
@@ -18,9 +18,9 @@ class GitHubUser extends Schema.Class("GitHubUser")({
18
18
  }) {
19
19
  }
20
20
  const GITHUB = {
21
- CLIENT_ID: getSecret("GITHUB_CLIENT_ID") ?? "",
22
- CLIENT_SECRET: getSecret("GITHUB_CLIENT_SECRET") ?? "",
23
- REDIRECT_URI: getSecret("GITHUB_REDIRECT_URI") ?? null
21
+ CLIENT_ID: getSecret("CMS_GITHUB_CLIENT_ID") ?? "",
22
+ CLIENT_SECRET: getSecret("CMS_GITHUB_CLIENT_SECRET") ?? "",
23
+ REDIRECT_URI: getSecret("CMS_GITHUB_REDIRECT_URI") ?? null
24
24
  };
25
25
  class GitHubOAuthAPI extends Effect.Service()("GitHubOAuthAPI", {
26
26
  dependencies: [VerifyEmail.Default, Platform.FetchHttpClient.layer],
@@ -42,13 +42,11 @@ class GitHubOAuthAPI extends Effect.Service()("GitHubOAuthAPI", {
42
42
  }
43
43
  }).pipe(
44
44
  Effect.flatMap(Platform.HttpClientResponse.schemaBodyJson(GitHubUser)),
45
- Effect.catchAll(
46
- (error) => Effect.fail(
47
- new ValidateAuthCodeError({
48
- provider: GitHubOAuthAPI.ProviderID,
49
- message: `Failed to fetch user info: ${error.message}`
50
- })
51
- )
45
+ Effect.mapError(
46
+ (error) => new ValidateAuthCodeError({
47
+ provider: GitHubOAuthAPI.ProviderID,
48
+ message: `Failed to fetch user info: ${error.message}`
49
+ })
52
50
  )
53
51
  );
54
52
  });
@@ -72,10 +70,10 @@ class GitHubOAuthAPI extends Effect.Service()("GitHubOAuthAPI", {
72
70
  }
73
71
  const githubUser = yield* validateAuthCode(code);
74
72
  const { id: githubUserId, login: githubUsername } = githubUser;
75
- const existingOAuthAccount = yield* sdk.AUTH.oAuth.searchProvidersForId(
76
- GitHubOAuthAPI.ProviderID,
77
- `${githubUserId}`
78
- );
73
+ const existingOAuthAccount = yield* sdk.AUTH.oAuth.searchProvidersForId({
74
+ providerId: GitHubOAuthAPI.ProviderID,
75
+ userId: `${githubUserId}`
76
+ });
79
77
  if (existingOAuthAccount) {
80
78
  const user = yield* sdk.GET.users.byId(existingOAuthAccount.userId);
81
79
  if (!user) {
@@ -117,12 +115,12 @@ class GitHubOAuthAPI extends Effect.Service()("GitHubOAuthAPI", {
117
115
  email: githubUser.email || null,
118
116
  name: githubUser.name || githubUsername,
119
117
  avatar: githubUser.avatar_url,
120
- createdAt: /* @__PURE__ */ new Date(),
118
+ createdAt: (/* @__PURE__ */ new Date()).toISOString(),
121
119
  url: githubUser.blog || null,
122
120
  emailVerified: false,
123
121
  notifications: null,
124
122
  password: null,
125
- updatedAt: /* @__PURE__ */ new Date()
123
+ updatedAt: (/* @__PURE__ */ new Date()).toISOString()
126
124
  },
127
125
  { provider: GitHubOAuthAPI.ProviderID, providerUserId: `${githubUserId}` }
128
126
  );
package/dist/index.js CHANGED
@@ -8,7 +8,7 @@ function studiocmsGithub() {
8
8
  name: "StudioCMS GitHub Plugin",
9
9
  studiocmsMinimumVersion: "0.1.0-beta.22",
10
10
  hooks: {
11
- "studiocms:config:setup": ({ setAuthService }) => {
11
+ "studiocms:auth": ({ setAuthService }) => {
12
12
  setAuthService({
13
13
  oAuthProvider: {
14
14
  name: "github",
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@studiocms/github",
3
- "version": "0.1.0-beta.30",
3
+ "version": "0.1.0",
4
4
  "description": "Add GitHub OAuth Support to your StudioCMS project.",
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.2",
58
+ "effect": "^3.19.14",
59
59
  "vite": "^6.3.4",
60
- "studiocms": "0.1.0-beta.30"
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
  }