PHP WebShell

Текущая директория: /usr/lib/node_modules/bitgo/node_modules/ic0/lib/canister

Просмотр файла: devCanister.js

"use strict";
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
    function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
    return new (P || (P = Promise))(function (resolve, reject) {
        function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
        function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
        function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
        step((generator = generator.apply(thisArg, _arguments || [])).next());
    });
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.devCanister = exports.DevCanister = void 0;
class DevCanister {
    constructor(alias, host) {
        this.alias = alias;
        this.host = host;
    }
    call(method, ...args) {
        return __awaiter(this, void 0, void 0, function* () {
            const response = yield fetch(new URL(`/call/${this.alias}/${method}`, this.host), {
                method: 'POST',
                headers: {
                    'Content-Type': 'application/json',
                },
                body: JSON.stringify({
                    args,
                }),
            });
            if (!response.ok) {
                throw new Error(`Error while calling ${this.alias}.${method}(${args
                    .map((a) => typeof a)
                    .join(', ')}): ${(yield response.text()) ||
                    response.statusText ||
                    `status code ${response.status}`}`);
            }
            const body = yield response.json();
            return body === null || body === void 0 ? void 0 : body.value;
        });
    }
}
exports.DevCanister = DevCanister;
function devCanister(alias, host = 'http://localhost:7700') {
    return new DevCanister(alias, host);
}
exports.devCanister = devCanister;
//# sourceMappingURL=devCanister.js.map

Выполнить команду


Для локальной разработки. Не используйте в интернете!