@sparkstudio/authentication-ui 1.0.17 → 1.0.19
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/index.cjs +21 -3
- package/dist/index.d.cts +2 -0
- package/dist/index.d.ts +2 -0
- package/dist/index.js +21 -3
- package/package.json +2 -2
package/dist/index.cjs
CHANGED
|
@@ -41,11 +41,13 @@ var Auth = class {
|
|
|
41
41
|
}
|
|
42
42
|
async Logout() {
|
|
43
43
|
const url = `${this.baseUrl}/api/Auth/Logout`;
|
|
44
|
+
const token = this.getCookie("auth_token");
|
|
44
45
|
const requestOptions = {
|
|
45
46
|
method: "GET",
|
|
46
47
|
credentials: "include",
|
|
47
48
|
headers: {
|
|
48
|
-
"Content-Type": "application/json"
|
|
49
|
+
"Content-Type": "application/json",
|
|
50
|
+
...token && { Authorization: `Bearer ${token}` }
|
|
49
51
|
}
|
|
50
52
|
};
|
|
51
53
|
const response = await fetch(url, requestOptions);
|
|
@@ -54,11 +56,13 @@ var Auth = class {
|
|
|
54
56
|
}
|
|
55
57
|
async GetCurrentUser() {
|
|
56
58
|
const url = `${this.baseUrl}/api/Auth/GetCurrentUser`;
|
|
59
|
+
const token = this.getCookie("auth_token");
|
|
57
60
|
const requestOptions = {
|
|
58
61
|
method: "GET",
|
|
59
62
|
credentials: "include",
|
|
60
63
|
headers: {
|
|
61
|
-
"Content-Type": "application/json"
|
|
64
|
+
"Content-Type": "application/json",
|
|
65
|
+
...token && { Authorization: `Bearer ${token}` }
|
|
62
66
|
}
|
|
63
67
|
};
|
|
64
68
|
const response = await fetch(url, requestOptions);
|
|
@@ -67,11 +71,13 @@ var Auth = class {
|
|
|
67
71
|
}
|
|
68
72
|
async SignIn(tokenRequest) {
|
|
69
73
|
const url = `${this.baseUrl}/api/Auth/SignIn`;
|
|
74
|
+
const token = this.getCookie("auth_token");
|
|
70
75
|
const requestOptions = {
|
|
71
76
|
method: "POST",
|
|
72
77
|
credentials: "include",
|
|
73
78
|
headers: {
|
|
74
|
-
"Content-Type": "application/json"
|
|
79
|
+
"Content-Type": "application/json",
|
|
80
|
+
...token && { Authorization: `Bearer ${token}` }
|
|
75
81
|
},
|
|
76
82
|
body: JSON.stringify(tokenRequest)
|
|
77
83
|
};
|
|
@@ -79,6 +85,12 @@ var Auth = class {
|
|
|
79
85
|
if (!response.ok) throw new Error(await response.text());
|
|
80
86
|
return await response.json();
|
|
81
87
|
}
|
|
88
|
+
getCookie(name) {
|
|
89
|
+
const value = `; ${document.cookie}`;
|
|
90
|
+
const parts = value.split(`; ${name}=`);
|
|
91
|
+
if (parts.length === 2) return parts.pop().split(";").shift() || null;
|
|
92
|
+
return null;
|
|
93
|
+
}
|
|
82
94
|
};
|
|
83
95
|
|
|
84
96
|
// src/api/Controllers/Home.ts
|
|
@@ -87,6 +99,12 @@ var Home = class {
|
|
|
87
99
|
constructor(baseUrl) {
|
|
88
100
|
this.baseUrl = baseUrl;
|
|
89
101
|
}
|
|
102
|
+
getCookie(name) {
|
|
103
|
+
const value = `; ${document.cookie}`;
|
|
104
|
+
const parts = value.split(`; ${name}=`);
|
|
105
|
+
if (parts.length === 2) return parts.pop().split(";").shift() || null;
|
|
106
|
+
return null;
|
|
107
|
+
}
|
|
90
108
|
};
|
|
91
109
|
|
|
92
110
|
// src/api/SparkStudioAuthenticationSDK.ts
|
package/dist/index.d.cts
CHANGED
|
@@ -105,6 +105,7 @@ declare class Auth {
|
|
|
105
105
|
Logout(): Promise<UserDTO>;
|
|
106
106
|
GetCurrentUser(): Promise<UserDTO>;
|
|
107
107
|
SignIn(tokenRequest: TokenRequest): Promise<AuthResponse>;
|
|
108
|
+
private getCookie;
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
/**
|
|
@@ -113,6 +114,7 @@ declare class Auth {
|
|
|
113
114
|
declare class Home {
|
|
114
115
|
private baseUrl;
|
|
115
116
|
constructor(baseUrl: string);
|
|
117
|
+
private getCookie;
|
|
116
118
|
}
|
|
117
119
|
|
|
118
120
|
/**
|
package/dist/index.d.ts
CHANGED
|
@@ -105,6 +105,7 @@ declare class Auth {
|
|
|
105
105
|
Logout(): Promise<UserDTO>;
|
|
106
106
|
GetCurrentUser(): Promise<UserDTO>;
|
|
107
107
|
SignIn(tokenRequest: TokenRequest): Promise<AuthResponse>;
|
|
108
|
+
private getCookie;
|
|
108
109
|
}
|
|
109
110
|
|
|
110
111
|
/**
|
|
@@ -113,6 +114,7 @@ declare class Auth {
|
|
|
113
114
|
declare class Home {
|
|
114
115
|
private baseUrl;
|
|
115
116
|
constructor(baseUrl: string);
|
|
117
|
+
private getCookie;
|
|
116
118
|
}
|
|
117
119
|
|
|
118
120
|
/**
|
package/dist/index.js
CHANGED
|
@@ -14,11 +14,13 @@ var Auth = class {
|
|
|
14
14
|
}
|
|
15
15
|
async Logout() {
|
|
16
16
|
const url = `${this.baseUrl}/api/Auth/Logout`;
|
|
17
|
+
const token = this.getCookie("auth_token");
|
|
17
18
|
const requestOptions = {
|
|
18
19
|
method: "GET",
|
|
19
20
|
credentials: "include",
|
|
20
21
|
headers: {
|
|
21
|
-
"Content-Type": "application/json"
|
|
22
|
+
"Content-Type": "application/json",
|
|
23
|
+
...token && { Authorization: `Bearer ${token}` }
|
|
22
24
|
}
|
|
23
25
|
};
|
|
24
26
|
const response = await fetch(url, requestOptions);
|
|
@@ -27,11 +29,13 @@ var Auth = class {
|
|
|
27
29
|
}
|
|
28
30
|
async GetCurrentUser() {
|
|
29
31
|
const url = `${this.baseUrl}/api/Auth/GetCurrentUser`;
|
|
32
|
+
const token = this.getCookie("auth_token");
|
|
30
33
|
const requestOptions = {
|
|
31
34
|
method: "GET",
|
|
32
35
|
credentials: "include",
|
|
33
36
|
headers: {
|
|
34
|
-
"Content-Type": "application/json"
|
|
37
|
+
"Content-Type": "application/json",
|
|
38
|
+
...token && { Authorization: `Bearer ${token}` }
|
|
35
39
|
}
|
|
36
40
|
};
|
|
37
41
|
const response = await fetch(url, requestOptions);
|
|
@@ -40,11 +44,13 @@ var Auth = class {
|
|
|
40
44
|
}
|
|
41
45
|
async SignIn(tokenRequest) {
|
|
42
46
|
const url = `${this.baseUrl}/api/Auth/SignIn`;
|
|
47
|
+
const token = this.getCookie("auth_token");
|
|
43
48
|
const requestOptions = {
|
|
44
49
|
method: "POST",
|
|
45
50
|
credentials: "include",
|
|
46
51
|
headers: {
|
|
47
|
-
"Content-Type": "application/json"
|
|
52
|
+
"Content-Type": "application/json",
|
|
53
|
+
...token && { Authorization: `Bearer ${token}` }
|
|
48
54
|
},
|
|
49
55
|
body: JSON.stringify(tokenRequest)
|
|
50
56
|
};
|
|
@@ -52,6 +58,12 @@ var Auth = class {
|
|
|
52
58
|
if (!response.ok) throw new Error(await response.text());
|
|
53
59
|
return await response.json();
|
|
54
60
|
}
|
|
61
|
+
getCookie(name) {
|
|
62
|
+
const value = `; ${document.cookie}`;
|
|
63
|
+
const parts = value.split(`; ${name}=`);
|
|
64
|
+
if (parts.length === 2) return parts.pop().split(";").shift() || null;
|
|
65
|
+
return null;
|
|
66
|
+
}
|
|
55
67
|
};
|
|
56
68
|
|
|
57
69
|
// src/api/Controllers/Home.ts
|
|
@@ -60,6 +72,12 @@ var Home = class {
|
|
|
60
72
|
constructor(baseUrl) {
|
|
61
73
|
this.baseUrl = baseUrl;
|
|
62
74
|
}
|
|
75
|
+
getCookie(name) {
|
|
76
|
+
const value = `; ${document.cookie}`;
|
|
77
|
+
const parts = value.split(`; ${name}=`);
|
|
78
|
+
if (parts.length === 2) return parts.pop().split(";").shift() || null;
|
|
79
|
+
return null;
|
|
80
|
+
}
|
|
63
81
|
};
|
|
64
82
|
|
|
65
83
|
// src/api/SparkStudioAuthenticationSDK.ts
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sparkstudio/authentication-ui",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.19",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"main": "dist/index.cjs",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -35,7 +35,7 @@
|
|
|
35
35
|
},
|
|
36
36
|
"dependencies": {
|
|
37
37
|
"@react-oauth/google": "^0.13.4",
|
|
38
|
-
"@sparkstudio/accounts-sdk": "^1.1.
|
|
38
|
+
"@sparkstudio/accounts-sdk": "^1.1.68",
|
|
39
39
|
"@sparkstudio/accounts-ui": "^1.1.56",
|
|
40
40
|
"@sparkstudio/common-ui": "^1.0.5",
|
|
41
41
|
"rimraf": "^6.1.2"
|