Socket
Socket
Sign inDemoInstall

@web3api/client-js

Package Overview
Dependencies
Maintainers
2
Versions
82
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@web3api/client-js - npm Package Compare versions

Comparing version 0.0.1-prealpha.70 to 0.0.1-prealpha.71

6

build/default-client-config.js

@@ -86,7 +86,7 @@ "use strict";

],
resolvers: [
uriResolvers: [
new core_js_1.RedirectsResolver(),
new core_js_1.CacheResolver(),
new core_js_1.PluginResolver(function (uri, plugin, environment) { return new PluginWeb3Api_1.PluginWeb3Api(uri, plugin, environment); }),
new core_js_1.CacheResolver(),
new core_js_1.ApiAggregatorResolver(function (uri, manifest, uriResolver, environment) {
new core_js_1.ExtendableUriResolver(function (uri, manifest, uriResolver, environment) {
return new _1.WasmWeb3Api(uri, manifest, uriResolver, environment);

@@ -93,0 +93,0 @@ }),

@@ -43,3 +43,3 @@ import { InvokeApiOptions, InvokeApiResult, Api, Web3ApiManifest, Uri, Client, GetManifestOptions, AnyManifestArtifact, ManifestArtifactType, Env, GetFileOptions } from "@web3api/core-js";

private _sanitizedEnv;
constructor(_uri: Uri, _manifest: Web3ApiManifest, _uriResolver: Uri, _clientEnv?: Env<Uri> | undefined);
constructor(_uri: Uri, _manifest: Web3ApiManifest, _uriResolver: string, _clientEnv?: Env<Uri> | undefined);
getManifest<TManifestArtifact extends ManifestArtifactType>(options: GetManifestOptions<TManifestArtifact>, client: Client): Promise<AnyManifestArtifact<TManifestArtifact>>;

@@ -46,0 +46,0 @@ getFile(options: GetFileOptions, client: Client): Promise<ArrayBuffer | string>;

@@ -186,3 +186,5 @@ "use strict";

path = options.path, encoding = options.encoding;
return [4 /*yield*/, core_js_1.UriResolver.Query.getFile(function (options) { return client.invoke(options); }, this._uriResolver, core_js_1.combinePaths(this._uri.path, path))];
return [4 /*yield*/, core_js_1.UriResolverInterface.Query.getFile(function (options) { return client.invoke(options); },
// TODO: support all types of URI resolvers (cache, etc)
new core_js_1.Uri(this._uriResolver), core_js_1.combinePaths(this._uri.path, path))];
case 1:

@@ -189,0 +191,0 @@ _a = _b.sent(), data = _a.data, error = _a.error;

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

import { Api, Client, InvokeApiOptions, InvokeApiResult, QueryApiOptions, QueryApiResult, Uri, UriRedirect, InterfaceImplementations, PluginRegistration, Env, Subscription, SubscribeOptions, AnyManifestArtifact, ManifestArtifactType, GetRedirectsOptions, GetPluginsOptions, GetInterfacesOptions, GetEnvsOptions, GetSchemaOptions, GetManifestOptions, GetFileOptions, GetImplementationsOptions, ClientConfig, ResolveUriError, UriResolutionHistory, UriToApiResolver, GetResolversOptions, ResolveUriOptions } from "@web3api/core-js";
import { Client, InvokeApiOptions, InvokeApiResult, QueryApiOptions, QueryApiResult, Uri, UriRedirect, InterfaceImplementations, PluginRegistration, Env, Subscription, SubscribeOptions, AnyManifestArtifact, ManifestArtifactType, GetRedirectsOptions, GetPluginsOptions, GetInterfacesOptions, GetEnvsOptions, GetSchemaOptions, GetManifestOptions, GetFileOptions, GetImplementationsOptions, ClientConfig, UriResolver, GetUriResolversOptions, ResolveUriOptions, ResolveUriResult } from "@web3api/core-js";
export interface Web3ApiClientConfig<TUri extends Uri | string = string> extends ClientConfig<TUri> {

@@ -17,3 +17,3 @@ tracingEnabled: boolean;

getEnvs(options?: GetEnvsOptions): readonly Env<Uri>[];
getResolvers(options?: GetResolversOptions): readonly UriToApiResolver[];
getUriResolvers(options?: GetUriResolversOptions): readonly UriResolver[];
getEnvByUri<TUri extends Uri | string>(uri: TUri, options: GetEnvsOptions): Env<Uri> | undefined;

@@ -27,7 +27,6 @@ getSchema<TUri extends Uri | string>(uri: TUri, options?: GetSchemaOptions): Promise<string>;

subscribe<TData extends Record<string, unknown> = Record<string, unknown>, TVariables extends Record<string, unknown> = Record<string, unknown>, TUri extends Uri | string = string>(options: SubscribeOptions<TVariables, TUri, Web3ApiClientConfig>): Subscription<TData>;
resolveUri<TUri extends Uri | string>(uri: TUri, options?: ResolveUriOptions<ClientConfig>): Promise<{
api?: Api;
uri?: Uri;
uriHistory: UriResolutionHistory;
error?: ResolveUriError;
resolveUri<TUri extends Uri | string>(uri: TUri, options?: ResolveUriOptions<ClientConfig>): Promise<ResolveUriResult>;
loadUriResolvers(): Promise<{
success: boolean;
failedUriResolvers: string[];
}>;

@@ -34,0 +33,0 @@ private _addDefaultConfig;

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

envs: [],
resolvers: [],
uriResolvers: [],
tracingEnabled: false,

@@ -138,3 +138,3 @@ };

: [],
resolvers: (_a = config.resolvers) !== null && _a !== void 0 ? _a : [],
uriResolvers: (_a = config.uriResolvers) !== null && _a !== void 0 ? _a : [],
tracingEnabled: !!config.tracingEnabled,

@@ -183,5 +183,5 @@ };

};
Web3ApiClient.prototype.getResolvers = function (options) {
Web3ApiClient.prototype.getUriResolvers = function (options) {
if (options === void 0) { options = {}; }
return this._getConfig(options.contextId).resolvers;
return this._getConfig(options.contextId).uriResolvers;
};

@@ -461,3 +461,3 @@ Web3ApiClient.prototype.getEnvByUri = function (uri, options) {

return __awaiter(this, void 0, void 0, function () {
var _a, contextId, shouldClearContext, ignoreCache, cacheWrite, cacheRead, client, resolvers, _b, api, resolvedUri, uriHistory, error, _c, _d, item;
var _a, contextId, shouldClearContext, ignoreCache, cacheWrite, cacheRead, client, uriResolvers, _b, api, resolvedUri, uriHistory, error, _c, _d, item;
var e_3, _e;

@@ -473,7 +473,7 @@ return __generator(this, function (_f) {

client = contextualizeClient(this, contextId);
resolvers = this.getResolvers({ contextId: contextId });
uriResolvers = this.getUriResolvers({ contextId: contextId });
if (!cacheRead) {
resolvers = resolvers.filter(function (x) { return x.name !== core_js_1.CacheResolver.name; });
uriResolvers = uriResolvers.filter(function (x) { return x.name !== core_js_1.CacheResolver.name; });
}
return [4 /*yield*/, core_js_1.resolveUri(this._toUri(uri), resolvers, client, this._apiCache)];
return [4 /*yield*/, core_js_1.resolveUri(this._toUri(uri), uriResolvers, client, this._apiCache)];
case 1:

@@ -510,2 +510,18 @@ _b = _f.sent(), api = _b.api, resolvedUri = _b.uri, uriHistory = _b.uriHistory, error = _b.error;

};
Web3ApiClient.prototype.loadUriResolvers = function () {
return __awaiter(this, void 0, void 0, function () {
var extendableUriResolver, uriResolverImpls;
return __generator(this, function (_a) {
extendableUriResolver = this.getUriResolvers().find(function (x) { return x.name === core_js_1.ExtendableUriResolver.name; });
if (!extendableUriResolver) {
return [2 /*return*/, {
success: true,
failedUriResolvers: [],
}];
}
uriResolverImpls = core_js_1.getImplementations(core_js_1.coreInterfaceUris.uriResolver, this.getInterfaces(), this.getRedirects());
return [2 /*return*/, extendableUriResolver.loadUriResolverWrappers(this, this._apiCache, uriResolverImpls)];
});
});
};
Web3ApiClient.prototype._addDefaultConfig = function () {

@@ -523,4 +539,4 @@ var _a, _b, _c, _d;

}
if (defaultClientConfig.resolvers) {
(_d = this._config.resolvers).push.apply(_d, __spread(defaultClientConfig.resolvers));
if (defaultClientConfig.uriResolvers) {
(_d = this._config.uriResolvers).push.apply(_d, __spread(defaultClientConfig.uriResolvers));
}

@@ -646,3 +662,3 @@ };

envs: (context === null || context === void 0 ? void 0 : context.envs) ? core_js_1.sanitizeEnvs(context.envs) : config.envs,
resolvers: (_a = context === null || context === void 0 ? void 0 : context.resolvers) !== null && _a !== void 0 ? _a : config.resolvers,
uriResolvers: (_a = context === null || context === void 0 ? void 0 : context.uriResolvers) !== null && _a !== void 0 ? _a : config.uriResolvers,
tracingEnabled: (context === null || context === void 0 ? void 0 : context.tracingEnabled) || config.tracingEnabled,

@@ -661,6 +677,7 @@ });

Web3ApiClient.prototype._loadWeb3Api = function (uri, options) {
var _a, _b;
return __awaiter(this, void 0, void 0, function () {
var _a, api, uriHistory, error;
return __generator(this, function (_b) {
switch (_b.label) {
var _c, api, uriHistory, error, errorMessage;
return __generator(this, function (_d) {
switch (_d.label) {
case 0: return [4 /*yield*/, this.resolveUri(uri, {

@@ -670,9 +687,21 @@ contextId: options === null || options === void 0 ? void 0 : options.contextId,

case 1:
_a = _b.sent(), api = _a.api, uriHistory = _a.uriHistory, error = _a.error;
_c = _d.sent(), api = _c.api, uriHistory = _c.uriHistory, error = _c.error;
if (!api) {
if (error && error === core_js_1.ResolveUriError.InfiniteLoop) {
throw Error("Infinite loop while resolving URI \"" + uri + "\".\nResolution Stack: " + JSON.stringify(uriHistory, null, 2));
if (error) {
errorMessage = (_b = (_a = error.error) === null || _a === void 0 ? void 0 : _a.message) !== null && _b !== void 0 ? _b : "";
switch (error.type) {
case core_js_1.ResolveUriErrorType.InfiniteLoop:
throw Error("Infinite loop while resolving URI \"" + uri + "\".\nResolution Stack: " + JSON.stringify(uriHistory, null, 2));
break;
case core_js_1.ResolveUriErrorType.InternalResolver:
throw Error("URI resolution error while resolving URI \"" + uri + "\".\n" + errorMessage + "\nResolution Stack: " + JSON.stringify(uriHistory, null, 2));
break;
default:
throw Error("Unsupported URI resolution error type occurred");
break;
}
}
throw Error("No Web3API found at URI: " + uri.uri +
("\nResolution history: " + JSON.stringify(uriHistory, null, 2)));
else {
throw Error("Uknown URI resolution error while resolving URI \"" + uri + "\"\nResolution Stack: " + JSON.stringify(uriHistory, null, 2));
}
}

@@ -697,4 +726,4 @@ return [2 /*return*/, api];

__decorate([
tracing_js_1.Tracer.traceMethod("Web3ApiClient: getResolvers")
], Web3ApiClient.prototype, "getResolvers", null);
tracing_js_1.Tracer.traceMethod("Web3ApiClient: getUriResolvers")
], Web3ApiClient.prototype, "getUriResolvers", null);
__decorate([

@@ -728,2 +757,5 @@ tracing_js_1.Tracer.traceMethod("Web3ApiClient: getEnvByUri")

__decorate([
tracing_js_1.Tracer.traceMethod("Web3ApiClient: loadUriResolverWrappers")
], Web3ApiClient.prototype, "loadUriResolvers", null);
__decorate([
tracing_js_1.Tracer.traceMethod("Web3ApiClient: isContextualized")

@@ -786,5 +818,5 @@ ], Web3ApiClient.prototype, "_isContextualized", null);

},
getResolvers: function (options) {
getUriResolvers: function (options) {
if (options === void 0) { options = {}; }
return client.getResolvers(__assign(__assign({}, options), { contextId: contextId }));
return client.getUriResolvers(__assign(__assign({}, options), { contextId: contextId }));
},

@@ -812,2 +844,5 @@ getEnvByUri: function (uri, options) {

},
loadUriResolvers: function () {
return client.loadUriResolvers();
},
}

@@ -814,0 +849,0 @@ : client;

{
"name": "@web3api/client-js",
"description": "Web3API Javascript Client",
"version": "0.0.1-prealpha.70",
"version": "0.0.1-prealpha.71",
"license": "MIT",

@@ -23,15 +23,15 @@ "repository": {

"dependencies": {
"@web3api/asyncify-js": "0.0.1-prealpha.70",
"@web3api/core-js": "0.0.1-prealpha.70",
"@web3api/ens-plugin-js": "0.0.1-prealpha.70",
"@web3api/ethereum-plugin-js": "0.0.1-prealpha.70",
"@web3api/fs-plugin-js": "0.0.1-prealpha.70",
"@web3api/graph-node-plugin-js": "0.0.1-prealpha.70",
"@web3api/http-plugin-js": "0.0.1-prealpha.70",
"@web3api/ipfs-plugin-js": "0.0.1-prealpha.70",
"@web3api/logger-plugin-js": "0.0.1-prealpha.70",
"@web3api/schema-parse": "0.0.1-prealpha.70",
"@web3api/sha3-plugin-js": "0.0.1-prealpha.70",
"@web3api/tracing-js": "0.0.1-prealpha.70",
"@web3api/uts46-plugin-js": "0.0.1-prealpha.70",
"@web3api/asyncify-js": "0.0.1-prealpha.71",
"@web3api/core-js": "0.0.1-prealpha.71",
"@web3api/ens-plugin-js": "0.0.1-prealpha.71",
"@web3api/ethereum-plugin-js": "0.0.1-prealpha.71",
"@web3api/fs-plugin-js": "0.0.1-prealpha.71",
"@web3api/graph-node-plugin-js": "0.0.1-prealpha.71",
"@web3api/http-plugin-js": "0.0.1-prealpha.71",
"@web3api/ipfs-plugin-js": "0.0.1-prealpha.71",
"@web3api/logger-plugin-js": "0.0.1-prealpha.71",
"@web3api/schema-parse": "0.0.1-prealpha.71",
"@web3api/sha3-plugin-js": "0.0.1-prealpha.71",
"@web3api/tracing-js": "0.0.1-prealpha.71",
"@web3api/uts46-plugin-js": "0.0.1-prealpha.71",
"graphql": "15.5.0",

@@ -45,6 +45,6 @@ "js-yaml": "3.14.0",

"@types/uuid": "8.3.0",
"@web3api/cli": "0.0.1-prealpha.70",
"@web3api/os-js": "0.0.1-prealpha.70",
"@web3api/test-cases": "0.0.1-prealpha.70",
"@web3api/test-env-js": "0.0.1-prealpha.70",
"@web3api/cli": "0.0.1-prealpha.71",
"@web3api/os-js": "0.0.1-prealpha.71",
"@web3api/test-cases": "0.0.1-prealpha.71",
"@web3api/test-env-js": "0.0.1-prealpha.71",
"jest": "26.6.3",

@@ -58,3 +58,3 @@ "rimraf": "3.0.2",

},
"gitHead": "b215f4c1e4f79e385d78a9b0383fb78ed2000019",
"gitHead": "daa694fd5d7e77c907307c38a40ca388ab23b5cc",
"publishConfig": {

@@ -61,0 +61,0 @@ "access": "public"

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