@alien_org/sso-sdk-core 1.0.9 → 1.0.11

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
@@ -5,23 +5,23 @@ export interface JWTHeader {
5
5
  typ: string;
6
6
  }
7
7
  export declare const AlienSsoSdkClientSchema: z.ZodMiniObject<{
8
- serverSdkBaseUrl: z.ZodMiniString<string>;
9
8
  ssoBaseUrl: z.ZodMiniURL;
9
+ providerAddress: z.ZodMiniString<string>;
10
10
  pollingInterval: z.ZodMiniOptional<z.ZodMiniNumber<number>>;
11
11
  }, z.core.$strip>;
12
12
  export type AlienSsoSdkClientConfig = z.infer<typeof AlienSsoSdkClientSchema>;
13
13
  export declare class AlienSsoSdkClient {
14
14
  readonly config: AlienSsoSdkClientConfig;
15
15
  readonly pollingInterval: number;
16
- readonly serverSdkBaseUrl: string;
17
16
  readonly ssoBaseUrl: string;
17
+ readonly providerAddress: string;
18
18
  constructor(config: AlienSsoSdkClientConfig);
19
19
  private generateCodeVerifier;
20
20
  private generateCodeChallenge;
21
21
  getAuthDeeplink(): Promise<AuthorizeResponse>;
22
22
  pollAuth(pollingCode: string): Promise<string>;
23
23
  exchangeToken(authorizationCode: string): Promise<string>;
24
- verifyAuth(providerAddress: string): Promise<boolean>;
24
+ verifyAuth(): Promise<boolean>;
25
25
  getAccessToken(): string | null;
26
26
  getAuthData(): TokenInfo | null;
27
27
  logout(): void;
package/dist/client.js CHANGED
@@ -3,20 +3,19 @@ import { z } from 'zod/v4-mini';
3
3
  import base64url from 'base64url';
4
4
  import CryptoJS from 'crypto-js';
5
5
  import { joinUrl } from './utils';
6
- const SERVER_SDK_BASEURL = 'http://localhost:3000';
7
6
  const SSO_BASE_URL = 'https://sso.alien.com';
8
7
  const POLLING_INTERVAL = 5000;
9
8
  const STORAGE_KEY = 'alien-sso_';
10
9
  export const AlienSsoSdkClientSchema = z.object({
11
- serverSdkBaseUrl: z.string(),
12
10
  ssoBaseUrl: z.url(),
11
+ providerAddress: z.string(),
13
12
  pollingInterval: z.optional(z.number()),
14
13
  });
15
14
  export class AlienSsoSdkClient {
16
15
  constructor(config) {
17
16
  this.config = AlienSsoSdkClientSchema.parse(config);
18
17
  this.ssoBaseUrl = this.config.ssoBaseUrl || SSO_BASE_URL;
19
- this.serverSdkBaseUrl = this.config.serverSdkBaseUrl || SERVER_SDK_BASEURL;
18
+ this.providerAddress = this.config.providerAddress;
20
19
  this.pollingInterval = this.config.pollingInterval || POLLING_INTERVAL;
21
20
  }
22
21
  generateCodeVerifier(length = 128) {
@@ -45,7 +44,7 @@ export class AlienSsoSdkClient {
45
44
  const codeVerifier = this.generateCodeVerifier();
46
45
  const codeChallenge = await this.generateCodeChallenge(codeVerifier);
47
46
  sessionStorage.setItem(STORAGE_KEY + 'code_verifier', codeVerifier);
48
- const authorizeUrl = `${this.config.serverSdkBaseUrl}/authorize`;
47
+ const authorizeUrl = `${this.config.ssoBaseUrl}/sso/authorize`;
49
48
  const authorizePayload = {
50
49
  code_challenge: codeChallenge,
51
50
  };
@@ -54,6 +53,7 @@ export class AlienSsoSdkClient {
54
53
  method: 'POST',
55
54
  headers: {
56
55
  'Content-Type': 'application/json',
56
+ 'X-PROVIDER-ADDRESS': this.providerAddress,
57
57
  },
58
58
  body: JSON.stringify(authorizePayload),
59
59
  });
@@ -66,10 +66,11 @@ export class AlienSsoSdkClient {
66
66
  };
67
67
  PollRequestSchema.parse(pollPayload);
68
68
  while (true) {
69
- const response = await fetch(joinUrl(this.config.ssoBaseUrl, '/poll'), {
69
+ const response = await fetch(joinUrl(this.config.ssoBaseUrl, '/sso/poll'), {
70
70
  method: 'POST',
71
71
  headers: {
72
72
  'Content-Type': 'application/json',
73
+ 'X-PROVIDER-ADDRESS': this.providerAddress,
73
74
  },
74
75
  body: JSON.stringify(pollPayload),
75
76
  });
@@ -99,10 +100,11 @@ export class AlienSsoSdkClient {
99
100
  code_verifier: codeVerifier,
100
101
  };
101
102
  ExchangeCodeRequestSchema.parse(exchangeCodePayload);
102
- const response = await fetch(joinUrl(this.config.ssoBaseUrl, '/access_token/exchange'), {
103
+ const response = await fetch(joinUrl(this.config.ssoBaseUrl, '/sso/access_token/exchange'), {
103
104
  method: 'POST',
104
105
  headers: {
105
106
  'Content-Type': 'application/json',
107
+ 'X-PROVIDER-ADDRESS': this.providerAddress,
106
108
  },
107
109
  body: JSON.stringify(exchangeCodePayload),
108
110
  });
@@ -119,20 +121,20 @@ export class AlienSsoSdkClient {
119
121
  throw new Error('Exchange failed');
120
122
  }
121
123
  }
122
- async verifyAuth(providerAddress) {
124
+ async verifyAuth() {
123
125
  const access_token = this.getAccessToken();
124
126
  if (!access_token) {
125
127
  throw new Error('Access token is invalid.');
126
128
  }
127
129
  const verifyTokenPayload = {
128
130
  access_token,
129
- provider_address: providerAddress,
130
131
  };
131
132
  VerifyTokenRequestSchema.parse(verifyTokenPayload);
132
- const response = await fetch(joinUrl(this.config.ssoBaseUrl, '/access_token/verify'), {
133
+ const response = await fetch(joinUrl(this.config.ssoBaseUrl, '/sso/access_token/verify'), {
133
134
  method: 'POST',
134
135
  headers: {
135
136
  'Content-Type': 'application/json',
137
+ 'X-PROVIDER-ADDRESS': this.providerAddress,
136
138
  },
137
139
  body: JSON.stringify(verifyTokenPayload),
138
140
  });
package/dist/index.d.ts CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './client';
2
- export * from './server';
3
2
  export * from './errors';
4
3
  export * from './schema';
package/dist/index.js CHANGED
@@ -1,4 +1,3 @@
1
1
  export * from './client';
2
- export * from './server';
3
2
  export * from './errors';
4
3
  export * from './schema';
package/dist/schema.d.ts CHANGED
@@ -12,8 +12,6 @@ export type InternalAuthorizeRequest = z.infer<typeof InternalAuthorizeRequestSc
12
12
  export declare const AuthorizeRequestSchema: z.ZodMiniObject<{
13
13
  code_challenge: z.ZodMiniString<string>;
14
14
  code_challenge_method: z.ZodMiniLiteral<"S256">;
15
- provider_address: z.ZodMiniString<string>;
16
- provider_signature: z.ZodMiniString<string>;
17
15
  }, z.core.$strip>;
18
16
  export type AuthorizeRequest = z.infer<typeof AuthorizeRequestSchema>;
19
17
  export declare const AuthorizeResponseSchema: z.ZodMiniObject<{
@@ -54,7 +52,6 @@ export type ExchangeCodeResponse = z.infer<typeof ExchangeCodeResponseSchema>;
54
52
  */
55
53
  export declare const VerifyTokenRequestSchema: z.ZodMiniObject<{
56
54
  access_token: z.ZodMiniString<string>;
57
- provider_address: z.ZodMiniString<string>;
58
55
  }, z.core.$strip>;
59
56
  export type VerifyTokenRequest = z.infer<typeof VerifyTokenRequestSchema>;
60
57
  export declare const VerifyTokenResponseSchema: z.ZodMiniObject<{
package/dist/schema.js CHANGED
@@ -11,8 +11,6 @@ export const InternalAuthorizeRequestSchema = z.object({
11
11
  export const AuthorizeRequestSchema = z.object({
12
12
  code_challenge: z.string(),
13
13
  code_challenge_method: z.literal('S256'),
14
- provider_address: z.string(),
15
- provider_signature: z.string(),
16
14
  });
17
15
  export const AuthorizeResponseSchema = z.object({
18
16
  deep_link: z.string(),
@@ -46,7 +44,6 @@ export const ExchangeCodeResponseSchema = z.object({
46
44
  */
47
45
  export const VerifyTokenRequestSchema = z.object({
48
46
  access_token: z.string(),
49
- provider_address: z.string(),
50
47
  });
51
48
  export const VerifyTokenResponseSchema = z.object({
52
49
  is_valid: z.boolean(),
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alien_org/sso-sdk-core",
3
- "version": "1.0.9",
3
+ "version": "1.0.11",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/alien-id/sso-sdk-js.git"