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

oasis-std

Package Overview
Dependencies
Maintainers
1
Versions
49
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

oasis-std - npm Package Compare versions

Comparing version 0.1.0-rc.27 to 0.1.0-rc.28

3

lib/src/abi.js

@@ -47,2 +47,3 @@ "use strict";

}
/* istanbul ignore next */
utils_1.unreachable(schema, `unknown schema: \`${schema}\``);

@@ -259,2 +260,3 @@ }

else {
/* istanbul ignore next */
utils_1.unreachable(schema, `unknown schema: \`${schema}\``);

@@ -387,2 +389,3 @@ }

}
/* istanbul ignore next */
utils_1.unreachable(schema, `unknown schema: \`${schema}\``);

@@ -389,0 +392,0 @@ }

15

lib/src/gateway.d.ts

@@ -9,10 +9,11 @@ import EventEmitter from 'eventemitter3';

readonly apiToken: string;
readonly headers: Map<string, string>;
private inner;
private keyStore;
private subscriptionId;
constructor(url: string, apiToken: string);
constructor(url: string, apiToken: string, headers?: Map<string, string>);
/**
* Deploy a new confidential service.
* `payload` should be the service bytecode followed by the constructor stdin.
* @returns a promise that resolves to the addreses of the newly-created service.
* @returns a promise that resolves to the address of the newly-created service.
*/

@@ -23,5 +24,12 @@ deploy(payload: Uint8Array, options?: DeployOptions): Promise<Address>;

* Calls a confidential service deployed at `address` with `payload` as stdin.
* Optional `headers` override those passed to the `Gateway` constructor.
* @returns a promise that resolves to the service stdout or rejects with an `RpcError`.
*/
rpc(address: Address, payload: Uint8Array, options?: RpcOptions): Promise<Uint8Array>;
rpc(address: Address, payload: Uint8Array, options?: RpcOptions, headers?: Map<string, string>): Promise<Uint8Array>;
/**
* Monkey-patches the headers on the inner `HttpGateway` for a single request, `req`.
* The code in `req` must be entirely synchronous to ensure that the additional headers
* are unset in time for the next request.
*/
private withHeaders;
private static convertError;

@@ -72,2 +80,3 @@ /**

private postResults;
private postError;
private hasResults;

@@ -74,0 +83,0 @@ constructor(name: string, emitter: EventEmitter, decoder: (payload: Uint8Array) => Promise<T>, gateway: Gateway);

@@ -46,7 +46,8 @@ "use strict";

class Gateway {
constructor(url, apiToken) {
constructor(url, apiToken, headers = new Map()) {
this.url = url;
this.apiToken = apiToken;
this.headers = headers;
this.subscriptionId = 0;
this.inner = new gateway_1.HttpGateway(url, apiToken, { headers: new Map() });
this.inner = new gateway_1.HttpGateway(url, apiToken, { headers });
this.keyStore = new confidential_1.KeyStore(new common_1.LocalStorage(), this.inner);

@@ -57,3 +58,3 @@ }

* `payload` should be the service bytecode followed by the constructor stdin.
* @returns a promise that resolves to the addreses of the newly-created service.
* @returns a promise that resolves to the address of the newly-created service.
*/

@@ -78,5 +79,6 @@ deploy(payload, options) {

* Calls a confidential service deployed at `address` with `payload` as stdin.
* Optional `headers` override those passed to the `Gateway` constructor.
* @returns a promise that resolves to the service stdout or rejects with an `RpcError`.
*/
rpc(address, payload, options) {
rpc(address, payload, options, headers = new Map()) {
var _a;

@@ -91,7 +93,9 @@ return __awaiter(this, void 0, void 0, function* () {

try {
const res = yield this.inner.rpc({
address: address.bytes,
data,
const res = this.withHeaders(headers, () => {
return this.inner.rpc({
address: address.bytes,
data,
});
});
return decryptToBuffer(utils_1.decodeHex(res.output));
return decryptToBuffer(utils_1.decodeHex((yield res).output));
}

@@ -103,2 +107,20 @@ catch (e) {

}
/**
* Monkey-patches the headers on the inner `HttpGateway` for a single request, `req`.
* The code in `req` must be entirely synchronous to ensure that the additional headers
* are unset in time for the next request.
*/
withHeaders(headers, req) {
const sessionHeaders = this
.inner.session.headers;
const origHeaders = sessionHeaders.headers;
const mergedHeaders = new Map(origHeaders);
for (const [k, v] of headers) {
mergedHeaders.set(k, v);
}
sessionHeaders.headers = mergedHeaders;
const res = req();
sessionHeaders.headers = origHeaders;
return res;
}
static convertError(e, decoder = (output) => __awaiter(this, void 0, void 0, function* () { return output; })) {

@@ -198,3 +220,6 @@ return __awaiter(this, void 0, void 0, function* () {

this.events = [];
this.hasResults = new Promise((resolve) => (this.postResults = resolve));
this.hasResults = new Promise((resolve, reject) => {
this.postResults = resolve;
this.postError = reject;
});
emitter

@@ -204,8 +229,9 @@ .on(name, ({ data }) => __awaiter(this, void 0, void 0, function* () {

this.postResults();
this.hasResults = new Promise((resolve) => {
this.hasResults = new Promise((resolve, reject) => {
this.postResults = resolve;
this.postError = reject;
});
}))
.on('error', (e) => {
throw e;
this.postError(e);
});

@@ -247,2 +273,3 @@ }

}
/* istanbul ignore next */
throw new Error('Subscription closed before the first event');

@@ -249,0 +276,0 @@ });

@@ -106,3 +106,2 @@ import { AbiDecodable, AbiEncodable, Encoder, Decoder } from './abi';

unwrapErr(): E;
static abiDecode(decoder: Decoder): Address;
}

@@ -109,0 +108,0 @@ export {};

@@ -39,3 +39,3 @@ "use strict";

toJSON() {
return this.hex;
return JSON.stringify(this.hex);
}

@@ -269,5 +269,2 @@ }

}
static abiDecode(decoder) {
return new Address(decoder.readU8Array(Address.LENGTH));
}
}

@@ -274,0 +271,0 @@ Result.Err = Err;

{
"name": "oasis-std",
"version": "0.1.0-rc.27",
"version": "0.1.0-rc.28",
"description": "Oasis platform standard library",

@@ -15,3 +15,3 @@ "license": "Apache-2.0",

"build": "tsc -b",
"prepublishOnly": "yarn build"
"prepublishOnly": "rm -rf lib && yarn build"
},

@@ -28,3 +28,3 @@ "dependencies": {

},
"gitHead": "ccb508a1c0f04ee5e3c0e6868177b23a11297810"
"gitHead": "31432c4e523409f16f2acc34cf305a5a18617954"
}

Sorry, the diff of this file is not supported yet

Sorry, the diff of this file is not supported yet

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