@sw-tsdk/core 3.11.2 → 4.0.0-alpha.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 (44) hide show
  1. package/package.json +6 -19
  2. package/LICENSE +0 -8
  3. package/lib/base.d.ts +0 -16
  4. package/lib/base.js +0 -58
  5. package/lib/base.js.map +0 -1
  6. package/lib/config-service.d.ts +0 -7
  7. package/lib/config-service.js +0 -37
  8. package/lib/config-service.js.map +0 -1
  9. package/lib/index.d.ts +0 -4
  10. package/lib/index.js +0 -8
  11. package/lib/index.js.map +0 -1
  12. package/lib/models/cipher.d.ts +0 -5
  13. package/lib/models/cipher.js +0 -3
  14. package/lib/models/cipher.js.map +0 -1
  15. package/lib/models/config.d.ts +0 -4
  16. package/lib/models/config.js +0 -3
  17. package/lib/models/config.js.map +0 -1
  18. package/lib/models/index.d.ts +0 -3
  19. package/lib/models/index.js +0 -7
  20. package/lib/models/index.js.map +0 -1
  21. package/lib/models/netrc-entry.d.ts +0 -5
  22. package/lib/models/netrc-entry.js +0 -3
  23. package/lib/models/netrc-entry.js.map +0 -1
  24. package/lib/utils/assertions.d.ts +0 -1
  25. package/lib/utils/assertions.js +0 -10
  26. package/lib/utils/assertions.js.map +0 -1
  27. package/lib/utils/fs-utils.d.ts +0 -3
  28. package/lib/utils/fs-utils.js +0 -41
  29. package/lib/utils/fs-utils.js.map +0 -1
  30. package/lib/utils/index.d.ts +0 -5
  31. package/lib/utils/index.js +0 -9
  32. package/lib/utils/index.js.map +0 -1
  33. package/lib/utils/netrc.d.ts +0 -4
  34. package/lib/utils/netrc.js +0 -48
  35. package/lib/utils/netrc.js.map +0 -1
  36. package/lib/utils/protector.d.ts +0 -9
  37. package/lib/utils/protector.js +0 -52
  38. package/lib/utils/protector.js.map +0 -1
  39. package/lib/utils/streams.d.ts +0 -16
  40. package/lib/utils/streams.js +0 -41
  41. package/lib/utils/streams.js.map +0 -1
  42. package/lib/utils/strings.d.ts +0 -1
  43. package/lib/utils/strings.js +0 -15
  44. package/lib/utils/strings.js.map +0 -1
package/package.json CHANGED
@@ -4,26 +4,19 @@
4
4
  "url": "https://github.com/swimlane/turbine-sdk/issues"
5
5
  },
6
6
  "dependencies": {
7
- "@oclif/core": "2.8.5",
8
- "fs-extra": "11.1.1",
9
- "git-credential-node": "1.1.0",
7
+ "@oclif/core": "4.2.10",
8
+ "fs-extra": "11.3.0",
10
9
  "netrc-parser": "3.1.6",
11
- "npmlog": "7.0.1"
10
+ "npmlog": "7.0.1",
11
+ "tslib": "2.8.1"
12
12
  },
13
13
  "description": "Core library for sw-tsdk",
14
- "directories": {
15
- "lib": "lib"
16
- },
17
- "engines": {
18
- "node": ">=16.13.0"
19
- },
20
14
  "files": [
21
- "lib",
22
15
  "/yarn.lock"
23
16
  ],
24
17
  "homepage": "https://github.com/swimlane/turbine-sdk#readme",
25
18
  "license": "ISC",
26
- "main": "lib/index.js",
19
+ "main": "src/index.js",
27
20
  "name": "@sw-tsdk/core",
28
21
  "publishConfig": {
29
22
  "access": "public"
@@ -32,12 +25,6 @@
32
25
  "type": "git",
33
26
  "url": "git+https://github.com/swimlane/turbine-sdk.git"
34
27
  },
35
- "scripts": {
36
- "build": "rm -rf lib && tsc",
37
- "lint": "eslint . --ext .ts --config .eslintrc",
38
- "test": "jest --passWithNoTests"
39
- },
40
28
  "types": "lib/index.d.ts",
