@dfinity/agent
Advanced tools
Comparing version 0.14.1 to 0.15.0
@@ -24,2 +24,4 @@ import { JsonObject } from '@dfinity/candid'; | ||
fetch?: typeof fetch; | ||
fetchOptions?: Record<string, unknown>; | ||
callOptions?: Record<string, unknown>; | ||
host?: string; | ||
@@ -55,2 +57,4 @@ identity?: Identity | Promise<Identity>; | ||
private readonly _fetch; | ||
private readonly _fetchOptions?; | ||
private readonly _callOptions?; | ||
private _timeDiffMsecs; | ||
@@ -57,0 +61,0 @@ private readonly _host; |
@@ -132,2 +132,4 @@ "use strict"; | ||
this._fetch = options.fetch || getDefaultFetch() || fetch.bind(global); | ||
this._fetchOptions = options.fetchOptions; | ||
this._callOptions = options.callOptions; | ||
} | ||
@@ -224,3 +226,3 @@ if (options.host !== undefined) { | ||
// calculate the requestId locally. | ||
const request = this._requestAndRetry(() => this._fetch('' + new URL(`/api/v2/canister/${ecid.toText()}/call`, this._host), Object.assign(Object.assign({}, transformedRequest.request), { body }))); | ||
const request = this._requestAndRetry(() => this._fetch('' + new URL(`/api/v2/canister/${ecid.toText()}/call`, this._host), Object.assign(Object.assign(Object.assign({}, this._callOptions), transformedRequest.request), { body }))); | ||
const [response, requestId] = await Promise.all([request, (0, request_id_1.requestIdOf)(submit)]); | ||
@@ -284,3 +286,3 @@ return { | ||
const body = cbor.encode(transformedRequest.body); | ||
const response = await this._requestAndRetry(() => this._fetch('' + new URL(`/api/v2/canister/${canister.toText()}/query`, this._host), Object.assign(Object.assign({}, transformedRequest.request), { body }))); | ||
const response = await this._requestAndRetry(() => this._fetch('' + new URL(`/api/v2/canister/${canister.toText()}/query`, this._host), Object.assign(Object.assign(Object.assign({}, this._fetchOptions), transformedRequest.request), { body }))); | ||
return cbor.decode(await response.arrayBuffer()); | ||
@@ -318,3 +320,3 @@ } | ||
const body = cbor.encode(transformedRequest.body); | ||
const response = await this._fetch('' + new URL(`/api/v2/canister/${canister}/read_state`, this._host), Object.assign(Object.assign({}, transformedRequest.request), { body })); | ||
const response = await this._fetch('' + new URL(`/api/v2/canister/${canister}/read_state`, this._host), Object.assign(Object.assign(Object.assign({}, this._fetchOptions), transformedRequest.request), { body })); | ||
if (!response.ok) { | ||
@@ -359,3 +361,3 @@ throw new Error(`Server returned an error:\n` + | ||
: {}; | ||
const response = await this._requestAndRetry(() => this._fetch('' + new URL(`/api/v2/status`, this._host), { headers })); | ||
const response = await this._requestAndRetry(() => this._fetch('' + new URL(`/api/v2/status`, this._host), Object.assign({ headers }, this._fetchOptions))); | ||
return cbor.decode(await response.arrayBuffer()); | ||
@@ -362,0 +364,0 @@ } |
@@ -84,5 +84,5 @@ import { Principal } from '@dfinity/principal'; | ||
/** | ||
* Create an IdentityDescriptor from a @dfinity/authentication Identity | ||
* Create an IdentityDescriptor from a @dfinity/identity Identity | ||
* @param identity - identity describe in returned descriptor | ||
*/ | ||
export declare function createIdentityDescriptor(identity: SignIdentity | AnonymousIdentity): IdentityDescriptor; |
@@ -60,3 +60,3 @@ "use strict"; | ||
/** | ||
* Create an IdentityDescriptor from a @dfinity/authentication Identity | ||
* Create an IdentityDescriptor from a @dfinity/identity Identity | ||
* @param identity - identity describe in returned descriptor | ||
@@ -63,0 +63,0 @@ */ |
@@ -18,3 +18,3 @@ import { ActorSubclass } from './actor'; | ||
* | ||
* You can request a canisters Controllers, ModuleHash, Candid interface, Subnet, or Time, or provide a custom path {@link CanisterStatus.CustomPath} and pass arbitrary buffers for valid paths identified in https://smartcontracts.org/docs/current/references/ic-interface-spec/. | ||
* You can request a canisters Controllers, ModuleHash, Candid interface, Subnet, or Time, or provide a custom path {@link CanisterStatus.CustomPath} and pass arbitrary buffers for valid paths identified in https://internetcomputer.org/docs/current/references/ic-interface-spec. | ||
* | ||
@@ -21,0 +21,0 @@ * The primary method for this namespace is {@link CanisterStatus.request} |
@@ -46,3 +46,3 @@ "use strict"; | ||
* | ||
* You can request a canisters Controllers, ModuleHash, Candid interface, Subnet, or Time, or provide a custom path {@link CanisterStatus.CustomPath} and pass arbitrary buffers for valid paths identified in https://smartcontracts.org/docs/current/references/ic-interface-spec/. | ||
* You can request a canisters Controllers, ModuleHash, Candid interface, Subnet, or Time, or provide a custom path {@link CanisterStatus.CustomPath} and pass arbitrary buffers for valid paths identified in https://internetcomputer.org/docs/current/references/ic-interface-spec. | ||
* | ||
@@ -49,0 +49,0 @@ * The primary method for this namespace is {@link CanisterStatus.request} |
@@ -24,2 +24,4 @@ import { JsonObject } from '@dfinity/candid'; | ||
fetch?: typeof fetch; | ||
fetchOptions?: Record<string, unknown>; | ||
callOptions?: Record<string, unknown>; | ||
host?: string; | ||
@@ -55,2 +57,4 @@ identity?: Identity | Promise<Identity>; | ||
private readonly _fetch; | ||
private readonly _fetchOptions?; | ||
private readonly _callOptions?; | ||
private _timeDiffMsecs; | ||
@@ -57,0 +61,0 @@ private readonly _host; |
@@ -101,2 +101,4 @@ import { Principal } from '@dfinity/principal'; | ||
this._fetch = options.fetch || getDefaultFetch() || fetch.bind(global); | ||
this._fetchOptions = options.fetchOptions; | ||
this._callOptions = options.callOptions; | ||
} | ||
@@ -193,3 +195,3 @@ if (options.host !== undefined) { | ||
// calculate the requestId locally. | ||
const request = this._requestAndRetry(() => this._fetch('' + new URL(`/api/v2/canister/${ecid.toText()}/call`, this._host), Object.assign(Object.assign({}, transformedRequest.request), { body }))); | ||
const request = this._requestAndRetry(() => this._fetch('' + new URL(`/api/v2/canister/${ecid.toText()}/call`, this._host), Object.assign(Object.assign(Object.assign({}, this._callOptions), transformedRequest.request), { body }))); | ||
const [response, requestId] = await Promise.all([request, requestIdOf(submit)]); | ||
@@ -253,3 +255,3 @@ return { | ||
const body = cbor.encode(transformedRequest.body); | ||
const response = await this._requestAndRetry(() => this._fetch('' + new URL(`/api/v2/canister/${canister.toText()}/query`, this._host), Object.assign(Object.assign({}, transformedRequest.request), { body }))); | ||
const response = await this._requestAndRetry(() => this._fetch('' + new URL(`/api/v2/canister/${canister.toText()}/query`, this._host), Object.assign(Object.assign(Object.assign({}, this._fetchOptions), transformedRequest.request), { body }))); | ||
return cbor.decode(await response.arrayBuffer()); | ||
@@ -287,3 +289,3 @@ } | ||
const body = cbor.encode(transformedRequest.body); | ||
const response = await this._fetch('' + new URL(`/api/v2/canister/${canister}/read_state`, this._host), Object.assign(Object.assign({}, transformedRequest.request), { body })); | ||
const response = await this._fetch('' + new URL(`/api/v2/canister/${canister}/read_state`, this._host), Object.assign(Object.assign(Object.assign({}, this._fetchOptions), transformedRequest.request), { body })); | ||
if (!response.ok) { | ||
@@ -328,3 +330,3 @@ throw new Error(`Server returned an error:\n` + | ||
: {}; | ||
const response = await this._requestAndRetry(() => this._fetch('' + new URL(`/api/v2/status`, this._host), { headers })); | ||
const response = await this._requestAndRetry(() => this._fetch('' + new URL(`/api/v2/status`, this._host), Object.assign({ headers }, this._fetchOptions))); | ||
return cbor.decode(await response.arrayBuffer()); | ||
@@ -331,0 +333,0 @@ } |
@@ -84,5 +84,5 @@ import { Principal } from '@dfinity/principal'; | ||
/** | ||
* Create an IdentityDescriptor from a @dfinity/authentication Identity | ||
* Create an IdentityDescriptor from a @dfinity/identity Identity | ||
* @param identity - identity describe in returned descriptor | ||
*/ | ||
export declare function createIdentityDescriptor(identity: SignIdentity | AnonymousIdentity): IdentityDescriptor; |
@@ -55,3 +55,3 @@ var __rest = (this && this.__rest) || function (s, e) { | ||
/** | ||
* Create an IdentityDescriptor from a @dfinity/authentication Identity | ||
* Create an IdentityDescriptor from a @dfinity/identity Identity | ||
* @param identity - identity describe in returned descriptor | ||
@@ -58,0 +58,0 @@ */ |
@@ -18,3 +18,3 @@ import { ActorSubclass } from './actor'; | ||
* | ||
* You can request a canisters Controllers, ModuleHash, Candid interface, Subnet, or Time, or provide a custom path {@link CanisterStatus.CustomPath} and pass arbitrary buffers for valid paths identified in https://smartcontracts.org/docs/current/references/ic-interface-spec/. | ||
* You can request a canisters Controllers, ModuleHash, Candid interface, Subnet, or Time, or provide a custom path {@link CanisterStatus.CustomPath} and pass arbitrary buffers for valid paths identified in https://internetcomputer.org/docs/current/references/ic-interface-spec. | ||
* | ||
@@ -21,0 +21,0 @@ * The primary method for this namespace is {@link CanisterStatus.request} |
@@ -17,3 +17,3 @@ export * from './actor'; | ||
* | ||
* You can request a canisters Controllers, ModuleHash, Candid interface, Subnet, or Time, or provide a custom path {@link CanisterStatus.CustomPath} and pass arbitrary buffers for valid paths identified in https://smartcontracts.org/docs/current/references/ic-interface-spec/. | ||
* You can request a canisters Controllers, ModuleHash, Candid interface, Subnet, or Time, or provide a custom path {@link CanisterStatus.CustomPath} and pass arbitrary buffers for valid paths identified in https://internetcomputer.org/docs/current/references/ic-interface-spec. | ||
* | ||
@@ -20,0 +20,0 @@ * The primary method for this namespace is {@link CanisterStatus.request} |
{ | ||
"name": "@dfinity/agent", | ||
"version": "0.14.1", | ||
"version": "0.15.0", | ||
"author": "DFINITY Stiftung <sdk@dfinity.org>", | ||
"license": "Apache-2.0", | ||
"description": "JavaScript and TypeScript library to interact with the Internet Computer", | ||
"homepage": "https://smartcontracts.org", | ||
"homepage": "https://internetcomputer.org", | ||
"repository": { | ||
@@ -41,3 +41,3 @@ "type": "git", | ||
"build:watch": "tsc -b --watch", | ||
"bundle": "npm run build", | ||
"bundle": "esbuild --bundle src/index.ts --outfile=dist/index.js", | ||
"eslint:fix": "npm run lint -- --fix", | ||
@@ -54,4 +54,4 @@ "eslint": "eslint --ext '.js,.jsx,.ts,.tsx' src/index.ts src/auth.ts src/request_id.ts src/request_id.test.ts", | ||
"peerDependencies": { | ||
"@dfinity/candid": "^0.14.1", | ||
"@dfinity/principal": "^0.14.1" | ||
"@dfinity/candid": "^0.15.0", | ||
"@dfinity/principal": "^0.15.0" | ||
}, | ||
@@ -71,2 +71,3 @@ "dependencies": { | ||
"@typescript-eslint/parser": "^5.30.5", | ||
"esbuild": "^0.15.16", | ||
"eslint": "^8.19.0", | ||
@@ -76,2 +77,3 @@ "eslint-plugin-jsdoc": "^39.3.3", | ||
"jest": "^28.1.2", | ||
"size-limit": "^8.1.0", | ||
"text-encoding": "^0.7.0", | ||
@@ -83,3 +85,10 @@ "ts-jest": "^28.0.5", | ||
"whatwg-fetch": "^3.0.0" | ||
} | ||
}, | ||
"size-limit": [ | ||
{ | ||
"path": "./dist/index.js", | ||
"limit": "100 kB", | ||
"webpack": false | ||
} | ||
] | ||
} |
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
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
1038154
7617
16