Renamed
This commit is contained in:
2
.gitignore
vendored
2
.gitignore
vendored
@@ -129,4 +129,4 @@ dist
|
||||
.yarn/install-state.gz
|
||||
.pnp.*
|
||||
|
||||
/src/api/infisical/model/*.ts
|
||||
/src/infisicalapi_client
|
||||
29
package-lock.json
generated
29
package-lock.json
generated
@@ -13,10 +13,12 @@
|
||||
"@aws-sdk/credential-provider-node": "^3.637.0",
|
||||
"@aws-sdk/credential-providers": "^3.637.0",
|
||||
"@aws-sdk/signature-v4": "^3.374.0",
|
||||
"axios": "^1.7.5"
|
||||
"axios": "^1.7.5",
|
||||
"typescript": "^5.5.4"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@openapitools/openapi-generator-cli": "^2.13.5"
|
||||
"@openapitools/openapi-generator-cli": "^2.13.5",
|
||||
"tsc": "^2.0.4"
|
||||
}
|
||||
},
|
||||
"node_modules/@aws-crypto/crc32": {
|
||||
@@ -2895,6 +2897,16 @@
|
||||
"tree-kill": "cli.js"
|
||||
}
|
||||
},
|
||||
"node_modules/tsc": {
|
||||
"version": "2.0.4",
|
||||
"resolved": "https://registry.npmjs.org/tsc/-/tsc-2.0.4.tgz",
|
||||
"integrity": "sha512-fzoSieZI5KKJVBYGvwbVZs/J5za84f2lSTLPYf6AGiIf43tZ3GNrI1QzTLcjtyDDP4aLxd46RTZq1nQxe7+k5Q==",
|
||||
"dev": true,
|
||||
"license": "MIT",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc"
|
||||
}
|
||||
},
|
||||
"node_modules/tslib": {
|
||||
"version": "2.6.2",
|
||||
"resolved": "https://registry.npmjs.org/tslib/-/tslib-2.6.2.tgz",
|
||||
@@ -2914,6 +2926,19 @@
|
||||
"url": "https://github.com/sponsors/sindresorhus"
|
||||
}
|
||||
},
|
||||
"node_modules/typescript": {
|
||||
"version": "5.5.4",
|
||||
"resolved": "https://registry.npmjs.org/typescript/-/typescript-5.5.4.tgz",
|
||||
"integrity": "sha512-Mtq29sKDAEYP7aljRgtPOpTvOfbwRWlS6dPRzwjdE+C0R4brX/GUyhHSecbHMFLNBLcJIPt9nl9yG5TZ1weH+Q==",
|
||||
"license": "Apache-2.0",
|
||||
"bin": {
|
||||
"tsc": "bin/tsc",
|
||||
"tsserver": "bin/tsserver"
|
||||
},
|
||||
"engines": {
|
||||
"node": ">=14.17"
|
||||
}
|
||||
},
|
||||
"node_modules/uid": {
|
||||
"version": "2.0.2",
|
||||
"resolved": "https://registry.npmjs.org/uid/-/uid-2.0.2.tgz",
|
||||
|
||||
@@ -3,20 +3,22 @@
|
||||
"version": "1.0.0",
|
||||
"main": "index.js",
|
||||
"scripts": {
|
||||
"generate-api:infisical": "openapi-generator-cli generate -i https://app.infisical.com/api/docs/json -g typescript-axios -o ./src/api/infisical/ --skip-validate-spec --additional-properties=useSingleRequestParameter=true"
|
||||
"generate-api:infisical": "openapi-generator-cli generate -i https://app.infisical.com/api/docs/json -g typescript-axios -o ./src/infisicalapi_client --skip-validate-spec --additional-properties=useSingleRequestParameter=true,withSeparateModelsAndApi=true,apiPackage=server,modelPackage=model --openapi-normalizer REFACTOR_ALLOF_WITH_PROPERTIES_ONLY=true", "build": "tsc && cp -R ./src/types ./lib"
|
||||
},
|
||||
"keywords": [],
|
||||
"author": "",
|
||||
"license": "ISC",
|
||||
"description": "",
|
||||
"devDependencies": {
|
||||
"@openapitools/openapi-generator-cli": "^2.13.5"
|
||||
"@openapitools/openapi-generator-cli": "^2.13.5",
|
||||
"tsc": "^2.0.4"
|
||||
},
|
||||
"dependencies": {
|
||||
"@aws-crypto/sha256-js": "^5.2.0",
|
||||
"@aws-sdk/credential-provider-node": "^3.637.0",
|
||||
"@aws-sdk/credential-providers": "^3.637.0",
|
||||
"@aws-sdk/signature-v4": "^3.374.0",
|
||||
"axios": "^1.7.5"
|
||||
"axios": "^1.7.5",
|
||||
"typescript": "^5.5.4"
|
||||
}
|
||||
}
|
||||
|
||||
4
src/api/infisical/.gitignore
vendored
4
src/api/infisical/.gitignore
vendored
@@ -1,4 +0,0 @@
|
||||
wwwroot/*.js
|
||||
node_modules
|
||||
typings
|
||||
dist
|
||||
@@ -1 +0,0 @@
|
||||
# empty npmignore to ensure all required files (e.g., in the dist folder) are published by npm
|
||||
@@ -1,23 +0,0 @@
|
||||
# OpenAPI Generator Ignore
|
||||
# Generated by openapi-generator https://github.com/openapitools/openapi-generator
|
||||
|
||||
# Use this file to prevent files from being overwritten by the generator.
|
||||
# The patterns follow closely to .gitignore or .dockerignore.
|
||||
|
||||
# As an example, the C# client generator defines ApiClient.cs.
|
||||
# You can make changes and tell OpenAPI Generator to ignore just this file by uncommenting the following line:
|
||||
#ApiClient.cs
|
||||
|
||||
# You can match any string of characters against a directory, file or extension with a single asterisk (*):
|
||||
#foo/*/qux
|
||||
# The above matches foo/bar/qux and foo/baz/qux, but not foo/bar/baz/qux
|
||||
|
||||
# You can recursively match patterns against a directory, file or extension with a double asterisk (**):
|
||||
#foo/**/qux
|
||||
# This matches foo/bar/qux, foo/baz/qux, and foo/bar/baz/qux
|
||||
|
||||
# You can also negate patterns with an exclamation (!).
|
||||
# For example, you can ignore all files in a docs folder with the file extension .md:
|
||||
#docs/*.md
|
||||
# Then explicitly reverse the ignore rule for a single file:
|
||||
#!docs/README.md
|
||||
@@ -1,9 +0,0 @@
|
||||
.gitignore
|
||||
.npmignore
|
||||
.openapi-generator-ignore
|
||||
api.ts
|
||||
base.ts
|
||||
common.ts
|
||||
configuration.ts
|
||||
git_push.sh
|
||||
index.ts
|
||||
@@ -1 +0,0 @@
|
||||
7.8.0
|
||||
63928
src/api/infisical/api.ts
63928
src/api/infisical/api.ts
File diff suppressed because it is too large
Load Diff
@@ -1,86 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Infisical API
|
||||
* List of all available APIs that can be consumed
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
import type { Configuration } from './configuration';
|
||||
// Some imports not used depending on template conditions
|
||||
// @ts-ignore
|
||||
import type { AxiosPromise, AxiosInstance, RawAxiosRequestConfig } from 'axios';
|
||||
import globalAxios from 'axios';
|
||||
|
||||
export const BASE_PATH = "https://app.infisical.com".replace(/\/+$/, "");
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const COLLECTION_FORMATS = {
|
||||
csv: ",",
|
||||
ssv: " ",
|
||||
tsv: "\t",
|
||||
pipes: "|",
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @interface RequestArgs
|
||||
*/
|
||||
export interface RequestArgs {
|
||||
url: string;
|
||||
options: RawAxiosRequestConfig;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @class BaseAPI
|
||||
*/
|
||||
export class BaseAPI {
|
||||
protected configuration: Configuration | undefined;
|
||||
|
||||
constructor(configuration?: Configuration, protected basePath: string = BASE_PATH, protected axios: AxiosInstance = globalAxios) {
|
||||
if (configuration) {
|
||||
this.configuration = configuration;
|
||||
this.basePath = configuration.basePath ?? basePath;
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
* @class RequiredError
|
||||
* @extends {Error}
|
||||
*/
|
||||
export class RequiredError extends Error {
|
||||
constructor(public field: string, msg?: string) {
|
||||
super(msg);
|
||||
this.name = "RequiredError"
|
||||
}
|
||||
}
|
||||
|
||||
interface ServerMap {
|
||||
[key: string]: {
|
||||
url: string,
|
||||
description: string,
|
||||
}[];
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const operationServerMap: ServerMap = {
|
||||
}
|
||||
@@ -1,150 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Infisical API
|
||||
* List of all available APIs that can be consumed
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
import type { Configuration } from "./configuration";
|
||||
import type { RequestArgs } from "./base";
|
||||
import type { AxiosInstance, AxiosResponse } from 'axios';
|
||||
import { RequiredError } from "./base";
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const DUMMY_BASE_URL = 'https://example.com'
|
||||
|
||||
/**
|
||||
*
|
||||
* @throws {RequiredError}
|
||||
* @export
|
||||
*/
|
||||
export const assertParamExists = function (functionName: string, paramName: string, paramValue: unknown) {
|
||||
if (paramValue === null || paramValue === undefined) {
|
||||
throw new RequiredError(paramName, `Required parameter ${paramName} was null or undefined when calling ${functionName}.`);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const setApiKeyToObject = async function (object: any, keyParamName: string, configuration?: Configuration) {
|
||||
if (configuration && configuration.apiKey) {
|
||||
const localVarApiKeyValue = typeof configuration.apiKey === 'function'
|
||||
? await configuration.apiKey(keyParamName)
|
||||
: await configuration.apiKey;
|
||||
object[keyParamName] = localVarApiKeyValue;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const setBasicAuthToObject = function (object: any, configuration?: Configuration) {
|
||||
if (configuration && (configuration.username || configuration.password)) {
|
||||
object["auth"] = { username: configuration.username, password: configuration.password };
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const setBearerAuthToObject = async function (object: any, configuration?: Configuration) {
|
||||
if (configuration && configuration.accessToken) {
|
||||
const accessToken = typeof configuration.accessToken === 'function'
|
||||
? await configuration.accessToken()
|
||||
: await configuration.accessToken;
|
||||
object["Authorization"] = "Bearer " + accessToken;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const setOAuthToObject = async function (object: any, name: string, scopes: string[], configuration?: Configuration) {
|
||||
if (configuration && configuration.accessToken) {
|
||||
const localVarAccessTokenValue = typeof configuration.accessToken === 'function'
|
||||
? await configuration.accessToken(name, scopes)
|
||||
: await configuration.accessToken;
|
||||
object["Authorization"] = "Bearer " + localVarAccessTokenValue;
|
||||
}
|
||||
}
|
||||
|
||||
function setFlattenedQueryParams(urlSearchParams: URLSearchParams, parameter: any, key: string = ""): void {
|
||||
if (parameter == null) return;
|
||||
if (typeof parameter === "object") {
|
||||
if (Array.isArray(parameter)) {
|
||||
(parameter as any[]).forEach(item => setFlattenedQueryParams(urlSearchParams, item, key));
|
||||
}
|
||||
else {
|
||||
Object.keys(parameter).forEach(currentKey =>
|
||||
setFlattenedQueryParams(urlSearchParams, parameter[currentKey], `${key}${key !== '' ? '.' : ''}${currentKey}`)
|
||||
);
|
||||
}
|
||||
}
|
||||
else {
|
||||
if (urlSearchParams.has(key)) {
|
||||
urlSearchParams.append(key, parameter);
|
||||
}
|
||||
else {
|
||||
urlSearchParams.set(key, parameter);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const setSearchParams = function (url: URL, ...objects: any[]) {
|
||||
const searchParams = new URLSearchParams(url.search);
|
||||
setFlattenedQueryParams(searchParams, objects);
|
||||
url.search = searchParams.toString();
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const serializeDataIfNeeded = function (value: any, requestOptions: any, configuration?: Configuration) {
|
||||
const nonString = typeof value !== 'string';
|
||||
const needsSerialization = nonString && configuration && configuration.isJsonMime
|
||||
? configuration.isJsonMime(requestOptions.headers['Content-Type'])
|
||||
: nonString;
|
||||
return needsSerialization
|
||||
? JSON.stringify(value !== undefined ? value : {})
|
||||
: (value || "");
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const toPathString = function (url: URL) {
|
||||
return url.pathname + url.search + url.hash
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @export
|
||||
*/
|
||||
export const createRequestFunction = function (axiosArgs: RequestArgs, globalAxios: AxiosInstance, BASE_PATH: string, configuration?: Configuration) {
|
||||
return <T = unknown, R = AxiosResponse<T>>(axios: AxiosInstance = globalAxios, basePath: string = BASE_PATH) => {
|
||||
const axiosRequestArgs = {...axiosArgs.options, url: (axios.defaults.baseURL ? '' : configuration?.basePath ?? basePath) + axiosArgs.url};
|
||||
return axios.request<T, R>(axiosRequestArgs);
|
||||
};
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Infisical API
|
||||
* List of all available APIs that can be consumed
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export interface ConfigurationParameters {
|
||||
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
||||
username?: string;
|
||||
password?: string;
|
||||
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
||||
basePath?: string;
|
||||
serverIndex?: number;
|
||||
baseOptions?: any;
|
||||
formDataCtor?: new () => any;
|
||||
}
|
||||
|
||||
export class Configuration {
|
||||
/**
|
||||
* parameter for apiKey security
|
||||
* @param name security name
|
||||
* @memberof Configuration
|
||||
*/
|
||||
apiKey?: string | Promise<string> | ((name: string) => string) | ((name: string) => Promise<string>);
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
username?: string;
|
||||
/**
|
||||
* parameter for basic security
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
password?: string;
|
||||
/**
|
||||
* parameter for oauth2 security
|
||||
* @param name security name
|
||||
* @param scopes oauth2 scope
|
||||
* @memberof Configuration
|
||||
*/
|
||||
accessToken?: string | Promise<string> | ((name?: string, scopes?: string[]) => string) | ((name?: string, scopes?: string[]) => Promise<string>);
|
||||
/**
|
||||
* override base path
|
||||
*
|
||||
* @type {string}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
basePath?: string;
|
||||
/**
|
||||
* override server index
|
||||
*
|
||||
* @type {number}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
serverIndex?: number;
|
||||
/**
|
||||
* base options for axios calls
|
||||
*
|
||||
* @type {any}
|
||||
* @memberof Configuration
|
||||
*/
|
||||
baseOptions?: any;
|
||||
/**
|
||||
* The FormData constructor that will be used to create multipart form data
|
||||
* requests. You can inject this here so that execution environments that
|
||||
* do not support the FormData class can still run the generated client.
|
||||
*
|
||||
* @type {new () => FormData}
|
||||
*/
|
||||
formDataCtor?: new () => any;
|
||||
|
||||
constructor(param: ConfigurationParameters = {}) {
|
||||
this.apiKey = param.apiKey;
|
||||
this.username = param.username;
|
||||
this.password = param.password;
|
||||
this.accessToken = param.accessToken;
|
||||
this.basePath = param.basePath;
|
||||
this.serverIndex = param.serverIndex;
|
||||
this.baseOptions = param.baseOptions;
|
||||
this.formDataCtor = param.formDataCtor;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the given MIME is a JSON MIME.
|
||||
* JSON MIME examples:
|
||||
* application/json
|
||||
* application/json; charset=UTF8
|
||||
* APPLICATION/JSON
|
||||
* application/vnd.company+json
|
||||
* @param mime - MIME (Multipurpose Internet Mail Extensions)
|
||||
* @return True if the given MIME is JSON, false otherwise.
|
||||
*/
|
||||
public isJsonMime(mime: string): boolean {
|
||||
const jsonMime: RegExp = new RegExp('^(application\/json|[^;/ \t]+\/[^;/ \t]+[+]json)[ \t]*(;.*)?$', 'i');
|
||||
return mime !== null && (jsonMime.test(mime) || mime.toLowerCase() === 'application/json-patch+json');
|
||||
}
|
||||
}
|
||||
@@ -1,57 +0,0 @@
|
||||
#!/bin/sh
|
||||
# ref: https://help.github.com/articles/adding-an-existing-project-to-github-using-the-command-line/
|
||||
#
|
||||
# Usage example: /bin/sh ./git_push.sh wing328 openapi-petstore-perl "minor update" "gitlab.com"
|
||||
|
||||
git_user_id=$1
|
||||
git_repo_id=$2
|
||||
release_note=$3
|
||||
git_host=$4
|
||||
|
||||
if [ "$git_host" = "" ]; then
|
||||
git_host="github.com"
|
||||
echo "[INFO] No command line input provided. Set \$git_host to $git_host"
|
||||
fi
|
||||
|
||||
if [ "$git_user_id" = "" ]; then
|
||||
git_user_id="GIT_USER_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_user_id to $git_user_id"
|
||||
fi
|
||||
|
||||
if [ "$git_repo_id" = "" ]; then
|
||||
git_repo_id="GIT_REPO_ID"
|
||||
echo "[INFO] No command line input provided. Set \$git_repo_id to $git_repo_id"
|
||||
fi
|
||||
|
||||
if [ "$release_note" = "" ]; then
|
||||
release_note="Minor update"
|
||||
echo "[INFO] No command line input provided. Set \$release_note to $release_note"
|
||||
fi
|
||||
|
||||
# Initialize the local directory as a Git repository
|
||||
git init
|
||||
|
||||
# Adds the files in the local repository and stages them for commit.
|
||||
git add .
|
||||
|
||||
# Commits the tracked changes and prepares them to be pushed to a remote repository.
|
||||
git commit -m "$release_note"
|
||||
|
||||
# Sets the new remote
|
||||
git_remote=$(git remote)
|
||||
if [ "$git_remote" = "" ]; then # git remote not defined
|
||||
|
||||
if [ "$GIT_TOKEN" = "" ]; then
|
||||
echo "[INFO] \$GIT_TOKEN (environment variable) is not set. Using the git credential in your environment."
|
||||
git remote add origin https://${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
else
|
||||
git remote add origin https://${git_user_id}:"${GIT_TOKEN}"@${git_host}/${git_user_id}/${git_repo_id}.git
|
||||
fi
|
||||
|
||||
fi
|
||||
|
||||
git pull origin master
|
||||
|
||||
# Pushes (Forces) the changes in the local repository up to the remote repository
|
||||
echo "Git pushing to https://${git_host}/${git_user_id}/${git_repo_id}.git"
|
||||
git push origin master 2>&1 | grep -v 'To https'
|
||||
@@ -1,18 +0,0 @@
|
||||
/* tslint:disable */
|
||||
/* eslint-disable */
|
||||
/**
|
||||
* Infisical API
|
||||
* List of all available APIs that can be consumed
|
||||
*
|
||||
* The version of the OpenAPI document: 0.0.1
|
||||
*
|
||||
*
|
||||
* NOTE: This class is auto generated by OpenAPI Generator (https://openapi-generator.tech).
|
||||
* https://openapi-generator.tech
|
||||
* Do not edit the class manually.
|
||||
*/
|
||||
|
||||
|
||||
export * from "./api";
|
||||
export * from "./configuration";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
import { InfisicalSDK } from "..";
|
||||
import { ApiV1AuthUniversalAuthLoginPostRequest } from "../api/infisical";
|
||||
import { DefaultApi as InfisicalApi } from "../api/infisical";
|
||||
import { ApiV1AuthUniversalAuthLoginPostRequest } from "../infisicalapi_client";
|
||||
import { DefaultApi as InfisicalApi } from "../infisicalapi_client";
|
||||
|
||||
type AuthenticatorFunction = (accessToken: string) => InfisicalSDK;
|
||||
|
||||
|
||||
@@ -1,11 +1,11 @@
|
||||
import { Configuration, DefaultApi as InfisicalApi } from "../api/infisical";
|
||||
import { Configuration, DefaultApi as InfisicalApi } from "../infisicalapi_client";
|
||||
import type {
|
||||
DefaultApiApiV3SecretsRawGetRequest,
|
||||
DefaultApiApiV3SecretsRawSecretNameDeleteRequest,
|
||||
DefaultApiApiV3SecretsRawSecretNameGetRequest,
|
||||
DefaultApiApiV3SecretsRawSecretNamePatchRequest,
|
||||
DefaultApiApiV3SecretsRawSecretNamePostRequest
|
||||
} from "../api/infisical";
|
||||
} from "../infisicalapi_client";
|
||||
|
||||
export default class SecretsClient {
|
||||
#apiInstance: InfisicalApi;
|
||||
@@ -18,23 +18,41 @@ export default class SecretsClient {
|
||||
return res.data;
|
||||
};
|
||||
|
||||
retrieveSecret = async (options: DefaultApiApiV3SecretsRawSecretNameGetRequest) => {
|
||||
getSecret = async (options: DefaultApiApiV3SecretsRawSecretNameGetRequest) => {
|
||||
const res = await this.#apiInstance.apiV3SecretsRawSecretNameGet(options);
|
||||
return res.data.secret;
|
||||
};
|
||||
|
||||
updateSecret = async (options: DefaultApiApiV3SecretsRawSecretNamePatchRequest) => {
|
||||
const res = await this.#apiInstance.apiV3SecretsRawSecretNamePatch(options);
|
||||
updateSecret = async (
|
||||
secretName: DefaultApiApiV3SecretsRawSecretNamePatchRequest["secretName"],
|
||||
options: DefaultApiApiV3SecretsRawSecretNamePatchRequest["apiV3SecretsRawSecretNamePatchRequest"]
|
||||
) => {
|
||||
const res = await this.#apiInstance.apiV3SecretsRawSecretNamePatch({
|
||||
secretName,
|
||||
apiV3SecretsRawSecretNamePatchRequest: options
|
||||
});
|
||||
return res.data;
|
||||
};
|
||||
|
||||
createSecret = async (options: DefaultApiApiV3SecretsRawSecretNamePostRequest) => {
|
||||
const res = await this.#apiInstance.apiV3SecretsRawSecretNamePost(options);
|
||||
createSecret = async (
|
||||
secretName: DefaultApiApiV3SecretsRawSecretNamePostRequest["secretName"],
|
||||
options: DefaultApiApiV3SecretsRawSecretNamePostRequest["apiV3SecretsRawSecretNamePostRequest"]
|
||||
) => {
|
||||
const res = await this.#apiInstance.apiV3SecretsRawSecretNamePost({
|
||||
secretName,
|
||||
apiV3SecretsRawSecretNamePostRequest: options
|
||||
});
|
||||
return res.data;
|
||||
};
|
||||
|
||||
deleteSecret = async (options: DefaultApiApiV3SecretsRawSecretNameDeleteRequest) => {
|
||||
const res = await this.#apiInstance.apiV3SecretsRawSecretNameDelete(options);
|
||||
deleteSecret = async (
|
||||
secretName: DefaultApiApiV3SecretsRawSecretNameDeleteRequest["secretName"],
|
||||
options: DefaultApiApiV3SecretsRawSecretNameDeleteRequest["apiV3SecretsRawSecretNameDeleteRequest"]
|
||||
) => {
|
||||
const res = await this.#apiInstance.apiV3SecretsRawSecretNameDelete({
|
||||
secretName,
|
||||
apiV3SecretsRawSecretNameDeleteRequest: options
|
||||
});
|
||||
return res.data;
|
||||
};
|
||||
}
|
||||
|
||||
16
src/index.ts
16
src/index.ts
@@ -1,26 +1,32 @@
|
||||
import { Configuration, DefaultApi as InfisicalApi } from "./api/infisical";
|
||||
import { Configuration, DefaultApi as InfisicalApi } from "./infisicalapi_client";
|
||||
|
||||
import SecretsClient from "./custom/secrets";
|
||||
import AuthClient from "./custom/auth";
|
||||
|
||||
// We need to do bind(this) because the authenticate method is a private method, and usually you can't call private methods from outside the class.
|
||||
|
||||
type InfisicalSDKOptions = {
|
||||
siteUrl?: string;
|
||||
};
|
||||
|
||||
class InfisicalSDK {
|
||||
#apiInstance: InfisicalApi;
|
||||
// #accessToken: string; // No need to store the auth token here
|
||||
|
||||
#secretsClient: SecretsClient;
|
||||
#authClient: AuthClient;
|
||||
#basePath: string;
|
||||
|
||||
constructor() {
|
||||
this.#apiInstance = new InfisicalApi();
|
||||
constructor(options?: InfisicalSDKOptions) {
|
||||
this.#basePath = options?.siteUrl || "https://app.infisical.com";
|
||||
this.#apiInstance = new InfisicalApi(new Configuration({ basePath: this.#basePath }));
|
||||
|
||||
this.#authClient = new AuthClient(this.authenticate.bind(this));
|
||||
this.#secretsClient = new SecretsClient(this.#apiInstance);
|
||||
}
|
||||
|
||||
private authenticate(accessToken: string) {
|
||||
this.#apiInstance = new InfisicalApi(new Configuration({ accessToken }));
|
||||
this.#apiInstance = new InfisicalApi(new Configuration({ accessToken, basePath: this.#basePath }));
|
||||
|
||||
this.#secretsClient = new SecretsClient(this.#apiInstance);
|
||||
this.#authClient = new AuthClient(this.authenticate.bind(this));
|
||||
@@ -30,7 +36,7 @@ class InfisicalSDK {
|
||||
|
||||
secrets = () => this.#secretsClient;
|
||||
auth = () => this.#authClient;
|
||||
// rest = () => this.#apiInstance;
|
||||
rest = () => this.#apiInstance;
|
||||
}
|
||||
|
||||
export { InfisicalSDK };
|
||||
|
||||
@@ -8,10 +8,35 @@ import { InfisicalSDK } from "../src";
|
||||
clientSecret: "CLIENT_SECRET"
|
||||
});
|
||||
|
||||
const secrets = await client.secrets().listSecrets({
|
||||
const allSecrets = await client.secrets().listSecrets({
|
||||
environment: "dev",
|
||||
workspaceId: "PROJECT_ID"
|
||||
});
|
||||
console.log(allSecrets.secrets);
|
||||
|
||||
console.log(secrets.secrets);
|
||||
const singleSecret = await client.secrets().getSecret({
|
||||
secretName: "SECRET_NAME",
|
||||
environment: "dev"
|
||||
});
|
||||
console.log(`Fetched single secret, ${singleSecret.secretKey}=${singleSecret.secretValue}`);
|
||||
|
||||
const newSecret = await client.secrets().createSecret("NEW_SECRET_NAME", {
|
||||
environment: "dev",
|
||||
workspaceId: "PROJECT_ID",
|
||||
secretValue: "INITIAL SECRET VALUE!"
|
||||
});
|
||||
console.log(`You created a new secret: ${newSecret.secret}`);
|
||||
|
||||
const updatedSecret = await client.secrets().updateSecret("NEW_SECRET_NAME", {
|
||||
environment: "dev",
|
||||
workspaceId: "PROJECT_ID",
|
||||
secretValue: "NEW SECRET VALUE!"
|
||||
});
|
||||
console.log(`You updated the secret: ${updatedSecret.secret}`);
|
||||
|
||||
const deletedSecret = await client.secrets().deleteSecret("NEW_SECRET_NAME", {
|
||||
environment: "dev",
|
||||
workspaceId: "PROJECT_ID"
|
||||
});
|
||||
console.log(`You deleted the secret: ${deletedSecret.secret}`);
|
||||
})();
|
||||
|
||||
@@ -27,7 +27,8 @@ const desiredEndpoints: Endpoint[] = [
|
||||
{ path: "/api/v1/auth/token-auth/identities/{identityId}/tokens", method: "GET" },
|
||||
{ path: "/api/v1/auth/token-auth/identities/{identityId}/tokens", method: "POST" },
|
||||
{ path: "/api/v1/auth/token-auth/tokens/{tokenId}", method: "PATCH" },
|
||||
{ path: "/v1/auth/token-auth/tokens/{tokenId}/revoke", method: "POST" }
|
||||
{ path: "/v1/auth/token-auth/tokens/{tokenId}/revoke", method: "POST" },
|
||||
|
||||
];
|
||||
|
||||
https
|
||||
|
||||
Reference in New Issue
Block a user