@futdevpro/nts-dynamo 1.15.122 → 1.15.126

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 (35) hide show
  1. package/.dynamo/logs/cicd-pipeline/output.log +1896 -1880
  2. package/.dynamo/logs/cicd-pipeline/status.json +39 -39
  3. package/build/_collections/signed-url.util.d.ts +85 -0
  4. package/build/_collections/signed-url.util.d.ts.map +1 -0
  5. package/build/_collections/signed-url.util.js +146 -0
  6. package/build/_collections/signed-url.util.js.map +1 -0
  7. package/build/_models/interfaces/signed-url-verify-result.interface.d.ts +14 -0
  8. package/build/_models/interfaces/signed-url-verify-result.interface.d.ts.map +1 -0
  9. package/build/_models/interfaces/signed-url-verify-result.interface.js +3 -0
  10. package/build/_models/interfaces/signed-url-verify-result.interface.js.map +1 -0
  11. package/build/index.d.ts +2 -0
  12. package/build/index.d.ts.map +1 -1
  13. package/build/index.js +2 -0
  14. package/build/index.js.map +1 -1
  15. package/package.json +1 -10
  16. package/src/_collections/signed-url.util.spec.ts +198 -0
  17. package/src/_collections/signed-url.util.ts +170 -0
  18. package/src/_models/interfaces/signed-url-verify-result.interface.ts +13 -0
  19. package/src/index.ts +2 -0
  20. package/build/_modules/ftp/_collections/ftp-url-signer.util.d.ts +0 -37
  21. package/build/_modules/ftp/_collections/ftp-url-signer.util.d.ts.map +0 -1
  22. package/build/_modules/ftp/_collections/ftp-url-signer.util.js +0 -57
  23. package/build/_modules/ftp/_collections/ftp-url-signer.util.js.map +0 -1
  24. package/build/_modules/ftp/_services/ftp-service.api-service.d.ts +0 -63
  25. package/build/_modules/ftp/_services/ftp-service.api-service.d.ts.map +0 -1
  26. package/build/_modules/ftp/_services/ftp-service.api-service.js +0 -84
  27. package/build/_modules/ftp/_services/ftp-service.api-service.js.map +0 -1
  28. package/build/_modules/ftp/index.d.ts +0 -3
  29. package/build/_modules/ftp/index.d.ts.map +0 -1
  30. package/build/_modules/ftp/index.js +0 -8
  31. package/build/_modules/ftp/index.js.map +0 -1
  32. package/src/_modules/ftp/_collections/ftp-url-signer.util.spec.ts +0 -44
  33. package/src/_modules/ftp/_collections/ftp-url-signer.util.ts +0 -60
  34. package/src/_modules/ftp/_services/ftp-service.api-service.ts +0 -120
  35. package/src/_modules/ftp/index.ts +0 -7
