Socket
Socket
Sign inDemoInstall

@dfinity/agent

Package Overview
Dependencies
Maintainers
10
Versions
121
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@dfinity/agent - npm Package Compare versions

Comparing version 0.12.1-beta.0 to 0.12.1

lib/cjs/vendor/bls/wasm.d.ts

10

lib/cjs/agent/api.d.ts

@@ -101,2 +101,8 @@ import { Principal } from '@dfinity/principal';

/**
* Create the request for the read state call.
* `readState` uses this internally.
* Useful to avoid signing the same request multiple times.
*/
createReadStateRequest?(options: ReadStateOptions, identity?: Identity): Promise<any>;
/**
* Send a read state query to the replica. This includes a list of paths to return,

@@ -107,4 +113,6 @@ * and will return a Certificate. This will only reject on communication errors,

* @param options The options for this call.
* @param identity Identity for the call. If not specified, uses the instance identity.
* @param request The request to send in case it has already been created.
*/
readState(effectiveCanisterId: Principal | string, options: ReadStateOptions): Promise<ReadStateResponse>;
readState(effectiveCanisterId: Principal | string, options: ReadStateOptions, identity?: Identity, request?: any): Promise<ReadStateResponse>;
call(canisterId: Principal | string, fields: CallOptions): Promise<SubmitResponse>;

@@ -111,0 +119,0 @@ /**

3

lib/cjs/agent/http/index.d.ts

@@ -61,3 +61,4 @@ import { JsonObject } from '@dfinity/candid';

query(canisterId: Principal | string, fields: QueryFields, identity?: Identity | Promise<Identity>): Promise<QueryResponse>;
readState(canisterId: Principal | string, fields: ReadStateOptions, identity?: Identity | Promise<Identity>): Promise<ReadStateResponse>;
createReadStateRequest(fields: ReadStateOptions, identity?: Identity | Promise<Identity>): Promise<any>;
readState(canisterId: Principal | string, fields: ReadStateOptions, identity?: Identity | Promise<Identity>, request?: any): Promise<ReadStateResponse>;
status(): Promise<JsonObject>;

@@ -64,0 +65,0 @@ fetchRootKey(): Promise<ArrayBuffer>;

@@ -257,4 +257,3 @@ "use strict";

}
async readState(canisterId, fields, identity) {
const canister = typeof canisterId === 'string' ? principal_1.Principal.fromText(canisterId) : canisterId;
async createReadStateRequest(fields, identity) {
const id = await (identity !== undefined ? await identity : await this._identity);

@@ -267,3 +266,3 @@ if (!id) {

// eslint-disable-next-line @typescript-eslint/no-explicit-any
let transformedRequest = await this._transform({
const transformedRequest = await this._transform({
request: {

@@ -282,3 +281,9 @@ method: 'POST',

// Apply transform for identity.
transformedRequest = await (id === null || id === void 0 ? void 0 : id.transformRequest(transformedRequest));
return id === null || id === void 0 ? void 0 : id.transformRequest(transformedRequest);
}
async readState(canisterId, fields, identity,
// eslint-disable-next-line
request) {
const canister = typeof canisterId === 'string' ? principal_1.Principal.fromText(canisterId) : canisterId;
const transformedRequest = request !== null && request !== void 0 ? request : (await this.createReadStateRequest(fields, identity));
const body = cbor.encode(transformedRequest.body);

@@ -285,0 +290,0 @@ const response = await this._fetch('' + new URL(`/api/v2/canister/${canister}/read_state`, this._host), Object.assign(Object.assign({}, transformedRequest.request), { body }));

@@ -15,3 +15,4 @@ import { Principal } from '@dfinity/principal';

* @param strategy A polling strategy.
* @param request Request for the readState call.
*/
export declare function pollForResponse(agent: Agent, canisterId: Principal, requestId: RequestId, strategy: PollStrategy): Promise<ArrayBuffer>;
export declare function pollForResponse(agent: Agent, canisterId: Principal, requestId: RequestId, strategy: PollStrategy, request?: any): Promise<ArrayBuffer>;

@@ -36,6 +36,11 @@ "use strict";

