sjursen-digital-watchtower
Version:
A TypeScript Node.js SDK for Watchtower, an Intelligence as a Service (IaaS) platform that uses Google's Gemini AI model to transform traditional logging into an active intelligence system with predictive analytics and automated decision-making capabiliti
99 lines • 3.3 kB
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.APIKeyEndpoint = void 0;
const base_1 = require("../base");
class APIKeyEndpoint extends base_1.BaseEndpoint {
constructor(client) {
super(client, '/api/apikey');
}
/**
* Create an organization and get an API key
* @param data - The organization creation request
* @returns Promise with the API key response
*/
async createOrganization(data) {
return this.post('/org', data);
}
/**
* Create an app and get an app API key
* @param data - The app creation request
* @returns Promise with the app API key response
*/
async createApp(data) {
return this.post('/app', data);
}
/**
* Create a tenant and get a tenant API key
* @param data - The tenant creation request
* @returns Promise with the tenant API key response
*/
async createTenant(data) {
return this.post('/tenant', data);
}
/**
* Roll an API key (organization, app, or tenant)
* @param data - The roll API key request
* @returns Promise with the new rolled API key
*/
async rollAPIKey(data) {
return this.post('/roll', data);
}
/**
* Create a new API key for an existing organization, app, or tenant
* @param data - The API key creation request
* @returns Promise with the new API key
*/
async createAPIKey(data) {
return this.post('/create', data);
}
/**
* Creates a new API key for an existing organization using JWT authentication
*
* @param organizationId - ID of the existing organization
* @param jwtToken - Valid Supabase JWT token
* @returns Promise<APIKeyResponse>
* @throws Error if request fails
*/
async createOrgKey(organizationId, jwtToken) {
try {
return await this.post('/api/apikey/org/jwt', {
organization_id: organizationId
}, {
headers: {
'Authorization': `Bearer ${jwtToken}`,
'Content-Type': 'application/json'
}
});
}
catch (error) {
throw new Error(error.response?.data?.error || 'Failed to create organization API key');
}
}
/**
* Creates a new API key for an app in the user's organization using JWT authentication
*
* @param appName - Name of the app
* @param tenancyModel - App's tenancy model ("single" or "multi")
* @param jwtToken - Valid Supabase JWT token
* @returns Promise<APIKeyResponse>
* @throws Error if request fails
*/
async createAppKey(appName, tenancyModel, jwtToken) {
try {
return await this.post('/api/apikey/app/jwt', {
app_name: appName,
tenancy_model: tenancyModel
}, {
headers: {
'Authorization': `Bearer ${jwtToken}`,
'Content-Type': 'application/json'
}
});
}
catch (error) {
throw new Error(error.response?.data?.error || 'Failed to create app API key');
}
}
}
exports.APIKeyEndpoint = APIKeyEndpoint;
//# sourceMappingURL=handler.js.map