@go-avro/avro-js 0.0.2-beta.3 → 0.0.2-beta.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.
|
@@ -6,7 +6,7 @@ export declare class AuthManager {
|
|
|
6
6
|
baseUrl: string;
|
|
7
7
|
storage: TokenStorage | TokenStorage[];
|
|
8
8
|
});
|
|
9
|
-
|
|
9
|
+
isAuthenticated(): Promise<boolean>;
|
|
10
10
|
fetchNewTokens(): Promise<Tokens>;
|
|
11
11
|
accessToken(): Promise<string | undefined>;
|
|
12
12
|
refreshTokens(): Promise<Tokens | null>;
|
package/dist/auth/AuthManager.js
CHANGED
|
@@ -11,11 +11,26 @@ export class AuthManager {
|
|
|
11
11
|
});
|
|
12
12
|
this.baseUrl = baseUrl;
|
|
13
13
|
}
|
|
14
|
-
async
|
|
14
|
+
async isAuthenticated() {
|
|
15
|
+
if (!this.storages.length) {
|
|
16
|
+
throw new Error('No token storages initialized');
|
|
17
|
+
}
|
|
15
18
|
for (const storage of this.storages) {
|
|
16
19
|
const tokens = await storage.get();
|
|
17
20
|
if (tokens && tokens.access_token) {
|
|
18
|
-
|
|
21
|
+
try {
|
|
22
|
+
const response = await fetch(`${this.baseUrl}/validate`, {
|
|
23
|
+
method: 'POST',
|
|
24
|
+
headers: {
|
|
25
|
+
'Content-Type': 'application/json',
|
|
26
|
+
'Authorization': `Bearer ${tokens.access_token}`,
|
|
27
|
+
},
|
|
28
|
+
});
|
|
29
|
+
return response.ok;
|
|
30
|
+
}
|
|
31
|
+
catch (error) {
|
|
32
|
+
console.error('Error validating access token:', error);
|
|
33
|
+
}
|
|
19
34
|
}
|
|
20
35
|
}
|
|
21
36
|
return false;
|
|
@@ -22,5 +22,5 @@ export declare class AvroQueryClient {
|
|
|
22
22
|
password: string;
|
|
23
23
|
}, cancelToken?: CancelToken): Promise<Boolean>;
|
|
24
24
|
logout(cancelToken?: CancelToken): Promise<void>;
|
|
25
|
-
fetchJobs(companyGuid: string, amt?: number, knownIds?: string[], unknownIds?: string[], keyword?: string, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
25
|
+
fetchJobs(companyGuid: string, amt?: number, knownIds?: string[], unknownIds?: string[], keyword?: string, offset?: number, cancelToken?: CancelToken, headers?: Record<string, string>): Promise<any>;
|
|
26
26
|
}
|
|
@@ -197,7 +197,7 @@ export class AvroQueryClient {
|
|
|
197
197
|
throw new StandardError(500, 'Logout failed');
|
|
198
198
|
});
|
|
199
199
|
}
|
|
200
|
-
fetchJobs(companyGuid, amt = 50, knownIds = [], unknownIds = [], keyword = '', cancelToken, headers = {}) {
|
|
200
|
+
fetchJobs(companyGuid, amt = 50, knownIds = [], unknownIds = [], keyword = '', offset = 0, cancelToken, headers = {}) {
|
|
201
201
|
const body = {
|
|
202
202
|
amt,
|
|
203
203
|
known_ids: knownIds,
|
|
@@ -207,7 +207,7 @@ export class AvroQueryClient {
|
|
|
207
207
|
if (!companyGuid) {
|
|
208
208
|
return Promise.reject(new StandardError(400, 'Company GUID is required'));
|
|
209
209
|
}
|
|
210
|
-
return this._fetch('POST', `/company/${companyGuid}/jobs?amt=${amt}`, body, cancelToken, headers)
|
|
210
|
+
return this._fetch('POST', `/company/${companyGuid}/jobs?amt=${amt}&offset=${offset}`, body, cancelToken, headers)
|
|
211
211
|
.then(response => {
|
|
212
212
|
if (!response || !Array.isArray(response)) {
|
|
213
213
|
throw new StandardError(400, 'Invalid jobs response');
|