Skip to content

Commit 6e742f8

Browse files
authored
Add a version header on calls to the TSP (#102)
* Add a version header on calls to the TSP Which can be read from TSP metrics to try to identify outdated TSCs or track migrations * Update copyright * Update Util.ts adjust the name of the language
1 parent b8a3052 commit 6e742f8

File tree

4 files changed

+73
-66
lines changed

4 files changed

+73
-66
lines changed

CHANGELOG.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,7 @@
1+
## 4.0.1
2+
3+
- Added header to TSP and Logdriver calls with the current TSC version and language. These can be consumed in TSP metrics and are useful to track migrations or find out of date TSC callers.
4+
15
## 4.0.0
26

37
- Encryption now throws a `TscException` when trying to encrypt a document that has already been IronCore encrypted.

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,4 +24,4 @@ Check in the `examples` subdirectory - there are subdirectories for some example
2424

2525
The Tenant Security Client is licensed under the [GNU Affero General Public License](https://github.com/IronCoreLabs/ironoxide/blob/main/LICENSE). We also offer commercial licenses - [email](mailto:info@ironcorelabs.com) for more information.
2626

27-
Copyright (c) 2021 IronCore Labs, Inc. All rights reserved.
27+
Copyright (c) 2023 IronCore Labs, Inc. All rights reserved.

package.json

Lines changed: 63 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -1,64 +1,64 @@
11
{
2-
"name": "@ironcorelabs/tenant-security-nodejs",
3-
"version": "4.0.0",
4-
"description": "NodeJS client library for the IronCore Labs Tenant Security Proxy.",
5-
"homepage": "https://ironcorelabs.com/docs",
6-
"main": "src/index.js",
7-
"repository": "git@github.com:IronCoreLabs/tenant-security-client-nodejs.git",
8-
"author": "IronCore Labs",
9-
"license": "AGPL-3.0-only",
10-
"types": "src/index.d.ts",
11-
"engines": {
12-
"node": ">=14.0.0"
13-
},
14-
"scripts": {
15-
"build": "./build.js",
16-
"test": "yarn run lint && yarn run unit",
17-
"unit": "jest -t UNIT",
18-
"integration": "jest -t \"INTEGRATION|UNIT\"",
19-
"local": "jest -t LOCAL",
20-
"lint": "eslint . --ext .ts",
21-
"testsingle": "jest",
22-
"protobuild": "pbjs -t static-module -w commonjs -o proto/ts/DocumentHeader.js proto/document_header.proto && pbts -o proto/ts/DocumentHeader.d.ts proto/ts/DocumentHeader.js"
23-
},
24-
"dependencies": {
25-
"futurejs": "2.2.0",
26-
"miscreant": "^0.3.2",
27-
"node-fetch": "2.6.12",
28-
"protobufjs": "^7.2.4"
29-
},
30-
"devDependencies": {
31-
"@types/jest": "^25.2.3",
32-
"@types/node": "^13.13.15",
33-
"@types/node-fetch": "^2.5.7",
34-
"@typescript-eslint/eslint-plugin": "^3.9.1",
35-
"@typescript-eslint/parser": "^3.9.1",
36-
"eslint": "^6.8.0",
37-
"jest": "^26.4.1",
38-
"jest-extended": "^0.11.5",
39-
"prompt": "^1.0.0",
40-
"protobufjs-cli": "^1.1.1",
41-
"shelljs": "^0.8.4",
42-
"ts-jest": "^26.2.0",
43-
"ts-node": "^8.10.2",
44-
"typescript": "^3.9.7",
45-
"typestrict": "^1.0.2",
46-
"uglify-js": "^3.7.7"
47-
},
48-
"prettier": {
49-
"printWidth": 160,
50-
"tabWidth": 4,
51-
"trailingComma": "es5",
52-
"bracketSpacing": false,
53-
"jsxBracketSameLine": true,
54-
"arrowParens": "always",
55-
"overrides": [
56-
{
57-
"files": "*.yml",
58-
"options": {
59-
"tabWidth": 2
60-
}
61-
}
62-
]
63-
}
64-
}
2+
"name": "@ironcorelabs/tenant-security-nodejs",
3+
"version": "4.0.1",
4+
"description": "NodeJS client library for the IronCore Labs Tenant Security Proxy.",
5+
"homepage": "https://ironcorelabs.com/docs",
6+
"main": "src/index.js",
7+
"repository": "git@github.com:IronCoreLabs/tenant-security-client-nodejs.git",
8+
"author": "IronCore Labs",
9+
"license": "AGPL-3.0-only",
10+
"types": "src/index.d.ts",
11+
"engines": {
12+
"node": ">=14.0.0"
13+
},
14+
"scripts": {
15+
"build": "./build.js",
16+
"test": "yarn run lint && yarn run unit",
17+
"unit": "jest -t UNIT",
18+
"integration": "jest -t \"INTEGRATION|UNIT\"",
19+
"local": "jest -t LOCAL",
20+
"lint": "eslint . --ext .ts",
21+
"testsingle": "jest",
22+
"protobuild": "pbjs -t static-module -w commonjs -o proto/ts/DocumentHeader.js proto/document_header.proto && pbts -o proto/ts/DocumentHeader.d.ts proto/ts/DocumentHeader.js"
23+
},
24+
"dependencies": {
25+
"futurejs": "2.2.0",
26+
"miscreant": "^0.3.2",
27+
"node-fetch": "2.6.12",
28+
"protobufjs": "^7.2.4"
29+
},
30+
"devDependencies": {
31+
"@types/jest": "^25.2.3",
32+
"@types/node": "^13.13.15",
33+
"@types/node-fetch": "^2.5.7",
34+
"@typescript-eslint/eslint-plugin": "^3.9.1",
35+
"@typescript-eslint/parser": "^3.9.1",
36+
"eslint": "^6.8.0",
37+
"jest": "^26.4.1",
38+
"jest-extended": "^0.11.5",
39+
"prompt": "^1.0.0",
40+
"protobufjs-cli": "^1.1.1",
41+
"shelljs": "^0.8.4",
42+
"ts-jest": "^26.2.0",
43+
"ts-node": "^8.10.2",
44+
"typescript": "^3.9.7",
45+
"typestrict": "^1.0.2",
46+
"uglify-js": "^3.7.7"
47+
},
48+
"prettier": {
49+
"printWidth": 160,
50+
"tabWidth": 4,
51+
"trailingComma": "es5",
52+
"bracketSpacing": false,
53+
"jsxBracketSameLine": true,
54+
"arrowParens": "always",
55+
"overrides": [
56+
{
57+
"files": "*.yml",
58+
"options": {
59+
"tabWidth": 2
60+
}
61+
}
62+
]
63+
}
64+
}

src/Util.ts

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import {ApiErrorResponse} from "./kms/KmsApi";
44
import {TenantSecurityErrorCode, TenantSecurityException} from "./TenantSecurityException";
55
import {TenantSecurityExceptionUtils} from "./TenantSecurityExceptionUtils";
66
import {TspServiceException} from "./TspServiceException";
7+
import {version} from "../package.json";
78
import * as Crypto from "./kms/Crypto";
89
import * as DetCrypto from "./kms/DeterministicCrypto";
910
import * as http from "http";
@@ -35,14 +36,16 @@ const agentSelector = function (_parsedURL: any) {
3536
* Request the provided API endpoint with the provided POST data. All requests to the TSP today are in POST. On failure,
3637
* attempt to parse the failed JSON to extract an error code and message.
3738
*/
38-
export const makeJsonRequest = <T>(tspDomain: string, apiKey: string, route: string, postData: string): Future<TenantSecurityException, T> =>
39+
export const makeJsonRequest = <T,>(tspDomain: string, apiKey: string, route: string, postData: string): Future<TenantSecurityException, T> =>
3940
Future.tryP(() =>
4041
fetch(`${tspDomain}/api/1/${route}`, {
4142
method: "POST",
4243
body: postData,
4344
headers: {
4445
"Content-Type": "application/json",
4546
Authorization: `cmk ${apiKey}`,
47+
"x-icl-tsc-language": "node",
48+
"x-icl-tsc-version": `${version}`,
4649
},
4750
agent: agentSelector,
4851
})
@@ -71,7 +74,7 @@ export const clearUndefinedProperties = (obj: {[key: string]: any}): {[key: stri
7174
* Take a batch result of encrypt/decrypt operations and convert it into the return structure from the SDK, calculating
7275
* some convenience fields on the response for successes and failures.
7376
*/
74-
export const mapBatchOperationToResult = <T>(
77+
export const mapBatchOperationToResult = <T,>(
7578
successesAndFailures:
7679
| Record<string, Crypto.BatchEncryptResult>
7780
| Record<string, Crypto.BatchDecryptResult>

0 commit comments

Comments
 (0)