epicenter-libs 3.33.0 → 3.34.1
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/CHANGELOG.md +17 -0
- package/dist/browser/epicenter.js +105 -2
- package/dist/browser/epicenter.js.map +1 -1
- package/dist/cjs/epicenter.js +105 -2
- package/dist/cjs/epicenter.js.map +1 -1
- package/dist/epicenter.js +105 -2
- package/dist/epicenter.js.map +1 -1
- package/dist/epicenter.min.js +1 -1
- package/dist/epicenter.min.js.map +1 -1
- package/dist/module/epicenter.js +105 -2
- package/dist/module/epicenter.js.map +1 -1
- package/dist/types/adapters/chat.d.ts +63 -0
- package/package.json +1 -1
- package/src/adapters/chat.ts +95 -0
- package/src/utils/identification.ts +4 -0
- package/dist/test/_virtual/runtime.js +0 -3
- package/dist/test/_virtual/runtime2.js +0 -3
- package/dist/test/adapters/account.js +0 -169
- package/dist/test/adapters/admin.js +0 -53
- package/dist/test/adapters/asset.js +0 -425
- package/dist/test/adapters/authentication.js +0 -349
- package/dist/test/adapters/channel.js +0 -201
- package/dist/test/adapters/chat.js +0 -199
- package/dist/test/adapters/cometd.js +0 -514
- package/dist/test/adapters/consensus.js +0 -484
- package/dist/test/adapters/daily.js +0 -244
- package/dist/test/adapters/email.js +0 -179
- package/dist/test/adapters/episode.js +0 -175
- package/dist/test/adapters/group.js +0 -655
- package/dist/test/adapters/leaderboard.js +0 -162
- package/dist/test/adapters/matchmaker.js +0 -159
- package/dist/test/adapters/presence.js +0 -85
- package/dist/test/adapters/project.js +0 -94
- package/dist/test/adapters/recaptcha.js +0 -24
- package/dist/test/adapters/run.js +0 -1008
- package/dist/test/adapters/somebody.js +0 -154
- package/dist/test/adapters/task.js +0 -192
- package/dist/test/adapters/time.js +0 -28
- package/dist/test/adapters/user.js +0 -105
- package/dist/test/adapters/vault.js +0 -403
- package/dist/test/adapters/video.js +0 -249
- package/dist/test/adapters/vonage.js +0 -130
- package/dist/test/adapters/wallet.js +0 -130
- package/dist/test/adapters/world.js +0 -507
- package/dist/test/apis/video.js +0 -294
- package/dist/test/apis/vonage.js +0 -121
- package/dist/test/epicenter.js +0 -121
- package/dist/test/node_modules/@babel/runtime/helpers/esm/defineProperty.js +0 -12
- package/dist/test/node_modules/@babel/runtime/helpers/esm/toPrimitive.js +0 -14
- package/dist/test/node_modules/@babel/runtime/helpers/esm/toPropertyKey.js +0 -9
- package/dist/test/node_modules/@babel/runtime/helpers/esm/typeof.js +0 -11
- package/dist/test/node_modules/cometd/AckExtension.js +0 -91
- package/dist/test/node_modules/cometd/CallbackPollingTransport.js +0 -148
- package/dist/test/node_modules/cometd/Client.js +0 -2160
- package/dist/test/node_modules/cometd/Extension.js +0 -47
- package/dist/test/node_modules/cometd/LongPollingTransport.js +0 -135
- package/dist/test/node_modules/cometd/ReloadExtension.js +0 -214
- package/dist/test/node_modules/cometd/RequestTransport.js +0 -252
- package/dist/test/node_modules/cometd/Transport.js +0 -167
- package/dist/test/node_modules/cometd/TransportRegistry.js +0 -107
- package/dist/test/node_modules/cometd/WebSocketTransport.js +0 -384
- package/dist/test/node_modules/cometd/cometd.js +0 -9
- package/dist/test/node_modules/regenerator-runtime/runtime.js +0 -773
- package/dist/test/utilities.js +0 -17
- package/dist/test/utils/config.js +0 -189
- package/dist/test/utils/constants.js +0 -293
- package/dist/test/utils/cookies.js +0 -75
- package/dist/test/utils/error-manager.js +0 -57
- package/dist/test/utils/error.js +0 -12
- package/dist/test/utils/fault.js +0 -34
- package/dist/test/utils/filter-parser.js +0 -68
- package/dist/test/utils/helpers.js +0 -9
- package/dist/test/utils/identification.js +0 -161
- package/dist/test/utils/result.js +0 -20
- package/dist/test/utils/router.js +0 -551
- package/dist/test/utils/store.js +0 -79
package/dist/test/utilities.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
import fetch from 'cross-fetch';
|
|
2
|
-
import config from './utils/config.js';
|
|
3
|
-
import { prefix } from './utils/helpers.js';
|
|
4
|
-
export { parseFilterInput } from './utils/filter-parser.js';
|
|
5
|
-
|
|
6
|
-
const proxy = async (resource, options) => {
|
|
7
|
-
const {
|
|
8
|
-
accountShortName,
|
|
9
|
-
projectShortName,
|
|
10
|
-
isLocal
|
|
11
|
-
} = config;
|
|
12
|
-
let path = prefix('/', resource);
|
|
13
|
-
if (!isLocal()) path = `/proxy/${accountShortName}/${projectShortName}${path}`;
|
|
14
|
-
return fetch(path, options);
|
|
15
|
-
};
|
|
16
|
-
|
|
17
|
-
export { proxy };
|
|
@@ -1,189 +0,0 @@
|
|
|
1
|
-
import _defineProperty from '../node_modules/@babel/runtime/helpers/esm/defineProperty.js';
|
|
2
|
-
import EpicenterError from './error.js';
|
|
3
|
-
import { isBrowser, isNode } from './helpers.js';
|
|
4
|
-
|
|
5
|
-
const API_VERSION = 3;
|
|
6
|
-
class Config {
|
|
7
|
-
constructor() {
|
|
8
|
-
_defineProperty(this, "_apiVersion", API_VERSION);
|
|
9
|
-
_defineProperty(this, "_apiProtocol", '');
|
|
10
|
-
_defineProperty(this, "_apiHost", '');
|
|
11
|
-
_defineProperty(this, "_useProjectProxy", false);
|
|
12
|
-
_defineProperty(this, "_accountShortName", '');
|
|
13
|
-
_defineProperty(this, "_projectShortName", '');
|
|
14
|
-
_defineProperty(this, "authOverride", void 0);
|
|
15
|
-
if (isBrowser()) {
|
|
16
|
-
this.loadBrowser();
|
|
17
|
-
return;
|
|
18
|
-
}
|
|
19
|
-
if (isNode()) {
|
|
20
|
-
this.loadNode();
|
|
21
|
-
return;
|
|
22
|
-
}
|
|
23
|
-
throw new EpicenterError('Could not identify environment; no configuration was setup');
|
|
24
|
-
}
|
|
25
|
-
|
|
26
|
-
/**
|
|
27
|
-
* Protocol used to make network requests (whether `http://` or `https://`).
|
|
28
|
-
* It is typically set on-load based on your browser's URL. For local development,
|
|
29
|
-
* this is defaulted to `https`, and can be overwritten if desired.
|
|
30
|
-
* @memberof config
|
|
31
|
-
* @type {string}
|
|
32
|
-
* */
|
|
33
|
-
get apiProtocol() {
|
|
34
|
-
return this._apiProtocol;
|
|
35
|
-
}
|
|
36
|
-
set apiProtocol(apiProtocol) {
|
|
37
|
-
if (!apiProtocol.startsWith('http')) return;
|
|
38
|
-
if (apiProtocol.endsWith(':')) {
|
|
39
|
-
apiProtocol = apiProtocol.slice(0, -1);
|
|
40
|
-
}
|
|
41
|
-
this._apiProtocol = apiProtocol;
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Hostname used to make network requests. It is typically set on-load based on
|
|
46
|
-
* your browser's URL. For local development, this is defaulted to `forio.com`,
|
|
47
|
-
* and can be overwritten if desired.
|
|
48
|
-
* @memberof config
|
|
49
|
-
* @type {string}
|
|
50
|
-
* */
|
|
51
|
-
get apiHost() {
|
|
52
|
-
return this._apiHost;
|
|
53
|
-
}
|
|
54
|
-
set apiHost(apiHost) {
|
|
55
|
-
this._apiHost = apiHost;
|
|
56
|
-
}
|
|
57
|
-
|
|
58
|
-
/**
|
|
59
|
-
* If true, requests are routed to project proxy server.
|
|
60
|
-
* The proxy server processes requests and forwards them to the Epicenter platform as appropriate,
|
|
61
|
-
* usually with some modification. Can be used to grant heightened privileges to a request.
|
|
62
|
-
* @memberof config
|
|
63
|
-
* @type {boolean}
|
|
64
|
-
*/
|
|
65
|
-
get useProjectProxy() {
|
|
66
|
-
return this._useProjectProxy;
|
|
67
|
-
}
|
|
68
|
-
set useProjectProxy(useProjectProxy) {
|
|
69
|
-
this._useProjectProxy = useProjectProxy;
|
|
70
|
-
}
|
|
71
|
-
|
|
72
|
-
/**
|
|
73
|
-
* Version used to make network requests. This is read-only variable intended for internal use.
|
|
74
|
-
* @memberof config
|
|
75
|
-
* @type {number}
|
|
76
|
-
*/
|
|
77
|
-
get apiVersion() {
|
|
78
|
-
return this._apiVersion;
|
|
79
|
-
}
|
|
80
|
-
set apiVersion(_apiVersion) {
|
|
81
|
-
return;
|
|
82
|
-
}
|
|
83
|
-
|
|
84
|
-
/**
|
|
85
|
-
* Account name used for making network requests.
|
|
86
|
-
* This is the default value used by Epicenter API adapters when making
|
|
87
|
-
* network requests without explicitly defining an account to use.
|
|
88
|
-
* It is defined on-load based on your browser's URL, and can be
|
|
89
|
-
* overwritten for local development.
|
|
90
|
-
* @example
|
|
91
|
-
* // with browser URL: https://forio.com/app/acme-simulations/foobar-game
|
|
92
|
-
*
|
|
93
|
-
* console.log(config.accountShortName);
|
|
94
|
-
* // should log 'acme-simulations'
|
|
95
|
-
*
|
|
96
|
-
* runAdapter.get(123);
|
|
97
|
-
* // instantiates a GET call with the URL: https://forio.com/api/v3/acme-simulations/foobar-game/run/123
|
|
98
|
-
*
|
|
99
|
-
* config.accountShortName = 'globex-simuations';
|
|
100
|
-
* runAdapter.get(123);
|
|
101
|
-
* // now instantiates a GET with the URL: https://forio.com/api/v3/globex-simulations/foobar-game/run/123
|
|
102
|
-
*
|
|
103
|
-
* runAdapter.get(123, { accountShortName: 'initech-simulations' });
|
|
104
|
-
* // now instantiates a GET with the URL: https://forio.com/api/v3/initech-simulations/foobar-game/run/123
|
|
105
|
-
*
|
|
106
|
-
* @memberof config
|
|
107
|
-
* @type {string}
|
|
108
|
-
*/
|
|
109
|
-
get accountShortName() {
|
|
110
|
-
return this._accountShortName;
|
|
111
|
-
}
|
|
112
|
-
set accountShortName(accountShortName) {
|
|
113
|
-
this._accountShortName = accountShortName;
|
|
114
|
-
}
|
|
115
|
-
|
|
116
|
-
/**
|
|
117
|
-
* Project name used for making network requests.
|
|
118
|
-
* This is the default value used by Epicenter API adapters when making
|
|
119
|
-
* network requests without explicitly defining an account to use.
|
|
120
|
-
* It is defined on-load based on your browser's URL, and can be
|
|
121
|
-
* overwritten for local development.
|
|
122
|
-
* @example
|
|
123
|
-
* // with browser URL: https://forio.com/app/acme-simulations/foobar-game
|
|
124
|
-
*
|
|
125
|
-
* console.log(config.projectShortName);
|
|
126
|
-
* // should log 'foobar-game'
|
|
127
|
-
*
|
|
128
|
-
* runAdapter.get(123);
|
|
129
|
-
* // instantiates a GET call with the URL: https://forio.com/api/v3/acme-simulations/foobar-game/run/123
|
|
130
|
-
*
|
|
131
|
-
* config.projectShortName = 'barfoo-game';
|
|
132
|
-
* runAdapter.get(123);
|
|
133
|
-
* // now instantiates a GET with the URL: https://forio.com/api/v3/acme-simulations/barfoo-game/run/123
|
|
134
|
-
*
|
|
135
|
-
* runAdapter.get(123, { projectShortName: 'barbaz-game' });
|
|
136
|
-
* // now instantiates a GET with the URL: https://forio.com/api/v3/acme-simulations/barbaz-game/run/123
|
|
137
|
-
*
|
|
138
|
-
* @memberof config
|
|
139
|
-
* @type {string}
|
|
140
|
-
*/
|
|
141
|
-
get projectShortName() {
|
|
142
|
-
return this._projectShortName;
|
|
143
|
-
}
|
|
144
|
-
set projectShortName(projectShortName) {
|
|
145
|
-
this._projectShortName = projectShortName;
|
|
146
|
-
}
|
|
147
|
-
|
|
148
|
-
/**
|
|
149
|
-
* Use to determines whether or not the environment is local.
|
|
150
|
-
* @memberof config
|
|
151
|
-
* @return whether or not environment is local.
|
|
152
|
-
*/
|
|
153
|
-
isLocal() {
|
|
154
|
-
if (!isBrowser()) return false;
|
|
155
|
-
const host = window.location.host;
|
|
156
|
-
return host === '127.0.0.1' || host.indexOf('local.') === 0 || host.indexOf('ngrok') !== -1 || host.indexOf('localhost') === 0;
|
|
157
|
-
}
|
|
158
|
-
loadNode() {
|
|
159
|
-
this.apiProtocol = 'https';
|
|
160
|
-
this.apiHost = 'forio.com';
|
|
161
|
-
return;
|
|
162
|
-
}
|
|
163
|
-
loadBrowser() {
|
|
164
|
-
const isLocal = this.isLocal();
|
|
165
|
-
const {
|
|
166
|
-
protocol,
|
|
167
|
-
pathname,
|
|
168
|
-
host
|
|
169
|
-
} = window.location;
|
|
170
|
-
this.apiProtocol = isLocal ? 'https' : protocol;
|
|
171
|
-
this.apiHost = isLocal ? 'forio.com' : host;
|
|
172
|
-
const match = pathname.match(/\/app\/([\w-]+)\/([\w-]+)/);
|
|
173
|
-
if (match) {
|
|
174
|
-
const [account, project] = match.slice(1);
|
|
175
|
-
this.accountShortName = account;
|
|
176
|
-
this.projectShortName = project;
|
|
177
|
-
}
|
|
178
|
-
}
|
|
179
|
-
setContext(context) {
|
|
180
|
-
if (context.apiProtocol) this.apiProtocol = context.apiProtocol;
|
|
181
|
-
if (context.apiHost) this.apiHost = context.apiHost;
|
|
182
|
-
if (typeof context.useProjectProxy === 'boolean') this.useProjectProxy = context.useProjectProxy;
|
|
183
|
-
if (context.accountShortName) this.accountShortName = context.accountShortName;
|
|
184
|
-
if (context.projectShortName) this.projectShortName = context.projectShortName;
|
|
185
|
-
}
|
|
186
|
-
}
|
|
187
|
-
const config = new Config();
|
|
188
|
-
|
|
189
|
-
export { config as default };
|
|
@@ -1,293 +0,0 @@
|
|
|
1
|
-
let BROWSER_STORAGE_TYPE = /*#__PURE__*/function (BROWSER_STORAGE_TYPE) {
|
|
2
|
-
BROWSER_STORAGE_TYPE["COOKIE"] = "COOKIE";
|
|
3
|
-
BROWSER_STORAGE_TYPE["SESSION"] = "SESSION";
|
|
4
|
-
return BROWSER_STORAGE_TYPE;
|
|
5
|
-
}({});
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Scope boundaries are values associated with runs. They help to define the *default* user permissions used when a run is created, althought further permission configuration can be done with {@link #ROLE lock types}. Scopes also provide an index that in which a run can be queried for.
|
|
9
|
-
*
|
|
10
|
-
* Three parts -- boundary: level of hierarchy (ontology) that a piece of data belongs to. Specifically, a run, an asset, or a vault data
|
|
11
|
-
* Boundary in which a piece of data (run, asset, vault) is ID-ed to (see scopeKey).
|
|
12
|
-
*
|
|
13
|
-
* pseudonymKey, goes in tandem w/ permit (lock types) --
|
|
14
|
-
* Data lives and dies with scope, delete the scope, you lose the data and associated scopes
|
|
15
|
-
* @enum {string}
|
|
16
|
-
*/
|
|
17
|
-
let SCOPE_BOUNDARY = /*#__PURE__*/function (SCOPE_BOUNDARY) {
|
|
18
|
-
/**
|
|
19
|
-
* Runs scoped by project, users and facilitators are allowed access so long as they are a user in a group on the project.
|
|
20
|
-
* @constant
|
|
21
|
-
* @type {string}
|
|
22
|
-
*/
|
|
23
|
-
SCOPE_BOUNDARY["PROJECT"] = "PROJECT";
|
|
24
|
-
/**
|
|
25
|
-
* Runs scoped by group, users and facilitators are allowed access only if they are in the associated group
|
|
26
|
-
* Groups are scoped by projects
|
|
27
|
-
* @constant
|
|
28
|
-
* @type {string}
|
|
29
|
-
*/
|
|
30
|
-
SCOPE_BOUNDARY["GROUP"] = "GROUP";
|
|
31
|
-
/**
|
|
32
|
-
* Runs scoped by episode, not sure what this one is permission-wise
|
|
33
|
-
* Episodes are scoped by groups
|
|
34
|
-
* @constant
|
|
35
|
-
* @type {string}
|
|
36
|
-
*/
|
|
37
|
-
SCOPE_BOUNDARY["EPISODE"] = "EPISODE";
|
|
38
|
-
/**
|
|
39
|
-
* Runs scoped by world, users are only allowed access to the if they are assigned to the associated world. Facilitators need only to belong on the group that created the world
|
|
40
|
-
* Worlds can be scoped by group or episode
|
|
41
|
-
* @constant
|
|
42
|
-
* @type {string}
|
|
43
|
-
*/
|
|
44
|
-
SCOPE_BOUNDARY["WORLD"] = "WORLD";
|
|
45
|
-
return SCOPE_BOUNDARY;
|
|
46
|
-
}({});
|
|
47
|
-
|
|
48
|
-
/**
|
|
49
|
-
* Rituals are used to define the way in which the Epicenter stores a run while running actions like getting variables, saving meta data, and call model operations. Runs can exist in-memory for a certain amount of time before expiring, and requiring their revival again before use.
|
|
50
|
-
* @enum {string}
|
|
51
|
-
*/
|
|
52
|
-
let RITUAL = /*#__PURE__*/function (RITUAL) {
|
|
53
|
-
/**
|
|
54
|
-
* Allow GET action against archive, no revival of run
|
|
55
|
-
* @constant
|
|
56
|
-
* @type {string}
|
|
57
|
-
*/
|
|
58
|
-
RITUAL["NONE"] = "NONE";
|
|
59
|
-
/**
|
|
60
|
-
* Does not allow restore and will not access archived state (if down stay down)
|
|
61
|
-
* @constant
|
|
62
|
-
* @type {string}
|
|
63
|
-
*/
|
|
64
|
-
RITUAL["INTER"] = "INTER";
|
|
65
|
-
/**
|
|
66
|
-
* A run with this ritual will be pulled into memory as needed, and will stay in memory until it's lifespan (defined in your project Settings) has expired.
|
|
67
|
-
* @constant
|
|
68
|
-
* @type {string}
|
|
69
|
-
*/
|
|
70
|
-
RITUAL["REANIMATE"] = "REANIMATE";
|
|
71
|
-
/**
|
|
72
|
-
* Will always restore, and never access archived state
|
|
73
|
-
* @constant
|
|
74
|
-
* @type {string}
|
|
75
|
-
*/
|
|
76
|
-
RITUAL["REVIVE"] = "REVIVE";
|
|
77
|
-
/**
|
|
78
|
-
* A run with this ritual will be pulled into memory as needed, and removed from memory afterwards.
|
|
79
|
-
* @constant
|
|
80
|
-
* @type {string}
|
|
81
|
-
*/
|
|
82
|
-
RITUAL["EXORCISE"] = "EXORCISE";
|
|
83
|
-
/**
|
|
84
|
-
* Will always restore, and never access archived state, but will also terminate the run after issuing the command.
|
|
85
|
-
* @constant
|
|
86
|
-
* @type {string}
|
|
87
|
-
*/
|
|
88
|
-
RITUAL["RESURRECT"] = "RESURRECT";
|
|
89
|
-
return RITUAL;
|
|
90
|
-
}({});
|
|
91
|
-
|
|
92
|
-
/**
|
|
93
|
-
* Push categories are pre-defined channels types in which one might use to receive push channel updates
|
|
94
|
-
* @enum {string}
|
|
95
|
-
*/
|
|
96
|
-
let PUSH_CATEGORY = /*#__PURE__*/function (PUSH_CATEGORY) {
|
|
97
|
-
/**
|
|
98
|
-
* intended for messaging users
|
|
99
|
-
* yes pub
|
|
100
|
-
* @constant
|
|
101
|
-
* @type {string} */
|
|
102
|
-
PUSH_CATEGORY["CHAT"] = "CHAT";
|
|
103
|
-
/**
|
|
104
|
-
* Used for the {@link https://github.com/forio Consensus API}
|
|
105
|
-
* no pub
|
|
106
|
-
* @constant
|
|
107
|
-
* @type {string} */
|
|
108
|
-
PUSH_CATEGORY["CONSENSUS"] = "CONSENSUS";
|
|
109
|
-
/**
|
|
110
|
-
* intended for general non-chat, sim-level communication
|
|
111
|
-
* yes pub
|
|
112
|
-
* @constant
|
|
113
|
-
* @type {string} */
|
|
114
|
-
PUSH_CATEGORY["CONTROL"] = "CONTROL";
|
|
115
|
-
/**
|
|
116
|
-
* Used for the {@link https://github.com/forio Presence API}
|
|
117
|
-
* no pub
|
|
118
|
-
* @constant
|
|
119
|
-
* @type {string} */
|
|
120
|
-
PUSH_CATEGORY["PRESENCE"] = "PRESENCE";
|
|
121
|
-
/**
|
|
122
|
-
* intended for awaiting entering games
|
|
123
|
-
* yes pub
|
|
124
|
-
* @constant
|
|
125
|
-
* @type {string} */
|
|
126
|
-
PUSH_CATEGORY["LOBBY"] = "LOBBY";
|
|
127
|
-
/**
|
|
128
|
-
* Used for streaming data; bypasses ack extension
|
|
129
|
-
* yes pub
|
|
130
|
-
* @constant
|
|
131
|
-
* @type {string} */
|
|
132
|
-
PUSH_CATEGORY["STREAM"] = "STREAM";
|
|
133
|
-
/**
|
|
134
|
-
* Used for the {@link https://github.com/forio Run API}
|
|
135
|
-
* no pub
|
|
136
|
-
* @constant
|
|
137
|
-
* @type {string} */
|
|
138
|
-
PUSH_CATEGORY["RUN"] = "RUN";
|
|
139
|
-
/**
|
|
140
|
-
* Used for the {@link https://github.com/forio Vault API}
|
|
141
|
-
* no pub
|
|
142
|
-
* @constant
|
|
143
|
-
* @type {string}
|
|
144
|
-
*/
|
|
145
|
-
PUSH_CATEGORY["VAULT"] = "VAULT";
|
|
146
|
-
/**
|
|
147
|
-
* Used for the {@link https://github.com/forio Video API}
|
|
148
|
-
* no pub
|
|
149
|
-
* @constant
|
|
150
|
-
* @type {string}
|
|
151
|
-
*/
|
|
152
|
-
PUSH_CATEGORY["VIDEO"] = "VIDEO";
|
|
153
|
-
/**
|
|
154
|
-
* Used for the {@link https://github.com/forio World API}
|
|
155
|
-
* no pub
|
|
156
|
-
* @constant
|
|
157
|
-
* @type {string}
|
|
158
|
-
*/
|
|
159
|
-
PUSH_CATEGORY["WORLD"] = "WORLD";
|
|
160
|
-
/**
|
|
161
|
-
* Used for the {@link https://github.com/forio Leaderboard API}
|
|
162
|
-
* no pub
|
|
163
|
-
* @constant
|
|
164
|
-
* @type {string}
|
|
165
|
-
*/
|
|
166
|
-
PUSH_CATEGORY["LEADERBOARD"] = "LEADERBOARD";
|
|
167
|
-
/**
|
|
168
|
-
* For group related things; assignments, unassignments
|
|
169
|
-
* @constant
|
|
170
|
-
* @type {string}
|
|
171
|
-
*/
|
|
172
|
-
PUSH_CATEGORY["GROUP"] = "GROUP";
|
|
173
|
-
/**
|
|
174
|
-
* internal
|
|
175
|
-
* @constant
|
|
176
|
-
* @type {string} */
|
|
177
|
-
PUSH_CATEGORY["SYSTEM"] = "SYSTEM";
|
|
178
|
-
return PUSH_CATEGORY;
|
|
179
|
-
}({});
|
|
180
|
-
|
|
181
|
-
/**
|
|
182
|
-
* Roles are used to define permissions on resources in Epicenter.
|
|
183
|
-
* @enum {string}
|
|
184
|
-
*/
|
|
185
|
-
let ROLE = /*#__PURE__*/function (ROLE) {
|
|
186
|
-
/**
|
|
187
|
-
* System -- Epicenter Manager
|
|
188
|
-
* @constant
|
|
189
|
-
* @type {string}
|
|
190
|
-
*/
|
|
191
|
-
ROLE["SYSTEM"] = "SYSTEM";
|
|
192
|
-
/**
|
|
193
|
-
* System minus -- read-only system access, write for certain accounts; think Geromel
|
|
194
|
-
* @constant
|
|
195
|
-
* @type {string}
|
|
196
|
-
*/
|
|
197
|
-
ROLE["MONITOR"] = "MONITOR";
|
|
198
|
-
/**
|
|
199
|
-
* Owner -- Full control over account
|
|
200
|
-
* @constant
|
|
201
|
-
* @type {string}
|
|
202
|
-
*/
|
|
203
|
-
ROLE["OWNER"] = "OWNER";
|
|
204
|
-
/**
|
|
205
|
-
* Author -- Team Members (and node server API keys)
|
|
206
|
-
* tied to one account (personal + current account)
|
|
207
|
-
* @constant
|
|
208
|
-
* @type {string}
|
|
209
|
-
*/
|
|
210
|
-
ROLE["AUTHOR"] = "AUTHOR";
|
|
211
|
-
/**
|
|
212
|
-
* Author minus
|
|
213
|
-
* @constant
|
|
214
|
-
* @type {string}
|
|
215
|
-
*/
|
|
216
|
-
ROLE["SUPPORT"] = "SUPPORT";
|
|
217
|
-
/**
|
|
218
|
-
* Associate -- Limited access to specific account
|
|
219
|
-
* @constant
|
|
220
|
-
* @type {string}
|
|
221
|
-
*/
|
|
222
|
-
ROLE["ASSOCIATE"] = "ASSOCIATE";
|
|
223
|
-
/**
|
|
224
|
-
* Facilitators
|
|
225
|
-
* @constant
|
|
226
|
-
* @type {string}
|
|
227
|
-
*/
|
|
228
|
-
ROLE["FACILITATOR"] = "FACILITATOR";
|
|
229
|
-
/**
|
|
230
|
-
* Reviewers (weaker facilitator)
|
|
231
|
-
* Facilitator minus
|
|
232
|
-
* @constant
|
|
233
|
-
* @type {string}
|
|
234
|
-
*/
|
|
235
|
-
ROLE["REVIEWER"] = "REVIEWER";
|
|
236
|
-
/**
|
|
237
|
-
* Users -- pseudonymKey (userKey) required in scope
|
|
238
|
-
* e.g., an avatar -- GROUP scope, PARTICIPANT read, USER write, userKey pseudonymKey
|
|
239
|
-
* @constant
|
|
240
|
-
* @type {string}
|
|
241
|
-
*/
|
|
242
|
-
ROLE["USER"] = "USER";
|
|
243
|
-
/**
|
|
244
|
-
* Leader
|
|
245
|
-
* Participant plus
|
|
246
|
-
* @constant
|
|
247
|
-
* @type {string}
|
|
248
|
-
*/
|
|
249
|
-
ROLE["LEADER"] = "LEADER";
|
|
250
|
-
/**
|
|
251
|
-
* Participant
|
|
252
|
-
* @constant
|
|
253
|
-
* @type {string}
|
|
254
|
-
*/
|
|
255
|
-
ROLE["PARTICIPANT"] = "PARTICIPANT";
|
|
256
|
-
/**
|
|
257
|
-
* Anonymous
|
|
258
|
-
* @constant
|
|
259
|
-
* @type {string}
|
|
260
|
-
*/
|
|
261
|
-
ROLE["ANONYMOUS"] = "ANONYMOUS";
|
|
262
|
-
return ROLE;
|
|
263
|
-
}({});
|
|
264
|
-
|
|
265
|
-
// /**
|
|
266
|
-
// * Roles are used to define permissions on resources in Epicenter.
|
|
267
|
-
// * @enum {string}
|
|
268
|
-
// */
|
|
269
|
-
// export const ROLE = {
|
|
270
|
-
// ...INTERNAL_ROLE,
|
|
271
|
-
// ...ACCOUNT_ROLE,
|
|
272
|
-
// ...PROJECT_ROLE,
|
|
273
|
-
// ...GROUP_ROLE,
|
|
274
|
-
// };
|
|
275
|
-
|
|
276
|
-
// export type ROLE = INTERNAL_ROLE | ACCOUNT_ROLE | PROJECT_ROLE | GROUP_ROLE;
|
|
277
|
-
|
|
278
|
-
/**
|
|
279
|
-
* Generic search options for adapter methods. All adapter methods
|
|
280
|
-
* will take `filter` and `sort` as a list of strings, and join with a ";"
|
|
281
|
-
*
|
|
282
|
-
* Enhanced filter support allows:
|
|
283
|
-
* - string[] (legacy): ['name=Mike', 'count<=3'] -> 'name=Mike;count<=3'
|
|
284
|
-
* - string (raw): '(name=Mike;count<=3;[id=1;id=2])' -> passed through as-is
|
|
285
|
-
* - FilterGroup (object): { type: 'and', filters: [...] } -> parsed to boolean syntax
|
|
286
|
-
*/
|
|
287
|
-
|
|
288
|
-
/**
|
|
289
|
-
* The query parameters expected by the Epicenter APIs for
|
|
290
|
-
* any kind of open search on a resource.
|
|
291
|
-
*/
|
|
292
|
-
|
|
293
|
-
export { BROWSER_STORAGE_TYPE, PUSH_CATEGORY, RITUAL, ROLE, SCOPE_BOUNDARY };
|
|
@@ -1,75 +0,0 @@
|
|
|
1
|
-
import { escapeRegExp } from './helpers.js';
|
|
2
|
-
|
|
3
|
-
// Modified version of https://github.com/madmurphy/cookies.js
|
|
4
|
-
const getExpiration = vEnd => {
|
|
5
|
-
if (!vEnd) return '';
|
|
6
|
-
switch (vEnd.constructor) {
|
|
7
|
-
case Number:
|
|
8
|
-
return vEnd === Infinity ? '; expires=Fri, 31 Dec 9999 23:59:59 GMT' : `; max-age=${vEnd}`;
|
|
9
|
-
/*
|
|
10
|
-
Note: Despite officially defined in RFC 6265, the use of `max-age` is not compatible with any
|
|
11
|
-
version of Internet Explorer, Edge and some mobile browsers. Therefore passing a number to
|
|
12
|
-
the end parameter might not work as expected. A possible solution might be to convert the the
|
|
13
|
-
relative time to an absolute time. For instance, replacing the previous line with:
|
|
14
|
-
*/
|
|
15
|
-
/*
|
|
16
|
-
case Number: return vEnd === Infinity ? '; expires=Fri, 31 Dec 9999 23:59:59 GMT' : `; expires=${(new Date(vEnd * 1e3 + Date.now())).toUTCString()}`;
|
|
17
|
-
*/
|
|
18
|
-
case String:
|
|
19
|
-
return `; expires=${vEnd}`;
|
|
20
|
-
case Date:
|
|
21
|
-
return `; expires=${new Date(vEnd).toUTCString()}`;
|
|
22
|
-
default:
|
|
23
|
-
return '';
|
|
24
|
-
}
|
|
25
|
-
};
|
|
26
|
-
var cookies = {
|
|
27
|
-
getItem(key) {
|
|
28
|
-
if (!key) return null;
|
|
29
|
-
return decodeURIComponent(document.cookie.replace(new RegExp(`(?:(?:^|.*;)\\s*${escapeRegExp(encodeURIComponent(key))}\\s*\\=\\s*([^;]*).*$)|^.*$`), '$1')) || null;
|
|
30
|
-
},
|
|
31
|
-
setItem(key, value, options = {}) {
|
|
32
|
-
if (!key || /^(?:expires|max-age|path|domain|secure)$/i.test(key)) return false;
|
|
33
|
-
const {
|
|
34
|
-
path,
|
|
35
|
-
domain,
|
|
36
|
-
end,
|
|
37
|
-
secure,
|
|
38
|
-
samesite
|
|
39
|
-
} = options;
|
|
40
|
-
const expireStr = getExpiration(end);
|
|
41
|
-
const domainStr = domain ? `; domain=${domain}` : '';
|
|
42
|
-
const pathStr = path ? `; path=${path}` : '';
|
|
43
|
-
const secureStr = secure ? '; secure' : '';
|
|
44
|
-
const samesiteStr = samesite ? `; samesite=${samesite}` : '';
|
|
45
|
-
document.cookie = `${encodeURIComponent(key)}=${encodeURIComponent(value)}${expireStr}${domainStr}${pathStr}${secureStr}${samesiteStr}`;
|
|
46
|
-
return true;
|
|
47
|
-
},
|
|
48
|
-
removeItem(key, options = {}) {
|
|
49
|
-
if (!this.hasItem(key)) return false;
|
|
50
|
-
const {
|
|
51
|
-
path,
|
|
52
|
-
domain
|
|
53
|
-
} = options;
|
|
54
|
-
const domainStr = domain ? `; domain=${domain}` : '';
|
|
55
|
-
const pathStr = path ? `; path=${path}` : '';
|
|
56
|
-
document.cookie = `${encodeURIComponent(key)}=; expires=Thu, 01 Jan 1970 00:00:00 GMT${domainStr}${pathStr}`;
|
|
57
|
-
return true;
|
|
58
|
-
},
|
|
59
|
-
hasItem(key) {
|
|
60
|
-
if (!key || /^(?:expires|max-age|path|domain|secure)$/i.test(key)) return false;
|
|
61
|
-
return new RegExp(`(?:^|;\\s*)${escapeRegExp(encodeURIComponent(key))}\\s*\\=`).test(document.cookie);
|
|
62
|
-
},
|
|
63
|
-
clear() {
|
|
64
|
-
// TODO: potentially replace this regex with simpler implementation
|
|
65
|
-
// eslint-disable-next-line no-useless-backreference
|
|
66
|
-
const aKeys = document.cookie.replace(/((?:^|\s*;)[^=]+)(?=;|$)|^\s*|\s*(?:=[^;]*)?(?:\1|$)/g, '').split(/\s*(?:=[^;]*)?;\s*/);
|
|
67
|
-
for (let nLen = aKeys.length, nIdx = 0; nIdx < nLen; nIdx++) {
|
|
68
|
-
aKeys[nIdx] = decodeURIComponent(aKeys[nIdx]);
|
|
69
|
-
this.removeItem(aKeys[nIdx]);
|
|
70
|
-
}
|
|
71
|
-
return aKeys;
|
|
72
|
-
}
|
|
73
|
-
};
|
|
74
|
-
|
|
75
|
-
export { cookies as default };
|
|
@@ -1,57 +0,0 @@
|
|
|
1
|
-
import _defineProperty from '../node_modules/@babel/runtime/helpers/esm/defineProperty.js';
|
|
2
|
-
import Fault from './fault.js';
|
|
3
|
-
|
|
4
|
-
/* eslint-disable @typescript-eslint/no-explicit-any */
|
|
5
|
-
|
|
6
|
-
/* eslint-enable @typescript-eslint/no-explicit-any */
|
|
7
|
-
|
|
8
|
-
class ErrorManager {
|
|
9
|
-
constructor() {
|
|
10
|
-
_defineProperty(this, "_handlers", []);
|
|
11
|
-
}
|
|
12
|
-
get handlers() {
|
|
13
|
-
return this._handlers;
|
|
14
|
-
}
|
|
15
|
-
clearHandlers() {
|
|
16
|
-
this._handlers = [];
|
|
17
|
-
}
|
|
18
|
-
registerHandler(identifier, handleFn) {
|
|
19
|
-
const handler = {
|
|
20
|
-
identifier,
|
|
21
|
-
handle: handleFn,
|
|
22
|
-
unregister: () => this.unregisterHandler(identifier)
|
|
23
|
-
};
|
|
24
|
-
this.handlers.unshift(handler);
|
|
25
|
-
return handler;
|
|
26
|
-
}
|
|
27
|
-
unregisterHandler(identifier) {
|
|
28
|
-
const index = this.handlers.findIndex(handler => handler.identifier === identifier);
|
|
29
|
-
if (index > -1) this.handlers.splice(index, 1);
|
|
30
|
-
}
|
|
31
|
-
async handle(error, retryFn, handlers) {
|
|
32
|
-
handlers = handlers || this.handlers;
|
|
33
|
-
const index = handlers.findIndex(({
|
|
34
|
-
identifier
|
|
35
|
-
}) => identifier(error));
|
|
36
|
-
const handler = handlers[index];
|
|
37
|
-
if (!handler) throw error;
|
|
38
|
-
let promise;
|
|
39
|
-
try {
|
|
40
|
-
promise = await handler.handle(error, retryFn).catch(err => {
|
|
41
|
-
/* This catch call ensures that handle always returns a promise,
|
|
42
|
-
otherwise it'd be caught in the catch block below */
|
|
43
|
-
throw err;
|
|
44
|
-
});
|
|
45
|
-
} catch (e) {
|
|
46
|
-
console.error('Handler failed due to error', e);
|
|
47
|
-
const remainingHandlers = index > -1 ? [...handlers.slice(0, index), ...handlers.slice(index + 1)] : [];
|
|
48
|
-
// Try to handle the new error with the remaining handlers, otherwise keep trying to handle the original error
|
|
49
|
-
const handleableError = e instanceof Fault ? e : error;
|
|
50
|
-
promise = await this.handle(handleableError, retryFn, remainingHandlers);
|
|
51
|
-
}
|
|
52
|
-
return promise;
|
|
53
|
-
}
|
|
54
|
-
}
|
|
55
|
-
const errorManager = new ErrorManager();
|
|
56
|
-
|
|
57
|
-
export { errorManager as default };
|
package/dist/test/utils/error.js
DELETED
|
@@ -1,12 +0,0 @@
|
|
|
1
|
-
import _defineProperty from '../node_modules/@babel/runtime/helpers/esm/defineProperty.js';
|
|
2
|
-
|
|
3
|
-
/* Generic throwable error */
|
|
4
|
-
class EpicenterError extends Error {
|
|
5
|
-
constructor(message, code) {
|
|
6
|
-
super(message);
|
|
7
|
-
_defineProperty(this, "code", void 0);
|
|
8
|
-
this.code = code;
|
|
9
|
-
}
|
|
10
|
-
}
|
|
11
|
-
|
|
12
|
-
export { EpicenterError as default };
|
package/dist/test/utils/fault.js
DELETED
|
@@ -1,34 +0,0 @@
|
|
|
1
|
-
import _defineProperty from '../node_modules/@babel/runtime/helpers/esm/defineProperty.js';
|
|
2
|
-
import EpicenterError from './error.js';
|
|
3
|
-
|
|
4
|
-
/* For failed network calls */
|
|
5
|
-
class Fault extends EpicenterError {
|
|
6
|
-
constructor(body, response) {
|
|
7
|
-
var _body$information;
|
|
8
|
-
super(body.message, (_body$information = body.information) === null || _body$information === void 0 ? void 0 : _body$information.code);
|
|
9
|
-
_defineProperty(this, "status", void 0);
|
|
10
|
-
_defineProperty(this, "information", void 0);
|
|
11
|
-
_defineProperty(this, "cause", void 0);
|
|
12
|
-
const {
|
|
13
|
-
information,
|
|
14
|
-
message,
|
|
15
|
-
cause,
|
|
16
|
-
status
|
|
17
|
-
} = body;
|
|
18
|
-
this.status = status !== null && status !== void 0 ? status : response === null || response === void 0 ? void 0 : response.status;
|
|
19
|
-
this.message = message;
|
|
20
|
-
if (information) {
|
|
21
|
-
const {
|
|
22
|
-
code,
|
|
23
|
-
...rest
|
|
24
|
-
} = information;
|
|
25
|
-
this.code = code;
|
|
26
|
-
this.information = rest;
|
|
27
|
-
}
|
|
28
|
-
if (cause) {
|
|
29
|
-
this.cause = cause;
|
|
30
|
-
}
|
|
31
|
-
}
|
|
32
|
-
}
|
|
33
|
-
|
|
34
|
-
export { Fault as default };
|