@rpcbase/server 0.203.0 → 0.204.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.
Files changed (2) hide show
  1. package/get_object_id.js +7 -7
  2. package/package.json +1 -1
package/get_object_id.js CHANGED
@@ -5,27 +5,27 @@ const crypto = require("crypto")
5
5
  const isHexadecimal = require("validator/lib/isHexadecimal")
6
6
 
7
7
 
8
- const {CUSTOMER_PREFIX} = process.env
8
+ const {TENANT_PREFIX} = process.env
9
9
 
10
10
  // TODO: WARNING: DANGER: this code is duplicated in the client
11
11
  // TODO: move it to iso
12
12
 
13
13
  // Validation
14
14
  // is defined
15
- assert(CUSTOMER_PREFIX, "expected CUSTOMER_PREFIX to be defined")
15
+ assert(TENANT_PREFIX, "expected TENANT_PREFIX to be defined")
16
16
  // is hexadecimal
17
- assert(isHexadecimal(CUSTOMER_PREFIX), "expected CUSTOMER_PREFIX to be a hexadecimal")
17
+ assert(isHexadecimal(TENANT_PREFIX), "expected TENANT_PREFIX to be a hexadecimal")
18
18
  // is 4 bytes
19
- assert(CUSTOMER_PREFIX.length === 8, "CUSTOMER_PREFIX must be exactly bytes long ie: 8 hex chars")
19
+ assert(TENANT_PREFIX.length === 8, "TENANT_PREFIX must be exactly bytes long ie: 8 hex chars")
20
20
  // is lower than
21
21
  const max_val = parseInt("6387427d", 16)
22
- const customer_prefix_int = parseInt(CUSTOMER_PREFIX, 16)
23
- assert(max_val - customer_prefix_int > 0, "CUSTOMER_PREFIX must be lower than 6387427d")
22
+ const tenant_prefix_int = parseInt(TENANT_PREFIX, 16)
23
+ assert(max_val - tenant_prefix_int > 0, "TENANT_PREFIX must be lower than 6387427d")
24
24
 
25
25
  // generates a 12 bytes mongodb object id using the org id prefix or custom customer id
26
26
  const get_object_id = () => {
27
27
  const random_bytes = crypto.randomBytes(8)
28
- const obj_id = `${CUSTOMER_PREFIX}${random_bytes.toString("hex")}`
28
+ const obj_id = `${TENANT_PREFIX}${random_bytes.toString("hex")}`
29
29
  return obj_id
30
30
  }
31
31
 
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@rpcbase/server",
3
- "version": "0.203.0",
3
+ "version": "0.204.0",
4
4
  "license": "SSPL-1.0",
5
5
  "main": "./index.js",
6
6
  "bin": {