@updating-secrets/infisical-adapter 1.0.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/LICENSE-CC0 ADDED
@@ -0,0 +1,121 @@
1
+ CC0 1.0 Universal
2
+
3
+ Creative Commons Legal Code
4
+
5
+ CREATIVE COMMONS CORPORATION IS NOT A LAW FIRM AND DOES NOT PROVIDE
6
+ LEGAL SERVICES. DISTRIBUTION OF THIS DOCUMENT DOES NOT CREATE AN
7
+ ATTORNEY-CLIENT RELATIONSHIP. CREATIVE COMMONS PROVIDES THIS
8
+ INFORMATION ON AN "AS-IS" BASIS. CREATIVE COMMONS MAKES NO WARRANTIES
9
+ REGARDING THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS
10
+ PROVIDED HEREUNDER, AND DISCLAIMS LIABILITY FOR DAMAGES RESULTING FROM
11
+ THE USE OF THIS DOCUMENT OR THE INFORMATION OR WORKS PROVIDED
12
+ HEREUNDER.
13
+
14
+ Statement of Purpose
15
+
16
+ The laws of most jurisdictions throughout the world automatically confer
17
+ exclusive Copyright and Related Rights (defined below) upon the creator
18
+ and subsequent owner(s) (each and all, an "owner") of an original work of
19
+ authorship and/or a database (each, a "Work").
20
+
21
+ Certain owners wish to permanently relinquish those rights to a Work for
22
+ the purpose of contributing to a commons of creative, cultural and
23
+ scientific works ("Commons") that the public can reliably and without fear
24
+ of later claims of infringement build upon, modify, incorporate in other
25
+ works, reuse and redistribute as freely as possible in any form whatsoever
26
+ and for any purposes, including without limitation commercial purposes.
27
+ These owners may contribute to the Commons to promote the ideal of a free
28
+ culture and the further production of creative, cultural and scientific
29
+ works, or to gain reputation or greater distribution for their Work in
30
+ part through the use and efforts of others.
31
+
32
+ For these and/or other purposes and motivations, and without any
33
+ expectation of additional consideration or compensation, the person
34
+ associating CC0 with a Work (the "Affirmer"), to the extent that he or she
35
+ is an owner of Copyright and Related Rights in the Work, voluntarily
36
+ elects to apply CC0 to the Work and publicly distribute the Work under its
37
+ terms, with knowledge of his or her Copyright and Related Rights in the
38
+ Work and the meaning and intended legal effect of CC0 on those rights.
39
+
40
+ 1. Copyright and Related Rights. A Work made available under CC0 may be
41
+ protected by copyright and related or neighboring rights ("Copyright and
42
+ Related Rights"). Copyright and Related Rights include, but are not
43
+ limited to, the following:
44
+
45
+ i. the right to reproduce, adapt, distribute, perform, display,
46
+ communicate, and translate a Work;
47
+ ii. moral rights retained by the original author(s) and/or performer(s);
48
+ iii. publicity and privacy rights pertaining to a person's image or
49
+ likeness depicted in a Work;
50
+ iv. rights protecting against unfair competition in regards to a Work,
51
+ subject to the limitations in paragraph 4(a), below;
52
+ v. rights protecting the extraction, dissemination, use and reuse of data
53
+ in a Work;
54
+ vi. database rights (such as those arising under Directive 96/9/EC of the
55
+ European Parliament and of the Council of 11 March 1996 on the legal
56
+ protection of databases, and under any national implementation
57
+ thereof, including any amended or successor version of such
58
+ directive); and
59
+ vii. other similar, equivalent or corresponding rights throughout the
60
+ world based on applicable law or treaty, and any national
61
+ implementations thereof.
62
+
63
+ 2. Waiver. To the greatest extent permitted by, but not in contravention
64
+ of, applicable law, Affirmer hereby overtly, fully, permanently,
65
+ irrevocably and unconditionally waives, abandons, and surrenders all of
66
+ Affirmer's Copyright and Related Rights and associated claims and causes
67
+ of action, whether now known or unknown (including existing as well as
68
+ future claims and causes of action), in the Work (i) in all territories
69
+ worldwide, (ii) for the maximum duration provided by applicable law or
70
+ treaty (including future time extensions), (iii) in any current or future
71
+ medium and for any number of copies, and (iv) for any purpose whatsoever,
72
+ including without limitation commercial, advertising or promotional
73
+ purposes (the "Waiver"). Affirmer makes the Waiver for the benefit of each
74
+ member of the public at large and to the detriment of Affirmer's heirs and
75
+ successors, fully intending that such Waiver shall not be subject to
76
+ revocation, rescission, cancellation, termination, or any other legal or
77
+ equitable action to disrupt the quiet enjoyment of the Work by the public
78
+ as contemplated by Affirmer's express Statement of Purpose.
79
+
80
+ 3. Public License Fallback. Should any part of the Waiver for any reason
81
+ be judged legally invalid or ineffective under applicable law, then the
82
+ Waiver shall be preserved to the maximum extent permitted taking into
83
+ account Affirmer's express Statement of Purpose. In addition, to the
84
+ extent the Waiver is so judged Affirmer hereby grants to each affected
85
+ person a royalty-free, non transferable, non sublicensable, non exclusive,
86
+ irrevocable and unconditional license to exercise Affirmer's Copyright and
87
+ Related Rights in the Work (i) in all territories worldwide, (ii) for the
88
+ maximum duration provided by applicable law or treaty (including future
89
+ time extensions), (iii) in any current or future medium and for any number
90
+ of copies, and (iv) for any purpose whatsoever, including without
91
+ limitation commercial, advertising or promotional purposes (the
92
+ "License"). The License shall be deemed effective as of the date CC0 was
93
+ applied by Affirmer to the Work. Should any part of the License for any
94
+ reason be judged legally invalid or ineffective under applicable law, such
95
+ partial invalidity or ineffectiveness shall not invalidate the remainder
96
+ of the License, and in such case Affirmer hereby affirms that he or she
97
+ will not (i) exercise any of his or her remaining Copyright and Related
98
+ Rights in the Work or (ii) assert any associated claims and causes of
99
+ action with respect to the Work, in either case contrary to Affirmer's
100
+ express Statement of Purpose.
101
+
102
+ 4. Limitations and Disclaimers.
103
+
104
+ a. No trademark or patent rights held by Affirmer are waived, abandoned,
105
+ surrendered, licensed or otherwise affected by this document.
106
+ b. Affirmer offers the Work as-is and makes no representations or
107
+ warranties of any kind concerning the Work, express, implied,
108
+ statutory or otherwise, including without limitation warranties of
109
+ title, merchantability, fitness for a particular purpose, non
110
+ infringement, or the absence of latent or other defects, accuracy, or
111
+ the present or absence of errors, whether or not discoverable, all to
112
+ the greatest extent permissible under applicable law.
113
+ c. Affirmer disclaims responsibility for clearing rights of other persons
114
+ that may apply to the Work or any use thereof, including without
115
+ limitation any person's Copyright and Related Rights in the Work.
116
+ Further, Affirmer disclaims responsibility for obtaining any necessary
117
+ consents, permissions or other rights required for any use of the
118
+ Work.
119
+ d. Affirmer understands and acknowledges that Creative Commons is not a
120
+ party to this document and has no duty or obligation with respect to
121
+ this CC0 or use of the Work.
package/LICENSE-MIT ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2024 electrovir
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md ADDED
@@ -0,0 +1,3 @@
1
+ # @updating-secrets/infisical-adapter
2
+
3
+ Adapter for [the `updating-secrets` package](https://www.npmjs.com/package/updating-secrets) for Infisical.
@@ -0,0 +1,2 @@
1
+ export * from './infisical.adapter.js';
2
+ export * from './mock-infisical-sdk.js';
package/dist/index.js ADDED
@@ -0,0 +1,2 @@
1
+ export * from './infisical.adapter.js';
2
+ export * from './mock-infisical-sdk.js';
@@ -0,0 +1,69 @@
1
+ import { type Values } from '@augment-vir/common';
2
+ import { type ListSecretsOptions, type Secret } from '@infisical/sdk';
3
+ import { BaseSecretsAdapter, type ProcessedSecretDefinitions, type RawSecrets } from 'updating-secrets';
4
+ /**
5
+ * Intermediate type for processing secrets from Infisical. Used in {@link InfisicalAdapter} and
6
+ * helper functions.
7
+ *
8
+ * @category Internal
9
+ */
10
+ export type MappedInfisicalSecrets = {
11
+ [SecretKey in string]: string | MappedInfisicalSecrets | Error;
12
+ };
13
+ /**
14
+ * The necessary subset of the `InfisicalSDK` API that {@link InfisicalAdapter} requires.
15
+ *
16
+ * @category Internal
17
+ */
18
+ export type NeededInfisicalSdk = {
19
+ /** Get the Infisical secrets client. */
20
+ secrets(): {
21
+ /** List the Infisical secrets. */
22
+ listSecrets(options: ListSecretsOptions): Promise<{
23
+ secrets: NeededInfisicalSecret[];
24
+ }>;
25
+ };
26
+ };
27
+ /**
28
+ * The necessary subset of the Infisical `Secret` type that {@link InfisicalAdapter} requires.
29
+ *
30
+ * @category Internal
31
+ */
32
+ export type NeededInfisicalSecret = Pick<Secret, 'secretKey' | 'secretPath' | 'secretValue'>;
33
+ /**
34
+ * Loads secrets from Infisical. A `InfisicalSDK` instance must be provided. The `InfisicalSDK`
35
+ * instance must also be authorized _before_ passing it into this.
36
+ *
37
+ * @category Adapters
38
+ */
39
+ export declare class InfisicalAdapter extends BaseSecretsAdapter {
40
+ /**
41
+ * Make sure that you've already authenticated this client.
42
+ * (`client.auth().universalAuth.login()`)
43
+ */
44
+ protected readonly infisicalClient: Readonly<NeededInfisicalSdk>;
45
+ /** `'dev'`, `'staging'`, `'prod'`, etc. */
46
+ protected readonly infisicalEnvironment: string;
47
+ constructor(
48
+ /**
49
+ * Make sure that you've already authenticated this client.
50
+ * (`client.auth().universalAuth.login()`)
51
+ */
52
+ infisicalClient: Readonly<NeededInfisicalSdk>,
53
+ /** `'dev'`, `'staging'`, `'prod'`, etc. */
54
+ infisicalEnvironment: string);
55
+ /** Load secrets from the provided `InfisicalSDK`. */
56
+ loadSecrets(secrets: ProcessedSecretDefinitions): RawSecrets;
57
+ }
58
+ /**
59
+ * Get an Infisical secret value nested within an object.
60
+ *
61
+ * @category Internal
62
+ */
63
+ export declare function getNested(parent: MappedInfisicalSecrets, keys: string[]): Values<MappedInfisicalSecrets>;
64
+ /**
65
+ * Set an Infisical secret value nested within an object.
66
+ *
67
+ * @category Internal
68
+ */
69
+ export declare function setNested(parent: MappedInfisicalSecrets, keys: string[], value: string): void;
@@ -0,0 +1,168 @@
1
+ import { check } from '@augment-vir/assert';
2
+ import { ensureError, getOrSet, mapObjectValuesSync, parseWithJson5, removePrefix, removeSuffix, stringify, wrapInTry, } from '@augment-vir/common';
3
+ import { BaseSecretsAdapter, } from 'updating-secrets';
4
+ /**
5
+ * Loads secrets from Infisical. A `InfisicalSDK` instance must be provided. The `InfisicalSDK`
6
+ * instance must also be authorized _before_ passing it into this.
7
+ *
8
+ * @category Adapters
9
+ */
10
+ export class InfisicalAdapter extends BaseSecretsAdapter {
11
+ infisicalClient;
12
+ infisicalEnvironment;
13
+ constructor(
14
+ /**
15
+ * Make sure that you've already authenticated this client.
16
+ * (`client.auth().universalAuth.login()`)
17
+ */
18
+ infisicalClient,
19
+ /** `'dev'`, `'staging'`, `'prod'`, etc. */
20
+ infisicalEnvironment) {
21
+ super('InfisicalAdapter');
22
+ this.infisicalClient = infisicalClient;
23
+ this.infisicalEnvironment = infisicalEnvironment;
24
+ }
25
+ /** Load secrets from the provided `InfisicalSDK`. */
26
+ loadSecrets(secrets) {
27
+ const secretsCache = {};
28
+ return mapObjectValuesSync(secrets, (secretName, secretDefinition) => {
29
+ const infisicalConfig = secretDefinition.adapterConfig.infisical;
30
+ if (!infisicalConfig) {
31
+ return new Error(`No Infisical adapter config (required for using InfisicalAdapter) defined for secret '${secretDefinition.secretName}'.`);
32
+ }
33
+ const projectSecretsPromise = getOrSet(secretsCache, infisicalConfig.projectId, () => {
34
+ try {
35
+ return (this.infisicalClient
36
+ .secrets()
37
+ .listSecrets({
38
+ recursive: true,
39
+ environment: this.infisicalEnvironment,
40
+ projectId: infisicalConfig.projectId,
41
+ viewSecretValue: true,
42
+ })
43
+ .then(({ secrets }) => {
44
+ return mapInfisicalSecrets(secrets);
45
+ })
46
+ /* node:coverage ignore next 3 */
47
+ .catch((error) => {
48
+ return ensureError(error);
49
+ }));
50
+ }
51
+ catch (error) {
52
+ return Promise.reject(ensureError(error));
53
+ }
54
+ });
55
+ return projectSecretsPromise
56
+ .then((projectSecrets) => {
57
+ /* node:coverage ignore next 3 */
58
+ if (projectSecrets instanceof Error) {
59
+ return projectSecrets;
60
+ }
61
+ const folderValue = infisicalConfig.folderPath === '/' || !infisicalConfig.folderPath
62
+ ? projectSecrets
63
+ : getNested(projectSecrets, removeSuffix({
64
+ value: removePrefix({
65
+ value: infisicalConfig.folderPath,
66
+ prefix: '/',
67
+ }),
68
+ suffix: '/',
69
+ }).split('/'));
70
+ /* node:coverage ignore next 3 */
71
+ if (check.isError(folderValue)) {
72
+ return folderValue;
73
+ }
74
+ if (infisicalConfig.keyInFolder) {
75
+ if (check.isString(folderValue)) {
76
+ throw new TypeError(`Cannot get keyInFolder of a non-folder.`);
77
+ }
78
+ else if (check.hasKey(folderValue, infisicalConfig.keyInFolder)) {
79
+ const value = folderValue[infisicalConfig.keyInFolder];
80
+ if (secretDefinition.shapeDefinition && check.isString(value)) {
81
+ return wrapInTry(() => parseWithJson5(value), {
82
+ fallbackValue: folderValue,
83
+ });
84
+ }
85
+ else {
86
+ return value;
87
+ }
88
+ }
89
+ else {
90
+ throw new Error(`Secret key not in folder '${infisicalConfig.folderPath}'`);
91
+ }
92
+ }
93
+ else {
94
+ return folderValue;
95
+ }
96
+ })
97
+ .catch((error) => {
98
+ return ensureError(error);
99
+ });
100
+ });
101
+ }
102
+ }
103
+ function mapInfisicalSecrets(secrets) {
104
+ const secretsMap = {};
105
+ secrets.forEach((secret) => {
106
+ if (!secret.secretPath || secret.secretPath === '/') {
107
+ secretsMap[secret.secretKey] = secret.secretValue;
108
+ }
109
+ else {
110
+ setNested(secretsMap, removeSuffix({
111
+ value: removePrefix({ value: secret.secretPath, prefix: '/' }),
112
+ suffix: '/',
113
+ })
114
+ .split('/')
115
+ .concat(secret.secretKey), secret.secretValue);
116
+ }
117
+ });
118
+ return secretsMap;
119
+ }
120
+ /**
121
+ * Get an Infisical secret value nested within an object.
122
+ *
123
+ * @category Internal
124
+ */
125
+ export function getNested(parent, keys) {
126
+ const nextKey = keys[0];
127
+ if (nextKey == undefined) {
128
+ throw new Error('Invalid key or ran out of keys.');
129
+ }
130
+ const nextParent = parent[nextKey];
131
+ if (!nextParent) {
132
+ throw new Error(`Nothing at key '${nextKey}'`);
133
+ }
134
+ else if (nextParent instanceof Error) {
135
+ throw nextParent;
136
+ }
137
+ if (keys.length > 1) {
138
+ if (check.isString(nextParent)) {
139
+ throw new TypeError(`Keys still remain but received string value: ${stringify({ keys })}`);
140
+ }
141
+ return getNested(nextParent, keys.slice(1));
142
+ }
143
+ else {
144
+ return nextParent;
145
+ }
146
+ }
147
+ /**
148
+ * Set an Infisical secret value nested within an object.
149
+ *
150
+ * @category Internal
151
+ */
152
+ export function setNested(parent, keys, value) {
153
+ const nextKey = keys[0];
154
+ if (nextKey == undefined) {
155
+ throw new Error('Invalid key or ran out of keys.');
156
+ }
157
+ if (keys.length === 1) {
158
+ parent[nextKey] = value;
159
+ return;
160
+ }
161
+ const nextParent = getOrSet(parent, nextKey, () => {
162
+ return {};
163
+ });
164
+ if (check.isString(nextParent) || check.isError(nextParent)) {
165
+ throw new TypeError(`Cannot set key '${nextKey}'; it's already set to a non-object.`);
166
+ }
167
+ return setNested(nextParent, keys.slice(1), value);
168
+ }
@@ -0,0 +1,70 @@
1
+ import { type JsonCompatibleValue } from '@augment-vir/common';
2
+ import { type InfisicalSDK, type ListSecretsOptions, type Secret } from '@infisical/sdk';
3
+ import { type RequireExactlyOne } from 'type-fest';
4
+ /**
5
+ * Mock secrets setup for {@link MockInfisicalSdk}.
6
+ *
7
+ * @category Internal
8
+ */
9
+ export type MockInfisicalSecrets = {
10
+ projectId: string;
11
+ /** `'dev'`, `'staging'`, `'prod'`, etc. */
12
+ env: string;
13
+ secrets: {
14
+ [SecretKey in string]: {
15
+ folderPath?: string | undefined;
16
+ } & RequireExactlyOne<{
17
+ /**
18
+ * A value that will be JSON stringified for the `.SecretString` output of AWS Secrets
19
+ * Manager.
20
+ */
21
+ preJson: JsonCompatibleValue;
22
+ /** Set the raw `.SecretString` output of AWS Secrets Manager directly. */
23
+ rawString: string;
24
+ }>;
25
+ };
26
+ }[];
27
+ /**
28
+ * A mock implementation of `InfisicalSDK` from the
29
+ * [@infisical/sdk](https://www.npmjs.com/package/@infisical/sdk) package. This only mocks what is
30
+ * necessary for the infisical adapter to work.
31
+ *
32
+ * @category Mocks
33
+ */
34
+ export declare class MockInfisicalSdk {
35
+ /** Mock secrets that will be used in `secrets().listSecrets()` */
36
+ readonly mockSecrets: Readonly<MockInfisicalSecrets>;
37
+ /** Keeps track of whether this SDK has been authorized or not. */
38
+ protected isAuthorized: boolean;
39
+ constructor(
40
+ /** Mock secrets that will be used in `secrets().listSecrets()` */
41
+ mockSecrets: Readonly<MockInfisicalSecrets>);
42
+ /** Mock of `InfisicalSDK.auth()` */
43
+ auth(): {
44
+ /** Mock of `InfisicalSDK.auth().universalAuth` */
45
+ universalAuth: {
46
+ /** Mock of `InfisicalSDK.auth().universalAuth.login()` */
47
+ login: (options: import("@infisical/sdk").UniversalAuthLoginRequest) => Promise<InfisicalSDK>;
48
+ /** Mock of `InfisicalSDK.auth().universalAuth.renew()` */
49
+ renew(): never;
50
+ };
51
+ /** Mock of `InfisicalSDK.auth().accessToken` */
52
+ accessToken: (token: string) => InfisicalSDK;
53
+ /** Mock of `InfisicalSDK.auth().awsIamAuth` */
54
+ awsIamAuth: {
55
+ /** Mock of `InfisicalSDK.auth().awsIamAuth.login()` */
56
+ login: (options?: {
57
+ identityId?: string;
58
+ } | undefined) => Promise<InfisicalSDK>;
59
+ /** Mock of `InfisicalSDK.auth().awsIamAuth.renew()` */
60
+ renew(): never;
61
+ };
62
+ };
63
+ /** Mock of `InfisicalSDK.secrets()` */
64
+ secrets(): {
65
+ /** Mock of `InfisicalSDK.secrets().listSecrets()` */
66
+ listSecrets: ({ projectId, environment }: ListSecretsOptions) => Promise<{
67
+ secrets: Partial<Secret>[];
68
+ }>;
69
+ };
70
+ }
@@ -0,0 +1,84 @@
1
+ import { getObjectTypedEntries, stringifyWithJson5, } from '@augment-vir/common';
2
+ /**
3
+ * A mock implementation of `InfisicalSDK` from the
4
+ * [@infisical/sdk](https://www.npmjs.com/package/@infisical/sdk) package. This only mocks what is
5
+ * necessary for the infisical adapter to work.
6
+ *
7
+ * @category Mocks
8
+ */
9
+ export class MockInfisicalSdk {
10
+ mockSecrets;
11
+ /** Keeps track of whether this SDK has been authorized or not. */
12
+ isAuthorized = false;
13
+ constructor(
14
+ /** Mock secrets that will be used in `secrets().listSecrets()` */
15
+ mockSecrets) {
16
+ this.mockSecrets = mockSecrets;
17
+ }
18
+ /** Mock of `InfisicalSDK.auth()` */
19
+ auth() {
20
+ return {
21
+ /** Mock of `InfisicalSDK.auth().universalAuth` */
22
+ universalAuth: {
23
+ /** Mock of `InfisicalSDK.auth().universalAuth.login()` */
24
+ login: (
25
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
26
+ ...params) => {
27
+ this.isAuthorized = true;
28
+ return Promise.resolve(this);
29
+ },
30
+ /** Mock of `InfisicalSDK.auth().universalAuth.renew()` */
31
+ renew() {
32
+ throw new Error('Not mocked.');
33
+ },
34
+ },
35
+ /** Mock of `InfisicalSDK.auth().accessToken` */
36
+ accessToken: (
37
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
38
+ ...params) => {
39
+ this.isAuthorized = true;
40
+ return this;
41
+ },
42
+ /** Mock of `InfisicalSDK.auth().awsIamAuth` */
43
+ awsIamAuth: {
44
+ /** Mock of `InfisicalSDK.auth().awsIamAuth.login()` */
45
+ login: (
46
+ // eslint-disable-next-line @typescript-eslint/no-unused-vars
47
+ ...params) => {
48
+ this.isAuthorized = true;
49
+ return Promise.resolve(this);
50
+ },
51
+ /** Mock of `InfisicalSDK.auth().awsIamAuth.renew()` */
52
+ renew() {
53
+ throw new Error('Not mocked.');
54
+ },
55
+ },
56
+ };
57
+ }
58
+ /** Mock of `InfisicalSDK.secrets()` */
59
+ secrets() {
60
+ return {
61
+ /** Mock of `InfisicalSDK.secrets().listSecrets()` */
62
+ listSecrets: ({ projectId, environment }) => {
63
+ if (!this.isAuthorized) {
64
+ throw new Error('Mock Infisical SDK client not authorized.');
65
+ }
66
+ const secrets = this.mockSecrets.find((mock) => mock.projectId === projectId && mock.env === environment)?.secrets;
67
+ if (!secrets) {
68
+ throw new Error('Invalid project.');
69
+ }
70
+ return Promise.resolve({
71
+ secrets: getObjectTypedEntries(secrets).map(([secretKey, mockDefinition,]) => {
72
+ return {
73
+ secretPath: mockDefinition.folderPath || '/',
74
+ secretKey,
75
+ secretValue: mockDefinition.preJson
76
+ ? stringifyWithJson5(mockDefinition.preJson)
77
+ : mockDefinition.rawString || '',
78
+ };
79
+ }),
80
+ });
81
+ },
82
+ };
83
+ }
84
+ }
package/package.json ADDED
@@ -0,0 +1,60 @@
1
+ {
2
+ "name": "@updating-secrets/infisical-adapter",
3
+ "version": "1.0.0",
4
+ "description": "Infisical adapter for the updating-secrets package.",
5
+ "keywords": [
6
+ "secrets",
7
+ "rotation",
8
+ "interval",
9
+ "update",
10
+ "infisical",
11
+ "adapter"
12
+ ],
13
+ "homepage": "https://github.com/electrovir/updating-secrets",
14
+ "bugs": {
15
+ "url": "https://github.com/electrovir/updating-secrets/issues"
16
+ },
17
+ "repository": {
18
+ "type": "git",
19
+ "url": "git+https://github.com/electrovir/updating-secrets.git"
20
+ },
21
+ "license": "(MIT or CC0 1.0)",
22
+ "author": {
23
+ "name": "electrovir",
24
+ "url": "https://github.com/electrovir"
25
+ },
26
+ "sideEffects": false,
27
+ "type": "module",
28
+ "main": "dist/index.js",
29
+ "module": "dist/index.js",
30
+ "types": "dist/index.d.ts",
31
+ "scripts": {
32
+ "compile": "virmator compile",
33
+ "docs": "virmator docs",
34
+ "start": "tsx src/index.ts",
35
+ "test": "virmator test node",
36
+ "test:coverage": "npm run test coverage",
37
+ "test:docs": "virmator docs check",
38
+ "test:update": "npm test update"
39
+ },
40
+ "dependencies": {
41
+ "@augment-vir/assert": "^31.26.0",
42
+ "@augment-vir/common": "^31.26.0",
43
+ "@infisical/sdk": "^4.0.2",
44
+ "type-fest": "^4.41.0",
45
+ "updating-secrets": "^1.0.0"
46
+ },
47
+ "devDependencies": {
48
+ "@augment-vir/test": "^31.26.0",
49
+ "@types/node": "^22.15.30",
50
+ "c8": "^10.1.3",
51
+ "istanbul-smart-text-reporter": "^1.1.5",
52
+ "object-shape-tester": "^5.1.7"
53
+ },
54
+ "engines": {
55
+ "node": ">=22"
56
+ },
57
+ "publishConfig": {
58
+ "access": "public"
59
+ }
60
+ }