@tern-secure/nextjs 3.0.7 → 3.0.9
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/app-router/client/auth.d.ts +1 -0
- package/dist/app-router/client/auth.d.ts.map +1 -0
- package/dist/app-router/client/client-init.d.ts +1 -0
- package/dist/app-router/client/client-init.d.ts.map +1 -0
- package/dist/app-router/client/config.d.ts +1 -0
- package/dist/app-router/client/config.d.ts.map +1 -0
- package/dist/app-router/client/index.d.ts +1 -0
- package/dist/app-router/client/index.d.ts.map +1 -0
- package/dist/app-router/client/index.js +106 -0
- package/dist/app-router/client/index.js.map +7 -0
- package/dist/app-router/client/providers/ternSecureClientProvider.d.ts +1 -0
- package/dist/app-router/client/providers/ternSecureClientProvider.d.ts.map +1 -0
- package/dist/app-router/client/providers/ternSecureContext.d.ts +1 -0
- package/dist/app-router/client/providers/ternSecureContext.d.ts.map +1 -0
- package/dist/app-router/server/index.d.ts +1 -0
- package/dist/app-router/server/index.d.ts.map +1 -0
- package/dist/app-router/server/index.js +112 -0
- package/dist/app-router/server/index.js.map +7 -0
- package/dist/app-router/server/providers/TernSecureServerProvider.d.ts +1 -0
- package/dist/app-router/server/providers/TernSecureServerProvider.d.ts.map +1 -0
- package/dist/components/index.d.ts +1 -0
- package/dist/components/index.d.ts.map +1 -0
- package/dist/components/index.js +295 -0
- package/dist/components/index.js.map +7 -0
- package/dist/components/sign-in.d.ts +1 -0
- package/dist/components/sign-in.d.ts.map +1 -0
- package/dist/errors/index.d.ts +1 -0
- package/dist/errors/index.d.ts.map +1 -0
- package/dist/hooks/index.d.ts +1 -0
- package/dist/hooks/index.d.ts.map +1 -0
- package/dist/hooks/index.js +133 -0
- package/dist/hooks/index.js.map +7 -0
- package/dist/hooks/useAuth.d.ts +1 -0
- package/dist/hooks/useAuth.d.ts.map +1 -0
- package/dist/index.cjs.js +506 -2
- package/dist/index.cjs.js.map +7 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +464 -2
- package/dist/index.js.map +7 -0
- package/dist/types/index.d.ts +1 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +1 -0
- package/dist/types/index.js.map +7 -0
- package/dist/utils/create-styles.d.ts +1 -0
- package/dist/utils/create-styles.d.ts.map +1 -0
- package/dist/utils/create-styles.js +125 -0
- package/dist/utils/create-styles.js.map +7 -0
- package/package.json +16 -6
- package/dist/utils/index.d.ts +0 -1
|
@@ -0,0 +1,125 @@
|
|
|
1
|
+
"use client";
|
|
2
|
+
|
|
3
|
+
// src/utils/create-styles.ts
|
|
4
|
+
var PREFIX = "tern";
|
|
5
|
+
var styleInjection = {
|
|
6
|
+
isInjected: false,
|
|
7
|
+
styleElement: null
|
|
8
|
+
};
|
|
9
|
+
var defaultClassNames = {
|
|
10
|
+
container: `${PREFIX}-container`,
|
|
11
|
+
header: `${PREFIX}-header`,
|
|
12
|
+
title: `${PREFIX}-title`,
|
|
13
|
+
formWrapper: `${PREFIX}-formWrapper`,
|
|
14
|
+
formContainer: `${PREFIX}-formContainer`,
|
|
15
|
+
form: `${PREFIX}-form`,
|
|
16
|
+
label: `${PREFIX}-label`,
|
|
17
|
+
input: `${PREFIX}-input`,
|
|
18
|
+
button: `${PREFIX}-button`,
|
|
19
|
+
error: `${PREFIX}-error`
|
|
20
|
+
};
|
|
21
|
+
function createStyleSheet(styles2) {
|
|
22
|
+
if (typeof window === "undefined") return defaultClassNames;
|
|
23
|
+
if (styleInjection.isInjected) {
|
|
24
|
+
return defaultClassNames;
|
|
25
|
+
}
|
|
26
|
+
let styleElement = document.querySelector("[data-tern-secure]");
|
|
27
|
+
if (!styleElement) {
|
|
28
|
+
styleElement = document.createElement("style");
|
|
29
|
+
styleElement.setAttribute("data-tern-secure", "");
|
|
30
|
+
document.head.appendChild(styleElement);
|
|
31
|
+
styleInjection.styleElement = styleElement;
|
|
32
|
+
}
|
|
33
|
+
const cssRules = Object.entries(styles2).map(([key, rules]) => {
|
|
34
|
+
const className = defaultClassNames[key];
|
|
35
|
+
const cssProperties = Object.entries(rules).map(([prop, value]) => {
|
|
36
|
+
const cssProperty = prop.replace(/([A-Z])/g, "-$1").toLowerCase();
|
|
37
|
+
return `${cssProperty}: ${value};`;
|
|
38
|
+
}).join(" ");
|
|
39
|
+
return `.${className} { ${cssProperties} }`;
|
|
40
|
+
}).join("\n");
|
|
41
|
+
styleElement.textContent = cssRules;
|
|
42
|
+
styleInjection.isInjected = true;
|
|
43
|
+
return defaultClassNames;
|
|
44
|
+
}
|
|
45
|
+
var styleConfig = {
|
|
46
|
+
container: {
|
|
47
|
+
display: "flex",
|
|
48
|
+
minHeight: "100%",
|
|
49
|
+
flex: "1",
|
|
50
|
+
flexDirection: "column",
|
|
51
|
+
justifyContent: "center",
|
|
52
|
+
padding: "3rem 1.5rem"
|
|
53
|
+
},
|
|
54
|
+
header: {
|
|
55
|
+
margin: "0 auto",
|
|
56
|
+
width: "100%",
|
|
57
|
+
maxWidth: "28rem"
|
|
58
|
+
},
|
|
59
|
+
title: {
|
|
60
|
+
marginTop: "1.5rem",
|
|
61
|
+
textAlign: "center",
|
|
62
|
+
fontSize: "1.875rem",
|
|
63
|
+
fontWeight: "700",
|
|
64
|
+
lineHeight: "2.25rem",
|
|
65
|
+
letterSpacing: "-0.025em",
|
|
66
|
+
color: "var(--tern-text-primary, #111827)"
|
|
67
|
+
},
|
|
68
|
+
formWrapper: {
|
|
69
|
+
marginTop: "2.5rem",
|
|
70
|
+
margin: "0 auto",
|
|
71
|
+
width: "100%",
|
|
72
|
+
maxWidth: "30rem"
|
|
73
|
+
},
|
|
74
|
+
formContainer: {
|
|
75
|
+
padding: "3rem 1.5rem",
|
|
76
|
+
boxShadow: "0 1px 3px 0 rgb(0 0 0 / 0.1)",
|
|
77
|
+
borderRadius: "0.5rem",
|
|
78
|
+
backgroundColor: "var(--tern-background, white)"
|
|
79
|
+
},
|
|
80
|
+
form: {
|
|
81
|
+
display: "flex",
|
|
82
|
+
flexDirection: "column",
|
|
83
|
+
gap: "1rem"
|
|
84
|
+
},
|
|
85
|
+
label: {
|
|
86
|
+
display: "block",
|
|
87
|
+
fontSize: "0.875rem",
|
|
88
|
+
fontWeight: "500",
|
|
89
|
+
color: "var(--tern-text-secondary, #374151)"
|
|
90
|
+
},
|
|
91
|
+
input: {
|
|
92
|
+
marginTop: "0.25rem",
|
|
93
|
+
display: "block",
|
|
94
|
+
width: "100%",
|
|
95
|
+
padding: "0.5rem 0.75rem",
|
|
96
|
+
borderRadius: "0.375rem",
|
|
97
|
+
border: "1px solid var(--tern-border, #D1D5DB)",
|
|
98
|
+
backgroundColor: "var(--tern-input-background, white)",
|
|
99
|
+
color: "var(--tern-text-primary, #111827)"
|
|
100
|
+
},
|
|
101
|
+
button: {
|
|
102
|
+
display: "flex",
|
|
103
|
+
width: "100%",
|
|
104
|
+
justifyContent: "center",
|
|
105
|
+
padding: "0.5rem 1rem",
|
|
106
|
+
fontSize: "0.875rem",
|
|
107
|
+
fontWeight: "500",
|
|
108
|
+
color: "white",
|
|
109
|
+
backgroundColor: "var(--tern-primary, #2563EB)",
|
|
110
|
+
border: "none",
|
|
111
|
+
borderRadius: "0.375rem",
|
|
112
|
+
cursor: "pointer"
|
|
113
|
+
},
|
|
114
|
+
error: {
|
|
115
|
+
color: "var(--tern-error, #DC2626)",
|
|
116
|
+
fontSize: "0.875rem"
|
|
117
|
+
}
|
|
118
|
+
};
|
|
119
|
+
var styles = createStyleSheet(styleConfig);
|
|
120
|
+
export {
|
|
121
|
+
defaultClassNames,
|
|
122
|
+
styleConfig,
|
|
123
|
+
styles
|
|
124
|
+
};
|
|
125
|
+
//# sourceMappingURL=create-styles.js.map
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
{
|
|
2
|
+
"version": 3,
|
|
3
|
+
"sources": ["../../src/utils/create-styles.ts"],
|
|
4
|
+
"sourcesContent": ["'use client'\r\n\r\nconst PREFIX = 'tern'\r\n\r\n// Singleton to track style injection\r\nconst styleInjection = {\r\n isInjected: false,\r\n styleElement: null as HTMLStyleElement | null\r\n}\r\n\r\nexport const defaultClassNames = {\r\n container: `${PREFIX}-container`,\r\n header: `${PREFIX}-header`,\r\n title: `${PREFIX}-title`,\r\n formWrapper: `${PREFIX}-formWrapper`,\r\n formContainer: `${PREFIX}-formContainer`,\r\n form: `${PREFIX}-form`,\r\n label: `${PREFIX}-label`,\r\n input: `${PREFIX}-input`,\r\n button: `${PREFIX}-button`,\r\n error: `${PREFIX}-error`\r\n} as const\r\n\r\n// Create styles once and cache them\r\nfunction createStyleSheet(styles: Record<string, React.CSSProperties>) {\r\n if (typeof window === 'undefined') return defaultClassNames\r\n\r\n // Return early if styles are already injected\r\n if (styleInjection.isInjected) {\r\n return defaultClassNames\r\n }\r\n\r\n // Find existing style element or create new one\r\n let styleElement = document.querySelector<HTMLStyleElement>('[data-tern-secure]')\r\n \r\n if (!styleElement) {\r\n styleElement = document.createElement('style')\r\n styleElement.setAttribute('data-tern-secure', '')\r\n document.head.appendChild(styleElement)\r\n styleInjection.styleElement = styleElement\r\n }\r\n\r\n // Create CSS rules\r\n const cssRules = Object.entries(styles).map(([key, rules]) => {\r\n const className = defaultClassNames[key as keyof typeof defaultClassNames]\r\n const cssProperties = Object.entries(rules).map(([prop, value]) => {\r\n const cssProperty = prop.replace(/([A-Z])/g, '-$1').toLowerCase()\r\n return `${cssProperty}: ${value};`\r\n }).join(' ')\r\n\r\n return `.${className} { ${cssProperties} }`\r\n }).join('\\n')\r\n\r\n // Insert styles only once\r\n styleElement.textContent = cssRules\r\n styleInjection.isInjected = true\r\n\r\n return defaultClassNames\r\n}\r\n\r\n// Style configuration\r\nexport const styleConfig = {\r\n container: {\r\n display: 'flex',\r\n minHeight: '100%',\r\n flex: '1',\r\n flexDirection: 'column',\r\n justifyContent: 'center',\r\n padding: '3rem 1.5rem'\r\n },\r\n header: {\r\n margin: '0 auto',\r\n width: '100%',\r\n maxWidth: '28rem'\r\n },\r\n title: {\r\n marginTop: '1.5rem',\r\n textAlign: 'center',\r\n fontSize: '1.875rem',\r\n fontWeight: '700',\r\n lineHeight: '2.25rem',\r\n letterSpacing: '-0.025em',\r\n color: 'var(--tern-text-primary, #111827)'\r\n },\r\n formWrapper: {\r\n marginTop: '2.5rem',\r\n margin: '0 auto',\r\n width: '100%',\r\n maxWidth: '30rem'\r\n },\r\n formContainer: {\r\n padding: '3rem 1.5rem',\r\n boxShadow: '0 1px 3px 0 rgb(0 0 0 / 0.1)',\r\n borderRadius: '0.5rem',\r\n backgroundColor: 'var(--tern-background, white)'\r\n },\r\n form: {\r\n display: 'flex',\r\n flexDirection: 'column',\r\n gap: '1rem'\r\n },\r\n label: {\r\n display: 'block',\r\n fontSize: '0.875rem',\r\n fontWeight: '500',\r\n color: 'var(--tern-text-secondary, #374151)'\r\n },\r\n input: {\r\n marginTop: '0.25rem',\r\n display: 'block',\r\n width: '100%',\r\n padding: '0.5rem 0.75rem',\r\n borderRadius: '0.375rem',\r\n border: '1px solid var(--tern-border, #D1D5DB)',\r\n backgroundColor: 'var(--tern-input-background, white)',\r\n color: 'var(--tern-text-primary, #111827)'\r\n },\r\n button: {\r\n display: 'flex',\r\n width: '100%',\r\n justifyContent: 'center',\r\n padding: '0.5rem 1rem',\r\n fontSize: '0.875rem',\r\n fontWeight: '500',\r\n color: 'white',\r\n backgroundColor: 'var(--tern-primary, #2563EB)',\r\n border: 'none',\r\n borderRadius: '0.375rem',\r\n cursor: 'pointer'\r\n },\r\n error: {\r\n color: 'var(--tern-error, #DC2626)',\r\n fontSize: '0.875rem'\r\n }\r\n} as const\r\n\r\n// Export pre-created styles\r\nexport const styles = createStyleSheet(styleConfig)\r\n\r\n"],
|
|
5
|
+
"mappings": ";;;AAEA,IAAM,SAAS;AAGf,IAAM,iBAAiB;AAAA,EACrB,YAAY;AAAA,EACZ,cAAc;AAChB;AAEO,IAAM,oBAAoB;AAAA,EAC/B,WAAW,GAAG,MAAM;AAAA,EACpB,QAAQ,GAA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AAU;AAAA,EACZ;AAAA,EACA,OAAO;AAAA,IACL,WAAW;AAAA,IACX,WAAW;AAAA,IACX,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,YAAY;AAAA,IACZ,eAAe;AAAA,IACf,OAAO;AAAA,EACT;AAAA,EACA,aAAa;AAAA,IACX,WAAW;AAAA,IACX,QAAQ;AAAA,IACR,OAAO;AAAA,IACP,UAAU;AAAA,EACZ;AAAA,EACA,eAAe;AAAA,IACb,SAAS;AAAA,IACT,WAAW;AAAA,IACX,cAAc;AAAA,IACd,iBAAiB;AAAA,EACnB;AAAA,EACA,MAAM;AAAA,IACJ,SAAS;AAAA,IACT,eAAe;AAAA,IACf,KAAK;AAAA,EACP;AAAA,EACA,OAAO;AAAA,IACL,SAAS;AAAA,IACT,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,OAAO;AAAA,EACT;AAAA,EACA,OAAO;AAAA,IACL,WAAW;AAAA,IACX,SAAS;AAAA,IACT,OAAO;AAAA,IACP,SAAS;AAAA,IACT,cAAc;AAAA,IACd,QAAQ;AAAA,IACR,iBAAiB;AAAA,IACjB,OAAO;AAAA,EACT;AAAA,EACA,QAAQ;AAAA,IACN,SAAS;AAAA,IACT,OAAO;AAAA,IACP,gBAAgB;AAAA,IAChB,SAAS;AAAA,IACT,UAAU;AAAA,IACV,YAAY;AAAA,IACZ,OAAO;AAAA,IACP,iBAAiB;AAAA,IACjB,QAAQ;AAAA,IACR,cAAc;AAAA,IACd,QAAQ;AAAA,EACV;AAAA,EACA,OAAO;AAAA,IACL,OAAO;AAAA,IACP,UAAU;AAAA,EACZ;AACF;AAGO,IAAM,SAAS,iBAAiB,WAAW;",
|
|
6
|
+
"names": ["styles"]
|
|
7
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@tern-secure/nextjs",
|
|
3
|
-
"version": "3.0.
|
|
3
|
+
"version": "3.0.9",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"publishConfig": {
|
|
6
6
|
"access": "public",
|
|
@@ -16,8 +16,8 @@
|
|
|
16
16
|
"homepage": "https://github.com/tern-secure/nextjs#readme",
|
|
17
17
|
"main": "./dist/index.cjs.js",
|
|
18
18
|
"module": "./dist/index.js",
|
|
19
|
-
|
|
20
|
-
"build": "npm run build:types && npm run build:js",
|
|
19
|
+
"scripts": {
|
|
20
|
+
"build": "rimraf dist && npm run build:types && npm run build:js",
|
|
21
21
|
"build:types": "tsc --emitDeclarationOnly",
|
|
22
22
|
"build:js": "node build.config.cjs",
|
|
23
23
|
"clean": "rimraf dist",
|
|
@@ -99,9 +99,19 @@
|
|
|
99
99
|
"require": "./dist/index.cjs.js"
|
|
100
100
|
},
|
|
101
101
|
"./server": {
|
|
102
|
-
"types": "./dist/server/index.d.ts",
|
|
103
|
-
"import": "./dist/server/index.js",
|
|
104
|
-
"require": "./dist/server/index.
|
|
102
|
+
"types": "./dist/app-router/server/index.d.ts",
|
|
103
|
+
"import": "./dist/app-router/server/index.js",
|
|
104
|
+
"require": "./dist/app-router/server/index.js"
|
|
105
|
+
},
|
|
106
|
+
"./client": {
|
|
107
|
+
"types": "./dist/app-router/client/index.d.ts",
|
|
108
|
+
"import": "./dist/app-router/client/index.js",
|
|
109
|
+
"require": "./dist/app-router/client/index.js"
|
|
110
|
+
},
|
|
111
|
+
"./components": {
|
|
112
|
+
"types": "./dist/components/index.d.ts",
|
|
113
|
+
"import": "./dist/components/index.js",
|
|
114
|
+
"require": "./dist/components/index.js"
|
|
105
115
|
}
|
|
106
116
|
}
|
|
107
117
|
}
|
package/dist/utils/index.d.ts
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|