@@ -1,3 +0,0 @@
1
- export { DyNTS_FtpUrlSigner_Util } from './_collections/ftp-url-signer.util';
2
- export { DyNTS_FtpService_ApiService, DyNTS_FtpService_Config, DyNTS_FtpService_UploadFile_Input, DyNTS_FtpService_UploadFile_Response, } from './_services/ftp-service.api-service';
3
- //# sourceMappingURL=index.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../../src/_modules/ftp/index.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,uBAAuB,EAAE,MAAM,oCAAoC,CAAC;AAC7E,OAAO,EACL,2BAA2B,EAC3B,uBAAuB,EACvB,iCAAiC,EACjC,oCAAoC,GACrC,MAAM,qCAAqC,CAAC"}
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.DyNTS_FtpService_ApiService = exports.DyNTS_FtpUrlSigner_Util = void 0;
4
- var ftp_url_signer_util_1 = require("./_collections/ftp-url-signer.util");
5
- Object.defineProperty(exports, "DyNTS_FtpUrlSigner_Util", { enumerable: true, get: function () { return ftp_url_signer_util_1.DyNTS_FtpUrlSigner_Util; } });
6
- var ftp_service_api_service_1 = require("./_services/ftp-service.api-service");
7
- Object.defineProperty(exports, "DyNTS_FtpService_ApiService", { enumerable: true, get: function () { return ftp_service_api_service_1.DyNTS_FtpService_ApiService; } });
8
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../../src/_modules/ftp/index.ts"],"names":[],"mappings":";;;AAAA,0EAA6E;AAApE,8HAAA,uBAAuB,OAAA;AAChC,+EAK6C;AAJ3C,sIAAA,2BAA2B,OAAA"}
@@ -1,44 +0,0 @@
1
- import { DyNTS_FtpUrlSigner_Util } from './ftp-url-signer.util';
2
-
3
- /**
4
- * A generikus FTP signed-URL aláíró tesztjei (AAA). Igazolja: a normalizálás + a HMAC determinisztikus,
5
- * a tamper/lejárat eltérő sig-et ad, üres titok → üres serve-URL (gate inaktív).
6
- */
7
- describe('| DyNTS_FtpUrlSigner_Util', () => {
8
- const SECRET: string = 'shared-ftp-signing-secret-123';
9
-
10
- it('| normalizePath: leading-slash le + backslash→slash', () => {
11
- expect(DyNTS_FtpUrlSigner_Util.normalizePath('/a\\b/c')).toBe('a/b/c');
12
- expect(DyNTS_FtpUrlSigner_Util.normalizePath('///x/y')).toBe('x/y');
13
- });
14
-
15
- it('| uploadTarget: accountId/folderPath/fileName', () => {
16
- expect(DyNTS_FtpUrlSigner_Util.uploadTarget('acc', 'invoices/u1', 'inv.pdf')).toBe('acc/invoices/u1/inv.pdf');
17
- });
18
-
19
- it('| sign: determinisztikus + a normalizált path-ra HMAC-el (a nyers és a normalizált egyezik)', () => {
20
- const a: string = DyNTS_FtpUrlSigner_Util.sign('/inv/u1.pdf', 1000, SECRET);
21
- const b: string = DyNTS_FtpUrlSigner_Util.sign('inv/u1.pdf', 1000, SECRET);
22
- expect(a).toBe(b);
23
- expect(a).toMatch(/^[0-9a-f]{64}$/);
24
- });
25
-
26
- it('| sign: eltérő exp / eltérő secret → eltérő aláírás (tamper-evidens)', () => {
27
- const base: string = DyNTS_FtpUrlSigner_Util.sign('inv/u1.pdf', 1000, SECRET);
28
- expect(DyNTS_FtpUrlSigner_Util.sign('inv/u1.pdf', 2000, SECRET)).not.toBe(base);
29
- expect(DyNTS_FtpUrlSigner_Util.sign('inv/u1.pdf', 1000, 'other')).not.toBe(base);
30
- });
31
-
32
- it('| buildSignedServeUrl: exp=now+ttl + sig; a base trailing-slash levágva', () => {
33
- const url: string = DyNTS_FtpUrlSigner_Util.buildSignedServeUrl({
34
- serveBaseUrl: 'https://ftp.host/', ftpPath: '/inv/u1.pdf', ttlMs: 5000, secret: SECRET, nowMs: 1000,
35
- });
36
- expect(url).toBe(`https://ftp.host/inv/u1.pdf?exp=6000&sig=${DyNTS_FtpUrlSigner_Util.sign('inv/u1.pdf', 6000, SECRET)}`);
37
- });
38
-
39
- it('| buildSignedServeUrl: ÜRES titok → üres string (gate inaktív)', () => {
40
- expect(DyNTS_FtpUrlSigner_Util.buildSignedServeUrl({
41
- serveBaseUrl: 'https://ftp.host', ftpPath: 'x.pdf', ttlMs: 5000, secret: '',
42
- })).toBe('');
43
- });
44
- });
@@ -1,60 +0,0 @@
1
- import * as Crypto from 'crypto';
2
-
3
- /**
4
- * FTP signed-URL ALÁÍRÓ (deep/generikus — `@futdevpro/nts-dynamo`).
5
- *
6
- * A böngésző-serve (`<img src>` / letöltő-link) nem tud Bearer-headert küldeni, ezért az
7
- * `fdp-ftp-service` HTTP-kiszolgálása rövid-/közép-életű **aláírt URL**-lel auth-ol. Ez az util a
8
- * megosztott titokkal HMAC-SHA256-tal aláírja a `path + exp`-et, és előállítja a serve-URL-t.
9
- *
10
- * ⚠️ Az algoritmusnak **BIT-RE egyeznie kell** az `fdp-ftp-service` `FtpUrlSignature_Util`-jával
11
- * (kanonikus string: `<normalizedPath>\n<expMs>`; normalizálás: leading-slash le + `\`→`/`), különben
12
- * az ftp elutasítja a signature-t.
13
- *
14
- * **PURE (ADR-004):** ez a modul NEM importál `fdp-templates`-et — a `secret`/`serveBaseUrl` a hívó-
15
- * (consumer-) oldalról jön paraméterként. Így minden FDP-server újrahasználhatja, egyetlen példányban.
16
- */
17
- export class DyNTS_FtpUrlSigner_Util {
18
-
19
- /** Path normalizálás — pontosan az ftp-serve normalizálása (leading-slash le, `\`→`/`). */
20
- static normalizePath(filePath: string): string {
21
- return filePath.replace(/^\/+/, '').replace(/\\/g, '/');
22
- }
23
-
24
- /**
25
- * Kanonikus UPLOAD-cél string: `accountId/folderPath/fileName`. A szerver-szerver (app→ftp) upload
26
- * ezt írja alá → az ftp ugyanígy építi + validálja. Bit-azonos kell legyen a két oldalon.
27
- */
28
- static uploadTarget(accountId: string, folderPath: string, fileName: string): string {
29
- return `${accountId}/${folderPath}/${fileName}`;
30
- }
31
-
32
- /** HMAC-SHA256 a `<normalizedPath>\n<expMs>`-en → hex (az ftp ezt validálja). */
33
- static sign(filePath: string, expMs: number, secret: string): string {
34
- const normalizedPath: string = DyNTS_FtpUrlSigner_Util.normalizePath(filePath);
35
- return Crypto
36
- .createHmac('sha256', secret)
37
- .update(`${normalizedPath}\n${expMs}`, 'utf8')
38
- .digest('hex');
39
- }
40
-
41
- /**
42
- * Teljes aláírt serve-URL egy ftp-path-ból: `<serveBaseUrl>/<normalizedPath>?exp=<ms>&sig=<hex>`.
43
- * Üres `secret` → üres string (a gate inaktív; a hívó dönt a fallback-ről). `nowMs` injektálható teszthez.
44
- */
45
- static buildSignedServeUrl(params: {
46
- serveBaseUrl: string;
47
- ftpPath: string;
48
- ttlMs: number;
49
- secret: string;
50
- nowMs?: number;
51
- }): string {
52
- if (!params.secret) { return ''; }
53
- const now: number = typeof params.nowMs === 'number' ? params.nowMs : Date.now();
54
- const expMs: number = now + params.ttlMs;
55
- const normalizedPath: string = DyNTS_FtpUrlSigner_Util.normalizePath(params.ftpPath);
56
- const sig: string = DyNTS_FtpUrlSigner_Util.sign(normalizedPath, expMs, params.secret);
57
- const base: string = params.serveBaseUrl.replace(/\/+$/, '');
58
- return `${base}/${normalizedPath}?exp=${expMs}&sig=${sig}`;
59
- }
60
- }
@@ -1,120 +0,0 @@
1
- import { DyFM_HttpCallType } from '@futdevpro/fsm-dynamo';
2
-
3
- import { DyNTS_ApiService } from '../../../_services/core/api.service';
4
- import { DyNTS_ApiCall_Params, DyNTS_HttpOptions } from '../../../_models/control-models/api-call-params.control-model';
5
- import { DyNTS_FtpUrlSigner_Util } from '../_collections/ftp-url-signer.util';
6
-
7
- /** A signed UPLOAD-aláírás érvényessége (10 perc) — a szerver-szerver app→ftp feltöltés szinkron, rövid ablak elég. */
8
- const FTP_SIGNED_UPLOAD_TTL_MS: number = 10 * 60 * 1000;
9
- /** A signed SERVE-URL alap-élettartama (30 nap) — a felhasználó később is letölti a fájlt. */
10
- const FTP_SIGNED_SERVE_TTL_MS: number = 30 * 24 * 60 * 60 * 1000;
11
-
12
- /**
13
- * FTP-kliens KONFIG (a consumer adja át — PURE: nincs fdp-templates-függés).
14
- * A `fdp-ftp-service` URL-jei + a megosztott aláíró-titok a hívó-oldalról jönnek.
15
- */
16
- export interface DyNTS_FtpService_Config {
17
- /** az `fdp-ftp-service` API base-URL a szerver-szerver feltöltéshez (pl. `FDP_ftpServiceApiEnv_settings.baseUrl.fromBE`). */
18
- apiBaseUrl: string;
19
- /** a publikus serve-host az aláírt letöltő-URL-ekhez (pl. `FDP_ftpServiceApiEnv_settings.baseUrl.siteAddress`). */
20
- serveBaseUrl: string;
21
- /** a megosztott HMAC-titok (env-var `FTP_URL_SIGNING_SECRET`, MÁR létező). Üres → a serve-gate inaktív. */
22
- signingSecret: string;
23
- /** az upload-endpoint (default `/files/upload`). */
24
- uploadFileEndpoint?: string;
25
- }
26
-
27
- /** FTP-feltöltés bemenete. */
28
- export interface DyNTS_FtpService_UploadFile_Input {
29
- accountId: string;
30
- folderPath: string;
31
- fileName: string;
32
- fileBuffer: Buffer;
33
- }
34
-
35
- /** FTP-feltöltés válasza. */
36
- export interface DyNTS_FtpService_UploadFile_Response {
37
- filePath: string;
38
- ftpPath: string;
39
- }
40
-
41
- /**
42
- * FTP Service API kliens (deep/generikus — `@futdevpro/nts-dynamo`).
43
- * @description A szerver-oldali FTP-KLIENS: a meglévő `fdp-ftp-service` tároló-szervert HÍVJA — fájlt tölt
44
- * fel (signed upload), és aláírt serve-URL-t épít. **NEM tartalmaz FTP-szervert.** A korábban az
45
- * MP-be / token-service-be duplikált FTP-kliens EGYETLEN, flotta-közös kiváltása.
46
- *
47
- * **PURE (ADR-004):** a config (URL-ek + titok) a `DyNTS_FtpService_Config`-ból, a hívó adja át —
48
- * nincs `fdp-templates`-import. Nem singleton: minden consumer a saját config-jával példányosít.
49
- *
50
- * @example
51
- * ```ts
52
- * const ftp: DyNTS_FtpService_ApiService = new DyNTS_FtpService_ApiService({
53
- * apiBaseUrl: FDP_ftpServiceApiEnv_settings.baseUrl.fromBE,
54
- * serveBaseUrl: FDP_ftpServiceApiEnv_settings.baseUrl.siteAddress,
55
- * signingSecret: process.env.FTP_URL_SIGNING_SECRET || '',
56
- * });
57
- * const { ftpPath } = await ftp.uploadFile({ accountId, folderPath: 'invoices/<userId>', fileName, fileBuffer });
58
- * const url: string = ftp.buildSignedServeUrl(ftpPath);
59
- * ```
60
- */
61
- export class DyNTS_FtpService_ApiService {
62
-
63
- private readonly config: DyNTS_FtpService_Config;
64
-
65
- constructor(config: DyNTS_FtpService_Config) {
66
- this.config = config;
67
- }
68
-
69
- private get uploadFileEndpoint(): string {
70
- return this.config.uploadFileEndpoint ?? '/files/upload';
71
- }
72
-
73
- /**
74
- * Fájl feltöltése az `fdp-ftp-service`-re (signed, szerver-szerver).
75
- * @description A kanonikus upload-célt + lejáratot HMAC-aláírjuk a megosztott titokkal; az ftp ezt
76
- * validálja (a signature a KONKRÉT account+path-hoz köt — más account-ra nem replay-elhető).
77
- */
78
- async uploadFile(input: DyNTS_FtpService_UploadFile_Input): Promise<DyNTS_FtpService_UploadFile_Response> {
79
- const expMs: number = Date.now() + FTP_SIGNED_UPLOAD_TTL_MS;
80
- const uploadTarget: string = DyNTS_FtpUrlSigner_Util.uploadTarget(input.accountId, input.folderPath, input.fileName);
81
- const sig: string = DyNTS_FtpUrlSigner_Util.sign(uploadTarget, expMs, this.config.signingSecret);
82
-
83
- return await DyNTS_ApiService.startApiCall<DyNTS_FtpService_UploadFile_Response>(
84
- new DyNTS_ApiCall_Params({
85
- name: 'uploadFile (DyNTS_FtpService)',
86
- type: DyFM_HttpCallType.post,
87
- baseUrl: this.config.apiBaseUrl,
88
- endpoint: this.uploadFileEndpoint,
89
- httpOptions: new DyNTS_HttpOptions({
90
- headers: {
91
- 'Content-Type': 'application/json',
92
- },
93
- }),
94
- }),
95
- {
96
- body: {
97
- accountId: input.accountId,
98
- folderPath: input.folderPath,
99
- fileName: input.fileName,
100
- fileBuffer: input.fileBuffer.toString('base64'),
101
- exp: expMs,
102
- sig: sig,
103
- },
104
- },
105
- );
106
- }
107
-
108
- /**
109
- * Aláírt serve-URL egy `ftpPath`-ból (böngésző-letöltéshez). Üres titok → üres string (gate inaktív).
110
- * @param ttlMs opcionális egyedi élettartam; default 30 nap.
111
- */
112
- buildSignedServeUrl(ftpPath: string, ttlMs: number = FTP_SIGNED_SERVE_TTL_MS): string {
113
- return DyNTS_FtpUrlSigner_Util.buildSignedServeUrl({
114
- serveBaseUrl: this.config.serveBaseUrl,
115
- ftpPath: ftpPath,
116
- ttlMs: ttlMs,
117
- secret: this.config.signingSecret,
118
- });
119
- }
120
- }
@@ -1,7 +0,0 @@
1
- export { DyNTS_FtpUrlSigner_Util } from './_collections/ftp-url-signer.util';
2
- export {
3
- DyNTS_FtpService_ApiService,
4
- DyNTS_FtpService_Config,
5
- DyNTS_FtpService_UploadFile_Input,
6
- DyNTS_FtpService_UploadFile_Response,
7
- } from './_services/ftp-service.api-service';