@octostar/platform-api 0.5.3 → 0.5.4
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/platform-api.d.ts +8 -48
- package/lib/apis.d.ts +1 -4
- package/lib/apis.d.ts.map +1 -1
- package/lib/apis.js +0 -12
- package/lib/apis.js.map +1 -1
- package/lib/constants.d.ts +3 -3
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +4 -9
- package/lib/constants.js.map +1 -1
- package/lib/factory.d.ts.map +1 -1
- package/lib/factory.js +15 -85
- package/lib/factory.js.map +1 -1
- package/lib/index.d.ts +0 -3
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +0 -3
- package/lib/index.js.map +1 -1
- package/lib/permissions.d.ts +0 -1
- package/lib/permissions.d.ts.map +1 -1
- package/lib/permissions.js +0 -1
- package/lib/permissions.js.map +1 -1
- package/package.json +5 -3
- package/lib/lib/AIClientImpl.d.ts +0 -9
- package/lib/lib/AIClientImpl.d.ts.map +0 -1
- package/lib/lib/AIClientImpl.js +0 -44
- package/lib/lib/AIClientImpl.js.map +0 -1
- package/lib/lib/JWTProvider.d.ts +0 -14
- package/lib/lib/JWTProvider.d.ts.map +0 -1
- package/lib/lib/JWTProvider.js +0 -39
- package/lib/lib/JWTProvider.js.map +0 -1
- package/lib/lib/Proxy.d.ts +0 -2
- package/lib/lib/Proxy.d.ts.map +0 -1
- package/lib/lib/Proxy.js +0 -17
- package/lib/lib/Proxy.js.map +0 -1
package/dist/platform-api.d.ts
CHANGED
|
@@ -1,15 +1,8 @@
|
|
|
1
|
-
import { AIClient } from '@octostar/platform-types';
|
|
2
|
-
import { ChatModel } from '@octostar/platform-types';
|
|
3
1
|
import { Concept } from '@octostar/platform-types';
|
|
4
2
|
import { ContextMenuRequest } from '@octostar/platform-types';
|
|
5
3
|
import { Desktop } from '@octostar/platform-types';
|
|
6
4
|
import { Entity } from '@octostar/platform-types';
|
|
7
|
-
import { ExtrasApi } from '@octostar/platform-types';
|
|
8
5
|
import { Ontology } from '@octostar/platform-types';
|
|
9
|
-
import { OsAPIClient } from '@octostar/platform-types';
|
|
10
|
-
import { PromptOptions } from '@octostar/platform-types';
|
|
11
|
-
import { RemoteAppApi } from '@octostar/platform-types';
|
|
12
|
-
import { SavedSearchAPIInterface } from '@octostar/platform-types';
|
|
13
6
|
import { TagWithRelationship } from '@octostar/platform-types';
|
|
14
7
|
import { WorkspaceItem } from '@octostar/platform-types';
|
|
15
8
|
|
|
@@ -32,27 +25,17 @@ export declare abstract class AbstractContextMenu extends HTMLElement {
|
|
|
32
25
|
private publishRequest;
|
|
33
26
|
}
|
|
34
27
|
|
|
35
|
-
export declare class AIClientImpl implements AIClient {
|
|
36
|
-
private osAPIClient;
|
|
37
|
-
private models;
|
|
38
|
-
constructor(osAPIClient: OsAPIClient);
|
|
39
|
-
getChatModels(): Promise<ChatModel[]>;
|
|
40
|
-
prompt(prompt: string, options?: PromptOptions): Promise<string>;
|
|
41
|
-
}
|
|
42
|
-
|
|
43
28
|
/**
|
|
44
29
|
* @beta
|
|
45
30
|
* All permissions.
|
|
46
31
|
*/
|
|
47
32
|
export declare const ALL_PERMISSIONS = "all";
|
|
48
33
|
|
|
49
|
-
export declare const ALL_PERMISSIONS_ARRAY: string[];
|
|
50
|
-
|
|
51
34
|
/**
|
|
52
35
|
* @beta
|
|
53
36
|
* API names.
|
|
54
37
|
*/
|
|
55
|
-
export declare const apiNames: Record<"desktop", "octostar:api-names:desktop"> & Record<"ontology", "octostar:api-names:ontology"> & Record<"context", "octostar:api-names:context"
|
|
38
|
+
export declare const apiNames: Record<"desktop", "octostar:api-names:desktop"> & Record<"ontology", "octostar:api-names:ontology"> & Record<"context", "octostar:api-names:context">;
|
|
56
39
|
|
|
57
40
|
declare type BasePostResponsePayload<D, E> = {
|
|
58
41
|
data: D;
|
|
@@ -88,7 +71,7 @@ declare type CreateMessageNamesResult<N, M> = M extends readonly [infer F, ...in
|
|
|
88
71
|
* @beta
|
|
89
72
|
* Create a set of message names with a namespace.
|
|
90
73
|
*/
|
|
91
|
-
export declare const createPrefixesConstants: <N extends string, M extends readonly [string, ...string[]]>(namespace: N, messages: M
|
|
74
|
+
export declare const createPrefixesConstants: <N extends string, M extends readonly [string, ...string[]]>(namespace: N, messages: M) => CreateMessageNamesResult<N, M>;
|
|
92
75
|
|
|
93
76
|
/**
|
|
94
77
|
* @beta
|
|
@@ -119,8 +102,6 @@ export declare type ErrorPostResponsePayload = BasePostResponsePayload<null, {
|
|
|
119
102
|
message: string;
|
|
120
103
|
}>;
|
|
121
104
|
|
|
122
|
-
export declare const extrasApi: () => EnsureMethodsReturnPromise<ExtrasApi>;
|
|
123
|
-
|
|
124
105
|
/**
|
|
125
106
|
* @beta
|
|
126
107
|
* Get the context API asynchronously.
|
|
@@ -139,12 +120,6 @@ export declare const getDesktopApi: () => Promise<EnsureMethodsReturnPromise<Des
|
|
|
139
120
|
*/
|
|
140
121
|
export declare const getOntologyApi: () => Promise<EnsureMethodsReturnPromise<Ontology>>;
|
|
141
122
|
|
|
142
|
-
/**
|
|
143
|
-
* @beta
|
|
144
|
-
* Message names for post messages.
|
|
145
|
-
*/
|
|
146
|
-
export declare const getPostMessageNames: (channelId: string) => Record<"get_api", "octostar:post-messages:get_api">;
|
|
147
|
-
|
|
148
123
|
/**
|
|
149
124
|
* @beta
|
|
150
125
|
* Type representing a message value.
|
|
@@ -153,19 +128,6 @@ export declare type GetRemoteApiParams = {
|
|
|
153
128
|
name: string;
|
|
154
129
|
};
|
|
155
130
|
|
|
156
|
-
export declare class JWTProvider implements TokenProvider {
|
|
157
|
-
private token;
|
|
158
|
-
private decoded;
|
|
159
|
-
private tokenProvider;
|
|
160
|
-
private expiresThreshold;
|
|
161
|
-
constructor(tokenProvider: TokenProvider, expiresThreshold?: number);
|
|
162
|
-
private fetchToken;
|
|
163
|
-
private isExpiredOrExpiringSoon;
|
|
164
|
-
getToken(): Promise<string>;
|
|
165
|
-
}
|
|
166
|
-
|
|
167
|
-
export declare const makeProxy: <T extends object>(obj: T, excludeKeys?: (keyof T)[]) => Record<string, any>;
|
|
168
|
-
|
|
169
131
|
declare type MessageValue<N, M> = `${N & string}:${M & string}`;
|
|
170
132
|
|
|
171
133
|
/**
|
|
@@ -296,6 +258,12 @@ export declare class OsTagsContextMenu extends AbstractContextMenu {
|
|
|
296
258
|
private update;
|
|
297
259
|
}
|
|
298
260
|
|
|
261
|
+
/**
|
|
262
|
+
* @beta
|
|
263
|
+
* Message names for post messages.
|
|
264
|
+
*/
|
|
265
|
+
export declare const postMessageNames: Record<"get_api", "octostar:post-messages:get_api">;
|
|
266
|
+
|
|
299
267
|
/**
|
|
300
268
|
* @beta
|
|
301
269
|
* Type representing a POST request.
|
|
@@ -335,8 +303,6 @@ export declare type RemoteApiError = Error & {
|
|
|
335
303
|
originalError: Error;
|
|
336
304
|
};
|
|
337
305
|
|
|
338
|
-
export declare const remoteAppApi: () => EnsureMethodsReturnPromise<RemoteAppApi>;
|
|
339
|
-
|
|
340
306
|
/**
|
|
341
307
|
* @beta
|
|
342
308
|
* Retry a function until it succeeds or the maximum number of attempts is reached.
|
|
@@ -352,8 +318,6 @@ declare type RetryOptions = {
|
|
|
352
318
|
retryInterval?: number;
|
|
353
319
|
};
|
|
354
320
|
|
|
355
|
-
export declare const savedSearchApi: () => EnsureMethodsReturnPromise<SavedSearchAPIInterface>;
|
|
356
|
-
|
|
357
321
|
/**
|
|
358
322
|
* @beta
|
|
359
323
|
* Type representing a POST response payload with a success.
|
|
@@ -374,8 +338,4 @@ export declare class TagDots extends HTMLElement {
|
|
|
374
338
|
render(): Promise<void>;
|
|
375
339
|
}
|
|
376
340
|
|
|
377
|
-
export declare interface TokenProvider {
|
|
378
|
-
getToken(): Promise<string>;
|
|
379
|
-
}
|
|
380
|
-
|
|
381
341
|
export { }
|
package/lib/apis.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Desktop, Ontology
|
|
1
|
+
import { Desktop, Ontology } from '@octostar/platform-types';
|
|
2
2
|
import { ContextApi, EnsureMethodsReturnPromise } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* @beta
|
|
@@ -6,9 +6,6 @@ import { ContextApi, EnsureMethodsReturnPromise } from './types';
|
|
|
6
6
|
* For asynchronous access, use {@link getDesktopApi}.
|
|
7
7
|
*/
|
|
8
8
|
export declare const desktopApi: () => EnsureMethodsReturnPromise<Desktop>;
|
|
9
|
-
export declare const extrasApi: () => EnsureMethodsReturnPromise<ExtrasApi>;
|
|
10
|
-
export declare const remoteAppApi: () => EnsureMethodsReturnPromise<RemoteAppApi>;
|
|
11
|
-
export declare const savedSearchApi: () => EnsureMethodsReturnPromise<SavedSearchAPIInterface>;
|
|
12
9
|
/**
|
|
13
10
|
* @beta
|
|
14
11
|
* Provides access to the ontology API.
|
package/lib/apis.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apis.d.ts","sourceRoot":"","sources":["../src/apis.ts"],"names":[],"mappings":"AAAA,OAAO,
|
|
1
|
+
{"version":3,"file":"apis.d.ts","sourceRoot":"","sources":["../src/apis.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,QAAQ,EAAE,MAAM,0BAA0B,CAAC;AAG7D,OAAO,EAAE,UAAU,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAuBjE;;;;GAIG;AACH,eAAO,MAAM,UAAU,2CACwC,CAAC;AAEhE;;;;GAIG;AACH,eAAO,MAAM,WAAW,4CACwC,CAAC;AAEjE;;;;GAIG;AACH,eAAO,MAAM,UAAU,uDACwC,CAAC;AAEhE;;;GAGG;AACH,eAAO,MAAM,aAAa,oDACoB,CAAC;AAE/C;;;GAGG;AACH,eAAO,MAAM,cAAc,qDACqB,CAAC;AAEjD;;;GAGG;AACH,eAAO,MAAM,aAAa,gEACoB,CAAC"}
|
package/lib/apis.js
CHANGED
|
@@ -23,15 +23,6 @@ const apisLocator = AsyncServiceLocator.getInstance('platform-api', {
|
|
|
23
23
|
// TODO: clarify about the context type
|
|
24
24
|
createRemoteApiHandle({
|
|
25
25
|
name: apiNames.context,
|
|
26
|
-
}))
|
|
27
|
-
.registerService('extras', () => createRemoteApiHandle({
|
|
28
|
-
name: apiNames.extras,
|
|
29
|
-
}))
|
|
30
|
-
.registerService('remoteApp', () => createRemoteApiHandle({
|
|
31
|
-
name: apiNames.remoteApp,
|
|
32
|
-
}))
|
|
33
|
-
.registerService('savedSearch', () => createRemoteApiHandle({
|
|
34
|
-
name: apiNames.savedSearch,
|
|
35
26
|
}));
|
|
36
27
|
/**
|
|
37
28
|
* @beta
|
|
@@ -39,9 +30,6 @@ createRemoteApiHandle({
|
|
|
39
30
|
* For asynchronous access, use {@link getDesktopApi}.
|
|
40
31
|
*/
|
|
41
32
|
export const desktopApi = () => forwardCallsToFutureObject(apisLocator.getService('desktop'));
|
|
42
|
-
export const extrasApi = () => forwardCallsToFutureObject(apisLocator.getService('extras'));
|
|
43
|
-
export const remoteAppApi = () => forwardCallsToFutureObject(apisLocator.getService('remoteApp'));
|
|
44
|
-
export const savedSearchApi = () => forwardCallsToFutureObject(apisLocator.getService('savedSearch'));
|
|
45
33
|
/**
|
|
46
34
|
* @beta
|
|
47
35
|
* Provides access to the ontology API.
|
package/lib/apis.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"apis.js","sourceRoot":"","sources":["../src/apis.ts"],"names":[],"mappings":";;;;;;;;;
|
|
1
|
+
{"version":3,"file":"apis.js","sourceRoot":"","sources":["../src/apis.ts"],"names":[],"mappings":";;;;;;;;;AACA,OAAO,EAAE,mBAAmB,EAAE,MAAM,2BAA2B,CAAC;AAChE,OAAO,EAAE,0BAA0B,EAAE,qBAAqB,EAAE,MAAM,WAAW,CAAC;AAE9E,OAAO,EAAE,QAAQ,EAAE,MAAM,aAAa,CAAC;AAEvC,MAAM,WAAW,GAAG,mBAAmB,CAAC,WAAW,CAAC,cAAc,EAAE;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@ -4,16 +4,16 @@ type CreateMessageNamesResult<N, M> = M extends readonly [infer F, ...infer R] ?
|
|
|
4
4
|
* @beta
|
|
5
5
|
* Create a set of message names with a namespace.
|
|
6
6
|
*/
|
|
7
|
-
export declare const createPrefixesConstants: <N extends string, M extends readonly [string, ...string[]]>(namespace: N, messages: M
|
|
7
|
+
export declare const createPrefixesConstants: <N extends string, M extends readonly [string, ...string[]]>(namespace: N, messages: M) => CreateMessageNamesResult<N, M>;
|
|
8
8
|
/**
|
|
9
9
|
* @beta
|
|
10
10
|
* Message names for post messages.
|
|
11
11
|
*/
|
|
12
|
-
export declare const
|
|
12
|
+
export declare const postMessageNames: Record<"get_api", "octostar:post-messages:get_api">;
|
|
13
13
|
/**
|
|
14
14
|
* @beta
|
|
15
15
|
* API names.
|
|
16
16
|
*/
|
|
17
|
-
export declare const apiNames: Record<"desktop", "octostar:api-names:desktop"> & Record<"ontology", "octostar:api-names:ontology"> & Record<"context", "octostar:api-names:context"
|
|
17
|
+
export declare const apiNames: Record<"desktop", "octostar:api-names:desktop"> & Record<"ontology", "octostar:api-names:ontology"> & Record<"context", "octostar:api-names:context">;
|
|
18
18
|
export {};
|
|
19
19
|
//# sourceMappingURL=constants.d.ts.map
|
package/lib/constants.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,EAAE,CAAC;AAExD,KAAK,wBAAwB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,GAC1E,MAAM,CAAC,CAAC,GAAG,MAAM,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAAC,GACvE,EAAE,CAAC;AAEP;;;GAGG;AACH,eAAO,MAAM,uBAAuB,
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAAA,KAAK,YAAY,CAAC,CAAC,EAAE,CAAC,IAAI,GAAG,CAAC,GAAG,MAAM,IAAI,CAAC,GAAG,MAAM,EAAE,CAAC;AAExD,KAAK,wBAAwB,CAAC,CAAC,EAAE,CAAC,IAAI,CAAC,SAAS,SAAS,CAAC,MAAM,CAAC,EAAE,GAAG,MAAM,CAAC,CAAC,GAC1E,MAAM,CAAC,CAAC,GAAG,MAAM,EAAE,YAAY,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,GAAG,wBAAwB,CAAC,CAAC,EAAE,CAAC,CAAC,GACvE,EAAE,CAAC;AAEP;;;GAGG;AACH,eAAO,MAAM,uBAAuB,2HAcnC,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,gBAAgB,qDAG5B,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,QAAQ,uJAIV,CAAC"}
|
package/lib/constants.js
CHANGED
|
@@ -2,12 +2,10 @@
|
|
|
2
2
|
* @beta
|
|
3
3
|
* Create a set of message names with a namespace.
|
|
4
4
|
*/
|
|
5
|
-
export const createPrefixesConstants = (namespace, messages
|
|
5
|
+
export const createPrefixesConstants = (namespace, messages) => {
|
|
6
6
|
const result = {};
|
|
7
7
|
messages.forEach(message => {
|
|
8
|
-
result[message] =
|
|
9
|
-
? `${namespace}:${channelId}:${message}`
|
|
10
|
-
: `${namespace}:${message}`;
|
|
8
|
+
result[message] = `${namespace}:${message}`;
|
|
11
9
|
});
|
|
12
10
|
return result;
|
|
13
11
|
};
|
|
@@ -15,7 +13,7 @@ export const createPrefixesConstants = (namespace, messages, channelId) => {
|
|
|
15
13
|
* @beta
|
|
16
14
|
* Message names for post messages.
|
|
17
15
|
*/
|
|
18
|
-
export const
|
|
16
|
+
export const postMessageNames = createPrefixesConstants('octostar:post-messages', ['get_api']);
|
|
19
17
|
/**
|
|
20
18
|
* @beta
|
|
21
19
|
* API names.
|
|
@@ -24,10 +22,7 @@ export const apiNames = createPrefixesConstants('octostar:api-names', [
|
|
|
24
22
|
'desktop',
|
|
25
23
|
'ontology',
|
|
26
24
|
'context',
|
|
27
|
-
|
|
28
|
-
'remoteApp',
|
|
29
|
-
'savedSearch',
|
|
30
|
-
], undefined);
|
|
25
|
+
]);
|
|
31
26
|
// test
|
|
32
27
|
// const v = messages.get_api;
|
|
33
28
|
//# sourceMappingURL=constants.js.map
|
package/lib/constants.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAIrC,SAAY,EACZ,QAAW,
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../src/constants.ts"],"names":[],"mappings":"AAMA;;;GAGG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAIrC,SAAY,EACZ,QAAW,EACqB,EAAE;IAClC,MAAM,MAAM,GAA+C,EAAE,CAAC;IAE9D,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACzB,MAAM,CAAC,OAAO,CAAC,GAAG,GAAG,SAAS,IAAI,OAAO,EAAE,CAAC;IAC9C,CAAC,CAAC,CAAC;IAEH,OAAO,MAAwC,CAAC;AAClD,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,gBAAgB,GAAG,uBAAuB,CACrD,wBAAwB,EACxB,CAAC,SAAS,CAAU,CACrB,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,uBAAuB,CAAC,oBAAoB,EAAE;IACpE,SAAS;IACT,UAAU;IACV,SAAS;CACD,CAAC,CAAC;AAEZ,OAAO;AACP,8BAA8B"}
|
package/lib/factory.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAGnB,MAAM,SAAS,CAAC;
|
|
1
|
+
{"version":3,"file":"factory.d.ts","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":"AACA,OAAO,EACL,kBAAkB,EAGnB,MAAM,SAAS,CAAC;AA0FjB,eAAO,MAAM,qBAAqB,6BACxB,kBAAkB,eAgB3B,CAAC;AAEF,eAAO,MAAM,0BAA0B,6BAS/B,CAAC"}
|
package/lib/factory.js
CHANGED
|
@@ -9,9 +9,9 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
|
|
|
9
9
|
};
|
|
10
10
|
import postRobot from 'post-robot';
|
|
11
11
|
import { retry } from './utils';
|
|
12
|
-
import {
|
|
12
|
+
import { postMessageNames } from './constants';
|
|
13
13
|
const hasParent = (window) => window.parent !== window;
|
|
14
|
-
function getOctostarWindow(
|
|
14
|
+
function getOctostarWindow(currentWindow = window, depth = 0) {
|
|
15
15
|
// Check all iframes in the current window
|
|
16
16
|
let iframes;
|
|
17
17
|
try {
|
|
@@ -24,7 +24,8 @@ function getOctostarWindow(channelId, currentWindow = window, depth = 0) {
|
|
|
24
24
|
for (let i = 0; i < iframes.length; i += 1) {
|
|
25
25
|
const iframe = iframes[i];
|
|
26
26
|
if (iframe.getAttribute('data-octostar-iframe') === 'true' &&
|
|
27
|
-
iframe.
|
|
27
|
+
new URL(iframe.baseURI).pathname === '/octostar/' // TODO: this is fragileremove this once we have a better way to check if the iframe is from Octostar
|
|
28
|
+
) {
|
|
28
29
|
return currentWindow;
|
|
29
30
|
}
|
|
30
31
|
}
|
|
@@ -39,7 +40,8 @@ function getOctostarWindow(channelId, currentWindow = window, depth = 0) {
|
|
|
39
40
|
throw new Error('Max depth reached. Octostar window not found.');
|
|
40
41
|
}
|
|
41
42
|
// If not found, continue searching in the parent window
|
|
42
|
-
|
|
43
|
+
// @ts-ignore
|
|
44
|
+
return getOctostarWindow(currentWindow.parent, depth + 1);
|
|
43
45
|
}
|
|
44
46
|
const handlePostResponse = (response) => {
|
|
45
47
|
if (response.data.error) {
|
|
@@ -73,88 +75,16 @@ const createObjectProxy = (value, options) => new Proxy(value, {
|
|
|
73
75
|
return target[prop];
|
|
74
76
|
},
|
|
75
77
|
});
|
|
76
|
-
function tryFetchingFomAttributes(currentWindow) {
|
|
77
|
-
try {
|
|
78
|
-
const iframes = currentWindow.parent.document.getElementsByTagName('iframe');
|
|
79
|
-
// eslint-disable-next-line no-restricted-syntax
|
|
80
|
-
for (const iframe of iframes) {
|
|
81
|
-
if (iframe.contentWindow === currentWindow) {
|
|
82
|
-
const channelId = iframe.getAttribute('data-octostar-iframe-channel');
|
|
83
|
-
if (channelId) {
|
|
84
|
-
console.log(`PostRobot: Setting channelId from iframe attribute ${channelId}`);
|
|
85
|
-
window.octostarChannelId = channelId;
|
|
86
|
-
return channelId;
|
|
87
|
-
}
|
|
88
|
-
}
|
|
89
|
-
}
|
|
90
|
-
return undefined;
|
|
91
|
-
}
|
|
92
|
-
catch (e) {
|
|
93
|
-
// Ignore errors, maybe cross-origin iframes
|
|
94
|
-
return undefined;
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
function traverseForChannelId(currentWindow = window, depth = 0) {
|
|
98
|
-
// Prevent infinite loops or excessive searching
|
|
99
|
-
if (depth > 25) {
|
|
100
|
-
throw new Error('PostRobot: Max depth reached. octostarChannelId not found.');
|
|
101
|
-
}
|
|
102
|
-
if (currentWindow.octostarChannelId) {
|
|
103
|
-
return currentWindow.octostarChannelId;
|
|
104
|
-
}
|
|
105
|
-
try {
|
|
106
|
-
if (currentWindow.location.search) {
|
|
107
|
-
const urlParams = new URLSearchParams(currentWindow.location.search);
|
|
108
|
-
const channelId = urlParams.get('octostarChannelId');
|
|
109
|
-
if (channelId) {
|
|
110
|
-
console.log(`PostRobot: Setting channelId from queryParams ${channelId}`);
|
|
111
|
-
window.octostarChannelId = channelId;
|
|
112
|
-
return channelId;
|
|
113
|
-
}
|
|
114
|
-
}
|
|
115
|
-
else {
|
|
116
|
-
const channelId = tryFetchingFomAttributes(currentWindow);
|
|
117
|
-
if (channelId) {
|
|
118
|
-
return channelId;
|
|
119
|
-
}
|
|
120
|
-
}
|
|
121
|
-
return traverseForChannelId(currentWindow.parent, depth + 1);
|
|
122
|
-
}
|
|
123
|
-
catch (e) {
|
|
124
|
-
console.error(e);
|
|
125
|
-
return undefined;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
window.addEventListener('message', event => {
|
|
129
|
-
var _a;
|
|
130
|
-
if (((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === 'SET_CHANNEL_ID') {
|
|
131
|
-
window.octostarChannelId = event.data.channelId;
|
|
132
|
-
console.log('PostRobot: received channelId', event.data.channelId);
|
|
133
|
-
}
|
|
134
|
-
});
|
|
135
78
|
export const createRemoteApiHandle = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
136
|
-
const
|
|
137
|
-
const
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
}
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
maxAttempts: 5,
|
|
146
|
-
retryInterval: 2000,
|
|
147
|
-
});
|
|
148
|
-
console.log(`PostRobot: Got remote api handle for ${params.name} on ${channelId}`);
|
|
149
|
-
const api = handlePostResponse(response);
|
|
150
|
-
return createObjectProxy(api, {
|
|
151
|
-
name: params.name,
|
|
152
|
-
});
|
|
153
|
-
}
|
|
154
|
-
catch (e) {
|
|
155
|
-
console.log(`PostRobot: Error while trying to create remote API handle on ${topic}`, e);
|
|
156
|
-
throw e;
|
|
157
|
-
}
|
|
79
|
+
const topWindow = getOctostarWindow();
|
|
80
|
+
const response = yield retry(() => postRobot.send(topWindow, postMessageNames.get_api, params), {
|
|
81
|
+
maxAttempts: 5,
|
|
82
|
+
retryInterval: 2000,
|
|
83
|
+
});
|
|
84
|
+
const api = handlePostResponse(response);
|
|
85
|
+
return createObjectProxy(api, {
|
|
86
|
+
name: params.name,
|
|
87
|
+
});
|
|
158
88
|
});
|
|
159
89
|
export const forwardCallsToFutureObject = (chain) => new Proxy({}, {
|
|
160
90
|
get: (target, prop) => new Proxy(() => { }, {
|
package/lib/factory.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAMnC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,
|
|
1
|
+
{"version":3,"file":"factory.js","sourceRoot":"","sources":["../src/factory.ts"],"names":[],"mappings":";;;;;;;;;AAAA,OAAO,SAAS,MAAM,YAAY,CAAC;AAMnC,OAAO,EAAE,KAAK,EAAE,MAAM,SAAS,CAAC;AAChC,OAAO,EAAE,gBAAgB,EAAE,MAAM,aAAa,CAAC;AAE/C,MAAM,SAAS,GAAG,CAAC,MAAc,EAAW,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC;AAExE,SAAS,iBAAiB,CAAC,aAAa,GAAG,MAAM,EAAE,KAAK,GAAG,CAAC;IAC1D,0CAA0C;IAC1C,IAAI,OAAsC,CAAC;IAC3C,IAAI;QACF,OAAO,GAAG,aAAa,CAAC,QAAQ,CAAC,gBAAgB,CAAC,QAAQ,CAAC,CAAC;KAC7D;IAAC,OAAO,CAAC,EAAE;QACV,+BAA+B;QAC/B,OAAO,aAAa,CAAC;KACtB;IAED,KAAK,IAAI,CAAC,GAAG,CAAC,EAAE,CAAC,GAAG,OAAO,CAAC,MAAM,EAAE,CAAC,IAAI,CAAC,EAAE;QAC1C,MAAM,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC,CAAC;QAC1B,IACE,MAAM,CAAC,YAAY,CAAC,sBAAsB,CAAC,KAAK,M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ClB,CAAC,CAAC;AACL,CAAC,CAAA,CAAC;AAEF,MAAM,CAAC,MAAM,0BAA0B,GAAG,CAAI,KAAiB,EAAK,EAAE,CACpE,IAAI,KAAK,CACP,EAAE,EACF;IACE,GAAG,EAAE,CAAC,MAAM,EAAE,IAAI,EAAE,EAAE,CACpB,IAAI,KAAK,CAAC,GAAG,EAAE,GAAE,CAAC,EAAE;QAClB,KAAK,EAAE,CAAC,EAAE,EAAE,CAAC,EAAE,IAAI,EAAE,EAAE,CAAC,KAAK,CAAC,IAAI,CAAC,CAAC,GAAQ,EAAE,EAAE,CAAC,GAAG,CAAC,IAAI,CAAC,CAAC,GAAG,IAAI,CAAC,CAAC;KACrE,CAAC;CACL,CACG,CAAC"}
|
package/lib/index.d.ts
CHANGED
package/lib/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
package/lib/index.js
CHANGED
package/lib/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,cAAc,QAAQ,CAAC;AACvB,cAAc,SAAS,CAAC;AACxB,cAAc,aAAa,CAAC;AAC5B,cAAc,SAAS,CAAC;AACxB,cAAc,eAAe,CAAC;AAC9B,cAAc,cAAc,CAAC"}
|
package/lib/permissions.d.ts
CHANGED
package/lib/permissions.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAQ,CAAC
|
|
1
|
+
{"version":3,"file":"permissions.d.ts","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AACA;;;GAGG;AACH,eAAO,MAAM,wBAAwB,sBAAsB,CAAC;AAE5D;;;GAGG;AACH,eAAO,MAAM,yBAAyB,uBAAuB,CAAC;AAE9D;;;GAGG;AACH,eAAO,MAAM,eAAe,QAAQ,CAAC"}
|
package/lib/permissions.js
CHANGED
package/lib/permissions.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAE5D;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,oBAAoB,CAAC;AAE9D;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC
|
|
1
|
+
{"version":3,"file":"permissions.js","sourceRoot":"","sources":["../src/permissions.ts"],"names":[],"mappings":"AAAA,qFAAqF;AACrF;;;GAGG;AACH,MAAM,CAAC,MAAM,wBAAwB,GAAG,mBAAmB,CAAC;AAE5D;;;GAGG;AACH,MAAM,CAAC,MAAM,yBAAyB,GAAG,oBAAoB,CAAC;AAE9D;;;GAGG;AACH,MAAM,CAAC,MAAM,eAAe,GAAG,KAAK,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octostar/platform-api",
|
|
3
|
-
"version": "0.5.
|
|
3
|
+
"version": "0.5.4",
|
|
4
4
|
"description": "Provides access to the API exposed by Octostar platform to an application run in an iframe",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"octostar",
|
|
@@ -28,7 +28,9 @@
|
|
|
28
28
|
"run:api-extractor": "api-extractor run --local --verbose"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"
|
|
31
|
+
"@types/uuid": "^9.0.2",
|
|
32
|
+
"post-robot": "^10.0.46",
|
|
33
|
+
"uuid": "^9.0.0"
|
|
32
34
|
},
|
|
33
35
|
"devDependencies": {
|
|
34
36
|
"@microsoft/api-extractor": "^7.42.3",
|
|
@@ -43,5 +45,5 @@
|
|
|
43
45
|
"publishConfig": {
|
|
44
46
|
"access": "public"
|
|
45
47
|
},
|
|
46
|
-
"gitHead": "
|
|
48
|
+
"gitHead": "9258c6a5a3ac5086dcc287c014d250438b3f1dc8"
|
|
47
49
|
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import { AIClient, ChatModel, OsAPIClient, PromptOptions } from '@octostar/platform-types';
|
|
2
|
-
export declare class AIClientImpl implements AIClient {
|
|
3
|
-
private osAPIClient;
|
|
4
|
-
private models;
|
|
5
|
-
constructor(osAPIClient: OsAPIClient);
|
|
6
|
-
getChatModels(): Promise<ChatModel[]>;
|
|
7
|
-
prompt(prompt: string, options?: PromptOptions): Promise<string>;
|
|
8
|
-
}
|
|
9
|
-
//# sourceMappingURL=AIClientImpl.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AIClientImpl.d.ts","sourceRoot":"","sources":["../../src/lib/AIClientImpl.ts"],"names":[],"mappings":"AAAA,OAAO,EACL,QAAQ,EAER,SAAS,EACT,WAAW,EACX,aAAa,EACd,MAAM,0BAA0B,CAAC;AAElC,qBAAa,YAAa,YAAW,QAAQ;IAC3C,OAAO,CAAC,WAAW,CAAc;IAEjC,OAAO,CAAC,MAAM,CAA0B;gBAE5B,WAAW,EAAE,WAAW;IAI9B,aAAa,IAAI,OAAO,CAAC,SAAS,EAAE,CAAC;IASrC,MAAM,CAAC,MAAM,EAAE,MAAM,EAAE,OAAO,CAAC,EAAE,aAAa,GAAG,OAAO,CAAC,MAAM,CAAC;CAgBvE"}
|
package/lib/lib/AIClientImpl.js
DELETED
|
@@ -1,44 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
export class AIClientImpl {
|
|
11
|
-
constructor(osAPIClient) {
|
|
12
|
-
this.osAPIClient = osAPIClient;
|
|
13
|
-
}
|
|
14
|
-
getChatModels() {
|
|
15
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
16
|
-
if (!this.models) {
|
|
17
|
-
this.models = yield this.osAPIClient.fetchData({
|
|
18
|
-
endpoint: '/api/v1/chat/models',
|
|
19
|
-
});
|
|
20
|
-
}
|
|
21
|
-
return this.models;
|
|
22
|
-
});
|
|
23
|
-
}
|
|
24
|
-
prompt(prompt, options) {
|
|
25
|
-
var _a;
|
|
26
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
27
|
-
const model = (options === null || options === void 0 ? void 0 : options.model) || ((_a = (yield this.getChatModels())[0]) === null || _a === void 0 ? void 0 : _a.model_name);
|
|
28
|
-
const chatMessage = yield this.osAPIClient.fetchData({
|
|
29
|
-
endpoint: '/api/v1/chat/',
|
|
30
|
-
method: 'POST',
|
|
31
|
-
headers: {
|
|
32
|
-
'Content-Type': 'application/json',
|
|
33
|
-
},
|
|
34
|
-
body: JSON.stringify({
|
|
35
|
-
model_name: model,
|
|
36
|
-
prompt,
|
|
37
|
-
api_key: (options === null || options === void 0 ? void 0 : options.apiKey) || '', // TODO: remove this server expects it at the moment, make it optional
|
|
38
|
-
}),
|
|
39
|
-
});
|
|
40
|
-
return chatMessage.content;
|
|
41
|
-
});
|
|
42
|
-
}
|
|
43
|
-
}
|
|
44
|
-
//# sourceMappingURL=AIClientImpl.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"AIClientImpl.js","sourceRoot":"","sources":["../../src/lib/AIClientImpl.ts"],"names":[],"mappings":";;;;;;;;;AAQA,MAAM,OAAO,YAAY;IAKvB,YAAY,WAAwB;QAClC,IAAI,CAAC,WAAW,GAAG,WAAW,CAAC;IACjC,CAAC;IAEK,aAAa;;YACjB,IAAI,CAAC,IAAI,CAAC,MAAM,EAAE;gBAChB,IAAI,CAAC,MAAM,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAc;oBAC1D,QAAQ,EAAE,qBAAqB;iBAChC,CAAC,CAAC;aACJ;YACD,OAAO,IAAI,CAAC,MAAM,CAAC;QACrB,CAAC;KAAA;IAEK,MAAM,CAAC,MAAc,EAAE,OAAuB;;;YAClD,MAAM,KAAK,GAAG,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,KAAK,MAAI,MAAA,CAAC,MAAM,IAAI,CAAC,aAAa,EAAE,CAAC,CAAC,CAAC,CAAC,0CAAE,UAAU,CAAA,CAAC;YAC5E,MAAM,WAAW,GAAG,MAAM,IAAI,CAAC,WAAW,CAAC,SAAS,CAAc;gBAChE,QAAQ,EAAE,eAAe;gBACzB,MAAM,EAAE,MAAM;gBACd,OAAO,EAAE;oBACP,cAAc,EAAE,kBAAkB;iBACnC;gBACD,IAAI,EAAE,IAAI,CAAC,SAAS,CAAC;oBACnB,UAAU,EAAE,KAAK;oBACjB,MAAM;oBACN,OAAO,EAAE,CAAA,OAAO,aAAP,OAAO,uBAAP,OAAO,CAAE,MAAM,KAAI,EAAE,EAAE,sEAAsE;iBACvG,CAAC;aACH,CAAC,CAAC;YACH,OAAO,WAAW,CAAC,OAAO,CAAC;;KAC5B;CACF"}
|
package/lib/lib/JWTProvider.d.ts
DELETED
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
export interface TokenProvider {
|
|
2
|
-
getToken(): Promise<string>;
|
|
3
|
-
}
|
|
4
|
-
export declare class JWTProvider implements TokenProvider {
|
|
5
|
-
private token;
|
|
6
|
-
private decoded;
|
|
7
|
-
private tokenProvider;
|
|
8
|
-
private expiresThreshold;
|
|
9
|
-
constructor(tokenProvider: TokenProvider, expiresThreshold?: number);
|
|
10
|
-
private fetchToken;
|
|
11
|
-
private isExpiredOrExpiringSoon;
|
|
12
|
-
getToken(): Promise<string>;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=JWTProvider.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JWTProvider.d.ts","sourceRoot":"","sources":["../../src/lib/JWTProvider.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,aAAa;IAC5B,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7B;AAED,qBAAa,WAAY,YAAW,aAAa;IAC/C,OAAO,CAAC,KAAK,CAAuB;IAEpC,OAAO,CAAC,OAAO,CAAiC;IAEhD,OAAO,CAAC,aAAa,CAAgB;IAErC,OAAO,CAAC,gBAAgB,CAAS;gBAErB,aAAa,EAAE,aAAa,EAAE,gBAAgB,SAAM;YAKlD,UAAU;IAKxB,OAAO,CAAC,uBAAuB;IAQzB,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;CAMlC"}
|
package/lib/lib/JWTProvider.js
DELETED
|
@@ -1,39 +0,0 @@
|
|
|
1
|
-
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
2
|
-
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
3
|
-
return new (P || (P = Promise))(function (resolve, reject) {
|
|
4
|
-
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
5
|
-
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
6
|
-
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
7
|
-
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
8
|
-
});
|
|
9
|
-
};
|
|
10
|
-
export class JWTProvider {
|
|
11
|
-
constructor(tokenProvider, expiresThreshold = 300) {
|
|
12
|
-
this.token = null;
|
|
13
|
-
this.decoded = null;
|
|
14
|
-
this.tokenProvider = tokenProvider;
|
|
15
|
-
this.expiresThreshold = expiresThreshold;
|
|
16
|
-
}
|
|
17
|
-
fetchToken() {
|
|
18
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
-
this.token = yield this.tokenProvider.getToken();
|
|
20
|
-
this.decoded = JSON.parse(atob(this.token.split('.')[1])); // Decode the payload
|
|
21
|
-
});
|
|
22
|
-
}
|
|
23
|
-
isExpiredOrExpiringSoon() {
|
|
24
|
-
if (!this.decoded || !this.decoded.exp) {
|
|
25
|
-
return true; // Treat as expired if there's no expiration time
|
|
26
|
-
}
|
|
27
|
-
const currentTime = Math.floor(Date.now() / 1000);
|
|
28
|
-
return this.decoded.exp < currentTime + this.expiresThreshold;
|
|
29
|
-
}
|
|
30
|
-
getToken() {
|
|
31
|
-
return __awaiter(this, void 0, void 0, function* () {
|
|
32
|
-
if (!this.token || this.isExpiredOrExpiringSoon()) {
|
|
33
|
-
yield this.fetchToken();
|
|
34
|
-
}
|
|
35
|
-
return this.token;
|
|
36
|
-
});
|
|
37
|
-
}
|
|
38
|
-
}
|
|
39
|
-
//# sourceMappingURL=JWTProvider.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"JWTProvider.js","sourceRoot":"","sources":["../../src/lib/JWTProvider.ts"],"names":[],"mappings":";;;;;;;;;AAMA,MAAM,OAAO,WAAW;IAStB,YAAY,aAA4B,EAAE,gBAAgB,GAAG,GAAG;QARxD,UAAK,GAAkB,IAAI,CAAC;QAE5B,YAAO,GAA4B,IAAI,CAAC;QAO9C,IAAI,CAAC,aAAa,GAAG,aAAa,CAAC;QACnC,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,CAAC;IAEa,UAAU;;YACtB,IAAI,CAAC,KAAK,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,QAAQ,EAAE,CAAC;YACjD,IAAI,CAAC,OAAO,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,IAAI,CAAC,KAAK,CAAC,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,CAAC,qBAAqB;QAClF,CAAC;KAAA;IAEO,uBAAuB;QAC7B,IAAI,CAAC,IAAI,CAAC,OAAO,IAAI,CAAC,IAAI,CAAC,OAAO,CAAC,GAAG,EAAE;YACtC,OAAO,IAAI,CAAC,CAAC,iDAAiD;SAC/D;QACD,MAAM,WAAW,GAAG,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,GAAG,EAAE,GAAG,IAAI,CAAC,CAAC;QAClD,OAAO,IAAI,CAAC,OAAO,CAAC,GAAG,GAAG,WAAW,GAAG,IAAI,CAAC,gBAAgB,CAAC;IAChE,CAAC;IAEK,QAAQ;;YACZ,IAAI,CAAC,IAAI,CAAC,KAAK,IAAI,IAAI,CAAC,uBAAuB,EAAE,EAAE;gBACjD,MAAM,IAAI,CAAC,UAAU,EAAE,CAAC;aACzB;YACD,OAAO,IAAI,CAAC,KAAM,CAAC;QACrB,CAAC;KAAA;CACF"}
|
package/lib/lib/Proxy.d.ts
DELETED
package/lib/lib/Proxy.d.ts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Proxy.d.ts","sourceRoot":"","sources":["../../src/lib/Proxy.ts"],"names":[],"mappings":"AACA,eAAO,MAAM,SAAS,2DAGnB,OAAO,MAAM,EAAE,GAAG,CAkBpB,CAAC"}
|
package/lib/lib/Proxy.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
/* eslint-disable no-restricted-syntax */
|
|
2
|
-
export const makeProxy = (obj, excludeKeys = []) => {
|
|
3
|
-
const proxyObj = {};
|
|
4
|
-
// Get prototype methods
|
|
5
|
-
const proto = Object.getPrototypeOf(obj);
|
|
6
|
-
if (proto) {
|
|
7
|
-
for (const key of Object.getOwnPropertyNames(proto)) {
|
|
8
|
-
if (key !== 'constructor' &&
|
|
9
|
-
typeof proto[key] === 'function' &&
|
|
10
|
-
!excludeKeys.includes(key)) {
|
|
11
|
-
proxyObj[key] = proto[key].bind(obj);
|
|
12
|
-
}
|
|
13
|
-
}
|
|
14
|
-
}
|
|
15
|
-
return proxyObj;
|
|
16
|
-
};
|
|
17
|
-
//# sourceMappingURL=Proxy.js.map
|
package/lib/lib/Proxy.js.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"Proxy.js","sourceRoot":"","sources":["../../src/lib/Proxy.ts"],"names":[],"mappings":"AAAA,yCAAyC;AACzC,MAAM,CAAC,MAAM,SAAS,GAAG,CACvB,GAAM,EACN,cAA2B,EAAE,EACR,EAAE;IACvB,MAAM,QAAQ,GAAwB,EAAE,CAAC;IAEzC,wBAAwB;IACxB,MAAM,KAAK,GAAG,MAAM,CAAC,cAAc,CAAC,GAAG,CAAC,CAAC;IACzC,IAAI,KAAK,EAAE;QACT,KAAK,MAAM,GAAG,IAAI,MAAM,CAAC,mBAAmB,CAAC,KAAK,CAAmB,EAAE;YACrE,IACE,GAAG,KAAK,aAAa;gBACrB,OAAO,KAAK,CAAC,GAAG,CAAC,KAAK,UAAU;gBAChC,CAAC,WAAW,CAAC,QAAQ,CAAC,GAAG,CAAC,EAC1B;gBACA,QAAQ,CAAC,GAAa,CAAC,GAAG,KAAK,CAAC,GAAG,CAAC,CAAC,IAAI,CAAC,GAAG,CAAC,CAAC;aAChD;SACF;KACF;IAED,OAAO,QAAQ,CAAC;AAClB,CAAC,CAAC"}
|