New Case Study:See how Anthropic automated 95% of dependency reviews with Socket.Learn More
Socket
Sign inDemoInstall
Socket

ic0

Package Overview
Dependencies
Maintainers
1
Versions
19
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

ic0 - npm Package Compare versions

Comparing version 0.2.0 to 0.2.1

lib/replica.d.ts

11

lib/index.d.ts

@@ -1,11 +0,8 @@

import { HttpAgent } from '@dfinity/agent';
import { agentCanister } from './canister/agentCanister';
import { devCanister } from './canister/devCanister';
import { mockCanister } from './canister/mockCanister';
import { replica } from './replica';
import { Canister, Network, Replica } from './types';
declare type AgentReplica = Replica<ReturnType<typeof agentCanister>>;
declare const replica: (host?: string | HttpAgent | undefined) => AgentReplica;
declare const ic: AgentReplica;
declare const local: AgentReplica;
declare const defaultExport: AgentReplica;
declare const ic: import("./replica").AgentReplica;
declare const local: import("./replica").AgentReplica;
declare const defaultExport: import("./replica").AgentReplica;
export default defaultExport;

@@ -12,0 +9,0 @@ export { ic, local, replica, devCanister, mockCanister };

"use strict";
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.mockCanister = exports.devCanister = exports.replica = exports.local = exports.ic = void 0;
const agent_1 = require("@dfinity/agent");
const cross_fetch_1 = __importDefault(require("cross-fetch"));
const agentCanister_1 = require("./canister/agentCanister");
const devCanister_1 = require("./canister/devCanister");

@@ -14,40 +8,9 @@ Object.defineProperty(exports, "devCanister", { enumerable: true, get: function () { return devCanister_1.devCanister; } });

Object.defineProperty(exports, "mockCanister", { enumerable: true, get: function () { return mockCanister_1.mockCanister; } });
const replica = (host) => {
let agent;
if (!host) {
agent = new agent_1.HttpAgent({ fetch: cross_fetch_1.default });
}
else if (typeof host === 'string') {
agent = new agent_1.HttpAgent({ host, fetch: cross_fetch_1.default });
}
else if (host instanceof agent_1.HttpAgent) {
agent = host;
}
else {
throw new Error(`Invalid host (expected \`string\` or \`HttpAgent\`, received \`${typeof host}\`)`);
}
// Fetch root key for local replica
if (agent.isLocal()) {
agent.fetchRootKey().catch((err) => {
console.warn('Unable to fetch root key (check to ensure that your local replica is running)');
console.error(err);
});
}
return (id) => (0, agentCanister_1.agentCanister)(agent, id);
};
exports.replica = replica;
// Defer creating the agent for built-in replica values
const deferredReplica = (...args) => {
let deferred;
return (...replicaArgs) => {
if (!deferred) {
deferred = replica(...args);
}
return deferred(...replicaArgs);
};
};
const ic = deferredReplica('https://ic0.app');
const replica_1 = require("./replica");
Object.defineProperty(exports, "replica", { enumerable: true, get: function () { return replica_1.replica; } });
const ic = (0, replica_1.deferredReplica)('https://ic0.app');
exports.ic = ic;
const local = deferredReplica('http://localhost:4943');
const local = (0, replica_1.deferredReplica)('http://localhost:4943');
exports.local = local;
// Configure exports for TS, CommonJS, and ESM
const defaultExport = ic;

@@ -58,6 +21,6 @@ Object.assign(defaultExport, {

local,
replica,
replica: replica_1.replica,
devCanister: devCanister_1.devCanister,
mockCanister: mockCanister_1.mockCanister,
__esModule: true, // Import as ES Module
__esModule: true, // Recognize as ES Module
});

@@ -64,0 +27,0 @@ module.exports = defaultExport;

{
"name": "ic0",
"version": "0.2.0",
"version": "0.2.1",
"description": "An easy-to-use JavaScript API for the Internet Computer.",

@@ -5,0 +5,0 @@ "author": "DFINITY Foundation",

@@ -1,49 +0,10 @@

import { HttpAgent } from '@dfinity/agent';
import fetch from 'cross-fetch';
import { agentCanister } from './canister/agentCanister';
import { devCanister } from './canister/devCanister';
import { mockCanister } from './canister/mockCanister';
import { deferredReplica, replica } from './replica';
import { Canister, Network, Replica } from './types';
type AgentReplica = Replica<ReturnType<typeof agentCanister>>;
const replica = (host?: string | HttpAgent | undefined): AgentReplica => {
let agent: HttpAgent;
if (!host) {
agent = new HttpAgent({ fetch });
} else if (typeof host === 'string') {
agent = new HttpAgent({ host, fetch });
} else if (host instanceof HttpAgent) {
agent = host;
} else {
throw new Error(
`Invalid host (expected \`string\` or \`HttpAgent\`, received \`${typeof host}\`)`,
);
}
// Fetch root key for local replica
if (agent.isLocal()) {
agent.fetchRootKey().catch((err) => {
console.warn(
'Unable to fetch root key (check to ensure that your local replica is running)',
);
console.error(err);
});
}
return (id: string) => agentCanister(agent, id);
};
// Defer creating the agent for built-in replica values
const deferredReplica = (...args: Parameters<typeof replica>): AgentReplica => {
let deferred: AgentReplica | undefined;
return (...replicaArgs) => {
if (!deferred) {
deferred = replica(...args);
}
return deferred(...replicaArgs);
};
};
const ic = deferredReplica('https://ic0.app');
const local = deferredReplica('http://localhost:4943');
// Configure exports for TS, CommonJS, and ESM
const defaultExport = ic;

@@ -57,5 +18,4 @@ Object.assign(defaultExport, {

mockCanister,
__esModule: true, // Import as ES Module
__esModule: true, // Recognize as ES Module
});
module.exports = defaultExport;

@@ -62,0 +22,0 @@ export default defaultExport;

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