@civic/auth 0.6.0 → 0.6.1-beta.1
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/shared/components/CivicAuthIframeContainer.js +1 -1
- package/dist/shared/components/CivicAuthIframeContainer.js.map +1 -1
- package/dist/shared/lib/BrowserAuthenticationRefresher.d.ts +7 -1
- package/dist/shared/lib/BrowserAuthenticationRefresher.d.ts.map +1 -1
- package/dist/shared/lib/BrowserAuthenticationRefresher.js +15 -2
- package/dist/shared/lib/BrowserAuthenticationRefresher.js.map +1 -1
- package/dist/shared/lib/util.d.ts +1 -1
- package/dist/shared/lib/util.d.ts.map +1 -1
- package/dist/shared/lib/util.js +6 -1
- package/dist/shared/lib/util.js.map +1 -1
- package/dist/shared/version.d.ts +1 -1
- package/dist/shared/version.d.ts.map +1 -1
- package/dist/shared/version.js +1 -1
- package/dist/shared/version.js.map +1 -1
- package/dist/vanillajs/auth/CivicAuth.d.ts +63 -5
- package/dist/vanillajs/auth/CivicAuth.d.ts.map +1 -1
- package/dist/vanillajs/auth/CivicAuth.js +202 -26
- package/dist/vanillajs/auth/CivicAuth.js.map +1 -1
- package/dist/vanillajs/auth/OAuthCallbackHandler.d.ts +90 -0
- package/dist/vanillajs/auth/OAuthCallbackHandler.d.ts.map +1 -0
- package/dist/vanillajs/auth/OAuthCallbackHandler.js +143 -0
- package/dist/vanillajs/auth/OAuthCallbackHandler.js.map +1 -0
- package/dist/vanillajs/auth/SessionManager.d.ts +40 -9
- package/dist/vanillajs/auth/SessionManager.d.ts.map +1 -1
- package/dist/vanillajs/auth/SessionManager.js +96 -61
- package/dist/vanillajs/auth/SessionManager.js.map +1 -1
- package/dist/vanillajs/auth/TokenRefresher.d.ts +54 -0
- package/dist/vanillajs/auth/TokenRefresher.d.ts.map +1 -0
- package/dist/vanillajs/auth/TokenRefresher.js +166 -0
- package/dist/vanillajs/auth/TokenRefresher.js.map +1 -0
- package/dist/vanillajs/iframe/IframeManager.d.ts +82 -0
- package/dist/vanillajs/iframe/IframeManager.d.ts.map +1 -0
- package/dist/vanillajs/iframe/IframeManager.js +487 -0
- package/dist/vanillajs/iframe/IframeManager.js.map +1 -0
- package/dist/vanillajs/iframe/IframeResizer.d.ts +15 -0
- package/dist/vanillajs/iframe/IframeResizer.d.ts.map +1 -0
- package/dist/vanillajs/iframe/IframeResizer.js +127 -0
- package/dist/vanillajs/iframe/IframeResizer.js.map +1 -0
- package/dist/vanillajs/index.d.ts +8 -7
- package/dist/vanillajs/index.d.ts.map +1 -1
- package/dist/vanillajs/index.js +10 -7
- package/dist/vanillajs/index.js.map +1 -1
- package/dist/vanillajs/types/index.d.ts +2 -2
- package/dist/vanillajs/types/index.d.ts.map +1 -1
- package/dist/vanillajs/types/index.js.map +1 -1
- package/dist/vanillajs/ui/LoadingComponents.d.ts +51 -0
- package/dist/vanillajs/ui/LoadingComponents.d.ts.map +1 -0
- package/dist/vanillajs/ui/LoadingComponents.js +363 -0
- package/dist/vanillajs/ui/LoadingComponents.js.map +1 -0
- package/package.json +1 -1
- package/dist/vanillajs/iframe/domUtils.d.ts +0 -4
- package/dist/vanillajs/iframe/domUtils.d.ts.map +0 -1
- package/dist/vanillajs/iframe/domUtils.js +0 -25
- package/dist/vanillajs/iframe/domUtils.js.map +0 -1
- package/dist/vanillajs/storage/BrowserCookieStorageAdapter.d.ts +0 -19
- package/dist/vanillajs/storage/BrowserCookieStorageAdapter.d.ts.map +0 -1
- package/dist/vanillajs/storage/BrowserCookieStorageAdapter.js +0 -101
- package/dist/vanillajs/storage/BrowserCookieStorageAdapter.js.map +0 -1
- package/dist/vanillajs/storage/BrowserLocalStorageAdapter.d.ts +0 -9
- package/dist/vanillajs/storage/BrowserLocalStorageAdapter.d.ts.map +0 -1
- package/dist/vanillajs/storage/BrowserLocalStorageAdapter.js +0 -36
- package/dist/vanillajs/storage/BrowserLocalStorageAdapter.js.map +0 -1
- package/dist/vanillajs/storage/InMemoryStorageAdapter.d.ts +0 -9
- package/dist/vanillajs/storage/InMemoryStorageAdapter.d.ts.map +0 -1
- package/dist/vanillajs/storage/InMemoryStorageAdapter.js +0 -16
- package/dist/vanillajs/storage/InMemoryStorageAdapter.js.map +0 -1
- package/dist/vanillajs/storage/StorageAdapter.d.ts +0 -15
- package/dist/vanillajs/storage/StorageAdapter.d.ts.map +0 -1
- package/dist/vanillajs/storage/StorageAdapter.js +0 -16
- package/dist/vanillajs/storage/StorageAdapter.js.map +0 -1
- package/dist/vanillajs/utils/page-handlers.d.ts +0 -29
- package/dist/vanillajs/utils/page-handlers.d.ts.map +0 -1
- package/dist/vanillajs/utils/page-handlers.js +0 -165
- package/dist/vanillajs/utils/page-handlers.js.map +0 -1
|
@@ -0,0 +1,363 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* UI Components for Civic Auth Vanilla JS implementation
|
|
3
|
+
* Converted from React components to vanilla DOM elements
|
|
4
|
+
*/
|
|
5
|
+
/**
|
|
6
|
+
* Utility function to set multiple styles on an element using a key-value object
|
|
7
|
+
*/
|
|
8
|
+
function setStyles(element, styles) {
|
|
9
|
+
Object.entries(styles).forEach(([property, value]) => {
|
|
10
|
+
// eslint-disable-next-line @typescript-eslint/no-explicit-any -- CSSStyleDeclaration has read-only properties that prevent proper typing
|
|
11
|
+
element.style[property] = value;
|
|
12
|
+
});
|
|
13
|
+
}
|
|
14
|
+
/**
|
|
15
|
+
* Utility function to set multiple attributes on an element using a key-value object
|
|
16
|
+
*/
|
|
17
|
+
function setAttributes(element, attributes) {
|
|
18
|
+
Object.entries(attributes).forEach(([name, value]) => {
|
|
19
|
+
element.setAttribute(name, value);
|
|
20
|
+
});
|
|
21
|
+
}
|
|
22
|
+
/**
|
|
23
|
+
* Creates a horizontal shimmer loader element (SVG-based)
|
|
24
|
+
* Equivalent to the SVGLoading component from React implementation
|
|
25
|
+
*/
|
|
26
|
+
export function createShimmerLoader(options = {}) {
|
|
27
|
+
const { backgroundColor = "#ffffff", width = "100%", height = "40px", borderRadius = "0.5rem", } = options;
|
|
28
|
+
// Create container div
|
|
29
|
+
const container = document.createElement("div");
|
|
30
|
+
setStyles(container, {
|
|
31
|
+
position: "absolute",
|
|
32
|
+
top: "-6px",
|
|
33
|
+
left: "0",
|
|
34
|
+
borderRadius,
|
|
35
|
+
backgroundColor,
|
|
36
|
+
width,
|
|
37
|
+
height,
|
|
38
|
+
opacity: "1",
|
|
39
|
+
});
|
|
40
|
+
setAttributes(container, {
|
|
41
|
+
class: "civic-auth-shimmer-loader",
|
|
42
|
+
});
|
|
43
|
+
// Add CSS animation keyframes
|
|
44
|
+
const style = document.createElement("style");
|
|
45
|
+
style.textContent = `
|
|
46
|
+
@keyframes civic-shimmer {
|
|
47
|
+
0% {
|
|
48
|
+
transform: translate(-328px, 0);
|
|
49
|
+
}
|
|
50
|
+
100% {
|
|
51
|
+
transform: translate(328px, 0);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
`;
|
|
55
|
+
// Only add the style if it doesn't already exist
|
|
56
|
+
if (!document.querySelector("style[data-civic-shimmer]")) {
|
|
57
|
+
style.setAttribute("data-civic-shimmer", "true");
|
|
58
|
+
document.head.appendChild(style);
|
|
59
|
+
}
|
|
60
|
+
// Create SVG element
|
|
61
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
62
|
+
setAttributes(svg, {
|
|
63
|
+
"shape-rendering": "geometricPrecision",
|
|
64
|
+
"text-rendering": "geometricPrecision",
|
|
65
|
+
viewBox: "0 0 324 28",
|
|
66
|
+
height: "40",
|
|
67
|
+
width: "100%",
|
|
68
|
+
class: "civic-auth-svg-loading",
|
|
69
|
+
});
|
|
70
|
+
setStyles(svg, {
|
|
71
|
+
position: "absolute",
|
|
72
|
+
top: "-6px",
|
|
73
|
+
left: "0",
|
|
74
|
+
borderRadius,
|
|
75
|
+
backgroundColor,
|
|
76
|
+
});
|
|
77
|
+
// Create gradient definition
|
|
78
|
+
const defs = document.createElementNS("http://www.w3.org/2000/svg", "defs");
|
|
79
|
+
const gradient = document.createElementNS("http://www.w3.org/2000/svg", "linearGradient");
|
|
80
|
+
setAttributes(gradient, {
|
|
81
|
+
id: `civic-shimmer-gradient-${Date.now()}`,
|
|
82
|
+
x2: "320",
|
|
83
|
+
y1: "15",
|
|
84
|
+
y2: "15",
|
|
85
|
+
gradientUnits: "userSpaceOnUse",
|
|
86
|
+
});
|
|
87
|
+
// Create gradient stops
|
|
88
|
+
const stop1 = document.createElementNS("http://www.w3.org/2000/svg", "stop");
|
|
89
|
+
setAttributes(stop1, {
|
|
90
|
+
offset: "0",
|
|
91
|
+
"stop-color": backgroundColor,
|
|
92
|
+
});
|
|
93
|
+
const stop2 = document.createElementNS("http://www.w3.org/2000/svg", "stop");
|
|
94
|
+
setAttributes(stop2, {
|
|
95
|
+
offset: ".511",
|
|
96
|
+
"stop-color": "#9A9DA6",
|
|
97
|
+
});
|
|
98
|
+
const stop3 = document.createElementNS("http://www.w3.org/2000/svg", "stop");
|
|
99
|
+
setAttributes(stop3, {
|
|
100
|
+
offset: "1",
|
|
101
|
+
"stop-color": backgroundColor,
|
|
102
|
+
});
|
|
103
|
+
gradient.appendChild(stop1);
|
|
104
|
+
gradient.appendChild(stop2);
|
|
105
|
+
gradient.appendChild(stop3);
|
|
106
|
+
defs.appendChild(gradient);
|
|
107
|
+
// Create background rectangle
|
|
108
|
+
const rect = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
109
|
+
setAttributes(rect, {
|
|
110
|
+
id: "civic-shimmer-rect",
|
|
111
|
+
fill: backgroundColor,
|
|
112
|
+
d: "M0 0h328v28H0z",
|
|
113
|
+
});
|
|
114
|
+
// Create shimmer path
|
|
115
|
+
const shimmer = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
116
|
+
setAttributes(shimmer, {
|
|
117
|
+
id: "civic-shimmer-path",
|
|
118
|
+
fill: `url(#${gradient.getAttribute("id")})`,
|
|
119
|
+
d: "M0 -2h328v34H0z",
|
|
120
|
+
transform: "translate(-328)",
|
|
121
|
+
});
|
|
122
|
+
setStyles(shimmer, {
|
|
123
|
+
animation: "1s linear infinite both civic-shimmer",
|
|
124
|
+
});
|
|
125
|
+
// Assemble SVG
|
|
126
|
+
svg.appendChild(defs);
|
|
127
|
+
svg.appendChild(rect);
|
|
128
|
+
svg.appendChild(shimmer);
|
|
129
|
+
// Add SVG to container
|
|
130
|
+
container.appendChild(svg);
|
|
131
|
+
return container;
|
|
132
|
+
}
|
|
133
|
+
/**
|
|
134
|
+
* Creates a shimmer loader for iframe loading states
|
|
135
|
+
* Positioned to center within an iframe container
|
|
136
|
+
*/
|
|
137
|
+
export function createIframeShimmerLoader(backgroundColor = "#ffffff", maxWidth) {
|
|
138
|
+
const wrapper = document.createElement("div");
|
|
139
|
+
const wrapperStyles = {
|
|
140
|
+
width: "100%",
|
|
141
|
+
height: "26px",
|
|
142
|
+
display: "flex",
|
|
143
|
+
alignItems: "center",
|
|
144
|
+
justifyContent: "center",
|
|
145
|
+
position: "absolute",
|
|
146
|
+
top: "50%",
|
|
147
|
+
left: "50%",
|
|
148
|
+
transform: "translate(-50%, -50%)",
|
|
149
|
+
borderRadius: "13px",
|
|
150
|
+
overflow: "hidden",
|
|
151
|
+
};
|
|
152
|
+
// Add max-width if specified
|
|
153
|
+
if (maxWidth) {
|
|
154
|
+
wrapperStyles.maxWidth = maxWidth;
|
|
155
|
+
}
|
|
156
|
+
setStyles(wrapper, wrapperStyles);
|
|
157
|
+
setAttributes(wrapper, {
|
|
158
|
+
"data-testid": "iframe-shimmer-loader",
|
|
159
|
+
class: "civic-auth-iframe-shimmer-wrapper",
|
|
160
|
+
});
|
|
161
|
+
const shimmerLoader = createShimmerLoader({
|
|
162
|
+
backgroundColor,
|
|
163
|
+
width: "100%",
|
|
164
|
+
height: "26px",
|
|
165
|
+
borderRadius: "13px",
|
|
166
|
+
});
|
|
167
|
+
wrapper.appendChild(shimmerLoader);
|
|
168
|
+
return wrapper;
|
|
169
|
+
}
|
|
170
|
+
/**
|
|
171
|
+
* Creates a simple horizontal skeleton loader (CSS-based alternative)
|
|
172
|
+
* Lighter weight alternative to SVG shimmer
|
|
173
|
+
*/
|
|
174
|
+
export function createSkeletonLoader(options = {}) {
|
|
175
|
+
const { backgroundColor = "#f0f0f0", width = "100%", height = "20px", borderRadius = "4px", } = options;
|
|
176
|
+
const skeleton = document.createElement("div");
|
|
177
|
+
setStyles(skeleton, {
|
|
178
|
+
width,
|
|
179
|
+
height,
|
|
180
|
+
background: `linear-gradient(90deg, ${backgroundColor} 25%, #e0e0e0 50%, ${backgroundColor} 75%)`,
|
|
181
|
+
backgroundSize: "200% 100%",
|
|
182
|
+
animation: "civic-skeleton-shimmer 1.5s infinite",
|
|
183
|
+
borderRadius,
|
|
184
|
+
});
|
|
185
|
+
setAttributes(skeleton, {
|
|
186
|
+
class: "civic-auth-skeleton-loader",
|
|
187
|
+
});
|
|
188
|
+
// Add CSS animation keyframes for skeleton
|
|
189
|
+
const style = document.createElement("style");
|
|
190
|
+
style.textContent = `
|
|
191
|
+
@keyframes civic-skeleton-shimmer {
|
|
192
|
+
0% { background-position: -200% 0; }
|
|
193
|
+
100% { background-position: 200% 0; }
|
|
194
|
+
}
|
|
195
|
+
`;
|
|
196
|
+
// Only add the style if it doesn't already exist
|
|
197
|
+
if (!document.querySelector("style[data-civic-skeleton]")) {
|
|
198
|
+
style.setAttribute("data-civic-skeleton", "true");
|
|
199
|
+
document.head.appendChild(style);
|
|
200
|
+
}
|
|
201
|
+
return skeleton;
|
|
202
|
+
}
|
|
203
|
+
/**
|
|
204
|
+
* Creates a button content loader that hides content and shows a skeleton
|
|
205
|
+
* Equivalent to ButtonContentOrLoader from React implementation
|
|
206
|
+
*/
|
|
207
|
+
export function createButtonContentLoader(content) {
|
|
208
|
+
const container = document.createElement("div");
|
|
209
|
+
setStyles(container, {
|
|
210
|
+
position: "relative",
|
|
211
|
+
display: "flex",
|
|
212
|
+
alignItems: "center",
|
|
213
|
+
justifyContent: "center",
|
|
214
|
+
});
|
|
215
|
+
setAttributes(container, {
|
|
216
|
+
class: "civic-auth-button-content-loader",
|
|
217
|
+
});
|
|
218
|
+
// Content span
|
|
219
|
+
const contentSpan = document.createElement("span");
|
|
220
|
+
setStyles(contentSpan, {
|
|
221
|
+
visibility: "visible",
|
|
222
|
+
whiteSpace: "nowrap",
|
|
223
|
+
});
|
|
224
|
+
setAttributes(contentSpan, {
|
|
225
|
+
class: "civic-auth-button-content",
|
|
226
|
+
});
|
|
227
|
+
if (typeof content === "string") {
|
|
228
|
+
contentSpan.textContent = content;
|
|
229
|
+
}
|
|
230
|
+
else {
|
|
231
|
+
contentSpan.appendChild(content);
|
|
232
|
+
}
|
|
233
|
+
// Loader span (hidden by default)
|
|
234
|
+
const loaderSpan = document.createElement("span");
|
|
235
|
+
setStyles(loaderSpan, {
|
|
236
|
+
position: "absolute",
|
|
237
|
+
display: "none",
|
|
238
|
+
justifyContent: "center",
|
|
239
|
+
alignItems: "center",
|
|
240
|
+
top: "0",
|
|
241
|
+
left: "0",
|
|
242
|
+
right: "0",
|
|
243
|
+
bottom: "0",
|
|
244
|
+
});
|
|
245
|
+
setAttributes(loaderSpan, {
|
|
246
|
+
class: "civic-auth-button-loader",
|
|
247
|
+
});
|
|
248
|
+
// Create skeleton loader for button
|
|
249
|
+
const skeletonLoader = createSkeletonLoader({
|
|
250
|
+
width: "70%",
|
|
251
|
+
height: "14px",
|
|
252
|
+
borderRadius: "7px",
|
|
253
|
+
});
|
|
254
|
+
loaderSpan.appendChild(skeletonLoader);
|
|
255
|
+
container.appendChild(contentSpan);
|
|
256
|
+
container.appendChild(loaderSpan);
|
|
257
|
+
return {
|
|
258
|
+
container,
|
|
259
|
+
showLoader: () => {
|
|
260
|
+
contentSpan.style.visibility = "hidden";
|
|
261
|
+
loaderSpan.style.display = "flex";
|
|
262
|
+
},
|
|
263
|
+
hideLoader: () => {
|
|
264
|
+
contentSpan.style.visibility = "visible";
|
|
265
|
+
loaderSpan.style.display = "none";
|
|
266
|
+
},
|
|
267
|
+
setContent: (newContent) => {
|
|
268
|
+
contentSpan.innerHTML = "";
|
|
269
|
+
if (typeof newContent === "string") {
|
|
270
|
+
contentSpan.textContent = newContent;
|
|
271
|
+
}
|
|
272
|
+
else {
|
|
273
|
+
contentSpan.appendChild(newContent);
|
|
274
|
+
}
|
|
275
|
+
},
|
|
276
|
+
};
|
|
277
|
+
}
|
|
278
|
+
/**
|
|
279
|
+
* Creates a close icon (X) SVG element
|
|
280
|
+
* Equivalent to the CloseIcon component from React implementation
|
|
281
|
+
*/
|
|
282
|
+
export function createCloseIcon() {
|
|
283
|
+
const svg = document.createElementNS("http://www.w3.org/2000/svg", "svg");
|
|
284
|
+
setAttributes(svg, {
|
|
285
|
+
xmlns: "http://www.w3.org/2000/svg",
|
|
286
|
+
width: "24",
|
|
287
|
+
height: "24",
|
|
288
|
+
viewBox: "0 0 24 24",
|
|
289
|
+
fill: "none",
|
|
290
|
+
stroke: "currentColor",
|
|
291
|
+
"stroke-width": "2",
|
|
292
|
+
"stroke-linecap": "round",
|
|
293
|
+
"stroke-linejoin": "round",
|
|
294
|
+
class: "lucide lucide-x",
|
|
295
|
+
});
|
|
296
|
+
// Create the X paths
|
|
297
|
+
const path1 = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
298
|
+
setAttributes(path1, {
|
|
299
|
+
d: "M18 6 6 18",
|
|
300
|
+
});
|
|
301
|
+
const path2 = document.createElementNS("http://www.w3.org/2000/svg", "path");
|
|
302
|
+
setAttributes(path2, {
|
|
303
|
+
d: "m6 6 12 12",
|
|
304
|
+
});
|
|
305
|
+
svg.appendChild(path1);
|
|
306
|
+
svg.appendChild(path2);
|
|
307
|
+
return svg;
|
|
308
|
+
}
|
|
309
|
+
/**
|
|
310
|
+
* Creates a close button for modal iframes
|
|
311
|
+
* Positioned absolutely in the top-right corner
|
|
312
|
+
*/
|
|
313
|
+
export function createCloseButton(onClose) {
|
|
314
|
+
const button = document.createElement("button");
|
|
315
|
+
setStyles(button, {
|
|
316
|
+
position: "absolute",
|
|
317
|
+
right: "0.6rem",
|
|
318
|
+
top: "0.6rem",
|
|
319
|
+
cursor: "pointer",
|
|
320
|
+
display: "flex",
|
|
321
|
+
alignItems: "center",
|
|
322
|
+
justifyContent: "center",
|
|
323
|
+
border: "none",
|
|
324
|
+
backgroundColor: "transparent",
|
|
325
|
+
padding: "0.25rem",
|
|
326
|
+
color: "#9ca3af",
|
|
327
|
+
zIndex: "100",
|
|
328
|
+
opacity: "0",
|
|
329
|
+
transition: "opacity 50ms ease",
|
|
330
|
+
});
|
|
331
|
+
setAttributes(button, {
|
|
332
|
+
type: "button",
|
|
333
|
+
"aria-label": "Close",
|
|
334
|
+
});
|
|
335
|
+
// Add hover effect
|
|
336
|
+
button.addEventListener("mouseenter", () => {
|
|
337
|
+
button.style.opacity = "0.8";
|
|
338
|
+
});
|
|
339
|
+
button.addEventListener("mouseleave", () => {
|
|
340
|
+
button.style.opacity = "1";
|
|
341
|
+
});
|
|
342
|
+
// Add the close icon
|
|
343
|
+
const closeIcon = createCloseIcon();
|
|
344
|
+
button.appendChild(closeIcon);
|
|
345
|
+
// Add click handler
|
|
346
|
+
button.addEventListener("click", onClose);
|
|
347
|
+
return button;
|
|
348
|
+
}
|
|
349
|
+
/**
|
|
350
|
+
* Utility function to remove all civic auth loading styles from the document
|
|
351
|
+
* Useful for cleanup
|
|
352
|
+
*/
|
|
353
|
+
export function cleanupLoadingStyles() {
|
|
354
|
+
const shimmerStyle = document.querySelector("style[data-civic-shimmer]");
|
|
355
|
+
const skeletonStyle = document.querySelector("style[data-civic-skeleton]");
|
|
356
|
+
if (shimmerStyle) {
|
|
357
|
+
shimmerStyle.remove();
|
|
358
|
+
}
|
|
359
|
+
if (skeletonStyle) {
|
|
360
|
+
skeletonStyle.remove();
|
|
361
|
+
}
|
|
362
|
+
}
|
|
363
|
+
//# sourceMappingURL=LoadingComponents.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"LoadingComponents.js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AClC,MAAM,YAAY,GAAG,QAAQ,CAAC,aAAa,CAAC,2BAA2B,CAAC,CAAC;IACzE,MAAM,aAAa,GAAG,QAAQ,CAAC,aAAa,CAAC,4BAA4B,CAAC,CAAC;IAE3E,IAAI,YAAY,EAAE,CAAC;QACjB,YAAY,CAAC,MAAM,EAAE,CAAC;IACxB,CAAC;IAED,IAAI,aAAa,EAAE,CAAC;QAClB,aAAa,CAAC,MAAM,EAAE,CAAC;IACzB,CAAC;AACH,CAAC","sourcesContent":["/**\n * UI Components for Civic Auth Vanilla JS implementation\n * Converted from React components to vanilla DOM elements\n */\n\n/**\n * Utility function to set multiple styles on an element using a key-value object\n */\nfunction setStyles(\n element: HTMLElement | SVGElement,\n styles: Record<string, string>,\n): void {\n Object.entries(styles).forEach(([property, value]) => {\n // eslint-disable-next-line @typescript-eslint/no-explicit-any -- CSSStyleDeclaration has read-only properties that prevent proper typing\n (element.style as any)[property] = value;\n });\n}\n\n/**\n * Utility function to set multiple attributes on an element using a key-value object\n */\nfunction setAttributes(\n element: Element,\n attributes: Record<string, string>,\n): void {\n Object.entries(attributes).forEach(([name, value]) => {\n element.setAttribute(name, value);\n });\n}\n\nexport interface ShimmerLoaderOptions {\n backgroundColor?: string;\n width?: string;\n height?: string;\n borderRadius?: string;\n}\n\n/**\n * Creates a horizontal shimmer loader element (SVG-based)\n * Equivalent to the SVGLoading component from React implementation\n */\nexport function createShimmerLoader(\n options: ShimmerLoaderOptions = {},\n): HTMLElement {\n const {\n backgroundColor = \"#ffffff\",\n width = \"100%\",\n height = \"40px\",\n borderRadius = \"0.5rem\",\n } = options;\n\n // Create container div\n const container = document.createElement(\"div\");\n setStyles(container, {\n position: \"absolute\",\n top: \"-6px\",\n left: \"0\",\n borderRadius,\n backgroundColor,\n width,\n height,\n opacity: \"1\",\n });\n setAttributes(container, {\n class: \"civic-auth-shimmer-loader\",\n });\n\n // Add CSS animation keyframes\n const style = document.createElement(\"style\");\n style.textContent = `\n @keyframes civic-shimmer {\n 0% {\n transform: translate(-328px, 0);\n }\n 100% {\n transform: translate(328px, 0);\n }\n }\n `;\n\n // Only add the style if it doesn't already exist\n if (!document.querySelector(\"style[data-civic-shimmer]\")) {\n style.setAttribute(\"data-civic-shimmer\", \"true\");\n document.head.appendChild(style);\n }\n\n // Create SVG element\n const svg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n setAttributes(svg, {\n \"shape-rendering\": \"geometricPrecision\",\n \"text-rendering\": \"geometricPrecision\",\n viewBox: \"0 0 324 28\",\n height: \"40\",\n width: \"100%\",\n class: \"civic-auth-svg-loading\",\n });\n setStyles(svg, {\n position: \"absolute\",\n top: \"-6px\",\n left: \"0\",\n borderRadius,\n backgroundColor,\n });\n\n // Create gradient definition\n const defs = document.createElementNS(\"http://www.w3.org/2000/svg\", \"defs\");\n const gradient = document.createElementNS(\n \"http://www.w3.org/2000/svg\",\n \"linearGradient\",\n );\n setAttributes(gradient, {\n id: `civic-shimmer-gradient-${Date.now()}`,\n x2: \"320\",\n y1: \"15\",\n y2: \"15\",\n gradientUnits: \"userSpaceOnUse\",\n });\n\n // Create gradient stops\n const stop1 = document.createElementNS(\"http://www.w3.org/2000/svg\", \"stop\");\n setAttributes(stop1, {\n offset: \"0\",\n \"stop-color\": backgroundColor,\n });\n\n const stop2 = document.createElementNS(\"http://www.w3.org/2000/svg\", \"stop\");\n setAttributes(stop2, {\n offset: \".511\",\n \"stop-color\": \"#9A9DA6\",\n });\n\n const stop3 = document.createElementNS(\"http://www.w3.org/2000/svg\", \"stop\");\n setAttributes(stop3, {\n offset: \"1\",\n \"stop-color\": backgroundColor,\n });\n\n gradient.appendChild(stop1);\n gradient.appendChild(stop2);\n gradient.appendChild(stop3);\n defs.appendChild(gradient);\n\n // Create background rectangle\n const rect = document.createElementNS(\"http://www.w3.org/2000/svg\", \"path\");\n setAttributes(rect, {\n id: \"civic-shimmer-rect\",\n fill: backgroundColor,\n d: \"M0 0h328v28H0z\",\n });\n\n // Create shimmer path\n const shimmer = document.createElementNS(\n \"http://www.w3.org/2000/svg\",\n \"path\",\n );\n setAttributes(shimmer, {\n id: \"civic-shimmer-path\",\n fill: `url(#${gradient.getAttribute(\"id\")})`,\n d: \"M0 -2h328v34H0z\",\n transform: \"translate(-328)\",\n });\n setStyles(shimmer, {\n animation: \"1s linear infinite both civic-shimmer\",\n });\n\n // Assemble SVG\n svg.appendChild(defs);\n svg.appendChild(rect);\n svg.appendChild(shimmer);\n\n // Add SVG to container\n container.appendChild(svg);\n\n return container;\n}\n\n/**\n * Creates a shimmer loader for iframe loading states\n * Positioned to center within an iframe container\n */\nexport function createIframeShimmerLoader(\n backgroundColor = \"#ffffff\",\n maxWidth?: string,\n): HTMLElement {\n const wrapper = document.createElement(\"div\");\n const wrapperStyles: Record<string, string> = {\n width: \"100%\",\n height: \"26px\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n position: \"absolute\",\n top: \"50%\",\n left: \"50%\",\n transform: \"translate(-50%, -50%)\",\n borderRadius: \"13px\",\n overflow: \"hidden\",\n };\n\n // Add max-width if specified\n if (maxWidth) {\n wrapperStyles.maxWidth = maxWidth;\n }\n\n setStyles(wrapper, wrapperStyles);\n setAttributes(wrapper, {\n \"data-testid\": \"iframe-shimmer-loader\",\n class: \"civic-auth-iframe-shimmer-wrapper\",\n });\n\n const shimmerLoader = createShimmerLoader({\n backgroundColor,\n width: \"100%\",\n height: \"26px\",\n borderRadius: \"13px\",\n });\n\n wrapper.appendChild(shimmerLoader);\n return wrapper;\n}\n\n/**\n * Creates a simple horizontal skeleton loader (CSS-based alternative)\n * Lighter weight alternative to SVG shimmer\n */\nexport function createSkeletonLoader(\n options: ShimmerLoaderOptions = {},\n): HTMLElement {\n const {\n backgroundColor = \"#f0f0f0\",\n width = \"100%\",\n height = \"20px\",\n borderRadius = \"4px\",\n } = options;\n\n const skeleton = document.createElement(\"div\");\n setStyles(skeleton, {\n width,\n height,\n background: `linear-gradient(90deg, ${backgroundColor} 25%, #e0e0e0 50%, ${backgroundColor} 75%)`,\n backgroundSize: \"200% 100%\",\n animation: \"civic-skeleton-shimmer 1.5s infinite\",\n borderRadius,\n });\n setAttributes(skeleton, {\n class: \"civic-auth-skeleton-loader\",\n });\n\n // Add CSS animation keyframes for skeleton\n const style = document.createElement(\"style\");\n style.textContent = `\n @keyframes civic-skeleton-shimmer {\n 0% { background-position: -200% 0; }\n 100% { background-position: 200% 0; }\n }\n `;\n\n // Only add the style if it doesn't already exist\n if (!document.querySelector(\"style[data-civic-skeleton]\")) {\n style.setAttribute(\"data-civic-skeleton\", \"true\");\n document.head.appendChild(style);\n }\n\n return skeleton;\n}\n\n/**\n * Creates a button content loader that hides content and shows a skeleton\n * Equivalent to ButtonContentOrLoader from React implementation\n */\nexport function createButtonContentLoader(content: string | HTMLElement): {\n container: HTMLElement;\n showLoader: () => void;\n hideLoader: () => void;\n setContent: (newContent: string | HTMLElement) => void;\n} {\n const container = document.createElement(\"div\");\n setStyles(container, {\n position: \"relative\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n });\n setAttributes(container, {\n class: \"civic-auth-button-content-loader\",\n });\n\n // Content span\n const contentSpan = document.createElement(\"span\");\n setStyles(contentSpan, {\n visibility: \"visible\",\n whiteSpace: \"nowrap\",\n });\n setAttributes(contentSpan, {\n class: \"civic-auth-button-content\",\n });\n\n if (typeof content === \"string\") {\n contentSpan.textContent = content;\n } else {\n contentSpan.appendChild(content);\n }\n\n // Loader span (hidden by default)\n const loaderSpan = document.createElement(\"span\");\n setStyles(loaderSpan, {\n position: \"absolute\",\n display: \"none\",\n justifyContent: \"center\",\n alignItems: \"center\",\n top: \"0\",\n left: \"0\",\n right: \"0\",\n bottom: \"0\",\n });\n setAttributes(loaderSpan, {\n class: \"civic-auth-button-loader\",\n });\n\n // Create skeleton loader for button\n const skeletonLoader = createSkeletonLoader({\n width: \"70%\",\n height: \"14px\",\n borderRadius: \"7px\",\n });\n loaderSpan.appendChild(skeletonLoader);\n\n container.appendChild(contentSpan);\n container.appendChild(loaderSpan);\n\n return {\n container,\n showLoader: () => {\n contentSpan.style.visibility = \"hidden\";\n loaderSpan.style.display = \"flex\";\n },\n hideLoader: () => {\n contentSpan.style.visibility = \"visible\";\n loaderSpan.style.display = \"none\";\n },\n setContent: (newContent: string | HTMLElement) => {\n contentSpan.innerHTML = \"\";\n if (typeof newContent === \"string\") {\n contentSpan.textContent = newContent;\n } else {\n contentSpan.appendChild(newContent);\n }\n },\n };\n}\n\n/**\n * Creates a close icon (X) SVG element\n * Equivalent to the CloseIcon component from React implementation\n */\nexport function createCloseIcon(): SVGElement {\n const svg = document.createElementNS(\"http://www.w3.org/2000/svg\", \"svg\");\n setAttributes(svg, {\n xmlns: \"http://www.w3.org/2000/svg\",\n width: \"24\",\n height: \"24\",\n viewBox: \"0 0 24 24\",\n fill: \"none\",\n stroke: \"currentColor\",\n \"stroke-width\": \"2\",\n \"stroke-linecap\": \"round\",\n \"stroke-linejoin\": \"round\",\n class: \"lucide lucide-x\",\n });\n\n // Create the X paths\n const path1 = document.createElementNS(\"http://www.w3.org/2000/svg\", \"path\");\n setAttributes(path1, {\n d: \"M18 6 6 18\",\n });\n\n const path2 = document.createElementNS(\"http://www.w3.org/2000/svg\", \"path\");\n setAttributes(path2, {\n d: \"m6 6 12 12\",\n });\n\n svg.appendChild(path1);\n svg.appendChild(path2);\n\n return svg;\n}\n\n/**\n * Creates a close button for modal iframes\n * Positioned absolutely in the top-right corner\n */\nexport function createCloseButton(onClose: () => void): HTMLButtonElement {\n const button = document.createElement(\"button\");\n setStyles(button, {\n position: \"absolute\",\n right: \"0.6rem\",\n top: \"0.6rem\",\n cursor: \"pointer\",\n display: \"flex\",\n alignItems: \"center\",\n justifyContent: \"center\",\n border: \"none\",\n backgroundColor: \"transparent\",\n padding: \"0.25rem\",\n color: \"#9ca3af\",\n zIndex: \"100\",\n opacity: \"0\",\n transition: \"opacity 50ms ease\",\n });\n setAttributes(button, {\n type: \"button\",\n \"aria-label\": \"Close\",\n });\n\n // Add hover effect\n button.addEventListener(\"mouseenter\", () => {\n button.style.opacity = \"0.8\";\n });\n\n button.addEventListener(\"mouseleave\", () => {\n button.style.opacity = \"1\";\n });\n\n // Add the close icon\n const closeIcon = createCloseIcon();\n button.appendChild(closeIcon);\n\n // Add click handler\n button.addEventListener(\"click\", onClose);\n\n return button;\n}\n\n/**\n * Utility function to remove all civic auth loading styles from the document\n * Useful for cleanup\n */\nexport function cleanupLoadingStyles(): void {\n const shimmerStyle = document.querySelector(\"style[data-civic-shimmer]\");\n const skeletonStyle = document.querySelector(\"style[data-civic-skeleton]\");\n\n if (shimmerStyle) {\n shimmerStyle.remove();\n }\n\n if (skeletonStyle) {\n skeletonStyle.remove();\n }\n}\n"]}
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"domUtils.d.ts","sourceRoot":"","sources":["../../../src/vanillajs/iframe/domUtils.ts"],"names":[],"mappings":"AAGA,wBAAgB,YAAY,CAC1B,GAAG,EAAE,MAAM,EACX,SAAS,EAAE,WAAW,EACtB,EAAE,CAAC,EAAE,MAAM,GACV,iBAAiB,CAWnB;AAED,wBAAgB,YAAY,CAAC,MAAM,EAAE,iBAAiB,GAAG,MAAM,GAAG,IAAI,CAQrE;AAKD,OAAO,EAAE,CAAC"}
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
// Placeholder for DOM Utilities (Task C)
|
|
2
|
-
// This file will contain helper functions for DOM manipulation related to the iframe.
|
|
3
|
-
export function createIframe(url, container, id) {
|
|
4
|
-
const iframe = document.createElement("iframe");
|
|
5
|
-
iframe.id = id || "civic-auth-iframe";
|
|
6
|
-
iframe.src = url;
|
|
7
|
-
// Basic styling, can be expanded
|
|
8
|
-
iframe.style.border = "none";
|
|
9
|
-
iframe.style.width = "100%";
|
|
10
|
-
iframe.style.height = "100%";
|
|
11
|
-
container.appendChild(iframe);
|
|
12
|
-
return iframe;
|
|
13
|
-
}
|
|
14
|
-
export function removeIframe(iframe) {
|
|
15
|
-
const element = typeof iframe === "string"
|
|
16
|
-
? document.getElementById(iframe)
|
|
17
|
-
: iframe;
|
|
18
|
-
if (element && element.parentNode) {
|
|
19
|
-
element.parentNode.removeChild(element);
|
|
20
|
-
}
|
|
21
|
-
}
|
|
22
|
-
// ... other DOM utility functions ...
|
|
23
|
-
// Placeholder for domUtils.ts
|
|
24
|
-
export {};
|
|
25
|
-
//# sourceMappingURL=domUtils.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"domUtils.js","sourceRoot":"","sources":["../../../src/vanillajs/iframe/domUtils.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,sFAAsF;AAEtF,MAAM,UAAU,YAAY,CAC1B,GAAW,EACX,SAAsB,EACtB,EAAW;IAEX,MAAM,MAAM,GAAG,QAAQ,CAAC,aAAa,CAAC,QAAQ,CAAC,CAAC;IAChD,MAAM,CAAC,EAAE,GAAG,EAAE,IAAI,mBAAmB,CAAC;IACtC,MAAM,CAAC,GAAG,GAAG,GAAG,CAAC;IACjB,iCAAiC;IACjC,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;IAC7B,MAAM,CAAC,KAAK,CAAC,KAAK,GAAG,MAAM,CAAC;IAC5B,MAAM,CAAC,KAAK,CAAC,MAAM,GAAG,MAAM,CAAC;IAE7B,SAAS,CAAC,WAAW,CAAC,MAAM,CAAC,CAAC;IAC9B,OAAO,MAAM,CAAC;AAChB,CAAC;AAED,MAAM,UAAU,YAAY,CAAC,MAAkC;IAC7D,MAAM,OAAO,GACX,OAAO,MAAM,KAAK,QAAQ;QACxB,CAAC,CAAE,QAAQ,CAAC,cAAc,CAAC,MAAM,CAAuB;QACxD,CAAC,CAAC,MAAM,CAAC;IACb,IAAI,OAAO,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;QAClC,OAAO,CAAC,UAAU,CAAC,WAAW,CAAC,OAAO,CAAC,CAAC;IAC1C,CAAC;AACH,CAAC;AAED,sCAAsC;AAEtC,8BAA8B;AAC9B,OAAO,EAAE,CAAC","sourcesContent":["// Placeholder for DOM Utilities (Task C)\n// This file will contain helper functions for DOM manipulation related to the iframe.\n\nexport function createIframe(\n url: string,\n container: HTMLElement,\n id?: string,\n): HTMLIFrameElement {\n const iframe = document.createElement(\"iframe\");\n iframe.id = id || \"civic-auth-iframe\";\n iframe.src = url;\n // Basic styling, can be expanded\n iframe.style.border = \"none\";\n iframe.style.width = \"100%\";\n iframe.style.height = \"100%\";\n\n container.appendChild(iframe);\n return iframe;\n}\n\nexport function removeIframe(iframe: HTMLIFrameElement | string): void {\n const element =\n typeof iframe === \"string\"\n ? (document.getElementById(iframe) as HTMLIFrameElement)\n : iframe;\n if (element && element.parentNode) {\n element.parentNode.removeChild(element);\n }\n}\n\n// ... other DOM utility functions ...\n\n// Placeholder for domUtils.ts\nexport {};\n"]}
|
|
@@ -1,19 +0,0 @@
|
|
|
1
|
-
import type { StorageAdapter } from "./StorageAdapter.js";
|
|
2
|
-
interface CookieOptions {
|
|
3
|
-
days?: number;
|
|
4
|
-
maxAge?: number;
|
|
5
|
-
path?: string;
|
|
6
|
-
secure?: boolean;
|
|
7
|
-
httpOnly?: boolean;
|
|
8
|
-
sameSite?: "Lax" | "Strict" | "None";
|
|
9
|
-
}
|
|
10
|
-
export declare class BrowserCookieStorageAdapter implements StorageAdapter {
|
|
11
|
-
private defaultCookieOptions;
|
|
12
|
-
private logger;
|
|
13
|
-
constructor(defaultOptions?: CookieOptions);
|
|
14
|
-
getItem(key: string): Promise<string | null>;
|
|
15
|
-
setItem(key: string, value: string, itemOptions?: CookieOptions): Promise<void>;
|
|
16
|
-
removeItem(key: string, itemOptions?: Pick<CookieOptions, "path">): Promise<void>;
|
|
17
|
-
}
|
|
18
|
-
export {};
|
|
19
|
-
//# sourceMappingURL=BrowserCookieStorageAdapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserCookieStorageAdapter.d.ts","sourceRoot":"","sources":["../../../src/vanillajs/storage/BrowserCookieStorageAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG1D,UAAU,aAAa;IACrB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,IAAI,CAAC,EAAE,MAAM,CAAC;IACd,MAAM,CAAC,EAAE,OAAO,CAAC;IACjB,QAAQ,CAAC,EAAE,OAAO,CAAC;IACnB,QAAQ,CAAC,EAAE,KAAK,GAAG,QAAQ,GAAG,MAAM,CAAC;CACtC;AA0DD,qBAAa,2BAA4B,YAAW,cAAc;IAChE,OAAO,CAAC,oBAAoB,CAAgB;IAC5C,OAAO,CAAC,MAAM,CAAsB;gBAExB,cAAc,GAAE,aAAkB;IAQxC,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAU5C,OAAO,CACX,GAAG,EAAE,MAAM,EACX,KAAK,EAAE,MAAM,EACb,WAAW,CAAC,EAAE,aAAa,GAC1B,OAAO,CAAC,IAAI,CAAC;IAqBV,UAAU,CACd,GAAG,EAAE,MAAM,EACX,WAAW,CAAC,EAAE,IAAI,CAAC,aAAa,EAAE,MAAM,CAAC,GACxC,OAAO,CAAC,IAAI,CAAC;CAUjB"}
|
|
@@ -1,101 +0,0 @@
|
|
|
1
|
-
import { getCurrentLogger } from "../utils/logger.js";
|
|
2
|
-
// Updated setCookie to handle more options
|
|
3
|
-
function setCookie(name, value, options = {}) {
|
|
4
|
-
if (typeof document === "undefined")
|
|
5
|
-
return;
|
|
6
|
-
let cookieString = name + "=" + (value || "");
|
|
7
|
-
if (options.maxAge !== undefined) {
|
|
8
|
-
cookieString += "; Max-Age=" + options.maxAge;
|
|
9
|
-
}
|
|
10
|
-
else if (options.days !== undefined) {
|
|
11
|
-
const date = new Date();
|
|
12
|
-
date.setTime(date.getTime() + options.days * 24 * 60 * 60 * 1000);
|
|
13
|
-
cookieString += "; expires=" + date.toUTCString();
|
|
14
|
-
}
|
|
15
|
-
cookieString += "; path=" + (options.path || "/");
|
|
16
|
-
if (options.secure) {
|
|
17
|
-
cookieString += "; Secure";
|
|
18
|
-
}
|
|
19
|
-
// HttpOnly cannot be set from client-side JavaScript.
|
|
20
|
-
// if (options.httpOnly) {
|
|
21
|
-
// cookieString += '; HttpOnly';
|
|
22
|
-
// }
|
|
23
|
-
if (options.sameSite) {
|
|
24
|
-
cookieString += "; SameSite=" + options.sameSite;
|
|
25
|
-
}
|
|
26
|
-
else {
|
|
27
|
-
cookieString += "; SameSite=Lax"; // Default SameSite
|
|
28
|
-
}
|
|
29
|
-
document.cookie = cookieString;
|
|
30
|
-
}
|
|
31
|
-
function getCookie(name) {
|
|
32
|
-
if (typeof document === "undefined")
|
|
33
|
-
return null;
|
|
34
|
-
const nameEQ = name + "=";
|
|
35
|
-
const ca = document.cookie.split(";");
|
|
36
|
-
for (let i = 0; i < ca.length; i++) {
|
|
37
|
-
let c = ca[i];
|
|
38
|
-
if (c) {
|
|
39
|
-
while (c.charAt(0) === " ")
|
|
40
|
-
c = c.substring(1, c.length);
|
|
41
|
-
if (c.indexOf(nameEQ) === 0)
|
|
42
|
-
return c.substring(nameEQ.length, c.length);
|
|
43
|
-
}
|
|
44
|
-
}
|
|
45
|
-
return null;
|
|
46
|
-
}
|
|
47
|
-
function eraseCookie(name, path = "/") {
|
|
48
|
-
if (typeof document === "undefined")
|
|
49
|
-
return;
|
|
50
|
-
// Set expiry to the past and include path and SameSite for robust deletion
|
|
51
|
-
document.cookie =
|
|
52
|
-
name +
|
|
53
|
-
"=; Path=" +
|
|
54
|
-
path +
|
|
55
|
-
"; Expires=Thu, 01 Jan 1970 00:00:01 GMT; SameSite=Lax";
|
|
56
|
-
}
|
|
57
|
-
export class BrowserCookieStorageAdapter {
|
|
58
|
-
defaultCookieOptions;
|
|
59
|
-
logger = getCurrentLogger();
|
|
60
|
-
constructor(defaultOptions = {}) {
|
|
61
|
-
this.defaultCookieOptions = {
|
|
62
|
-
path: "/",
|
|
63
|
-
sameSite: "Lax",
|
|
64
|
-
...defaultOptions,
|
|
65
|
-
};
|
|
66
|
-
}
|
|
67
|
-
async getItem(key) {
|
|
68
|
-
if (typeof document !== "undefined") {
|
|
69
|
-
return getCookie(key);
|
|
70
|
-
}
|
|
71
|
-
this.logger.warn("CivicAuth: Cookies not available (document is undefined). Cannot get item.");
|
|
72
|
-
return null;
|
|
73
|
-
}
|
|
74
|
-
async setItem(key, value, itemOptions) {
|
|
75
|
-
if (typeof document !== "undefined") {
|
|
76
|
-
const optionsToUse = { ...this.defaultCookieOptions, ...itemOptions };
|
|
77
|
-
// HttpOnly cookies cannot be effectively managed (set/read/deleted reliably) from client-side JS if they are truly HttpOnly.
|
|
78
|
-
// The browser will prevent JS from accessing them. If set server-side, JS can't touch them.
|
|
79
|
-
// If we try to set HttpOnly here, it might be ignored by the browser or not behave as expected for a client-side adapter.
|
|
80
|
-
// We should primarily focus on attributes settable from client-side JS.
|
|
81
|
-
// If httpOnly is true in options, we might log a warning or ignore it.
|
|
82
|
-
if (optionsToUse.httpOnly) {
|
|
83
|
-
this.logger.warn(`CivicAuth: Attempting to set HttpOnly cookie '${key}' from client-side. This attribute is typically managed server-side and may not be effective here.`);
|
|
84
|
-
}
|
|
85
|
-
setCookie(key, value, optionsToUse);
|
|
86
|
-
}
|
|
87
|
-
else {
|
|
88
|
-
this.logger.warn("CivicAuth: Cookies not available (document is undefined). Item not set.");
|
|
89
|
-
}
|
|
90
|
-
}
|
|
91
|
-
async removeItem(key, itemOptions) {
|
|
92
|
-
if (typeof document !== "undefined") {
|
|
93
|
-
const path = itemOptions?.path || this.defaultCookieOptions.path || "/";
|
|
94
|
-
eraseCookie(key, path);
|
|
95
|
-
}
|
|
96
|
-
else {
|
|
97
|
-
this.logger.warn("CivicAuth: Cookies not available (document is undefined). Item not removed.");
|
|
98
|
-
}
|
|
99
|
-
}
|
|
100
|
-
}
|
|
101
|
-
//# sourceMappingURL=BrowserCookieStorageAdapter.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserCookieStorageAdapter.js","sourceRoot":"","sources":["../../../src/vanillajs/storage/BrowserCookieStorageAdapter.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAWtD,2CAA2C;AAC3C,SAAS,SAAS,CAAC,IAAY,EAAE,KAAa,EAAE,UAAyB,EAAE;IACzE,IAAI,OAAO,QAAQ,KAAK,WAAW;QAAE,OAAO;IAE5C,IAAI,YAAY,GAAG,IAAI,GAAG,GAAG,GAAG,CAAC,KAAK,IAAI,EAAE,CAAC,CAAC;IAE9C,IAAI,OAAO,CAAC,MAAM,KAAK,SAAS,EAAE,CAAC;QACjC,YAAY,IAAI,YAAY,GAAG,OAAO,CAAC,MAAM,CAAC;IAChD,CAAC;SAAM,IAAI,OAAO,CAAC,IAAI,KAAK,SAAS,EAAE,CAAC;QACtC,MAAM,IAAI,GAAG,IAAI,IAAI,EAAE,CAAC;QACxB,IAAI,CAAC,OAAO,CAAC,IAAI,CAAC,OAAO,EAAE,GAAG,OAAO,CAAC,IAAI,GAAG,EAAE,GAAG,EAAE,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;QAClE,YAAY,IAAI,YAAY,GAAG,IAAI,CAAC,WAAW,EAAE,CAAC;IACpD,CAAC;IAED,YAAY,IAAI,SAAS,GAAG,CAAC,OAAO,CAAC,IAAI,IAAI,GAAG,CAAC,CAAC;IAElD,IAAI,OAAO,CAAC,MAAM,EAAE,CAAC;QACnB,YAAY,IAAI,UAAU,CAAC;IAC7B,CAAC;IACD,sDAAsD;IACtD,0BAA0B;IAC1B,kCAAkC;IAClC,IAAI;IACJ,IAAI,OAAO,CAAC,QAAQ,EAAE,CAAC;QACrB,YAAY,IAAI,aAAa,GAAG,OAAO,CAAC,QAAQ,CAAC;IACnD,CAAC;SAA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AAC;IACH,CAAC;CACF","sourcesContent":["import type { StorageAdapter } from \"./StorageAdapter.js\";\nimport { getCurrentLogger } from \"../utils/logger.js\";\n\ninterface CookieOptions {\n days?: number;\n maxAge?: number; // seconds\n path?: string;\n secure?: boolean;\n httpOnly?: boolean; // Note: httpOnly cookies cannot be set or read by client-side JS after being set.\n sameSite?: \"Lax\" | \"Strict\" | \"None\";\n}\n\n// Updated setCookie to handle more options\nfunction setCookie(name: string, value: string, options: CookieOptions = {}) {\n if (typeof document === \"undefined\") return;\n\n let cookieString = name + \"=\" + (value || \"\");\n\n if (options.maxAge !== undefined) {\n cookieString += \"; Max-Age=\" + options.maxAge;\n } else if (options.days !== undefined) {\n const date = new Date();\n date.setTime(date.getTime() + options.days * 24 * 60 * 60 * 1000);\n cookieString += \"; expires=\" + date.toUTCString();\n }\n\n cookieString += \"; path=\" + (options.path || \"/\");\n\n if (options.secure) {\n cookieString += \"; Secure\";\n }\n // HttpOnly cannot be set from client-side JavaScript.\n // if (options.httpOnly) {\n // cookieString += '; HttpOnly';\n // }\n if (options.sameSite) {\n cookieString += \"; SameSite=\" + options.sameSite;\n } else {\n cookieString += \"; SameSite=Lax\"; // Default SameSite\n }\n\n document.cookie = cookieString;\n}\n\nfunction getCookie(name: string): string | null {\n if (typeof document === \"undefined\") return null;\n const nameEQ = name + \"=\";\n const ca = document.cookie.split(\";\");\n for (let i = 0; i < ca.length; i++) {\n let c = ca[i];\n if (c) {\n while (c.charAt(0) === \" \") c = c.substring(1, c.length);\n if (c.indexOf(nameEQ) === 0) return c.substring(nameEQ.length, c.length);\n }\n }\n return null;\n}\n\nfunction eraseCookie(name: string, path: string = \"/\") {\n if (typeof document === \"undefined\") return;\n // Set expiry to the past and include path and SameSite for robust deletion\n document.cookie =\n name +\n \"=; Path=\" +\n path +\n \"; Expires=Thu, 01 Jan 1970 00:00:01 GMT; SameSite=Lax\";\n}\n\nexport class BrowserCookieStorageAdapter implements StorageAdapter {\n private defaultCookieOptions: CookieOptions;\n private logger = getCurrentLogger();\n\n constructor(defaultOptions: CookieOptions = {}) {\n this.defaultCookieOptions = {\n path: \"/\",\n sameSite: \"Lax\",\n ...defaultOptions,\n };\n }\n\n async getItem(key: string): Promise<string | null> {\n if (typeof document !== \"undefined\") {\n return getCookie(key);\n }\n this.logger.warn(\n \"CivicAuth: Cookies not available (document is undefined). Cannot get item.\",\n );\n return null;\n }\n\n async setItem(\n key: string,\n value: string,\n itemOptions?: CookieOptions,\n ): Promise<void> {\n if (typeof document !== \"undefined\") {\n const optionsToUse = { ...this.defaultCookieOptions, ...itemOptions };\n // HttpOnly cookies cannot be effectively managed (set/read/deleted reliably) from client-side JS if they are truly HttpOnly.\n // The browser will prevent JS from accessing them. If set server-side, JS can't touch them.\n // If we try to set HttpOnly here, it might be ignored by the browser or not behave as expected for a client-side adapter.\n // We should primarily focus on attributes settable from client-side JS.\n // If httpOnly is true in options, we might log a warning or ignore it.\n if (optionsToUse.httpOnly) {\n this.logger.warn(\n `CivicAuth: Attempting to set HttpOnly cookie '${key}' from client-side. This attribute is typically managed server-side and may not be effective here.`,\n );\n }\n setCookie(key, value, optionsToUse);\n } else {\n this.logger.warn(\n \"CivicAuth: Cookies not available (document is undefined). Item not set.\",\n );\n }\n }\n\n async removeItem(\n key: string,\n itemOptions?: Pick<CookieOptions, \"path\">,\n ): Promise<void> {\n if (typeof document !== \"undefined\") {\n const path = itemOptions?.path || this.defaultCookieOptions.path || \"/\";\n eraseCookie(key, path);\n } else {\n this.logger.warn(\n \"CivicAuth: Cookies not available (document is undefined). Item not removed.\",\n );\n }\n }\n}\n"]}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { StorageAdapter } from "./StorageAdapter.js";
|
|
2
|
-
export declare class BrowserLocalStorageAdapter implements StorageAdapter {
|
|
3
|
-
private logger;
|
|
4
|
-
getItem(key: string): Promise<string | null>;
|
|
5
|
-
setItem(key: string, value: string): Promise<void>;
|
|
6
|
-
removeItem(key: string): Promise<void>;
|
|
7
|
-
clear(): Promise<void>;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=BrowserLocalStorageAdapter.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"BrowserLocalStorageAdapter.d.ts","sourceRoot":"","sources":["../../../src/vanillajs/storage/BrowserLocalStorageAdapter.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,cAAc,EAAE,MAAM,qBAAqB,CAAC;AAG1D,qBAAa,0BAA2B,YAAW,cAAc;IAC/D,OAAO,CAAC,MAAM,CAAsB;IAE9B,OAAO,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,MAAM,GAAG,IAAI,CAAC;IAQ5C,OAAO,CAAC,GAAG,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQlD,UAAU,CAAC,GAAG,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAQtC,KAAK,IAAI,OAAO,CAAC,IAAI,CAAC;CAO7B"}
|
|
@@ -1,36 +0,0 @@
|
|
|
1
|
-
import { getCurrentLogger } from "../utils/logger.js";
|
|
2
|
-
export class BrowserLocalStorageAdapter {
|
|
3
|
-
logger = getCurrentLogger();
|
|
4
|
-
async getItem(key) {
|
|
5
|
-
if (typeof window !== "undefined" && window.localStorage) {
|
|
6
|
-
return window.localStorage.getItem(key);
|
|
7
|
-
}
|
|
8
|
-
this.logger.warn("LocalStorage is not available. Returning null.");
|
|
9
|
-
return null;
|
|
10
|
-
}
|
|
11
|
-
async setItem(key, value) {
|
|
12
|
-
if (typeof window !== "undefined" && window.localStorage) {
|
|
13
|
-
window.localStorage.setItem(key, value);
|
|
14
|
-
}
|
|
15
|
-
else {
|
|
16
|
-
this.logger.warn("LocalStorage is not available. Item not set.");
|
|
17
|
-
}
|
|
18
|
-
}
|
|
19
|
-
async removeItem(key) {
|
|
20
|
-
if (typeof window !== "undefined" && window.localStorage) {
|
|
21
|
-
window.localStorage.removeItem(key);
|
|
22
|
-
}
|
|
23
|
-
else {
|
|
24
|
-
this.logger.warn("LocalStorage is not available. Item not removed.");
|
|
25
|
-
}
|
|
26
|
-
}
|
|
27
|
-
async clear() {
|
|
28
|
-
if (typeof window !== "undefined" && window.localStorage) {
|
|
29
|
-
window.localStorage.clear();
|
|
30
|
-
}
|
|
31
|
-
else {
|
|
32
|
-
this.logger.warn("LocalStorage is not available. Storage not cleared.");
|
|
33
|
-
}
|
|
34
|
-
}
|
|
35
|
-
}
|
|
36
|
-
//# sourceMappingURL=BrowserLocalStorageAdapter.js.map
|