diff --git a/src/Secret.d.ts b/src/Secret.d.ts deleted file mode 100644 index 24310fe..0000000 --- a/src/Secret.d.ts +++ /dev/null @@ -1,62 +0,0 @@ -import type { Identity, StringKeys } from '@transcend-io/type-utils'; -/** - * A secret that must be explicitly released. It is made to be annoying, so that - * users must really make an effort to release the stored value. - * The goal is to prevent accidentally logging secret values. - */ -export declare class Secret { - /** The secret value */ - private value; - /** - * Constructor - * - * @param value - The secret value - */ - constructor(value: T); - /** - * Ensure secrets are not coerced to their secret values. - * - * toJSON is called in cases like JSON.stringify(obj) - * - * @returns a redacted message - */ - toJSON(): string; - /** - * Ensure secrets are not coerced to their secret values. - * - * @returns a redacted message - */ - valueOf(): string; - /** - * Ensure secrets are not coerced to their secret values. - * - * @returns a redacted message - */ - toLocaleString(): string; - /** - * Ensure secrets are not coerced to their secret values. - * - * @returns a redacted message - */ - toString(): string; - /** - * Releases the secret for usage - * - * @returns the secret value - */ - release(): T; - /** - * Apply a function to the secret value, and returns a new Secret with that value. - * - * @param transformFunc - Function to apply to the current value - * @returns the new secret for chaining other commands - */ - map(transformFunc: (value: T) => R): Secret; -} -/** - * Set the type of values in an object to be Secret by name of object key - */ -export type Secretify> = Identity<{ - [k in keyof T]: k extends TSecretKey ? Secret : T[k]; -}>; -//# sourceMappingURL=Secret.d.ts.map \ No newline at end of file diff --git a/src/Secret.js b/src/Secret.js deleted file mode 100644 index cc0f467..0000000 --- a/src/Secret.js +++ /dev/null @@ -1,84 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.Secret = void 0; -const REDACTED = '[redacted]'; -/** - * A secret that must be explicitly released. It is made to be annoying, so that - * users must really make an effort to release the stored value. - * The goal is to prevent accidentally logging secret values. - */ -class Secret { - /** - * Constructor - * - * @param value - The secret value - */ - constructor(value) { - this.value = value; - } - /* eslint-disable class-methods-use-this */ - /** - * Ensure secrets are not coerced to their secret values. - * - * toJSON is called in cases like JSON.stringify(obj) - * - * @returns a redacted message - */ - toJSON() { - return REDACTED; - } - /** - * Ensure secrets are not coerced to their secret values. - * - * @returns a redacted message - */ - valueOf() { - return REDACTED; - } - /** - * Ensure secrets are not coerced to their secret values. - * - * This is the method used by `console.log` on objects - * - * @returns a redacted message - */ - [Symbol.for('nodejs.util.inspect.custom')]() { - return REDACTED; - } - /** - * Ensure secrets are not coerced to their secret values. - * - * @returns a redacted message - */ - toLocaleString() { - return REDACTED; - } - /** - * Ensure secrets are not coerced to their secret values. - * - * @returns a redacted message - */ - toString() { - return REDACTED; - } - /* eslint-enable class-methods-use-this */ - /** - * Releases the secret for usage - * - * @returns the secret value - */ - release() { - return this.value; - } - /** - * Apply a function to the secret value, and returns a new Secret with that value. - * - * @param transformFunc - Function to apply to the current value - * @returns the new secret for chaining other commands - */ - map(transformFunc) { - return new Secret(transformFunc(this.value)); - } -} -exports.Secret = Secret; -//# sourceMappingURL=Secret.js.map \ No newline at end of file diff --git a/src/Secret.js.map b/src/Secret.js.map deleted file mode 100644 index f7f871f..0000000 --- a/src/Secret.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Secret.js","sourceRoot":"","sources":["Secret.ts"],"names":[],"mappings":";;;AAGA,MAAM,QAAQ,GAAG,YAAY,CAAC;AAE9B;;;;GAIG;AACH,MAAa,MAAM;IAIjB;;;;OAIG;IACH,YAAY,KAAQ;QAClB,IAAI,CAAC,KAAK,GAAG,KAAK,CAAC;IACrB,CAAC;IAED,2CAA2C;IAC3C;;;;;;OAMG;IACI,MAAM;QACX,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACI,OAAO;QACZ,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;;;OAMG;IACH,CAAC,MAAM,CAAC,GAAG,CAAC,4BAA4B,CAAC,CAAC;QACxC,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACI,cAAc;QACnB,OAAO,QAAQ,CAAC;IAClB,CAAC;IAED;;;;OAIG;IACI,QAAQ;QACb,OAAO,QAAQ,CAAC;IAClB,CAAC;IACD,0CAA0C;IAE1C;;;;OAIG;IACI,OAAO;QACZ,OAAO,IAAI,CAAC,KAAK,CAAC;IACpB,CAAC;IAED;;;;;OAKG;IACI,GAAG,CAAI,aAA8B;QAC1C,OAAO,IAAI,MAAM,CAAC,aAAa,CAAC,IAAI,CAAC,KAAK,CAAC,CAAC,CAAC;IAC/C,CAAC;CACF;AAlFD,wBAkFC"} \ No newline at end of file diff --git a/src/index.d.ts b/src/index.d.ts deleted file mode 100644 index 062b43c..0000000 --- a/src/index.d.ts +++ /dev/null @@ -1,4 +0,0 @@ -export * from './Secret'; -export * from './wrapSecrets'; -export * from './secretValue'; -//# sourceMappingURL=index.d.ts.map \ No newline at end of file diff --git a/src/index.js b/src/index.js deleted file mode 100644 index 1e99ae5..0000000 --- a/src/index.js +++ /dev/null @@ -1,20 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __exportStar = (this && this.__exportStar) || function(m, exports) { - for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); -}; -Object.defineProperty(exports, "__esModule", { value: true }); -__exportStar(require("./Secret"), exports); -__exportStar(require("./wrapSecrets"), exports); -__exportStar(require("./secretValue"), exports); -//# sourceMappingURL=index.js.map \ No newline at end of file diff --git a/src/index.js.map b/src/index.js.map deleted file mode 100644 index a1c4d71..0000000 --- a/src/index.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"index.js","sourceRoot":"","sources":["index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,2CAAyB;AACzB,gDAA8B;AAC9B,gDAA8B"} \ No newline at end of file diff --git a/src/secretValue.d.ts b/src/secretValue.d.ts deleted file mode 100644 index 4c3fbd8..0000000 --- a/src/secretValue.d.ts +++ /dev/null @@ -1,34 +0,0 @@ -import * as t from 'io-ts'; -import { Secret } from './Secret'; -/** - * Sometimes we want to add context to the event manager but not log that - * context to console. To do so, wrap the variable in - * import('@transcend-io/secret-value').Secret: - * - * ```ts - * public toContext(): { user: UserLogContext; } { - * return { - * user: { - * id: this.id, - * name: new Secret(this.name), - * email: new Secret(this.email), - * }, - * }; - * } - * ``` - * - * and set the codec to be : secretValue: - * - * ``` - * export const UserLogContext = t.type({ - * id: dbModelId('user'), - * email: secretValue(t.string), - * name: secretValue(t.string), - * }); - * ``` - * - * @param underlyingType - The underlying type of secret - * @returns The secret instance - */ -export declare function secretValue(underlyingType: T): t.Type>, t.TypeOf, unknown>; -//# sourceMappingURL=secretValue.d.ts.map \ No newline at end of file diff --git a/src/secretValue.d.ts.map b/src/secretValue.d.ts.map deleted file mode 100644 index 62af92f..0000000 --- a/src/secretValue.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"secretValue.d.ts","sourceRoot":"","sources":["secretValue.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,CAAC,MAAM,OAAO,CAAC;AAE3B,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAGlC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,CAAC,CAAC,GAAG,EACzC,cAAc,EAAE,CAAC,GAChB,CAAC,CAAC,IAAI,CAAC,MAAM,CAAC,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,CAAC,MAAM,CAAC,CAAC,CAAC,EAAE,OAAO,CAAC,CAiBnD"} \ No newline at end of file diff --git a/src/secretValue.js b/src/secretValue.js deleted file mode 100644 index 21407b9..0000000 --- a/src/secretValue.js +++ /dev/null @@ -1,68 +0,0 @@ -"use strict"; -var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - var desc = Object.getOwnPropertyDescriptor(m, k); - if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { - desc = { enumerable: true, get: function() { return m[k]; } }; - } - Object.defineProperty(o, k2, desc); -}) : (function(o, m, k, k2) { - if (k2 === undefined) k2 = k; - o[k2] = m[k]; -})); -var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { - Object.defineProperty(o, "default", { enumerable: true, value: v }); -}) : function(o, v) { - o["default"] = v; -}); -var __importStar = (this && this.__importStar) || function (mod) { - if (mod && mod.__esModule) return mod; - var result = {}; - if (mod != null) for (var k in mod) if (k !== "default" && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); - __setModuleDefault(result, mod); - return result; -}; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.secretValue = void 0; -const Either_1 = require("fp-ts/lib/Either"); -const pipeable_1 = require("fp-ts/lib/pipeable"); -const t = __importStar(require("io-ts")); -const type_utils_1 = require("@transcend-io/type-utils"); -/** - * Sometimes we want to add context to the event manager but not log that - * context to console. To do so, wrap the variable in - * import('@transcend-io/secret-value').Secret: - * - * ```ts - * public toContext(): { user: UserLogContext; } { - * return { - * user: { - * id: this.id, - * name: new Secret(this.name), - * email: new Secret(this.email), - * }, - * }; - * } - * ``` - * - * and set the codec to be : secretValue: - * - * ``` - * export const UserLogContext = t.type({ - * id: dbModelId('user'), - * email: secretValue(t.string), - * name: secretValue(t.string), - * }); - * ``` - * - * @param underlyingType - The underlying type of secret - * @returns The secret instance - */ -function secretValue(underlyingType) { - return new t.Type('SecretValue', (x) => typeof x === 'object' && - !!x && - x.constructor.name === 'Secret' && - !!(0, type_utils_1.decodeCodec)(underlyingType, x.release()), (u, c) => (0, pipeable_1.pipe)(t.object.validate(u, c), (0, Either_1.chain)((n) => underlyingType.validate(n.release(), c))), (a) => a.toString()); -} -exports.secretValue = secretValue; -//# sourceMappingURL=secretValue.js.map \ No newline at end of file diff --git a/src/secretValue.js.map b/src/secretValue.js.map deleted file mode 100644 index 92ba2a5..0000000 --- a/src/secretValue.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"secretValue.js","sourceRoot":"","sources":["secretValue.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,6CAAyC;AACzC,iDAA0C;AAC1C,yCAA2B;AAG3B,yDAAuD;AAEvD;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GA6BG;AACH,SAAgB,WAAW,CACzB,cAAiB;IAEjB,OAAO,IAAI,CAAC,CAAC,IAAI,CACf,aAAa,EACb,CAAC,CAAC,EAA4B,EAAE,CAC9B,OAAO,CAAC,KAAK,QAAQ;QACrB,CAAC,CAAC,CAAC;QACH,CAAC,CAAC,WAAW,CAAC,IAAI,KAAK,QAAQ;QAC/B,CAAC,CAAC,IAAA,wBAAW,EAAC,cAAc,EAAG,CAAyB,CAAC,OAAO,EAAE,CAAC,EACrE,CAAC,CAAC,EAAE,CAAC,EAAE,EAAE,CACP,IAAA,eAAI,EACF,CAAC,CAAC,MAAM,CAAC,QAAQ,CAAC,CAAC,EAAE,CAAC,CAAC,EACvB,IAAA,cAAK,EAAC,CAAC,CAAC,EAAE,EAAE,CACV,cAAc,CAAC,QAAQ,CAAE,CAAyB,CAAC,OAAO,EAAE,EAAE,CAAC,CAAC,CACjE,CACF,EACH,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,CAAC,QAAQ,EAAE,CACpB,CAAC;AACJ,CAAC;AAnBD,kCAmBC"} \ No newline at end of file diff --git a/src/tests/Secret.test.d.ts b/src/tests/Secret.test.d.ts deleted file mode 100644 index bc5649e..0000000 --- a/src/tests/Secret.test.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export {}; -//# sourceMappingURL=Secret.test.d.ts.map \ No newline at end of file diff --git a/src/tests/Secret.test.d.ts.map b/src/tests/Secret.test.d.ts.map deleted file mode 100644 index a785c0a..0000000 --- a/src/tests/Secret.test.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Secret.test.d.ts","sourceRoot":"","sources":["Secret.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/src/tests/Secret.test.js b/src/tests/Secret.test.js deleted file mode 100644 index 1db717d..0000000 --- a/src/tests/Secret.test.js +++ /dev/null @@ -1,56 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -// external -const chai_1 = require("chai"); -const util_1 = require("util"); -// global -const Secret_1 = require("../Secret"); -describe('Secret', () => { - it('can wrap a string value', () => { - const secret = new Secret_1.Secret('ahhhhhh'); - (0, chai_1.expect)(secret.release()).to.equal('ahhhhhh'); - }); - it('can wrap objects', () => { - const someObject = { - ahhhhhh: 'ahhhhhh', - }; - const secret = new Secret_1.Secret(someObject); - (0, chai_1.expect)(secret.release()).to.deep.equal(someObject); - }); - it('redacts the values when converted to string', () => { - const secret = new Secret_1.Secret('ahhhhhh'); - (0, chai_1.expect)(`${secret}`).to.equal('[redacted]'); - }); - it('redacts values in JSON stringification', () => { - const secret = new Secret_1.Secret('ahhhhhh'); - (0, chai_1.expect)(JSON.stringify({ secret })).to.equal('{"secret":"[redacted]"}'); - }); - it('redacts values in localized format', () => { - const secret = new Secret_1.Secret('ahhhhhh'); - (0, chai_1.expect)(secret.toLocaleString()).to.equal('[redacted]'); - }); - it('redacts values called with valueOf', () => { - const secret = new Secret_1.Secret('ahhhhhh'); - (0, chai_1.expect)(secret.valueOf()).to.equal('[redacted]'); - }); - it('redacts values in console.log format', () => { - const secret = new Secret_1.Secret('ahhhhhh'); - (0, chai_1.expect)((0, util_1.inspect)(secret)).to.equal('[redacted]'); - }); - describe('map', () => { - it('can create a new secret value', () => { - const secret = new Secret_1.Secret('GME'); - (0, chai_1.expect)(secret.map(() => '🌙').release()).to.equal('🌙'); - }); - it('can create a new secret value of a different type', () => { - const secret = new Secret_1.Secret('ahhhhhh'); - (0, chai_1.expect)(secret.map((val) => val.length).release()).to.equal(7); - }); - it('does not affect the original secret', () => { - const secret = new Secret_1.Secret('ahhhhhh'); - secret.map((val) => val.length); - (0, chai_1.expect)(secret.release()).to.equal('ahhhhhh'); - }); - }); -}); -//# sourceMappingURL=Secret.test.js.map \ No newline at end of file diff --git a/src/tests/Secret.test.js.map b/src/tests/Secret.test.js.map deleted file mode 100644 index 4a9138d..0000000 --- a/src/tests/Secret.test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"Secret.test.js","sourceRoot":"","sources":["Secret.test.ts"],"names":[],"mappings":"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"} \ No newline at end of file diff --git a/src/tests/wrapSecrets.test.d.ts b/src/tests/wrapSecrets.test.d.ts deleted file mode 100644 index 5635b77..0000000 --- a/src/tests/wrapSecrets.test.d.ts +++ /dev/null @@ -1,2 +0,0 @@ -export {}; -//# sourceMappingURL=wrapSecrets.test.d.ts.map \ No newline at end of file diff --git a/src/tests/wrapSecrets.test.d.ts.map b/src/tests/wrapSecrets.test.d.ts.map deleted file mode 100644 index e754e87..0000000 --- a/src/tests/wrapSecrets.test.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"wrapSecrets.test.d.ts","sourceRoot":"","sources":["wrapSecrets.test.ts"],"names":[],"mappings":""} \ No newline at end of file diff --git a/src/tests/wrapSecrets.test.js b/src/tests/wrapSecrets.test.js deleted file mode 100644 index 5954339..0000000 --- a/src/tests/wrapSecrets.test.js +++ /dev/null @@ -1,20 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -// external -const chai_1 = require("chai"); -// global -const __1 = require(".."); -describe('wrapSecrets', () => { - it('wraps secrets by key name', () => { - const obj = { - cat: 2, - fish: 'cow', - moose: [2], - }; - const secretObject = (0, __1.wrapSecrets)(obj, ['fish']); - (0, chai_1.expect)(secretObject.cat).to.equal(2); - (0, chai_1.expect)(secretObject.moose[0]).to.equal(2); - (0, chai_1.expect)(secretObject.fish.release()).to.equal('cow'); - }); -}); -//# sourceMappingURL=wrapSecrets.test.js.map \ No newline at end of file diff --git a/src/tests/wrapSecrets.test.js.map b/src/tests/wrapSecrets.test.js.map deleted file mode 100644 index 2ae05d9..0000000 --- a/src/tests/wrapSecrets.test.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"wrapSecrets.test.js","sourceRoot":"","sources":["wrapSecrets.test.ts"],"names":[],"mappings":";;AAAA,WAAW;AACX,+BAA8B;AAE9B,SAAS;AACT,0BAAiC;AAEjC,QAAQ,CAAC,aAAa,EAAE,GAAG,EAAE;IAC3B,EAAE,CAAC,2BAA2B,EAAE,GAAG,EAAE;QACnC,MAAM,GAAG,GAAG;YACV,GAAG,EAAE,CAAC;YACN,IAAI,EAAE,KAAK;YACX,KAAK,EAAE,CAAC,CAAC,CAAC;SACX,CAAC;QAEF,MAAM,YAAY,GAAG,IAAA,eAAW,EAAC,GAAG,EAAE,CAAC,MAAM,CAAC,CAAC,CAAC;QAEhD,IAAA,aAAM,EAAC,YAAY,CAAC,GAAG,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QACrC,IAAA,aAAM,EAAC,YAAY,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC;QAC1C,IAAA,aAAM,EAAC,YAAY,CAAC,IAAI,CAAC,OAAO,EAAE,CAAC,CAAC,EAAE,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC;IACtD,CAAC,CAAC,CAAC;AACL,CAAC,CAAC,CAAC"} \ No newline at end of file diff --git a/src/wrapSecrets.d.ts b/src/wrapSecrets.d.ts deleted file mode 100644 index 705729c..0000000 --- a/src/wrapSecrets.d.ts +++ /dev/null @@ -1,11 +0,0 @@ -import { StringKeys } from '@transcend-io/type-utils'; -import { Secretify } from './Secret'; -/** - * Utility function to wrap values of an object as secrets - * - * @param obj - The object to modify - * @param secretKeys - The keys of the object that should be secrets - * @returns The object with values wrapped as secrets - */ -export declare function wrapSecrets>(obj: T, secretKeys: TSecretKey[]): Secretify; -//# sourceMappingURL=wrapSecrets.d.ts.map \ No newline at end of file diff --git a/src/wrapSecrets.d.ts.map b/src/wrapSecrets.d.ts.map deleted file mode 100644 index 5079502..0000000 --- a/src/wrapSecrets.d.ts.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"wrapSecrets.d.ts","sourceRoot":"","sources":["wrapSecrets.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,UAAU,EAAS,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,SAAS,EAAU,MAAM,UAAU,CAAC;AAE7C;;;;;;GAMG;AACH,wBAAgB,WAAW,CAAC,CAAC,SAAS,MAAM,EAAE,UAAU,SAAS,UAAU,CAAC,CAAC,CAAC,EAC5E,GAAG,EAAE,CAAC,EACN,UAAU,EAAE,UAAU,EAAE,GACvB,SAAS,CAAC,CAAC,EAAE,UAAU,CAAC,CAI1B"} \ No newline at end of file diff --git a/src/wrapSecrets.js b/src/wrapSecrets.js deleted file mode 100644 index 96f1506..0000000 --- a/src/wrapSecrets.js +++ /dev/null @@ -1,18 +0,0 @@ -"use strict"; -Object.defineProperty(exports, "__esModule", { value: true }); -exports.wrapSecrets = void 0; -// local -const type_utils_1 = require("@transcend-io/type-utils"); -const Secret_1 = require("./Secret"); -/** - * Utility function to wrap values of an object as secrets - * - * @param obj - The object to modify - * @param secretKeys - The keys of the object that should be secrets - * @returns The object with values wrapped as secrets - */ -function wrapSecrets(obj, secretKeys) { - return (0, type_utils_1.apply)(obj, (value, key) => secretKeys.includes(key) ? new Secret_1.Secret(value) : value); -} -exports.wrapSecrets = wrapSecrets; -//# sourceMappingURL=wrapSecrets.js.map \ No newline at end of file diff --git a/src/wrapSecrets.js.map b/src/wrapSecrets.js.map deleted file mode 100644 index b0f08f5..0000000 --- a/src/wrapSecrets.js.map +++ /dev/null @@ -1 +0,0 @@ -{"version":3,"file":"wrapSecrets.js","sourceRoot":"","sources":["wrapSecrets.ts"],"names":[],"mappings":";;;AAAA,QAAQ;AACR,yDAA6D;AAC7D,qCAA6C;AAE7C;;;;;;GAMG;AACH,SAAgB,WAAW,CACzB,GAAM,EACN,UAAwB;IAExB,OAAO,IAAA,kBAAK,EAAC,GAAG,EAAE,CAAC,KAAK,EAAE,GAAG,EAAE,EAAE,CAC/B,UAAU,CAAC,QAAQ,CAAC,GAAiB,CAAC,CAAC,CAAC,CAAC,IAAI,eAAM,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,KAAK,CACvC,CAAC;AAChC,CAAC;AAPD,kCAOC"} \ No newline at end of file diff --git a/tsconfig.json b/tsconfig.json index 896f859..488583b 100644 --- a/tsconfig.json +++ b/tsconfig.json @@ -30,7 +30,7 @@ "outDir": "build", "tsBuildInfoFile": "./build/tsbuildinfo", "rootDir": "src", - "types": ["mocha"], + "types": ["mocha"] }, "include": ["src"], "exclude": ["node_modules", "build"],