@lockerpm/desktop-service 1.1.5 → 2.1.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/lib/cjs/abstractions/crypto.service.js +1 -0
- package/lib/cjs/index.js +11 -0
- package/lib/cjs/services/api.service.js +36 -0
- package/lib/cjs/services/core-crypto.service.js +20 -3
- package/lib/cjs/services/crypto.service.js +6 -10
- package/lib/cjs/types/abstractions/api.service.d.ts +44 -1
- package/lib/cjs/types/abstractions/api.service.d.ts.map +1 -1
- package/lib/cjs/types/abstractions/crypto.service.d.ts +2 -1
- package/lib/cjs/types/abstractions/crypto.service.d.ts.map +1 -1
- package/lib/cjs/types/abstractions/index.d.ts +33 -2
- package/lib/cjs/types/abstractions/index.d.ts.map +1 -1
- package/lib/cjs/types/index.d.ts +34 -2
- package/lib/cjs/types/index.d.ts.map +1 -1
- package/lib/cjs/types/proto/locker-service-grpc.d.ts +1 -0
- package/lib/cjs/types/proto/locker-service-grpc.d.ts.map +1 -1
- package/lib/cjs/types/services/api.service.d.ts +3 -1
- package/lib/cjs/types/services/api.service.d.ts.map +1 -1
- package/lib/cjs/types/services/core-crypto.service.d.ts +2 -1
- package/lib/cjs/types/services/core-crypto.service.d.ts.map +1 -1
- package/lib/cjs/types/services/crypto.service.d.ts.map +1 -1
- package/lib/cjs/types/services/grpc.service.d.ts +1 -0
- package/lib/cjs/types/services/grpc.service.d.ts.map +1 -1
- package/lib/cjs/types/services/socket.service.d.ts +1 -0
- package/lib/cjs/types/services/socket.service.d.ts.map +1 -1
- package/lib/cjs/types/usecases/fido.d.ts +43 -3
- package/lib/cjs/types/usecases/fido.d.ts.map +1 -1
- package/lib/cjs/usecases/fido.js +124 -11
- package/lib/esm/abstractions/api.service.js +1 -2
- package/lib/esm/abstractions/crypto.service.js +14 -19
- package/lib/esm/abstractions/errors.js +4 -8
- package/lib/esm/abstractions/event.service.js +1 -2
- package/lib/esm/abstractions/index.js +1 -2
- package/lib/esm/abstractions/socket.service.js +1 -5
- package/lib/esm/abstractions/storage.service.js +1 -2
- package/lib/esm/index.mjs +45 -38
- package/lib/esm/misc/config.js +5 -8
- package/lib/esm/misc/utils.js +4 -11
- package/lib/esm/proto/google/api/annotations.js +1 -2
- package/lib/esm/proto/google/api/http.js +3 -29
- package/lib/esm/proto/google/protobuf/descriptor.js +3 -29
- package/lib/esm/proto/locker-service-grpc.js +4 -30
- package/lib/esm/services/api.service.js +61 -30
- package/lib/esm/services/cache.service.js +4 -8
- package/lib/esm/services/core-crypto.service.js +34 -26
- package/lib/esm/services/crypto.service.js +22 -33
- package/lib/esm/services/event.service.js +3 -10
- package/lib/esm/services/fido.service.js +9 -13
- package/lib/esm/services/grpc.service.js +18 -25
- package/lib/esm/services/log.service.js +3 -7
- package/lib/esm/services/pairing.service.js +8 -12
- package/lib/esm/services/socket.service.js +26 -33
- package/lib/esm/services/user.service.js +5 -9
- package/lib/esm/types/abstractions/api.service.d.ts +44 -1
- package/lib/esm/types/abstractions/api.service.d.ts.map +1 -1
- package/lib/esm/types/abstractions/crypto.service.d.ts +2 -1
- package/lib/esm/types/abstractions/crypto.service.d.ts.map +1 -1
- package/lib/esm/types/abstractions/index.d.ts +33 -2
- package/lib/esm/types/abstractions/index.d.ts.map +1 -1
- package/lib/esm/types/index.d.ts +34 -2
- package/lib/esm/types/index.d.ts.map +1 -1
- package/lib/esm/types/proto/locker-service-grpc.d.ts +1 -0
- package/lib/esm/types/proto/locker-service-grpc.d.ts.map +1 -1
- package/lib/esm/types/services/api.service.d.ts +3 -1
- package/lib/esm/types/services/api.service.d.ts.map +1 -1
- package/lib/esm/types/services/core-crypto.service.d.ts +2 -1
- package/lib/esm/types/services/core-crypto.service.d.ts.map +1 -1
- package/lib/esm/types/services/crypto.service.d.ts.map +1 -1
- package/lib/esm/types/services/grpc.service.d.ts +1 -0
- package/lib/esm/types/services/grpc.service.d.ts.map +1 -1
- package/lib/esm/types/services/socket.service.d.ts +1 -0
- package/lib/esm/types/services/socket.service.d.ts.map +1 -1
- package/lib/esm/types/usecases/fido.d.ts +43 -3
- package/lib/esm/types/usecases/fido.d.ts.map +1 -1
- package/lib/esm/usecases/fido.js +131 -29
- package/package.json +3 -1
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
import { KdfType, SymmetricCryptoKey } from '../abstractions/crypto.service';
|
|
1
2
|
import { ApiService } from '../services/api.service';
|
|
2
3
|
import { CryptoService } from '../services/crypto.service';
|
|
3
4
|
import { FidoService } from '../services/fido.service';
|
|
@@ -36,12 +37,44 @@ export declare function setBackupPasswordless(params: {
|
|
|
36
37
|
apiService: ApiService;
|
|
37
38
|
fidoService: FidoService;
|
|
38
39
|
cryptoService: CryptoService;
|
|
39
|
-
}): Promise<
|
|
40
|
+
}): Promise<{
|
|
41
|
+
secret: string;
|
|
42
|
+
kdf: KdfType;
|
|
43
|
+
kdf_iterations: number;
|
|
44
|
+
kdf_memory: number | null;
|
|
45
|
+
kdf_parallelism: number | null;
|
|
46
|
+
}>;
|
|
47
|
+
/**
|
|
48
|
+
* Remake an existing backup passwordless (fido) credential's encrypted key + password hash
|
|
49
|
+
* using the provided secret. If kdf info is not given, it is fetched from prelogin.
|
|
50
|
+
* @param params
|
|
51
|
+
* @param services
|
|
52
|
+
*/
|
|
53
|
+
export declare function remakeBackupPasswordless(params: {
|
|
54
|
+
id: string;
|
|
55
|
+
email: string;
|
|
56
|
+
currentEncKey: ArrayBuffer;
|
|
57
|
+
secret: string;
|
|
58
|
+
kdf?: KdfType;
|
|
59
|
+
kdfIterations?: number;
|
|
60
|
+
kdfMemory?: number | null;
|
|
61
|
+
kdfParallelism?: number | null;
|
|
62
|
+
}, services: {
|
|
63
|
+
apiService: ApiService;
|
|
64
|
+
cryptoService: CryptoService;
|
|
65
|
+
}): Promise<{
|
|
66
|
+
kdf: KdfType;
|
|
67
|
+
kdf_iterations: number;
|
|
68
|
+
kdf_memory: number | null;
|
|
69
|
+
kdf_parallelism: number | null;
|
|
70
|
+
key: SymmetricCryptoKey;
|
|
71
|
+
hashedPassword: string;
|
|
72
|
+
}>;
|
|
40
73
|
/**
|
|
41
74
|
* Get pwl from fido key using from a list of credentials saved on server
|
|
42
75
|
* Group credentials with the same random for batch call
|
|
43
76
|
* @param params
|
|
44
|
-
* @returns secret
|
|
77
|
+
* @returns secret + kdf info
|
|
45
78
|
*/
|
|
46
79
|
export declare function getPasswordless(params: {
|
|
47
80
|
email: string;
|
|
@@ -52,5 +85,12 @@ export declare function getPasswordless(params: {
|
|
|
52
85
|
apiService: ApiService;
|
|
53
86
|
fidoService: FidoService;
|
|
54
87
|
logService: LogService;
|
|
55
|
-
}): Promise<
|
|
88
|
+
}): Promise<{
|
|
89
|
+
secret: string;
|
|
90
|
+
kdf: KdfType;
|
|
91
|
+
kdf_iterations: number;
|
|
92
|
+
kdf_memory: number | null;
|
|
93
|
+
kdf_parallelism: number | null;
|
|
94
|
+
pwl_id: string;
|
|
95
|
+
}>;
|
|
56
96
|
//# sourceMappingURL=fido.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"fido.d.ts","sourceRoot":"","sources":["../../../../src/usecases/fido.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"fido.d.ts","sourceRoot":"","sources":["../../../../src/usecases/fido.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,OAAO,EAAE,kBAAkB,EAAE,MAAM,gCAAgC,CAAA;AAG5E,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AACpD,OAAO,EAAE,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAC1D,OAAO,EAAE,WAAW,EAAE,MAAM,0BAA0B,CAAA;AACtD,OAAO,EAAE,UAAU,EAAE,MAAM,yBAAyB,CAAA;AAEpD;;;;;GAKG;AACH,wBAAsB,kBAAkB,CACtC,MAAM,EAAE;IACN,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,GAAG,CAAC,EAAE,MAAM,CAAA;CACb,EACD,QAAQ,EAAE;IACR,UAAU,EAAE,UAAU,CAAA;IACtB,WAAW,EAAE,WAAW,CAAA;IACxB,aAAa,EAAE,aAAa,CAAA;CAC7B,mBA8CF;AAED;;;;;GAKG;AACH,wBAAsB,qBAAqB,CACzC,MAAM,EAAE;IACN,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,EAAE,MAAM,CAAA;IAClB,KAAK,EAAE,MAAM,CAAA;IACb,IAAI,EAAE,MAAM,CAAA;IACZ,aAAa,EAAE,WAAW,CAAA;IAC1B,GAAG,CAAC,EAAE,MAAM,GAAG,SAAS,CAAA;CACzB,EACD,QAAQ,EAAE;IACR,UAAU,EAAE,UAAU,CAAA;IACtB,WAAW,EAAE,WAAW,CAAA;IACxB,aAAa,EAAE,aAAa,CAAA;CAC7B;;;;;;GAyFF;AAED;;;;;GAKG;AACH,wBAAsB,wBAAwB,CAC5C,MAAM,EAAE;IACN,EAAE,EAAE,MAAM,CAAA;IACV,KAAK,EAAE,MAAM,CAAA;IACb,aAAa,EAAE,WAAW,CAAA;IAC1B,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,CAAC,EAAE,OAAO,CAAA;IACb,aAAa,CAAC,EAAE,MAAM,CAAA;IACtB,SAAS,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,cAAc,CAAC,EAAE,MAAM,GAAG,IAAI,CAAA;CAC/B,EACD,QAAQ,EAAE;IACR,UAAU,EAAE,UAAU,CAAA;IACtB,aAAa,EAAE,aAAa,CAAA;CAC7B,GACA,OAAO,CAAC;IACT,GAAG,EAAE,OAAO,CAAA;IACZ,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,GAAG,EAAE,kBAAkB,CAAA;IACvB,cAAc,EAAE,MAAM,CAAA;CACvB,CAAC,CA6DD;AAED;;;;;GAKG;AACH,wBAAsB,eAAe,CACnC,MAAM,EAAE;IACN,KAAK,EAAE,MAAM,CAAA;IACb,GAAG,CAAC,EAAE,MAAM,CAAA;IACZ,UAAU,EAAE,MAAM,CAAA;IAClB,UAAU,CAAC,EAAE,OAAO,CAAA;CACrB,EACD,QAAQ,EAAE;IACR,UAAU,EAAE,UAAU,CAAA;IACtB,WAAW,EAAE,WAAW,CAAA;IACxB,UAAU,EAAE,UAAU,CAAA;CACvB,GACA,OAAO,CAAC;IACT,MAAM,EAAE,MAAM,CAAA;IACd,GAAG,EAAE,OAAO,CAAA;IACZ,cAAc,EAAE,MAAM,CAAA;IACtB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAA;IACzB,eAAe,EAAE,MAAM,GAAG,IAAI,CAAA;IAC9B,MAAM,EAAE,MAAM,CAAA;CACf,CAAC,CAyFD"}
|
package/lib/cjs/usecases/fido.js
CHANGED
|
@@ -20,7 +20,8 @@ var __rest = (this && this.__rest) || function (s, e) {
|
|
|
20
20
|
return t;
|
|
21
21
|
};
|
|
22
22
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
23
|
-
exports.getPasswordless = exports.setBackupPasswordless = exports.setNewPasswordless = void 0;
|
|
23
|
+
exports.getPasswordless = exports.remakeBackupPasswordless = exports.setBackupPasswordless = exports.setNewPasswordless = void 0;
|
|
24
|
+
const crypto_service_1 = require("../abstractions/crypto.service");
|
|
24
25
|
const errors_1 = require("../abstractions/errors");
|
|
25
26
|
const utils_1 = require("../misc/utils");
|
|
26
27
|
/**
|
|
@@ -44,7 +45,7 @@ function setNewPasswordless(params, services) {
|
|
|
44
45
|
// Get previous random, if not found, generate a random value
|
|
45
46
|
let random = yield getPreviousRandom({ email, apiService });
|
|
46
47
|
if (!random) {
|
|
47
|
-
random = utils_1.Utils.fromBufferToHex(cryptoService.getRandomValues(16));
|
|
48
|
+
random = utils_1.Utils.fromBufferToHex(cryptoService.getRandomValues(16).buffer);
|
|
48
49
|
}
|
|
49
50
|
// Make credential
|
|
50
51
|
const { credentialId } = yield fidoService.makeCredential({
|
|
@@ -93,7 +94,7 @@ function setBackupPasswordless(params, services) {
|
|
|
93
94
|
// Get previous random, if not found, generate a random value
|
|
94
95
|
let random = yield getPreviousRandom({ email, apiService });
|
|
95
96
|
if (!random) {
|
|
96
|
-
random = utils_1.Utils.fromBufferToHex(cryptoService.getRandomValues(16));
|
|
97
|
+
random = utils_1.Utils.fromBufferToHex(cryptoService.getRandomValues(16).buffer);
|
|
97
98
|
}
|
|
98
99
|
// Create credential
|
|
99
100
|
const { credentialId } = yield fidoService.makeCredential({
|
|
@@ -110,10 +111,27 @@ function setBackupPasswordless(params, services) {
|
|
|
110
111
|
salt: random,
|
|
111
112
|
pin,
|
|
112
113
|
});
|
|
114
|
+
// Resolve KDF params: legacy accounts (kdf_version < 1) use fixed defaults;
|
|
115
|
+
// newer accounts use the algo/params returned by prelogin.
|
|
116
|
+
const prelogin = yield apiService.getPreloginInfo();
|
|
117
|
+
let kdf;
|
|
118
|
+
let kdfIterations;
|
|
119
|
+
let kdfMemory;
|
|
120
|
+
let kdfParallelism;
|
|
121
|
+
if (prelogin.kdf_version < 1) {
|
|
122
|
+
kdf = crypto_service_1.KdfType.PBKDF2_SHA256;
|
|
123
|
+
kdfIterations = 100000;
|
|
124
|
+
kdfMemory = null;
|
|
125
|
+
kdfParallelism = null;
|
|
126
|
+
}
|
|
127
|
+
else {
|
|
128
|
+
kdf = prelogin.kdf;
|
|
129
|
+
kdfIterations = prelogin.kdf_iterations;
|
|
130
|
+
kdfMemory = prelogin.kdf_memory;
|
|
131
|
+
kdfParallelism = prelogin.kdf_parallelism;
|
|
132
|
+
}
|
|
113
133
|
// Create new encrypted key hash and password hash
|
|
114
|
-
const
|
|
115
|
-
const kdfIterations = 100000;
|
|
116
|
-
const key = yield cryptoService.core.makeKey(secret, email, kdf, kdfIterations);
|
|
134
|
+
const key = yield cryptoService.core.makeKey(secret, email, kdf, kdfIterations, kdfMemory !== null && kdfMemory !== void 0 ? kdfMemory : undefined, kdfParallelism !== null && kdfParallelism !== void 0 ? kdfParallelism : undefined);
|
|
117
135
|
const newPwHash = yield cryptoService.core.hashPassword(secret, key);
|
|
118
136
|
const encKey = yield cryptoService.core.remakeEncKey(currentEncKey, key);
|
|
119
137
|
// Send API
|
|
@@ -124,18 +142,92 @@ function setBackupPasswordless(params, services) {
|
|
|
124
142
|
master_password_hash: newPwHash,
|
|
125
143
|
name: deviceName,
|
|
126
144
|
type: 'hmac',
|
|
145
|
+
kdf,
|
|
146
|
+
kdf_iterations: kdfIterations,
|
|
147
|
+
kdf_memory: kdfMemory,
|
|
148
|
+
kdf_parallelism: kdfParallelism,
|
|
127
149
|
});
|
|
128
|
-
return
|
|
150
|
+
return {
|
|
151
|
+
secret,
|
|
152
|
+
kdf,
|
|
153
|
+
kdf_iterations: kdfIterations,
|
|
154
|
+
kdf_memory: kdfMemory,
|
|
155
|
+
kdf_parallelism: kdfParallelism,
|
|
156
|
+
};
|
|
129
157
|
});
|
|
130
158
|
}
|
|
131
159
|
exports.setBackupPasswordless = setBackupPasswordless;
|
|
160
|
+
/**
|
|
161
|
+
* Remake an existing backup passwordless (fido) credential's encrypted key + password hash
|
|
162
|
+
* using the provided secret. If kdf info is not given, it is fetched from prelogin.
|
|
163
|
+
* @param params
|
|
164
|
+
* @param services
|
|
165
|
+
*/
|
|
166
|
+
function remakeBackupPasswordless(params, services) {
|
|
167
|
+
var _a, _b;
|
|
168
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
169
|
+
const { apiService, cryptoService } = services;
|
|
170
|
+
if (!apiService.token) {
|
|
171
|
+
throw new errors_1.ServiceError('1001');
|
|
172
|
+
}
|
|
173
|
+
const { id, email, currentEncKey, secret } = params;
|
|
174
|
+
// Resolve KDF params from caller; fall back to prelogin when not provided.
|
|
175
|
+
let kdf;
|
|
176
|
+
let kdfIterations;
|
|
177
|
+
let kdfMemory;
|
|
178
|
+
let kdfParallelism;
|
|
179
|
+
if (params.kdf !== undefined && params.kdfIterations !== undefined) {
|
|
180
|
+
kdf = params.kdf;
|
|
181
|
+
kdfIterations = params.kdfIterations;
|
|
182
|
+
kdfMemory = (_a = params.kdfMemory) !== null && _a !== void 0 ? _a : null;
|
|
183
|
+
kdfParallelism = (_b = params.kdfParallelism) !== null && _b !== void 0 ? _b : null;
|
|
184
|
+
}
|
|
185
|
+
else {
|
|
186
|
+
const prelogin = yield apiService.getPreloginInfo();
|
|
187
|
+
if (prelogin.kdf_version < 1) {
|
|
188
|
+
kdf = crypto_service_1.KdfType.PBKDF2_SHA256;
|
|
189
|
+
kdfIterations = 100000;
|
|
190
|
+
kdfMemory = null;
|
|
191
|
+
kdfParallelism = null;
|
|
192
|
+
}
|
|
193
|
+
else {
|
|
194
|
+
kdf = prelogin.kdf;
|
|
195
|
+
kdfIterations = prelogin.kdf_iterations;
|
|
196
|
+
kdfMemory = prelogin.kdf_memory;
|
|
197
|
+
kdfParallelism = prelogin.kdf_parallelism;
|
|
198
|
+
}
|
|
199
|
+
}
|
|
200
|
+
// Create new encrypted key hash and password hash
|
|
201
|
+
const key = yield cryptoService.core.makeKey(secret, email, kdf, kdfIterations, kdfMemory !== null && kdfMemory !== void 0 ? kdfMemory : undefined, kdfParallelism !== null && kdfParallelism !== void 0 ? kdfParallelism : undefined);
|
|
202
|
+
const newPwHash = yield cryptoService.core.hashPassword(secret, key);
|
|
203
|
+
const encKey = yield cryptoService.core.remakeEncKey(currentEncKey, key);
|
|
204
|
+
yield apiService.remakeBackupPasswordlessCredential(id, {
|
|
205
|
+
key: encKey[1].encryptedString || '',
|
|
206
|
+
master_password_hash: newPwHash,
|
|
207
|
+
kdf,
|
|
208
|
+
kdf_iterations: kdfIterations,
|
|
209
|
+
kdf_memory: kdfMemory,
|
|
210
|
+
kdf_parallelism: kdfParallelism,
|
|
211
|
+
});
|
|
212
|
+
return {
|
|
213
|
+
kdf,
|
|
214
|
+
kdf_iterations: kdfIterations,
|
|
215
|
+
kdf_memory: kdfMemory,
|
|
216
|
+
kdf_parallelism: kdfParallelism,
|
|
217
|
+
key,
|
|
218
|
+
hashedPassword: newPwHash,
|
|
219
|
+
};
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
exports.remakeBackupPasswordless = remakeBackupPasswordless;
|
|
132
223
|
/**
|
|
133
224
|
* Get pwl from fido key using from a list of credentials saved on server
|
|
134
225
|
* Group credentials with the same random for batch call
|
|
135
226
|
* @param params
|
|
136
|
-
* @returns secret
|
|
227
|
+
* @returns secret + kdf info
|
|
137
228
|
*/
|
|
138
229
|
function getPasswordless(params, services) {
|
|
230
|
+
var _a;
|
|
139
231
|
return __awaiter(this, void 0, void 0, function* () {
|
|
140
232
|
const { fidoService, apiService, logService } = services;
|
|
141
233
|
const { email, pin, devicePath, onlyBackup } = params;
|
|
@@ -145,17 +237,29 @@ function getPasswordless(params, services) {
|
|
|
145
237
|
throw new errors_1.ServiceError('2001');
|
|
146
238
|
}
|
|
147
239
|
// Get creds + random from API and filter only HMAC keys
|
|
148
|
-
const
|
|
240
|
+
const _b = yield apiService.getPasswordlessCredentials(email), { backup_keys } = _b, mainKey = __rest(_b, ["backup_keys"]);
|
|
149
241
|
const validKeys = backup_keys
|
|
150
242
|
.filter((k) => k.type === 'hmac' && k.credential_id && k.random)
|
|
151
243
|
.map((k) => ({
|
|
244
|
+
id: k.id,
|
|
152
245
|
credentialId: k.credential_id,
|
|
153
246
|
random: k.random,
|
|
247
|
+
kdf_version: k.kdf_version,
|
|
248
|
+
kdf: k.kdf,
|
|
249
|
+
kdf_iterations: k.kdf_iterations,
|
|
250
|
+
kdf_memory: k.kdf_memory,
|
|
251
|
+
kdf_parallelism: k.kdf_parallelism,
|
|
154
252
|
}));
|
|
155
253
|
if (!onlyBackup && mainKey.type === 'hmac' && !!mainKey.credential_id && !!mainKey.random) {
|
|
156
254
|
validKeys.unshift({
|
|
255
|
+
id: '',
|
|
157
256
|
credentialId: mainKey.credential_id,
|
|
158
257
|
random: mainKey.random,
|
|
258
|
+
kdf_version: mainKey.kdf_version,
|
|
259
|
+
kdf: mainKey.kdf,
|
|
260
|
+
kdf_iterations: mainKey.kdf_iterations,
|
|
261
|
+
kdf_memory: mainKey.kdf_memory,
|
|
262
|
+
kdf_parallelism: mainKey.kdf_parallelism,
|
|
159
263
|
});
|
|
160
264
|
}
|
|
161
265
|
if (!validKeys.length) {
|
|
@@ -168,7 +272,8 @@ function getPasswordless(params, services) {
|
|
|
168
272
|
// Try each random
|
|
169
273
|
for (const random in credGroups) {
|
|
170
274
|
try {
|
|
171
|
-
const
|
|
275
|
+
const group = credGroups[random];
|
|
276
|
+
const credentialIds = group.map((c) => c.credentialId);
|
|
172
277
|
let validCredId = credentialIds[0];
|
|
173
278
|
// If there is more than 1 creds -> find valid cred first
|
|
174
279
|
if (credentialIds.length > 1) {
|
|
@@ -183,7 +288,15 @@ function getPasswordless(params, services) {
|
|
|
183
288
|
pin,
|
|
184
289
|
});
|
|
185
290
|
logService.debug(`HMAC group with random ${random} successful`);
|
|
186
|
-
|
|
291
|
+
const usedKey = (_a = group.find((c) => c.credentialId === validCredId)) !== null && _a !== void 0 ? _a : group[0];
|
|
292
|
+
return {
|
|
293
|
+
pwl_id: usedKey.id,
|
|
294
|
+
secret,
|
|
295
|
+
kdf: usedKey.kdf,
|
|
296
|
+
kdf_iterations: usedKey.kdf_iterations,
|
|
297
|
+
kdf_memory: usedKey.kdf_memory,
|
|
298
|
+
kdf_parallelism: usedKey.kdf_parallelism,
|
|
299
|
+
};
|
|
187
300
|
}
|
|
188
301
|
catch (error) {
|
|
189
302
|
logService.debug(`HMAC group with random ${random} failed, ${error}`);
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,21 +1,19 @@
|
|
|
1
|
-
"use strict";
|
|
2
1
|
// @ts-nocheck
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
const utils_1 = require("../misc/utils");
|
|
6
|
-
exports.ECDH = {
|
|
2
|
+
import { Utils } from '../misc/utils';
|
|
3
|
+
export const ECDH = {
|
|
7
4
|
name: 'ECDH',
|
|
8
5
|
namedCurve: 'P-384',
|
|
9
6
|
};
|
|
10
|
-
|
|
7
|
+
export const AES = {
|
|
11
8
|
name: 'AES-CBC',
|
|
12
9
|
};
|
|
13
10
|
// -------------- CORE --------------
|
|
14
|
-
var KdfType;
|
|
11
|
+
export var KdfType;
|
|
15
12
|
(function (KdfType) {
|
|
16
13
|
KdfType[KdfType["PBKDF2_SHA256"] = 0] = "PBKDF2_SHA256";
|
|
17
|
-
|
|
18
|
-
|
|
14
|
+
KdfType[KdfType["ARGON2ID"] = 1] = "ARGON2ID";
|
|
15
|
+
})(KdfType || (KdfType = {}));
|
|
16
|
+
export var EncryptionType;
|
|
19
17
|
(function (EncryptionType) {
|
|
20
18
|
EncryptionType[EncryptionType["AesCbc256_B64"] = 0] = "AesCbc256_B64";
|
|
21
19
|
EncryptionType[EncryptionType["AesCbc128_HmacSha256_B64"] = 1] = "AesCbc128_HmacSha256_B64";
|
|
@@ -24,8 +22,8 @@ var EncryptionType;
|
|
|
24
22
|
EncryptionType[EncryptionType["Rsa2048_OaepSha1_B64"] = 4] = "Rsa2048_OaepSha1_B64";
|
|
25
23
|
EncryptionType[EncryptionType["Rsa2048_OaepSha256_HmacSha256_B64"] = 5] = "Rsa2048_OaepSha256_HmacSha256_B64";
|
|
26
24
|
EncryptionType[EncryptionType["Rsa2048_OaepSha1_HmacSha256_B64"] = 6] = "Rsa2048_OaepSha1_HmacSha256_B64";
|
|
27
|
-
})(EncryptionType || (
|
|
28
|
-
class SymmetricCryptoKey {
|
|
25
|
+
})(EncryptionType || (EncryptionType = {}));
|
|
26
|
+
export class SymmetricCryptoKey {
|
|
29
27
|
key;
|
|
30
28
|
encKey;
|
|
31
29
|
macKey;
|
|
@@ -67,18 +65,17 @@ class SymmetricCryptoKey {
|
|
|
67
65
|
throw new Error('Unsupported encType/key length.');
|
|
68
66
|
}
|
|
69
67
|
if (this.key != null) {
|
|
70
|
-
this.keyB64 =
|
|
68
|
+
this.keyB64 = Utils.fromBufferToB64(this.key);
|
|
71
69
|
}
|
|
72
70
|
if (this.encKey != null) {
|
|
73
|
-
this.encKeyB64 =
|
|
71
|
+
this.encKeyB64 = Utils.fromBufferToB64(this.encKey);
|
|
74
72
|
}
|
|
75
73
|
if (this.macKey != null) {
|
|
76
|
-
this.macKeyB64 =
|
|
74
|
+
this.macKeyB64 = Utils.fromBufferToB64(this.macKey);
|
|
77
75
|
}
|
|
78
76
|
}
|
|
79
77
|
}
|
|
80
|
-
|
|
81
|
-
class EncString {
|
|
78
|
+
export class EncString {
|
|
82
79
|
encryptedString;
|
|
83
80
|
encryptionType;
|
|
84
81
|
decryptedValue;
|
|
@@ -155,11 +152,9 @@ class EncString {
|
|
|
155
152
|
}
|
|
156
153
|
}
|
|
157
154
|
}
|
|
158
|
-
|
|
159
|
-
class EncryptedObject {
|
|
155
|
+
export class EncryptedObject {
|
|
160
156
|
iv;
|
|
161
157
|
data;
|
|
162
158
|
mac;
|
|
163
159
|
key;
|
|
164
160
|
}
|
|
165
|
-
exports.EncryptedObject = EncryptedObject;
|
|
@@ -1,7 +1,4 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.ERRORS = exports.ServiceError = void 0;
|
|
4
|
-
class ServiceError extends Error {
|
|
1
|
+
export class ServiceError extends Error {
|
|
5
2
|
code;
|
|
6
3
|
message;
|
|
7
4
|
rawError;
|
|
@@ -13,7 +10,7 @@ class ServiceError extends Error {
|
|
|
13
10
|
rawError?.message ||
|
|
14
11
|
rawError?.toString() ||
|
|
15
12
|
'Unknown error';
|
|
16
|
-
this.message = code === '0000' ? rawMessage :
|
|
13
|
+
this.message = code === '0000' ? rawMessage : ERRORS[code].message;
|
|
17
14
|
}
|
|
18
15
|
static fromError(rawError) {
|
|
19
16
|
const message = rawError?.response?.data?.message ||
|
|
@@ -27,8 +24,7 @@ class ServiceError extends Error {
|
|
|
27
24
|
return new ServiceError('0000', rawError);
|
|
28
25
|
}
|
|
29
26
|
}
|
|
30
|
-
|
|
31
|
-
exports.ERRORS = {
|
|
27
|
+
export const ERRORS = {
|
|
32
28
|
'0000': {
|
|
33
29
|
message: 'Unspecified error',
|
|
34
30
|
},
|
|
@@ -102,4 +98,4 @@ exports.ERRORS = {
|
|
|
102
98
|
},
|
|
103
99
|
}; // as { [code: string]: { message: string; signatures?: string[] } }
|
|
104
100
|
// @ts-ignore
|
|
105
|
-
const ERRORS_LIST = Object.keys(
|
|
101
|
+
const ERRORS_LIST = Object.keys(ERRORS).map((code) => ({ code, ...ERRORS[code] }));
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
|
@@ -1,11 +1,7 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.buildOutgoingSocketMessage = void 0;
|
|
4
|
-
function buildOutgoingSocketMessage(message, data, secure) {
|
|
1
|
+
export function buildOutgoingSocketMessage(message, data, secure) {
|
|
5
2
|
return {
|
|
6
3
|
message,
|
|
7
4
|
data,
|
|
8
5
|
secure,
|
|
9
6
|
};
|
|
10
7
|
}
|
|
11
|
-
exports.buildOutgoingSocketMessage = buildOutgoingSocketMessage;
|
|
@@ -1,2 +1 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
1
|
+
export {};
|
package/lib/esm/index.mjs
CHANGED
|
@@ -1,21 +1,18 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
const
|
|
15
|
-
|
|
16
|
-
const cache_service_1 = require("./services/cache.service");
|
|
17
|
-
exports.ServiceErrors = errors_1.ERRORS;
|
|
18
|
-
class DesktopService {
|
|
1
|
+
import { buildOutgoingSocketMessage } from './abstractions/socket.service';
|
|
2
|
+
import { ApiService } from './services/api.service';
|
|
3
|
+
import { UserService } from './services/user.service';
|
|
4
|
+
import { CryptoService } from './services/crypto.service';
|
|
5
|
+
import { EventService } from './services/event.service';
|
|
6
|
+
import { FidoService } from './services/fido.service';
|
|
7
|
+
import { GRPCService } from './services/grpc.service';
|
|
8
|
+
import { LogService } from './services/log.service';
|
|
9
|
+
import { PairingService } from './services/pairing.service';
|
|
10
|
+
import { SocketService } from './services/socket.service';
|
|
11
|
+
import { ERRORS } from './abstractions/errors';
|
|
12
|
+
import { getPasswordless, remakeBackupPasswordless, setBackupPasswordless, setNewPasswordless, } from './usecases/fido';
|
|
13
|
+
import { CacheService } from './services/cache.service';
|
|
14
|
+
export const ServiceErrors = ERRORS;
|
|
15
|
+
export class DesktopService {
|
|
19
16
|
apiService;
|
|
20
17
|
fidoService;
|
|
21
18
|
logService;
|
|
@@ -31,16 +28,16 @@ class DesktopService {
|
|
|
31
28
|
// Constructor
|
|
32
29
|
constructor(params) {
|
|
33
30
|
const { baseApiUrl, logLevel, storageService, ssl, unsafe, apiHeaders, serviceAlias, socketSsl, } = params;
|
|
34
|
-
this.cryptoService = new
|
|
31
|
+
this.cryptoService = new CryptoService();
|
|
35
32
|
this.storageService = storageService;
|
|
36
|
-
this.logService = new
|
|
37
|
-
this.eventService = new
|
|
38
|
-
this.apiService = new
|
|
33
|
+
this.logService = new LogService(logLevel);
|
|
34
|
+
this.eventService = new EventService(this.logService);
|
|
35
|
+
this.apiService = new ApiService({
|
|
39
36
|
baseUrl: baseApiUrl || 'https://api.locker.io/v3',
|
|
40
37
|
logger: this.logService,
|
|
41
38
|
headers: apiHeaders,
|
|
42
39
|
});
|
|
43
|
-
this.grpcService = new
|
|
40
|
+
this.grpcService = new GRPCService({
|
|
44
41
|
logger: this.logService,
|
|
45
42
|
event: this.eventService,
|
|
46
43
|
cryptoService: this.cryptoService,
|
|
@@ -50,20 +47,20 @@ class DesktopService {
|
|
|
50
47
|
unsafe,
|
|
51
48
|
serviceAlias: serviceAlias || '',
|
|
52
49
|
});
|
|
53
|
-
this.fidoService = new
|
|
54
|
-
this.pairingService = new
|
|
50
|
+
this.fidoService = new FidoService(this.logService, this.eventService, this.grpcService);
|
|
51
|
+
this.pairingService = new PairingService({
|
|
55
52
|
cryptoService: this.cryptoService,
|
|
56
53
|
eventService: this.eventService,
|
|
57
54
|
storageService: this.storageService,
|
|
58
55
|
logger: this.logService,
|
|
59
56
|
grpcService: this.grpcService,
|
|
60
57
|
});
|
|
61
|
-
this.userService = new
|
|
58
|
+
this.userService = new UserService({
|
|
62
59
|
logger: this.logService,
|
|
63
60
|
storageService: this.storageService,
|
|
64
61
|
grpcService: this.grpcService,
|
|
65
62
|
});
|
|
66
|
-
this.socketService = new
|
|
63
|
+
this.socketService = new SocketService({
|
|
67
64
|
logger: this.logService,
|
|
68
65
|
pairingService: this.pairingService,
|
|
69
66
|
userService: this.userService,
|
|
@@ -71,7 +68,7 @@ class DesktopService {
|
|
|
71
68
|
ssl: socketSsl,
|
|
72
69
|
serviceAlias: serviceAlias || '',
|
|
73
70
|
});
|
|
74
|
-
this.cacheService = new
|
|
71
|
+
this.cacheService = new CacheService(this.logService, this.grpcService);
|
|
75
72
|
this.waitUntilReady();
|
|
76
73
|
}
|
|
77
74
|
// ---------------------- READY STATE ----------------------
|
|
@@ -149,7 +146,7 @@ class DesktopService {
|
|
|
149
146
|
return this.fidoService.getDeviceList();
|
|
150
147
|
}
|
|
151
148
|
setNewPasswordless(params) {
|
|
152
|
-
return
|
|
149
|
+
return setNewPasswordless(params, {
|
|
153
150
|
apiService: this.apiService,
|
|
154
151
|
fidoService: this.fidoService,
|
|
155
152
|
cryptoService: this.cryptoService,
|
|
@@ -159,12 +156,18 @@ class DesktopService {
|
|
|
159
156
|
return this.apiService.deletePasswordlessCredential();
|
|
160
157
|
}
|
|
161
158
|
setBackupPasswordless(params) {
|
|
162
|
-
return
|
|
159
|
+
return setBackupPasswordless(params, {
|
|
163
160
|
apiService: this.apiService,
|
|
164
161
|
fidoService: this.fidoService,
|
|
165
162
|
cryptoService: this.cryptoService,
|
|
166
163
|
});
|
|
167
164
|
}
|
|
165
|
+
remakeBackupPasswordless(params) {
|
|
166
|
+
return remakeBackupPasswordless(params, {
|
|
167
|
+
apiService: this.apiService,
|
|
168
|
+
cryptoService: this.cryptoService,
|
|
169
|
+
});
|
|
170
|
+
}
|
|
168
171
|
async listAllPasswordless(email) {
|
|
169
172
|
const [mainKey, backupKeys] = await Promise.all([
|
|
170
173
|
this.apiService.getPasswordlessCredentials(email),
|
|
@@ -183,6 +186,11 @@ class DesktopService {
|
|
|
183
186
|
fd_random: mainKey.random || '',
|
|
184
187
|
isPrimary: true,
|
|
185
188
|
type: mainKey.type,
|
|
189
|
+
kdf_version: mainKey.kdf_version,
|
|
190
|
+
kdf: mainKey.kdf,
|
|
191
|
+
kdf_iterations: mainKey.kdf_iterations,
|
|
192
|
+
kdf_memory: mainKey.kdf_memory,
|
|
193
|
+
kdf_parallelism: mainKey.kdf_parallelism,
|
|
186
194
|
});
|
|
187
195
|
}
|
|
188
196
|
return res;
|
|
@@ -194,7 +202,7 @@ class DesktopService {
|
|
|
194
202
|
return this.apiService.deleteBackupPasswordlessCredential(id);
|
|
195
203
|
}
|
|
196
204
|
getPasswordless(params) {
|
|
197
|
-
return
|
|
205
|
+
return getPasswordless(params, {
|
|
198
206
|
apiService: this.apiService,
|
|
199
207
|
fidoService: this.fidoService,
|
|
200
208
|
logService: this.logService,
|
|
@@ -203,13 +211,13 @@ class DesktopService {
|
|
|
203
211
|
// ---------------------- PAIRING ----------------------
|
|
204
212
|
async confirmPairingClient(clientId, clientType) {
|
|
205
213
|
await this.pairingService.confirmPairingClient(clientId, clientType === 'extension');
|
|
206
|
-
this.socketService.sendMessageToClient(clientId,
|
|
214
|
+
this.socketService.sendMessageToClient(clientId, buildOutgoingSocketMessage('pairingConfirmed', undefined));
|
|
207
215
|
}
|
|
208
216
|
async resetPairingCode(clientId) {
|
|
209
|
-
this.socketService.sendMessageToClient(clientId,
|
|
217
|
+
this.socketService.sendMessageToClient(clientId, buildOutgoingSocketMessage('resetPairing', undefined));
|
|
210
218
|
}
|
|
211
219
|
async sendCustomMessage(data) {
|
|
212
|
-
this.socketService.broadcastMessageToAll(
|
|
220
|
+
this.socketService.broadcastMessageToAll(buildOutgoingSocketMessage('customMessage', data));
|
|
213
221
|
}
|
|
214
222
|
getCacheData() {
|
|
215
223
|
return this.cacheService.getCache();
|
|
@@ -223,20 +231,20 @@ class DesktopService {
|
|
|
223
231
|
}
|
|
224
232
|
async login(params) {
|
|
225
233
|
await this.userService.login(params);
|
|
226
|
-
this.socketService.broadcastMessageToAll(
|
|
234
|
+
this.socketService.broadcastMessageToAll(buildOutgoingSocketMessage('userLogin', { email: params.email }));
|
|
227
235
|
}
|
|
228
236
|
async logout() {
|
|
229
237
|
const currentUser = { ...this.userService.currentUser };
|
|
230
238
|
if (currentUser?.email) {
|
|
231
239
|
await this.userService.logout();
|
|
232
|
-
this.socketService.broadcastMessageToAll(
|
|
240
|
+
this.socketService.broadcastMessageToAll(buildOutgoingSocketMessage('userLogout', { email: currentUser.email }));
|
|
233
241
|
}
|
|
234
242
|
}
|
|
235
243
|
async lock() {
|
|
236
244
|
const currentUser = { ...this.userService.currentUser };
|
|
237
245
|
if (currentUser?.email) {
|
|
238
246
|
await this.userService.lock();
|
|
239
|
-
this.socketService.broadcastMessageToAll(
|
|
247
|
+
this.socketService.broadcastMessageToAll(buildOutgoingSocketMessage('userLock', { email: currentUser.email }));
|
|
240
248
|
}
|
|
241
249
|
}
|
|
242
250
|
// ---------------------- EVENTS ----------------------
|
|
@@ -253,4 +261,3 @@ class DesktopService {
|
|
|
253
261
|
this.eventService.removeAllListeners();
|
|
254
262
|
}
|
|
255
263
|
}
|
|
256
|
-
exports.DesktopService = DesktopService;
|
package/lib/esm/misc/config.js
CHANGED
|
@@ -1,15 +1,12 @@
|
|
|
1
|
-
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.GRPC_PING_TIMEOUT = exports.GRPC_CONNECTION_TIMEOUT = exports.WEBSOCKET_SSL_PORTS = exports.WEBSOCKET_PORTS = exports.HTTP_PORTS = void 0;
|
|
4
|
-
exports.HTTP_PORTS = [
|
|
1
|
+
export const HTTP_PORTS = [
|
|
5
2
|
14411, 14110, 15611, 14412, 16311, 14514, 14515, 14413, 14401, 14100, 15601, 14402, 16301, 14504,
|
|
6
3
|
14505, 14403,
|
|
7
4
|
];
|
|
8
|
-
|
|
5
|
+
export const WEBSOCKET_PORTS = [
|
|
9
6
|
10040, 10124, 10978, 11307, 11792, 21792, 10041, 10125, 10979, 11308, 11793, 21793,
|
|
10
7
|
];
|
|
11
|
-
|
|
8
|
+
export const WEBSOCKET_SSL_PORTS = [
|
|
12
9
|
20040, 20124, 20978, 21307, 21792, 22792, 20041, 20125, 20979, 21308, 21793, 22793,
|
|
13
10
|
];
|
|
14
|
-
|
|
15
|
-
|
|
11
|
+
export const GRPC_CONNECTION_TIMEOUT = 1500;
|
|
12
|
+
export const GRPC_PING_TIMEOUT = 1000;
|