@studiocms/auth0 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/auth0.d.ts +4 -4
- package/dist/effect/auth0.js +9 -8
- package/package.json +5 -4
package/README.md
CHANGED
|
@@ -1,5 +1,7 @@
|
|
|
1
1
|
# @studiocms/auth0 Plugin
|
|
2
2
|
|
|
3
|
+
[](https://codecov.io/github/withstudiocms/studiocms)
|
|
4
|
+
|
|
3
5
|
This plugin integrates Auth0 as an OAuth provider for StudioCMS, enabling authentication via Auth0. It sets up the necessary configuration, including required environment variables and endpoint paths.
|
|
4
6
|
|
|
5
7
|
## Usage
|
package/dist/effect/auth0.d.ts
CHANGED
|
@@ -46,11 +46,11 @@ export declare class Auth0User extends Auth0User_base {
|
|
|
46
46
|
*/
|
|
47
47
|
export declare const cleanDomain: (domain: string) => string;
|
|
48
48
|
declare const Auth0OAuthAPI_base: Effect.Service.Class<Auth0OAuthAPI, "Auth0OAuthAPI", {
|
|
49
|
-
readonly dependencies: readonly [import("effect/Layer").Layer<import("studiocms/lib/auth/
|
|
49
|
+
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
50
|
readonly effect: Effect.Effect<{
|
|
51
|
-
initSession: (context: APIContext) => Effect.Effect<Response, import("
|
|
52
|
-
initCallback: (context: APIContext) => Effect.Effect<Response,
|
|
53
|
-
},
|
|
51
|
+
initSession: (context: APIContext) => Effect.Effect<Response, import("@withstudiocms/auth-kit/errors").SessionError, never>;
|
|
52
|
+
initCallback: (context: APIContext) => Effect.Effect<Response, import("@withstudiocms/auth-kit/errors").SessionError, never>;
|
|
53
|
+
}, import("@withstudiocms/auth-kit/errors").SessionError | import("@withstudiocms/auth-kit/errors").UserError, import("studiocms/lib/auth/verify-email").VerifyEmail | Platform.HttpClient.HttpClient>;
|
|
54
54
|
}>;
|
|
55
55
|
/**
|
|
56
56
|
* Provides Auth0 OAuth authentication effects for the StudioCMS API.
|
package/dist/effect/auth0.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 { Auth0, generateCodeVerifier, generateState } from "arctic";
|
|
7
|
+
import { LinkNewOAuthCookieName } from "studiocms/consts";
|
|
7
8
|
import { Effect, genLogger, Platform, pipe, Schema } from "studiocms/effect";
|
|
8
9
|
import { getCookie, getUrlParam, ValidateAuthCodeError } from "studiocms/oAuthUtils";
|
|
9
10
|
class Auth0User extends Schema.Class("Auth0User")({
|
|
@@ -27,12 +28,7 @@ const AUTH0 = {
|
|
|
27
28
|
REDIRECT_URI: getSecret("CMS_AUTH0_REDIRECT_URI") || ""
|
|
28
29
|
};
|
|
29
30
|
class Auth0OAuthAPI extends Effect.Service()("Auth0OAuthAPI", {
|
|
30
|
-
dependencies: [
|
|
31
|
-
Session.Default,
|
|
32
|
-
VerifyEmail.Default,
|
|
33
|
-
User.Default,
|
|
34
|
-
Platform.FetchHttpClient.layer
|
|
35
|
-
],
|
|
31
|
+
dependencies: [VerifyEmail.Default, Platform.FetchHttpClient.layer],
|
|
36
32
|
effect: genLogger("studiocms/routes/api/auth/auth0/effect")(function* () {
|
|
37
33
|
const [
|
|
38
34
|
sdk,
|
|
@@ -108,7 +104,7 @@ class Auth0OAuthAPI extends Effect.Service()("Auth0OAuthAPI", {
|
|
|
108
104
|
return redirect(StudioCMSRoutes.mainLinks.dashboardIndex);
|
|
109
105
|
}
|
|
110
106
|
const loggedInUser = yield* getUserData(context);
|
|
111
|
-
const linkNewOAuth = !!cookies.get(
|
|
107
|
+
const linkNewOAuth = !!cookies.get(LinkNewOAuthCookieName)?.value;
|
|
112
108
|
if (loggedInUser.user && linkNewOAuth) {
|
|
113
109
|
const existingUser2 = yield* sdk.GET.users.byId(loggedInUser.user.id);
|
|
114
110
|
if (existingUser2) {
|
|
@@ -134,7 +130,12 @@ class Auth0OAuthAPI extends Effect.Service()("Auth0OAuthAPI", {
|
|
|
134
130
|
name: auth0User.name,
|
|
135
131
|
email: auth0User.email,
|
|
136
132
|
avatar: auth0User.picture,
|
|
137
|
-
createdAt: /* @__PURE__ */ new Date()
|
|
133
|
+
createdAt: /* @__PURE__ */ new Date(),
|
|
134
|
+
emailVerified: false,
|
|
135
|
+
notifications: null,
|
|
136
|
+
password: null,
|
|
137
|
+
updatedAt: /* @__PURE__ */ new Date(),
|
|
138
|
+
url: null
|
|
138
139
|
},
|
|
139
140
|
{ provider: Auth0OAuthAPI.ProviderID, providerUserId: auth0UserId }
|
|
140
141
|
);
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@studiocms/auth0",
|
|
3
|
-
"version": "0.1.0-beta.
|
|
3
|
+
"version": "0.1.0-beta.27",
|
|
4
4
|
"description": "Add Auth0 OAuth Support into 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
|
}
|