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
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import { ROLE } from '../utils/constants.js';
|
|
2
|
-
import { getInfo, getSession, postToken, postArchive, deleteArchiveByID } from '../apis/vonage.js';
|
|
3
|
-
|
|
4
|
-
/**
|
|
5
|
-
* Gets the Vonage project ID (not to be confused with the Epicenter project). Used to initialize the session object on the client side
|
|
6
|
-
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/vonage/info`
|
|
7
|
-
*
|
|
8
|
-
* @example
|
|
9
|
-
* import OT from '@opentok/client';
|
|
10
|
-
* import { vonageAdapter } from 'epicenter-libs';
|
|
11
|
-
* const [sessionID, projectID] = await Promise.all([
|
|
12
|
-
* vonageAdapter.createSession(),
|
|
13
|
-
* vonageAdapter.getProjectID()
|
|
14
|
-
* ]);
|
|
15
|
-
* const vonageSession = OT.initSession(projectID, sessionID);
|
|
16
|
-
*
|
|
17
|
-
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
18
|
-
* @returns promise that resolves to the Vonage project ID (otherwise known as the Vonage API key)
|
|
19
|
-
*/
|
|
20
|
-
async function getProjectID(optionals = {}) {
|
|
21
|
-
return (await getInfo(optionals)).apiKey;
|
|
22
|
-
}
|
|
23
|
-
|
|
24
|
-
/**
|
|
25
|
-
* Calls the server SDK call for creating a session. Used to create a session object on the client side.
|
|
26
|
-
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/vonage/session`
|
|
27
|
-
*
|
|
28
|
-
* @example
|
|
29
|
-
* import OT from '@opentok/client';
|
|
30
|
-
* import { vonageAdapter } from 'epicenter-libs';
|
|
31
|
-
* const [sessionID, projectID] = await Promise.all([
|
|
32
|
-
* vonageAdapter.createSession(),
|
|
33
|
-
* vonageAdapter.getProjectID()
|
|
34
|
-
* ]);
|
|
35
|
-
* const vonageSession = OT.initSession(projectID, sessionID);
|
|
36
|
-
*
|
|
37
|
-
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
38
|
-
* @returns promise that resolves to an object containing the Vonage session ID
|
|
39
|
-
*/
|
|
40
|
-
async function createSession(optionals = {}) {
|
|
41
|
-
return getSession(optionals);
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
/**
|
|
45
|
-
* Creates a Vonage session token, used to connect a session.
|
|
46
|
-
* Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/vonage/token`
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* import { vonageAdapter } from 'epicenter-libs';
|
|
50
|
-
* const token = await vonageAdapter.generateToken('2_MX40NzQ...Y1TnZ-fg');
|
|
51
|
-
* vonageSession.connect(token);
|
|
52
|
-
*
|
|
53
|
-
* @param sessionID ID of the session you're expecting to connect to using the token
|
|
54
|
-
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
55
|
-
* @returns promise that resolves to a Vonage session token
|
|
56
|
-
*/
|
|
57
|
-
async function generateToken(sessionID, optionals = {}) {
|
|
58
|
-
return (await postToken({
|
|
59
|
-
sessionId: sessionID
|
|
60
|
-
}, optionals)).token;
|
|
61
|
-
}
|
|
62
|
-
|
|
63
|
-
/**
|
|
64
|
-
* Starts a Vonage archive -- a user recording of a Vonage session
|
|
65
|
-
* Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/vonage/archive`
|
|
66
|
-
*
|
|
67
|
-
* @example
|
|
68
|
-
* import { authAdapter, vonageAdapter, SCOPE_BOUNDARY } from 'epicenter-libs';
|
|
69
|
-
* const session = authAdapter.getLocalSession();
|
|
70
|
-
* vonageAdapter.startArchive('my-archive', '2_MX40NzQ...Y1TnZ-fg', {
|
|
71
|
-
* scopeBoundary: SCOPE_BOUNDARY.GROUP,
|
|
72
|
-
* scopeKey: session.groupKey,
|
|
73
|
-
* })
|
|
74
|
-
*
|
|
75
|
-
* @param name Name of the archive; for your own purposes
|
|
76
|
-
* @param sessionID ID of the session you're creating an archive for
|
|
77
|
-
* @param scope Scope attached to the archive
|
|
78
|
-
* @param scope.scopeBoundary Scope boundary, defines the type of scope; See [scope boundary](#SCOPE_BOUNDARY) for all types
|
|
79
|
-
* @param scope.scopeKey Scope key, a unique identifier tied to the scope. E.g., if your `scopeBoundary` is `GROUP`, your `scopeKey` will be your `groupKey`; for `EPISODE`, `episodeKey`, etc.
|
|
80
|
-
* @param [scope.userKey] User key, to attach a user to the scope
|
|
81
|
-
* @param [optionals] Optional arguments; pass network call options overrides here. Special arguments specific to this method are listed below if they exist.
|
|
82
|
-
* @param [optionals.readLock] Read permission role; one of the strings defined in ROLE
|
|
83
|
-
* @param [optionals.writeLock] Write permission role; one of the strings defined in ROLE
|
|
84
|
-
* @param [optionals.resolution] Video resolution the archive should be recorded at -- string like '1920x1080'
|
|
85
|
-
* @param [optionals.ttlSeconds] Life span of the archive (how long before it is deleted); defaults to 604,800 (1 week), max of 31,536,000 (1 year)
|
|
86
|
-
* @returns promise that resolves to an object containing the archive ID and status
|
|
87
|
-
*/
|
|
88
|
-
async function startArchive(name, sessionID, scope, optionals = {}) {
|
|
89
|
-
const {
|
|
90
|
-
readLock,
|
|
91
|
-
writeLock,
|
|
92
|
-
ttlSeconds,
|
|
93
|
-
resolution,
|
|
94
|
-
...routingOptions
|
|
95
|
-
} = optionals;
|
|
96
|
-
const {
|
|
97
|
-
PARTICIPANT,
|
|
98
|
-
USER
|
|
99
|
-
} = ROLE;
|
|
100
|
-
const defaultLock = scope.userKey ? USER : PARTICIPANT;
|
|
101
|
-
return postArchive({
|
|
102
|
-
name,
|
|
103
|
-
sessionId: sessionID,
|
|
104
|
-
scope,
|
|
105
|
-
permit: {
|
|
106
|
-
readLock: readLock !== null && readLock !== void 0 ? readLock : defaultLock,
|
|
107
|
-
writeLock: writeLock !== null && writeLock !== void 0 ? writeLock : defaultLock
|
|
108
|
-
},
|
|
109
|
-
ttlSeconds,
|
|
110
|
-
resolution
|
|
111
|
-
}, routingOptions);
|
|
112
|
-
}
|
|
113
|
-
|
|
114
|
-
/**
|
|
115
|
-
* Stops a Vonage archive -- begins the serialization process for a recording
|
|
116
|
-
* Base URL: DELETE `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/vonage/archive/{ARCHIVE_ID}`
|
|
117
|
-
*
|
|
118
|
-
* @example
|
|
119
|
-
* import { vonageAdapter } from 'epicenter-libs';
|
|
120
|
-
* vonageAdapter.stopArchive('004355...ede770e39');
|
|
121
|
-
*
|
|
122
|
-
* @param archiveID ID of the archive to stop
|
|
123
|
-
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
124
|
-
* @returns promise that resolves to an object containing the archive ID and status (which should be "stopped")
|
|
125
|
-
*/
|
|
126
|
-
async function stopArchive(archiveID, optionals = {}) {
|
|
127
|
-
return deleteArchiveByID(archiveID, optionals);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export { createSession, generateToken, getProjectID, startArchive, stopArchive };
|
|
@@ -1,130 +0,0 @@
|
|
|
1
|
-
import '../utils/helpers.js';
|
|
2
|
-
import '../utils/config.js';
|
|
3
|
-
import identification from '../utils/identification.js';
|
|
4
|
-
import '../utils/error-manager.js';
|
|
5
|
-
import Router from '../utils/router.js';
|
|
6
|
-
|
|
7
|
-
/**
|
|
8
|
-
* Updates a wallet
|
|
9
|
-
* Base URL: POST `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/wallet`
|
|
10
|
-
*
|
|
11
|
-
* @example
|
|
12
|
-
* // Add a user's phone number to their wallet
|
|
13
|
-
* import { walletAdapter } from 'epicenter-libs';
|
|
14
|
-
* const scope = {
|
|
15
|
-
* userKey: '000001796733eef0842f4d6d960997018a33',
|
|
16
|
-
* scopeBoundary: SCOPE_BOUNDARY.GROUP,
|
|
17
|
-
* scopeKey: '0000017dd3bf540e5ada5b1e058f08f20461',
|
|
18
|
-
* };
|
|
19
|
-
* walletAdapter.update(scope, [{ label: 'phone', value: '555-555-5555' }]);
|
|
20
|
-
*
|
|
21
|
-
* @param scope Scope attached to the wallet; userKey is required
|
|
22
|
-
* @param scope.scopeBoundary Can be a couple things, commonly group, project, episode, or world
|
|
23
|
-
* @param scope.scopeKey Key of the resource defined by the scope boundary
|
|
24
|
-
* @param scope.userKey User key for the user creating the entry, if omitted will use the one in current session
|
|
25
|
-
* @param items List of items to update the wallet with
|
|
26
|
-
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
27
|
-
* @returns promise that resolves to the updated wallet
|
|
28
|
-
*/
|
|
29
|
-
async function update(scope, items, optionals = {}) {
|
|
30
|
-
var _scope$userKey;
|
|
31
|
-
const session = identification.session;
|
|
32
|
-
(_scope$userKey = scope.userKey) !== null && _scope$userKey !== void 0 ? _scope$userKey : scope.userKey = session === null || session === void 0 ? void 0 : session.userKey;
|
|
33
|
-
return await new Router().post('/wallet', {
|
|
34
|
-
body: {
|
|
35
|
-
items,
|
|
36
|
-
scope
|
|
37
|
-
},
|
|
38
|
-
...optionals
|
|
39
|
-
}).then(({
|
|
40
|
-
body
|
|
41
|
-
}) => body);
|
|
42
|
-
}
|
|
43
|
-
const NOT_FOUND = 404;
|
|
44
|
-
/**
|
|
45
|
-
* Gets a wallet
|
|
46
|
-
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/wallet/{SCOPE_BOUNDARY}/{SCOPE_KEY}/{USER_KEY}`
|
|
47
|
-
*
|
|
48
|
-
* @example
|
|
49
|
-
* // Get a user's wallet
|
|
50
|
-
* import { walletAdapter, SCOPE_BOUNDARY } from 'epicenter-libs';
|
|
51
|
-
* const scope = {
|
|
52
|
-
* userKey: '000001796733eef0842f4d6d960997018a33',
|
|
53
|
-
* scopeBoundary: SCOPE_BOUNDARY.GROUP,
|
|
54
|
-
* scopeKey: '0000017dd3bf540e5ada5b1e058f08f20461',
|
|
55
|
-
* };
|
|
56
|
-
* walletAdapter.get(scope);
|
|
57
|
-
*
|
|
58
|
-
* @param scope Scope attached to the wallet; userKey is required
|
|
59
|
-
* @param scope.scopeBoundary Can be a couple things, commonly group, project, episode, or world
|
|
60
|
-
* @param scope.scopeKey Key of the resource defined by the scope boundary
|
|
61
|
-
* @param scope.userKey User key for the user creating the entry, if omitted will use the one in current session
|
|
62
|
-
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
63
|
-
* @returns promise that resolves to the wallet
|
|
64
|
-
*/
|
|
65
|
-
async function get(scope, optionals = {}) {
|
|
66
|
-
const {
|
|
67
|
-
scopeBoundary,
|
|
68
|
-
scopeKey
|
|
69
|
-
} = scope;
|
|
70
|
-
let {
|
|
71
|
-
userKey
|
|
72
|
-
} = scope;
|
|
73
|
-
const session = identification.session;
|
|
74
|
-
userKey !== null && userKey !== void 0 ? userKey : userKey = session === null || session === void 0 ? void 0 : session.userKey;
|
|
75
|
-
return await new Router().get(`/wallet/${scopeBoundary}/${scopeKey}/${userKey}`, optionals).catch(error => {
|
|
76
|
-
if (error.status === NOT_FOUND) return {
|
|
77
|
-
body: undefined
|
|
78
|
-
};
|
|
79
|
-
return Promise.reject(error);
|
|
80
|
-
}).then(({
|
|
81
|
-
body
|
|
82
|
-
}) => body);
|
|
83
|
-
}
|
|
84
|
-
|
|
85
|
-
/**
|
|
86
|
-
* Get all wallets under a certain scope
|
|
87
|
-
* Base URL: GET `https://forio.com/api/v3/{ACCOUNT}/{PROJECT}/wallet/with/{SCOPE_BOUNDARY}/{SCOPE_KEY}`
|
|
88
|
-
*
|
|
89
|
-
* @example
|
|
90
|
-
* // Get all wallets under a group
|
|
91
|
-
* import { walletAdapter, SCOPE_BOUNDARY } from 'epicenter-libs';
|
|
92
|
-
* const scope = {
|
|
93
|
-
* scopeBoundary: SCOPE_BOUNDARY.GROUP,
|
|
94
|
-
* scopeKey: '0000017dd3bf540e5ada5b1e058f08f20461',
|
|
95
|
-
* };
|
|
96
|
-
* walletAdapter.withScope(scope);
|
|
97
|
-
*
|
|
98
|
-
* @param scope Scope attached to the wallets
|
|
99
|
-
* @param scope.scopeBoundary Can be a couple things, commonly group, project, episode, or world
|
|
100
|
-
* @param scope.scopeKey Key of the resource defined by the scope boundary
|
|
101
|
-
* @param [optionals] Optional arguments; pass network call options overrides here.
|
|
102
|
-
* @returns promise that resolves to a page of wallets
|
|
103
|
-
*/
|
|
104
|
-
async function withScope(scope, optionals = {}) {
|
|
105
|
-
const {
|
|
106
|
-
scopeBoundary,
|
|
107
|
-
scopeKey
|
|
108
|
-
} = scope;
|
|
109
|
-
const {
|
|
110
|
-
first = 0,
|
|
111
|
-
max,
|
|
112
|
-
...routingOptions
|
|
113
|
-
} = optionals;
|
|
114
|
-
return await new Router().withSearchParams({
|
|
115
|
-
first,
|
|
116
|
-
max
|
|
117
|
-
}).get(`/wallet/with/${scopeBoundary}/${scopeKey}`, {
|
|
118
|
-
paginated: true,
|
|
119
|
-
...routingOptions
|
|
120
|
-
}).catch(error => {
|
|
121
|
-
if (error.status === NOT_FOUND) return {
|
|
122
|
-
body: undefined
|
|
123
|
-
};
|
|
124
|
-
return Promise.reject(error);
|
|
125
|
-
}).then(({
|
|
126
|
-
body
|
|
127
|
-
}) => body);
|
|
128
|
-
}
|
|
129
|
-
|
|
130
|
-
export { get, update, withScope };
|