@eotl/core
Version:
Assortment of data structures, Vue.js components, and utilities across EOTL apps and sites.
357 lines (356 loc) • 14.3 kB
JavaScript
import { c as commonjsGlobal } from "./_commonjsHelpers-DWwsNxpa.js";
import { ssrFetcher } from "@eotl/simple-signed-records";
import { useEotlCore } from "./store.js";
import { u as useAuthSsr } from "./authSsr-BedulHkH.js";
import { openBlock, createElementBlock, createElementVNode, toDisplayString, withDirectives, vModelText, Fragment, renderList, vModelSelect, createTextVNode, createCommentVNode } from "vue";
import { _ as _export_sfc } from "./_plugin-vue_export-helper-1tPrXgE0.js";
var naclUtil = { exports: {} };
(function(module) {
(function(root, f) {
if (module.exports) module.exports = f();
else if (root.nacl) root.nacl.util = f();
else {
root.nacl = {};
root.nacl.util = f();
}
})(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 = useEotlCore();
const authSsr = useAuthSsr();
return {
store,
authSsr,
details: {
emails: "",
name: "",
language: ""
},
showRecoveryWords: false,
showActualKeys: false,
loading: true
};
},
created() {
this.getAccount();
},
methods: {
getAccount() {
const identity = this.authSsr.identity.publicKey;
let vm = this;
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"
}
};
ssrFetcher.Post("keys", record).then((data) => {
console.log(data);
});
},
btnShowRecoveryWords() {
this.showRecoveryWords = true;
},
btnShowActualKeys() {
this.showActualKeys = true;
}
}
};
const _hoisted_1 = /* @__PURE__ */ createElementVNode("h2", null, "Account", -1);
const _hoisted_2 = /* @__PURE__ */ createElementVNode("hr", { class: "thick mb-5" }, null, -1);
const _hoisted_3 = { class: "row mb-5" };
const _hoisted_4 = /* @__PURE__ */ createElementVNode("div", { class: "col-3" }, [
/* @__PURE__ */ createElementVNode("div", {
class: "nav flex-column nav-pills",
id: "v-pills-tab",
role: "tablist",
"aria-orientation": "vertical"
}, [
/* @__PURE__ */ 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__ */ 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__ */ 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__ */ 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__ */ createElementVNode("h3", null, "Identity", -1);
const _hoisted_9 = /* @__PURE__ */ 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__ */ createElementVNode("h3", null, "Details", -1);
const _hoisted_12 = { class: "form-group" };
const _hoisted_13 = /* @__PURE__ */ createElementVNode("label", null, "Name", -1);
const _hoisted_14 = { class: "form-group" };
const _hoisted_15 = /* @__PURE__ */ createElementVNode("label", null, "You are", -1);
const _hoisted_16 = ["value"];
const _hoisted_17 = { class: "form-group" };
const _hoisted_18 = /* @__PURE__ */ createElementVNode("label", null, "Language", -1);
const _hoisted_19 = ["value"];
const _hoisted_20 = { class: "form-group" };
const _hoisted_21 = /* @__PURE__ */ createElementVNode("div", {
class: "tab-pane",
id: "v-pills-notifications",
role: "tabpanel",
"aria-labelledby": "v-pills-notifications-tab"
}, [
/* @__PURE__ */ createElementVNode("h3", null, "Notifications"),
/* @__PURE__ */ 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__ */ createElementVNode("h3", null, "Account Key", -1);
const _hoisted_24 = /* @__PURE__ */ 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__ */ 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__ */ 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 openBlock(), createElementBlock("main", null, [
_hoisted_1,
_hoisted_2,
createElementVNode("div", _hoisted_3, [
_hoisted_4,
createElementVNode("div", _hoisted_5, [
createElementVNode("div", _hoisted_6, [
createElementVNode("div", _hoisted_7, [
_hoisted_8,
_hoisted_9,
createElementVNode("label", null, toDisplayString(_ctx.$t("account.yourIdentityKey")), 1),
withDirectives(createElementVNode("input", {
class: "mb-4 bg-light form-control",
"onUpdate:modelValue": _cache[0] || (_cache[0] = ($event) => _ctx.authSsr.identity.publicKey = $event),
readonly: ""
}, null, 512), [
[vModelText, _ctx.authSsr.identity.publicKey]
])
]),
createElementVNode("div", _hoisted_10, [
_hoisted_11,
createElementVNode("div", _hoisted_12, [
_hoisted_13,
withDirectives(createElementVNode("input", {
type: "text",
"onUpdate:modelValue": _cache[1] || (_cache[1] = ($event) => _ctx.authSsr.account.name = $event),
class: "form-control",
placeholder: "David Buckle"
}, null, 512), [
[vModelText, _ctx.authSsr.account.name]
])
]),
createElementVNode("div", _hoisted_14, [
_hoisted_15,
withDirectives(createElementVNode("select", {
"onUpdate:modelValue": _cache[2] || (_cache[2] = ($event) => _ctx.authSsr.account.type = $event),
class: "form-control"
}, [
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.store.config.account_types, (type) => {
return openBlock(), createElementBlock("option", {
key: type,
value: type
}, toDisplayString(_ctx.$t("accountTypes." + type)), 9, _hoisted_16);
}), 128))
], 512), [
[vModelSelect, _ctx.authSsr.account.type]
])
]),
createElementVNode("div", _hoisted_17, [
_hoisted_18,
withDirectives(createElementVNode("select", {
"onUpdate:modelValue": _cache[3] || (_cache[3] = ($event) => _ctx.authSsr.account.language = $event),
class: "form-control"
}, [
(openBlock(true), createElementBlock(Fragment, null, renderList(_ctx.store.config.languages, (language) => {
return openBlock(), createElementBlock("option", {
key: language,
value: language
}, toDisplayString(language), 9, _hoisted_19);
}), 128))
], 512), [
[vModelSelect, _ctx.authSsr.account.language]
])
]),
createElementVNode("div", _hoisted_20, [
createElementVNode("button", {
onClick: _cache[4] || (_cache[4] = (...args) => $options.btnDetailsUpdate && $options.btnDetailsUpdate(...args)),
class: "btn btn-primary btn-block"
}, " Update Details ")
])
]),
_hoisted_21,
createElementVNode("div", _hoisted_22, [
_hoisted_23,
createElementVNode("p", null, [
createElementVNode("em", null, toDisplayString(_ctx.store.config.name), 1),
createTextVNode(" is different from most websites or apps as there is no username and password, instead it uses cryptographic keys to secure your account. ")
]),
createElementVNode("h5", null, toDisplayString(_ctx.$t("account.recoveryWords")), 1),
_hoisted_24,
_ctx.showRecoveryWords ? (openBlock(), createElementBlock("div", _hoisted_25, [
_hoisted_26,
withDirectives(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), [
[vModelText, _ctx.authSsr.identity.words]
])
])) : createCommentVNode("", true),
createElementVNode("div", _hoisted_27, [
createElementVNode("button", {
type: "button",
onClick: _cache[6] || (_cache[6] = (...args) => $options.btnShowRecoveryWords && $options.btnShowRecoveryWords(...args)),
class: "btn btn-secondary"
}, toDisplayString(_ctx.$t("account.btnShowRecoveryWords")), 1)
]),
createElementVNode("h5", null, toDisplayString(_ctx.$t("account.yourAccountKey")), 1),
createElementVNode("p", null, toDisplayString(_ctx.$t("account.textAccountKey")), 1),
_ctx.showActualKeys ? (openBlock(), createElementBlock("div", _hoisted_28, [
_hoisted_29,
withDirectives(createElementVNode("textarea", {
rows: "2",
"onUpdate:modelValue": _cache[7] || (_cache[7] = ($event) => _ctx.authSsr.identity.secretKey = $event),
class: "bg-light form-control",
readonly: ""
}, null, 512), [
[vModelText, _ctx.authSsr.identity.secretKey]
])
])) : createCommentVNode("", true),
createElementVNode("div", _hoisted_30, [
createElementVNode("button", {
class: "btn btn-secondary",
onClick: _cache[8] || (_cache[8] = (...args) => $options.btnShowActualKeys && $options.btnShowActualKeys(...args))
}, toDisplayString(_ctx.$t("account.btnShowActualKey")), 1)
])
])
])
])
])
]);
}
const Account = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
const Account$1 = /* @__PURE__ */ Object.freeze(/* @__PURE__ */ Object.defineProperty({
__proto__: null,
default: Account
}, Symbol.toStringTag, { value: "Module" }));
export {
Account as A,
Account$1 as a,
naclUtilExports as n
};
//# sourceMappingURL=Account-BbY3T8-e.js.map