@webex/webex-server 2.29.3 → 2.52.7
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/.eslintrc.js +6 -0
- package/babel.config.js +3 -0
- package/dist/config.js.map +1 -1
- package/dist/index.js +4 -18
- package/dist/index.js.map +1 -1
- package/dist/memory-store.js +12 -33
- package/dist/memory-store.js.map +1 -1
- package/dist/session.js +5 -35
- package/dist/session.js.map +1 -1
- package/dist/webex.js +0 -22
- package/dist/webex.js.map +1 -1
- package/jest.config.js +3 -0
- package/package.json +51 -31
- package/process +1 -0
- package/src/index.js +30 -19
- package/src/memory-store.js +44 -42
- package/src/session.js +71 -79
- package/test/integration/spec/session.js +148 -147
package/dist/webex.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"names":["WebexCore"],"sources":["webex.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport '@babel/polyfill';\n\nimport '@webex/plugin-authorization-node';\nimport '@webex/internal-plugin-avatar';\nimport '@webex/internal-plugin-board';\nimport '@webex/internal-plugin-calendar';\nimport '@webex/internal-plugin-conversation';\nimport '@webex/internal-plugin-encryption';\nimport '@webex/internal-plugin-feature';\nimport '@webex/internal-plugin-flag';\nimport '@webex/plugin-logger';\nimport '@webex/internal-plugin-mercury';\nimport '@webex/internal-plugin-metrics';\nimport '@webex/internal-plugin-search';\nimport '@webex/internal-plugin-support';\nimport '@webex/internal-plugin-team';\nimport '@webex/internal-plugin-user';\nimport '@webex/internal-plugin-device';\n\nimport WebexCore from '@webex/webex-core';\n\nexport default WebexCore;\n"],"mappings":"
|
|
1
|
+
{"version":3,"names":["require","_webexCore","_interopRequireDefault","_default","WebexCore","exports","default"],"sources":["webex.js"],"sourcesContent":["/*!\n * Copyright (c) 2015-2020 Cisco Systems, Inc. See LICENSE file.\n */\n\nimport '@babel/polyfill';\n\nimport '@webex/plugin-authorization-node';\nimport '@webex/internal-plugin-avatar';\nimport '@webex/internal-plugin-board';\nimport '@webex/internal-plugin-calendar';\nimport '@webex/internal-plugin-conversation';\nimport '@webex/internal-plugin-encryption';\nimport '@webex/internal-plugin-feature';\nimport '@webex/internal-plugin-flag';\nimport '@webex/plugin-logger';\nimport '@webex/internal-plugin-mercury';\nimport '@webex/internal-plugin-metrics';\nimport '@webex/internal-plugin-search';\nimport '@webex/internal-plugin-support';\nimport '@webex/internal-plugin-team';\nimport '@webex/internal-plugin-user';\nimport '@webex/internal-plugin-device';\n\nimport WebexCore from '@webex/webex-core';\n\nexport default WebexCore;\n"],"mappings":";;;;;;;;AAIAA,OAAA;AAEAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AACAA,OAAA;AAEA,IAAAC,UAAA,GAAAC,sBAAA,CAAAF,OAAA;AAvBA;AACA;AACA;AAFA,IAAAG,QAAA,GAyBeC,kBAAS;AAAAC,OAAA,CAAAC,OAAA,GAAAH,QAAA"}
|
package/jest.config.js
ADDED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@webex/webex-server",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.52.7",
|
|
4
4
|
"description": ".",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"contributors": [
|
|
@@ -9,15 +9,14 @@
|
|
|
9
9
|
],
|
|
10
10
|
"main": "dist/index.js",
|
|
11
11
|
"devMain": "src/index.js",
|
|
12
|
-
"bin":
|
|
13
|
-
|
|
14
|
-
},
|
|
15
|
-
"repository": "https://github.com/webex/webex-js-sdk/tree/master/packages/node_modules/@webex/webex-server",
|
|
12
|
+
"bin": "./bin/webex-server",
|
|
13
|
+
"repository": "https://github.com/webex/webex-js-sdk/tree/master/packages/@webex/webex-server",
|
|
16
14
|
"engines": {
|
|
17
|
-
"node": ">=
|
|
15
|
+
"node": ">=14"
|
|
18
16
|
},
|
|
19
17
|
"browserify": {
|
|
20
18
|
"transform": [
|
|
19
|
+
"babelify",
|
|
21
20
|
"envify"
|
|
22
21
|
]
|
|
23
22
|
},
|
|
@@ -32,39 +31,60 @@
|
|
|
32
31
|
"http-server",
|
|
33
32
|
"server"
|
|
34
33
|
],
|
|
34
|
+
"devDependencies": {
|
|
35
|
+
"@babel/core": "^7.17.10",
|
|
36
|
+
"@babel/polyfill": "^7.12.1",
|
|
37
|
+
"@webex/babel-config-legacy": "2.52.7",
|
|
38
|
+
"@webex/eslint-config-legacy": "2.52.7",
|
|
39
|
+
"@webex/jest-config-legacy": "2.52.7",
|
|
40
|
+
"@webex/legacy-tools": "2.52.7",
|
|
41
|
+
"@webex/test-helper-chai": "2.52.7",
|
|
42
|
+
"@webex/test-helper-mocha": "2.52.7",
|
|
43
|
+
"@webex/test-helper-mock-webex": "2.52.7",
|
|
44
|
+
"@webex/test-helper-test-users": "2.52.7",
|
|
45
|
+
"eslint": "^8.24.0",
|
|
46
|
+
"prettier": "^2.7.1"
|
|
47
|
+
},
|
|
35
48
|
"dependencies": {
|
|
36
|
-
"@
|
|
49
|
+
"@webex/internal-plugin-avatar": "2.52.7",
|
|
50
|
+
"@webex/internal-plugin-board": "2.52.7",
|
|
51
|
+
"@webex/internal-plugin-calendar": "2.52.7",
|
|
52
|
+
"@webex/internal-plugin-conversation": "2.52.7",
|
|
53
|
+
"@webex/internal-plugin-device": "2.52.7",
|
|
54
|
+
"@webex/internal-plugin-encryption": "2.52.7",
|
|
55
|
+
"@webex/internal-plugin-feature": "2.52.7",
|
|
56
|
+
"@webex/internal-plugin-flag": "2.52.7",
|
|
57
|
+
"@webex/internal-plugin-mercury": "2.52.7",
|
|
58
|
+
"@webex/internal-plugin-metrics": "2.52.7",
|
|
59
|
+
"@webex/internal-plugin-search": "2.52.7",
|
|
60
|
+
"@webex/internal-plugin-support": "2.52.7",
|
|
61
|
+
"@webex/internal-plugin-team": "2.52.7",
|
|
62
|
+
"@webex/internal-plugin-user": "2.52.7",
|
|
63
|
+
"@webex/plugin-authorization-node": "2.52.7",
|
|
64
|
+
"@webex/plugin-logger": "2.52.7",
|
|
65
|
+
"@webex/webex-core": "2.52.7",
|
|
66
|
+
"body-parser": "^1.19.0",
|
|
37
67
|
"compression": "^1.7.4",
|
|
38
68
|
"cors": "^2.8.5",
|
|
39
69
|
"errorhandler": "^1.5.1",
|
|
40
70
|
"express": "^4.17.1",
|
|
71
|
+
"express-session": "^1.16.2",
|
|
72
|
+
"express-validator": "^5.3.1",
|
|
73
|
+
"lodash": "^4.17.21",
|
|
41
74
|
"morgan": "^1.9.1",
|
|
42
75
|
"on-finished": "^2.3.0",
|
|
43
76
|
"request-id": "^0.11.1",
|
|
44
77
|
"response-time": "^2.3.2",
|
|
45
|
-
"
|
|
46
|
-
"
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
"
|
|
50
|
-
"
|
|
51
|
-
"
|
|
52
|
-
"
|
|
53
|
-
"
|
|
54
|
-
"
|
|
55
|
-
"
|
|
56
|
-
"@webex/internal-plugin-mercury": "2.29.3",
|
|
57
|
-
"@webex/internal-plugin-metrics": "2.29.3",
|
|
58
|
-
"@webex/internal-plugin-search": "2.29.3",
|
|
59
|
-
"@webex/internal-plugin-support": "2.29.3",
|
|
60
|
-
"@webex/internal-plugin-team": "2.29.3",
|
|
61
|
-
"@webex/internal-plugin-user": "2.29.3",
|
|
62
|
-
"@webex/internal-plugin-device": "2.29.3",
|
|
63
|
-
"@webex/webex-core": "2.29.3",
|
|
64
|
-
"lodash": "^4.17.21",
|
|
65
|
-
"body-parser": "^1.19.0",
|
|
66
|
-
"express-validator": "^5.3.1",
|
|
67
|
-
"express-session": "^1.16.2",
|
|
68
|
-
"envify": "^4.1.0"
|
|
78
|
+
"supertest": "^3.4.2",
|
|
79
|
+
"uuid": "^3.3.2"
|
|
80
|
+
},
|
|
81
|
+
"scripts": {
|
|
82
|
+
"build": "yarn build:src",
|
|
83
|
+
"build:src": "webex-legacy-tools build -dest \"./dist\" -src \"./src\" -js -ts -maps",
|
|
84
|
+
"test": "yarn test:style && yarn test:unit && yarn test:integration && yarn test:browser",
|
|
85
|
+
"test:browser:broken": "webex-legacy-tools test --integration --unit --runner karma",
|
|
86
|
+
"test:integration:broken": "webex-legacy-tools test --integration --runner mocha",
|
|
87
|
+
"test:style": "eslint ./src/**/*.*",
|
|
88
|
+
"test:unit": "webex-legacy-tools test --unit --runner jest"
|
|
69
89
|
}
|
|
70
90
|
}
|
package/process
ADDED
|
@@ -0,0 +1 @@
|
|
|
1
|
+
module.exports = {browser: true};
|
package/src/index.js
CHANGED
|
@@ -20,34 +20,45 @@ import sessionRouter from './session';
|
|
|
20
20
|
const app = express();
|
|
21
21
|
|
|
22
22
|
app.use(responseTime());
|
|
23
|
-
app.use(
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
23
|
+
app.use(
|
|
24
|
+
requestId({
|
|
25
|
+
generator() {
|
|
26
|
+
// TODO get sequence from session data
|
|
27
|
+
const sequence = 0;
|
|
28
|
+
|
|
29
|
+
return `webex-server_${uuid.v4()}_${sequence}`;
|
|
30
|
+
},
|
|
31
|
+
reqHeader: 'TrackingID',
|
|
32
|
+
resHeader: 'TrackingID',
|
|
33
|
+
})
|
|
34
|
+
);
|
|
33
35
|
app.use(morgan('dev'));
|
|
34
36
|
app.use((req, res, next) => {
|
|
35
37
|
onFinished(res, () => {
|
|
36
|
-
console.info(
|
|
38
|
+
console.info(
|
|
39
|
+
req.method.toUpperCase(),
|
|
40
|
+
req.path,
|
|
41
|
+
res.statusCode,
|
|
42
|
+
res.getHeader('X-Response-Time')
|
|
43
|
+
);
|
|
37
44
|
});
|
|
38
45
|
next();
|
|
39
46
|
});
|
|
40
47
|
app.use(compression());
|
|
41
|
-
app.use(
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
48
|
+
app.use(
|
|
49
|
+
cors({
|
|
50
|
+
origin: true,
|
|
51
|
+
credentials: true,
|
|
52
|
+
maxAge: 24 * 60 * 60,
|
|
53
|
+
})
|
|
54
|
+
);
|
|
46
55
|
|
|
47
56
|
app.get('/ping', (req, res) => {
|
|
48
|
-
res.send(
|
|
49
|
-
'
|
|
50
|
-
|
|
57
|
+
res.send({
|
|
58
|
+
name: '@webex/webex-server',
|
|
59
|
+
version: PACKAGE_VERSION,
|
|
60
|
+
'sdk-version': Webex.version,
|
|
61
|
+
});
|
|
51
62
|
});
|
|
52
63
|
|
|
53
64
|
app.use('/api/v1', sessionRouter);
|
package/src/memory-store.js
CHANGED
|
@@ -31,15 +31,18 @@ import util from 'util';
|
|
|
31
31
|
*/
|
|
32
32
|
|
|
33
33
|
/* istanbul ignore next */
|
|
34
|
-
var defer =
|
|
35
|
-
|
|
36
|
-
|
|
34
|
+
var defer =
|
|
35
|
+
typeof setImmediate === 'function'
|
|
36
|
+
? setImmediate
|
|
37
|
+
: function (fn) {
|
|
38
|
+
process.nextTick(fn.bind.apply(fn, arguments));
|
|
39
|
+
};
|
|
37
40
|
|
|
38
41
|
/**
|
|
39
42
|
* Module exports.
|
|
40
43
|
*/
|
|
41
44
|
|
|
42
|
-
export default MemoryStore
|
|
45
|
+
export default MemoryStore;
|
|
43
46
|
|
|
44
47
|
/**
|
|
45
48
|
* A session store in memory.
|
|
@@ -47,15 +50,15 @@ export default MemoryStore
|
|
|
47
50
|
*/
|
|
48
51
|
|
|
49
52
|
function MemoryStore() {
|
|
50
|
-
Store.call(this)
|
|
51
|
-
this.sessions = Object.create(null)
|
|
53
|
+
Store.call(this);
|
|
54
|
+
this.sessions = Object.create(null);
|
|
52
55
|
}
|
|
53
56
|
|
|
54
57
|
/**
|
|
55
58
|
* Inherit from Store.
|
|
56
59
|
*/
|
|
57
60
|
|
|
58
|
-
util.inherits(MemoryStore, Store)
|
|
61
|
+
util.inherits(MemoryStore, Store);
|
|
59
62
|
|
|
60
63
|
/**
|
|
61
64
|
* Get all active sessions.
|
|
@@ -65,20 +68,20 @@ util.inherits(MemoryStore, Store)
|
|
|
65
68
|
*/
|
|
66
69
|
|
|
67
70
|
MemoryStore.prototype.all = function all(callback) {
|
|
68
|
-
var sessionIds = Object.keys(this.sessions)
|
|
69
|
-
var sessions = Object.create(null)
|
|
71
|
+
var sessionIds = Object.keys(this.sessions);
|
|
72
|
+
var sessions = Object.create(null);
|
|
70
73
|
|
|
71
|
-
for (var i = 0; i < sessionIds.length; i+= 1) {
|
|
72
|
-
var sessionId = sessionIds[i]
|
|
73
|
-
var session = getSession.call(this, sessionId)
|
|
74
|
+
for (var i = 0; i < sessionIds.length; i += 1) {
|
|
75
|
+
var sessionId = sessionIds[i];
|
|
76
|
+
var session = getSession.call(this, sessionId);
|
|
74
77
|
|
|
75
78
|
if (session) {
|
|
76
79
|
sessions[sessionId] = session;
|
|
77
80
|
}
|
|
78
81
|
}
|
|
79
82
|
|
|
80
|
-
callback && defer(callback, null, sessions)
|
|
81
|
-
}
|
|
83
|
+
callback && defer(callback, null, sessions);
|
|
84
|
+
};
|
|
82
85
|
|
|
83
86
|
/**
|
|
84
87
|
* Clear all sessions.
|
|
@@ -88,9 +91,9 @@ MemoryStore.prototype.all = function all(callback) {
|
|
|
88
91
|
*/
|
|
89
92
|
|
|
90
93
|
MemoryStore.prototype.clear = function clear(callback) {
|
|
91
|
-
this.sessions = Object.create(null)
|
|
92
|
-
callback && defer(callback)
|
|
93
|
-
}
|
|
94
|
+
this.sessions = Object.create(null);
|
|
95
|
+
callback && defer(callback);
|
|
96
|
+
};
|
|
94
97
|
|
|
95
98
|
/**
|
|
96
99
|
* Destroy the session associated with the given session ID.
|
|
@@ -100,9 +103,9 @@ MemoryStore.prototype.clear = function clear(callback) {
|
|
|
100
103
|
*/
|
|
101
104
|
|
|
102
105
|
MemoryStore.prototype.destroy = function destroy(sessionId, callback) {
|
|
103
|
-
delete this.sessions[sessionId]
|
|
104
|
-
callback && defer(callback)
|
|
105
|
-
}
|
|
106
|
+
delete this.sessions[sessionId];
|
|
107
|
+
callback && defer(callback);
|
|
108
|
+
};
|
|
106
109
|
|
|
107
110
|
/**
|
|
108
111
|
* Fetch session by the given session ID.
|
|
@@ -113,8 +116,8 @@ MemoryStore.prototype.destroy = function destroy(sessionId, callback) {
|
|
|
113
116
|
*/
|
|
114
117
|
|
|
115
118
|
MemoryStore.prototype.get = function get(sessionId, callback) {
|
|
116
|
-
defer(callback, null, getSession.call(this, sessionId))
|
|
117
|
-
}
|
|
119
|
+
defer(callback, null, getSession.call(this, sessionId));
|
|
120
|
+
};
|
|
118
121
|
|
|
119
122
|
/**
|
|
120
123
|
* Commit the given session associated with the given sessionId to the store.
|
|
@@ -134,15 +137,15 @@ MemoryStore.prototype.get = function get(sessionId, callback) {
|
|
|
134
137
|
|
|
135
138
|
MemoryStore.prototype.length = function length(callback) {
|
|
136
139
|
this.all(function (err, sessions) {
|
|
137
|
-
if (err) return callback(err)
|
|
138
|
-
callback(null, Object.keys(sessions).length)
|
|
139
|
-
})
|
|
140
|
-
}
|
|
140
|
+
if (err) return callback(err);
|
|
141
|
+
callback(null, Object.keys(sessions).length);
|
|
142
|
+
});
|
|
143
|
+
};
|
|
141
144
|
|
|
142
145
|
MemoryStore.prototype.set = function set(sessionId, session, callback) {
|
|
143
|
-
this.sessions[sessionId] = session
|
|
144
|
-
callback && defer(callback)
|
|
145
|
-
}
|
|
146
|
+
this.sessions[sessionId] = session;
|
|
147
|
+
callback && defer(callback);
|
|
148
|
+
};
|
|
146
149
|
|
|
147
150
|
/**
|
|
148
151
|
* Touch the given session object associated with the given session ID.
|
|
@@ -154,16 +157,16 @@ MemoryStore.prototype.set = function set(sessionId, session, callback) {
|
|
|
154
157
|
*/
|
|
155
158
|
|
|
156
159
|
MemoryStore.prototype.touch = function touch(sessionId, session, callback) {
|
|
157
|
-
var currentSession = getSession.call(this, sessionId)
|
|
160
|
+
var currentSession = getSession.call(this, sessionId);
|
|
158
161
|
|
|
159
162
|
if (currentSession) {
|
|
160
163
|
// update expiration
|
|
161
|
-
currentSession.cookie = session.cookie
|
|
162
|
-
this.sessions[sessionId] = currentSession
|
|
164
|
+
currentSession.cookie = session.cookie;
|
|
165
|
+
this.sessions[sessionId] = currentSession;
|
|
163
166
|
}
|
|
164
167
|
|
|
165
|
-
callback && defer(callback)
|
|
166
|
-
}
|
|
168
|
+
callback && defer(callback);
|
|
169
|
+
};
|
|
167
170
|
|
|
168
171
|
/**
|
|
169
172
|
* Get session from the store.
|
|
@@ -171,21 +174,20 @@ MemoryStore.prototype.touch = function touch(sessionId, session, callback) {
|
|
|
171
174
|
*/
|
|
172
175
|
|
|
173
176
|
function getSession(sessionId) {
|
|
174
|
-
var sess = this.sessions[sessionId]
|
|
177
|
+
var sess = this.sessions[sessionId];
|
|
175
178
|
|
|
176
179
|
if (!sess) {
|
|
177
|
-
return
|
|
180
|
+
return;
|
|
178
181
|
}
|
|
179
182
|
|
|
180
|
-
var expires =
|
|
181
|
-
? new Date(sess.cookie.expires)
|
|
182
|
-
: sess.cookie.expires
|
|
183
|
+
var expires =
|
|
184
|
+
typeof sess.cookie.expires === 'string' ? new Date(sess.cookie.expires) : sess.cookie.expires;
|
|
183
185
|
|
|
184
186
|
// destroy expired session
|
|
185
187
|
if (expires && expires <= Date.now()) {
|
|
186
|
-
delete this.sessions[sessionId]
|
|
187
|
-
return
|
|
188
|
+
delete this.sessions[sessionId];
|
|
189
|
+
return;
|
|
188
190
|
}
|
|
189
191
|
|
|
190
|
-
return sess
|
|
192
|
+
return sess;
|
|
191
193
|
}
|
package/src/session.js
CHANGED
|
@@ -14,7 +14,6 @@ import {get} from 'lodash';
|
|
|
14
14
|
import WebexCore from './webex';
|
|
15
15
|
import MemoryStore from './memory-store';
|
|
16
16
|
|
|
17
|
-
|
|
18
17
|
/* eslint-disable camelcase */
|
|
19
18
|
/* eslint-disable no-console */
|
|
20
19
|
// express induces more callbacks than usual
|
|
@@ -27,12 +26,14 @@ export default router;
|
|
|
27
26
|
|
|
28
27
|
router.use(bodyParser.json());
|
|
29
28
|
router.use(validator());
|
|
30
|
-
router.use(
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
29
|
+
router.use(
|
|
30
|
+
session({
|
|
31
|
+
resave: true,
|
|
32
|
+
saveUninitialized: true,
|
|
33
|
+
secret: 'keyboardcat',
|
|
34
|
+
store: new MemoryStore(),
|
|
35
|
+
})
|
|
36
|
+
);
|
|
36
37
|
|
|
37
38
|
/**
|
|
38
39
|
* Return the details for a given session
|
|
@@ -42,9 +43,7 @@ router.get('/session', (req, res) => {
|
|
|
42
43
|
const {webex} = req.session;
|
|
43
44
|
|
|
44
45
|
if (!webex) {
|
|
45
|
-
res
|
|
46
|
-
.status(404)
|
|
47
|
-
.end();
|
|
46
|
+
res.status(404).end();
|
|
48
47
|
|
|
49
48
|
return;
|
|
50
49
|
}
|
|
@@ -52,7 +51,7 @@ router.get('/session', (req, res) => {
|
|
|
52
51
|
res
|
|
53
52
|
.status(200)
|
|
54
53
|
.send({
|
|
55
|
-
webex: webex.serialize()
|
|
54
|
+
webex: webex.serialize(),
|
|
56
55
|
})
|
|
57
56
|
.end();
|
|
58
57
|
});
|
|
@@ -72,40 +71,35 @@ router.put('/session', (req, res, next) => {
|
|
|
72
71
|
req.checkBody('user.token.token_type').notEmpty();
|
|
73
72
|
req.checkBody('user.token.expires_in').notEmpty();
|
|
74
73
|
|
|
75
|
-
req.getValidationResult()
|
|
76
|
-
.
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
}
|
|
94
|
-
}
|
|
95
|
-
});
|
|
74
|
+
req.getValidationResult().then((result) => {
|
|
75
|
+
if (!result.isEmpty()) {
|
|
76
|
+
console.info(result.array());
|
|
77
|
+
res.status(400).send(`${result.array()[0].param} is missing`);
|
|
78
|
+
|
|
79
|
+
return;
|
|
80
|
+
}
|
|
81
|
+
const webex = new WebexCore({
|
|
82
|
+
credentials: req.body.user.token,
|
|
83
|
+
config: {
|
|
84
|
+
credentials: {
|
|
85
|
+
client_id: req.body.clientId,
|
|
86
|
+
client_secret: req.body.clientSecret,
|
|
87
|
+
redirect_uri: req.body.redirectUri,
|
|
88
|
+
scope: req.body.scope,
|
|
89
|
+
},
|
|
90
|
+
},
|
|
91
|
+
});
|
|
96
92
|
|
|
97
|
-
|
|
93
|
+
req.session.webex = webex;
|
|
98
94
|
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
});
|
|
108
|
-
});
|
|
95
|
+
webex.internal.mercury
|
|
96
|
+
.connect()
|
|
97
|
+
.then(() => res.status(200).send({webex}).end())
|
|
98
|
+
.catch((err) => {
|
|
99
|
+
console.error(err);
|
|
100
|
+
next(err);
|
|
101
|
+
});
|
|
102
|
+
});
|
|
109
103
|
});
|
|
110
104
|
|
|
111
105
|
/**
|
|
@@ -118,38 +112,35 @@ router.delete('/session', (req, res, next) => {
|
|
|
118
112
|
res
|
|
119
113
|
.status(404)
|
|
120
114
|
.send({
|
|
121
|
-
err: 'no webex instance found for session'
|
|
115
|
+
err: 'no webex instance found for session',
|
|
122
116
|
})
|
|
123
117
|
.end();
|
|
124
118
|
|
|
125
119
|
return;
|
|
126
120
|
}
|
|
127
121
|
|
|
128
|
-
webex.internal.mercury
|
|
122
|
+
webex.internal.mercury
|
|
123
|
+
.disconnect()
|
|
129
124
|
.then(() => {
|
|
130
|
-
req.session
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
.status(204)
|
|
140
|
-
.end();
|
|
141
|
-
});
|
|
125
|
+
req.session.destroy((err) => {
|
|
126
|
+
if (err) {
|
|
127
|
+
next(err);
|
|
128
|
+
|
|
129
|
+
return;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
res.status(204).end();
|
|
133
|
+
});
|
|
142
134
|
})
|
|
143
135
|
.catch((err) => {
|
|
144
|
-
req.session
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
next(err2);
|
|
136
|
+
req.session.destroy((err2) => {
|
|
137
|
+
if (err2) {
|
|
138
|
+
next(err2);
|
|
148
139
|
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
140
|
+
return;
|
|
141
|
+
}
|
|
142
|
+
next(err);
|
|
143
|
+
});
|
|
153
144
|
});
|
|
154
145
|
});
|
|
155
146
|
|
|
@@ -162,7 +153,7 @@ router.post('/session/invoke/internal/conversation/share', (req, res) => {
|
|
|
162
153
|
res
|
|
163
154
|
.status(404)
|
|
164
155
|
.send({
|
|
165
|
-
message: 'No session found - did you forget to hit /session?'
|
|
156
|
+
message: 'No session found - did you forget to hit /session?',
|
|
166
157
|
})
|
|
167
158
|
.end();
|
|
168
159
|
|
|
@@ -179,18 +170,22 @@ router.post('/session/invoke/internal/conversation/share', (req, res) => {
|
|
|
179
170
|
});
|
|
180
171
|
|
|
181
172
|
console.info('invoke: invoking "conversation.share" with arguments\n', util.inspect(req.body));
|
|
182
|
-
webex.internal.conversation
|
|
173
|
+
webex.internal.conversation
|
|
174
|
+
.share(req.body[0], share)
|
|
183
175
|
.then((result) => {
|
|
184
176
|
res.status(200).send(result).end();
|
|
185
177
|
})
|
|
186
178
|
.catch((reason) => {
|
|
187
179
|
console.log(reason);
|
|
188
|
-
res
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
180
|
+
res
|
|
181
|
+
.status(400)
|
|
182
|
+
.send({
|
|
183
|
+
message: 'An error occured while processing your request',
|
|
184
|
+
error: reason.toString(),
|
|
185
|
+
upstreamStatusCode: reason.statusCode,
|
|
186
|
+
upstreamResponse: reason.body,
|
|
187
|
+
})
|
|
188
|
+
.end();
|
|
194
189
|
});
|
|
195
190
|
});
|
|
196
191
|
|
|
@@ -206,7 +201,7 @@ router.post(/^\/session\/invoke\/.*/, (req, res) => {
|
|
|
206
201
|
res
|
|
207
202
|
.status(404)
|
|
208
203
|
.send({
|
|
209
|
-
message: 'No session found - did you forget to hit /session?'
|
|
204
|
+
message: 'No session found - did you forget to hit /session?',
|
|
210
205
|
})
|
|
211
206
|
.end();
|
|
212
207
|
|
|
@@ -237,10 +232,7 @@ router.post(/^\/session\/invoke\/.*/, (req, res) => {
|
|
|
237
232
|
Reflect.apply(method, context, req.body)
|
|
238
233
|
.then((result) => {
|
|
239
234
|
console.info(`invoke: successfully invoked "${label}"`);
|
|
240
|
-
res
|
|
241
|
-
.status(200)
|
|
242
|
-
.send(result)
|
|
243
|
-
.end();
|
|
235
|
+
res.status(200).send(result).end();
|
|
244
236
|
})
|
|
245
237
|
.catch((reason) => {
|
|
246
238
|
console.error({req, err: reason}, `invoke: "${label}" failed with error`);
|
|
@@ -250,7 +242,7 @@ router.post(/^\/session\/invoke\/.*/, (req, res) => {
|
|
|
250
242
|
message: 'An error occured while processing your request',
|
|
251
243
|
error: reason.toString(),
|
|
252
244
|
upstreamStatusCode: reason.statusCode,
|
|
253
|
-
upstreamResponse: reason.body
|
|
245
|
+
upstreamResponse: reason.body,
|
|
254
246
|
})
|
|
255
247
|
.end();
|
|
256
248
|
});
|