41
- "version": "3.11.2",
42
- "gitHead": "6d49f5984522f27b6d8de39625a0db4735bc03ec"
29
+ "version": "4.0.0-alpha.0"
43
30
  }
package/LICENSE DELETED
@@ -1,8 +0,0 @@
1
- The ISC License (ISC)
2
-
3
- Copyright © SWIMLANE 2021
4
-
5
- Permission to use, copy, modify, and/or distribute this software for any purpose with or without fee is hereby granted, provided that the above copyright notice and this permission notice appear in all copies.
6
-
7
- THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
8
- {"mode":"full","isActive":false}
package/lib/base.d.ts DELETED
@@ -1,16 +0,0 @@
1
- import { Command } from '@oclif/core';
2
- import type { ConfigType, ConfigTypeValue } from './models';
3
- export declare abstract class Base extends Command {
4
- sdkConfig: ConfigType;
5
- environment: string | null;
6
- static BaseFlags: {
7
- 'log-level': import("@oclif/core/lib/interfaces").OptionFlag<string | undefined, import("@oclif/core/lib/interfaces/parser").CustomOptions>;
8
- };
9
- init(): Promise<void>;
10
- catch(error: Error & {
11
- exitCode?: number;
12
- }): Promise<void>;
13
- protected cleanup(): Promise<void>;
14
- protected saveConfig(key: string, value: ConfigTypeValue): Promise<void>;
15
- protected getConfig<T extends ConfigTypeValue>(key: string): Promise<T>;
16
- }
package/lib/base.js DELETED
@@ -1,58 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Base = void 0;
4
- const core_1 = require("@oclif/core");
5
- const config_service_1 = require("./config-service");
6
- const core_2 = require("@oclif/core");
7
- // noinspection JSUnusedGlobalSymbols
8
- class Base extends core_1.Command {
9
- constructor() {
10
- super(...arguments);
11
- this.sdkConfig = {};
12
- this.environment = null;
13
- }
14
- async init() {
15
- const entry = this.config.configDir;
16
- const { flags } = (await this.parse(this.constructor));
17
- if (flags['log-level'] === 'debug') {
18
- core_2.ux.config.outputLevel = 'debug';
19
- }
20
- const configService = new config_service_1.ConfigService(entry);
21
- const config = (await configService.loadConfig()) || {};
22
- this.sdkConfig = config;
23
- for (const signal of ['SIGINT']) {
24
- process.on(signal, async () => {
25
- /** do your logic */
26
- await this.cleanup();
27
- });
28
- }
29
- }
30
- async catch(error) {
31
- await this.cleanup();
32
- throw error;
33
- }
34
- cleanup() {
35
- return Promise.resolve();
36
- }
37
- async saveConfig(key, value) {
38
- const entry = this.config.configDir;
39
- const configService = new config_service_1.ConfigService(entry);
40
- const loadedConfig = await configService.loadConfig() || {};
41
- if (!loadedConfig) {
42
- return;
43
- }
44
- loadedConfig[key] = value;
45
- await configService.saveConfig(loadedConfig);
46
- }
47
- async getConfig(key) {
48
- const entry = this.config.configDir;
49
- const configService = new config_service_1.ConfigService(entry);
50
- const loadedConfig = await configService.loadConfig() || {};
51
- return loadedConfig[key];
52
- }
53
- }
54
- exports.Base = Base;
55
- Base.BaseFlags = {
56
- 'log-level': core_1.Flags.string({ options: ['debug'], hidden: true }),
57
- };
58
- //# sourceMappingURL=base.js.map
package/lib/base.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"base.js","sourceRoot":"","sources":["../src/base.ts"],"names":[],"mappings":";;;AAAA,sCAA0C;AAE1C,qDAA8C;AAC9C,sCAA8B;AAE9B,qCAAqC;AACrC,MAAsB,IAAK,SAAQ,cAAO;IAA1C;;QACE,cAAS,GAAe,EAAE,CAAA;QAE1B,gBAAW,GAAkB,IAAI,CAAA;IAwDnC,CAAC;IAlDC,KAAK,CAAC,IAAI;QACR,MAAM,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,SAAS,CAAA;QACnC,MAAM,EAAC,KAAK,EAAC,GAAG,CAAC,MAAM,IAAI,CAAC,KAAK,CAAC,IAAI,CAAC,WAA6B,CAAC,CAAQ,CAAA;QAE7E,IAAI,KAAK,CAAC,WAAW,CAAC,KAAK,OAAO,EAAE;YAClC,SAAE,CAAC,MAAM,CAAC,WAAW,GAAG,OAAO,CAAA;SAChC;QAED,MAAM,aAAa,GAAG,IAAI,8BAAa,CAAC,KAAK,CAAC,CAAA;QAE9C,MAAM,MAAM,GAAG,CAAC,MAAM,aA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AAE,YAAK,CAAC,MAAM,CAAC,EAAC,OAAO,EAAE,CAAC,OAAO,CAAC,EAAE,MAAM,EAAE,IAAI,EAAC,CAAC;CAC9D,AAFe,CAEf"}
@@ -1,7 +0,0 @@
1
- import type { ConfigType } from './models';
2
- export declare class ConfigService {
3
- private _basePath;
4
- constructor(_basePath: string);
5
- loadConfig(): Promise<ConfigType | null>;
6
- saveConfig(config: ConfigType): Promise<void>;
7
- }
@@ -1,37 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.ConfigService = void 0;
4
- const fs_extra_1 = require("fs-extra");
5
- const node_path_1 = require("node:path");
6
- const utils_1 = require("./utils");
7
- class ConfigService {
8
- // eslint-disable-next-line no-useless-constructor
9
- constructor(_basePath) {
10
- this._basePath = _basePath;
11
- }
12
- async loadConfig() {
13
- const configPath = (0, node_path_1.join)(this._basePath, '.tsdkrc.json');
14
- if (!await (0, utils_1.fileExists)(configPath)) {
15
- await (0, fs_extra_1.ensureFile)(configPath);
16
- await (0, fs_extra_1.writeJson)(configPath, {}, { spaces: 2, EOL: '\n' });
17
- return {};
18
- }
19
- const result = await (0, fs_extra_1.readJson)(configPath);
20
- if (!result) {
21
- return null;
22
- }
23
- return result;
24
- }
25
- async saveConfig(config) {
26
- const configPath = (0, node_path_1.join)(this._basePath, '.tsdkrc.json');
27
- let configValues = {};
28
- if (await (0, utils_1.fileExists)(configPath)) {
29
- configValues = Object.assign(configValues, (await (0, fs_extra_1.readJson)(configPath)));
30
- }
31
- Object.assign(configValues, config);
32
- await (0, fs_extra_1.ensureFile)(configPath);
33
- await (0, fs_extra_1.writeJson)(configPath, configValues, { spaces: 2, EOL: '\n' });
34
- }
35
- }
36
- exports.ConfigService = ConfigService;
37
- //# sourceMappingURL=config-service.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config-service.js","sourceRoot":"","sources":["../src/config-service.ts"],"names":[],"mappings":";;;AACA,uCAAwD;AACxD,yCAA8B;AAC9B,m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sCAoCC"}
package/lib/index.d.ts DELETED
@@ -1,4 +0,0 @@
1
- export * from './base';
2
- export * from './models';
3
- export * from './utils';
4
- export * from './config-service';
package/lib/index.js DELETED
@@ -1,8 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./base"), exports);
5
- tslib_1.__exportStar(require("./models"), exports);
6
- tslib_1.__exportStar(require("./utils"), exports);
7
- tslib_1.__exportStar(require("./config-service"), exports);
8
- //# sourceMappingURL=index.js.map
package/lib/index.js.map DELETED
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":";;;AAAA,iDAAsB;AACtB,mDAAwB;AACxB,kDAAuB;AACvB,2DAAgC"}
@@ -1,5 +0,0 @@
1
- /// <reference types="node" />
2
- export type Cipher = {
3
- cipherKey: Buffer;
4
- hashingSalt: Buffer;
5
- };
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=cipher.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"cipher.js","sourceRoot":"","sources":["../../src/models/cipher.ts"],"names":[],"mappings":""}
@@ -1,4 +0,0 @@
1
- export type ConfigType = {
2
- [key: string]: ConfigTypeValue;
3
- };
4
- export type ConfigTypeValue = string | Date | undefined | Record<string, unknown>;
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=config.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"config.js","sourceRoot":"","sources":["../../src/models/config.ts"],"names":[],"mappings":""}
@@ -1,3 +0,0 @@
1
- export * from './config';
2
- export * from './cipher';
3
- export * from './netrc-entry';
@@ -1,7 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./config"), exports);
5
- tslib_1.__exportStar(require("./cipher"), exports);
6
- tslib_1.__exportStar(require("./netrc-entry"), exports);
7
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/models/index.ts"],"names":[],"mappings":";;;AAAA,mDAAwB;AACxB,mDAAwB;AACxB,wDAA6B"}
@@ -1,5 +0,0 @@
1
- export interface NetrcEntry {
2
- host: string;
3
- login: string;
4
- password: string;
5
- }
@@ -1,3 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- //# sourceMappingURL=netrc-entry.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"netrc-entry.js","sourceRoot":"","sources":["../../src/models/netrc-entry.ts"],"names":[],"mappings":""}
@@ -1 +0,0 @@
1
- export declare function assertIsDefined<T>(value: T, name?: string): asserts value is NonNullable<T>;
@@ -1,10 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.assertIsDefined = void 0;
4
- function assertIsDefined(value, name) {
5
- if (value === undefined || value === null) {
6
- throw new Error(`${name || value} is not defined`);
7
- }
8
- }
9
- exports.assertIsDefined = assertIsDefined;
10
- //# sourceMappingURL=assertions.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"assertions.js","sourceRoot":"","sources":["../../src/utils/assertions.ts"],"names":[],"mappings":";;;AAAA,SAAgB,eAAe,CAAI,KAAQ,EAAE,IAAa;IACxD,IAAI,KAAK,KAAK,SAAS,IAAI,KAAK,KAAK,IAAI,EAAE;QACzC,MAAM,IAAI,KAAK,CAAC,GAAG,IAAI,IAAI,KAAK,iBAAiB,CAAC,CAAA;KACnD;AACH,CAAC;AAJD,0CAIC"}
@@ -1,3 +0,0 @@
1
- export declare function directoryExists(path: string): Promise<boolean>;
2
- export declare function fileExists(path: string): Promise<boolean>;
3
- export declare function hasGit(path: string): Promise<boolean>;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.hasGit = exports.fileExists = exports.directoryExists = void 0;
4
- const node_fs_1 = require("node:fs");
5
- async function directoryExists(path) {
6
- return node_fs_1.promises.stat(path)
7
- .then(stat => {
8
- return stat.isDirectory();
9
- })
10
- .catch(error => {
11
- if (error.code === 'ENOENT') {
12
- return false;
13
- }
14
- throw error;
15
- });
16
- }
17
- exports.directoryExists = directoryExists;
18
- async function fileExists(path) {
19
- return node_fs_1.promises.stat(path)
20
- .then(stat => {
21
- return stat.isFile();
22
- })
23
- .catch(error => {
24
- if (error.code === 'ENOENT') {
25
- return false;
26
- }
27
- throw error;
28
- });
29
- }
30
- exports.fileExists = fileExists;
31
- async function hasGit(path) {
32
- const exists = await directoryExists(path);
33
- if (!exists) {
34
- return false;
35
- }
36
- const results = await node_fs_1.promises.readdir(path, { withFileTypes: true });
37
- const directories = results.filter(d => d.isDirectory());
38
- return directories.some(d => d.name === '.git');
39
- }
40
- exports.hasGit = hasGit;
41
- //# sourceMappingURL=fs-utils.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"fs-utils.js","sourceRoot":"","sources":["../../src/utils/fs-utils.ts"],"names":[],"mappings":";;;AAAA,qCAAgC;AAEzB,KAAK,UAAU,eAAe,CAAC,IAAY;IAChD,OAAO,kBAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;SACzB,IAAI,CAAC,IAAI,CAAC,EAAE;QACX,OAAO,IAAI,CAAC,WAAW,EAAE,CAAA;IAC3B,CAAC,CAAC;SACD,KAAK,CAAC,KAAK,CAAC,EAAE;QACb,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;YAC3B,OAAO,KAAK,CAAA;SACb;QAED,MAAM,KAAK,CAAA;IACb,CAAC,CAAC,CAAA;AACJ,CAAC;AAZD,0CAYC;AAEM,KAAK,UAAU,UAAU,CAAC,IAAY;IAC3C,OAAO,kBAAQ,CAAC,IAAI,CAAC,IAAI,CAAC;SACzB,IAAI,CAAC,IAAI,CAAC,EAAE;QACX,OAAO,IAAI,CAAC,MAAM,EAAE,CAAA;IACtB,CAAC,CAAC;SACD,KAAK,CAAC,KAAK,CAAC,EAAE;QACb,IAAI,KAAK,CAAC,IAAI,KAAK,QAAQ,EAAE;YAC3B,OAAO,KAAK,CAAA;SACb;QAED,MAAM,KAAK,CAAA;IACb,CAAC,CAAC,CAAA;AACJ,CAAC;AAZD,gCAYC;AAEM,KAAK,UAAU,MAAM,CAAC,IAAY;IACvC,MAAM,MAAM,GAAG,MAAM,eAAe,CAAC,IAAI,CAAC,CAAA;IAC1C,IAAI,CAAC,MAAM,EAAE;QACX,OAAO,KAAK,CAAA;KACb;IAED,MAAM,OAAO,GAAG,MAAM,kBAAQ,CAAC,OAAO,CAAC,IAAI,EAAE,EAAC,aAAa,EAAE,IAAI,EAAC,CAAC,CAAA;IAEnE,MAAM,WAAW,GAAG,OAAO,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,WAAW,EAAE,CAAC,CAAA;IACxD,OAAO,WAAW,CAAC,IAAI,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,CAAC,IAAI,KAAK,MAAM,CAAC,CAAA;AACjD,CAAC;AAVD,wBAUC"}
@@ -1,5 +0,0 @@
1
- export * from './fs-utils';
2
- export * from './netrc';
3
- export * from './strings';
4
- export * from './streams';
5
- export * from './assertions';
@@ -1,9 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- const tslib_1 = require("tslib");
4
- tslib_1.__exportStar(require("./fs-utils"), exports);
5
- tslib_1.__exportStar(require("./netrc"), exports);
6
- tslib_1.__exportStar(require("./strings"), exports);
7
- tslib_1.__exportStar(require("./streams"), exports);
8
- tslib_1.__exportStar(require("./assertions"), exports);
9
- //# sourceMappingURL=index.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/utils/index.ts"],"names":[],"mappings":";;;AAAA,qDAA0B;AAC1B,kDAAuB;AACvB,oDAAyB;AACzB,oDAAyB;AACzB,uDAA4B"}
@@ -1,4 +0,0 @@
1
- import type { NetrcEntry } from '../models';
2
- export declare function saveToken(entry: NetrcEntry): Promise<void>;
3
- export declare function getToken(host: string): Promise<NetrcEntry | null>;
4
- export declare function deleteToken(host: string): Promise<void>;
@@ -1,48 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.deleteToken = exports.getToken = exports.saveToken = void 0;
4
- const tslib_1 = require("tslib");
5
- const netrc_parser_1 = tslib_1.__importDefault(require("netrc-parser"));
6
- const protector_1 = require("./protector");
7
- async function saveToken(entry) {
8
- const host = entry.host;
9
- await netrc_parser_1.default.load();
10
- if (!netrc_parser_1.default.machines[host])
11
- netrc_parser_1.default.machines[host] = {};
12
- netrc_parser_1.default.machines[host].login = entry.login;
13
- netrc_parser_1.default.machines[host].password = new protector_1.Protector().encrypt(entry.password);
14
- delete netrc_parser_1.default.machines[host].method;
15
- delete netrc_parser_1.default.machines[host].org;
16
- if (netrc_parser_1.default.machines._tokens) {
17
- for (const token of netrc_parser_1.default.machines._tokens) {
18
- if (host === token.host) {
19
- token.internalWhitespace = '\n ';
20
- }
21
- }
22
- }
23
- await netrc_parser_1.default.save();
24
- }
25
- exports.saveToken = saveToken;
26
- async function getToken(host) {
27
- await netrc_parser_1.default.load();
28
- if (!netrc_parser_1.default.machines[host]) {
29
- return null;
30
- }
31
- let pwd = netrc_parser_1.default.machines[host].password;
32
- if (pwd) {
33
- pwd = new protector_1.Protector().decrypt(pwd);
34
- }
35
- return {
36
- host: host,
37
- login: netrc_parser_1.default.machines[host].login || '',
38
- password: pwd || '',
39
- };
40
- }
41
- exports.getToken = getToken;
42
- async function deleteToken(host) {
43
- await netrc_parser_1.default.load();
44
- delete netrc_parser_1.default.machines[host];
45
- await netrc_parser_1.default.save();
46
- }
47
- exports.deleteToken = deleteToken;
48
- //# sourceMappingURL=netrc.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"netrc.js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,CAAA;IACvC,IAAI,GAAG,EAAE;QACP,GAAG,GAAG,IAAI,qBAAS,EAAE,CAAC,OAAO,CAAC,GAAG,CAAC,CAAA;KACnC;IAED,OAAO;QACL,IAAI,EAAE,IAAI;QACV,KAAK,EAAE,sBAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAC,KAAK,IAAI,EAAE;QACvC,QAAQ,EAAE,GAAG,IAAI,EAAE;KACpB,CAAA;AACH,CAAC;AAhBD,4BAgBC;AAEM,KAAK,UAAU,WAAW,CAAC,IAAY;IAC5C,MAAM,sBAAK,CAAC,IAAI,EAAE,CAAA;IAClB,OAAO,sBAAK,CAAC,QAAQ,CAAC,IAAI,CAAC,CAAA;IAC3B,MAAM,sBAAK,CAAC,IAAI,EAAE,CAAA;AACpB,CAAC;AAJD,kCAIC"}
@@ -1,9 +0,0 @@
1
- export declare class Protector {
2
- private key;
3
- constructor();
4
- private static stretchString;
5
- private static keyFromPassword;
6
- encrypt(sourceData: string): string;
7
- decrypt(encryptedData: string): string;
8
- hash(sourceData: string): number;
9
- }
@@ -1,52 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.Protector = void 0;
4
- const node_crypto_1 = require("node:crypto");
5
- const node_os_1 = require("node:os");
6
- class Protector {
7
- constructor() {
8
- const info = (0, node_os_1.userInfo)();
9
- const uid = info.username;
10
- this.key = Protector.keyFromPassword(uid);
11
- }
12
- // Uses the PBKDF2 algorithm to stretch the string 's' to an arbitrary size,
13
- // in a way that is completely deterministic yet impossible to guess without
14
- // knowing the original string
15
- static stretchString(s, salt, outputLength) {
16
- return (0, node_crypto_1.pbkdf2Sync)(s, salt, 100000, outputLength, 'sha512');
17
- }
18
- // Stretches the password in order to generate a key (for encrypting)
19
- // and a large salt (for hashing)
20
- static keyFromPassword(password) {
21
- // We need 24 bytes for the key, and another 48 bytes for the salt
22
- const keyPlusHashingSalt = Protector.stretchString(password, 'salt', 24 + 48);
23
- return {
24
- cipherKey: keyPlusHashingSalt.slice(0, 24),
25
- hashingSalt: keyPlusHashingSalt.slice(24),
26
- };
27
- }
28
- // Encrypts data using the key generated using the 'keyFromPassword' function
29
- encrypt(sourceData) {
30
- const iv = Buffer.alloc(16, 0); // Initialization vector
31
- const cipher = (0, node_crypto_1.createCipheriv)('aes-192-cbc', this.key.cipherKey, iv);
32
- let encrypted = cipher.update(sourceData, 'ascii', 'base64');
33
- encrypted += cipher.final('base64');
34
- return encrypted;
35
- }
36
- // Decrypts data using the key generated using the 'keyFromPassword' function
37
- decrypt(encryptedData) {
38
- const iv = Buffer.alloc(16, 0); // Initialization vector
39
- const decipher = (0, node_crypto_1.createDecipheriv)('aes-192-cbc', this.key.cipherKey, iv);
40
- let decrypted = decipher.update(encryptedData, 'base64', 'ascii');
41
- decrypted += decipher.final('ascii');
42
- return decrypted;
43
- }
44
- // Computes a unique (integer) hash from the given data, using the salt
45
- // we generated from the password (using 'keyFromPassword')
46
- hash(sourceData) {
47
- const hashBuffer = Protector.stretchString(sourceData, this.key.hashingSalt, 6);
48
- return hashBuffer.readUIntLE(0, 6);
49
- }
50
- }
51
- exports.Protector = Protector;
52
- //# sourceMappingURL=protector.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"protector.js","sourceRoot":"","sources":["../../src/utils/protector.ts"],"names":[],"mappings":";;;AAAA,6CAAwE;AAExE,qCAAgC;AAChC,MAAa,SAAS;IAGpB;QACE,MAAM,IAAI,GAAG,IAAA,kBAAQ,GAAE,CAAA;QACvB,MAAM,GAAG,GAAG,IAAI,CAAC,QAAQ,CAAA;QACzB,IAAI,CAAC,GAAG,GAAG,SAAS,CAAC,eAAe,CAAC,GAAG,CAAC,CAAA;IAC3C,CAAC;IAED,4EAA4E;IAC5E,4EAA4E;IAC5E,8BAA8B;IACtB,MAAM,CAAC,aAAa,CAAC,CAAS,EAAE,IAAqB,EAAE,YAAoB;QACjF,OAAO,IAAA,wBAAU,EAAC,CAAC,EAAE,IAAI,EAAE,MAAO,EAA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,OAAO,SAAS,CAAA;IAClB,CAAC;IAED,uEAAuE;IACvE,2DAA2D;IAC3D,IAAI,CAAC,UAAkB;QACrB,MAAM,UAAU,GAAG,SAAS,CAAC,aAAa,CAAC,UAAU,EAAE,IAAI,CAAC,GAAG,CAAC,WAAW,EAAE,CAAC,CAAC,CAAA;QAC/E,OAAO,UAAU,CAAC,UAAU,CAAC,CAAC,EAAE,CAAC,CAAC,CAAA;IACpC,CAAC;CACF;AAnDD,8BAmDC"}
@@ -1,16 +0,0 @@
1
- /// <reference types="node" />
2
- /// <reference types="node" />
3
- import type { ReadableOptions as ReadableNodeStreamOptions, WritableOptions as WritableNodeStreamOptions } from 'node:stream';
4
- export interface ReadableStreamOptions extends Omit<ReadableNodeStreamOptions, 'read'> {
5
- /**
6
- The amount of data to stream in bytes.
7
-
8
- Set it to `Infinity` to make it produce data until you manually destroy the stream.
9
-
10
- @default 0
11
- */
12
- readonly size?: number;
13
- }
14
- export type WritableStreamOptions = Omit<WritableNodeStreamOptions, 'write'>;
15
- export declare function readableNoopStream({ size, ...options }: ReadableStreamOptions): NodeJS.ReadableStream;
16
- export declare function writableNoopStream(options?: WritableStreamOptions): NodeJS.WritableStream;
@@ -1,41 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.writableNoopStream = exports.readableNoopStream = void 0;
4
- const node_stream_1 = require("node:stream");
5
- const node_buffer_1 = require("node:buffer");
6
- // noinspection JSUnusedGlobalSymbols
7
- function readableNoopStream({ size = 0, ...options }) {
8
- let producedSize = 0;
9
- return new node_stream_1.Readable({
10
- ...options,
11
- read(readSize) {
12
- let shouldEnd = false;
13
- if ((producedSize + readSize) >= size) {
14
- readSize = size - producedSize;
15
- shouldEnd = true;
16
- }
17
- setImmediate(() => {
18
- if (size === 0) {
19
- this.push(null);
20
- }
21
- producedSize += readSize;
22
- this.push(node_buffer_1.Buffer.alloc(readSize));
23
- if (shouldEnd) {
24
- this.push(null);
25
- }
26
- });
27
- },
28
- });
29
- }
30
- exports.readableNoopStream = readableNoopStream;
31
- // noinspection JSUnusedGlobalSymbols
32
- function writableNoopStream(options) {
33
- return new node_stream_1.Writable({
34
- ...options,
35
- write(chunk, encding, callback) {
36
- setImmediate(callback);
37
- },
38
- });
39
- }
40
- exports.writableNoopStream = writableNoopStream;
41
- //# sourceMappingURL=streams.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"streams.js","sourceRoot":"","sources":["../../src/utils/streams.ts"],"names":[],"mappings":";;;AAAA,6CAGoB;AACpB,6CAAkC;AAoBlC,qCAAqC;AACrC,SAAgB,kBAAkB,CAAC,EAAC,IAAI,GAAG,CAAC,EAAE,GAAG,OAAO,EAAwB;IAC9E,IAAI,YAAY,GAAG,CAAC,CAAA;IAEpB,OAAO,IAAI,sBAAc,CAAC;QACxB,GAAG,OAAO;QACV,IAAI,CAAC,QAAQ;YACX,IAAI,SAAS,GAAG,KAAK,CAAA;YAErB,IAAI,CAAC,YAAY,GAAG,QAAQ,CAAC,IAAI,IAAI,EAAE;gBACrC,QAAQ,GAAG,IAAI,GAAG,YAAY,CAAA;gBAC9B,SAAS,GAAG,IAAI,CAAA;aACjB;YAED,YAAY,CAAC,GAAG,EAAE;gBAChB,IAAI,IAAI,KAAK,CAAC,EAAE;oBACd,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;iBAChB;gBAED,YAAY,IAAI,QAAQ,CAAA;gBACxB,IAAI,CAAC,IAAI,CAAC,oBAAM,CAAC,KAAK,CAAC,QAAQ,CAAC,CAAC,CAAA;gBAEjC,IAAI,SAAS,EAAE;oBACb,IAAI,CAAC,IAAI,CAAC,IAAI,CAAC,CAAA;iBAChB;YACH,CAAC,CAAC,CAAA;QACJ,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AA3BD,gDA2BC;AAED,qCAAqC;AACrC,SAAgB,kBAAkB,CAAC,OAA+B;IAChE,OAAO,IAAI,sBAAc,CAAC;QACxB,GAAG,OAAO;QACV,KAAK,CAAC,KAAK,EAAE,OAAO,EAAE,QAAQ;YAC5B,YAAY,CAAC,QAAQ,CAAC,CAAA;QACxB,CAAC;KACF,CAAC,CAAA;AACJ,CAAC;AAPD,gDAOC"}
@@ -1 +0,0 @@
1
- export declare function trimSuffix(toTrim: string, trim: string): string;
@@ -1,15 +0,0 @@
1
- "use strict";
2
- Object.defineProperty(exports, "__esModule", { value: true });
3
- exports.trimSuffix = void 0;
4
- function trimSuffix(toTrim, trim) {
5
- if (!toTrim || !trim) {
6
- return toTrim;
7
- }
8
- const index = toTrim.lastIndexOf(trim);
9
- if (index === -1 || (index + trim.length) !== toTrim.length) {
10
- return toTrim;
11
- }
12
- return toTrim.slice(0, Math.max(0, index));
13
- }
14
- exports.trimSuffix = trimSuffix;
15
- //# sourceMappingURL=strings.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"strings.js","sourceRoot":"","sources":["../../src/utils/strings.ts"],"names":[],"mappings":";;;AAAA,SAAgB,UAAU,CAAC,MAAc,EAAE,IAAY;IACrD,IAAI,CAAC,MAAM,IAAI,CAAC,IAAI,EAAE;QACpB,OAAO,MAAM,CAAA;KACd;IAED,MAAM,KAAK,GAAG,MAAM,CAAC,WAAW,CAAC,IAAI,CAAC,CAAA;IACtC,IAAI,KAAK,KAAK,CAAC,CAAC,IAAI,CAAC,KAAK,GAAG,IAAI,CAAC,MAAM,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE;QAC3D,OAAO,MAAM,CAAA;KACd;IAED,OAAO,MAAM,CAAC,KAAK,CAAC,CAAC,EAAE,IAAI,CAAC,GAAG,CAAC,CAAC,EAAE,KAAK,CAAC,CAAC,CAAA;AAC5C,CAAC;AAXD,gCAWC"}