dsh-workbench-vault 0.3.9 → 0.3.11
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/lib/client.js +113 -75
- package/lib/index.js +2 -1
- package/package.json +3 -3
package/lib/client.js
CHANGED
|
@@ -844,6 +844,107 @@ var require_icons2 = __commonJS({
|
|
|
844
844
|
}
|
|
845
845
|
});
|
|
846
846
|
|
|
847
|
+
// packages/addons/lib/vault-lock.cjs
|
|
848
|
+
var require_vault_lock = __commonJS({
|
|
849
|
+
"packages/addons/lib/vault-lock.cjs"(exports2, module2) {
|
|
850
|
+
"use strict";
|
|
851
|
+
var POLL_MS = 4e3;
|
|
852
|
+
function create(options) {
|
|
853
|
+
var cfg = options || {};
|
|
854
|
+
var prefix = String(cfg.prefix || "wb");
|
|
855
|
+
var wrapClass = String(cfg.wrapClass || prefix);
|
|
856
|
+
var lock = {
|
|
857
|
+
POLL_MS: Number(cfg.pollMs) > 0 ? Number(cfg.pollMs) : POLL_MS,
|
|
858
|
+
prefix,
|
|
859
|
+
use,
|
|
860
|
+
Panel,
|
|
861
|
+
styles
|
|
862
|
+
};
|
|
863
|
+
function use(opts) {
|
|
864
|
+
var React = opts.React;
|
|
865
|
+
var api = opts.api;
|
|
866
|
+
var C = opts.C;
|
|
867
|
+
var every = Number(opts.pollMs) > 0 ? Number(opts.pollMs) : Number(lock.POLL_MS) || POLL_MS;
|
|
868
|
+
var action = opts.action || "vault.status";
|
|
869
|
+
var st = React.useState({ ready: false, locked: true, initialized: false, error: "" });
|
|
870
|
+
var tick = React.useState(0);
|
|
871
|
+
function read() {
|
|
872
|
+
return C.call(api, action).then(function(data) {
|
|
873
|
+
st[1](function(old) {
|
|
874
|
+
var next = {
|
|
875
|
+
ready: true,
|
|
876
|
+
locked: !(data && data.locked === false),
|
|
877
|
+
initialized: !!(data && data.initialized),
|
|
878
|
+
error: ""
|
|
879
|
+
};
|
|
880
|
+
if (old.ready === next.ready && old.locked === next.locked && old.initialized === next.initialized && !old.error) return old;
|
|
881
|
+
return next;
|
|
882
|
+
});
|
|
883
|
+
}).catch(function(e) {
|
|
884
|
+
st[1](function(old) {
|
|
885
|
+
return Object.assign({}, old, { ready: true, locked: true, error: C.errText(e) });
|
|
886
|
+
});
|
|
887
|
+
});
|
|
888
|
+
}
|
|
889
|
+
React.useEffect(function() {
|
|
890
|
+
var alive = true;
|
|
891
|
+
function poll() {
|
|
892
|
+
if (alive) read();
|
|
893
|
+
}
|
|
894
|
+
poll();
|
|
895
|
+
var timer = setInterval(poll, every);
|
|
896
|
+
if (timer && typeof timer.unref === "function") timer.unref();
|
|
897
|
+
return function() {
|
|
898
|
+
alive = false;
|
|
899
|
+
clearInterval(timer);
|
|
900
|
+
};
|
|
901
|
+
}, [tick[0]]);
|
|
902
|
+
return {
|
|
903
|
+
ready: st[0].ready,
|
|
904
|
+
locked: st[0].locked,
|
|
905
|
+
initialized: st[0].initialized,
|
|
906
|
+
error: st[0].error,
|
|
907
|
+
refresh: function() {
|
|
908
|
+
tick[1](tick[0] + 1);
|
|
909
|
+
}
|
|
910
|
+
};
|
|
911
|
+
}
|
|
912
|
+
function Panel(props) {
|
|
913
|
+
var h = props.h;
|
|
914
|
+
var C = props.C;
|
|
915
|
+
var lang = props.lang === "en" ? "en" : "zh";
|
|
916
|
+
var Icon2 = props.Icon || cfg.Icon || null;
|
|
917
|
+
function pick(custom, fallback) {
|
|
918
|
+
var v = custom !== void 0 ? custom : fallback;
|
|
919
|
+
if (v && typeof v === "object") return v[lang] || v.zh || v.en || "";
|
|
920
|
+
return v || "";
|
|
921
|
+
}
|
|
922
|
+
return h(
|
|
923
|
+
"div",
|
|
924
|
+
{ className: props.wrapClass || wrapClass },
|
|
925
|
+
h(
|
|
926
|
+
"div",
|
|
927
|
+
{ className: prefix + "-lock-card", role: "status", "aria-live": "polite" },
|
|
928
|
+
Icon2 ? h(Icon2, { size: 22, strokeWidth: 2, "aria-hidden": "true", className: prefix + "-lock-ico" }) : null,
|
|
929
|
+
h("div", { className: prefix + "-lock-title" }, pick(props.title, cfg.title)),
|
|
930
|
+
h("div", { className: prefix + "-muted" }, pick(props.hint, cfg.hint)),
|
|
931
|
+
props.error ? h(C.Notice, { h, kind: "error", text: props.error }) : null
|
|
932
|
+
)
|
|
933
|
+
);
|
|
934
|
+
}
|
|
935
|
+
function styles() {
|
|
936
|
+
return [
|
|
937
|
+
"." + prefix + "-lock-card{max-width:560px;margin:28px auto;padding:26px 24px;border:1px solid var(--wb-border);border-radius:12px;background:var(--wb-card);display:flex;flex-direction:column;gap:8px;align-items:flex-start}",
|
|
938
|
+
"." + prefix + "-lock-ico{color:var(--wb-muted)}",
|
|
939
|
+
"." + prefix + "-lock-title{font-size:15px;font-weight:600}"
|
|
940
|
+
];
|
|
941
|
+
}
|
|
942
|
+
return lock;
|
|
943
|
+
}
|
|
944
|
+
module2.exports = { create, POLL_MS };
|
|
945
|
+
}
|
|
946
|
+
});
|
|
947
|
+
|
|
847
948
|
// packages/addons/lib/filter-checklist-styles.cjs
|
|
848
949
|
var require_filter_checklist_styles = __commonJS({
|
|
849
950
|
"packages/addons/lib/filter-checklist-styles.cjs"(exports2, module2) {
|
|
@@ -933,7 +1034,7 @@ var require_icon_label = __commonJS({
|
|
|
933
1034
|
return h(
|
|
934
1035
|
"span",
|
|
935
1036
|
{ className: "wb-icon-label" },
|
|
936
|
-
h(Icon2, { size: 14, strokeWidth: 2, "aria-hidden": true, focusable: false }),
|
|
1037
|
+
Icon2 ? h(Icon2, { size: 14, strokeWidth: 2, "aria-hidden": true, focusable: false }) : null,
|
|
937
1038
|
h("span", null, text)
|
|
938
1039
|
);
|
|
939
1040
|
};
|
|
@@ -1005,11 +1106,8 @@ var require_styles = __commonJS({
|
|
|
1005
1106
|
".wbv-empty-title{font-size:14px;font-weight:600}",
|
|
1006
1107
|
".wbv-check-list{display:flex;flex-wrap:wrap;gap:6px 14px;margin:4px 0}",
|
|
1007
1108
|
".wbv-check{display:inline-flex;align-items:center;gap:6px;font-size:12px;cursor:pointer}",
|
|
1008
|
-
".wbv-dot{width:8px;height:8px;border-radius:50%;display:inline-block;flex:none}"
|
|
1009
|
-
|
|
1010
|
-
".wbv-lock-ico{color:var(--wb-muted)}",
|
|
1011
|
-
".wbv-lock-title{font-size:15px;font-weight:600}"
|
|
1012
|
-
].concat(require_filter_checklist_styles()).concat(require_client_base_styles().secretFieldStyles, require_icon_label().styles);
|
|
1109
|
+
".wbv-dot{width:8px;height:8px;border-radius:50%;display:inline-block;flex:none}"
|
|
1110
|
+
].concat(require_vault_lock().create({ prefix: "wbv" }).styles()).concat(require_filter_checklist_styles()).concat(require_client_base_styles().secretFieldStyles, require_icon_label().styles);
|
|
1013
1111
|
}
|
|
1014
1112
|
});
|
|
1015
1113
|
|
|
@@ -1644,75 +1742,15 @@ var require_status = __commonJS({
|
|
|
1644
1742
|
var require_lock = __commonJS({
|
|
1645
1743
|
"packages/addons/vault/client/ui/lock.cjs"(exports2, module2) {
|
|
1646
1744
|
"use strict";
|
|
1647
|
-
|
|
1648
|
-
|
|
1649
|
-
|
|
1650
|
-
|
|
1651
|
-
|
|
1652
|
-
|
|
1653
|
-
|
|
1654
|
-
var st = React.useState({ ready: false, locked: true, initialized: false, error: "" });
|
|
1655
|
-
var tick = React.useState(0);
|
|
1656
|
-
function read() {
|
|
1657
|
-
return C.call(api, "vault.status").then(function(data) {
|
|
1658
|
-
st[1](function(old) {
|
|
1659
|
-
var next = {
|
|
1660
|
-
ready: true,
|
|
1661
|
-
locked: !(data && data.locked === false),
|
|
1662
|
-
initialized: !!(data && data.initialized),
|
|
1663
|
-
error: ""
|
|
1664
|
-
};
|
|
1665
|
-
if (old.ready === next.ready && old.locked === next.locked && old.initialized === next.initialized && !old.error) return old;
|
|
1666
|
-
return next;
|
|
1667
|
-
});
|
|
1668
|
-
}).catch(function(e) {
|
|
1669
|
-
st[1](function(old) {
|
|
1670
|
-
return Object.assign({}, old, { ready: true, locked: true, error: C.errText(e) });
|
|
1671
|
-
});
|
|
1672
|
-
});
|
|
1745
|
+
module2.exports = require_vault_lock().create({
|
|
1746
|
+
prefix: "wbv",
|
|
1747
|
+
Icon: require_icons2().ICONS.lock,
|
|
1748
|
+
title: { zh: "\u4FDD\u9669\u7BB1\u5DF2\u9501\u5B9A", en: "Vault is locked" },
|
|
1749
|
+
hint: {
|
|
1750
|
+
zh: "\u8BF7\u5148\u5728\u300C\u4FDD\u9669\u7BB1\u300D\u9875\u89E3\u9501\uFF1B\u89E3\u9501\u540E\u672C\u9875\u4F1A\u81EA\u52A8\u6062\u590D\u5217\u8868\u4E0E\u8BE6\u60C5\u3002",
|
|
1751
|
+
en: "Unlock it on the Vault page first; this page recovers automatically once unlocked."
|
|
1673
1752
|
}
|
|
1674
|
-
|
|
1675
|
-
var alive = true;
|
|
1676
|
-
function poll() {
|
|
1677
|
-
if (alive) read();
|
|
1678
|
-
}
|
|
1679
|
-
poll();
|
|
1680
|
-
var timer = setInterval(poll, every);
|
|
1681
|
-
if (timer && typeof timer.unref === "function") timer.unref();
|
|
1682
|
-
return function() {
|
|
1683
|
-
alive = false;
|
|
1684
|
-
clearInterval(timer);
|
|
1685
|
-
};
|
|
1686
|
-
}, [tick[0]]);
|
|
1687
|
-
return {
|
|
1688
|
-
ready: st[0].ready,
|
|
1689
|
-
locked: st[0].locked,
|
|
1690
|
-
initialized: st[0].initialized,
|
|
1691
|
-
error: st[0].error,
|
|
1692
|
-
refresh: function() {
|
|
1693
|
-
tick[1](tick[0] + 1);
|
|
1694
|
-
}
|
|
1695
|
-
};
|
|
1696
|
-
}
|
|
1697
|
-
function Panel(props) {
|
|
1698
|
-
var h = props.h;
|
|
1699
|
-
var C = props.C;
|
|
1700
|
-
var en = props.lang === "en";
|
|
1701
|
-
return h(
|
|
1702
|
-
"div",
|
|
1703
|
-
{ className: "wbv" },
|
|
1704
|
-
h(
|
|
1705
|
-
"div",
|
|
1706
|
-
{ className: "wbv-lock-card", role: "status", "aria-live": "polite" },
|
|
1707
|
-
h(GLYPHS2.lock, { size: 22, strokeWidth: 2, "aria-hidden": "true", className: "wbv-lock-ico" }),
|
|
1708
|
-
h("div", { className: "wbv-lock-title" }, en ? "Vault is locked" : "\u4FDD\u9669\u7BB1\u5DF2\u9501\u5B9A"),
|
|
1709
|
-
h("div", { className: "wbv-muted" }, en ? "Unlock it on the Vault page first; this page recovers automatically once unlocked." : "\u8BF7\u5148\u5728\u300C\u4FDD\u9669\u7BB1\u300D\u9875\u89E3\u9501\uFF1B\u89E3\u9501\u540E\u672C\u9875\u4F1A\u81EA\u52A8\u6062\u590D\u5217\u8868\u4E0E\u8BE6\u60C5\u3002"),
|
|
1710
|
-
props.error ? h(C.Notice, { h, kind: "error", text: props.error }) : null
|
|
1711
|
-
)
|
|
1712
|
-
);
|
|
1713
|
-
}
|
|
1714
|
-
var obj = { use: useVaultLock, Panel, POLL_MS };
|
|
1715
|
-
module2.exports = obj;
|
|
1753
|
+
});
|
|
1716
1754
|
}
|
|
1717
1755
|
});
|
|
1718
1756
|
|
|
@@ -5230,7 +5268,7 @@ var GLYPHS = require_icons2().ICONS;
|
|
|
5230
5268
|
ensureStyles();
|
|
5231
5269
|
host.registerAddon({
|
|
5232
5270
|
id: "wb-addon-vault",
|
|
5233
|
-
version: "0.3.
|
|
5271
|
+
version: "0.3.11",
|
|
5234
5272
|
icon: GLYPHS["shield-check"],
|
|
5235
5273
|
views: [
|
|
5236
5274
|
{ id: "status", icon: tabIcon("shield"), title: { zh: "\u4FDD\u9669\u7BB1", en: "Vault" }, component: withProps(require_status(), "\u4FDD\u9669\u7BB1") },
|
package/lib/index.js
CHANGED
|
@@ -31,7 +31,8 @@ export function createDomain(host) {
|
|
|
31
31
|
id: "wb-addon-vault",
|
|
32
32
|
title: "凭据保险箱",
|
|
33
33
|
description: "集中保存密码、应用专用密码与 token;按分组授权给业务模块,加密落库、密文可同步。",
|
|
34
|
-
version: "0.3.
|
|
34
|
+
version: "0.3.11",
|
|
35
|
+
category: "assets",
|
|
35
36
|
tables: [
|
|
36
37
|
"vault_header",
|
|
37
38
|
"vault_device",
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-workbench-vault",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.11",
|
|
4
4
|
"description": "个人工作台凭据保险箱:加密保存密码与 token,agent 只见掩码",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"main": "lib/index.js",
|
|
@@ -16,7 +16,7 @@
|
|
|
16
16
|
"addon": {
|
|
17
17
|
"id": "wb-addon-vault",
|
|
18
18
|
"title": "凭据保险箱",
|
|
19
|
-
"version": "0.3.
|
|
19
|
+
"version": "0.3.11",
|
|
20
20
|
"minShell": "0.8.0",
|
|
21
21
|
"tables": [
|
|
22
22
|
"vault_header",
|
|
@@ -68,7 +68,7 @@
|
|
|
68
68
|
}
|
|
69
69
|
},
|
|
70
70
|
"dependencies": {
|
|
71
|
-
"dsh-workbench-host": "^0.8.
|
|
71
|
+
"dsh-workbench-host": "^0.8.2"
|
|
72
72
|
},
|
|
73
73
|
"dsh": {
|
|
74
74
|
"bundle": {
|