@softwear/latestcollectioncore 1.0.153 → 1.0.159
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/cryptography.d.ts +0 -1
- package/dist/cryptography.js +19 -8
- package/dist/index.d.ts +2 -2
- package/dist/index.js +8 -3
- package/package.json +16 -3
- package/scripts/verify-exports.mjs +32 -0
- package/src/cryptography.ts +13 -2
- package/src/index.ts +32 -2
- package/test/cryptography.spec.js +1 -1
package/dist/cryptography.d.ts
CHANGED
package/dist/cryptography.js
CHANGED
|
@@ -1,31 +1,42 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.decrypt = exports.encrypt = void 0;
|
|
4
|
-
|
|
5
|
-
|
|
4
|
+
/**
|
|
5
|
+
* Node-only AES-GCM. Import from `@softwear/latestcollectioncore/cryptography` (not the main package).
|
|
6
|
+
* Uses global `Buffer` and bare `crypto` so bundlers need not resolve `node:` URLs.
|
|
7
|
+
*/
|
|
8
|
+
const crypto_1 = require("crypto");
|
|
9
|
+
function assertNodeOnly() {
|
|
10
|
+
var _a;
|
|
11
|
+
if (typeof process === 'undefined' || !((_a = process.versions) === null || _a === void 0 ? void 0 : _a.node)) {
|
|
12
|
+
throw new Error('@softwear/latestcollectioncore/cryptography is Node-only');
|
|
13
|
+
}
|
|
14
|
+
}
|
|
6
15
|
function encrypt(plain, KEY) {
|
|
7
|
-
|
|
8
|
-
const
|
|
9
|
-
const
|
|
16
|
+
assertNodeOnly();
|
|
17
|
+
const iv = (0, crypto_1.randomBytes)(12);
|
|
18
|
+
const cipher = (0, crypto_1.createCipheriv)('aes-256-gcm', KEY, iv);
|
|
19
|
+
const ciphertext = Buffer.concat([cipher.update(plain, 'utf8'), cipher.final()]);
|
|
10
20
|
const tag = cipher.getAuthTag();
|
|
11
21
|
const b64 = (b) => b.toString('base64').replace(/\+/g, '-').replace(/\//g, '_').replace(/=+$/g, '');
|
|
12
22
|
return `v1:${b64(iv)}:${b64(ciphertext)}:${b64(tag)}`;
|
|
13
23
|
}
|
|
14
24
|
exports.encrypt = encrypt;
|
|
15
25
|
function decrypt(enc, KEY) {
|
|
26
|
+
assertNodeOnly();
|
|
16
27
|
const [version, ivB64, ctB64, tagB64] = enc.split(':');
|
|
17
28
|
if (version !== 'v1')
|
|
18
29
|
throw new Error('Unsupported version');
|
|
19
30
|
const fromB64 = (s) => {
|
|
20
31
|
const pad = s.length % 4 ? '='.repeat(4 - (s.length % 4)) : '';
|
|
21
|
-
return
|
|
32
|
+
return Buffer.from(s.replace(/-/g, '+').replace(/_/g, '/') + pad, 'base64');
|
|
22
33
|
};
|
|
23
34
|
const iv = fromB64(ivB64);
|
|
24
35
|
const ct = fromB64(ctB64);
|
|
25
36
|
const tag = fromB64(tagB64);
|
|
26
|
-
const decipher = (0,
|
|
37
|
+
const decipher = (0, crypto_1.createDecipheriv)('aes-256-gcm', KEY, iv);
|
|
27
38
|
decipher.setAuthTag(tag);
|
|
28
|
-
const plain =
|
|
39
|
+
const plain = Buffer.concat([decipher.update(ct), decipher.final()]);
|
|
29
40
|
return plain.toString('utf8');
|
|
30
41
|
}
|
|
31
42
|
exports.decrypt = decrypt;
|
package/dist/index.d.ts
CHANGED
|
@@ -15,8 +15,8 @@ export { default as pivotTable } from './pivotTable';
|
|
|
15
15
|
export { default as round2 } from './round2';
|
|
16
16
|
export { default as sizeToMap } from './sizeToMap';
|
|
17
17
|
export { default as transaction } from './transaction';
|
|
18
|
-
export
|
|
18
|
+
export type { AggregateFnI, AggregatorFnI, AttributeI, BrandSettingI, ColorI, dbTransactionI, DocumentItemI, GroupI, HrTimeframeI, ImageI, MarkedSkuI, MatrixI, ProductI, RaGI, RowI, SkuI, StockTransferDataI, StockTransferMatrixI, StockTransferSelectionI, TransactionI, } from './types';
|
|
19
|
+
export { mappingStrategyE, subscriptionE, tagTypeE, TimeGranularityE, transactionTypeE, vatCategoryE, } from './types';
|
|
19
20
|
export * from './consts';
|
|
20
|
-
export * from './cryptography';
|
|
21
21
|
export { default as lcAxios, createAxiosInstance, axiosRetry, exponentialDelay, isAxiosError, } from './lcAxios';
|
|
22
22
|
export type { AxiosRequestConfig, AxiosResponse, AxiosPromise, AxiosError, AxiosTransformer, AxiosRetryOptions, AxiosRequestConfigAny, } from './lcAxios';
|
package/dist/index.js
CHANGED
|
@@ -17,7 +17,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
17
17
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
18
18
|
};
|
|
19
19
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
20
|
-
exports.isAxiosError = exports.exponentialDelay = exports.axiosRetry = exports.createAxiosInstance = exports.lcAxios = exports.transaction = exports.sizeToMap = exports.round2 = exports.pivotTable = exports.isean13 = exports.imageBinder = exports.hasOnlyDigits = exports.hashBrand = exports.getPreferedPropertyMappings = exports.getBrandName = exports.findSkuByBarcode = exports.ensureArray = exports.edifact = exports.ean13 = exports.deepCopy = exports.buildPropertyMappingFn = exports.articleStatus = void 0;
|
|
20
|
+
exports.isAxiosError = exports.exponentialDelay = exports.axiosRetry = exports.createAxiosInstance = exports.lcAxios = exports.vatCategoryE = exports.transactionTypeE = exports.TimeGranularityE = exports.tagTypeE = exports.subscriptionE = exports.mappingStrategyE = exports.transaction = exports.sizeToMap = exports.round2 = exports.pivotTable = exports.isean13 = exports.imageBinder = exports.hasOnlyDigits = exports.hashBrand = exports.getPreferedPropertyMappings = exports.getBrandName = exports.findSkuByBarcode = exports.ensureArray = exports.edifact = exports.ean13 = exports.deepCopy = exports.buildPropertyMappingFn = exports.articleStatus = void 0;
|
|
21
21
|
var articleStatus_1 = require("./articleStatus");
|
|
22
22
|
Object.defineProperty(exports, "articleStatus", { enumerable: true, get: function () { return __importDefault(articleStatus_1).default; } });
|
|
23
23
|
var buildPropertyMappingFn_1 = require("./buildPropertyMappingFn");
|
|
@@ -52,9 +52,14 @@ var sizeToMap_1 = require("./sizeToMap");
|
|
|
52
52
|
Object.defineProperty(exports, "sizeToMap", { enumerable: true, get: function () { return __importDefault(sizeToMap_1).default; } });
|
|
53
53
|
var transaction_1 = require("./transaction");
|
|
54
54
|
Object.defineProperty(exports, "transaction", { enumerable: true, get: function () { return __importDefault(transaction_1).default; } });
|
|
55
|
-
|
|
55
|
+
var types_1 = require("./types");
|
|
56
|
+
Object.defineProperty(exports, "mappingStrategyE", { enumerable: true, get: function () { return types_1.mappingStrategyE; } });
|
|
57
|
+
Object.defineProperty(exports, "subscriptionE", { enumerable: true, get: function () { return types_1.subscriptionE; } });
|
|
58
|
+
Object.defineProperty(exports, "tagTypeE", { enumerable: true, get: function () { return types_1.tagTypeE; } });
|
|
59
|
+
Object.defineProperty(exports, "TimeGranularityE", { enumerable: true, get: function () { return types_1.TimeGranularityE; } });
|
|
60
|
+
Object.defineProperty(exports, "transactionTypeE", { enumerable: true, get: function () { return types_1.transactionTypeE; } });
|
|
61
|
+
Object.defineProperty(exports, "vatCategoryE", { enumerable: true, get: function () { return types_1.vatCategoryE; } });
|
|
56
62
|
__exportStar(require("./consts"), exports);
|
|
57
|
-
__exportStar(require("./cryptography"), exports);
|
|
58
63
|
var lcAxios_1 = require("./lcAxios");
|
|
59
64
|
Object.defineProperty(exports, "lcAxios", { enumerable: true, get: function () { return __importDefault(lcAxios_1).default; } });
|
|
60
65
|
Object.defineProperty(exports, "createAxiosInstance", { enumerable: true, get: function () { return lcAxios_1.createAxiosInstance; } });
|
package/package.json
CHANGED
|
@@ -1,14 +1,27 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@softwear/latestcollectioncore",
|
|
3
|
-
|
|
3
|
+
"version": "1.0.159",
|
|
4
4
|
"description": "Core functions for LatestCollections applications",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
7
|
+
"exports": {
|
|
8
|
+
".": {
|
|
9
|
+
"types": "./dist/index.d.ts",
|
|
10
|
+
"default": "./dist/index.js"
|
|
11
|
+
},
|
|
12
|
+
"./cryptography": {
|
|
13
|
+
"types": "./dist/cryptography.d.ts",
|
|
14
|
+
"default": "./dist/cryptography.js"
|
|
15
|
+
}
|
|
16
|
+
},
|
|
7
17
|
"scripts": {
|
|
8
18
|
"build": "tsc -p tsconfig.json",
|
|
19
|
+
"verify": "node scripts/verify-exports.mjs",
|
|
20
|
+
"postbuild": "npm run verify",
|
|
9
21
|
"build:watch": "tsc -p tsconfig.json --watch",
|
|
10
22
|
"test": "vitest run",
|
|
11
23
|
"test:watch": "vitest",
|
|
24
|
+
"prepublishOnly": "npm run build && npm test",
|
|
12
25
|
"dev": "concurrently \"npm:build:watch\" \"npm:test:watch\""
|
|
13
26
|
},
|
|
14
27
|
"repository": {
|
|
@@ -27,8 +40,8 @@
|
|
|
27
40
|
"typescript": "^4.9.4",
|
|
28
41
|
"vitest": "^1.0.0"
|
|
29
42
|
},
|
|
30
|
-
|
|
31
|
-
|
|
43
|
+
"dependencies": {
|
|
44
|
+
"date-fns": "^2.29.3",
|
|
32
45
|
"filtrex": "^2.2.3"
|
|
33
46
|
}
|
|
34
47
|
}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Ensures dist/index.js exposes runtime enums for both CJS require() and ESM named imports
|
|
3
|
+
* (same interop Vite/esbuild rely on). Run after `npm run build`.
|
|
4
|
+
*/
|
|
5
|
+
import { createRequire } from 'module'
|
|
6
|
+
import { dirname, join } from 'path'
|
|
7
|
+
import { fileURLToPath, pathToFileURL } from 'url'
|
|
8
|
+
|
|
9
|
+
const root = dirname(fileURLToPath(import.meta.url))
|
|
10
|
+
const indexPath = join(root, '..', 'dist', 'index.js')
|
|
11
|
+
|
|
12
|
+
const ENUMS = [
|
|
13
|
+
'subscriptionE',
|
|
14
|
+
'vatCategoryE',
|
|
15
|
+
'tagTypeE',
|
|
16
|
+
'mappingStrategyE',
|
|
17
|
+
'transactionTypeE',
|
|
18
|
+
'TimeGranularityE',
|
|
19
|
+
]
|
|
20
|
+
|
|
21
|
+
const require = createRequire(import.meta.url)
|
|
22
|
+
const cjs = require(indexPath)
|
|
23
|
+
for (const name of ENUMS) {
|
|
24
|
+
if (cjs[name] == null) throw new Error(`CJS: missing export "${name}"`)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
const ns = await import(pathToFileURL(indexPath).href)
|
|
28
|
+
for (const name of ENUMS) {
|
|
29
|
+
if (ns[name] == null) throw new Error(`ESM: missing export "${name}"`)
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
console.log('verify-exports: ok (%d enums)', ENUMS.length)
|
package/src/cryptography.ts
CHANGED
|
@@ -1,7 +1,17 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
1
|
+
/**
|
|
2
|
+
* Node-only AES-GCM. Import from `@softwear/latestcollectioncore/cryptography` (not the main package).
|
|
3
|
+
* Uses global `Buffer` and bare `crypto` so bundlers need not resolve `node:` URLs.
|
|
4
|
+
*/
|
|
5
|
+
import { createCipheriv, createDecipheriv, randomBytes } from 'crypto'
|
|
6
|
+
|
|
7
|
+
function assertNodeOnly(): void {
|
|
8
|
+
if (typeof process === 'undefined' || !process.versions?.node) {
|
|
9
|
+
throw new Error('@softwear/latestcollectioncore/cryptography is Node-only')
|
|
10
|
+
}
|
|
11
|
+
}
|
|
3
12
|
|
|
4
13
|
export function encrypt(plain: string, KEY: Buffer): string {
|
|
14
|
+
assertNodeOnly()
|
|
5
15
|
const iv = randomBytes(12)
|
|
6
16
|
const cipher = createCipheriv('aes-256-gcm', KEY, iv)
|
|
7
17
|
const ciphertext = Buffer.concat([cipher.update(plain, 'utf8'), cipher.final()])
|
|
@@ -13,6 +23,7 @@ export function encrypt(plain: string, KEY: Buffer): string {
|
|
|
13
23
|
}
|
|
14
24
|
|
|
15
25
|
export function decrypt(enc: string, KEY: Buffer): string {
|
|
26
|
+
assertNodeOnly()
|
|
16
27
|
const [version, ivB64, ctB64, tagB64] = enc.split(':')
|
|
17
28
|
if (version !== 'v1') throw new Error('Unsupported version')
|
|
18
29
|
|
package/src/index.ts
CHANGED
|
@@ -15,9 +15,39 @@ export { default as pivotTable } from './pivotTable'
|
|
|
15
15
|
export { default as round2 } from './round2'
|
|
16
16
|
export { default as sizeToMap } from './sizeToMap'
|
|
17
17
|
export { default as transaction } from './transaction'
|
|
18
|
-
export
|
|
18
|
+
// Explicit type vs value re-exports: `export *` compiles to CJS `__exportStar`, which some ESM
|
|
19
|
+
// consumers (e.g. Vite) do not surface as named exports. Runtime enums need explicit re-exports.
|
|
20
|
+
export type {
|
|
21
|
+
AggregateFnI,
|
|
22
|
+
AggregatorFnI,
|
|
23
|
+
AttributeI,
|
|
24
|
+
BrandSettingI,
|
|
25
|
+
ColorI,
|
|
26
|
+
dbTransactionI,
|
|
27
|
+
DocumentItemI,
|
|
28
|
+
GroupI,
|
|
29
|
+
HrTimeframeI,
|
|
30
|
+
ImageI,
|
|
31
|
+
MarkedSkuI,
|
|
32
|
+
MatrixI,
|
|
33
|
+
ProductI,
|
|
34
|
+
RaGI,
|
|
35
|
+
RowI,
|
|
36
|
+
SkuI,
|
|
37
|
+
StockTransferDataI,
|
|
38
|
+
StockTransferMatrixI,
|
|
39
|
+
StockTransferSelectionI,
|
|
40
|
+
TransactionI,
|
|
41
|
+
} from './types'
|
|
42
|
+
export {
|
|
43
|
+
mappingStrategyE,
|
|
44
|
+
subscriptionE,
|
|
45
|
+
tagTypeE,
|
|
46
|
+
TimeGranularityE,
|
|
47
|
+
transactionTypeE,
|
|
48
|
+
vatCategoryE,
|
|
49
|
+
} from './types'
|
|
19
50
|
export * from './consts'
|
|
20
|
-
export * from './cryptography'
|
|
21
51
|
export {
|
|
22
52
|
default as lcAxios,
|
|
23
53
|
createAxiosInstance,
|