@pallasoft/ps-utilities 2.18.0 → 2.19.1
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/bin/ps-worker-bundle-check.js +4 -0
- package/dist/build/index.d.ts +6 -0
- package/dist/build/index.js +18 -0
- package/dist/build/worker-bundle-cli.d.ts +5 -0
- package/dist/build/worker-bundle-cli.js +40 -0
- package/dist/build/worker-bundle-service.d.ts +10 -0
- package/dist/build/worker-bundle-service.js +100 -0
- package/dist/esm/build/index.js +2 -0
- package/dist/esm/build/worker-bundle-cli.js +33 -0
- package/dist/esm/build/worker-bundle-service.js +80 -0
- package/dist/esm/client/constants/device-config.js +6 -0
- package/dist/esm/client/debounce-service.js +34 -0
- package/dist/esm/client/device-service.js +15 -0
- package/dist/esm/client/http-service.js +51 -0
- package/dist/esm/client/index.js +3 -0
- package/dist/esm/common/amount-service.js +37 -0
- package/dist/esm/common/base64-service.js +17 -0
- package/dist/esm/common/color-service.js +8 -0
- package/dist/esm/common/constants/amount-config.js +8 -0
- package/dist/esm/common/constants/amount-direction.js +6 -0
- package/dist/esm/common/constants/email-preview-config.js +30 -0
- package/dist/esm/common/constants/error-response-config.js +4 -0
- package/dist/esm/common/constants/file-size-config.js +5 -0
- package/dist/esm/common/constants/http-auth-scheme.js +3 -0
- package/dist/esm/common/constants/http-content-type.js +8 -0
- package/dist/esm/common/constants/http-header.js +23 -0
- package/dist/esm/common/constants/http-method.js +10 -0
- package/dist/esm/common/constants/index.js +19 -0
- package/dist/esm/common/constants/phone-config.js +6 -0
- package/dist/esm/common/constants/portable-text-config.js +17 -0
- package/dist/esm/common/constants/postal-code-formats.js +10 -0
- package/dist/esm/common/constants/relative-time-config.js +11 -0
- package/dist/esm/common/constants/request-client-config.js +6 -0
- package/dist/esm/common/constants/signed-token-config.js +11 -0
- package/dist/esm/common/constants/socket-token-config.js +4 -0
- package/dist/esm/common/constants/user-agent-config.js +18 -0
- package/dist/esm/common/constants/user-token-config.js +5 -0
- package/dist/esm/common/constants/validation-config.js +8 -0
- package/dist/esm/common/crypto-service.js +128 -0
- package/dist/esm/common/date-service.js +101 -0
- package/dist/esm/common/email-preview-service.js +142 -0
- package/dist/esm/common/encrypted-fields-service.js +49 -0
- package/dist/esm/common/envelope-crypto-service.js +48 -0
- package/dist/esm/common/error-response-service.js +20 -0
- package/dist/esm/common/file-size-service.js +15 -0
- package/dist/esm/common/index.js +27 -0
- package/dist/esm/common/json-service.js +16 -0
- package/dist/esm/common/number-format-service.js +22 -0
- package/dist/esm/common/phone-service.js +70 -0
- package/dist/esm/common/portable-text-service.js +97 -0
- package/dist/esm/common/postal-code-service.js +34 -0
- package/dist/esm/common/recaptcha-service.js +23 -0
- package/dist/esm/common/relative-time-service.js +18 -0
- package/dist/esm/common/request-client-service.js +20 -0
- package/dist/esm/common/signed-token-service.js +111 -0
- package/dist/esm/common/socket-token-service.js +22 -0
- package/dist/esm/common/string-service.js +5 -0
- package/dist/esm/common/transform-service.js +12 -0
- package/dist/esm/common/url-service.js +15 -0
- package/dist/esm/common/user-agent-service.js +26 -0
- package/dist/esm/common/user-token-service.js +59 -0
- package/dist/esm/common/validation-service.js +29 -0
- package/dist/esm/index.js +4 -0
- package/dist/esm/models/coded-error-data.js +1 -0
- package/dist/esm/models/device-data.js +1 -0
- package/dist/esm/models/email-preview-input.js +1 -0
- package/dist/esm/models/encrypted-value-payload.js +1 -0
- package/dist/esm/models/json-value-guard.js +1 -0
- package/dist/esm/models/phone-country-data.js +1 -0
- package/dist/esm/models/phone-display-data.js +1 -0
- package/dist/esm/models/postal-code-format-data.js +1 -0
- package/dist/esm/models/relative-time-options.js +1 -0
- package/dist/esm/models/request-client-data.js +1 -0
- package/dist/esm/models/request-client-options.js +1 -0
- package/dist/esm/models/signed-token-header.js +1 -0
- package/dist/esm/models/signed-token-key-pair.js +1 -0
- package/dist/esm/models/socket-client-options.js +1 -0
- package/dist/esm/models/socket-token-claims.js +1 -0
- package/dist/esm/models/user-token-claims.js +1 -0
- package/dist/esm/models/user-token-issue-options.js +1 -0
- package/dist/esm/models/user-token-request.js +1 -0
- package/dist/esm/models/user-token-subject.js +1 -0
- package/dist/esm/models/user-token-verify-options.js +1 -0
- package/dist/esm/models/worker-bundle-budget-data.js +1 -0
- package/dist/esm/models/worker-bundle-file-data.js +1 -0
- package/dist/esm/models/worker-bundle-options-data.js +1 -0
- package/dist/esm/models/worker-bundle-report-data.js +1 -0
- package/dist/esm/package.json +1 -0
- package/dist/esm/server/file-service.js +41 -0
- package/dist/esm/server/index.js +2 -0
- package/dist/esm/server/timing-safe-service.js +8 -0
- package/dist/esm/sockets/index.js +1 -0
- package/dist/esm/sockets/socket-client-service.js +10 -0
- package/dist/index.d.ts +2 -4
- package/dist/index.js +3 -5
- package/dist/models/worker-bundle-budget-data.d.ts +5 -0
- package/dist/models/worker-bundle-budget-data.js +2 -0
- package/dist/models/worker-bundle-file-data.d.ts +6 -0
- package/dist/models/worker-bundle-file-data.js +2 -0
- package/dist/models/worker-bundle-options-data.d.ts +6 -0
- package/dist/models/worker-bundle-options-data.js +2 -0
- package/dist/models/worker-bundle-report-data.d.ts +8 -0
- package/dist/models/worker-bundle-report-data.js +2 -0
- package/package.json +17 -2
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
import { Readable } from 'stream';
|
|
2
|
+
export class FileService {
|
|
3
|
+
static async getUploadedFile(c, fieldName) {
|
|
4
|
+
const formData = await c.req.formData();
|
|
5
|
+
const file = formData.get(fieldName);
|
|
6
|
+
if (!(file instanceof File))
|
|
7
|
+
return null;
|
|
8
|
+
const webStream = file.stream();
|
|
9
|
+
const nodeStream = new Readable({
|
|
10
|
+
async read() {
|
|
11
|
+
const reader = webStream.getReader();
|
|
12
|
+
try {
|
|
13
|
+
while (true) {
|
|
14
|
+
const { done, value } = await reader.read();
|
|
15
|
+
if (done) {
|
|
16
|
+
this.push(null);
|
|
17
|
+
break;
|
|
18
|
+
}
|
|
19
|
+
this.push(value);
|
|
20
|
+
}
|
|
21
|
+
}
|
|
22
|
+
catch (error) {
|
|
23
|
+
this.destroy(error);
|
|
24
|
+
}
|
|
25
|
+
finally {
|
|
26
|
+
reader.releaseLock();
|
|
27
|
+
}
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
Object.defineProperty(nodeStream, 'contentLength', {
|
|
31
|
+
value: file.size,
|
|
32
|
+
writable: false,
|
|
33
|
+
enumerable: true,
|
|
34
|
+
});
|
|
35
|
+
return {
|
|
36
|
+
filename: file.name,
|
|
37
|
+
type: file.type,
|
|
38
|
+
stream: nodeStream,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
}
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import { timingSafeEqual } from 'node:crypto';
|
|
2
|
+
export class TimingSafeService {
|
|
3
|
+
static equals(candidate, secret) {
|
|
4
|
+
const candidateBytes = Buffer.from(candidate);
|
|
5
|
+
const secretBytes = Buffer.from(secret);
|
|
6
|
+
return (candidateBytes.length === secretBytes.length && timingSafeEqual(candidateBytes, secretBytes));
|
|
7
|
+
}
|
|
8
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export * from './socket-client-service.js';
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import { io } from 'socket.io-client';
|
|
2
|
+
export class SocketClientService {
|
|
3
|
+
static connect(options) {
|
|
4
|
+
return io({
|
|
5
|
+
path: options.path,
|
|
6
|
+
transports: options.transports === undefined ? ['websocket'] : options.transports,
|
|
7
|
+
auth: (send) => send({ token: options.token() }),
|
|
8
|
+
});
|
|
9
|
+
}
|
|
10
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -1,7 +1,5 @@
|
|
|
1
|
-
|
|
2
|
-
|
|
3
|
-
export declare const Common: typeof CommonNamespace;
|
|
4
|
-
export declare const Client: typeof ClientNamespace;
|
|
1
|
+
export * as Client from './client';
|
|
2
|
+
export * as Common from './common';
|
|
5
3
|
export { AmountDirection } from './common/constants/amount-direction';
|
|
6
4
|
export { HttpMethod } from './common/constants/http-method';
|
|
7
5
|
export type { CodedErrorData } from './models/coded-error-data';
|
package/dist/index.js
CHANGED
|
@@ -33,11 +33,9 @@ var __importStar = (this && this.__importStar) || (function () {
|
|
|
33
33
|
};
|
|
34
34
|
})();
|
|
35
35
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
36
|
-
exports.HttpMethod = exports.AmountDirection = exports.
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
exports.Common = CommonNamespace;
|
|
40
|
-
exports.Client = ClientNamespace;
|
|
36
|
+
exports.HttpMethod = exports.AmountDirection = exports.Common = exports.Client = void 0;
|
|
37
|
+
exports.Client = __importStar(require("./client"));
|
|
38
|
+
exports.Common = __importStar(require("./common"));
|
|
41
39
|
var amount_direction_1 = require("./common/constants/amount-direction");
|
|
42
40
|
Object.defineProperty(exports, "AmountDirection", { enumerable: true, get: function () { return amount_direction_1.AmountDirection; } });
|
|
43
41
|
var http_method_1 = require("./common/constants/http-method");
|
package/package.json
CHANGED
|
@@ -1,22 +1,32 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@pallasoft/ps-utilities",
|
|
3
|
-
"version": "2.
|
|
3
|
+
"version": "2.19.1",
|
|
4
4
|
"private": false,
|
|
5
5
|
"main": "./dist/index.js",
|
|
6
|
+
"module": "./dist/esm/index.js",
|
|
7
|
+
"sideEffects": false,
|
|
6
8
|
"types": "./dist/index.d.ts",
|
|
7
9
|
"exports": {
|
|
8
10
|
".": {
|
|
9
11
|
"types": "./dist/index.d.ts",
|
|
12
|
+
"module": "./dist/esm/index.js",
|
|
10
13
|
"require": "./dist/index.js",
|
|
11
14
|
"default": "./dist/index.js"
|
|
12
15
|
},
|
|
13
16
|
"./server": {
|
|
14
17
|
"types": "./dist/server/index.d.ts",
|
|
18
|
+
"module": "./dist/esm/server/index.js",
|
|
15
19
|
"require": "./dist/server/index.js",
|
|
16
20
|
"default": "./dist/server/index.js"
|
|
17
21
|
},
|
|
22
|
+
"./build": {
|
|
23
|
+
"types": "./dist/build/index.d.ts",
|
|
24
|
+
"require": "./dist/build/index.js",
|
|
25
|
+
"default": "./dist/build/index.js"
|
|
26
|
+
},
|
|
18
27
|
"./sockets": {
|
|
19
28
|
"types": "./dist/sockets/index.d.ts",
|
|
29
|
+
"module": "./dist/esm/sockets/index.js",
|
|
20
30
|
"require": "./dist/sockets/index.js",
|
|
21
31
|
"default": "./dist/sockets/index.js"
|
|
22
32
|
}
|
|
@@ -25,12 +35,16 @@
|
|
|
25
35
|
"type": "git",
|
|
26
36
|
"url": "git+https://github.com/pallasoft/ps-utilities.git"
|
|
27
37
|
},
|
|
38
|
+
"bin": {
|
|
39
|
+
"ps-worker-bundle-check": "./bin/ps-worker-bundle-check.js"
|
|
40
|
+
},
|
|
28
41
|
"files": [
|
|
42
|
+
"/bin",
|
|
29
43
|
"/dist"
|
|
30
44
|
],
|
|
31
45
|
"scripts": {
|
|
32
46
|
"husky:prepare": "npx husky",
|
|
33
|
-
"build": "tsc",
|
|
47
|
+
"build": "tsc && tsc -p tsconfig.esm.json && tsc-esm-fix --target=dist/esm --ext=.js && node -e \"require('fs').writeFileSync('dist/esm/package.json', JSON.stringify({ type: 'module' }))\"",
|
|
34
48
|
"setup:graphify": "sh scripts/graphify-setup.sh",
|
|
35
49
|
"update:graphify": "sh scripts/graphify-update.sh",
|
|
36
50
|
"lint": "npm run lint:eslint",
|
|
@@ -68,6 +82,7 @@
|
|
|
68
82
|
"semantic-release": "^24.2.0",
|
|
69
83
|
"socket.io-client": "^4.8.3",
|
|
70
84
|
"ts-node": "^10.9.2",
|
|
85
|
+
"tsc-esm-fix": "^3.1.2",
|
|
71
86
|
"typescript": "^5.9.3",
|
|
72
87
|
"vitest": "^3.2.7"
|
|
73
88
|
},
|