jazz-react-auth-clerk 0.7.33-unique.2 → 0.7.35-guest-auth.5
Sign up to get free protection for your applications and to get access to all the features.
- package/.turbo/turbo-build.log +2 -2
- package/CHANGELOG.md +28 -0
- package/dist/index.js +19 -44
- package/dist/index.js.map +1 -1
- package/package.json +5 -6
- package/src/index.tsx +23 -80
package/.turbo/turbo-build.log
CHANGED
@@ -1,8 +1,8 @@
|
|
1
1
|
|
2
|
-
> jazz-react-auth-clerk@0.7.33-
|
2
|
+
> jazz-react-auth-clerk@0.7.33-guest-auth.3 build /Users/anselm/jazz/jazz/packages/jazz-react-auth-clerk
|
3
3
|
> npm run lint && rm -rf ./dist && tsc --sourceMap --outDir dist
|
4
4
|
|
5
5
|
|
6
|
-
> jazz-react-auth-clerk@0.7.33-
|
6
|
+
> jazz-react-auth-clerk@0.7.33-guest-auth.3 lint
|
7
7
|
> eslint . --ext ts,tsx
|
8
8
|
|
package/CHANGELOG.md
CHANGED
@@ -1,5 +1,33 @@
|
|
1
1
|
# jazz-browser-media-images
|
2
2
|
|
3
|
+
## 0.7.35-guest-auth.5
|
4
|
+
|
5
|
+
### Patch Changes
|
6
|
+
|
7
|
+
- Updated dependencies
|
8
|
+
- cojson@0.7.35-guest-auth.5
|
9
|
+
- jazz-browser-auth-clerk@0.7.35-guest-auth.5
|
10
|
+
- jazz-react@0.7.35-guest-auth.5
|
11
|
+
- jazz-tools@0.7.35-guest-auth.5
|
12
|
+
|
13
|
+
## 0.7.35-guest-auth.4
|
14
|
+
|
15
|
+
### Patch Changes
|
16
|
+
|
17
|
+
- Updated dependencies
|
18
|
+
- jazz-react@0.7.35-guest-auth.4
|
19
|
+
- jazz-tools@0.7.35-guest-auth.4
|
20
|
+
- jazz-browser-auth-clerk@0.7.35-guest-auth.4
|
21
|
+
|
22
|
+
## 0.7.33-guest-auth.3
|
23
|
+
|
24
|
+
### Patch Changes
|
25
|
+
|
26
|
+
- Updated dependencies
|
27
|
+
- jazz-react@0.7.35-guest-auth.3
|
28
|
+
- jazz-tools@0.7.35-guest-auth.3
|
29
|
+
- jazz-browser-auth-clerk@0.7.33-guest-auth.2
|
30
|
+
|
3
31
|
## 0.7.33-unique.2
|
4
32
|
|
5
33
|
### Patch Changes
|
package/dist/index.js
CHANGED
@@ -1,48 +1,23 @@
|
|
1
|
-
import { jsx as _jsx, jsxs as _jsxs } from "react/jsx-runtime";
|
2
|
-
import { SignedOut, SignInButton, useClerk } from "@clerk/clerk-react";
|
3
1
|
import { BrowserClerkAuth } from "jazz-browser-auth-clerk";
|
4
|
-
import {
|
5
|
-
|
6
|
-
|
7
|
-
errors: [],
|
8
|
-
});
|
9
|
-
export function JazzClerkAuth({ children }) {
|
10
|
-
const clerk = useClerk();
|
11
|
-
const [errors, setErrors] = useState([]);
|
2
|
+
import { useState, useMemo } from "react";
|
3
|
+
export function useJazzClerkAuth(clerk) {
|
4
|
+
const [state, setState] = useState({ errors: [] });
|
12
5
|
const authMethod = useMemo(() => {
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
6
|
+
if (clerk.user) {
|
7
|
+
return new BrowserClerkAuth({
|
8
|
+
onError: (error) => {
|
9
|
+
void clerk.signOut();
|
10
|
+
setState((state) => ({
|
11
|
+
...state,
|
12
|
+
errors: [...state.errors, error.toString()],
|
13
|
+
}));
|
14
|
+
},
|
15
|
+
}, clerk);
|
16
|
+
}
|
17
|
+
else {
|
18
|
+
return undefined;
|
19
|
+
}
|
20
|
+
}, [clerk.user]);
|
21
|
+
return [authMethod, state];
|
21
22
|
}
|
22
|
-
const JazzClerkBasicUI = ({ appName }) => {
|
23
|
-
const { errors } = useContext(JazzClerkAuthCtx);
|
24
|
-
const darkMode = typeof window !== "undefined"
|
25
|
-
? window.matchMedia("(prefers-color-scheme: dark)").matches
|
26
|
-
: false;
|
27
|
-
return (_jsx(SignedOut, { children: _jsx("div", { style: {
|
28
|
-
width: "100vw",
|
29
|
-
height: "100vh",
|
30
|
-
display: "flex",
|
31
|
-
alignItems: "center",
|
32
|
-
justifyContent: "center",
|
33
|
-
...(darkMode ? { background: "#000" } : {}),
|
34
|
-
}, children: _jsxs("div", { style: {
|
35
|
-
width: "18rem",
|
36
|
-
display: "flex",
|
37
|
-
flexDirection: "column",
|
38
|
-
gap: "2rem",
|
39
|
-
}, children: [_jsx("h1", { style: {
|
40
|
-
color: darkMode ? "#fff" : "#000",
|
41
|
-
textAlign: "center",
|
42
|
-
}, children: appName }), _jsx(SignInButton, {}), errors.map((error) => (_jsx("div", { style: { color: "red" }, children: error }, error)))] }) }) }));
|
43
|
-
};
|
44
|
-
// eslint-disable-next-line @typescript-eslint/no-namespace
|
45
|
-
(function (JazzClerkAuth) {
|
46
|
-
JazzClerkAuth.BasicUI = JazzClerkBasicUI;
|
47
|
-
})(JazzClerkAuth || (JazzClerkAuth = {}));
|
48
23
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
@@ -1 +1 @@
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.tsx"],"names":[],"mappings":"AAAA,OAAO,EAAE,gBAAgB,EAAsB,MAAM,yBAAyB,CAAC;AAC/E,OAAO,EAAE,QAAQ,EAAE,OAAO,EAAE,MAAM,OAAO,CAAC;AAE1C,MAAM,UAAU,gBAAgB,CAAC,KAEhC;IACG,MAAM,CAAC,KAAK,EAAE,QAAQ,CAAC,GAAG,QAAQ,CAAuB,EAAE,MAAM,EAAE,EAAE,EAAE,CAAC,CAAC;IAEzE,MAAM,UAAU,GAAG,OAAO,CAAC,GAAG,EAAE;QAC5B,IAAI,KAAK,CAAC,IAAI,EAAE,CAAC;YACb,OAAO,IAAI,gBAAgB,CACvB;gBACI,OAAO,EAAE,CAAC,KAAK,EAAE,EAAE;oBACf,KAAK,KAAK,CAAC,OAAO,EAAE,CAAC;oBACrB,QAAQ,CAAC,CAAC,KAAK,EAAE,EAAE,CAAC,CAAC;wBACjB,GAAG,KAAK;wBACR,MAAM,EAAE,CAAC,GAAG,KAAK,CAAC,MAAM,EAAE,KAAK,CAAC,QAAQ,EAAE,CAAC;qBAC9C,CAAC,CAAC,CAAC;gBACR,CAAC;aACJ,EACD,KAAK,CACR,CAAC;QACN,CAAC;aAAM,CAAC;YACJ,OAAO,SAAS,CAAC;QACrB,CAAC;IACL,CAAC,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,CAAC;IAEjB,OAAO,CAAC,UAAU,EAAE,KAAK,CAAU,CAAC;AACxC,CAAC"}
|
package/package.json
CHANGED
@@ -1,18 +1,17 @@
|
|
1
1
|
{
|
2
2
|
"name": "jazz-react-auth-clerk",
|
3
|
-
"version": "0.7.
|
3
|
+
"version": "0.7.35-guest-auth.5",
|
4
4
|
"type": "module",
|
5
5
|
"main": "dist/index.js",
|
6
6
|
"types": "src/index.tsx",
|
7
7
|
"license": "MIT",
|
8
8
|
"dependencies": {},
|
9
9
|
"peerDependencies": {
|
10
|
-
"@clerk/clerk-react": "^4.0.0",
|
11
10
|
"react": "^18.2.0",
|
12
|
-
"cojson": "0.7.35-
|
13
|
-
"jazz-
|
14
|
-
"jazz-
|
15
|
-
"jazz-
|
11
|
+
"cojson": "0.7.35-guest-auth.5",
|
12
|
+
"jazz-react": "0.7.35-guest-auth.5",
|
13
|
+
"jazz-browser-auth-clerk": "0.7.35-guest-auth.5",
|
14
|
+
"jazz-tools": "0.7.35-guest-auth.5"
|
16
15
|
},
|
17
16
|
"devDependencies": {
|
18
17
|
"typescript": "^5.1.6",
|
package/src/index.tsx
CHANGED
@@ -1,86 +1,29 @@
|
|
1
|
-
import {
|
2
|
-
import {
|
3
|
-
import { AuthMethodCtx } from "jazz-react";
|
4
|
-
import { useState, useMemo, ReactNode, useContext, createContext } from "react";
|
1
|
+
import { BrowserClerkAuth, MinimalClerkClient } from "jazz-browser-auth-clerk";
|
2
|
+
import { useState, useMemo } from "react";
|
5
3
|
|
6
|
-
export
|
7
|
-
|
8
|
-
}
|
9
|
-
errors: []
|
10
|
-
});
|
11
|
-
|
12
|
-
export function JazzClerkAuth({ children }: { children: ReactNode }) {
|
13
|
-
const clerk = useClerk();
|
14
|
-
const [errors, setErrors] = useState<string[]>([]);
|
4
|
+
export function useJazzClerkAuth(clerk: MinimalClerkClient & {
|
5
|
+
signOut: () => Promise<unknown>;
|
6
|
+
}) {
|
7
|
+
const [state, setState] = useState<{ errors: string[] }>({ errors: [] });
|
15
8
|
|
16
9
|
const authMethod = useMemo(() => {
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
10
|
+
if (clerk.user) {
|
11
|
+
return new BrowserClerkAuth(
|
12
|
+
{
|
13
|
+
onError: (error) => {
|
14
|
+
void clerk.signOut();
|
15
|
+
setState((state) => ({
|
16
|
+
...state,
|
17
|
+
errors: [...state.errors, error.toString()],
|
18
|
+
}));
|
19
|
+
},
|
22
20
|
},
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
<JazzClerkAuthCtx.Provider value={{ errors }}>
|
30
|
-
<AuthMethodCtx.Provider value={authMethod}>
|
31
|
-
{children}
|
32
|
-
</AuthMethodCtx.Provider>
|
33
|
-
</JazzClerkAuthCtx.Provider>
|
34
|
-
);
|
35
|
-
}
|
36
|
-
|
37
|
-
const JazzClerkBasicUI = ({ appName }: { appName: string }) => {
|
38
|
-
const { errors } = useContext(JazzClerkAuthCtx);
|
39
|
-
const darkMode =
|
40
|
-
typeof window !== "undefined"
|
41
|
-
? window.matchMedia("(prefers-color-scheme: dark)").matches
|
42
|
-
: false;
|
43
|
-
return (
|
44
|
-
<SignedOut>
|
45
|
-
<div
|
46
|
-
style={{
|
47
|
-
width: "100vw",
|
48
|
-
height: "100vh",
|
49
|
-
display: "flex",
|
50
|
-
alignItems: "center",
|
51
|
-
justifyContent: "center",
|
52
|
-
...(darkMode ? { background: "#000" } : {}),
|
53
|
-
}}
|
54
|
-
>
|
55
|
-
<div
|
56
|
-
style={{
|
57
|
-
width: "18rem",
|
58
|
-
display: "flex",
|
59
|
-
flexDirection: "column",
|
60
|
-
gap: "2rem",
|
61
|
-
}}
|
62
|
-
>
|
63
|
-
<h1
|
64
|
-
style={{
|
65
|
-
color: darkMode ? "#fff" : "#000",
|
66
|
-
textAlign: "center",
|
67
|
-
}}
|
68
|
-
>
|
69
|
-
{appName}
|
70
|
-
</h1>
|
71
|
-
<SignInButton />
|
72
|
-
{errors.map((error) => (
|
73
|
-
<div key={error} style={{ color: "red" }}>
|
74
|
-
{error}
|
75
|
-
</div>
|
76
|
-
))}
|
77
|
-
</div>
|
78
|
-
</div>
|
79
|
-
</SignedOut>
|
80
|
-
);
|
81
|
-
};
|
21
|
+
clerk,
|
22
|
+
);
|
23
|
+
} else {
|
24
|
+
return undefined;
|
25
|
+
}
|
26
|
+
}, [clerk.user]);
|
82
27
|
|
83
|
-
|
84
|
-
export namespace JazzClerkAuth {
|
85
|
-
export const BasicUI = JazzClerkBasicUI;
|
28
|
+
return [authMethod, state] as const;
|
86
29
|
}
|