@alien_org/sso-sdk-core 1.0.5 → 1.0.7

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/client.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- import { AuthorizeResponse, TokenInfo, UserInfo } from './schema';
1
+ import { AuthorizeResponse, TokenInfo } from './schema';
2
2
  import { z } from 'zod/v4-mini';
3
3
  export interface JWTHeader {
4
4
  alg: string;
@@ -23,8 +23,6 @@ export declare class AlienSsoSdkClient {
23
23
  exchangeToken(authorizationCode: string): Promise<string | null>;
24
24
  verifyAuth(): Promise<boolean>;
25
25
  getAccessToken(): string | null;
26
- getUserInfo(): (TokenInfo & {
27
- user: UserInfo;
28
- }) | null;
26
+ getAuthData(): TokenInfo | null;
29
27
  logout(): void;
30
28
  }
package/dist/client.js CHANGED
@@ -1,4 +1,4 @@
1
- import { AuthorizeResponseSchema, ExchangeCodeRequestSchema, ExchangeCodeResponseSchema, InternalAuthorizeRequestSchema, PollRequestSchema, PollResponseSchema, TokenInfoSchema, UserInfoSchema, VerifyTokenRequestSchema, VerifyTokenResponseSchema, } from './schema';
1
+ import { AuthorizeResponseSchema, ExchangeCodeRequestSchema, ExchangeCodeResponseSchema, InternalAuthorizeRequestSchema, PollRequestSchema, PollResponseSchema, TokenInfoSchema, VerifyTokenRequestSchema, VerifyTokenResponseSchema, } from './schema';
2
2
  import { z } from 'zod/v4-mini';
3
3
  import base64url from 'base64url';
4
4
  import CryptoJS from 'crypto-js';
@@ -140,56 +140,39 @@ export class AlienSsoSdkClient {
140
140
  }
141
141
  const json = await response.json();
142
142
  const verifyTokenResponse = VerifyTokenResponseSchema.parse(json);
143
- if (!verifyTokenResponse.is_valid) {
144
- throw new Error('Access token is invalid.');
145
- }
146
143
  return verifyTokenResponse.is_valid;
147
144
  }
148
145
  getAccessToken() {
149
146
  return localStorage.getItem(STORAGE_KEY + 'access_token');
150
147
  }
151
- getUserInfo() {
148
+ getAuthData() {
152
149
  const token = this.getAccessToken();
153
150
  if (!token)
154
151
  return null;
155
152
  const tokenParts = token.split('.');
156
153
  if (tokenParts.length !== 3) {
157
- throw new Error('Invalid token format');
158
- }
159
- const headerPart = tokenParts[0];
160
- if (!headerPart)
161
154
  return null;
155
+ }
162
156
  let header;
163
157
  try {
164
- const headerJson = base64url.decode(headerPart);
158
+ const headerJson = base64url.decode(tokenParts[0]);
165
159
  header = JSON.parse(headerJson);
166
160
  }
167
161
  catch {
168
- throw new Error('Invalid token header format');
162
+ return null;
169
163
  }
170
164
  if (header.alg !== 'HS256' || header.typ !== 'JWT') {
171
- throw new Error('Unsupported token algorithm or type');
172
- }
173
- const payloadPart = tokenParts[1];
174
- if (!payloadPart)
175
165
  return null;
166
+ }
176
167
  let payload;
177
168
  try {
178
- const payloadJson = JSON.parse(base64url.decode(payloadPart));
169
+ const payloadJson = JSON.parse(base64url.decode(tokenParts[1]));
179
170
  payload = TokenInfoSchema.parse(payloadJson);
180
171
  }
181
172
  catch {
182
- throw new Error('Invalid token payload format');
183
- }
184
- let user;
185
- try {
186
- const userJson = JSON.parse(payload.app_callback_payload);
187
- user = UserInfoSchema.parse(userJson);
188
- }
189
- catch {
190
- throw new Error('Invalid app_callback_payload JSON format');
173
+ return null;
191
174
  }
192
- return Object.assign({}, payload, { user });
175
+ return payload;
193
176
  }
194
177
  logout() {
195
178
  localStorage.removeItem(STORAGE_KEY + 'access_token');
package/dist/schema.d.ts CHANGED
@@ -60,19 +60,10 @@ export declare const VerifyTokenResponseSchema: z.ZodMiniObject<{
60
60
  is_valid: z.ZodMiniBoolean<boolean>;
61
61
  }, z.core.$strip>;
62
62
  export type VerifyTokenResponse = z.infer<typeof VerifyTokenResponseSchema>;
63
- /**
64
- * User info schema
65
- */
66
- export declare const UserInfoSchema: z.ZodMiniObject<{
67
- session_address: z.ZodMiniString<string>;
68
- }, z.core.$strip>;
69
- export type UserInfo = z.infer<typeof UserInfoSchema>;
70
63
  /**
71
64
  * Token info schema
72
65
  */
73
66
  export declare const TokenInfoSchema: z.ZodMiniObject<{
74
- app_callback_payload: z.ZodMiniString<string>;
75
- app_callback_session_signature: z.ZodMiniString<string>;
76
67
  app_callback_session_address: z.ZodMiniString<string>;
77
68
  expired_at: z.ZodMiniNumber<number>;
78
69
  issued_at: z.ZodMiniNumber<number>;
package/dist/schema.js CHANGED
@@ -50,18 +50,10 @@ export const VerifyTokenRequestSchema = z.object({
50
50
  export const VerifyTokenResponseSchema = z.object({
51
51
  is_valid: z.boolean(),
52
52
  });
53
- /**
54
- * User info schema
55
- */
56
- export const UserInfoSchema = z.object({
57
- session_address: z.string(),
58
- });
59
53
  /**
60
54
  * Token info schema
61
55
  */
62
56
  export const TokenInfoSchema = z.object({
63
- app_callback_payload: z.string(),
64
- app_callback_session_signature: z.string(),
65
57
  app_callback_session_address: z.string(),
66
58
  expired_at: z.number(),
67
59
  issued_at: z.number(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alien_org/sso-sdk-core",
3
- "version": "1.0.5",
3
+ "version": "1.0.7",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/alien-id/sso-sdk-js.git"