From 745f052fcdd75e60f9df9f58a2807dd21f9f56dc Mon Sep 17 00:00:00 2001 From: typicode Date: Thu, 2 Jan 2025 19:56:09 +0100 Subject: [PATCH] feat: add getOrgSecurityPolicy --- README.md | 2 ++ index.js | 16 ++++++++++++++++ 2 files changed, 18 insertions(+) diff --git a/README.md b/README.md index 54f59ca..5197fb7 100644 --- a/README.md +++ b/README.md @@ -63,6 +63,8 @@ const { SocketSdk } = require('@socketsecurity/sdk') * `getOrganizations()` * `postSettings(selectors)` * `selectors`: An array of settings selectors, e.g. `[{ organization: 'id' }]` +* `getOrgSecurityPolicy(orgSlug)` + * `orgSlug`: the slug of the organization ## Additional exports diff --git a/index.js b/index.js index 0c72f22..7ef2750 100644 --- a/index.js +++ b/index.js @@ -587,6 +587,22 @@ class SocketSdk { } } + /** + * @param {string} orgSlug + * @returns {Promise>} + */ + async getOrgSecurityPolicy (orgSlug) { + const orgSlugParam = encodeURIComponent(orgSlug) + + try { + const client = await this.#getClient() + const data = await client.get(`orgs/${orgSlugParam}/settings/security-policy`).json() + return { success: true, status: 200, data } + } catch (err) { + return /** @type {SocketSdkErrorType<'getOrgSecurityPolicy'>} */ (this.#handleApiError(err)) + } + } + /** * @param {unknown} err * @returns {{ success: false, status: number, error: Record }}