@octostar/platform-api 0.3.0 → 0.5.0
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 +32 -8
- package/lib/apis.d.ts +4 -1
- package/lib/apis.d.ts.map +1 -1
- package/lib/apis.js +12 -0
- package/lib/apis.js.map +1 -1
- package/lib/components/OsSpinner.d.ts +2 -0
- package/lib/components/OsSpinner.d.ts.map +1 -1
- package/lib/components/OsSpinner.js +37 -21
- package/lib/components/OsSpinner.js.map +1 -1
- package/lib/constants.d.ts +3 -3
- package/lib/constants.d.ts.map +1 -1
- package/lib/constants.js +9 -4
- package/lib/constants.js.map +1 -1
- package/lib/factory.d.ts.map +1 -1
- package/lib/factory.js +55 -9
- package/lib/factory.js.map +1 -1
- package/lib/index.d.ts +1 -0
- package/lib/index.d.ts.map +1 -1
- package/lib/index.js +1 -0
- package/lib/index.js.map +1 -1
- package/lib/lib/JWTProvider.d.ts +12 -0
- package/lib/lib/JWTProvider.d.ts.map +1 -0
- package/lib/lib/JWTProvider.js +40 -0
- package/lib/lib/JWTProvider.js.map +1 -0
- package/lib/permissions.d.ts +1 -0
- package/lib/permissions.d.ts.map +1 -1
- package/lib/permissions.js +1 -0
- package/lib/permissions.js.map +1 -1
- package/package.json +3 -3
package/dist/platform-api.d.ts
CHANGED
|
@@ -2,7 +2,10 @@ import { Concept } from '@octostar/platform-types';
|
|
|
2
2
|
import { ContextMenuRequest } from '@octostar/platform-types';
|
|
3
3
|
import { Desktop } from '@octostar/platform-types';
|
|
4
4
|
import { Entity } from '@octostar/platform-types';
|
|
5
|
+
import { ExtrasApi } from '@octostar/platform-types';
|
|
5
6
|
import { Ontology } from '@octostar/platform-types';
|
|
7
|
+
import { RemoteAppApi } from '@octostar/platform-types';
|
|
8
|
+
import { SavedSearchAPIInterface } from '@octostar/platform-types';
|
|
6
9
|
import { TagWithRelationship } from '@octostar/platform-types';
|
|
7
10
|
import { WorkspaceItem } from '@octostar/platform-types';
|
|
8
11
|
|
|
@@ -31,11 +34,13 @@ export declare abstract class AbstractContextMenu extends HTMLElement {
|
|
|
31
34
|
*/
|
|
32
35
|
export declare const ALL_PERMISSIONS = "all";
|
|
33
36
|
|
|
37
|
+
export declare const ALL_PERMISSIONS_ARRAY: string[];
|
|
38
|
+
|
|
34
39
|
/**
|
|
35
40
|
* @beta
|
|
36
41
|
* API names.
|
|
37
42
|
*/
|
|
38
|
-
export declare const apiNames: Record<"desktop", "octostar:api-names:desktop"> & Record<"ontology", "octostar:api-names:ontology"> & Record<"context", "octostar:api-names:context">;
|
|
43
|
+
export declare const apiNames: Record<"desktop", "octostar:api-names:desktop"> & Record<"ontology", "octostar:api-names:ontology"> & Record<"context", "octostar:api-names:context"> & Record<"extras", "octostar:api-names:extras"> & Record<"remoteApp", "octostar:api-names:remoteApp"> & Record<"savedSearch", "octostar:api-names:savedSearch">;
|
|
39
44
|
|
|
40
45
|
declare type BasePostResponsePayload<D, E> = {
|
|
41
46
|
data: D;
|
|
@@ -71,7 +76,7 @@ declare type CreateMessageNamesResult<N, M> = M extends readonly [infer F, ...in
|
|
|
71
76
|
* @beta
|
|
72
77
|
* Create a set of message names with a namespace.
|
|
73
78
|
*/
|
|
74
|
-
export declare const createPrefixesConstants: <N extends string, M extends readonly [string, ...string[]]>(namespace: N, messages: M) => CreateMessageNamesResult<N, M>;
|
|
79
|
+
export declare const createPrefixesConstants: <N extends string, M extends readonly [string, ...string[]]>(namespace: N, messages: M, channelId?: string) => CreateMessageNamesResult<N, M>;
|
|
75
80
|
|
|
76
81
|
/**
|
|
77
82
|
* @beta
|
|
@@ -102,6 +107,8 @@ export declare type ErrorPostResponsePayload = BasePostResponsePayload<null, {
|
|
|
102
107
|
message: string;
|
|
103
108
|
}>;
|
|
104
109
|
|
|
110
|
+
export declare const extrasApi: () => EnsureMethodsReturnPromise<ExtrasApi>;
|
|
111
|
+
|
|
105
112
|
/**
|
|
106
113
|
* @beta
|
|
107
114
|
* Get the context API asynchronously.
|
|
@@ -120,6 +127,12 @@ export declare const getDesktopApi: () => Promise<EnsureMethodsReturnPromise<Des
|
|
|
120
127
|
*/
|
|
121
128
|
export declare const getOntologyApi: () => Promise<EnsureMethodsReturnPromise<Ontology>>;
|
|
122
129
|
|
|
130
|
+
/**
|
|
131
|
+
* @beta
|
|
132
|
+
* Message names for post messages.
|
|
133
|
+
*/
|
|
134
|
+
export declare const getPostMessageNames: (channelId: string) => Record<"get_api", "octostar:post-messages:get_api">;
|
|
135
|
+
|
|
123
136
|
/**
|
|
124
137
|
* @beta
|
|
125
138
|
* Type representing a message value.
|
|
@@ -128,6 +141,17 @@ export declare type GetRemoteApiParams = {
|
|
|
128
141
|
name: string;
|
|
129
142
|
};
|
|
130
143
|
|
|
144
|
+
export declare class JWTProvider {
|
|
145
|
+
private token;
|
|
146
|
+
private decoded;
|
|
147
|
+
private desktop;
|
|
148
|
+
private expiresThreshold;
|
|
149
|
+
constructor(desktop: Desktop, expiresThreshold?: number);
|
|
150
|
+
private fetchToken;
|
|
151
|
+
private isExpiredOrExpiringSoon;
|
|
152
|
+
getToken(): Promise<string>;
|
|
153
|
+
}
|
|
154
|
+
|
|
131
155
|
declare type MessageValue<N, M> = `${N & string}:${M & string}`;
|
|
132
156
|
|
|
133
157
|
/**
|
|
@@ -202,6 +226,8 @@ export declare class OsSpinner extends HTMLElement {
|
|
|
202
226
|
constructor();
|
|
203
227
|
static get observedAttributes(): string[];
|
|
204
228
|
attributeChangedCallback(name: string, oldValue: any, newValue: any): void;
|
|
229
|
+
set imageSrc(value: string);
|
|
230
|
+
get imageSrc(): string;
|
|
205
231
|
render(): void;
|
|
206
232
|
}
|
|
207
233
|
|
|
@@ -256,12 +282,6 @@ export declare class OsTagsContextMenu extends AbstractContextMenu {
|
|
|
256
282
|
private update;
|
|
257
283
|
}
|
|
258
284
|
|
|
259
|
-
/**
|
|
260
|
-
* @beta
|
|
261
|
-
* Message names for post messages.
|
|
262
|
-
*/
|
|
263
|
-
export declare const postMessageNames: Record<"get_api", "octostar:post-messages:get_api">;
|
|
264
|
-
|
|
265
285
|
/**
|
|
266
286
|
* @beta
|
|
267
287
|
* Type representing a POST request.
|
|
@@ -301,6 +321,8 @@ export declare type RemoteApiError = Error & {
|
|
|
301
321
|
originalError: Error;
|
|
302
322
|
};
|
|
303
323
|
|
|
324
|
+
export declare const remoteAppApi: () => EnsureMethodsReturnPromise<RemoteAppApi>;
|
|
325
|
+
|
|
304
326
|
/**
|
|
305
327
|
* @beta
|
|
306
328
|
* Retry a function until it succeeds or the maximum number of attempts is reached.
|
|
@@ -316,6 +338,8 @@ declare type RetryOptions = {
|
|
|
316
338
|
retryInterval?: number;
|
|
317
339
|
};
|
|
318
340
|
|
|
341
|
+
export declare const savedSearchApi: () => EnsureMethodsReturnPromise<SavedSearchAPIInterface>;
|
|
342
|
+
|
|
319
343
|
/**
|
|
320
344
|
* @beta
|
|
321
345
|
* Type representing a POST response payload with a success.
|
package/lib/apis.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { Desktop, Ontology } from '@octostar/platform-types';
|
|
1
|
+
import { Desktop, Ontology, ExtrasApi, RemoteAppApi, SavedSearchAPIInterface } from '@octostar/platform-types';
|
|
2
2
|
import { ContextApi, EnsureMethodsReturnPromise } from './types';
|
|
3
3
|
/**
|
|
4
4
|
* @beta
|
|
@@ -6,6 +6,9 @@ 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>;
|
|
9
12
|
/**
|
|
10
13
|
* @beta
|
|
11
14
|
* 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,EACL,OAAO,EACP,QAAQ,EACR,SAAS,EACT,YAAY,EACZ,uBAAuB,EACxB,MAAM,0BAA0B,CAAC;AAGlC,OAAO,EAAE,UAAU,EAAE,0BAA0B,EAAE,MAAM,SAAS,CAAC;AAsCjE;;;;GAIG;AACH,eAAO,MAAM,UAAU,2CACwC,CAAC;AAEhE,eAAO,MAAM,SAAS,6CACwC,CAAC;AAE/D,eAAO,MAAM,YAAY,gDACwC,CAAC;AAElE,eAAO,MAAM,cAAc,2DACwC,CAAC;AAEpE;;;;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,6 +23,15 @@ 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,
|
|
26
35
|
}));
|
|
27
36
|
/**
|
|
28
37
|
* @beta
|
|
@@ -30,6 +39,9 @@ createRemoteApiHandle({
|
|
|
30
39
|
* For asynchronous access, use {@link getDesktopApi}.
|
|
31
40
|
*/
|
|
32
41
|
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'));
|
|
33
45
|
/**
|
|
34
46
|
* @beta
|
|
35
47
|
* 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":";;;;;;;;;AAOA,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;IAClE,KAAK,EAAE,KAAK;CACb,CAAC;KACC,eAAe,CAAC,SAAS,EAAE,GAAG,EAAE,CAC/B,qBAAqB,CAAsC;IACzD,IAAI,EAAE,QAAQ,CAAC,OAAO;CACvB,CAAC,CACH;KACA,eAAe,CAAC,UAAU,EAAE,GAAG,EAAE,CAChC,qBAAqB,CAAuC;IAC1D,IAAI,EAAE,QAAQ,CAAC,QAAQ;CACxB,CAAC,CACH;KACA,eAAe,CAAC,SAAS,EAAE,GAAG,EAAE;AAC/B,uCAAuC;AACvC,qBAAqB,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AAS,EAAE,kDACtC,OAAA,WAAW,CAAC,UAAU,CAAY,SAAS,CAAC,CAAA,GAAA,CAAC;AAE/C;;;GAGG;AACH,MAAM,CAAC,MAAM,cAAc,GAAG,GAAS,EAAE,kDACvC,OAAA,WAAW,CAAC,UAAU,CAAa,UAAU,CAAC,CAAA,GAAA,CAAC;AAEjD;;;GAGG;AACH,MAAM,CAAC,MAAM,aAAa,GAAG,GAAS,EAAE,kDACtC,OAAA,WAAW,CAAC,UAAU,CAAY,SAAS,CAAC,CAAA,GAAA,CAAC"}
|
|
@@ -9,6 +9,8 @@ export declare class OsSpinner extends HTMLElement {
|
|
|
9
9
|
constructor();
|
|
10
10
|
static get observedAttributes(): string[];
|
|
11
11
|
attributeChangedCallback(name: string, oldValue: any, newValue: any): void;
|
|
12
|
+
set imageSrc(value: string);
|
|
13
|
+
get imageSrc(): string;
|
|
12
14
|
render(): void;
|
|
13
15
|
}
|
|
14
16
|
//# sourceMappingURL=OsSpinner.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OsSpinner.d.ts","sourceRoot":"","sources":["../../src/components/OsSpinner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,SAAU,SAAQ,WAAW;IACxC,IAAI,EAAE,UAAU,CAAC;IAEjB,QAAQ,SAAc;IAEtB,KAAK,SAAuC;;
|
|
1
|
+
{"version":3,"file":"OsSpinner.d.ts","sourceRoot":"","sources":["../../src/components/OsSpinner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,qBAAa,SAAU,SAAQ,WAAW;IACxC,IAAI,EAAE,UAAU,CAAC;IAEjB,QAAQ,SAAc;IAEtB,KAAK,SAAuC;;IAe5C,MAAM,KAAK,kBAAkB,aAE5B;IAED,wBAAwB,CAAC,IAAI,EAAE,MAAM,EAAE,QAAQ,EAAE,GAAG,EAAE,QAAQ,EAAE,GAAG;IAanE,IAAI,QAAQ,CAAC,KAAK,EAAE,MAAM,EAIzB;IAED,IAAI,QAAQ,IANQ,MAAM,CAQzB;IAED,MAAM;CAsCP"}
|
|
@@ -6,10 +6,12 @@ export class OsSpinner extends HTMLElement {
|
|
|
6
6
|
constructor() {
|
|
7
7
|
super();
|
|
8
8
|
this.position = 'floating';
|
|
9
|
-
this.image = '/static/assets/images/loading.
|
|
9
|
+
this.image = '/static/assets/images/loading.svg';
|
|
10
10
|
this.root = this.attachShadow({ mode: 'open' });
|
|
11
|
-
|
|
12
|
-
|
|
11
|
+
const attrImage = this.getAttribute('image');
|
|
12
|
+
if (attrImage) {
|
|
13
|
+
this.image = attrImage;
|
|
14
|
+
}
|
|
13
15
|
this.render();
|
|
14
16
|
}
|
|
15
17
|
static get observedAttributes() {
|
|
@@ -17,43 +19,57 @@ export class OsSpinner extends HTMLElement {
|
|
|
17
19
|
}
|
|
18
20
|
attributeChangedCallback(name, oldValue, newValue) {
|
|
19
21
|
if (oldValue !== newValue) {
|
|
20
|
-
|
|
22
|
+
if (name === 'position') {
|
|
23
|
+
this.position = newValue || 'floating';
|
|
24
|
+
}
|
|
25
|
+
if (name === 'image') {
|
|
26
|
+
this.image = newValue || this.image;
|
|
27
|
+
}
|
|
21
28
|
this.render();
|
|
22
29
|
}
|
|
23
30
|
}
|
|
31
|
+
set imageSrc(value) {
|
|
32
|
+
this.image = value || this.image;
|
|
33
|
+
this.setAttribute('image', this.image);
|
|
34
|
+
this.render();
|
|
35
|
+
}
|
|
36
|
+
get imageSrc() {
|
|
37
|
+
return this.image;
|
|
38
|
+
}
|
|
24
39
|
render() {
|
|
25
40
|
this.root.innerHTML = `
|
|
26
41
|
<style>
|
|
27
42
|
.loading {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
43
|
+
z-index: 99;
|
|
44
|
+
width: 50px;
|
|
45
|
+
height: unset;
|
|
46
|
+
position: relative;
|
|
47
|
+
margin: 10px;
|
|
33
48
|
}
|
|
34
49
|
.inline {
|
|
35
|
-
|
|
36
|
-
|
|
50
|
+
margin: 0px;
|
|
51
|
+
width: 30px;
|
|
37
52
|
}
|
|
38
53
|
.inline-centered {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
54
|
+
margin: 0 auto;
|
|
55
|
+
width: 30px;
|
|
56
|
+
display: block;
|
|
42
57
|
}
|
|
43
58
|
.floating {
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
59
|
+
padding: 0;
|
|
60
|
+
margin: 0;
|
|
61
|
+
position: absolute;
|
|
62
|
+
left: 50%;
|
|
63
|
+
top: 50%;
|
|
64
|
+
transform: translate(-50%, -50%);
|
|
50
65
|
}
|
|
51
66
|
</style>
|
|
52
67
|
`;
|
|
53
68
|
const img = document.createElement('img');
|
|
54
69
|
img.src = this.image;
|
|
55
|
-
img.className =
|
|
70
|
+
img.className = `loading ${this.position}`;
|
|
56
71
|
img.alt = 'loading...';
|
|
72
|
+
this.root.innerHTML = '';
|
|
57
73
|
this.root.appendChild(img);
|
|
58
74
|
}
|
|
59
75
|
}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"OsSpinner.js","sourceRoot":"","sources":["../../src/components/OsSpinner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,WAAW;IAOxC;QACE,KAAK,EAAE,CAAC;QALV,aAAQ,GAAG,UAAU,CAAC;QAEtB,UAAK,GAAG,mCAAmC,CAAC;QAK1C,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,YAAY,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,CAAC,CAAC;QAEhD,
|
|
1
|
+
{"version":3,"file":"OsSpinner.js","sourceRoot":"","sources":["../../src/components/OsSpinner.ts"],"names":[],"mappings":"AAAA;;;GAGG;AACH,MAAM,OAAO,SAAU,SAAQ,WAAW;IAOxC;QACE,KAAK,EAAE,CAAC;QALV,aAAQ,GAAG,UAAU,CAAC;QAEtB,UAAK,GAA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,CAAC;QACrB,GAAG,CAAC,SAAS,GAAG,WAAW,IAAI,CAAC,QAAQ,EAAE,CAAC;QAC3C,GAAG,CAAC,GAAG,GAAG,YAAY,CAAC;QAEvB,IAAI,CAAC,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;QACzB,IAAI,CAAC,IAAI,CAAC,WAAW,CAAC,GAAG,CAAC,CAAC;IAC7B,CAAC;CACF;AAED,IAAI,CAAC,cAAc,CAAC,GAAG,CAAC,YAAY,CAAC,EAAE;IACrC,cAAc,CAAC,MAAM,CAAC,YAAY,EAAE,SAAS,CAAC,CAAC;CAChD"}
|
package/lib/constants.d.ts
CHANGED
|
@@ -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) => CreateMessageNamesResult<N, M>;
|
|
7
|
+
export declare const createPrefixesConstants: <N extends string, M extends readonly [string, ...string[]]>(namespace: N, messages: M, channelId?: string) => 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 getPostMessageNames: (channelId: string) => 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"> & Record<"extras", "octostar:api-names:extras"> & Record<"remoteApp", "octostar:api-names:remoteApp"> & Record<"savedSearch", "octostar:api-names:savedSearch">;
|
|
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,sGAMtB,MAAM,mCAWnB,CAAC;AAEF;;;GAGG;AACH,eAAO,MAAM,mBAAmB,cAAe,MAAM,wDAKlD,CAAC;AAEJ;;;GAGG;AACH,eAAO,MAAM,QAAQ,uTAWpB,CAAC"}
|
package/lib/constants.js
CHANGED
|
@@ -2,10 +2,12 @@
|
|
|
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, channelId) => {
|
|
6
6
|
const result = {};
|
|
7
7
|
messages.forEach(message => {
|
|
8
|
-
result[message] =
|
|
8
|
+
result[message] = channelId
|
|
9
|
+
? `${namespace}:${channelId}:${message}`
|
|
10
|
+
: `${namespace}:${message}`;
|
|
9
11
|
});
|
|
10
12
|
return result;
|
|
11
13
|
};
|
|
@@ -13,7 +15,7 @@ export const createPrefixesConstants = (namespace, messages) => {
|
|
|
13
15
|
* @beta
|
|
14
16
|
* Message names for post messages.
|
|
15
17
|
*/
|
|
16
|
-
export const
|
|
18
|
+
export const getPostMessageNames = (channelId) => createPrefixesConstants('octostar:post-messages', ['get_api'], channelId);
|
|
17
19
|
/**
|
|
18
20
|
* @beta
|
|
19
21
|
* API names.
|
|
@@ -22,7 +24,10 @@ export const apiNames = createPrefixesConstants('octostar:api-names', [
|
|
|
22
24
|
'desktop',
|
|
23
25
|
'ontology',
|
|
24
26
|
'context',
|
|
25
|
-
|
|
27
|
+
'extras',
|
|
28
|
+
'remoteApp',
|
|
29
|
+
'savedSearch',
|
|
30
|
+
], undefined);
|
|
26
31
|
// test
|
|
27
32
|
// const v = messages.get_api;
|
|
28
33
|
//# 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,EACX,SAAkB,EACc,EAAE;IAClC,MAAM,MAAM,GAA+C,EAAE,CAAC;IAE9D,QAAQ,CAAC,OAAO,CAAC,OAAO,CAAC,EAAE;QACzB,MAAM,CAAC,OAAO,CAAC,GAAG,SAAS;YACzB,CAAC,CAAC,GAAG,SAAS,IAAI,SAAS,IAAI,OAAO,EAAE;YACxC,CAAC,CAAC,GAAG,SAAS,IAAI,OAAO,EAAE,CAAC;IAChC,CAAC,CAAC,CAAC;IAEH,OAAO,MAAwC,CAAC;AAClD,CAAC,CAAC;AAEF;;;GAGG;AACH,MAAM,CAAC,MAAM,mBAAmB,GAAG,CAAC,SAAiB,EAAE,EAAE,CACvD,uBAAuB,CACrB,wBAAwB,EACxB,CAAC,SAAS,CAAU,EACpB,SAAS,CACV,CAAC;AAEJ;;;GAGG;AACH,MAAM,CAAC,MAAM,QAAQ,GAAG,uBAAuB,CAC7C,oBAAoB,EACpB;IACE,SAAS;IACT,UAAU;IACV,SAAS;IACT,QAAQ;IACR,WAAW;IACX,aAAa;CACL,EACV,SAAS,CACV,CAAC;AAEF,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;AA8HjB,eAAO,MAAM,qBAAqB,6BACxB,kBAAkB,eAmC3B,CAAC;AAEF,eAAO,MAAM,0BAA0B,6BAS/B,CAAC"}
|
package/lib/factory.js
CHANGED
|
@@ -9,7 +9,7 @@ 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 { getPostMessageNames } from './constants';
|
|
13
13
|
const hasParent = (window) => window.parent !== window;
|
|
14
14
|
function getOctostarWindow(currentWindow = window, depth = 0) {
|
|
15
15
|
// Check all iframes in the current window
|
|
@@ -23,7 +23,9 @@ function getOctostarWindow(currentWindow = window, depth = 0) {
|
|
|
23
23
|
}
|
|
24
24
|
for (let i = 0; i < iframes.length; i += 1) {
|
|
25
25
|
const iframe = iframes[i];
|
|
26
|
-
if (iframe.getAttribute('data-octostar-iframe') === 'true'
|
|
26
|
+
if (iframe.getAttribute('data-octostar-iframe') === 'true' &&
|
|
27
|
+
new URL(iframe.baseURI).pathname.startsWith('/octostar/') // TODO: this is fragileremove this once we have a better way to check if the iframe is from Octostar
|
|
28
|
+
) {
|
|
27
29
|
return currentWindow;
|
|
28
30
|
}
|
|
29
31
|
}
|
|
@@ -38,7 +40,6 @@ function getOctostarWindow(currentWindow = window, depth = 0) {
|
|
|
38
40
|
throw new Error('Max depth reached. Octostar window not found.');
|
|
39
41
|
}
|
|
40
42
|
// If not found, continue searching in the parent window
|
|
41
|
-
// @ts-ignore
|
|
42
43
|
return getOctostarWindow(currentWindow.parent, depth + 1);
|
|
43
44
|
}
|
|
44
45
|
const handlePostResponse = (response) => {
|
|
@@ -73,16 +74,61 @@ const createObjectProxy = (value, options) => new Proxy(value, {
|
|
|
73
74
|
return target[prop];
|
|
74
75
|
},
|
|
75
76
|
});
|
|
77
|
+
function traverseForChannelId(currentWindow = window, depth = 0) {
|
|
78
|
+
// Prevent infinite loops or excessive searching
|
|
79
|
+
if (depth > 25) {
|
|
80
|
+
throw new Error('PostRobot: Max depth reached. octostarChannelId not found.');
|
|
81
|
+
}
|
|
82
|
+
if (currentWindow.octostarChannelId) {
|
|
83
|
+
return currentWindow.octostarChannelId;
|
|
84
|
+
}
|
|
85
|
+
try {
|
|
86
|
+
if (currentWindow.location.search) {
|
|
87
|
+
const urlParams = new URLSearchParams(currentWindow.location.search);
|
|
88
|
+
const channelId = urlParams.get('octostarChannelId');
|
|
89
|
+
if (channelId) {
|
|
90
|
+
console.log(`PostRobot: Setting channelId from queryParams ${channelId}`);
|
|
91
|
+
window.octostarChannelId = channelId;
|
|
92
|
+
return channelId;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return traverseForChannelId(currentWindow.parent, depth + 1);
|
|
96
|
+
}
|
|
97
|
+
catch (e) {
|
|
98
|
+
console.error(e);
|
|
99
|
+
return undefined;
|
|
100
|
+
}
|
|
101
|
+
}
|
|
102
|
+
window.addEventListener('message', event => {
|
|
103
|
+
var _a;
|
|
104
|
+
if (((_a = event.data) === null || _a === void 0 ? void 0 : _a.type) === 'SET_CHANNEL_ID') {
|
|
105
|
+
window.octostarChannelId = event.data.channelId;
|
|
106
|
+
console.log('PostRobot: received channelId', event.data.channelId);
|
|
107
|
+
}
|
|
108
|
+
});
|
|
76
109
|
export const createRemoteApiHandle = (params) => __awaiter(void 0, void 0, void 0, function* () {
|
|
77
|
-
const
|
|
78
|
-
const
|
|
110
|
+
const octostarWindow = getOctostarWindow();
|
|
111
|
+
const channelId = traverseForChannelId();
|
|
112
|
+
if (!channelId) {
|
|
113
|
+
console.error('PostRobot: No channelId found', channelId);
|
|
114
|
+
}
|
|
115
|
+
console.log(`PostRobot: Trying to get handle ${channelId}`);
|
|
116
|
+
const topic = getPostMessageNames(channelId).get_api;
|
|
117
|
+
const response = yield retry(() => postRobot.send(octostarWindow, topic, params), {
|
|
79
118
|
maxAttempts: 5,
|
|
80
119
|
retryInterval: 2000,
|
|
81
120
|
});
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
121
|
+
console.log(`PostRobot: Got remote api handle for ${params.name} on ${channelId}`);
|
|
122
|
+
try {
|
|
123
|
+
const api = handlePostResponse(response);
|
|
124
|
+
return createObjectProxy(api, {
|
|
125
|
+
name: params.name,
|
|
126
|
+
});
|
|
127
|
+
}
|
|
128
|
+
catch (e) {
|
|
129
|
+
console.log(`PostRobot: Error while trying to create remote API handle on ${topic}`, e);
|
|
130
|
+
throw e;
|
|
131
|
+
}
|
|
86
132
|
});
|
|
87
133
|
export const forwardCallsToFutureObject = (chain) => new Proxy({}, {
|
|
88
134
|
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,mBAAmB,EAAE,MAAM,aAAa,CAAC;AAElD,MAAM,SAAS,GAAG,CAAC,MAAc,EAAW,EAAE,CAAC,MAAM,CAAC,MAAM,KAAK,MAAM,CAAC;AAExE,SAAS,iBAAiB,CAAC,gBAAwB,MAAM,EAAE,KAAK,GAAG,CAAC;IAClE,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,sB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,CAAC,EACnD;QACE,WAAW,EAAE,CAAC;QACd,aAAa,EAAE,IAAI;KACpB,CACF,CAAC;IACF,OAAO,CAAC,GAAG,CACT,wCAAwC,MAAM,CAAC,IAAI,OAAO,SAAS,EAAE,CACtE,CAAC;IAEF,IAAI;QACF,MAAM,GAAG,GAAG,kBAAkB,CAAI,QAAsC,CAAC,CAAC;QAE1E,OAAO,iBAAiB,CAAI,GAAG,EAAE;YAC/B,IAAI,EAAE,MAAM,CAAC,IAAI;SAClB,CAAC,CAAC;KACJ;IAAC,OAAO,CAAC,EAAE;QACV,OAAO,CAAC,GAAG,CACT,gEAAgE,KAAK,EAAE,EACvE,CAAC,CACF,CAAC;QACF,MAAM,CAAC,CAAC;KACT;AACH,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;AAC7B,cAAc,mBAAmB,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;AAC7B,cAAc,mBAAmB,CAAC"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { Desktop } from '@octostar/platform-types';
|
|
2
|
+
export declare class JWTProvider {
|
|
3
|
+
private token;
|
|
4
|
+
private decoded;
|
|
5
|
+
private desktop;
|
|
6
|
+
private expiresThreshold;
|
|
7
|
+
constructor(desktop: Desktop, expiresThreshold?: number);
|
|
8
|
+
private fetchToken;
|
|
9
|
+
private isExpiredOrExpiringSoon;
|
|
10
|
+
getToken(): Promise<string>;
|
|
11
|
+
}
|
|
12
|
+
//# sourceMappingURL=JWTProvider.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JWTProvider.d.ts","sourceRoot":"","sources":["../../src/lib/JWTProvider.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,MAAM,0BAA0B,CAAC;AAEnD,qBAAa,WAAW;IACtB,OAAO,CAAC,KAAK,CAAuB;IAEpC,OAAO,CAAC,OAAO,CAAiC;IAEhD,OAAO,CAAC,OAAO,CAAU;IAEzB,OAAO,CAAC,gBAAgB,CAAS;gBAErB,OAAO,EAAE,OAAO,EAAE,gBAAgB,SAAM;YAKtC,UAAU;IAMxB,OAAO,CAAC,uBAAuB;IAQzB,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC;CAMlC"}
|
|
@@ -0,0 +1,40 @@
|
|
|
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(desktop, expiresThreshold = 300) {
|
|
12
|
+
this.token = null;
|
|
13
|
+
this.decoded = null;
|
|
14
|
+
this.desktop = desktop;
|
|
15
|
+
this.expiresThreshold = expiresThreshold;
|
|
16
|
+
}
|
|
17
|
+
fetchToken() {
|
|
18
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
19
|
+
const whoami = yield this.desktop.whoami();
|
|
20
|
+
this.token = whoami.os_jwt;
|
|
21
|
+
this.decoded = JSON.parse(atob(this.token.split('.')[1])); // Decode the payload
|
|
22
|
+
});
|
|
23
|
+
}
|
|
24
|
+
isExpiredOrExpiringSoon() {
|
|
25
|
+
if (!this.decoded || !this.decoded.exp) {
|
|
26
|
+
return true; // Treat as expired if there's no expiration time
|
|
27
|
+
}
|
|
28
|
+
const currentTime = Math.floor(Date.now() / 1000);
|
|
29
|
+
return this.decoded.exp < currentTime + this.expiresThreshold;
|
|
30
|
+
}
|
|
31
|
+
getToken() {
|
|
32
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
33
|
+
if (!this.token || this.isExpiredOrExpiringSoon()) {
|
|
34
|
+
yield this.fetchToken();
|
|
35
|
+
}
|
|
36
|
+
return this.token;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
}
|
|
40
|
+
//# sourceMappingURL=JWTProvider.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"JWTProvider.js","sourceRoot":"","sources":["../../src/lib/JWTProvider.ts"],"names":[],"mappings":";;;;;;;;;AAEA,MAAM,OAAO,WAAW;IAStB,YAAY,OAAgB,EAAE,gBAAgB,GAAG,GAAG;QAR5C,UAAK,GAAkB,IAAI,CAAC;QAE5B,YAAO,GAA4B,IAAI,CAAC;QAO9C,IAAI,CAAC,OAAO,GAAG,OAAO,CAAC;QACvB,IAAI,CAAC,gBAAgB,GAAG,gBAAgB,CAAC;IAC3C,CAAC;IAEa,UAAU;;YACtB,MAAM,MAAM,GAAG,MAAM,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YAC3C,IAAI,CAAC,KAAK,GAAG,MAAM,CAAC,MAAM,CAAC;YAC3B,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/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;AAErC,eAAO,MAAM,qBAAqB,UAAoB,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;AAErC,MAAM,CAAC,MAAM,qBAAqB,GAAG,CAAC,eAAe,CAAC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@octostar/platform-api",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.5.0",
|
|
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",
|
|
@@ -38,10 +38,10 @@
|
|
|
38
38
|
"rimraf": "^5.0.5"
|
|
39
39
|
},
|
|
40
40
|
"peerDependencies": {
|
|
41
|
-
"@octostar/platform-types": "^0.
|
|
41
|
+
"@octostar/platform-types": "^0.4.0"
|
|
42
42
|
},
|
|
43
43
|
"publishConfig": {
|
|
44
44
|
"access": "public"
|
|
45
45
|
},
|
|
46
|
-
"gitHead": "
|
|
46
|
+
"gitHead": "63aeec6895a1470e0066fa0266a3ca76f060fb5c"
|
|
47
47
|
}
|