@salesforce/core 3.6.1 → 3.6.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +7 -0
- package/lib/crypto/crypto.js +24 -5
- package/lib/util/cache.d.ts +11 -0
- package/lib/util/cache.js +70 -0
- package/package.json +1 -1
package/CHANGELOG.md
CHANGED
|
@@ -2,6 +2,13 @@
|
|
|
2
2
|
|
|
3
3
|
All notable changes to this project will be documented in this file. See [standard-version](https://github.com/conventional-changelog/standard-version) for commit guidelines.
|
|
4
4
|
|
|
5
|
+
### [3.6.2](https://github.com/forcedotcom/sfdx-core/compare/v3.6.1...v3.6.2) (2021-09-17)
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
### Bug Fixes
|
|
9
|
+
|
|
10
|
+
* improve time to build auths for many orgs @W-9914839@ ([#478](https://github.com/forcedotcom/sfdx-core/issues/478)) ([c788541](https://github.com/forcedotcom/sfdx-core/commit/c7885415d59994b28552227f0b84dcee5d3ec7cf))
|
|
11
|
+
|
|
5
12
|
### [3.6.1](https://github.com/forcedotcom/sfdx-core/compare/v3.6.0...v3.6.1) (2021-09-13)
|
|
6
13
|
|
|
7
14
|
|
package/lib/crypto/crypto.js
CHANGED
|
@@ -15,6 +15,7 @@ const ts_types_1 = require("@salesforce/ts-types");
|
|
|
15
15
|
const kit_1 = require("@salesforce/kit");
|
|
16
16
|
const logger_1 = require("../logger");
|
|
17
17
|
const messages_1 = require("../messages");
|
|
18
|
+
const cache_1 = require("../util/cache");
|
|
18
19
|
const keyChain_1 = require("./keyChain");
|
|
19
20
|
const secureBuffer_1 = require("./secureBuffer");
|
|
20
21
|
const TAG_DELIMITER = ':';
|
|
@@ -31,6 +32,11 @@ const messages = messages_1.Messages.load('@salesforce/core', 'encryption', [
|
|
|
31
32
|
'authDecryptError',
|
|
32
33
|
'macKeychainOutOfSync',
|
|
33
34
|
]);
|
|
35
|
+
const makeSecureBuffer = (password) => {
|
|
36
|
+
const newSb = new secureBuffer_1.SecureBuffer();
|
|
37
|
+
newSb.consume(Buffer.from(ts_types_1.ensure(password), 'utf8'));
|
|
38
|
+
return newSb;
|
|
39
|
+
};
|
|
34
40
|
/**
|
|
35
41
|
* osxKeyChain promise wrapper.
|
|
36
42
|
*/
|
|
@@ -43,11 +49,24 @@ const keychainPromises = {
|
|
|
43
49
|
* @param account The keychain account name.
|
|
44
50
|
*/
|
|
45
51
|
getPassword(_keychain, service, account) {
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
52
|
+
const sb = cache_1.Cache.get(`${service}:${account}`);
|
|
53
|
+
if (!sb) {
|
|
54
|
+
return new Promise((resolve, reject) => {
|
|
55
|
+
return _keychain.getPassword({ service, account }, (err, password) => {
|
|
56
|
+
if (err)
|
|
57
|
+
return reject(err);
|
|
58
|
+
cache_1.Cache.set(`${service}:${account}`, makeSecureBuffer(password));
|
|
59
|
+
return resolve({ username: account, password: ts_types_1.ensure(password) });
|
|
60
|
+
});
|
|
61
|
+
});
|
|
62
|
+
}
|
|
63
|
+
else {
|
|
64
|
+
const pw = sb.value((buffer) => buffer.toString('utf8'));
|
|
65
|
+
cache_1.Cache.set(`${service}:${account}`, makeSecureBuffer(pw));
|
|
66
|
+
return new Promise((resolve) => {
|
|
67
|
+
return resolve({ username: account, password: ts_types_1.ensure(pw) });
|
|
68
|
+
});
|
|
69
|
+
}
|
|
51
70
|
},
|
|
52
71
|
/**
|
|
53
72
|
* Sets a generic password item in OSX keychain.
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
export declare class Cache extends Map {
|
|
2
|
+
#private;
|
|
3
|
+
private constructor();
|
|
4
|
+
static instance(): Cache;
|
|
5
|
+
static set<V>(key: string, value: V): void;
|
|
6
|
+
static get<V>(key: string): V | undefined;
|
|
7
|
+
static disable(): void;
|
|
8
|
+
static enable(): void;
|
|
9
|
+
static get hits(): number;
|
|
10
|
+
static get lookups(): number;
|
|
11
|
+
}
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __classPrivateFieldSet = (this && this.__classPrivateFieldSet) || function (receiver, state, value, kind, f) {
|
|
3
|
+
if (kind === "m") throw new TypeError("Private method is not writable");
|
|
4
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a setter");
|
|
5
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot write private member to an object whose class did not declare it");
|
|
6
|
+
return (kind === "a" ? f.call(receiver, value) : f ? f.value = value : state.set(receiver, value)), value;
|
|
7
|
+
};
|
|
8
|
+
var __classPrivateFieldGet = (this && this.__classPrivateFieldGet) || function (receiver, state, kind, f) {
|
|
9
|
+
if (kind === "a" && !f) throw new TypeError("Private accessor was defined without a getter");
|
|
10
|
+
if (typeof state === "function" ? receiver !== state || !f : !state.has(receiver)) throw new TypeError("Cannot read private member from an object whose class did not declare it");
|
|
11
|
+
return kind === "m" ? f : kind === "a" ? f.call(receiver) : f ? f.value : state.get(receiver);
|
|
12
|
+
};
|
|
13
|
+
var _a, _Cache_instance, _Cache_enabled, _Cache_hits, _Cache_lookups;
|
|
14
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
+
exports.Cache = void 0;
|
|
16
|
+
/*
|
|
17
|
+
* Copyright (c) 2020, salesforce.com, inc.
|
|
18
|
+
* All rights reserved.
|
|
19
|
+
* Licensed under the BSD 3-Clause license.
|
|
20
|
+
* For full license text, see LICENSE.txt file in the repo root or https://opensource.org/licenses/BSD-3-Clause
|
|
21
|
+
*/
|
|
22
|
+
class Cache extends Map {
|
|
23
|
+
/* eslint-enable @typescript-eslint/explicit-member-accessibility */
|
|
24
|
+
constructor() {
|
|
25
|
+
super();
|
|
26
|
+
_Cache_hits.set(this, void 0);
|
|
27
|
+
_Cache_lookups.set(this, void 0);
|
|
28
|
+
__classPrivateFieldSet(this, _Cache_hits, 0, "f");
|
|
29
|
+
__classPrivateFieldSet(this, _Cache_lookups, 0, "f");
|
|
30
|
+
}
|
|
31
|
+
static instance() {
|
|
32
|
+
if (!__classPrivateFieldGet(Cache, _a, "f", _Cache_instance)) {
|
|
33
|
+
__classPrivateFieldSet(Cache, _a, true, "f", _Cache_enabled);
|
|
34
|
+
__classPrivateFieldSet(Cache, _a, new Cache(), "f", _Cache_instance);
|
|
35
|
+
}
|
|
36
|
+
return __classPrivateFieldGet(Cache, _a, "f", _Cache_instance);
|
|
37
|
+
}
|
|
38
|
+
static set(key, value) {
|
|
39
|
+
if (__classPrivateFieldGet(Cache, _a, "f", _Cache_enabled)) {
|
|
40
|
+
Cache.instance().set(key, value);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
static get(key) {
|
|
44
|
+
var _b, _c;
|
|
45
|
+
if (!__classPrivateFieldGet(Cache, _a, "f", _Cache_enabled)) {
|
|
46
|
+
return undefined;
|
|
47
|
+
}
|
|
48
|
+
__classPrivateFieldSet(_b = Cache.instance(), _Cache_lookups, +__classPrivateFieldGet(_b, _Cache_lookups, "f") + 1, "f");
|
|
49
|
+
__classPrivateFieldSet(_c = Cache.instance(), _Cache_hits, __classPrivateFieldGet(_c, _Cache_hits, "f") + (Cache.instance().has(key) ? 1 : 0), "f");
|
|
50
|
+
return __classPrivateFieldGet(Cache, _a, "f", _Cache_instance).get(key);
|
|
51
|
+
}
|
|
52
|
+
static disable() {
|
|
53
|
+
__classPrivateFieldSet(Cache, _a, false, "f", _Cache_enabled);
|
|
54
|
+
}
|
|
55
|
+
static enable() {
|
|
56
|
+
__classPrivateFieldSet(Cache, _a, true, "f", _Cache_enabled);
|
|
57
|
+
}
|
|
58
|
+
static get hits() {
|
|
59
|
+
return __classPrivateFieldGet(Cache.instance(), _Cache_hits, "f");
|
|
60
|
+
}
|
|
61
|
+
static get lookups() {
|
|
62
|
+
return __classPrivateFieldGet(Cache.instance(), _Cache_lookups, "f");
|
|
63
|
+
}
|
|
64
|
+
}
|
|
65
|
+
exports.Cache = Cache;
|
|
66
|
+
_a = Cache, _Cache_hits = new WeakMap(), _Cache_lookups = new WeakMap();
|
|
67
|
+
/* eslint-disable @typescript-eslint/explicit-member-accessibility */
|
|
68
|
+
_Cache_instance = { value: void 0 };
|
|
69
|
+
_Cache_enabled = { value: true };
|
|
70
|
+
//# sourceMappingURL=cache.js.map
|