@fusebit/add-on-sdk
Advanced tools
Comparing version 1.3.0 to 1.3.1
@@ -285,12 +285,17 @@ const Superagent = require('superagent'); | ||
exports.deleteStorage = async (ctx) => { | ||
exports.deleteStorage = async (functionCtx, ctx) => { | ||
debug('DELETE STORAGE'); | ||
const issuerId = ctx.configuration.fusebit_storage_issuer_id; | ||
const subject = ctx.configuration.fusebit_storage_subject; | ||
const accountId = ctx.configuration.fusebit_storage_account_id; | ||
const issuerId = functionCtx.configuration.fusebit_storage_issuer_id; | ||
const subject = functionCtx.configuration.fusebit_storage_subject; | ||
const accountId = functionCtx.configuration.fusebit_storage_account_id; | ||
if (!issuerId || !subject || !accountId) { | ||
debug('Storage not configured for this function'); | ||
return; | ||
} | ||
// Delete the storage | ||
debug('Deleting storage'); | ||
await Superagent.delete(generateStorageUrl(ctx)) | ||
await Superagent.delete(generateStorageUrl(functionCtx)) | ||
.set('Authorization', ctx.headers['authorization']) // pass-through authorization | ||
@@ -402,2 +407,4 @@ .ok((r) => r.status < 300 || r.status === 404); | ||
exports.deleteFunction = async (ctx, boundaryId, functionId) => { | ||
let functionCtx = await exports.getFunctionDefinition(ctx, boundaryId, functionId); | ||
await Superagent.delete( | ||
@@ -408,4 +415,17 @@ `${ctx.body.baseUrl}/v1/account/${ctx.body.accountId}/subscription/${ctx.body.subscriptionId}/boundary/${ | ||
).set('Authorization', ctx.headers['authorization']); // pass-through authorization | ||
// Try to delete the storage, this will do nothing if storage wasn't configured | ||
await exports.deleteStorage(functionCtx, ctx); | ||
}; | ||
exports.getFunctionDefinition = async (ctx, boundaryId, functionId) => { | ||
let response = await Superagent.get( | ||
`${ctx.body.baseUrl}/v1/account/${ctx.body.accountId}/subscription/${ctx.body.subscriptionId}/boundary/${ | ||
boundaryId || ctx.body.boundaryId | ||
}/function/${functionId || ctx.body.functionId}` | ||
).set('Authorization', ctx.headers['authorization']); // pass-through authorization | ||
return response.body; | ||
}; | ||
exports.getFunctionUrl = async (ctx, boundaryId, functionId) => { | ||
@@ -412,0 +432,0 @@ let response = await Superagent.get( |
{ | ||
"name": "@fusebit/add-on-sdk", | ||
"version": "1.3.0", | ||
"version": "1.3.1", | ||
"description": "SDK for implementing Fusebit Add-Ons", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
22271
435
1