@sparkstudio/authentication-ui 1.0.32 → 1.0.34

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 CHANGED
@@ -25,6 +25,7 @@ __export(index_exports, {
25
25
  AuthResponse: () => AuthResponse,
26
26
  AuthenticatorProvider: () => AuthenticatorProvider,
27
27
  EMPTY_GUID: () => EMPTY_GUID,
28
+ GuidUtil: () => GuidUtil,
28
29
  Home: () => Home,
29
30
  LoginButton: () => LoginButton,
30
31
  SparkStudioAuthenticationSDK: () => SparkStudioAuthenticationSDK,
@@ -134,6 +135,28 @@ var AuthResponse = class {
134
135
  }
135
136
  };
136
137
 
138
+ // src/api/DTOs/Guid.ts
139
+ var GuidUtil = class {
140
+ static Empty = "00000000-0000-0000-0000-000000000000";
141
+ static guidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
142
+ static create() {
143
+ return crypto.randomUUID();
144
+ }
145
+ static parse(value) {
146
+ if (value === this.Empty) return this.Empty;
147
+ if (!this.isValid(value)) {
148
+ throw new Error(`Invalid GUID: ${value}`);
149
+ }
150
+ return value;
151
+ }
152
+ static isValid(value) {
153
+ return value === this.Empty || this.guidRegex.test(value);
154
+ }
155
+ static isEmpty(value) {
156
+ return value === this.Empty;
157
+ }
158
+ };
159
+
137
160
  // src/api/DTOs/TokenRequest.ts
138
161
  var TokenRequest = class {
139
162
  Token;
@@ -415,6 +438,7 @@ var EMPTY_GUID = "00000000-0000-0000-0000-000000000000";
415
438
  AuthResponse,
416
439
  AuthenticatorProvider,
417
440
  EMPTY_GUID,
441
+ GuidUtil,
418
442
  Home,
419
443
  LoginButton,
420
444
  SparkStudioAuthenticationSDK,
package/dist/index.js CHANGED
@@ -95,6 +95,28 @@ var AuthResponse = class {
95
95
  }
96
96
  };
97
97
 
98
+ // src/api/DTOs/Guid.ts
99
+ var GuidUtil = class {
100
+ static Empty = "00000000-0000-0000-0000-000000000000";
101
+ static guidRegex = /^[0-9a-f]{8}-[0-9a-f]{4}-[1-5][0-9a-f]{3}-[89ab][0-9a-f]{3}-[0-9a-f]{12}$/i;
102
+ static create() {
103
+ return crypto.randomUUID();
104
+ }
105
+ static parse(value) {
106
+ if (value === this.Empty) return this.Empty;
107
+ if (!this.isValid(value)) {
108
+ throw new Error(`Invalid GUID: ${value}`);
109
+ }
110
+ return value;
111
+ }
112
+ static isValid(value) {
113
+ return value === this.Empty || this.guidRegex.test(value);
114
+ }
115
+ static isEmpty(value) {
116
+ return value === this.Empty;
117
+ }
118
+ };
119
+
98
120
  // src/api/DTOs/TokenRequest.ts
99
121
  var TokenRequest = class {
100
122
  Token;
@@ -385,6 +407,7 @@ export {
385
407
  AuthResponse,
386
408
  AuthenticatorProvider,
387
409
  EMPTY_GUID,
410
+ GuidUtil,
388
411
  Home,
389
412
  LoginButton,
390
413
  SparkStudioAuthenticationSDK,
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sparkstudio/authentication-ui",
3
- "version": "1.0.32",
3
+ "version": "1.0.34",
4
4
  "type": "module",
5
5
  "main": "dist/index.cjs",
6
6
  "module": "dist/index.js",
package/dist/index.css DELETED
@@ -1,3 +0,0 @@
1
- @import "/node_modules/@sparkstudio/accounts-ui/dist/index.css";
2
-
3
- /*# sourceMappingURL=index.css.map */
@@ -1 +0,0 @@
1
- {"version":3,"sourceRoot":"","sources":["../src/index.scss"],"names":[],"mappings":"AAAQ","file":"index.css"}
package/dist/index.d.cts DELETED
@@ -1,141 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ReactNode } from 'react';
3
-
4
- interface IAppSettings {
5
- AuthenticationUrl: string;
6
- AccountsUrl: string;
7
- Version: string;
8
- GoogleClientId: string;
9
- ApplicationName: string;
10
- }
11
- declare const AppSettings: IAppSettings;
12
- declare function loadConfig(): Promise<void>;
13
-
14
- /**
15
- * Represents an Auto-generated model for UserDTO.
16
- */
17
- interface IUserDTO {
18
- Id?: string;
19
- Sub?: string;
20
- Name?: string;
21
- Email?: string;
22
- ProfilePicture?: string;
23
- }
24
- type UserDTOInit = Partial<IUserDTO>;
25
- declare class UserDTO implements IUserDTO {
26
- Id?: string;
27
- Sub?: string;
28
- Name?: string;
29
- Email?: string;
30
- ProfilePicture?: string;
31
- constructor(init: UserDTOInit);
32
- }
33
-
34
- /**
35
- * Represents an Auto-generated model for TokenRequest.
36
- */
37
- interface ITokenRequest {
38
- Token?: string;
39
- }
40
- type TokenRequestInit = Partial<ITokenRequest>;
41
- declare class TokenRequest implements ITokenRequest {
42
- Token?: string;
43
- constructor(init: TokenRequestInit);
44
- }
45
-
46
- /**
47
- * Represents an Auto-generated model for AuthResponse.
48
- */
49
- interface IAuthResponse {
50
- Token?: string;
51
- User: UserDTO;
52
- }
53
- type AuthResponseInit = Partial<IAuthResponse> & Pick<IAuthResponse, "User">;
54
- declare class AuthResponse implements IAuthResponse {
55
- Token?: string;
56
- User: UserDTO;
57
- constructor(init: AuthResponseInit);
58
- }
59
-
60
- /**
61
- * Auto-generated client for the Auth controller.
62
- */
63
- declare class Auth {
64
- private baseUrl;
65
- constructor(baseUrl: string);
66
- Logout(): Promise<UserDTO>;
67
- GetCurrentUser(): Promise<UserDTO>;
68
- SignIn(tokenRequest: TokenRequest): Promise<AuthResponse>;
69
- }
70
-
71
- /**
72
- * Auto-generated client for the Home controller.
73
- */
74
- declare class Home {
75
- private baseUrl;
76
- constructor(baseUrl: string);
77
- }
78
-
79
- /**
80
- * Auto-generated API client.
81
- */
82
- declare class SparkStudioAuthenticationSDK {
83
- auth: Auth;
84
- home: Home;
85
- constructor(baseUrl: string);
86
- }
87
-
88
- interface AuthenticatorProviderProps {
89
- googleClientId: string;
90
- authenticationUrl: string;
91
- accountsUrl: string;
92
- children: ReactNode;
93
- onLoginSuccess?: (user: UserDTO | null) => void;
94
- onLoginFailed?: (error: unknown) => void;
95
- onLogoutSuccess?: () => void;
96
- onLogoutFailed?: (error: unknown) => void;
97
- }
98
- /**
99
- * Public entrypoint for consumers:
100
- * Wraps children with Google OAuth + User context.
101
- */
102
- declare function AuthenticatorProvider({ googleClientId, authenticationUrl, accountsUrl, children, onLoginSuccess, onLoginFailed, onLogoutSuccess, onLogoutFailed, }: AuthenticatorProviderProps): react_jsx_runtime.JSX.Element;
103
-
104
- interface UserInfoCardProps {
105
- onLogin?: (user: UserDTO) => void;
106
- onLoginFailed?: (error: unknown) => void;
107
- onLogout?: () => void;
108
- }
109
- declare function UserInfoCard({ onLogin, onLogout, onLoginFailed }: UserInfoCardProps): react_jsx_runtime.JSX.Element;
110
-
111
- interface LoginButtonProps {
112
- onLogin?: (user: AuthResponse["User"]) => void;
113
- onLoginFailed?: (error: unknown) => void;
114
- }
115
- declare function LoginButton({ onLogin, onLoginFailed }: LoginButtonProps): react_jsx_runtime.JSX.Element;
116
-
117
- interface UserContextType {
118
- user: UserDTO | null;
119
- setUser: (user: UserDTO | null) => void;
120
- logout: () => Promise<void>;
121
- authenticationUrl: string;
122
- accountsUrl: string;
123
- isAuthenticated: boolean;
124
- isLoading: boolean;
125
- }
126
- interface UserProviderProps {
127
- children: ReactNode;
128
- authenticationUrl: string;
129
- accountsUrl: string;
130
- onLoginSuccess?: (user: UserDTO | null) => void;
131
- onLoginFailed?: (error: unknown) => void;
132
- onLogoutSuccess?: () => void;
133
- onLogoutFailed?: (error: unknown) => void;
134
- }
135
- declare function UserProvider({ children, authenticationUrl, accountsUrl, onLoginSuccess, onLoginFailed, onLogoutSuccess, onLogoutFailed, }: UserProviderProps): react_jsx_runtime.JSX.Element;
136
- declare function useUser(): UserContextType;
137
-
138
- type Guid = string;
139
- declare const EMPTY_GUID: Guid;
140
-
141
- export { AppSettings, Auth, AuthResponse, AuthenticatorProvider, type AuthenticatorProviderProps, EMPTY_GUID, type Guid, Home, type IAppSettings, type IAuthResponse, type ITokenRequest, type IUserDTO, LoginButton, SparkStudioAuthenticationSDK, TokenRequest, UserDTO, UserInfoCard, UserProvider, loadConfig, useUser };
package/dist/index.d.ts DELETED
@@ -1,141 +0,0 @@
1
- import * as react_jsx_runtime from 'react/jsx-runtime';
2
- import { ReactNode } from 'react';
3
-
4
- interface IAppSettings {
5
- AuthenticationUrl: string;
6
- AccountsUrl: string;
7
- Version: string;
8
- GoogleClientId: string;
9
- ApplicationName: string;
10
- }
11
- declare const AppSettings: IAppSettings;
12
- declare function loadConfig(): Promise<void>;
13
-
14
- /**
15
- * Represents an Auto-generated model for UserDTO.
16
- */
17
- interface IUserDTO {
18
- Id?: string;
19
- Sub?: string;
20
- Name?: string;
21
- Email?: string;
22
- ProfilePicture?: string;
23
- }
24
- type UserDTOInit = Partial<IUserDTO>;
25
- declare class UserDTO implements IUserDTO {
26
- Id?: string;
27
- Sub?: string;
28
- Name?: string;
29
- Email?: string;
30
- ProfilePicture?: string;
31
- constructor(init: UserDTOInit);
32
- }
33
-
34
- /**
35
- * Represents an Auto-generated model for TokenRequest.
36
- */
37
- interface ITokenRequest {
38
- Token?: string;
39
- }
40
- type TokenRequestInit = Partial<ITokenRequest>;
41
- declare class TokenRequest implements ITokenRequest {
42
- Token?: string;
43
- constructor(init: TokenRequestInit);
44
- }
45
-
46
- /**
47
- * Represents an Auto-generated model for AuthResponse.
48
- */
49
- interface IAuthResponse {
50
- Token?: string;
51
- User: UserDTO;
52
- }
53
- type AuthResponseInit = Partial<IAuthResponse> & Pick<IAuthResponse, "User">;
54
- declare class AuthResponse implements IAuthResponse {
55
- Token?: string;
56
- User: UserDTO;
57
- constructor(init: AuthResponseInit);
58
- }
59
-
60
- /**
61
- * Auto-generated client for the Auth controller.
62
- */
63
- declare class Auth {
64
- private baseUrl;
65
- constructor(baseUrl: string);
66
- Logout(): Promise<UserDTO>;
67
- GetCurrentUser(): Promise<UserDTO>;
68
- SignIn(tokenRequest: TokenRequest): Promise<AuthResponse>;
69
- }
70
-
71
- /**
72
- * Auto-generated client for the Home controller.
73
- */
74
- declare class Home {
75
- private baseUrl;
76
- constructor(baseUrl: string);
77
- }
78
-
79
- /**
80
- * Auto-generated API client.
81
- */
82
- declare class SparkStudioAuthenticationSDK {
83
- auth: Auth;
84
- home: Home;
85
- constructor(baseUrl: string);
86
- }
87
-
88
- interface AuthenticatorProviderProps {
89
- googleClientId: string;
90
- authenticationUrl: string;
91
- accountsUrl: string;
92
- children: ReactNode;
93
- onLoginSuccess?: (user: UserDTO | null) => void;
94
- onLoginFailed?: (error: unknown) => void;
95
- onLogoutSuccess?: () => void;
96
- onLogoutFailed?: (error: unknown) => void;
97
- }
98
- /**
99
- * Public entrypoint for consumers:
100
- * Wraps children with Google OAuth + User context.
101
- */
102
- declare function AuthenticatorProvider({ googleClientId, authenticationUrl, accountsUrl, children, onLoginSuccess, onLoginFailed, onLogoutSuccess, onLogoutFailed, }: AuthenticatorProviderProps): react_jsx_runtime.JSX.Element;
103
-
104
- interface UserInfoCardProps {
105
- onLogin?: (user: UserDTO) => void;
106
- onLoginFailed?: (error: unknown) => void;
107
- onLogout?: () => void;
108
- }
109
- declare function UserInfoCard({ onLogin, onLogout, onLoginFailed }: UserInfoCardProps): react_jsx_runtime.JSX.Element;
110
-
111
- interface LoginButtonProps {
112
- onLogin?: (user: AuthResponse["User"]) => void;
113
- onLoginFailed?: (error: unknown) => void;
114
- }
115
- declare function LoginButton({ onLogin, onLoginFailed }: LoginButtonProps): react_jsx_runtime.JSX.Element;
116
-
117
- interface UserContextType {
118
- user: UserDTO | null;
119
- setUser: (user: UserDTO | null) => void;
120
- logout: () => Promise<void>;
121
- authenticationUrl: string;
122
- accountsUrl: string;
123
- isAuthenticated: boolean;
124
- isLoading: boolean;
125
- }
126
- interface UserProviderProps {
127
- children: ReactNode;
128
- authenticationUrl: string;
129
- accountsUrl: string;
130
- onLoginSuccess?: (user: UserDTO | null) => void;
131
- onLoginFailed?: (error: unknown) => void;
132
- onLogoutSuccess?: () => void;
133
- onLogoutFailed?: (error: unknown) => void;
134
- }
135
- declare function UserProvider({ children, authenticationUrl, accountsUrl, onLoginSuccess, onLoginFailed, onLogoutSuccess, onLogoutFailed, }: UserProviderProps): react_jsx_runtime.JSX.Element;
136
- declare function useUser(): UserContextType;
137
-
138
- type Guid = string;
139
- declare const EMPTY_GUID: Guid;
140
-
141
- export { AppSettings, Auth, AuthResponse, AuthenticatorProvider, type AuthenticatorProviderProps, EMPTY_GUID, type Guid, Home, type IAppSettings, type IAuthResponse, type ITokenRequest, type IUserDTO, LoginButton, SparkStudioAuthenticationSDK, TokenRequest, UserDTO, UserInfoCard, UserProvider, loadConfig, useUser };