@clxmedia/credstore-client 1.0.15 → 1.0.17
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/dist/client.d.ts +1 -3
- package/dist/client.js +9 -4
- package/dist/helpers.d.ts +2 -0
- package/dist/helpers.js +26 -0
- package/dist/index.d.ts +1 -0
- package/dist/index.js +3 -1
- package/package.json +6 -3
package/dist/client.d.ts
CHANGED
|
@@ -80,9 +80,7 @@ export declare class CredStoreClient {
|
|
|
80
80
|
private httpService;
|
|
81
81
|
constructor(config: CredStoreConfig);
|
|
82
82
|
buildHeaders(guidSecret?: string, skipCache?: boolean): {
|
|
83
|
-
|
|
84
|
-
'x-credstore-secret': string;
|
|
85
|
-
'x-credstore-admin-key': string;
|
|
83
|
+
[x: string]: string;
|
|
86
84
|
};
|
|
87
85
|
fetchCredential(guid: string, fetchOptions?: FetchOptions): Promise<CredStoreBundle>;
|
|
88
86
|
createCredential(provider: CredentialProvider, credData: EntrataCredential | RealPageCredential | YardiCredential | GenericCredential | MailJetCredential): Promise<any>;
|
package/dist/client.js
CHANGED
|
@@ -28,11 +28,16 @@ class CredStoreClient {
|
|
|
28
28
|
this.apiKey = config.api_key;
|
|
29
29
|
}
|
|
30
30
|
buildHeaders(guidSecret, skipCache) {
|
|
31
|
-
|
|
32
|
-
'x-credstore-skip-cache': `${skipCache}
|
|
33
|
-
'x-credstore-secret': guidSecret,
|
|
34
|
-
'x-credstore-admin-key': this.apiKey
|
|
31
|
+
const headers = {
|
|
32
|
+
'x-credstore-skip-cache': `${skipCache}`
|
|
35
33
|
};
|
|
34
|
+
if (this.apiKey) {
|
|
35
|
+
headers['x-credstore-admin-key'] = this.apiKey;
|
|
36
|
+
}
|
|
37
|
+
if (guidSecret) {
|
|
38
|
+
headers['x-credstore-secret'] = guidSecret;
|
|
39
|
+
}
|
|
40
|
+
return headers;
|
|
36
41
|
}
|
|
37
42
|
fetchCredential(guid, fetchOptions) {
|
|
38
43
|
return __awaiter(this, void 0, void 0, function* () {
|
package/dist/helpers.js
ADDED
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.XperienceEntityKeyGenerator = exports.XperienceEntityKeyValidator = void 0;
|
|
4
|
+
const luxon_1 = require("luxon");
|
|
5
|
+
const crypto_1 = require("crypto");
|
|
6
|
+
const XperienceEntityKeyValidator = (entityId, entitySecret, availableEntityKeys) => {
|
|
7
|
+
const now = luxon_1.DateTime.local().startOf('minute').toSeconds();
|
|
8
|
+
const timeRange = Array.from(Array(9).keys()).map((i) => now + (i - 4) * 60);
|
|
9
|
+
return timeRange.some((timeSalt) => {
|
|
10
|
+
return availableEntityKeys.some((entityKey) => {
|
|
11
|
+
return entitySecret === sha256Hash(`${entityId}:${entityKey}`, timeSalt.toString());
|
|
12
|
+
});
|
|
13
|
+
});
|
|
14
|
+
};
|
|
15
|
+
exports.XperienceEntityKeyValidator = XperienceEntityKeyValidator;
|
|
16
|
+
const XperienceEntityKeyGenerator = (entityId, xperienceEntityKey) => {
|
|
17
|
+
const timeSalt = luxon_1.DateTime.local().startOf('minute').toSeconds();
|
|
18
|
+
return sha256Hash(`${entityId}:${xperienceEntityKey}`, timeSalt.toString());
|
|
19
|
+
};
|
|
20
|
+
exports.XperienceEntityKeyGenerator = XperienceEntityKeyGenerator;
|
|
21
|
+
const sha256Hash = (input, salt) => {
|
|
22
|
+
return (0, crypto_1.createHash)("sha256")
|
|
23
|
+
.update(input)
|
|
24
|
+
.update((0, crypto_1.createHash)("sha256").update(salt, "utf8").digest("hex"))
|
|
25
|
+
.digest("hex");
|
|
26
|
+
};
|
package/dist/index.d.ts
CHANGED
|
@@ -1 +1,2 @@
|
|
|
1
1
|
export { CredStoreClient, CredStoreConfig, CredentialAttribute, BaseCredential, EntrataCredential, RealPageCredential, YardiCredential, MailJetCredential, GenericCredential, CredStoreBundle, EntrataCredStoreBundle, RealPageCredStoreBundle, YardiCredStoreBundle, MailJetCredStoreBundle, CredentialProvider, FetchOptions, UpdateOptions, OptionsBase } from './client';
|
|
2
|
+
export { XperienceEntityKeyValidator } from './helpers';
|
package/dist/index.js
CHANGED
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.CredentialProvider = exports.CredStoreClient = void 0;
|
|
3
|
+
exports.XperienceEntityKeyValidator = exports.CredentialProvider = exports.CredStoreClient = void 0;
|
|
4
4
|
var client_1 = require("./client");
|
|
5
5
|
Object.defineProperty(exports, "CredStoreClient", { enumerable: true, get: function () { return client_1.CredStoreClient; } });
|
|
6
6
|
Object.defineProperty(exports, "CredentialProvider", { enumerable: true, get: function () { return client_1.CredentialProvider; } });
|
|
7
|
+
var helpers_1 = require("./helpers");
|
|
8
|
+
Object.defineProperty(exports, "XperienceEntityKeyValidator", { enumerable: true, get: function () { return helpers_1.XperienceEntityKeyValidator; } });
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@clxmedia/credstore-client",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "CLXperience CredStore Client",
|
|
5
5
|
"author": "Brandon Thompson <brandont@clxmedia.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -37,7 +37,9 @@
|
|
|
37
37
|
"@nestjs/common": "^8.1.1"
|
|
38
38
|
},
|
|
39
39
|
"dependencies": {
|
|
40
|
-
"@nestjs/axios": "^0.1.0"
|
|
40
|
+
"@nestjs/axios": "^0.1.0",
|
|
41
|
+
"crypto": "^1.0.1",
|
|
42
|
+
"luxon": "^3.3.0"
|
|
41
43
|
},
|
|
42
44
|
"devDependencies": {
|
|
43
45
|
"@nestjs/common": "^8.1.1",
|
|
@@ -45,11 +47,12 @@
|
|
|
45
47
|
"@nestjs/platform-express": "^8.1.1",
|
|
46
48
|
"@nestjs/testing": "8.1.1",
|
|
47
49
|
"@types/jest": "28.1.7",
|
|
50
|
+
"@types/luxon": "^3.3.0",
|
|
48
51
|
"@types/node": "16.11.7",
|
|
49
52
|
"@types/supertest": "2.0.12",
|
|
50
53
|
"jest": "28.1.3",
|
|
51
|
-
"rxjs": "7.5.7",
|
|
52
54
|
"prettier": "2.7.1",
|
|
55
|
+
"rxjs": "7.5.7",
|
|
53
56
|
"supertest": "6.2.4",
|
|
54
57
|
"ts-jest": "28.0.8",
|
|
55
58
|
"ts-node": "10.9.1",
|