@alien_org/sso-sdk-core 1.0.6 → 1.0.8
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 +2 -2
- package/dist/client.js +6 -15
- package/package.json +1 -1
package/dist/client.d.ts
CHANGED
|
@@ -19,8 +19,8 @@ export declare class AlienSsoSdkClient {
|
|
|
19
19
|
private generateCodeVerifier;
|
|
20
20
|
private generateCodeChallenge;
|
|
21
21
|
getAuthDeeplink(): Promise<AuthorizeResponse>;
|
|
22
|
-
pollAuth(pollingCode: string): Promise<string
|
|
23
|
-
exchangeToken(authorizationCode: string): Promise<string
|
|
22
|
+
pollAuth(pollingCode: string): Promise<string>;
|
|
23
|
+
exchangeToken(authorizationCode: string): Promise<string>;
|
|
24
24
|
verifyAuth(): Promise<boolean>;
|
|
25
25
|
getAccessToken(): string | null;
|
|
26
26
|
getAuthData(): TokenInfo | null;
|
package/dist/client.js
CHANGED
|
@@ -140,9 +140,6 @@ 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() {
|
|
@@ -154,32 +151,26 @@ export class AlienSsoSdkClient {
|
|
|
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(
|
|
158
|
+
const headerJson = base64url.decode(tokenParts[0]);
|
|
165
159
|
header = JSON.parse(headerJson);
|
|
166
160
|
}
|
|
167
161
|
catch {
|
|
168
|
-
|
|
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(
|
|
169
|
+
const payloadJson = JSON.parse(base64url.decode(tokenParts[1]));
|
|
179
170
|
payload = TokenInfoSchema.parse(payloadJson);
|
|
180
171
|
}
|
|
181
172
|
catch {
|
|
182
|
-
|
|
173
|
+
return null;
|
|
183
174
|
}
|
|
184
175
|
return payload;
|
|
185
176
|
}
|