@alien_org/sso-sdk-core 1.0.3 → 1.0.5

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.js CHANGED
@@ -2,6 +2,7 @@ import { AuthorizeResponseSchema, ExchangeCodeRequestSchema, ExchangeCodeRespons
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',
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',
@@ -42,7 +42,6 @@ export class AlienSsoSdkServer {
42
42
  body: JSON.stringify(authorizePayload),
43
43
  });
44
44
  if (!response.ok) {
45
- const text = await response.text();
46
45
  throw new AuthenticationError(`SSO Router Authorization failed: ${response.status} ${response.statusText} ${await response.text()}`);
47
46
  }
48
47
  const json = await response.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.3",
3
+ "version": "1.0.5",
4
4
  "repository": {
5
5
  "type": "git",
6
6
  "url": "git+https://github.com/alien-id/sso-sdk-js.git"