Latest Threat Research:SANDWORM_MODE: Shai-Hulud-Style npm Worm Hijacks CI Workflows and Poisons AI Toolchains.Details
Socket
Book a DemoInstallSign in
Socket

@suborbital/suborbital

Package Overview
Dependencies
Maintainers
2
Versions
11
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@suborbital/suborbital - npm Package Compare versions

Comparing version
0.12.0
to
0.13.0
+2
-2
assembly/cache.ts
import { cache_set, cache_get } from "./env"
import { ffi_result, getIdent, toFFI } from "./ffi"
import { Result, ffi_result, getIdent, toFFI } from "./ffi"
export function cacheGet(key: string): ArrayBuffer {
export function cacheGet(key: string): Result {
let keyBuf = String.UTF8.encode(key)

@@ -6,0 +6,0 @@ let keyFFI = toFFI(keyBuf)

@@ -5,2 +5,21 @@ import { get_ffi_result } from "./env"

export class Result {
Result: ArrayBuffer
Err: Error | null
constructor(result: ArrayBuffer, err: Error | null) {
this.Result = result
this.Err = err
}
toString(): string {
let err = this.Err
if(err) {
return err.toString()
}
return String.UTF8.decode(this.Result)
}
}
export function setIdent(ident: i32): void {

@@ -14,15 +33,29 @@ current_ident = ident

export function ffi_result(size: i32): ArrayBuffer {
export function ffi_result(size: i32): Result {
let allocSize = size
let unknownRes: Result = new Result(new ArrayBuffer(0), new Error("unknown error returned from host"))
if (size < 0) {
return new ArrayBuffer(0)
if (size == -1) {
return unknownRes
}
allocSize = size * -1
}
let result_ptr = heap.alloc(size)
let result_ptr = heap.alloc(allocSize)
let code = get_ffi_result(result_ptr, current_ident)
if (code != 0) {
return new ArrayBuffer(0)
return unknownRes
}
return fromFFI(result_ptr, size)
let data = fromFFI(result_ptr, allocSize)
if (size < 0) {
return new Result(new ArrayBuffer(0), new Error(String.UTF8.decode(data)))
}
return new Result(data, null)
}

@@ -29,0 +62,0 @@

import { graphql_query } from "./env";
import { toFFI, ffi_result, getIdent } from "./ffi";
import { Result, toFFI, ffi_result, getIdent } from "./ffi";
// send a GraphQL query to the provided endpoint
export function graphQLQuery(endpoint: string, query: string): ArrayBuffer {
export function graphQLQuery(endpoint: string, query: string): Result {
let endpointFFI = toFFI(String.UTF8.encode(endpoint))

@@ -11,5 +11,3 @@ let queryFFI = toFFI(String.UTF8.encode(query))

let result = ffi_result(result_size)
return result
return ffi_result(result_size)
}
import { fetch_url } from "./env"
import { ffi_result, getIdent, toFFI } from "./ffi"
import { Result, ffi_result, getIdent, toFFI } from "./ffi"
export function httpGet(url: string, headers: Map<string, string> | null): ArrayBuffer {
export function httpGet(url: string, headers: Map<string, string> | null): Result {
return do_request(method_get, url, new ArrayBuffer(0), headers)
}
export function httpPost(url: string, body: ArrayBuffer, headers: Map<string, string> | null): ArrayBuffer {
export function httpHead(url: string, headers: Map<string, string> | null): Result {
return do_request(method_head, url, new ArrayBuffer(0), headers)
}
export function httpOptions(url: string, headers: Map<string, string> | null): Result {
return do_request(method_options, url, new ArrayBuffer(0), headers)
}
export function httpPost(url: string, body: ArrayBuffer, headers: Map<string, string> | null): Result {
return do_request(method_post, url, body, headers)
}
export function httpPatch(url: string, body: ArrayBuffer, headers: Map<string, string> | null): ArrayBuffer {
export function httpPut(url: string, body: ArrayBuffer, headers: Map<string, string> | null): Result {
return do_request(method_put, url, body, headers)
}
export function httpPatch(url: string, body: ArrayBuffer, headers: Map<string, string> | null): Result {
return do_request(method_patch, url, body, headers)
}
export function httpDelete(url: string, headers: Map<string, string> | null): ArrayBuffer {
export function httpDelete(url: string, headers: Map<string, string> | null): Result {
return do_request(method_delete, url, new ArrayBuffer(0), headers)
}
const method_get = 1
const method_post = 2
const method_patch = 3
const method_delete = 4
const method_get = 0
const method_head = 1
const method_options = 2
const method_post = 3
const method_put = 4
const method_patch = 5
const method_delete = 6
function do_request(method: i32, url: string, body: ArrayBuffer, headers: Map<string, string> | null): ArrayBuffer {
function do_request(method: i32, url: string, body: ArrayBuffer, headers: Map<string, string> | null): Result {
var headerString = ""

@@ -38,5 +53,3 @@ if (headers != null) {

let result = ffi_result(result_size)
return result
return ffi_result(result_size)
}

@@ -43,0 +56,0 @@

import { request_get_field } from "./env";
import { ffi_result, getIdent, toFFI } from "./ffi"
import { Result, ffi_result, getIdent, toFFI } from "./ffi"

@@ -12,3 +12,3 @@ const FIELD_TYPE_META: i32 = 0

let result = get_field(FIELD_TYPE_META, "method")
return String.UTF8.decode(result)
return result.toString()
}

@@ -18,3 +18,3 @@

let result = get_field(FIELD_TYPE_META, "url")
return String.UTF8.decode(result)
return result.toString()
}

@@ -24,6 +24,6 @@

let result = get_field(FIELD_TYPE_META, "id")
return String.UTF8.decode(result)
return result.toString()
}
export function reqBody(): ArrayBuffer {
export function reqBody(): Result {
return get_field(FIELD_TYPE_META, "body")

@@ -34,3 +34,3 @@ }

let result = get_field(FIELD_TYPE_BODY, key)
return String.UTF8.decode(result)
return result.toString()
}

@@ -40,3 +40,3 @@

let result = get_field(FIELD_TYPE_HEADER, key)
return String.UTF8.decode(result)
return result.toString()
}

@@ -47,15 +47,14 @@

let result = get_field(FIELD_TYPE_PARAMS, key)
return String.UTF8.decode(result)
return result.toString()
}
export function reqState(key: string): string {
let result = get_field(FIELD_TYPE_STATE, key)
return String.UTF8.decode(result)
export function reqState(key: string): Result {
return get_field(FIELD_TYPE_STATE, key)
}
export function reqStateRaw(key: string): ArrayBuffer {
export function reqStateRaw(key: string): Result {
return get_field(FIELD_TYPE_STATE, key)
}
function get_field(field_type: i32, key: string): ArrayBuffer {
function get_field(field_type: i32, key: string): Result {
let keyBuf = String.UTF8.encode(key)

@@ -62,0 +61,0 @@ let keyFFI = toFFI(keyBuf)

{
"name": "@suborbital/suborbital",
"version": "0.12.0",
"version": "0.13.0",
"types": "assembly/index.ts",

@@ -35,4 +35,4 @@ "description": "Suborbital's Runnable API for AssemblyScript",

"devDependencies": {
"assemblyscript": "^0.19"
"assemblyscript": "0.19.16"
}
}