@smithy/shared-ini-file-loader 4.3.4 → 4.4.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.
- package/dist-cjs/getSSOTokenFromFile.js +2 -3
- package/dist-cjs/index.js +10 -6
- package/dist-cjs/readFile.js +16 -0
- package/dist-es/externalDataInterceptor.js +1 -1
- package/dist-es/getSSOTokenFromFile.js +1 -2
- package/dist-es/index.js +1 -0
- package/dist-es/loadSharedConfigFiles.js +3 -3
- package/dist-es/loadSsoSessionData.js +2 -2
- package/dist-es/readFile.js +12 -0
- package/dist-types/getSSOTokenFromFile.d.ts +2 -0
- package/dist-types/index.d.ts +1 -0
- package/dist-types/readFile.d.ts +21 -0
- package/dist-types/ts3.4/getSSOTokenFromFile.d.ts +2 -0
- package/dist-types/ts3.4/index.d.ts +1 -0
- package/dist-types/ts3.4/readFile.d.ts +21 -0
- package/package.json +5 -5
- package/dist-cjs/slurpFile.js +0 -17
- package/dist-es/slurpFile.js +0 -13
- package/dist-types/slurpFile.d.ts +0 -7
- package/dist-types/ts3.4/slurpFile.d.ts +0 -7
|
@@ -1,16 +1,15 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.getSSOTokenFromFile = exports.tokenIntercept = void 0;
|
|
4
|
-
const
|
|
4
|
+
const promises_1 = require("fs/promises");
|
|
5
5
|
const getSSOTokenFilepath_1 = require("./getSSOTokenFilepath");
|
|
6
|
-
const { readFile } = fs_1.promises;
|
|
7
6
|
exports.tokenIntercept = {};
|
|
8
7
|
const getSSOTokenFromFile = async (id) => {
|
|
9
8
|
if (exports.tokenIntercept[id]) {
|
|
10
9
|
return exports.tokenIntercept[id];
|
|
11
10
|
}
|
|
12
11
|
const ssoTokenFilepath = (0, getSSOTokenFilepath_1.getSSOTokenFilepath)(id);
|
|
13
|
-
const ssoTokenText = await readFile(ssoTokenFilepath, "utf8");
|
|
12
|
+
const ssoTokenText = await (0, promises_1.readFile)(ssoTokenFilepath, "utf8");
|
|
14
13
|
return JSON.parse(ssoTokenText);
|
|
15
14
|
};
|
|
16
15
|
exports.getSSOTokenFromFile = getSSOTokenFromFile;
|
package/dist-cjs/index.js
CHANGED
|
@@ -5,7 +5,7 @@ var getSSOTokenFilepath = require('./getSSOTokenFilepath');
|
|
|
5
5
|
var getSSOTokenFromFile = require('./getSSOTokenFromFile');
|
|
6
6
|
var path = require('path');
|
|
7
7
|
var types = require('@smithy/types');
|
|
8
|
-
var
|
|
8
|
+
var readFile = require('./readFile');
|
|
9
9
|
|
|
10
10
|
const ENV_PROFILE = "AWS_PROFILE";
|
|
11
11
|
const DEFAULT_PROFILE = "default";
|
|
@@ -101,13 +101,13 @@ const loadSharedConfigFiles = async (init = {}) => {
|
|
|
101
101
|
resolvedConfigFilepath = path.join(homeDir, configFilepath.slice(2));
|
|
102
102
|
}
|
|
103
103
|
const parsedFiles = await Promise.all([
|
|
104
|
-
|
|
104
|
+
readFile.readFile(resolvedConfigFilepath, {
|
|
105
105
|
ignoreCache: init.ignoreCache,
|
|
106
106
|
})
|
|
107
107
|
.then(parseIni)
|
|
108
108
|
.then(getConfigData)
|
|
109
109
|
.catch(swallowError$1),
|
|
110
|
-
|
|
110
|
+
readFile.readFile(resolvedFilepath, {
|
|
111
111
|
ignoreCache: init.ignoreCache,
|
|
112
112
|
})
|
|
113
113
|
.then(parseIni)
|
|
@@ -124,7 +124,7 @@ const getSsoSessionData = (data) => Object.entries(data)
|
|
|
124
124
|
.reduce((acc, [key, value]) => ({ ...acc, [key.substring(key.indexOf(CONFIG_PREFIX_SEPARATOR) + 1)]: value }), {});
|
|
125
125
|
|
|
126
126
|
const swallowError = () => ({});
|
|
127
|
-
const loadSsoSessionData = async (init = {}) =>
|
|
127
|
+
const loadSsoSessionData = async (init = {}) => readFile.readFile(init.configFilepath ?? getConfigFilepath())
|
|
128
128
|
.then(parseIni)
|
|
129
129
|
.then(getSsoSessionData)
|
|
130
130
|
.catch(swallowError);
|
|
@@ -151,10 +151,10 @@ const parseKnownFiles = async (init) => {
|
|
|
151
151
|
|
|
152
152
|
const externalDataInterceptor = {
|
|
153
153
|
getFileRecord() {
|
|
154
|
-
return
|
|
154
|
+
return readFile.fileIntercept;
|
|
155
155
|
},
|
|
156
156
|
interceptFile(path, contents) {
|
|
157
|
-
|
|
157
|
+
readFile.fileIntercept[path] = Promise.resolve(contents);
|
|
158
158
|
},
|
|
159
159
|
getTokenRecord() {
|
|
160
160
|
return getSSOTokenFromFile.tokenIntercept;
|
|
@@ -168,6 +168,10 @@ Object.defineProperty(exports, "getSSOTokenFromFile", {
|
|
|
168
168
|
enumerable: true,
|
|
169
169
|
get: function () { return getSSOTokenFromFile.getSSOTokenFromFile; }
|
|
170
170
|
});
|
|
171
|
+
Object.defineProperty(exports, "readFile", {
|
|
172
|
+
enumerable: true,
|
|
173
|
+
get: function () { return readFile.readFile; }
|
|
174
|
+
});
|
|
171
175
|
exports.CONFIG_PREFIX_SEPARATOR = CONFIG_PREFIX_SEPARATOR;
|
|
172
176
|
exports.DEFAULT_PROFILE = DEFAULT_PROFILE;
|
|
173
177
|
exports.ENV_PROFILE = ENV_PROFILE;
|
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.readFile = exports.fileIntercept = exports.filePromises = void 0;
|
|
4
|
+
const promises_1 = require("node:fs/promises");
|
|
5
|
+
exports.filePromises = {};
|
|
6
|
+
exports.fileIntercept = {};
|
|
7
|
+
const readFile = (path, options) => {
|
|
8
|
+
if (exports.fileIntercept[path] !== undefined) {
|
|
9
|
+
return exports.fileIntercept[path];
|
|
10
|
+
}
|
|
11
|
+
if (!exports.filePromises[path] || options?.ignoreCache) {
|
|
12
|
+
exports.filePromises[path] = (0, promises_1.readFile)(path, "utf8");
|
|
13
|
+
}
|
|
14
|
+
return exports.filePromises[path];
|
|
15
|
+
};
|
|
16
|
+
exports.readFile = readFile;
|
|
@@ -1,6 +1,5 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { readFile } from "fs/promises";
|
|
2
2
|
import { getSSOTokenFilepath } from "./getSSOTokenFilepath";
|
|
3
|
-
const { readFile } = fsPromises;
|
|
4
3
|
export const tokenIntercept = {};
|
|
5
4
|
export const getSSOTokenFromFile = async (id) => {
|
|
6
5
|
if (tokenIntercept[id]) {
|
package/dist-es/index.js
CHANGED
|
@@ -4,7 +4,7 @@ import { getConfigFilepath } from "./getConfigFilepath";
|
|
|
4
4
|
import { getCredentialsFilepath } from "./getCredentialsFilepath";
|
|
5
5
|
import { getHomeDir } from "./getHomeDir";
|
|
6
6
|
import { parseIni } from "./parseIni";
|
|
7
|
-
import {
|
|
7
|
+
import { readFile } from "./readFile";
|
|
8
8
|
const swallowError = () => ({});
|
|
9
9
|
export { CONFIG_PREFIX_SEPARATOR } from "./constants";
|
|
10
10
|
export const loadSharedConfigFiles = async (init = {}) => {
|
|
@@ -20,13 +20,13 @@ export const loadSharedConfigFiles = async (init = {}) => {
|
|
|
20
20
|
resolvedConfigFilepath = join(homeDir, configFilepath.slice(2));
|
|
21
21
|
}
|
|
22
22
|
const parsedFiles = await Promise.all([
|
|
23
|
-
|
|
23
|
+
readFile(resolvedConfigFilepath, {
|
|
24
24
|
ignoreCache: init.ignoreCache,
|
|
25
25
|
})
|
|
26
26
|
.then(parseIni)
|
|
27
27
|
.then(getConfigData)
|
|
28
28
|
.catch(swallowError),
|
|
29
|
-
|
|
29
|
+
readFile(resolvedFilepath, {
|
|
30
30
|
ignoreCache: init.ignoreCache,
|
|
31
31
|
})
|
|
32
32
|
.then(parseIni)
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { getConfigFilepath } from "./getConfigFilepath";
|
|
2
2
|
import { getSsoSessionData } from "./getSsoSessionData";
|
|
3
3
|
import { parseIni } from "./parseIni";
|
|
4
|
-
import {
|
|
4
|
+
import { readFile } from "./readFile";
|
|
5
5
|
const swallowError = () => ({});
|
|
6
|
-
export const loadSsoSessionData = async (init = {}) =>
|
|
6
|
+
export const loadSsoSessionData = async (init = {}) => readFile(init.configFilepath ?? getConfigFilepath())
|
|
7
7
|
.then(parseIni)
|
|
8
8
|
.then(getSsoSessionData)
|
|
9
9
|
.catch(swallowError);
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import { readFile as fsReadFile } from "node:fs/promises";
|
|
2
|
+
export const filePromises = {};
|
|
3
|
+
export const fileIntercept = {};
|
|
4
|
+
export const readFile = (path, options) => {
|
|
5
|
+
if (fileIntercept[path] !== undefined) {
|
|
6
|
+
return fileIntercept[path];
|
|
7
|
+
}
|
|
8
|
+
if (!filePromises[path] || options?.ignoreCache) {
|
|
9
|
+
filePromises[path] = fsReadFile(path, "utf8");
|
|
10
|
+
}
|
|
11
|
+
return filePromises[path];
|
|
12
|
+
};
|
package/dist-types/index.d.ts
CHANGED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime file cache.
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare const filePromises: Record<string, Promise<string>>;
|
|
6
|
+
/**
|
|
7
|
+
* For testing only.
|
|
8
|
+
* @internal
|
|
9
|
+
* @deprecated minimize use in application code.
|
|
10
|
+
*/
|
|
11
|
+
export declare const fileIntercept: Record<string, Promise<string>>;
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export interface ReadFileOptions {
|
|
16
|
+
ignoreCache?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare const readFile: (path: string, options?: ReadFileOptions) => Promise<string>;
|
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Runtime file cache.
|
|
3
|
+
* @internal
|
|
4
|
+
*/
|
|
5
|
+
export declare const filePromises: Record<string, Promise<string>>;
|
|
6
|
+
/**
|
|
7
|
+
* For testing only.
|
|
8
|
+
* @internal
|
|
9
|
+
* @deprecated minimize use in application code.
|
|
10
|
+
*/
|
|
11
|
+
export declare const fileIntercept: Record<string, Promise<string>>;
|
|
12
|
+
/**
|
|
13
|
+
* @internal
|
|
14
|
+
*/
|
|
15
|
+
export interface ReadFileOptions {
|
|
16
|
+
ignoreCache?: boolean;
|
|
17
|
+
}
|
|
18
|
+
/**
|
|
19
|
+
* @internal
|
|
20
|
+
*/
|
|
21
|
+
export declare const readFile: (path: string, options?: ReadFileOptions) => Promise<string>;
|
package/package.json
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@smithy/shared-ini-file-loader",
|
|
3
|
-
"version": "4.
|
|
3
|
+
"version": "4.4.0",
|
|
4
4
|
"dependencies": {
|
|
5
|
-
"@smithy/types": "^4.
|
|
5
|
+
"@smithy/types": "^4.9.0",
|
|
6
6
|
"tslib": "^2.6.2"
|
|
7
7
|
},
|
|
8
8
|
"devDependencies": {
|
|
@@ -37,13 +37,13 @@
|
|
|
37
37
|
"types": "./dist-types/index.d.ts",
|
|
38
38
|
"browser": {
|
|
39
39
|
"./dist-es/getSSOTokenFromFile": false,
|
|
40
|
-
"./dist-es/
|
|
40
|
+
"./dist-es/readFile": false
|
|
41
41
|
},
|
|
42
42
|
"react-native": {
|
|
43
43
|
"./dist-cjs/getSSOTokenFromFile": false,
|
|
44
|
-
"./dist-cjs/
|
|
44
|
+
"./dist-cjs/readFile": false,
|
|
45
45
|
"./dist-es/getSSOTokenFromFile": false,
|
|
46
|
-
"./dist-es/
|
|
46
|
+
"./dist-es/readFile": false
|
|
47
47
|
},
|
|
48
48
|
"engines": {
|
|
49
49
|
"node": ">=18.0.0"
|
package/dist-cjs/slurpFile.js
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.slurpFile = exports.fileIntercept = exports.filePromisesHash = void 0;
|
|
4
|
-
const fs_1 = require("fs");
|
|
5
|
-
const { readFile } = fs_1.promises;
|
|
6
|
-
exports.filePromisesHash = {};
|
|
7
|
-
exports.fileIntercept = {};
|
|
8
|
-
const slurpFile = (path, options) => {
|
|
9
|
-
if (exports.fileIntercept[path] !== undefined) {
|
|
10
|
-
return exports.fileIntercept[path];
|
|
11
|
-
}
|
|
12
|
-
if (!exports.filePromisesHash[path] || options?.ignoreCache) {
|
|
13
|
-
exports.filePromisesHash[path] = readFile(path, "utf8");
|
|
14
|
-
}
|
|
15
|
-
return exports.filePromisesHash[path];
|
|
16
|
-
};
|
|
17
|
-
exports.slurpFile = slurpFile;
|
package/dist-es/slurpFile.js
DELETED
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { promises as fsPromises } from "fs";
|
|
2
|
-
const { readFile } = fsPromises;
|
|
3
|
-
export const filePromisesHash = {};
|
|
4
|
-
export const fileIntercept = {};
|
|
5
|
-
export const slurpFile = (path, options) => {
|
|
6
|
-
if (fileIntercept[path] !== undefined) {
|
|
7
|
-
return fileIntercept[path];
|
|
8
|
-
}
|
|
9
|
-
if (!filePromisesHash[path] || options?.ignoreCache) {
|
|
10
|
-
filePromisesHash[path] = readFile(path, "utf8");
|
|
11
|
-
}
|
|
12
|
-
return filePromisesHash[path];
|
|
13
|
-
};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const filePromisesHash: Record<string, Promise<string>>;
|
|
2
|
-
export declare const fileIntercept: Record<string, Promise<string>>;
|
|
3
|
-
interface SlurpFileOptions {
|
|
4
|
-
ignoreCache?: boolean;
|
|
5
|
-
}
|
|
6
|
-
export declare const slurpFile: (path: string, options?: SlurpFileOptions) => Promise<string>;
|
|
7
|
-
export {};
|
|
@@ -1,7 +0,0 @@
|
|
|
1
|
-
export declare const filePromisesHash: Record<string, Promise<string>>;
|
|
2
|
-
export declare const fileIntercept: Record<string, Promise<string>>;
|
|
3
|
-
interface SlurpFileOptions {
|
|
4
|
-
ignoreCache?: boolean;
|
|
5
|
-
}
|
|
6
|
-
export declare const slurpFile: (path: string, options?: SlurpFileOptions) => Promise<string>;
|
|
7
|
-
export {};
|