@proveanything/smartlinks-auth-ui 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.
- package/README.md +323 -0
- package/dist/api.d.ts +44 -0
- package/dist/api.d.ts.map +1 -0
- package/dist/api.js +105 -0
- package/dist/components/AuthContainer.d.ts +12 -0
- package/dist/components/AuthContainer.d.ts.map +1 -0
- package/dist/components/AuthContainer.js +46 -0
- package/dist/components/AuthUIPreview.d.ts +11 -0
- package/dist/components/AuthUIPreview.d.ts.map +1 -0
- package/dist/components/AuthUIPreview.js +10 -0
- package/dist/components/EmailAuthForm.d.ts +14 -0
- package/dist/components/EmailAuthForm.d.ts.map +1 -0
- package/dist/components/EmailAuthForm.js +20 -0
- package/dist/components/PasswordResetForm.d.ts +13 -0
- package/dist/components/PasswordResetForm.d.ts.map +1 -0
- package/dist/components/PasswordResetForm.js +37 -0
- package/dist/components/PhoneAuthForm.d.ts +11 -0
- package/dist/components/PhoneAuthForm.d.ts.map +1 -0
- package/dist/components/PhoneAuthForm.js +20 -0
- package/dist/components/ProtectedRoute.d.ts +9 -0
- package/dist/components/ProtectedRoute.d.ts.map +1 -0
- package/dist/components/ProtectedRoute.js +20 -0
- package/dist/components/ProviderButtons.d.ts +12 -0
- package/dist/components/ProviderButtons.d.ts.map +1 -0
- package/dist/components/ProviderButtons.js +8 -0
- package/dist/context/AuthContext.d.ts +20 -0
- package/dist/context/AuthContext.d.ts.map +1 -0
- package/dist/context/AuthContext.js +113 -0
- package/dist/index.css +2 -0
- package/dist/index.css.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.esm.css +2 -0
- package/dist/index.esm.css.map +1 -0
- package/dist/index.esm.js +840 -0
- package/dist/index.esm.js.map +1 -0
- package/dist/index.js +867 -0
- package/dist/index.js.map +1 -0
- package/dist/smartlinks.d.ts +65 -0
- package/dist/smartlinks.d.ts.map +1 -0
- package/dist/smartlinks.js +141 -0
- package/dist/types.d.ts +101 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +1 -0
- package/dist/utils/tokenStorage.d.ts +14 -0
- package/dist/utils/tokenStorage.d.ts.map +1 -0
- package/dist/utils/tokenStorage.js +71 -0
- package/package.json +57 -0
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
const TOKEN_KEY = 'smartlinks_auth_token';
|
|
2
|
+
const USER_KEY = 'smartlinks_auth_user';
|
|
3
|
+
const ACCOUNT_DATA_KEY = 'smartlinks_account_data';
|
|
4
|
+
export const tokenStorage = {
|
|
5
|
+
saveToken(token, expiresAt) {
|
|
6
|
+
const authToken = {
|
|
7
|
+
token,
|
|
8
|
+
expiresAt: expiresAt || Date.now() + 3600000, // Default 1 hour
|
|
9
|
+
};
|
|
10
|
+
localStorage.setItem(TOKEN_KEY, JSON.stringify(authToken));
|
|
11
|
+
},
|
|
12
|
+
getToken() {
|
|
13
|
+
const stored = localStorage.getItem(TOKEN_KEY);
|
|
14
|
+
if (!stored)
|
|
15
|
+
return null;
|
|
16
|
+
try {
|
|
17
|
+
const authToken = JSON.parse(stored);
|
|
18
|
+
// Check if token is expired
|
|
19
|
+
if (authToken.expiresAt && authToken.expiresAt < Date.now()) {
|
|
20
|
+
this.clearToken();
|
|
21
|
+
return null;
|
|
22
|
+
}
|
|
23
|
+
return authToken;
|
|
24
|
+
}
|
|
25
|
+
catch {
|
|
26
|
+
return null;
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
clearToken() {
|
|
30
|
+
localStorage.removeItem(TOKEN_KEY);
|
|
31
|
+
},
|
|
32
|
+
saveUser(user) {
|
|
33
|
+
localStorage.setItem(USER_KEY, JSON.stringify(user));
|
|
34
|
+
},
|
|
35
|
+
getUser() {
|
|
36
|
+
const stored = localStorage.getItem(USER_KEY);
|
|
37
|
+
if (!stored)
|
|
38
|
+
return null;
|
|
39
|
+
try {
|
|
40
|
+
return JSON.parse(stored);
|
|
41
|
+
}
|
|
42
|
+
catch {
|
|
43
|
+
return null;
|
|
44
|
+
}
|
|
45
|
+
},
|
|
46
|
+
clearUser() {
|
|
47
|
+
localStorage.removeItem(USER_KEY);
|
|
48
|
+
},
|
|
49
|
+
clearAll() {
|
|
50
|
+
this.clearToken();
|
|
51
|
+
this.clearUser();
|
|
52
|
+
this.clearAccountData();
|
|
53
|
+
},
|
|
54
|
+
saveAccountData(data) {
|
|
55
|
+
localStorage.setItem(ACCOUNT_DATA_KEY, JSON.stringify(data));
|
|
56
|
+
},
|
|
57
|
+
getAccountData() {
|
|
58
|
+
const stored = localStorage.getItem(ACCOUNT_DATA_KEY);
|
|
59
|
+
if (!stored)
|
|
60
|
+
return null;
|
|
61
|
+
try {
|
|
62
|
+
return JSON.parse(stored);
|
|
63
|
+
}
|
|
64
|
+
catch {
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
67
|
+
},
|
|
68
|
+
clearAccountData() {
|
|
69
|
+
localStorage.removeItem(ACCOUNT_DATA_KEY);
|
|
70
|
+
},
|
|
71
|
+
};
|
package/package.json
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@proveanything/smartlinks-auth-ui",
|
|
3
|
+
"version": "0.1.0",
|
|
4
|
+
"description": "Lightweight React authentication UI components with bearer token support and Smartlinks SDK integration",
|
|
5
|
+
"main": "dist/index.js",
|
|
6
|
+
"module": "dist/index.esm.js",
|
|
7
|
+
"types": "dist/index.d.ts",
|
|
8
|
+
"files": [
|
|
9
|
+
"dist",
|
|
10
|
+
"README.md"
|
|
11
|
+
],
|
|
12
|
+
"keywords": [
|
|
13
|
+
"react",
|
|
14
|
+
"authentication",
|
|
15
|
+
"auth",
|
|
16
|
+
"ui",
|
|
17
|
+
"login",
|
|
18
|
+
"bearer-token",
|
|
19
|
+
"smartlinks",
|
|
20
|
+
"oauth",
|
|
21
|
+
"rest-api"
|
|
22
|
+
],
|
|
23
|
+
"author": "Prove Anything",
|
|
24
|
+
"license": "MIT",
|
|
25
|
+
"peerDependencies": {
|
|
26
|
+
"react": "^18.0.0",
|
|
27
|
+
"react-dom": "^18.0.0"
|
|
28
|
+
},
|
|
29
|
+
"dependencies": {
|
|
30
|
+
"@proveanything/smartlinks": "^1.0.0"
|
|
31
|
+
},
|
|
32
|
+
"publishConfig": {
|
|
33
|
+
"access": "public"
|
|
34
|
+
},
|
|
35
|
+
"devDependencies": {
|
|
36
|
+
"@types/react": "^18.3.1",
|
|
37
|
+
"@types/react-dom": "^18.3.0",
|
|
38
|
+
"typescript": "^5.3.3",
|
|
39
|
+
"@rollup/plugin-typescript": "^11.1.5",
|
|
40
|
+
"@rollup/plugin-node-resolve": "^15.2.3",
|
|
41
|
+
"@rollup/plugin-commonjs": "^25.0.7",
|
|
42
|
+
"rollup": "^4.9.6",
|
|
43
|
+
"rollup-plugin-peer-deps-external": "^2.2.4",
|
|
44
|
+
"rollup-plugin-postcss": "^4.0.2",
|
|
45
|
+
"autoprefixer": "^10.4.16",
|
|
46
|
+
"tslib": "^2.6.2"
|
|
47
|
+
},
|
|
48
|
+
"scripts": {
|
|
49
|
+
"build": "rollup -c",
|
|
50
|
+
"dev": "rollup -c -w",
|
|
51
|
+
"prepublishOnly": "npm run build"
|
|
52
|
+
},
|
|
53
|
+
"repository": {
|
|
54
|
+
"type": "git",
|
|
55
|
+
"url": "https://github.com/smartlinks/auth-ui"
|
|
56
|
+
}
|
|
57
|
+
}
|