UNPKG

textiot

Version:

A framework for building web and native (IoT) Dapps on the IPFS network

188 lines (187 loc) 7.53 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; Object.defineProperty(o, k2, { enumerable: true, get: function() { return m[k]; } }); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __setModuleDefault = (this && this.__setModuleDefault) || (Object.create ? (function(o, v) { Object.defineProperty(o, "default", { enumerable: true, value: v }); }) : function(o, v) { o["default"] = v; }); var __importStar = (this && this.__importStar) || function (mod) { if (mod && mod.__esModule) return mod; var result = {}; if (mod != null) for (var k in mod) if (k !== "default" && Object.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k); __setModuleDefault(result, mod); return result; }; 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.util = exports.events = exports.threads = exports.schemas = exports.profile = exports.notifications = exports.messages = exports.logs = exports.likes = exports.ipfs = exports.invites = exports.ignores = exports.flags = exports.files = exports.feed = exports.contacts = exports.comments = exports.cafes = exports.account = exports.summary = exports.gitSummary = exports.version = exports.launch = exports.initializeCreatingNewWalletAndAccount = exports.initialize = exports.isInitialized = exports.walletAccountAt = exports.newWallet = void 0; const react_native_1 = require("react-native"); const buffer_1 = require("buffer"); const model_1 = require("./model"); const account = __importStar(require("./account")); exports.account = account; const cafes = __importStar(require("./cafes")); exports.cafes = cafes; const comments = __importStar(require("./comments")); exports.comments = comments; const contacts = __importStar(require("./contacts")); exports.contacts = contacts; const feed = __importStar(require("./feed")); exports.feed = feed; const files = __importStar(require("./files")); exports.files = files; const flags = __importStar(require("./flags")); exports.flags = flags; const ignores = __importStar(require("./ignores")); exports.ignores = ignores; const invites = __importStar(require("./invites")); exports.invites = invites; const ipfs = __importStar(require("./ipfs")); exports.ipfs = ipfs; const likes = __importStar(require("./likes")); exports.likes = likes; const logs = __importStar(require("./logs")); exports.logs = logs; const messages = __importStar(require("./messages")); exports.messages = messages; const notifications = __importStar(require("./notifications")); exports.notifications = notifications; const profile = __importStar(require("./profile")); exports.profile = profile; const schemas = __importStar(require("./schemas")); exports.schemas = schemas; const threads = __importStar(require("./threads")); exports.threads = threads; const events = __importStar(require("./events")); exports.events = events; const util = __importStar(require("./util")); exports.util = util; const { TextileBridge } = react_native_1.NativeModules; /** * Create a new Textile wallet * @param wordCount The number of words the wallet recovery phrase should contain * @returns The new wallet recovery phrase Promise */ function newWallet(wordCount) { return __awaiter(this, void 0, void 0, function* () { const phrase = yield TextileBridge.newWallet(wordCount); return phrase; }); } exports.newWallet = newWallet; /** * Resolve a wallet account * @param phrase The wallet recovery phrase * @param index The index of the account to resolve * @param password The optional wallet password * @returns The wallet account Promise */ function walletAccountAt(phrase, index, password) { return __awaiter(this, void 0, void 0, function* () { const result = yield TextileBridge.walletAccountAt(phrase, index, password); return model_1.MobileWalletAccount.decode(buffer_1.Buffer.from(result, 'base64')); }); } exports.walletAccountAt = walletAccountAt; /** * Check if Textile is already initialized * @param repoPath The path to the Textile repo * @returns A boolean Promise value indicating if Textile is initialized or not */ function isInitialized(repoPath) { return __awaiter(this, void 0, void 0, function* () { const result = yield TextileBridge.isInitialized(repoPath); return result; }); } exports.isInitialized = isInitialized; /** * Initialize the shared Textile instance with an existing account seed * @param repoPath The path to the Textile repo * @param seed The account seed * @param debug Sets the log level to debug or not * @param logToDisk Whether or not to write Textile logs to disk */ function initialize(repoPath, seed, debug, logToDisk) { return __awaiter(this, void 0, void 0, function* () { return yield TextileBridge.initialize(repoPath, seed, debug, logToDisk); }); } exports.initialize = initialize; /** * Initialize the shared Textile instance, creating a new wallet * @param repoPath The path to the Textile repo * @param debug Sets the log level to debug or not * @param logToDisk Whether or not to write Textile logs to disk * @returns The wallet recovery phrase Promise */ function initializeCreatingNewWalletAndAccount(repoPath, debug, logToDisk) { return __awaiter(this, void 0, void 0, function* () { return yield TextileBridge.initializeCreatingNewWalletAndAccount(repoPath, debug, logToDisk); }); } exports.initializeCreatingNewWalletAndAccount = initializeCreatingNewWalletAndAccount; /** * After initialization is complete, launch Textile * @param repoPath The path to the Textile repo * @param debug Sets the log level to debug or not */ function launch(repoPath, debug) { return __awaiter(this, void 0, void 0, function* () { return yield TextileBridge.launch(repoPath, debug); }); } exports.launch = launch; /** * Get the Textile node version * ```typescript * Textile.version(); * ``` */ function version() { return __awaiter(this, void 0, void 0, function* () { const result = yield TextileBridge.version(); return result; }); } exports.version = version; /** * Get the latest git summary * ```typescript * Textile.gitSummary(); * ``` */ function gitSummary() { return __awaiter(this, void 0, void 0, function* () { const result = yield TextileBridge.gitSummary(); return result; }); } exports.gitSummary = gitSummary; /** * Get the summary of node data * ```typescript * Textile.summary(); * ``` */ function summary() { return __awaiter(this, void 0, void 0, function* () { const result = yield TextileBridge.summary(); return model_1.Summary.decode(buffer_1.Buffer.from(result, 'base64')); }); } exports.summary = summary;