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

@superfaceai/one-sdk

Package Overview
Dependencies
Maintainers
3
Versions
135
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@superfaceai/one-sdk - npm Package Compare versions

Comparing version 3.0.0-alpha.11 to 3.0.0-alpha.12

54

cloudflare/index.js
import { WASI } from '@cloudflare/workers-wasi';
import { App, HandleMap } from '../common/index.js';
import { App, HandleMap, UnexpectedError } from '../common/index.js';
export { PerformError, UnexpectedError } from '../common/error.js';

@@ -86,6 +86,30 @@ // @ts-ignore

}
class CfwTextStreamDecoder {
constructor() {
this.decoder = new TextDecoder();
this.decoderBuffer = '';
}
/** Decodes streaming data and splits it by newline. */
decodeUtf8Lines(buffer) {
this.decoderBuffer += this.decoder.decode(buffer, { stream: true });
return this.getLines();
}
flush() {
this.decoderBuffer += this.decoder.decode();
return this.getLines();
}
getLines() {
const lines = this.decoderBuffer.split('\n');
if (lines.length > 1) {
this.decoderBuffer = lines[lines.length - 1];
return lines.slice(0, -1);
}
return [];
}
}
class CfwWasiCompat {
constructor(wasi) {
this.stdoutDecoder = new CfwTextStreamDecoder();
this.stderrDecoder = new CfwTextStreamDecoder();
this.wasi = wasi;
this.coder = new CfwTextCoder();
}

@@ -119,4 +143,4 @@ get wasiImport() {

fd_write(fd, ciovs_ptr, ciovs_len, retptr0) {
// hijack stdout yolo
if (fd !== 1) {
// hijack stdout and stderr
if (fd !== 1 && fd !== 2) {
return this.wasi.wasiImport.fd_write(fd, ciovs_ptr, ciovs_len, retptr0);

@@ -136,4 +160,9 @@ }

view.setUint32(retptr0, writeCount, true);
console.log(this.coder.decodeUtf8(buffer).trimEnd());
return 0;
if (fd === 1) {
this.stdoutDecoder.decodeUtf8Lines(buffer).forEach(line => console.log(line));
}
else {
this.stderrDecoder.decodeUtf8Lines(buffer).forEach(line => console.error(line));
}
return 0; // SUCCESS
}

@@ -170,3 +199,3 @@ }

for (const event of events) {
console.error(event);
console.error(event.trim());
}

@@ -188,2 +217,3 @@ }

async init() {
// TODO: probably will need a lock like node platform has at some point
if (this.ready) {

@@ -207,3 +237,11 @@ return;

const assetsPath = this.options.assetsPath ?? 'superface'; // TODO: path join? - not sure if we are going to stick with this VFS
return await this.app.perform(`file://${assetsPath}/${resolvedProfile}.profile`, `file://${assetsPath}/${provider}.provider.json`, `file://${assetsPath}/${resolvedProfile}.${provider}.map.js`, usecase, input, parameters, security);
try {
return await this.app.perform(`file://${assetsPath}/${resolvedProfile}.profile`, `file://${assetsPath}/${provider}.provider.json`, `file://${assetsPath}/${resolvedProfile}.${provider}.map.js`, usecase, input, parameters, security);
}
catch (err) {
if (err instanceof UnexpectedError && (err.name === 'WebAssemblyRuntimeError')) {
await this.destroy();
}
throw err;
}
}

@@ -210,0 +248,0 @@ async sendMetrics() {

2

package.json
{
"name": "@superfaceai/one-sdk",
"version": "3.0.0-alpha.11",
"version": "3.0.0-alpha.12",
"main": "node/index.js",

@@ -5,0 +5,0 @@ "type": "module",

Sorry, the diff of this file is not supported yet

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