@alien_org/sso-sdk-core 1.0.4 → 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 +4 -6
- package/dist/server.js +2 -2
- package/dist/utils.d.ts +1 -0
- package/dist/utils.js +3 -0
- package/package.json +1 -1
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(
|
|
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
|
|
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
|
|
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
|
|
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',
|
package/dist/utils.d.ts
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare const joinUrl: (base: string, path: string) => string;
|
package/dist/utils.js
ADDED