@alien_org/sso-sdk-core 1.0.4 → 1.0.6

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,7 +1,8 @@
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';
5
+ import { joinUrl } from './utils';
5
6
  const SERVER_SDK_BASEURL = 'http://localhost:3000';
6
7
  const SSO_BASE_URL = 'https://sso.alien.com';
7
8
  const POLLING_INTERVAL = 5000;
@@ -64,9 +65,8 @@ export class AlienSsoSdkClient {
64
65
  polling_code: pollingCode,
65
66
  };
66
67
  PollRequestSchema.parse(pollPayload);
67
- const pollingUrl = `${this.config.ssoBaseUrl}/poll`;
68
68
  while (true) {
69
- const response = await fetch(pollingUrl, {
69
+ const response = await fetch(joinUrl(this.config.ssoBaseUrl, '/poll'), {
70
70
  method: 'POST',
71
71
  headers: {
72
72
  'Content-Type': 'application/json',
@@ -99,8 +99,7 @@ export class AlienSsoSdkClient {
99
99
  code_verifier: codeVerifier,
100
100
  };
101
101
  ExchangeCodeRequestSchema.parse(exchangeCodePayload);
102
- const exchangeUrl = `${this.config.ssoBaseUrl}/access_token/exchange`;
103
- const response = await fetch(exchangeUrl, {
102
+ const response = await fetch(joinUrl(this.config.ssoBaseUrl, '/access_token/exchange'), {
104
103
  method: 'POST',
105
104
  headers: {
106
105
  'Content-Type': 'application/json',
@@ -129,8 +128,7 @@ export class AlienSsoSdkClient {
129
128
  access_token,
130
129
  };
131
130
  VerifyTokenRequestSchema.parse(verifyTokenPayload);
132
- const verifyTokenUrl = `${this.config.ssoBaseUrl}/access_token/verify`;
133
- const response = await fetch(verifyTokenUrl, {
131
+ const response = await fetch(joinUrl(this.config.ssoBaseUrl, '/access_token/verify'), {
134
132
  method: 'POST',
135
133
  headers: {
136
134
  'Content-Type': 'application/json',
@@ -150,7 +148,7 @@ export class AlienSsoSdkClient {
150
148
  getAccessToken() {
151
149
  return localStorage.getItem(STORAGE_KEY + 'access_token');
152
150
  }
153
- getUserInfo() {
151
+ getAuthData() {
154
152
  const token = this.getAccessToken();
155
153
  if (!token)
156
154
  return null;
@@ -183,15 +181,7 @@ export class AlienSsoSdkClient {
183
181
  catch {
184
182
  throw new Error('Invalid token payload format');
185
183
  }
186
- let user;
187
- try {
188
- const userJson = JSON.parse(payload.app_callback_payload);
189
- user = UserInfoSchema.parse(userJson);
190
- }
191
- catch {
192
- throw new Error('Invalid app_callback_payload JSON format');
193
- }
194
- return Object.assign({}, payload, { user });
184
+ return payload;
195
185
  }
196
186
  logout() {
197
187
  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/dist/server.js CHANGED
@@ -2,6 +2,7 @@ import { AuthorizeResponseSchema, AuthorizeRequestSchema, } from './schema';
2
2
  import { z } from 'zod/v4-mini';
3
3
  import { signAsync } from '@noble/ed25519';
4
4
  import { AuthenticationError, ValidationError } from './errors';
5
+ import { joinUrl } from './utils';
5
6
  const DEFAULT_SSO_BASE_URL = 'https://sso.alien-api.com';
6
7
  export const AlienSsoSdkServerConfigSchema = z.object({
7
8
  providerAddress: z.string(),
@@ -33,8 +34,7 @@ export class AlienSsoSdkServer {
33
34
  provider_signature: Buffer.from(signature).toString('hex'),
34
35
  };
35
36
  AuthorizeRequestSchema.parse(authorizePayload);
36
- const authorizationUrl = `${this.config.ssoBaseUrl}/authorize`;
37
- const response = await fetch(authorizationUrl, {
37
+ const response = await fetch(joinUrl(this.config.ssoBaseUrl, '/authorize'), {
38
38
  method: 'POST',
39
39
  headers: {
40
40
  'Content-Type': 'application/json',
@@ -0,0 +1 @@
1
+ export declare const joinUrl: (base: string, path: string) => string;
package/dist/utils.js ADDED
@@ -0,0 +1,3 @@
1
+ export const joinUrl = (base, path) => {
2
+ return new URL(path, base).toString();
3
+ };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alien_org/sso-sdk-core",
3
- "version": "1.0.4",
3
+ "version": "1.0.6",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/alien-id/sso-sdk-js.git"