This commit is contained in:
Daniel Hougaard
2024-08-30 01:08:45 +04:00
7 changed files with 72 additions and 306 deletions

3
.gitignore vendored
View File

@@ -129,4 +129,5 @@ dist
.yarn/install-state.gz
.pnp.*
/src/infisicalapi_client
/src/infisicalapi_client
/lib

18
package-lock.json generated
View File

@@ -18,6 +18,7 @@
},
"devDependencies": {
"@openapitools/openapi-generator-cli": "^2.13.5",
"@types/node": "^22.5.1",
"tsc": "^2.0.4"
}
},
@@ -1705,6 +1706,16 @@
"node": ">=14.0.0"
}
},
"node_modules/@types/node": {
"version": "22.5.1",
"resolved": "https://registry.npmjs.org/@types/node/-/node-22.5.1.tgz",
"integrity": "sha512-KkHsxej0j9IW1KKOOAA/XBA0z08UFSrRQHErzEfA3Vgq57eXIMYboIlHJuYIfd+lwCQjtKqUu3UnmKbtUc9yRw==",
"dev": true,
"license": "MIT",
"dependencies": {
"undici-types": "~6.19.2"
}
},
"node_modules/agent-base": {
"version": "7.1.1",
"resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.1.tgz",
@@ -2952,6 +2963,13 @@
"node": ">=8"
}
},
"node_modules/undici-types": {
"version": "6.19.8",
"resolved": "https://registry.npmjs.org/undici-types/-/undici-types-6.19.8.tgz",
"integrity": "sha512-ve2KP6f/JnbPBFyobGHuerC9g1FYGn/F8n1LWTwNxCEzd6IfqTwUQcNXgEtmmQ6DlRrC1hrSrBnCZPokRrDHjw==",
"dev": true,
"license": "MIT"
},
"node_modules/universalify": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/universalify/-/universalify-2.0.1.tgz",

View File

@@ -1,16 +1,30 @@
{
"name": "infisical-node-sdk",
"version": "1.0.0",
"main": "index.js",
"name": "@infisical/sdk-v2",
"version": "0.0.0",
"main": "./lib/index.js",
"files": [
"lib"
],
"scripts": {
"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"
"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"
},
"keywords": [],
"author": "",
"keywords": [
"infisical",
"open-source",
"sdk",
"typescript"
],
"repository": {
"type": "git",
"url": "https://github.com/infisical/infisical-node-sdk"
},
"author": "Infisical Inc, <daniel@infisical.com>",
"license": "ISC",
"description": "",
"devDependencies": {
"@openapitools/openapi-generator-cli": "^2.13.5",
"@types/node": "^22.5.1",
"tsc": "^2.0.4"
},
"dependencies": {

View File

@@ -1,292 +0,0 @@
{
"openapi": "3.0.3",
"info": {
"title": "Infisical API",
"description": "List of all available APIs that can be consumed",
"version": "0.0.1"
},
"components": {
"securitySchemes": {
"bearerAuth": {
"type": "http",
"scheme": "bearer",
"bearerFormat": "JWT",
"description": "An access token in Infisical"
}
},
"schemas": {}
},
"paths": {
"/api/v1/identities": {
"get": {
"description": "List identities",
"parameters": [
{
"schema": {
"type": "string"
},
"in": "query",
"name": "orgId",
"required": true,
"description": "The ID of the organization to list identities."
}
],
"security": [
{
"bearerAuth": []
}
],
"responses": {
"200": {
"description": "Default Response",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"identities": {
"type": "array",
"items": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"role": {
"type": "string"
},
"roleId": {
"type": "string",
"format": "uuid",
"nullable": true
},
"orgId": {
"type": "string",
"format": "uuid"
},
"createdAt": {
"type": "string",
"format": "date-time"
},
"updatedAt": {
"type": "string",
"format": "date-time"
},
"identityId": {
"type": "string",
"format": "uuid"
},
"customRole": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"name": {
"type": "string"
},
"slug": {
"type": "string"
},
"permissions": {},
"description": {
"type": "string",
"nullable": true
}
},
"required": [
"id",
"name",
"slug"
],
"additionalProperties": false
},
"identity": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"id": {
"type": "string",
"format": "uuid"
},
"authMethod": {
"type": "string",
"nullable": true
}
},
"required": [
"name",
"id"
],
"additionalProperties": false
}
},
"required": [
"id",
"role",
"orgId",
"createdAt",
"updatedAt",
"identityId",
"identity"
],
"additionalProperties": false
}
}
},
"required": [
"identities"
],
"additionalProperties": false
}
}
}
}
}
}
},
"/api/v1/identities/{identityId}": {
"get": {
"description": "Get an identity by id",
"parameters": [
{
"schema": {
"type": "string"
},
"in": "path",
"name": "identityId",
"required": true,
"description": "The ID of the identity to get details."
}
],
"security": [
{
"bearerAuth": []
}
],
"responses": {
"200": {
"description": "Default Response",
"content": {
"application/json": {
"schema": {
"type": "object",
"properties": {
"identity": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"role": {
"type": "string"
},
"roleId": {
"type": "string",
"format": "uuid",
"nullable": true
},
"orgId": {
"type": "string",
"format": "uuid"
},
"createdAt": {
"type": "string",
"format": "date-time"
},
"updatedAt": {
"type": "string",
"format": "date-time"
},
"identityId": {
"type": "string",
"format": "uuid"
},
"customRole": {
"type": "object",
"properties": {
"id": {
"type": "string",
"format": "uuid"
},
"name": {
"type": "string"
},
"slug": {
"type": "string"
},
"permissions": {},
"description": {
"type": "string",
"nullable": true
}
},
"required": [
"id",
"name",
"slug"
],
"additionalProperties": false
},
"identity": {
"type": "object",
"properties": {
"name": {
"type": "string"
},
"id": {
"type": "string",
"format": "uuid"
},
"authMethod": {
"type": "string",
"nullable": true
}
},
"required": [
"name",
"id"
],
"additionalProperties": false
}
},
"required": [
"id",
"role",
"orgId",
"createdAt",
"updatedAt",
"identityId",
"identity"
],
"additionalProperties": false
}
},
"required": [
"identity"
],
"additionalProperties": false
}
}
}
}
}
}
}
},
"servers": [
{
"url": "https://app.infisical.com",
"description": "Production server"
},
{
"url": "http://localhost:8080",
"description": "Local server"
}
]
}

17
test/index.js Normal file
View File

@@ -0,0 +1,17 @@
const { InfisicalSDK } = require("../lib");
(async () => {
const client = new InfisicalSDK();
await client.auth().universalAuth.login({
clientId: "CLIENT_ID",
clientSecret: "CLIENT_SECRET"
});
const secrets = await client.secrets().listSecrets({
environment: "dev",
workspaceId: "PROJECT_ID"
});
console.log(secrets.secrets);
})();

View File

@@ -1,7 +0,0 @@
{
"$schema": "./node_modules/@openapitools/openapi-generator-cli/config.schema.json",
"spaces": 2,
"generator-cli": {
"version": "7.8.0"
}
}

15
tsconfig.json Normal file
View File

@@ -0,0 +1,15 @@
{
"compilerOptions": {
"target": "es6",
"module": "commonjs",
"declaration": true,
"rootDir": "./src",
"outDir": "./lib",
"strict": true,
"resolveJsonModule": true,
"removeComments": true,
"esModuleInterop": true
},
"include": [".", "src"],
"exclude": ["examples", "node_modules", "lib", "test"]
}