@oino-ts/hashid 0.1.2 → 0.1.3

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.
@@ -0,0 +1,42 @@
1
+ export declare const OINOHASHID_MIN_LENGTH: number;
2
+ export declare const OINOHASHID_MAX_LENGTH: number;
3
+ /**
4
+ * Hashid implementation for OINO API:s for the purpose of making it infeasible to scan
5
+ * through numeric autoinc keys. It's not a solution to keeping the id secret in insecure
6
+ * channels, just making it hard enough to not iterate through the entire key space. Half
7
+ * of the the hashid length is nonce and half cryptotext, i.e. 16 char hashid 8 chars of
8
+ * base64 encoded nonce ~ 6 bytes or 48 bits of entropy.
9
+ *
10
+ */
11
+ export declare class OINOHashid {
12
+ private _key;
13
+ private _iv;
14
+ private _domainId;
15
+ private _minLength;
16
+ private _staticIds;
17
+ /**
18
+ * Hashid constructor
19
+ *
20
+ * @param key AES128 key (32 char hex-string)
21
+ * @param domainId a sufficiently unique domain ID in which row-Id's are unique
22
+ * @param minLength minimum length of nonce and crypto
23
+ * @param staticIds whether hash values should remain static per row or random values
24
+ *
25
+ */
26
+ constructor(key: string, domainId: string, minLength?: number, staticIds?: boolean);
27
+ /**
28
+ * Encode given id value as a hashid either using random data or given seed value for nonce.
29
+ *
30
+ * @param id numeric value
31
+ * @param cellSeed a sufficiently unique seed for the current cell to keep hashids unique but persistent (e.g. fieldname + primarykey values)
32
+ *
33
+ */
34
+ encode(id: string, cellSeed?: string): string;
35
+ /**
36
+ * Decode given hashid.
37
+ *
38
+ * @param hashid value
39
+ *
40
+ */
41
+ decode(hashid: string): string;
42
+ }
@@ -0,0 +1 @@
1
+ export { OINOHashid } from "./OINOHashid.js";
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@oino-ts/hashid",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "description": "OINO TS package for hashid's.",
5
5
  "author": "Matias Kiviniemi (pragmatta)",
6
6
  "license": "MPL-2.0",
@@ -18,11 +18,11 @@
18
18
  "types": "./dist/types/index.d.ts",
19
19
  "dependencies": {
20
20
  "@types/node": "^20.12.7",
21
- "@oino-ts/common": "0.1.2",
21
+ "@oino-ts/common": "0.1.3",
22
22
  "base-x": "^5.0.0"
23
23
  },
24
24
  "devDependencies": {
25
- "@oino-ts/types": "0.1.2"
25
+ "@oino-ts/types": "0.1.3"
26
26
  },
27
27
  "files": [
28
28
  "src/*.ts",