@fusebit/add-on-sdk
Advanced tools
Comparing version 1.3.1 to 2.0.0
@@ -281,12 +281,12 @@ const Superagent = require('superagent'); | ||
function generateStorageUrl(ctx) { | ||
return `${ctx.configuration.fusebit_storage_audience}/v1/account/${ctx.configuration.fusebit_storage_account_id}/subscription/${ctx.configuration.fusebit_storage_subscription_id}/storage/${ctx.configuration.fusebit_storage_id}`; | ||
function generateStorageUrl(storageCtx) { | ||
return `${storageCtx.fusebit_storage_audience}/v1/account/${storageCtx.fusebit_storage_account_id}/subscription/${storageCtx.fusebit_storage_subscription_id}/storage/${storageCtx.fusebit_storage_id}`; | ||
} | ||
exports.deleteStorage = async (functionCtx, ctx) => { | ||
exports.deleteStorage = async (ctx, storageCtx) => { | ||
debug('DELETE STORAGE'); | ||
const issuerId = functionCtx.configuration.fusebit_storage_issuer_id; | ||
const subject = functionCtx.configuration.fusebit_storage_subject; | ||
const accountId = functionCtx.configuration.fusebit_storage_account_id; | ||
const issuerId = storageCtx.fusebit_storage_issuer_id; | ||
const subject = storageCtx.fusebit_storage_subject; | ||
const accountId = storageCtx.fusebit_storage_account_id; | ||
@@ -300,3 +300,3 @@ if (!issuerId || !subject || !accountId) { | ||
debug('Deleting storage'); | ||
await Superagent.delete(generateStorageUrl(functionCtx)) | ||
await Superagent.delete(generateStorageUrl(storageCtx)) | ||
.set('Authorization', ctx.headers['authorization']) // pass-through authorization | ||
@@ -334,31 +334,2 @@ .ok((r) => r.status < 300 || r.status === 404); | ||
try { | ||
// Acquire any additional configuration elements from optional components | ||
let additionalCfg = {}; | ||
// Is storage requested? | ||
if (functionSpecification.enableStorage) { | ||
additionalCfg = await exports.createStorage(ctx); | ||
if (typeof functionSpecification.nodejs.files['package.json'] === 'object') { | ||
functionSpecification.nodejs.files['package.json'].dependencies['@fusebit/add-on-sdk'] = '*'; | ||
} else if (typeof functionSpecification.nodejs.files['package.json'] === 'string') { | ||
let pkg = JSON.parse(functionSpecification.nodejs.files['package.json']); | ||
pkg.dependencies['@fusebit/add-on-sdk'] = '*'; | ||
functionSpecification.nodejs.files['package.json'] = pkg; | ||
} | ||
} | ||
delete functionSpecification.enableStorage; | ||
// Add the additional configuration elements to the specification | ||
if (Object.keys(additionalCfg).length != 0) { | ||
if (functionSpecification.configurationSerialized) { | ||
functionSpecification.configurationSerialized += `# Storage configuration settings\n${Object.keys(additionalCfg) | ||
.sort() | ||
.map((k) => `${k}=${additionalCfg[k]}`) | ||
.join('\n')}\n`; | ||
} else { | ||
functionSpecification.configuration = { ...functionSpecification.configuration, ...additionalCfg }; | ||
} | ||
} | ||
// Create the function | ||
@@ -409,4 +380,2 @@ let url = `${ctx.body.baseUrl}/v1/account/${ctx.body.accountId}/subscription/${ctx.body.subscriptionId}/boundary/${ctx.body.boundaryId}/function/${ctx.body.functionId}`; | ||
exports.deleteFunction = async (ctx, boundaryId, functionId) => { | ||
let functionCtx = await exports.getFunctionDefinition(ctx, boundaryId, functionId); | ||
await Superagent.delete( | ||
@@ -417,5 +386,2 @@ `${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); | ||
}; | ||
@@ -454,3 +420,3 @@ | ||
const url = generateStorageUrl(ctx); | ||
const url = generateStorageUrl(ctx.configuration); | ||
@@ -457,0 +423,0 @@ return { |
{ | ||
"name": "@fusebit/add-on-sdk", | ||
"version": "1.3.1", | ||
"version": "2.0.0", | ||
"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
0
20520
407