Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

carbone-sdk-js

Package Overview
Dependencies
Maintainers
3
Versions
9
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

carbone-sdk-js - npm Package Compare versions

Comparing version 1.1.5 to 1.1.6

dist/main.mjs

2

CHANGELOG.md

@@ -0,1 +1,3 @@

### v1.1.6
- generates a CJS module
### v1.1.5

@@ -2,0 +4,0 @@ - Update documentation, license and lint code

2

dist/main.js

@@ -1,2 +0,2 @@

const d=function(h){const t={apiUrl:"https://render.carbone.io",accessToken:h,apiVersion:3};return{getAccessToken:function(){return t.accessToken},setAccessToken:function(e){t.accessToken=e},getApiVersion:function(){return t.apiVersion},setApiVersion:function(e){t.apiVersion=e},getApiUrl:function(){return t.apiUrl},setApiUrl:function(e){t.apiUrl=e},addTemplate:async function(e,r=""){var n=new FormData;if(!e)throw new Error("Carbone SDK addTemplate error: the file argument is not valid.");n.append("payload",r),n.append("template",e);const o=await fetch(`${t.apiUrl}/template`,{method:"post",body:n,headers:{"carbone-version":t.apiVersion,Authorization:"Bearer "+t.accessToken}});return await o.json()},deleteTemplate:async function(e){if(!e)throw new Error("Carbone SDK deleteTemplate error: the templateId argument is not valid.");const r=await fetch(`${t.apiUrl}/template/${e}`,{method:"delete",headers:{"carbone-version":t.apiVersion,Authorization:"Bearer "+t.accessToken}});return await r.json()},getTemplate:async function(e,r="blob"){if(!e)throw new Error("Carbone SDK getTemplate error: the templateId argument is not valid.");if(["blob","text"].indexOf(r)===-1)throw new Error("Carbone SDK getTemplate error: the responseType argument is not valid.");const n=await fetch(`${t.apiUrl}/template/${e}`,{method:"get",headers:{"carbone-version":t.apiVersion,Authorization:"Bearer "+t.accessToken}});return await n[r]()},renderReport:async function(e,r){if(!e)throw new Error("Carbone SDK renderReport error: the templateId argument is not valid.");if(!r)throw new Error("Carbone SDK renderReport error: the data argument is not valid.");const n=await fetch(`${t.apiUrl}/render/${e}`,{method:"post",body:JSON.stringify(r),headers:{"Content-type":"application/json","carbone-version":t.apiVersion,Authorization:"Bearer "+t.accessToken}});return await n.json()},getReport:async function(e,r="blob"){if(!e)throw new Error("Carbone SDK getReport error: the renderId argument is not valid.");if(["blob","text"].indexOf(r)===-1)throw new Error("Carbone SDK getReport error: the responseType argument is not valid.");const n=await fetch(`${t.apiUrl}/render/${e}`,{method:"get",headers:{"carbone-version":t.apiVersion,Authorization:"Bearer "+t.accessToken}});return{content:await n[r](),name:this.getReportNameFromHeader(n.headers)}},render:async function(e,r,n="",o="blob"){if(!e)throw new Error("Carbone SDK render error: the templateId argument is not valid.");if(!r)throw new Error("Carbone SDK render error: the data argument is not valid.");let a=null;if(typeof e=="string"&&e.length===64&&Object.prototype.hasOwnProperty.call(e,"name")===!1&&(a=await this.renderReport(e,r)),a===null||a.success===!1){const l=await(typeof e=="string"?e:await e.arrayBuffer().then(i=>new Uint8Array(i))),s=await this.generateTemplateId(l,n);if(s&&(a=await this.renderReport(s,r)),a===null||a.success===!1){const i=await this.addTemplate(e,n);i&&i.success===!0&&i.data.templateId&&(a=await this.renderReport(i.data.templateId,r))}}if(!a||a.success===!1||!a.data.renderId)throw new Error("Carbone SDK render error: the rendering has failled.");return this.getReport(a.data.renderId,o)},generateTemplateId:async function(e,r=""){function n(s){for(var i="",c=new DataView(s),p=0;p<c.byteLength;p+=4){var m=c.getUint32(p),f=m.toString(16),u="00000000",b=(u+f).slice(-u.length);i+=b}return i}var o=typeof e=="string"?new TextEncoder("utf-8").encode(e):e,a=typeof r=="string"?new TextEncoder("utf-8").encode(r):r,l=new Uint8Array(a.length+o.length);return l.set(a),l.set(o,a.length),await crypto.subtle.digest("SHA-256",l).then(function(s){return n(s)})},getReportNameFromHeader(e){if(!e)return null;const r=e.get("content-disposition");if(!r)return null;let n=r.split("=");if(n.length===1||!n[1])return null;let o=n[1];return o[0]==='"'&&o[o.length-1]==='"'&&(o=o.substr(1,n[1].length-2)),o}}};window.carboneRenderSDK=d;window.carboneSDK=d;var g=d;export{g as default};
var m=Object.defineProperty,w=s=>m(s,"__esModule",{value:!0}),y=(s,r)=>{w(s);for(var e in r)m(s,e,{get:r[e],enumerable:!0})};y(exports,{default:()=>S});const c=function(s){const r={apiUrl:"https://render.carbone.io",accessToken:s,apiVersion:3};return{getAccessToken:function(){return r.accessToken},setAccessToken:function(e){r.accessToken=e},getApiVersion:function(){return r.apiVersion},setApiVersion:function(e){r.apiVersion=e},getApiUrl:function(){return r.apiUrl},setApiUrl:function(e){r.apiUrl=e},addTemplate:async function(e,t=""){var n=new FormData;if(!e)throw new Error("Carbone SDK addTemplate error: the file argument is not valid.");n.append("payload",t),n.append("template",e);const o=await fetch(`${r.apiUrl}/template`,{method:"post",body:n,headers:{"carbone-version":r.apiVersion,Authorization:"Bearer "+r.accessToken}});return await o.json()},deleteTemplate:async function(e){if(!e)throw new Error("Carbone SDK deleteTemplate error: the templateId argument is not valid.");const t=await fetch(`${r.apiUrl}/template/${e}`,{method:"delete",headers:{"carbone-version":r.apiVersion,Authorization:"Bearer "+r.accessToken}});return await t.json()},getTemplate:async function(e,t="blob"){if(!e)throw new Error("Carbone SDK getTemplate error: the templateId argument is not valid.");if(["blob","text"].indexOf(t)===-1)throw new Error("Carbone SDK getTemplate error: the responseType argument is not valid.");const n=await fetch(`${r.apiUrl}/template/${e}`,{method:"get",headers:{"carbone-version":r.apiVersion,Authorization:"Bearer "+r.accessToken}});return await n[t]()},renderReport:async function(e,t){if(!e)throw new Error("Carbone SDK renderReport error: the templateId argument is not valid.");if(!t)throw new Error("Carbone SDK renderReport error: the data argument is not valid.");const n=await fetch(`${r.apiUrl}/render/${e}`,{method:"post",body:JSON.stringify(t),headers:{"Content-type":"application/json","carbone-version":r.apiVersion,Authorization:"Bearer "+r.accessToken}});return await n.json()},getReport:async function(e,t="blob"){if(!e)throw new Error("Carbone SDK getReport error: the renderId argument is not valid.");if(["blob","text"].indexOf(t)===-1)throw new Error("Carbone SDK getReport error: the responseType argument is not valid.");const n=await fetch(`${r.apiUrl}/render/${e}`,{method:"get",headers:{"carbone-version":r.apiVersion,Authorization:"Bearer "+r.accessToken}});return{content:await n[t](),name:this.getReportNameFromHeader(n.headers)}},render:async function(e,t,n="",o="blob"){if(!e)throw new Error("Carbone SDK render error: the templateId argument is not valid.");if(!t)throw new Error("Carbone SDK render error: the data argument is not valid.");let a=null;if(typeof e=="string"&&e.length===64&&Object.prototype.hasOwnProperty.call(e,"name")===!1&&(a=await this.renderReport(e,t)),a===null||a.success===!1){const p=await(typeof e=="string"?e:await e.arrayBuffer().then(i=>new Uint8Array(i))),l=await this.generateTemplateId(p,n);if(l&&(a=await this.renderReport(l,t)),a===null||a.success===!1){const i=await this.addTemplate(e,n);i&&i.success===!0&&i.data.templateId&&(a=await this.renderReport(i.data.templateId,t))}}if(!a||a.success===!1||!a.data.renderId)throw new Error("Carbone SDK render error: the rendering has failled.");return this.getReport(a.data.renderId,o)},generateTemplateId:async function(e,t=""){function n(l){for(var i="",u=new DataView(l),d=0;d<u.byteLength;d+=4){var f=u.getUint32(d),b=f.toString(16),h="00000000",g=(h+b).slice(-h.length);i+=g}return i}var o=typeof e=="string"?new TextEncoder("utf-8").encode(e):e,a=typeof t=="string"?new TextEncoder("utf-8").encode(t):t,p=new Uint8Array(a.length+o.length);return p.set(a),p.set(o,a.length),await crypto.subtle.digest("SHA-256",p).then(function(l){return n(l)})},getReportNameFromHeader(e){if(!e)return null;const t=e.get("content-disposition");if(!t)return null;let n=t.split("=");if(n.length===1||!n[1])return null;let o=n[1];return o[0]==='"'&&o[o.length-1]==='"'&&(o=o.substr(1,n[1].length-2)),o}}};window.carboneRenderSDK=c;window.carboneSDK=c;var S=c;
//# sourceMappingURL=main.js.map
{
"name": "carbone-sdk-js",
"version": "1.1.5",
"version": "1.1.6",
"description": "The javascript SDK to use Carbone Render easily ",
"homepage": "https://github.com/carboneio/carbone-sdk-js",
"main": "dist/main.js",
"module": "dist/main.js",
"module": "dist/main.mjs",
"repository": {

@@ -9,0 +9,0 @@ "type": "git",

# Carbone Render Javascript SDK
![Version](https://img.shields.io/badge/version-1.1.5-blue.svg?cacheSeconds=2592000)
![Version](https://img.shields.io/badge/version-1.1.6-blue.svg?cacheSeconds=2592000)
[![Documentation](https://img.shields.io/badge/documentation-yes-brightgreen.svg)](./doc/API-REFERENCE.md)

@@ -4,0 +4,0 @@

Sorry, the diff of this file is not supported yet

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc