@lockerpm/desktop-service 1.0.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/README.md +98 -0
- package/lib/cjs/abstractions/api.service.js +2 -0
- package/lib/cjs/abstractions/crypto.service.js +147 -0
- package/lib/cjs/abstractions/errors.js +99 -0
- package/lib/cjs/abstractions/event.service.js +2 -0
- package/lib/cjs/abstractions/index.js +2 -0
- package/lib/cjs/abstractions/socket.service.js +11 -0
- package/lib/cjs/abstractions/storage.service.js +2 -0
- package/lib/cjs/index.js +243 -0
- package/lib/cjs/misc/config.js +15 -0
- package/lib/cjs/misc/utils.js +37 -0
- package/lib/cjs/proto/google/api/annotations.js +2 -0
- package/lib/cjs/proto/google/api/http.js +477 -0
- package/lib/cjs/proto/google/protobuf/descriptor.js +4873 -0
- package/lib/cjs/proto/locker-service-grpc.js +1915 -0
- package/lib/cjs/services/api.service.js +182 -0
- package/lib/cjs/services/cache.service.js +50 -0
- package/lib/cjs/services/core-crypto.service.js +193 -0
- package/lib/cjs/services/crypto.service.js +101 -0
- package/lib/cjs/services/event.service.js +31 -0
- package/lib/cjs/services/fido.service.js +136 -0
- package/lib/cjs/services/grpc.service.js +130 -0
- package/lib/cjs/services/log.service.js +30 -0
- package/lib/cjs/services/pairing.service.js +122 -0
- package/lib/cjs/services/socket.service.js +280 -0
- package/lib/cjs/services/user.service.js +134 -0
- package/lib/cjs/types/abstractions/api.service.d.ts +40 -0
- package/lib/cjs/types/abstractions/api.service.d.ts.map +1 -0
- package/lib/cjs/types/abstractions/crypto.service.d.ts +46 -0
- package/lib/cjs/types/abstractions/crypto.service.d.ts.map +1 -0
- package/lib/cjs/types/abstractions/errors.d.ts +73 -0
- package/lib/cjs/types/abstractions/errors.d.ts.map +1 -0
- package/lib/cjs/types/abstractions/event.service.d.ts +23 -0
- package/lib/cjs/types/abstractions/event.service.d.ts.map +1 -0
- package/lib/cjs/types/abstractions/index.d.ts +56 -0
- package/lib/cjs/types/abstractions/index.d.ts.map +1 -0
- package/lib/cjs/types/abstractions/socket.service.d.ts +52 -0
- package/lib/cjs/types/abstractions/socket.service.d.ts.map +1 -0
- package/lib/cjs/types/abstractions/storage.service.d.ts +6 -0
- package/lib/cjs/types/abstractions/storage.service.d.ts.map +1 -0
- package/lib/cjs/types/index.d.ts +164 -0
- package/lib/cjs/types/index.d.ts.map +1 -0
- package/lib/cjs/types/misc/config.d.ts +6 -0
- package/lib/cjs/types/misc/config.d.ts.map +1 -0
- package/lib/cjs/types/misc/utils.d.ts +21 -0
- package/lib/cjs/types/misc/utils.d.ts.map +1 -0
- package/lib/cjs/types/proto/google/api/annotations.d.ts +2 -0
- package/lib/cjs/types/proto/google/api/annotations.d.ts.map +1 -0
- package/lib/cjs/types/proto/google/api/http.d.ts +195 -0
- package/lib/cjs/types/proto/google/api/http.d.ts.map +1 -0
- package/lib/cjs/types/proto/google/protobuf/descriptor.d.ts +3409 -0
- package/lib/cjs/types/proto/google/protobuf/descriptor.d.ts.map +1 -0
- package/lib/cjs/types/proto/locker-service-grpc.d.ts +622 -0
- package/lib/cjs/types/proto/locker-service-grpc.d.ts.map +1 -0
- package/lib/cjs/types/services/api.service.d.ts +37 -0
- package/lib/cjs/types/services/api.service.d.ts.map +1 -0
- package/lib/cjs/types/services/cache.service.d.ts +10 -0
- package/lib/cjs/types/services/cache.service.d.ts.map +1 -0
- package/lib/cjs/types/services/core-crypto.service.d.ts +17 -0
- package/lib/cjs/types/services/core-crypto.service.d.ts.map +1 -0
- package/lib/cjs/types/services/crypto.service.d.ts +23 -0
- package/lib/cjs/types/services/crypto.service.d.ts.map +1 -0
- package/lib/cjs/types/services/event.service.d.ts +14 -0
- package/lib/cjs/types/services/event.service.d.ts.map +1 -0
- package/lib/cjs/types/services/fido.service.d.ts +40 -0
- package/lib/cjs/types/services/fido.service.d.ts.map +1 -0
- package/lib/cjs/types/services/grpc.service.d.ts +34 -0
- package/lib/cjs/types/services/grpc.service.d.ts.map +1 -0
- package/lib/cjs/types/services/log.service.d.ts +13 -0
- package/lib/cjs/types/services/log.service.d.ts.map +1 -0
- package/lib/cjs/types/services/pairing.service.d.ts +37 -0
- package/lib/cjs/types/services/pairing.service.d.ts.map +1 -0
- package/lib/cjs/types/services/socket.service.d.ts +39 -0
- package/lib/cjs/types/services/socket.service.d.ts.map +1 -0
- package/lib/cjs/types/services/user.service.d.ts +32 -0
- package/lib/cjs/types/services/user.service.d.ts.map +1 -0
- package/lib/cjs/types/usecases/fido.d.ts +54 -0
- package/lib/cjs/types/usecases/fido.d.ts.map +1 -0
- package/lib/cjs/usecases/fido.js +227 -0
- package/lib/esm/abstractions/api.service.js +2 -0
- package/lib/esm/abstractions/crypto.service.js +165 -0
- package/lib/esm/abstractions/errors.js +100 -0
- package/lib/esm/abstractions/event.service.js +2 -0
- package/lib/esm/abstractions/index.js +2 -0
- package/lib/esm/abstractions/socket.service.js +11 -0
- package/lib/esm/abstractions/storage.service.js +2 -0
- package/lib/esm/index.mjs +227 -0
- package/lib/esm/misc/config.js +15 -0
- package/lib/esm/misc/utils.js +37 -0
- package/lib/esm/proto/google/api/annotations.js +2 -0
- package/lib/esm/proto/google/api/http.js +468 -0
- package/lib/esm/proto/google/protobuf/descriptor.js +4830 -0
- package/lib/esm/proto/locker-service-grpc.js +1892 -0
- package/lib/esm/services/api.service.js +177 -0
- package/lib/esm/services/cache.service.js +52 -0
- package/lib/esm/services/core-crypto.service.js +164 -0
- package/lib/esm/services/crypto.service.js +83 -0
- package/lib/esm/services/event.service.js +33 -0
- package/lib/esm/services/fido.service.js +139 -0
- package/lib/esm/services/grpc.service.js +119 -0
- package/lib/esm/services/log.service.js +31 -0
- package/lib/esm/services/pairing.service.js +107 -0
- package/lib/esm/services/socket.service.js +265 -0
- package/lib/esm/services/user.service.js +116 -0
- package/lib/esm/types/abstractions/api.service.d.ts +40 -0
- package/lib/esm/types/abstractions/api.service.d.ts.map +1 -0
- package/lib/esm/types/abstractions/crypto.service.d.ts +46 -0
- package/lib/esm/types/abstractions/crypto.service.d.ts.map +1 -0
- package/lib/esm/types/abstractions/errors.d.ts +73 -0
- package/lib/esm/types/abstractions/errors.d.ts.map +1 -0
- package/lib/esm/types/abstractions/event.service.d.ts +23 -0
- package/lib/esm/types/abstractions/event.service.d.ts.map +1 -0
- package/lib/esm/types/abstractions/index.d.ts +56 -0
- package/lib/esm/types/abstractions/index.d.ts.map +1 -0
- package/lib/esm/types/abstractions/socket.service.d.ts +52 -0
- package/lib/esm/types/abstractions/socket.service.d.ts.map +1 -0
- package/lib/esm/types/abstractions/storage.service.d.ts +6 -0
- package/lib/esm/types/abstractions/storage.service.d.ts.map +1 -0
- package/lib/esm/types/index.d.ts +164 -0
- package/lib/esm/types/index.d.ts.map +1 -0
- package/lib/esm/types/misc/config.d.ts +6 -0
- package/lib/esm/types/misc/config.d.ts.map +1 -0
- package/lib/esm/types/misc/utils.d.ts +21 -0
- package/lib/esm/types/misc/utils.d.ts.map +1 -0
- package/lib/esm/types/proto/google/api/annotations.d.ts +2 -0
- package/lib/esm/types/proto/google/api/annotations.d.ts.map +1 -0
- package/lib/esm/types/proto/google/api/http.d.ts +195 -0
- package/lib/esm/types/proto/google/api/http.d.ts.map +1 -0
- package/lib/esm/types/proto/google/protobuf/descriptor.d.ts +3409 -0
- package/lib/esm/types/proto/google/protobuf/descriptor.d.ts.map +1 -0
- package/lib/esm/types/proto/locker-service-grpc.d.ts +622 -0
- package/lib/esm/types/proto/locker-service-grpc.d.ts.map +1 -0
- package/lib/esm/types/services/api.service.d.ts +37 -0
- package/lib/esm/types/services/api.service.d.ts.map +1 -0
- package/lib/esm/types/services/cache.service.d.ts +10 -0
- package/lib/esm/types/services/cache.service.d.ts.map +1 -0
- package/lib/esm/types/services/core-crypto.service.d.ts +17 -0
- package/lib/esm/types/services/core-crypto.service.d.ts.map +1 -0
- package/lib/esm/types/services/crypto.service.d.ts +23 -0
- package/lib/esm/types/services/crypto.service.d.ts.map +1 -0
- package/lib/esm/types/services/event.service.d.ts +14 -0
- package/lib/esm/types/services/event.service.d.ts.map +1 -0
- package/lib/esm/types/services/fido.service.d.ts +40 -0
- package/lib/esm/types/services/fido.service.d.ts.map +1 -0
- package/lib/esm/types/services/grpc.service.d.ts +34 -0
- package/lib/esm/types/services/grpc.service.d.ts.map +1 -0
- package/lib/esm/types/services/log.service.d.ts +13 -0
- package/lib/esm/types/services/log.service.d.ts.map +1 -0
- package/lib/esm/types/services/pairing.service.d.ts +37 -0
- package/lib/esm/types/services/pairing.service.d.ts.map +1 -0
- package/lib/esm/types/services/socket.service.d.ts +39 -0
- package/lib/esm/types/services/socket.service.d.ts.map +1 -0
- package/lib/esm/types/services/user.service.d.ts +32 -0
- package/lib/esm/types/services/user.service.d.ts.map +1 -0
- package/lib/esm/types/usecases/fido.d.ts +54 -0
- package/lib/esm/types/usecases/fido.d.ts.map +1 -0
- package/lib/esm/usecases/fido.js +201 -0
- package/package.json +55 -0
|
@@ -0,0 +1,280 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
12
|
+
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
|
+
};
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.SocketService = void 0;
|
|
16
|
+
const ws_1 = require("ws");
|
|
17
|
+
const socket_service_1 = require("../abstractions/socket.service");
|
|
18
|
+
const errors_1 = require("../abstractions/errors");
|
|
19
|
+
const https_1 = __importDefault(require("https"));
|
|
20
|
+
const http_1 = __importDefault(require("http"));
|
|
21
|
+
const config_1 = require("../misc/config");
|
|
22
|
+
class SocketService {
|
|
23
|
+
constructor(params) {
|
|
24
|
+
this.sslConfig = undefined;
|
|
25
|
+
this.server = undefined;
|
|
26
|
+
this.clients = {};
|
|
27
|
+
this.serviceAlias = '';
|
|
28
|
+
this.currentPort = 0;
|
|
29
|
+
this.currentSslPort = 0;
|
|
30
|
+
const { logger, pairingService, userService, eventService, ssl } = params;
|
|
31
|
+
this.logger = logger;
|
|
32
|
+
this.pairingService = pairingService;
|
|
33
|
+
this.userService = userService;
|
|
34
|
+
this.eventService = eventService;
|
|
35
|
+
if (ssl) {
|
|
36
|
+
this.sslConfig = ssl;
|
|
37
|
+
this.initSslSocket();
|
|
38
|
+
}
|
|
39
|
+
this.initSocket();
|
|
40
|
+
}
|
|
41
|
+
get isReady() {
|
|
42
|
+
const isWsReady = this.currentPort !== 0;
|
|
43
|
+
const isWssReady = this.currentSslPort !== 0;
|
|
44
|
+
return this.sslConfig ? isWsReady && isWssReady : isWsReady;
|
|
45
|
+
}
|
|
46
|
+
sendMessageToClient(clientId, envelop) {
|
|
47
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
48
|
+
const ws = this.clients[clientId];
|
|
49
|
+
if (!ws) {
|
|
50
|
+
throw new errors_1.ServiceError('4001');
|
|
51
|
+
}
|
|
52
|
+
let data = envelop.data;
|
|
53
|
+
if (envelop.secure) {
|
|
54
|
+
if (!this.pairingService.isClientConfirmed(clientId)) {
|
|
55
|
+
this.sendMessage(ws, (0, socket_service_1.buildOutgoingSocketMessage)('requestPairing', undefined));
|
|
56
|
+
return;
|
|
57
|
+
}
|
|
58
|
+
try {
|
|
59
|
+
data = yield this.pairingService.encryptDataForClient(clientId, JSON.stringify(data));
|
|
60
|
+
}
|
|
61
|
+
catch (error) {
|
|
62
|
+
this.logger.debug(error);
|
|
63
|
+
this.sendMessage(ws, (0, socket_service_1.buildOutgoingSocketMessage)('requestPairing', undefined));
|
|
64
|
+
return;
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
this.sendMessage(ws, Object.assign(Object.assign({}, envelop), { data }));
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
broadcastMessageToAll(envelop) {
|
|
71
|
+
var _a, _b;
|
|
72
|
+
if (envelop.secure) {
|
|
73
|
+
throw new errors_1.ServiceError('4002');
|
|
74
|
+
}
|
|
75
|
+
(_b = (_a = this.server) === null || _a === void 0 ? void 0 : _a.clients) === null || _b === void 0 ? void 0 : _b.forEach((ws) => {
|
|
76
|
+
if (ws.readyState === ws_1.WebSocket.OPEN) {
|
|
77
|
+
this.sendMessage(ws, envelop);
|
|
78
|
+
}
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
broadcastToAllExcept(clientId, envelop) {
|
|
82
|
+
if (envelop.secure) {
|
|
83
|
+
throw new errors_1.ServiceError('4002');
|
|
84
|
+
}
|
|
85
|
+
Object.keys(this.clients)
|
|
86
|
+
.filter((id) => id !== clientId)
|
|
87
|
+
.forEach((id) => {
|
|
88
|
+
if (this.clients[id].readyState === ws_1.WebSocket.OPEN) {
|
|
89
|
+
this.sendMessage(this.clients[id], envelop);
|
|
90
|
+
}
|
|
91
|
+
});
|
|
92
|
+
}
|
|
93
|
+
initSocket() {
|
|
94
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
95
|
+
this.currentPort = 0;
|
|
96
|
+
for (const port of config_1.WEBSOCKET_PORTS) {
|
|
97
|
+
try {
|
|
98
|
+
const isSuccess = yield this.initSocketOnPort(port);
|
|
99
|
+
if (isSuccess) {
|
|
100
|
+
this.currentPort = port;
|
|
101
|
+
return;
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
catch (error) {
|
|
105
|
+
//
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
});
|
|
109
|
+
}
|
|
110
|
+
initSslSocket() {
|
|
111
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
112
|
+
this.currentSslPort = 0;
|
|
113
|
+
for (const port of config_1.WEBSOCKET_SSL_PORTS) {
|
|
114
|
+
try {
|
|
115
|
+
const isSuccess = yield this.initSocketOnPort(port, true);
|
|
116
|
+
if (isSuccess) {
|
|
117
|
+
this.currentSslPort = port;
|
|
118
|
+
return;
|
|
119
|
+
}
|
|
120
|
+
}
|
|
121
|
+
catch (error) {
|
|
122
|
+
this.logger.debug(error);
|
|
123
|
+
}
|
|
124
|
+
}
|
|
125
|
+
});
|
|
126
|
+
}
|
|
127
|
+
// ---------------------- PRIVATE METHODS ----------------------
|
|
128
|
+
initSocketOnPort(port, enableSsl) {
|
|
129
|
+
return new Promise((resolve) => {
|
|
130
|
+
// Host API server
|
|
131
|
+
const apiHandler = (req, res) => {
|
|
132
|
+
if (req.method === 'GET' && req.url === '/ping-locker-desktop') {
|
|
133
|
+
res.writeHead(200, { 'Content-Type': 'application/json' });
|
|
134
|
+
res.end(JSON.stringify({
|
|
135
|
+
message: 'pong',
|
|
136
|
+
alias: this.serviceAlias,
|
|
137
|
+
port: this.currentPort,
|
|
138
|
+
sslPort: this.currentSslPort,
|
|
139
|
+
}));
|
|
140
|
+
}
|
|
141
|
+
else {
|
|
142
|
+
res.writeHead(404, { 'Content-Type': 'text/plain' });
|
|
143
|
+
res.end('Not Found');
|
|
144
|
+
}
|
|
145
|
+
};
|
|
146
|
+
const server = enableSsl && this.sslConfig
|
|
147
|
+
? https_1.default.createServer(this.sslConfig, apiHandler)
|
|
148
|
+
: http_1.default.createServer(apiHandler);
|
|
149
|
+
server.listen(port);
|
|
150
|
+
// Init socket
|
|
151
|
+
const wss = new ws_1.WebSocketServer({ server });
|
|
152
|
+
const debugName = `Socket${enableSsl ? ' with SSL' : ''}`;
|
|
153
|
+
wss.on('listening', () => {
|
|
154
|
+
this.logger.debug(`${debugName} listening at :${port}`);
|
|
155
|
+
resolve(true);
|
|
156
|
+
});
|
|
157
|
+
wss.on('error', (err) => {
|
|
158
|
+
server.close();
|
|
159
|
+
resolve(false);
|
|
160
|
+
});
|
|
161
|
+
// Setup handler
|
|
162
|
+
wss.on('connection', (ws) => {
|
|
163
|
+
this.logger.debug(`${debugName} connected at :${port}`);
|
|
164
|
+
ws.on('error', (err) => {
|
|
165
|
+
this.logger.error(err);
|
|
166
|
+
});
|
|
167
|
+
ws.on('message', (data) => __awaiter(this, void 0, void 0, function* () {
|
|
168
|
+
this.logger.debug(`Received from ${debugName}: ${data}`);
|
|
169
|
+
try {
|
|
170
|
+
const envelop = JSON.parse(data.toString());
|
|
171
|
+
// Decrypt message if needed
|
|
172
|
+
if (envelop.secure) {
|
|
173
|
+
if (!this.pairingService.isClientConfirmed(envelop.clientId)) {
|
|
174
|
+
this.sendMessage(ws, (0, socket_service_1.buildOutgoingSocketMessage)('requestPairing', undefined));
|
|
175
|
+
return;
|
|
176
|
+
}
|
|
177
|
+
try {
|
|
178
|
+
const decData = yield this.pairingService.decryptDataFromClient(envelop.clientId, envelop.data);
|
|
179
|
+
envelop.data = JSON.parse(decData);
|
|
180
|
+
}
|
|
181
|
+
catch (error) {
|
|
182
|
+
this.logger.debug(error);
|
|
183
|
+
this.sendMessage(ws, (0, socket_service_1.buildOutgoingSocketMessage)('requestPairing', undefined));
|
|
184
|
+
return;
|
|
185
|
+
}
|
|
186
|
+
}
|
|
187
|
+
this.handleMessage(ws, envelop);
|
|
188
|
+
}
|
|
189
|
+
catch (error) {
|
|
190
|
+
this.logger.debug(`Invalid message: ${JSON.stringify(data)} - Error: ${error}`);
|
|
191
|
+
}
|
|
192
|
+
}));
|
|
193
|
+
});
|
|
194
|
+
this.server = wss;
|
|
195
|
+
});
|
|
196
|
+
}
|
|
197
|
+
sendMessage(ws, envelop) {
|
|
198
|
+
this.logger.debug(`Send ${envelop.message}: ${JSON.stringify(envelop.data)}`);
|
|
199
|
+
ws.send(JSON.stringify(envelop));
|
|
200
|
+
}
|
|
201
|
+
handleMessage(ws, envelop) {
|
|
202
|
+
var _a, _b, _c;
|
|
203
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
204
|
+
if (envelop.clientId) {
|
|
205
|
+
this.clients[envelop.clientId] = ws;
|
|
206
|
+
}
|
|
207
|
+
switch (envelop.message) {
|
|
208
|
+
// Ping
|
|
209
|
+
case 'ping':
|
|
210
|
+
this.sendMessage(ws, (0, socket_service_1.buildOutgoingSocketMessage)('pingResponse', envelop.data));
|
|
211
|
+
this.eventService.emit('clientPing', envelop.data);
|
|
212
|
+
break;
|
|
213
|
+
// Pairing request
|
|
214
|
+
case 'pairingRequest': {
|
|
215
|
+
const d = envelop.data;
|
|
216
|
+
const res = yield this.pairingService.getResponseForPairingRequest(envelop.clientId, d.key, d.clientType || 'web');
|
|
217
|
+
this.sendMessage(ws, res);
|
|
218
|
+
break;
|
|
219
|
+
}
|
|
220
|
+
// When a user login in any client
|
|
221
|
+
case 'userLogin': {
|
|
222
|
+
// Ignore unconfirmed client
|
|
223
|
+
if (!this.pairingService.isClientConfirmed(envelop.clientId)) {
|
|
224
|
+
break;
|
|
225
|
+
}
|
|
226
|
+
const d = envelop.data;
|
|
227
|
+
if (d.email !== ((_a = this.userService.currentUser) === null || _a === void 0 ? void 0 : _a.email)) {
|
|
228
|
+
const cred = yield this.userService.getCurrentUser();
|
|
229
|
+
if (cred) {
|
|
230
|
+
this.eventService.emit('userLogin', cred);
|
|
231
|
+
}
|
|
232
|
+
}
|
|
233
|
+
// Notify other clients
|
|
234
|
+
this.broadcastToAllExcept(envelop.clientId, (0, socket_service_1.buildOutgoingSocketMessage)('userLogin', { email: d.email }));
|
|
235
|
+
break;
|
|
236
|
+
}
|
|
237
|
+
// When a user logout in any client
|
|
238
|
+
case 'userLogout': {
|
|
239
|
+
// Ignore unconfirmed client
|
|
240
|
+
if (!this.pairingService.isClientConfirmed(envelop.clientId)) {
|
|
241
|
+
break;
|
|
242
|
+
}
|
|
243
|
+
const d = envelop.data;
|
|
244
|
+
if (d.email === ((_b = this.userService.currentUser) === null || _b === void 0 ? void 0 : _b.email)) {
|
|
245
|
+
yield this.userService.logout(true);
|
|
246
|
+
this.eventService.emit('userLogout', { email: d.email });
|
|
247
|
+
}
|
|
248
|
+
// Notify other clients
|
|
249
|
+
this.broadcastToAllExcept(envelop.clientId, (0, socket_service_1.buildOutgoingSocketMessage)('userLogout', { email: d.email }));
|
|
250
|
+
break;
|
|
251
|
+
}
|
|
252
|
+
// When a user lock in any client
|
|
253
|
+
case 'userLock': {
|
|
254
|
+
// Ignore unconfirmed client
|
|
255
|
+
if (!this.pairingService.isClientConfirmed(envelop.clientId)) {
|
|
256
|
+
break;
|
|
257
|
+
}
|
|
258
|
+
const d = envelop.data;
|
|
259
|
+
if (d.email === ((_c = this.userService.currentUser) === null || _c === void 0 ? void 0 : _c.email)) {
|
|
260
|
+
yield this.userService.lock(true);
|
|
261
|
+
this.eventService.emit('userLock', { email: d.email });
|
|
262
|
+
}
|
|
263
|
+
// Notify other clients
|
|
264
|
+
this.broadcastToAllExcept(envelop.clientId, (0, socket_service_1.buildOutgoingSocketMessage)('userLock', { email: d.email }));
|
|
265
|
+
break;
|
|
266
|
+
}
|
|
267
|
+
// Custom message
|
|
268
|
+
case 'customMessage': {
|
|
269
|
+
const d = envelop.data;
|
|
270
|
+
this.eventService.emit('customMessageReceived', d);
|
|
271
|
+
this.broadcastToAllExcept(envelop.clientId, (0, socket_service_1.buildOutgoingSocketMessage)('customMessage', d));
|
|
272
|
+
break;
|
|
273
|
+
}
|
|
274
|
+
default:
|
|
275
|
+
this.logger.debug(`Invalid message: ${envelop.message} - data: ${envelop.data}`);
|
|
276
|
+
}
|
|
277
|
+
});
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
exports.SocketService = SocketService;
|
|
@@ -0,0 +1,134 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.UserService = void 0;
|
|
13
|
+
const errors_1 = require("../abstractions/errors");
|
|
14
|
+
const locker_service_grpc_1 = require("../proto/locker-service-grpc");
|
|
15
|
+
const STORAGE_KEY = 'service_current_user';
|
|
16
|
+
var LoginSyncMessage;
|
|
17
|
+
(function (LoginSyncMessage) {
|
|
18
|
+
LoginSyncMessage["LOGIN"] = "loginSuccess";
|
|
19
|
+
LoginSyncMessage["LOGOUT"] = "logoutSuccess";
|
|
20
|
+
LoginSyncMessage["GET_USER"] = "storedCredRequest";
|
|
21
|
+
})(LoginSyncMessage || (LoginSyncMessage = {}));
|
|
22
|
+
class UserService {
|
|
23
|
+
constructor(services) {
|
|
24
|
+
this.currentUser = null;
|
|
25
|
+
this.isLocked = true;
|
|
26
|
+
this.isReady = false;
|
|
27
|
+
const { logger, storageService, grpcService } = services;
|
|
28
|
+
this.logger = logger;
|
|
29
|
+
this.storage = storageService;
|
|
30
|
+
this.grpc = grpcService;
|
|
31
|
+
this.loadFromStore().then(() => (this.isReady = true));
|
|
32
|
+
}
|
|
33
|
+
login(data) {
|
|
34
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
35
|
+
yield Promise.all([this.loginService(data), this.setUser(data)]);
|
|
36
|
+
this.isLocked = false;
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
logout(localOnly) {
|
|
40
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
41
|
+
if (localOnly) {
|
|
42
|
+
yield this.setUser(null);
|
|
43
|
+
}
|
|
44
|
+
else {
|
|
45
|
+
yield Promise.all([this.logoutService(), this.setUser(null)]);
|
|
46
|
+
}
|
|
47
|
+
this.isLocked = true;
|
|
48
|
+
});
|
|
49
|
+
}
|
|
50
|
+
lock(localOnly) {
|
|
51
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
52
|
+
// TODO
|
|
53
|
+
this.isLocked = true;
|
|
54
|
+
});
|
|
55
|
+
}
|
|
56
|
+
getCurrentUser() {
|
|
57
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
58
|
+
const res = yield this.getCurrentUserFromService();
|
|
59
|
+
yield this.setUser(res);
|
|
60
|
+
return res;
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
// ---------------------- PRIVATE METHODS ----------------------
|
|
64
|
+
getCurrentUserFromService() {
|
|
65
|
+
const req = new locker_service_grpc_1.locker_service_grpc.LoginSyncRequest();
|
|
66
|
+
req.message = LoginSyncMessage.GET_USER;
|
|
67
|
+
return new Promise((resolve, reject) => {
|
|
68
|
+
this.grpc.client.LoginSyncChannel(req, (err, res) => {
|
|
69
|
+
this.logger.debug(res);
|
|
70
|
+
if (err) {
|
|
71
|
+
reject(errors_1.ServiceError.fromError(err));
|
|
72
|
+
return;
|
|
73
|
+
}
|
|
74
|
+
resolve((res === null || res === void 0 ? void 0 : res.email)
|
|
75
|
+
? {
|
|
76
|
+
email: res.email,
|
|
77
|
+
key: res.key,
|
|
78
|
+
hashedPassword: res.hashed_pass,
|
|
79
|
+
}
|
|
80
|
+
: null);
|
|
81
|
+
});
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
loginService(data) {
|
|
85
|
+
const req = new locker_service_grpc_1.locker_service_grpc.LoginSyncRequest();
|
|
86
|
+
req.message = LoginSyncMessage.LOGIN;
|
|
87
|
+
req.email = data.email;
|
|
88
|
+
req.key = data.key;
|
|
89
|
+
req.hashed_pass = data.hashedPassword;
|
|
90
|
+
return new Promise((resolve, reject) => {
|
|
91
|
+
this.grpc.client.LoginSyncChannel(req, (err, res) => {
|
|
92
|
+
this.logger.debug(res);
|
|
93
|
+
if (err) {
|
|
94
|
+
reject(errors_1.ServiceError.fromError(err));
|
|
95
|
+
return;
|
|
96
|
+
}
|
|
97
|
+
resolve();
|
|
98
|
+
});
|
|
99
|
+
});
|
|
100
|
+
}
|
|
101
|
+
logoutService() {
|
|
102
|
+
const req = new locker_service_grpc_1.locker_service_grpc.LoginSyncRequest();
|
|
103
|
+
req.message = LoginSyncMessage.LOGOUT;
|
|
104
|
+
return new Promise((resolve, reject) => {
|
|
105
|
+
this.grpc.client.LoginSyncChannel(req, (err, res) => {
|
|
106
|
+
this.logger.debug(res);
|
|
107
|
+
if (err) {
|
|
108
|
+
reject(errors_1.ServiceError.fromError(err));
|
|
109
|
+
return;
|
|
110
|
+
}
|
|
111
|
+
resolve();
|
|
112
|
+
});
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
setUser(data) {
|
|
116
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
117
|
+
this.currentUser = data;
|
|
118
|
+
yield this.saveToStore();
|
|
119
|
+
});
|
|
120
|
+
}
|
|
121
|
+
loadFromStore() {
|
|
122
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
123
|
+
const data = yield this.storage.getSecure(STORAGE_KEY);
|
|
124
|
+
if (data) {
|
|
125
|
+
this.currentUser = data;
|
|
126
|
+
}
|
|
127
|
+
this.isLocked = !(data === null || data === void 0 ? void 0 : data.key);
|
|
128
|
+
});
|
|
129
|
+
}
|
|
130
|
+
saveToStore() {
|
|
131
|
+
return this.storage.setSecure(STORAGE_KEY, this.currentUser);
|
|
132
|
+
}
|
|
133
|
+
}
|
|
134
|
+
exports.UserService = UserService;
|
|
@@ -0,0 +1,40 @@
|
|
|
1
|
+
import { OS, OmitKeys } from '../misc/utils';
|
|
2
|
+
export type PasswordlessType = 'prf' | 'hmac';
|
|
3
|
+
export type GetPublicPwlCredentialResponse = {
|
|
4
|
+
credential_id: string | null;
|
|
5
|
+
random: string | null;
|
|
6
|
+
name: string | null;
|
|
7
|
+
creation_date: number | null;
|
|
8
|
+
last_use_date: number | null;
|
|
9
|
+
type: PasswordlessType;
|
|
10
|
+
backup_keys: {
|
|
11
|
+
name: string;
|
|
12
|
+
credential_id: string;
|
|
13
|
+
random: string;
|
|
14
|
+
creation_date: number | null;
|
|
15
|
+
last_use_date: number | null;
|
|
16
|
+
type: PasswordlessType;
|
|
17
|
+
}[];
|
|
18
|
+
};
|
|
19
|
+
export type BackupKey = {
|
|
20
|
+
id: string;
|
|
21
|
+
name: string;
|
|
22
|
+
creation_date: number | null;
|
|
23
|
+
last_use_date: number | null;
|
|
24
|
+
master_password_hash: string;
|
|
25
|
+
key: string;
|
|
26
|
+
fd_credential_id: string;
|
|
27
|
+
fd_random: string;
|
|
28
|
+
type: PasswordlessType;
|
|
29
|
+
};
|
|
30
|
+
export type GetReleasesResponse = {
|
|
31
|
+
version: string;
|
|
32
|
+
environment: string;
|
|
33
|
+
platform: OS;
|
|
34
|
+
checksum: {
|
|
35
|
+
desktop: string;
|
|
36
|
+
service: string;
|
|
37
|
+
};
|
|
38
|
+
}[];
|
|
39
|
+
export type SetBackupPwlParams = OmitKeys<BackupKey, 'creation_date' | 'last_use_date' | 'id'>;
|
|
40
|
+
//# sourceMappingURL=api.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"api.service.d.ts","sourceRoot":"","sources":["../../../../src/abstractions/api.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,EAAE,EAAE,QAAQ,EAAE,MAAM,eAAe,CAAA;AAE5C,MAAM,MAAM,gBAAgB,GAAG,KAAK,GAAG,MAAM,CAAA;AAE7C,MAAM,MAAM,8BAA8B,GAAG;IAC3C,aAAa,EAAE,MAAM,GAAG,IAAI,CA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|
4
|
+
};
|
|
5
|
+
export declare const AES: {
|
|
6
|
+
name: string;
|
|
7
|
+
};
|
|
8
|
+
export declare enum KdfType {
|
|
9
|
+
PBKDF2_SHA256 = 0
|
|
10
|
+
}
|
|
11
|
+
export declare enum EncryptionType {
|
|
12
|
+
AesCbc256_B64 = 0,
|
|
13
|
+
AesCbc128_HmacSha256_B64 = 1,
|
|
14
|
+
AesCbc256_HmacSha256_B64 = 2,
|
|
15
|
+
Rsa2048_OaepSha256_B64 = 3,
|
|
16
|
+
Rsa2048_OaepSha1_B64 = 4,
|
|
17
|
+
Rsa2048_OaepSha256_HmacSha256_B64 = 5,
|
|
18
|
+
Rsa2048_OaepSha1_HmacSha256_B64 = 6
|
|
19
|
+
}
|
|
20
|
+
export declare class SymmetricCryptoKey {
|
|
21
|
+
key: ArrayBuffer;
|
|
22
|
+
encKey?: ArrayBuffer;
|
|
23
|
+
macKey?: ArrayBuffer;
|
|
24
|
+
encType: EncryptionType;
|
|
25
|
+
keyB64: string;
|
|
26
|
+
encKeyB64: string;
|
|
27
|
+
macKeyB64: string;
|
|
28
|
+
meta: any;
|
|
29
|
+
constructor(key: ArrayBuffer, encType?: EncryptionType);
|
|
30
|
+
}
|
|
31
|
+
export declare class EncString {
|
|
32
|
+
encryptedString?: string;
|
|
33
|
+
encryptionType?: EncryptionType;
|
|
34
|
+
decryptedValue?: string;
|
|
35
|
+
data?: string;
|
|
36
|
+
iv?: string;
|
|
37
|
+
mac?: string;
|
|
38
|
+
constructor(encryptedStringOrType: string | EncryptionType, data?: string, iv?: string, mac?: string);
|
|
39
|
+
}
|
|
40
|
+
export declare class EncryptedObject {
|
|
41
|
+
iv: ArrayBuffer;
|
|
42
|
+
data: ArrayBuffer;
|
|
43
|
+
mac: ArrayBuffer;
|
|
44
|
+
key: SymmetricCryptoKey;
|
|
45
|
+
}
|
|
46
|
+
//# sourceMappingURL=crypto.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"cr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@@
|
|
|
1
|
+
export declare class ServiceError extends Error {
|
|
2
|
+
code: ErrorCode;
|
|
3
|
+
message: string;
|
|
4
|
+
rawError?: any;
|
|
5
|
+
constructor(code: ErrorCode, rawError?: any);
|
|
6
|
+
static fromError(rawError: any): ServiceError;
|
|
7
|
+
}
|
|
8
|
+
export type ErrorCode = keyof typeof ERRORS;
|
|
9
|
+
export declare const ERRORS: {
|
|
10
|
+
'0000': {
|
|
11
|
+
message: string;
|
|
12
|
+
};
|
|
13
|
+
'1000': {
|
|
14
|
+
message: string;
|
|
15
|
+
};
|
|
16
|
+
'1001': {
|
|
17
|
+
message: string;
|
|
18
|
+
};
|
|
19
|
+
'1002': {
|
|
20
|
+
message: string;
|
|
21
|
+
};
|
|
22
|
+
'2001': {
|
|
23
|
+
message: string;
|
|
24
|
+
};
|
|
25
|
+
'2002': {
|
|
26
|
+
message: string;
|
|
27
|
+
};
|
|
28
|
+
'2003': {
|
|
29
|
+
message: string;
|
|
30
|
+
signatures: string[];
|
|
31
|
+
};
|
|
32
|
+
'2004': {
|
|
33
|
+
message: string;
|
|
34
|
+
signatures: string[];
|
|
35
|
+
};
|
|
36
|
+
'2005': {
|
|
37
|
+
message: string;
|
|
38
|
+
};
|
|
39
|
+
'2006': {
|
|
40
|
+
message: string;
|
|
41
|
+
signatures: string[];
|
|
42
|
+
};
|
|
43
|
+
'2007': {
|
|
44
|
+
message: string;
|
|
45
|
+
signatures: string[];
|
|
46
|
+
};
|
|
47
|
+
'2008': {
|
|
48
|
+
message: string;
|
|
49
|
+
signatures: string[];
|
|
50
|
+
};
|
|
51
|
+
'2009': {
|
|
52
|
+
message: string;
|
|
53
|
+
signatures: string[];
|
|
54
|
+
};
|
|
55
|
+
'2010': {
|
|
56
|
+
message: string;
|
|
57
|
+
signatures: string[];
|
|
58
|
+
};
|
|
59
|
+
'2011': {
|
|
60
|
+
message: string;
|
|
61
|
+
signatures: string[];
|
|
62
|
+
};
|
|
63
|
+
'3001': {
|
|
64
|
+
message: string;
|
|
65
|
+
};
|
|
66
|
+
'4001': {
|
|
67
|
+
message: string;
|
|
68
|
+
};
|
|
69
|
+
'4002': {
|
|
70
|
+
message: string;
|
|
71
|
+
};
|
|
72
|
+
};
|
|
73
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../../../../src/abstractions/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,YAAa,SAAQ,KAAK;IACrC,IAAI,EAAE,SAAS,CAAA;IACf,OAAO,EAAE,MAAM,CAAA;IAEf,QAAQ,CAAC,EAAE,GAAG,CAAA;gBAEF,IAAI,EAAE,SAAS,EAAE,QAAQ,CAAC,EAAE,GAAG;IAa3C,MAAM,CAAC,SAAS,CAAC,QAAQ,EAAE,GAAG;CAc/B;AAED,MAAM,MAAM,SAAS,GAAG,MAAM,OAAO,MAAM,CAAA;AAE3C,eAAO,MAAM,MAAM;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CA2ElB,CAAA"}
|
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { ClientType } from '.';
|
|
2
|
+
import { UserCredentials } from '../services/user.service';
|
|
3
|
+
export type Event = 'clientPing' | 'serviceReady' | 'fidoRequestFingerprint' | 'fidoRequestTouch' | 'pairingConfirmation' | 'userLogin' | 'userLogout' | 'userLock' | 'customMessageReceived';
|
|
4
|
+
export interface EventArguments {
|
|
5
|
+
clientPing: any;
|
|
6
|
+
serviceReady: undefined;
|
|
7
|
+
fidoRequestFingerprint: undefined;
|
|
8
|
+
fidoRequestTouch: undefined;
|
|
9
|
+
pairingConfirmation: {
|
|
10
|
+
clientId: string;
|
|
11
|
+
approveCode: string;
|
|
12
|
+
clientType: ClientType;
|
|
13
|
+
};
|
|
14
|
+
userLogin: UserCredentials;
|
|
15
|
+
userLogout: {
|
|
16
|
+
email: string;
|
|
17
|
+
};
|
|
18
|
+
userLock: {
|
|
19
|
+
email: string;
|
|
20
|
+
};
|
|
21
|
+
customMessageReceived: any;
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=event.service.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"event.service.d.ts","sourceRoot":"","sources":["../../../../src/abstractions/event.service.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,GAAG,CAAA;AAC9B,OAAO,EAAE,eAAe,EAAE,MAAM,0BAA0B,CAAA;AAE1D,MAAM,MAAM,KAAK,GACb,YAAY,GACZ,cAAc,GACd,wBAAwB,GACxB,kBAAkB,GAClB,qBAAqB,GACrB,WAAW,GACX,YAAY,GACZ,UAAU,GACV,uBAAuB,CAAA;AAE3B,MAAM,WAAW,cAAc;IAC7B,UAAU,EAAE,GAAG,CAAA;IACf,YAAY,EAAE,SAAS,CAAA;IACvB,sBAAsB,EAAE,SAAS,CAAA;IACjC,gBAAgB,EAAE,SAAS,CAAA;IAC3B,mBAAmB,EAAE;QACnB,QAAQ,EAAE,MAAM,CAAA;QAChB,WAAW,EAAE,MAAM,CAAA;QACnB,UAAU,EAAE,UAAU,CAAA;KACvB,CAAA;IACD,SAAS,EAAE,eAAe,CAAA;IAC1B,UAAU,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC7B,QAAQ,EAAE;QAAE,KAAK,EAAE,MAAM,CAAA;KAAE,CAAA;IAC3B,qBAAqB,EAAE,GAAG,CAAA;CAC3B"}
|
|
@@ -0,0 +1,56 @@
|
|
|
1
|
+
import { BackupKey } from './api.service';
|
|
2
|
+
export interface IDesktopService {
|
|
3
|
+
waitUntilReady: () => Promise<boolean>;
|
|
4
|
+
login: (params: {
|
|
5
|
+
email: string;
|
|
6
|
+
key: string;
|
|
7
|
+
hashedPassword: string;
|
|
8
|
+
}) => Promise<void>;
|
|
9
|
+
logout: () => Promise<void>;
|
|
10
|
+
lock: () => Promise<void>;
|
|
11
|
+
getCurrentUser: () => Promise<{
|
|
12
|
+
email: string;
|
|
13
|
+
key: string;
|
|
14
|
+
hashedPassword: string;
|
|
15
|
+
} | null>;
|
|
16
|
+
setApiToken: (token: string) => void;
|
|
17
|
+
setNewPasswordless: (params: {
|
|
18
|
+
devicePath: string;
|
|
19
|
+
deviceName: string;
|
|
20
|
+
email: string;
|
|
21
|
+
name: string;
|
|
22
|
+
pin?: string;
|
|
23
|
+
}) => Promise<string>;
|
|
24
|
+
deletePasswordless: () => Promise<void>;
|
|
25
|
+
getFidoDeviceList: () => Promise<{
|
|
26
|
+
name: string;
|
|
27
|
+
path: string;
|
|
28
|
+
}[]>;
|
|
29
|
+
getPasswordless: (params: {
|
|
30
|
+
email: string;
|
|
31
|
+
pin?: string;
|
|
32
|
+
devicePath: string;
|
|
33
|
+
}) => Promise<string>;
|
|
34
|
+
setBackupPasswordless: (params: {
|
|
35
|
+
deviceName: string;
|
|
36
|
+
devicePath: string;
|
|
37
|
+
email: string;
|
|
38
|
+
name: string;
|
|
39
|
+
currentEncKey: ArrayBuffer;
|
|
40
|
+
pin?: string;
|
|
41
|
+
}) => Promise<string>;
|
|
42
|
+
listAllPasswordless: (email: string) => Promise<(BackupKey & {
|
|
43
|
+
isPrimary?: boolean;
|
|
44
|
+
})[]>;
|
|
45
|
+
listBackupPasswordless: () => Promise<BackupKey[]>;
|
|
46
|
+
deleteBackupPasswordless: (id: string) => Promise<void>;
|
|
47
|
+
resetPairingCode: (clientId: string) => Promise<void>;
|
|
48
|
+
confirmPairingClient: (clientId: string, clientType: ClientType) => Promise<void>;
|
|
49
|
+
resetSocket: () => Promise<void>;
|
|
50
|
+
resetGRPC: () => Promise<void>;
|
|
51
|
+
sendCustomMessage: (data: any) => Promise<void>;
|
|
52
|
+
getCacheData: () => Promise<any>;
|
|
53
|
+
setCacheData: (data: any) => Promise<void>;
|
|
54
|
+
}
|
|
55
|
+
export type ClientType = 'web' | 'extension';
|
|
56
|
+
//# sourceMapping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