@sparkstudio/authentication-sdk 1.0.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/README.md +73 -0
- package/dist/index.cjs +92 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +71 -0
- package/dist/index.d.ts +71 -0
- package/dist/index.js +65 -0
- package/dist/index.js.map +1 -0
- package/package.json +31 -0
package/README.md
ADDED
|
@@ -0,0 +1,73 @@
|
|
|
1
|
+
# React + TypeScript + Vite
|
|
2
|
+
|
|
3
|
+
This template provides a minimal setup to get React working in Vite with HMR and some ESLint rules.
|
|
4
|
+
|
|
5
|
+
Currently, two official plugins are available:
|
|
6
|
+
|
|
7
|
+
- [@vitejs/plugin-react](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react) uses [Babel](https://babeljs.io/) (or [oxc](https://oxc.rs) when used in [rolldown-vite](https://vite.dev/guide/rolldown)) for Fast Refresh
|
|
8
|
+
- [@vitejs/plugin-react-swc](https://github.com/vitejs/vite-plugin-react/blob/main/packages/plugin-react-swc) uses [SWC](https://swc.rs/) for Fast Refresh
|
|
9
|
+
|
|
10
|
+
## React Compiler
|
|
11
|
+
|
|
12
|
+
The React Compiler is not enabled on this template because of its impact on dev & build performances. To add it, see [this documentation](https://react.dev/learn/react-compiler/installation).
|
|
13
|
+
|
|
14
|
+
## Expanding the ESLint configuration
|
|
15
|
+
|
|
16
|
+
If you are developing a production application, we recommend updating the configuration to enable type-aware lint rules:
|
|
17
|
+
|
|
18
|
+
```js
|
|
19
|
+
export default defineConfig([
|
|
20
|
+
globalIgnores(['dist']),
|
|
21
|
+
{
|
|
22
|
+
files: ['**/*.{ts,tsx}'],
|
|
23
|
+
extends: [
|
|
24
|
+
// Other configs...
|
|
25
|
+
|
|
26
|
+
// Remove tseslint.configs.recommended and replace with this
|
|
27
|
+
tseslint.configs.recommendedTypeChecked,
|
|
28
|
+
// Alternatively, use this for stricter rules
|
|
29
|
+
tseslint.configs.strictTypeChecked,
|
|
30
|
+
// Optionally, add this for stylistic rules
|
|
31
|
+
tseslint.configs.stylisticTypeChecked,
|
|
32
|
+
|
|
33
|
+
// Other configs...
|
|
34
|
+
],
|
|
35
|
+
languageOptions: {
|
|
36
|
+
parserOptions: {
|
|
37
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
38
|
+
tsconfigRootDir: import.meta.dirname,
|
|
39
|
+
},
|
|
40
|
+
// other options...
|
|
41
|
+
},
|
|
42
|
+
},
|
|
43
|
+
])
|
|
44
|
+
```
|
|
45
|
+
|
|
46
|
+
You can also install [eslint-plugin-react-x](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-x) and [eslint-plugin-react-dom](https://github.com/Rel1cx/eslint-react/tree/main/packages/plugins/eslint-plugin-react-dom) for React-specific lint rules:
|
|
47
|
+
|
|
48
|
+
```js
|
|
49
|
+
// eslint.config.js
|
|
50
|
+
import reactX from 'eslint-plugin-react-x'
|
|
51
|
+
import reactDom from 'eslint-plugin-react-dom'
|
|
52
|
+
|
|
53
|
+
export default defineConfig([
|
|
54
|
+
globalIgnores(['dist']),
|
|
55
|
+
{
|
|
56
|
+
files: ['**/*.{ts,tsx}'],
|
|
57
|
+
extends: [
|
|
58
|
+
// Other configs...
|
|
59
|
+
// Enable lint rules for React
|
|
60
|
+
reactX.configs['recommended-typescript'],
|
|
61
|
+
// Enable lint rules for React DOM
|
|
62
|
+
reactDom.configs.recommended,
|
|
63
|
+
],
|
|
64
|
+
languageOptions: {
|
|
65
|
+
parserOptions: {
|
|
66
|
+
project: ['./tsconfig.node.json', './tsconfig.app.json'],
|
|
67
|
+
tsconfigRootDir: import.meta.dirname,
|
|
68
|
+
},
|
|
69
|
+
// other options...
|
|
70
|
+
},
|
|
71
|
+
},
|
|
72
|
+
])
|
|
73
|
+
```
|
package/dist/index.cjs
ADDED
|
@@ -0,0 +1,92 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
SparkStudioAuthenticationSDK: () => SparkStudioAuthenticationSDK
|
|
24
|
+
});
|
|
25
|
+
module.exports = __toCommonJS(index_exports);
|
|
26
|
+
|
|
27
|
+
// src/api/Controllers/Auth.ts
|
|
28
|
+
var Auth = class {
|
|
29
|
+
constructor(baseUrl) {
|
|
30
|
+
this.baseUrl = baseUrl;
|
|
31
|
+
}
|
|
32
|
+
async Logout() {
|
|
33
|
+
const url = `${this.baseUrl}/api/Auth/Logout`;
|
|
34
|
+
const requestOptions = {
|
|
35
|
+
method: "GET",
|
|
36
|
+
credentials: "include",
|
|
37
|
+
headers: {
|
|
38
|
+
"Content-Type": "application/json"
|
|
39
|
+
}
|
|
40
|
+
};
|
|
41
|
+
const response = await fetch(url, requestOptions);
|
|
42
|
+
if (!response.ok) throw new Error(await response.text());
|
|
43
|
+
return await response.json();
|
|
44
|
+
}
|
|
45
|
+
async GetCurrentUser() {
|
|
46
|
+
const url = `${this.baseUrl}/api/Auth/GetCurrentUser`;
|
|
47
|
+
const requestOptions = {
|
|
48
|
+
method: "GET",
|
|
49
|
+
credentials: "include",
|
|
50
|
+
headers: {
|
|
51
|
+
"Content-Type": "application/json"
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
const response = await fetch(url, requestOptions);
|
|
55
|
+
if (!response.ok) throw new Error(await response.text());
|
|
56
|
+
return await response.json();
|
|
57
|
+
}
|
|
58
|
+
async SignIn(tokenRequest) {
|
|
59
|
+
const url = `${this.baseUrl}/api/Auth/SignIn`;
|
|
60
|
+
const requestOptions = {
|
|
61
|
+
method: "POST",
|
|
62
|
+
credentials: "include",
|
|
63
|
+
headers: {
|
|
64
|
+
"Content-Type": "application/json"
|
|
65
|
+
},
|
|
66
|
+
body: JSON.stringify(tokenRequest)
|
|
67
|
+
};
|
|
68
|
+
const response = await fetch(url, requestOptions);
|
|
69
|
+
if (!response.ok) throw new Error(await response.text());
|
|
70
|
+
return await response.json();
|
|
71
|
+
}
|
|
72
|
+
};
|
|
73
|
+
|
|
74
|
+
// src/api/Controllers/Home.ts
|
|
75
|
+
var Home = class {
|
|
76
|
+
constructor(baseUrl) {
|
|
77
|
+
this.baseUrl = baseUrl;
|
|
78
|
+
}
|
|
79
|
+
};
|
|
80
|
+
|
|
81
|
+
// src/api/SparkStudioAuthenticationSDK.ts
|
|
82
|
+
var SparkStudioAuthenticationSDK = class {
|
|
83
|
+
constructor(baseUrl) {
|
|
84
|
+
this.auth = new Auth(baseUrl);
|
|
85
|
+
this.home = new Home(baseUrl);
|
|
86
|
+
}
|
|
87
|
+
};
|
|
88
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
89
|
+
0 && (module.exports = {
|
|
90
|
+
SparkStudioAuthenticationSDK
|
|
91
|
+
});
|
|
92
|
+
//# sourceMappingURL=index.cjs.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/index.ts","../src/api/Controllers/Auth.ts","../src/api/Controllers/Home.ts","../src/api/SparkStudioAuthenticationSDK.ts"],"sourcesContent":["export * from \"./api/SparkStudioAuthenticationSDK\";","\r\nimport type { UserDTO } from \"../DTOs/UserDTO\";\r\nimport type { TokenRequest } from \"../DTOs/TokenRequest\";\r\nimport type { AuthResponse } from \"../DTOs/AuthResponse\";\r\n\r\n /**\r\n * Auto-generated client for the Auth controller.\r\n */\r\nexport class Auth {\r\n private baseUrl: string;\r\n\r\n constructor(baseUrl: string) {\r\n this.baseUrl = baseUrl;\r\n }\r\n\r\n public async Logout( ): Promise<UserDTO> {\r\n const url = `${this.baseUrl}/api/Auth/Logout`\r\n\r\n // Construct the request options\r\n const requestOptions: RequestInit = {\r\n method: 'GET',\r\n credentials: \"include\",\r\n headers: {\r\n 'Content-Type': 'application/json'\r\n }, \r\n };\r\n\r\n // Perform the fetch request\r\n const response = await fetch(url, requestOptions);\r\n\r\n // Throw an error if the response is not successful\r\n if (!response.ok) throw new Error(await response.text());\r\n\r\n // Return the parsed response\r\n return await response.json();\r\n } \r\n public async GetCurrentUser( ): Promise<UserDTO> {\r\n const url = `${this.baseUrl}/api/Auth/GetCurrentUser`\r\n\r\n // Construct the request options\r\n const requestOptions: RequestInit = {\r\n method: 'GET',\r\n credentials: \"include\",\r\n headers: {\r\n 'Content-Type': 'application/json'\r\n }, \r\n };\r\n\r\n // Perform the fetch request\r\n const response = await fetch(url, requestOptions);\r\n\r\n // Throw an error if the response is not successful\r\n if (!response.ok) throw new Error(await response.text());\r\n\r\n // Return the parsed response\r\n return await response.json();\r\n } \r\n public async SignIn(tokenRequest: TokenRequest ): Promise<AuthResponse> {\r\n const url = `${this.baseUrl}/api/Auth/SignIn`\r\n\r\n // Construct the request options\r\n const requestOptions: RequestInit = {\r\n method: 'POST',\r\n credentials: \"include\",\r\n headers: {\r\n 'Content-Type': 'application/json'\r\n }, \r\n body: JSON.stringify(tokenRequest) \r\n };\r\n\r\n // Perform the fetch request\r\n const response = await fetch(url, requestOptions);\r\n\r\n // Throw an error if the response is not successful\r\n if (!response.ok) throw new Error(await response.text());\r\n\r\n // Return the parsed response\r\n return await response.json();\r\n } \r\n}","\r\n\r\n /**\r\n * Auto-generated client for the Home controller.\r\n */\r\nexport class Home {\r\n private baseUrl: string;\r\n\r\n constructor(baseUrl: string) {\r\n this.baseUrl = baseUrl;\r\n }\r\n\r\n}","\r\nimport { Auth } from \"./Controllers/Auth\";\r\nimport { Home } from \"./Controllers/Home\";\r\n\r\n /**\r\n * Auto-generated API client.\r\n */\r\nexport class SparkStudioAuthenticationSDK {\r\n\r\n public auth: Auth;\r\n public home: Home;\r\n\r\n constructor(baseUrl: string) { \r\n this.auth = new Auth(baseUrl);\r\n this.home = new Home(baseUrl);\r\n }\r\n}\r\n\r\n"],"mappings":";;;;;;;;;;;;;;;;;;;;AAAA;AAAA;AAAA;AAAA;AAAA;;;ACQO,IAAM,OAAN,MAAW;AAAA,EAGd,YAAY,SAAiB;AACzB,SAAK,UAAU;AAAA,EACnB;AAAA,EAEA,MAAa,SAA4B;AACrC,UAAM,MAAM,GAAG,KAAK,OAAO;AAG3B,UAAM,iBAA8B;AAAA,MAChC,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,SAAS;AAAA,QACL,gBAAgB;AAAA,MACpB;AAAA,IACJ;AAGA,UAAM,WAAW,MAAM,MAAM,KAAK,cAAc;AAGhD,QAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,MAAM,SAAS,KAAK,CAAC;AAGvD,WAAO,MAAM,SAAS,KAAK;AAAA,EAC/B;AAAA,EACA,MAAa,iBAAoC;AAC7C,UAAM,MAAM,GAAG,KAAK,OAAO;AAG3B,UAAM,iBAA8B;AAAA,MAChC,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,SAAS;AAAA,QACL,gBAAgB;AAAA,MACpB;AAAA,IACJ;AAGA,UAAM,WAAW,MAAM,MAAM,KAAK,cAAc;AAGhD,QAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,MAAM,SAAS,KAAK,CAAC;AAGvD,WAAO,MAAM,SAAS,KAAK;AAAA,EAC/B;AAAA,EACA,MAAa,OAAO,cAAoD;AACpE,UAAM,MAAM,GAAG,KAAK,OAAO;AAG3B,UAAM,iBAA8B;AAAA,MAChC,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,SAAS;AAAA,QACL,gBAAgB;AAAA,MACpB;AAAA,MACA,MAAM,KAAK,UAAU,YAAY;AAAA,IACrC;AAGA,UAAM,WAAW,MAAM,MAAM,KAAK,cAAc;AAGhD,QAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,MAAM,SAAS,KAAK,CAAC;AAGvD,WAAO,MAAM,SAAS,KAAK;AAAA,EAC/B;AACJ;;;AC1EO,IAAM,OAAN,MAAW;AAAA,EAGd,YAAY,SAAiB;AACzB,SAAK,UAAU;AAAA,EACnB;AAEJ;;;ACLO,IAAM,+BAAN,MAAmC;AAAA,EAKtC,YAAY,SAAiB;AACzB,SAAK,OAAO,IAAI,KAAK,OAAO;AAC5B,SAAK,OAAO,IAAI,KAAK,OAAO;AAAA,EAChC;AACJ;","names":[]}
|
package/dist/index.d.cts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an Auto-generated model for UserDTO.
|
|
3
|
+
*/
|
|
4
|
+
interface IUserDTO {
|
|
5
|
+
Sub?: string;
|
|
6
|
+
Name?: string;
|
|
7
|
+
Email?: string;
|
|
8
|
+
ProfilePicture?: string;
|
|
9
|
+
}
|
|
10
|
+
type UserDTOInit = Partial<IUserDTO>;
|
|
11
|
+
declare class UserDTO implements IUserDTO {
|
|
12
|
+
Sub?: string;
|
|
13
|
+
Name?: string;
|
|
14
|
+
Email?: string;
|
|
15
|
+
ProfilePicture?: string;
|
|
16
|
+
constructor(init: UserDTOInit);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Represents an Auto-generated model for TokenRequest.
|
|
21
|
+
*/
|
|
22
|
+
interface ITokenRequest {
|
|
23
|
+
Token?: string;
|
|
24
|
+
}
|
|
25
|
+
type TokenRequestInit = Partial<ITokenRequest>;
|
|
26
|
+
declare class TokenRequest implements ITokenRequest {
|
|
27
|
+
Token?: string;
|
|
28
|
+
constructor(init: TokenRequestInit);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Represents an Auto-generated model for AuthResponse.
|
|
33
|
+
*/
|
|
34
|
+
interface IAuthResponse {
|
|
35
|
+
User: UserDTO;
|
|
36
|
+
}
|
|
37
|
+
type AuthResponseInit = Partial<IAuthResponse> & Pick<IAuthResponse, "User">;
|
|
38
|
+
declare class AuthResponse implements IAuthResponse {
|
|
39
|
+
User: UserDTO;
|
|
40
|
+
constructor(init: AuthResponseInit);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Auto-generated client for the Auth controller.
|
|
45
|
+
*/
|
|
46
|
+
declare class Auth {
|
|
47
|
+
private baseUrl;
|
|
48
|
+
constructor(baseUrl: string);
|
|
49
|
+
Logout(): Promise<UserDTO>;
|
|
50
|
+
GetCurrentUser(): Promise<UserDTO>;
|
|
51
|
+
SignIn(tokenRequest: TokenRequest): Promise<AuthResponse>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Auto-generated client for the Home controller.
|
|
56
|
+
*/
|
|
57
|
+
declare class Home {
|
|
58
|
+
private baseUrl;
|
|
59
|
+
constructor(baseUrl: string);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Auto-generated API client.
|
|
64
|
+
*/
|
|
65
|
+
declare class SparkStudioAuthenticationSDK {
|
|
66
|
+
auth: Auth;
|
|
67
|
+
home: Home;
|
|
68
|
+
constructor(baseUrl: string);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { SparkStudioAuthenticationSDK };
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,71 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Represents an Auto-generated model for UserDTO.
|
|
3
|
+
*/
|
|
4
|
+
interface IUserDTO {
|
|
5
|
+
Sub?: string;
|
|
6
|
+
Name?: string;
|
|
7
|
+
Email?: string;
|
|
8
|
+
ProfilePicture?: string;
|
|
9
|
+
}
|
|
10
|
+
type UserDTOInit = Partial<IUserDTO>;
|
|
11
|
+
declare class UserDTO implements IUserDTO {
|
|
12
|
+
Sub?: string;
|
|
13
|
+
Name?: string;
|
|
14
|
+
Email?: string;
|
|
15
|
+
ProfilePicture?: string;
|
|
16
|
+
constructor(init: UserDTOInit);
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Represents an Auto-generated model for TokenRequest.
|
|
21
|
+
*/
|
|
22
|
+
interface ITokenRequest {
|
|
23
|
+
Token?: string;
|
|
24
|
+
}
|
|
25
|
+
type TokenRequestInit = Partial<ITokenRequest>;
|
|
26
|
+
declare class TokenRequest implements ITokenRequest {
|
|
27
|
+
Token?: string;
|
|
28
|
+
constructor(init: TokenRequestInit);
|
|
29
|
+
}
|
|
30
|
+
|
|
31
|
+
/**
|
|
32
|
+
* Represents an Auto-generated model for AuthResponse.
|
|
33
|
+
*/
|
|
34
|
+
interface IAuthResponse {
|
|
35
|
+
User: UserDTO;
|
|
36
|
+
}
|
|
37
|
+
type AuthResponseInit = Partial<IAuthResponse> & Pick<IAuthResponse, "User">;
|
|
38
|
+
declare class AuthResponse implements IAuthResponse {
|
|
39
|
+
User: UserDTO;
|
|
40
|
+
constructor(init: AuthResponseInit);
|
|
41
|
+
}
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* Auto-generated client for the Auth controller.
|
|
45
|
+
*/
|
|
46
|
+
declare class Auth {
|
|
47
|
+
private baseUrl;
|
|
48
|
+
constructor(baseUrl: string);
|
|
49
|
+
Logout(): Promise<UserDTO>;
|
|
50
|
+
GetCurrentUser(): Promise<UserDTO>;
|
|
51
|
+
SignIn(tokenRequest: TokenRequest): Promise<AuthResponse>;
|
|
52
|
+
}
|
|
53
|
+
|
|
54
|
+
/**
|
|
55
|
+
* Auto-generated client for the Home controller.
|
|
56
|
+
*/
|
|
57
|
+
declare class Home {
|
|
58
|
+
private baseUrl;
|
|
59
|
+
constructor(baseUrl: string);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
/**
|
|
63
|
+
* Auto-generated API client.
|
|
64
|
+
*/
|
|
65
|
+
declare class SparkStudioAuthenticationSDK {
|
|
66
|
+
auth: Auth;
|
|
67
|
+
home: Home;
|
|
68
|
+
constructor(baseUrl: string);
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
export { SparkStudioAuthenticationSDK };
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
// src/api/Controllers/Auth.ts
|
|
2
|
+
var Auth = class {
|
|
3
|
+
constructor(baseUrl) {
|
|
4
|
+
this.baseUrl = baseUrl;
|
|
5
|
+
}
|
|
6
|
+
async Logout() {
|
|
7
|
+
const url = `${this.baseUrl}/api/Auth/Logout`;
|
|
8
|
+
const requestOptions = {
|
|
9
|
+
method: "GET",
|
|
10
|
+
credentials: "include",
|
|
11
|
+
headers: {
|
|
12
|
+
"Content-Type": "application/json"
|
|
13
|
+
}
|
|
14
|
+
};
|
|
15
|
+
const response = await fetch(url, requestOptions);
|
|
16
|
+
if (!response.ok) throw new Error(await response.text());
|
|
17
|
+
return await response.json();
|
|
18
|
+
}
|
|
19
|
+
async GetCurrentUser() {
|
|
20
|
+
const url = `${this.baseUrl}/api/Auth/GetCurrentUser`;
|
|
21
|
+
const requestOptions = {
|
|
22
|
+
method: "GET",
|
|
23
|
+
credentials: "include",
|
|
24
|
+
headers: {
|
|
25
|
+
"Content-Type": "application/json"
|
|
26
|
+
}
|
|
27
|
+
};
|
|
28
|
+
const response = await fetch(url, requestOptions);
|
|
29
|
+
if (!response.ok) throw new Error(await response.text());
|
|
30
|
+
return await response.json();
|
|
31
|
+
}
|
|
32
|
+
async SignIn(tokenRequest) {
|
|
33
|
+
const url = `${this.baseUrl}/api/Auth/SignIn`;
|
|
34
|
+
const requestOptions = {
|
|
35
|
+
method: "POST",
|
|
36
|
+
credentials: "include",
|
|
37
|
+
headers: {
|
|
38
|
+
"Content-Type": "application/json"
|
|
39
|
+
},
|
|
40
|
+
body: JSON.stringify(tokenRequest)
|
|
41
|
+
};
|
|
42
|
+
const response = await fetch(url, requestOptions);
|
|
43
|
+
if (!response.ok) throw new Error(await response.text());
|
|
44
|
+
return await response.json();
|
|
45
|
+
}
|
|
46
|
+
};
|
|
47
|
+
|
|
48
|
+
// src/api/Controllers/Home.ts
|
|
49
|
+
var Home = class {
|
|
50
|
+
constructor(baseUrl) {
|
|
51
|
+
this.baseUrl = baseUrl;
|
|
52
|
+
}
|
|
53
|
+
};
|
|
54
|
+
|
|
55
|
+
// src/api/SparkStudioAuthenticationSDK.ts
|
|
56
|
+
var SparkStudioAuthenticationSDK = class {
|
|
57
|
+
constructor(baseUrl) {
|
|
58
|
+
this.auth = new Auth(baseUrl);
|
|
59
|
+
this.home = new Home(baseUrl);
|
|
60
|
+
}
|
|
61
|
+
};
|
|
62
|
+
export {
|
|
63
|
+
SparkStudioAuthenticationSDK
|
|
64
|
+
};
|
|
65
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"sources":["../src/api/Controllers/Auth.ts","../src/api/Controllers/Home.ts","../src/api/SparkStudioAuthenticationSDK.ts"],"sourcesContent":["\r\nimport type { UserDTO } from \"../DTOs/UserDTO\";\r\nimport type { TokenRequest } from \"../DTOs/TokenRequest\";\r\nimport type { AuthResponse } from \"../DTOs/AuthResponse\";\r\n\r\n /**\r\n * Auto-generated client for the Auth controller.\r\n */\r\nexport class Auth {\r\n private baseUrl: string;\r\n\r\n constructor(baseUrl: string) {\r\n this.baseUrl = baseUrl;\r\n }\r\n\r\n public async Logout( ): Promise<UserDTO> {\r\n const url = `${this.baseUrl}/api/Auth/Logout`\r\n\r\n // Construct the request options\r\n const requestOptions: RequestInit = {\r\n method: 'GET',\r\n credentials: \"include\",\r\n headers: {\r\n 'Content-Type': 'application/json'\r\n }, \r\n };\r\n\r\n // Perform the fetch request\r\n const response = await fetch(url, requestOptions);\r\n\r\n // Throw an error if the response is not successful\r\n if (!response.ok) throw new Error(await response.text());\r\n\r\n // Return the parsed response\r\n return await response.json();\r\n } \r\n public async GetCurrentUser( ): Promise<UserDTO> {\r\n const url = `${this.baseUrl}/api/Auth/GetCurrentUser`\r\n\r\n // Construct the request options\r\n const requestOptions: RequestInit = {\r\n method: 'GET',\r\n credentials: \"include\",\r\n headers: {\r\n 'Content-Type': 'application/json'\r\n }, \r\n };\r\n\r\n // Perform the fetch request\r\n const response = await fetch(url, requestOptions);\r\n\r\n // Throw an error if the response is not successful\r\n if (!response.ok) throw new Error(await response.text());\r\n\r\n // Return the parsed response\r\n return await response.json();\r\n } \r\n public async SignIn(tokenRequest: TokenRequest ): Promise<AuthResponse> {\r\n const url = `${this.baseUrl}/api/Auth/SignIn`\r\n\r\n // Construct the request options\r\n const requestOptions: RequestInit = {\r\n method: 'POST',\r\n credentials: \"include\",\r\n headers: {\r\n 'Content-Type': 'application/json'\r\n }, \r\n body: JSON.stringify(tokenRequest) \r\n };\r\n\r\n // Perform the fetch request\r\n const response = await fetch(url, requestOptions);\r\n\r\n // Throw an error if the response is not successful\r\n if (!response.ok) throw new Error(await response.text());\r\n\r\n // Return the parsed response\r\n return await response.json();\r\n } \r\n}","\r\n\r\n /**\r\n * Auto-generated client for the Home controller.\r\n */\r\nexport class Home {\r\n private baseUrl: string;\r\n\r\n constructor(baseUrl: string) {\r\n this.baseUrl = baseUrl;\r\n }\r\n\r\n}","\r\nimport { Auth } from \"./Controllers/Auth\";\r\nimport { Home } from \"./Controllers/Home\";\r\n\r\n /**\r\n * Auto-generated API client.\r\n */\r\nexport class SparkStudioAuthenticationSDK {\r\n\r\n public auth: Auth;\r\n public home: Home;\r\n\r\n constructor(baseUrl: string) { \r\n this.auth = new Auth(baseUrl);\r\n this.home = new Home(baseUrl);\r\n }\r\n}\r\n\r\n"],"mappings":";AAQO,IAAM,OAAN,MAAW;AAAA,EAGd,YAAY,SAAiB;AACzB,SAAK,UAAU;AAAA,EACnB;AAAA,EAEA,MAAa,SAA4B;AACrC,UAAM,MAAM,GAAG,KAAK,OAAO;AAG3B,UAAM,iBAA8B;AAAA,MAChC,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,SAAS;AAAA,QACL,gBAAgB;AAAA,MACpB;AAAA,IACJ;AAGA,UAAM,WAAW,MAAM,MAAM,KAAK,cAAc;AAGhD,QAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,MAAM,SAAS,KAAK,CAAC;AAGvD,WAAO,MAAM,SAAS,KAAK;AAAA,EAC/B;AAAA,EACA,MAAa,iBAAoC;AAC7C,UAAM,MAAM,GAAG,KAAK,OAAO;AAG3B,UAAM,iBAA8B;AAAA,MAChC,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,SAAS;AAAA,QACL,gBAAgB;AAAA,MACpB;AAAA,IACJ;AAGA,UAAM,WAAW,MAAM,MAAM,KAAK,cAAc;AAGhD,QAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,MAAM,SAAS,KAAK,CAAC;AAGvD,WAAO,MAAM,SAAS,KAAK;AAAA,EAC/B;AAAA,EACA,MAAa,OAAO,cAAoD;AACpE,UAAM,MAAM,GAAG,KAAK,OAAO;AAG3B,UAAM,iBAA8B;AAAA,MAChC,QAAQ;AAAA,MACR,aAAa;AAAA,MACb,SAAS;AAAA,QACL,gBAAgB;AAAA,MACpB;AAAA,MACA,MAAM,KAAK,UAAU,YAAY;AAAA,IACrC;AAGA,UAAM,WAAW,MAAM,MAAM,KAAK,cAAc;AAGhD,QAAI,CAAC,SAAS,GAAI,OAAM,IAAI,MAAM,MAAM,SAAS,KAAK,CAAC;AAGvD,WAAO,MAAM,SAAS,KAAK;AAAA,EAC/B;AACJ;;;AC1EO,IAAM,OAAN,MAAW;AAAA,EAGd,YAAY,SAAiB;AACzB,SAAK,UAAU;AAAA,EACnB;AAEJ;;;ACLO,IAAM,+BAAN,MAAmC;AAAA,EAKtC,YAAY,SAAiB;AACzB,SAAK,OAAO,IAAI,KAAK,OAAO;AAC5B,SAAK,OAAO,IAAI,KAAK,OAAO;AAAA,EAChC;AACJ;","names":[]}
|
package/package.json
ADDED
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@sparkstudio/authentication-sdk",
|
|
3
|
+
"version": "1.0.1",
|
|
4
|
+
"type": "module",
|
|
5
|
+
"main": "./dist/index.cjs",
|
|
6
|
+
"module": "./dist/index.js",
|
|
7
|
+
"types": "./dist/index.d.ts",
|
|
8
|
+
"publishConfig": {
|
|
9
|
+
"access": "public"
|
|
10
|
+
},
|
|
11
|
+
"exports": {
|
|
12
|
+
".": {
|
|
13
|
+
"types": "./dist/index.d.ts",
|
|
14
|
+
"import": "./dist/index.js",
|
|
15
|
+
"require": "./dist/index.cjs"
|
|
16
|
+
}
|
|
17
|
+
},
|
|
18
|
+
"files": [
|
|
19
|
+
"dist",
|
|
20
|
+
"README.md",
|
|
21
|
+
"LICENSE"
|
|
22
|
+
],
|
|
23
|
+
"scripts": {
|
|
24
|
+
"build": "tsup",
|
|
25
|
+
"test": "echo \"(no tests)\""
|
|
26
|
+
},
|
|
27
|
+
"dependencies": {
|
|
28
|
+
"tsup": "^8.5.1",
|
|
29
|
+
"typescript": "^5.9.3"
|
|
30
|
+
}
|
|
31
|
+
}
|