* @param strategy A polling strategy.
* @param request Request for the readState call.
*/
async function pollForResponse(agent, canisterId, requestId, strategy) {
async function pollForResponse(agent, canisterId, requestId, strategy,
// eslint-disable-next-line
request) {
var _a;
const path = [new TextEncoder().encode('request_status'), requestId];
const state = await agent.readState(canisterId, { paths: [path] });
const currentRequest = request !== null && request !== void 0 ? request : (await ((_a = agent.createReadStateRequest) === null || _a === void 0 ? void 0 : _a.call(agent, { paths: [path] })));
const state = await agent.readState(canisterId, { paths: [path] }, undefined, currentRequest);
if (agent.rootKey == null)

@@ -66,3 +71,3 @@ throw new Error('Agent root key not initialized before polling');

await strategy(canisterId, requestId, status);
return pollForResponse(agent, canisterId, requestId, strategy);
return pollForResponse(agent, canisterId, requestId, strategy, currentRequest);
case agent_1.RequestStatusResponseStatus.Rejected: {

@@ -69,0 +74,0 @@ const rejectCode = new Uint8Array(cert.lookup([...path, 'reject_code']))[0];

@@ -101,2 +101,8 @@ import { Principal } from '@dfinity/principal';

/**
* Create the request for the read state call.
* `readState` uses this internally.
* Useful to avoid signing the same request multiple times.
*/
createReadStateRequest?(options: ReadStateOptions, identity?: Identity): Promise<any>;
/**
* Send a read state query to the replica. This includes a list of paths to return,

@@ -107,4 +113,6 @@ * and will return a Certificate. This will only reject on communication errors,

* @param options The options for this call.
* @param identity Identity for the call. If not specified, uses the instance identity.
* @param request The request to send in case it has already been created.
*/
readState(effectiveCanisterId: Principal | string, options: ReadStateOptions): Promise<ReadStateResponse>;
readState(effectiveCanisterId: Principal | string, options: ReadStateOptions, identity?: Identity, request?: any): Promise<ReadStateResponse>;
call(canisterId: Principal | string, fields: CallOptions): Promise<SubmitResponse>;

@@ -111,0 +119,0 @@ /**

@@ -61,3 +61,4 @@ import { JsonObject } from '@dfinity/candid';

query(canisterId: Principal | string, fields: QueryFields, identity?: Identity | Promise<Identity>): Promise<QueryResponse>;
readState(canisterId: Principal | string, fields: ReadStateOptions, identity?: Identity | Promise<Identity>): Promise<ReadStateResponse>;
createReadStateRequest(fields: ReadStateOptions, identity?: Identity | Promise<Identity>): Promise<any>;
readState(canisterId: Principal | string, fields: ReadStateOptions, identity?: Identity | Promise<Identity>, request?: any): Promise<ReadStateResponse>;
status(): Promise<JsonObject>;

@@ -64,0 +65,0 @@ fetchRootKey(): Promise<ArrayBuffer>;

@@ -230,4 +230,3 @@ import { Principal } from '@dfinity/principal';

}
async readState(canisterId, fields, identity) {
const canister = typeof canisterId === 'string' ? Principal.fromText(canisterId) : canisterId;
async createReadStateRequest(fields, identity) {
const id = await (identity !== undefined ? await identity : await this._identity);

@@ -240,3 +239,3 @@ if (!id) {

// eslint-disable-next-line @typescript-eslint/no-explicit-any
let transformedRequest = await this._transform({
const transformedRequest = await this._transform({
request: {

@@ -255,3 +254,9 @@ method: 'POST',

// Apply transform for identity.
transformedRequest = await (id === null || id === void 0 ? void 0 : id.transformRequest(transformedRequest));
return id === null || id === void 0 ? void 0 : id.transformRequest(transformedRequest);
}
async readState(canisterId, fields, identity,
// eslint-disable-next-line
request) {
const canister = typeof canisterId === 'string' ? Principal.fromText(canisterId) : canisterId;
const transformedRequest = request !== null && request !== void 0 ? request : (await this.createReadStateRequest(fields, identity));
const body = cbor.encode(transformedRequest.body);

@@ -258,0 +263,0 @@ const response = await this._fetch('' + new URL(`/api/v2/canister/${canister}/read_state`, this._host), Object.assign(Object.assign({}, transformedRequest.request), { body }));

@@ -15,3 +15,4 @@ import { Principal } from '@dfinity/principal';

* @param strategy A polling strategy.
* @param request Request for the readState call.
*/
export declare function pollForResponse(agent: Agent, canisterId: Principal, requestId: RequestId, strategy: PollStrategy): Promise<ArrayBuffer>;
export declare function pollForResponse(agent: Agent, canisterId: Principal, requestId: RequestId, strategy: PollStrategy, request?: any): Promise<ArrayBuffer>;

@@ -13,6 +13,11 @@ import { RequestStatusResponseStatus } from '../agent';

* @param strategy A polling strategy.
* @param request Request for the readState call.
*/
export async function pollForResponse(agent, canisterId, requestId, strategy) {
export async function pollForResponse(agent, canisterId, requestId, strategy,
// eslint-disable-next-line
request) {
var _a;
const path = [new TextEncoder().encode('request_status'), requestId];
const state = await agent.readState(canisterId, { paths: [path] });
const currentRequest = request !== null && request !== void 0 ? request : (await ((_a = agent.createReadStateRequest) === null || _a === void 0 ? void 0 : _a.call(agent, { paths: [path] })));
const state = await agent.readState(canisterId, { paths: [path] }, undefined, currentRequest);
if (agent.rootKey == null)

@@ -43,3 +48,3 @@ throw new Error('Agent root key not initialized before polling');

await strategy(canisterId, requestId, status);
return pollForResponse(agent, canisterId, requestId, strategy);
return pollForResponse(agent, canisterId, requestId, strategy, currentRequest);
case RequestStatusResponseStatus.Rejected: {

@@ -46,0 +51,0 @@ const rejectCode = new Uint8Array(cert.lookup([...path, 'reject_code']))[0];

{
"name": "@dfinity/agent",
"version": "0.12.1-beta.0",
"version": "0.12.1",
"author": "DFINITY Stiftung <sdk@dfinity.org>",

@@ -52,4 +52,4 @@ "license": "Apache-2.0",

"peerDependencies": {
"@dfinity/candid": "^0.12.1-beta.0",
"@dfinity/principal": "^0.12.1-beta.0"
"@dfinity/candid": "^0.12.1",
"@dfinity/principal": "^0.12.1"
},

@@ -56,0 +56,0 @@ "dependencies": {

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

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

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

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

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

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 too big to display

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

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

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

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

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

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

Sorry, the diff of this file is too big to display

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