UNPKG

textiot

Version:

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

93 lines (92 loc) 3.03 kB
"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.ignore = exports.acceptExternal = exports.accept = exports.list = exports.addExternal = exports.add = void 0; const react_native_1 = require("react-native"); const buffer_1 = require("buffer"); const model_1 = require("./model"); const { InvitesBridge } = react_native_1.NativeModules; /** * Add a new Thread invite by invitee address. * ```typescript * Textile.invites.add(threadId, address); * ``` */ function add(threadId, address) { return __awaiter(this, void 0, void 0, function* () { return InvitesBridge.add(threadId, address); }); } exports.add = add; /** * Add an external Thread invite, returning a sharable object. * ```typescript * Textile.invites.addExternal(threadId); * ``` */ function addExternal(threadId) { return __awaiter(this, void 0, void 0, function* () { const result = yield InvitesBridge.addExternal(threadId); return model_1.ExternalInvite.decode(buffer_1.Buffer.from(result, 'base64')); }); } exports.addExternal = addExternal; /** * List all pending thread invites. * ```typescript * Textile.invites.list(); * ``` */ function list() { return __awaiter(this, void 0, void 0, function* () { const result = yield InvitesBridge.list(); return model_1.InviteViewList.decode(buffer_1.Buffer.from(result, 'base64')); }); } exports.list = list; /** * Accept invite by thread id. * ```typescript * Textile.invites.accept(threadId); * ``` */ function accept(inviteId) { return __awaiter(this, void 0, void 0, function* () { const result = yield InvitesBridge.accept(inviteId); return result; }); } exports.accept = accept; /** * Accept an external invite. * ```typescript * Textile.invites.acceptExternal(id, key); * ``` */ function acceptExternal(id_, key) { return __awaiter(this, void 0, void 0, function* () { const result = yield InvitesBridge.acceptExternal(id_, key); return result; }); } exports.acceptExternal = acceptExternal; /** * Ignore invite by thread id. * ```typescript * Textile.invites.ignore(threadId); * ``` */ function ignore(inviteId) { return __awaiter(this, void 0, void 0, function* () { return InvitesBridge.ignore(inviteId); }); } exports.ignore = ignore;