UNPKG

@eotl/core

Version:

Assortment of data structures, Vue.js components, and utilities across EOTL apps and sites.

356 lines (355 loc) 14.6 kB
"use strict"; const _commonjsHelpers = require("./_commonjsHelpers-Bc2YnDe1.cjs"); const simpleSignedRecords = require("@eotl/simple-signed-records"); const store = require("./store.cjs"); const authSsr = require("./authSsr-Aa_pi4mF.cjs"); const vue = require("vue"); const _pluginVue_exportHelper = require("./_plugin-vue_export-helper-DM9IkUGy.cjs"); var naclUtil = { exports: {} }; (function(module2) { (function(root, f) { if (module2.exports) module2.exports = f(); else if (root.nacl) root.nacl.util = f(); else { root.nacl = {}; root.nacl.util = f(); } })(_commonjsHelpers.commonjsGlobal, function() { var util = {}; function validateBase64(s) { if (!/^(?:[A-Za-z0-9+\/]{2}[A-Za-z0-9+\/]{2})*(?:[A-Za-z0-9+\/]{2}==|[A-Za-z0-9+\/]{3}=)?$/.test(s)) { throw new TypeError("invalid encoding"); } } util.decodeUTF8 = function(s) { if (typeof s !== "string") throw new TypeError("expected string"); var i, d = unescape(encodeURIComponent(s)), b = new Uint8Array(d.length); for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i); return b; }; util.encodeUTF8 = function(arr) { var i, s = []; for (i = 0; i < arr.length; i++) s.push(String.fromCharCode(arr[i])); return decodeURIComponent(escape(s.join(""))); }; if (typeof atob === "undefined") { if (typeof Buffer.from !== "undefined") { util.encodeBase64 = function(arr) { return Buffer.from(arr).toString("base64"); }; util.decodeBase64 = function(s) { validateBase64(s); return new Uint8Array(Array.prototype.slice.call(Buffer.from(s, "base64"), 0)); }; } else { util.encodeBase64 = function(arr) { return new Buffer(arr).toString("base64"); }; util.decodeBase64 = function(s) { validateBase64(s); return new Uint8Array(Array.prototype.slice.call(new Buffer(s, "base64"), 0)); }; } } else { util.encodeBase64 = function(arr) { var i, s = [], len = arr.length; for (i = 0; i < len; i++) s.push(String.fromCharCode(arr[i])); return btoa(s.join("")); }; util.decodeBase64 = function(s) { validateBase64(s); var i, d = atob(s), b = new Uint8Array(d.length); for (i = 0; i < d.length; i++) b[i] = d.charCodeAt(i); return b; }; } return util; }); })(naclUtil); var naclUtilExports = naclUtil.exports; const _sfc_main = { components: {}, data: function() { const store$1 = store.useEotlCore(); const authSsr$1 = authSsr.useAuthSsr(); return { store: store$1, authSsr: authSsr$1, details: { emails: "", name: "", language: "" }, showRecoveryWords: false, showActualKeys: false, loading: true }; }, created() { this.getAccount(); }, methods: { getAccount() { const identity = this.authSsr.identity.publicKey; let vm = this; simpleSignedRecords.ssrFetcher.Get("keys/" + identity).then((data) => { vm.invites = data; }); }, btnDetailsUpdate() { console.log("btnDetailsUpdate"); let publicKey = naclUtilExports.decodeBase64(this.authSsr.identity.publicKey); let record = { identity: publicKey, info: { email: "yolo@joker.com" } }; simpleSignedRecords.ssrFetcher.Post("keys", record).then((data) => { console.log(data); }); }, btnShowRecoveryWords() { this.showRecoveryWords = true; }, btnShowActualKeys() { this.showActualKeys = true; } } }; const _hoisted_1 = /* @__PURE__ */ vue.createElementVNode("h2", null, "Account", -1); const _hoisted_2 = /* @__PURE__ */ vue.createElementVNode("hr", { class: "thick mb-5" }, null, -1); const _hoisted_3 = { class: "row mb-5" }; const _hoisted_4 = /* @__PURE__ */ vue.createElementVNode("div", { class: "col-3" }, [ /* @__PURE__ */ vue.createElementVNode("div", { class: "nav flex-column nav-pills", id: "v-pills-tab", role: "tablist", "aria-orientation": "vertical" }, [ /* @__PURE__ */ vue.createElementVNode("a", { class: "nav-link active", id: "v-pills-home-tab", "data-toggle": "pill", href: "#v-pills-home", role: "tab", "aria-controls": "v-pills-home", "aria-selected": "true" }, " Identity "), /* @__PURE__ */ vue.createElementVNode("a", { class: "nav-link", id: "v-pills-details-tab", "data-toggle": "pill", href: "#v-pills-details", role: "tab", "aria-controls": "v-pills-details", "aria-selected": "true" }, " Details "), /* @__PURE__ */ vue.createElementVNode("a", { class: "nav-link", id: "v-pills-notifications-tab", "data-toggle": "pill", href: "#v-pills-notifications", role: "tab", "aria-controls": "v-pills-notifications", "aria-selected": "true" }, " Notifications "), /* @__PURE__ */ vue.createElementVNode("a", { class: "nav-link", id: "v-pills-key-tab", "data-toggle": "pill", href: "#v-pills-key", role: "tab", "aria-controls": "v-pills-key", "aria-selected": "true" }, " Account Key ") ]) ], -1); const _hoisted_5 = { class: "col-9" }; const _hoisted_6 = { class: "tab-content border-top", id: "v-pills-tabContent" }; const _hoisted_7 = { class: "tab-pane show active", id: "v-pills-home", role: "tabpanel", "aria-labelledby": "v-pills-home-tab" }; const _hoisted_8 = /* @__PURE__ */ vue.createElementVNode("h3", null, "Identity", -1); const _hoisted_9 = /* @__PURE__ */ vue.createElementVNode("p", null, "To connect with others in the network and build a reputation share your identity key.", -1); const _hoisted_10 = { class: "tab-pane", id: "v-pills-details", role: "tabpanel", "aria-labelledby": "v-pills-details-tab" }; const _hoisted_11 = /* @__PURE__ */ vue.createElementVNode("h3", null, "Details", -1); const _hoisted_12 = { class: "form-group" }; const _hoisted_13 = /* @__PURE__ */ vue.createElementVNode("label", null, "Name", -1); const _hoisted_14 = { class: "form-group" }; const _hoisted_15 = /* @__PURE__ */ vue.createElementVNode("label", null, "You are", -1); const _hoisted_16 = ["value"]; const _hoisted_17 = { class: "form-group" }; const _hoisted_18 = /* @__PURE__ */ vue.createElementVNode("label", null, "Language", -1); const _hoisted_19 = ["value"]; const _hoisted_20 = { class: "form-group" }; const _hoisted_21 = /* @__PURE__ */ vue.createElementVNode("div", { class: "tab-pane", id: "v-pills-notifications", role: "tabpanel", "aria-labelledby": "v-pills-notifications-tab" }, [ /* @__PURE__ */ vue.createElementVNode("h3", null, "Notifications"), /* @__PURE__ */ vue.createElementVNode("p", null, "Add an email, SMS, or messenger account to receive notifications about shipments.") ], -1); const _hoisted_22 = { class: "tab-pane", id: "v-pills-key", role: "tabpanel", "aria-labelledby": "v-pills-key-tab" }; const _hoisted_23 = /* @__PURE__ */ vue.createElementVNode("h3", null, "Account Key", -1); const _hoisted_24 = /* @__PURE__ */ vue.createElementVNode("p", null, "Your recovery words are used to restore your account on another device, a new computer, or if you lose data on this device.", -1); const _hoisted_25 = { key: 0 }; const _hoisted_26 = /* @__PURE__ */ vue.createElementVNode("label", { class: "text-danger" }, "DO NOT SHARE!!!", -1); const _hoisted_27 = { class: "mb-5" }; const _hoisted_28 = { key: 1, class: "mt-3 form-group" }; const _hoisted_29 = /* @__PURE__ */ vue.createElementVNode("label", { class: "text-danger" }, "DO NOT SHARE!!!", -1); const _hoisted_30 = { class: "mb-5" }; function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) { return vue.openBlock(), vue.createElementBlock("main", null, [ _hoisted_1, _hoisted_2, vue.createElementVNode("div", _hoisted_3, [ _hoisted_4, vue.createElementVNode("div", _hoisted_5, [ vue.createElementVNode("div", _hoisted_6, [ vue.createElementVNode("div", _hoisted_7, [ _hoisted_8, _hoisted_9, vue.createElementVNode("label", null, vue.toDisplayString(_ctx.$t("account.yourIdentityKey")), 1), vue.withDirectives(vue.createElementVNode("input", { class: "mb-4 bg-light form-control", "onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.authSsr.identity.publicKey = $event), readonly: "" }, null, 512), [ [vue.vModelText, _ctx.authSsr.identity.publicKey] ]) ]), vue.createElementVNode("div", _hoisted_10, [ _hoisted_11, vue.createElementVNode("div", _hoisted_12, [ _hoisted_13, vue.withDirectives(vue.createElementVNode("input", { type: "text", "onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _ctx.authSsr.account.name = $event), class: "form-control", placeholder: "David Buckle" }, null, 512), [ [vue.vModelText, _ctx.authSsr.account.name] ]) ]), vue.createElementVNode("div", _hoisted_14, [ _hoisted_15, vue.withDirectives(vue.createElementVNode("select", { "onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => _ctx.authSsr.account.type = $event), class: "form-control" }, [ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.store.config.account_types, (type) => { return vue.openBlock(), vue.createElementBlock("option", { key: type, value: type }, vue.toDisplayString(_ctx.$t("accountTypes." + type)), 9, _hoisted_16); }), 128)) ], 512), [ [vue.vModelSelect, _ctx.authSsr.account.type] ]) ]), vue.createElementVNode("div", _hoisted_17, [ _hoisted_18, vue.withDirectives(vue.createElementVNode("select", { "onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => _ctx.authSsr.account.language = $event), class: "form-control" }, [ (vue.openBlock(true), vue.createElementBlock(vue.Fragment, null, vue.renderList(_ctx.store.config.languages, (language) => { return vue.openBlock(), vue.createElementBlock("option", { key: language, value: language }, vue.toDisplayString(language), 9, _hoisted_19); }), 128)) ], 512), [ [vue.vModelSelect, _ctx.authSsr.account.language] ]) ]), vue.createElementVNode("div", _hoisted_20, [ vue.createElementVNode("button", { onClick: _cache[4] || (_cache[4] = (...args) => $options.btnDetailsUpdate && $options.btnDetailsUpdate(...args)), class: "btn btn-primary btn-block" }, " Update Details ") ]) ]), _hoisted_21, vue.createElementVNode("div", _hoisted_22, [ _hoisted_23, vue.createElementVNode("p", null, [ vue.createElementVNode("em", null, vue.toDisplayString(_ctx.store.config.name), 1), vue.createTextVNode(" is different from most websites or apps as there is no username and password, instead it uses cryptographic keys to secure your account. ") ]), vue.createElementVNode("h5", null, vue.toDisplayString(_ctx.$t("account.recoveryWords")), 1), _hoisted_24, _ctx.showRecoveryWords ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_25, [ _hoisted_26, vue.withDirectives(vue.createElementVNode("textarea", { rows: "3", class: "passphrase text-monospace bg-light mb-4 form-control", "onUpdate:modelValue": _cache[5] || (_cache[5] = ($event) => _ctx.authSsr.identity.words = $event), readonly: "" }, "\n ", 512), [ [vue.vModelText, _ctx.authSsr.identity.words] ]) ])) : vue.createCommentVNode("", true), vue.createElementVNode("div", _hoisted_27, [ vue.createElementVNode("button", { type: "button", onClick: _cache[6] || (_cache[6] = (...args) => $options.btnShowRecoveryWords && $options.btnShowRecoveryWords(...args)), class: "btn btn-secondary" }, vue.toDisplayString(_ctx.$t("account.btnShowRecoveryWords")), 1) ]), vue.createElementVNode("h5", null, vue.toDisplayString(_ctx.$t("account.yourAccountKey")), 1), vue.createElementVNode("p", null, vue.toDisplayString(_ctx.$t("account.textAccountKey")), 1), _ctx.showActualKeys ? (vue.openBlock(), vue.createElementBlock("div", _hoisted_28, [ _hoisted_29, vue.withDirectives(vue.createElementVNode("textarea", { rows: "2", "onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => _ctx.authSsr.identity.secretKey = $event), class: "bg-light form-control", readonly: "" }, null, 512), [ [vue.vModelText, _ctx.authSsr.identity.secretKey] ]) ])) : vue.createCommentVNode("", true), vue.createElementVNode("div", _hoisted_30, [ vue.createElementVNode("button", { class: "btn btn-secondary", onClick: _cache[8] || (_cache[8] = (...args) => $options.btnShowActualKeys && $options.btnShowActualKeys(...args)) }, vue.toDisplayString(_ctx.$t("account.btnShowActualKey")), 1) ]) ]) ]) ]) ]) ]); } const Account = /* @__PURE__ */ _pluginVue_exportHelper._export_sfc(_sfc_main, [["render", _sfc_render]]); const Account$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({ __proto__: null, default: Account }, Symbol.toStringTag, { value: "Module" })); exports.Account = Account; exports.Account$1 = Account$1; exports.naclUtilExports = naclUtilExports; //# sourceMappingURL=Account-CRSRrcCP.cjs.map