@peers-app/peers-ui 0.16.0 → 0.16.1
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/dist/components/router.js +4 -0
- package/dist/screens/account/account-screen.d.ts +1 -0
- package/dist/screens/account/account-screen.js +60 -0
- package/dist/screens/setup-user.js +4 -0
- package/dist/system-apps/account.app.d.ts +2 -0
- package/dist/system-apps/account.app.js +8 -0
- package/dist/system-apps/index.d.ts +1 -0
- package/dist/system-apps/index.js +5 -1
- package/package.json +3 -3
- package/src/components/router.tsx +4 -0
- package/src/screens/account/account-screen.tsx +141 -0
- package/src/screens/setup-user.tsx +5 -0
- package/src/system-apps/account.app.ts +7 -0
- package/src/system-apps/index.ts +3 -0
|
@@ -37,6 +37,7 @@ exports.Router = Router;
|
|
|
37
37
|
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
38
38
|
const globals = __importStar(require("../globals"));
|
|
39
39
|
const hooks_1 = require("../hooks");
|
|
40
|
+
const account_screen_1 = require("../screens/account/account-screen");
|
|
40
41
|
const assistant_details_1 = require("../screens/assistants/assistant-details");
|
|
41
42
|
const assistant_list_1 = require("../screens/assistants/assistant-list");
|
|
42
43
|
const package_details_1 = require("../screens/packages/package-details");
|
|
@@ -87,6 +88,9 @@ function Router({ path: providedPath } = {}) {
|
|
|
87
88
|
if (path === "settings" || path === "profile") {
|
|
88
89
|
return (0, jsx_runtime_1.jsx)(settings_page_1.SettingsPage, {});
|
|
89
90
|
}
|
|
91
|
+
if (path === "account") {
|
|
92
|
+
return (0, jsx_runtime_1.jsx)(account_screen_1.AccountScreen, {});
|
|
93
|
+
}
|
|
90
94
|
if (path === "threads" || path === "") {
|
|
91
95
|
return (0, jsx_runtime_1.jsx)(channel_view_1.ChannelMessages, {});
|
|
92
96
|
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
export declare function AccountScreen(): import("react/jsx-runtime").JSX.Element;
|
|
@@ -0,0 +1,60 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.AccountScreen = AccountScreen;
|
|
4
|
+
const jsx_runtime_1 = require("react/jsx-runtime");
|
|
5
|
+
const peers_sdk_1 = require("@peers-app/peers-sdk");
|
|
6
|
+
const react_1 = require("react");
|
|
7
|
+
const tooltip_1 = require("../../components/tooltip");
|
|
8
|
+
const hooks_1 = require("../../hooks");
|
|
9
|
+
const registrationStatusPvar = (0, peers_sdk_1.userVar)("PEERS_SERVICES_REGISTERED", {
|
|
10
|
+
defaultValue: "",
|
|
11
|
+
});
|
|
12
|
+
const servicesTokenPvar = (0, peers_sdk_1.userVar)("PEERS_SERVICES_TOKEN", {
|
|
13
|
+
isSecret: true,
|
|
14
|
+
defaultValue: "",
|
|
15
|
+
});
|
|
16
|
+
const INFO_TEXT = `### What does registering do?
|
|
17
|
+
|
|
18
|
+
Registering your account links your **public key** with the Peers cloud service. This enables cloud-powered features like:
|
|
19
|
+
|
|
20
|
+
- **AI Assistant** - use the built-in assistant powered by hosted LLM inference
|
|
21
|
+
- **Cloud relay** - improved connectivity between your devices
|
|
22
|
+
- **Future services** - new cloud features as they become available
|
|
23
|
+
|
|
24
|
+
### Is it safe?
|
|
25
|
+
|
|
26
|
+
Registration uses a **cryptographic challenge-response** to prove you own your secret key.
|
|
27
|
+
Your **secret key never leaves your device**. Only your public key is shared with the server.
|
|
28
|
+
|
|
29
|
+
### Do I have to register?
|
|
30
|
+
|
|
31
|
+
No. Peers works fully in local/peer-to-peer mode without registration. Cloud features simply won't be available until you register.`;
|
|
32
|
+
function AccountScreen() {
|
|
33
|
+
const [registrationStatus] = (0, hooks_1.useObservable)(registrationStatusPvar);
|
|
34
|
+
const [isRegistering, setIsRegistering] = (0, react_1.useState)(false);
|
|
35
|
+
const [error, setError] = (0, react_1.useState)(null);
|
|
36
|
+
const [success, setSuccess] = (0, react_1.useState)(null);
|
|
37
|
+
const isRegistered = !!registrationStatus;
|
|
38
|
+
const handleRegister = async () => {
|
|
39
|
+
setIsRegistering(true);
|
|
40
|
+
setError(null);
|
|
41
|
+
setSuccess(null);
|
|
42
|
+
try {
|
|
43
|
+
const token = await peers_sdk_1.rpcServerCalls.registerWithPeersServices();
|
|
44
|
+
servicesTokenPvar(token);
|
|
45
|
+
registrationStatusPvar(new Date().toISOString());
|
|
46
|
+
setSuccess("Account registered successfully.");
|
|
47
|
+
}
|
|
48
|
+
catch (err) {
|
|
49
|
+
setError(`Registration failed: ${String(err)}`);
|
|
50
|
+
}
|
|
51
|
+
finally {
|
|
52
|
+
setIsRegistering(false);
|
|
53
|
+
}
|
|
54
|
+
};
|
|
55
|
+
return ((0, jsx_runtime_1.jsxs)("div", { className: "container-fluid p-3", style: { maxWidth: 600 }, children: [(0, jsx_runtime_1.jsxs)("h4", { className: "mb-3 d-flex align-items-center gap-2", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-person-circle" }), "Account"] }), error && ((0, jsx_runtime_1.jsxs)("div", { className: "alert alert-danger alert-dismissible", role: "alert", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-exclamation-triangle me-2" }), error, (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn-close", onClick: () => setError(null), "aria-label": "Close" })] })), success && ((0, jsx_runtime_1.jsxs)("div", { className: "alert alert-success alert-dismissible", role: "alert", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-check-circle me-2" }), success, (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn-close", onClick: () => setSuccess(null), "aria-label": "Close" })] })), (0, jsx_runtime_1.jsx)("div", { className: "card", children: (0, jsx_runtime_1.jsxs)("div", { className: "card-body", children: [(0, jsx_runtime_1.jsxs)("h5", { className: "card-title d-flex align-items-center gap-2", children: ["Peers Services Registration", (0, jsx_runtime_1.jsx)(tooltip_1.Tooltip, { markdownContent: INFO_TEXT })] }), isRegistered ? ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsxs)("div", { className: "d-flex align-items-center gap-2 mb-2", children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-check-circle-fill text-success", style: { fontSize: "1.2em" } }), (0, jsx_runtime_1.jsx)("span", { children: "Registered" })] }), (0, jsx_runtime_1.jsxs)("small", { className: "text-muted", children: ["Registered on", " ", new Date(registrationStatus).toLocaleDateString(undefined, {
|
|
56
|
+
year: "numeric",
|
|
57
|
+
month: "long",
|
|
58
|
+
day: "numeric",
|
|
59
|
+
})] })] })) : ((0, jsx_runtime_1.jsxs)("div", { children: [(0, jsx_runtime_1.jsx)("p", { className: "text-muted mb-3", children: "Register your account to enable cloud-powered features like the AI assistant." }), (0, jsx_runtime_1.jsx)("button", { type: "button", className: "btn btn-primary", onClick: handleRegister, disabled: isRegistering, children: isRegistering ? ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("span", { className: "spinner-border spinner-border-sm me-2" }), "Registering..."] })) : ((0, jsx_runtime_1.jsxs)(jsx_runtime_1.Fragment, { children: [(0, jsx_runtime_1.jsx)("i", { className: "bi bi-cloud-upload me-2" }), "Register Account"] })) })] }))] }) })] }));
|
|
60
|
+
}
|
|
@@ -31,6 +31,10 @@ const SetupUser = () => {
|
|
|
31
31
|
.catch((err) => {
|
|
32
32
|
console.error("Error auto-installing peers-core:", err);
|
|
33
33
|
});
|
|
34
|
+
// Register with peers-services
|
|
35
|
+
await peers_sdk_1.rpcServerCalls.registerWithPeersServices().catch((err) => {
|
|
36
|
+
console.warn("Auto-registration with peers-services deferred:", err);
|
|
37
|
+
});
|
|
34
38
|
// Success - reload the app
|
|
35
39
|
window.location.reload();
|
|
36
40
|
}
|
|
@@ -1,6 +1,8 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.systemPackage = exports.systemApps = exports.workflowsApp = exports.variablesApp = exports.typesApp = exports.toolsApp = exports.threadsApp = exports.settingsApp = exports.searchApp = exports.packagesApp = exports.networkViewerApp = exports.mobileSettingsApp = exports.joinGroupApp = exports.groupsApp = exports.dataExplorerApp = exports.contactsApp = exports.consoleLogsApp = exports.assistantsApp = void 0;
|
|
3
|
+
exports.systemPackage = exports.systemApps = exports.workflowsApp = exports.variablesApp = exports.typesApp = exports.toolsApp = exports.threadsApp = exports.settingsApp = exports.searchApp = exports.packagesApp = exports.networkViewerApp = exports.mobileSettingsApp = exports.joinGroupApp = exports.groupsApp = exports.dataExplorerApp = exports.contactsApp = exports.consoleLogsApp = exports.assistantsApp = exports.accountApp = void 0;
|
|
4
|
+
var account_app_1 = require("./account.app");
|
|
5
|
+
Object.defineProperty(exports, "accountApp", { enumerable: true, get: function () { return account_app_1.accountApp; } });
|
|
4
6
|
var assistants_app_1 = require("./assistants.app");
|
|
5
7
|
Object.defineProperty(exports, "assistantsApp", { enumerable: true, get: function () { return assistants_app_1.assistantsApp; } });
|
|
6
8
|
var console_logs_app_1 = require("./console-logs.app");
|
|
@@ -34,6 +36,7 @@ var variables_app_1 = require("./variables.app");
|
|
|
34
36
|
Object.defineProperty(exports, "variablesApp", { enumerable: true, get: function () { return variables_app_1.variablesApp; } });
|
|
35
37
|
var workflows_app_1 = require("./workflows.app");
|
|
36
38
|
Object.defineProperty(exports, "workflowsApp", { enumerable: true, get: function () { return workflows_app_1.workflowsApp; } });
|
|
39
|
+
const account_app_2 = require("./account.app");
|
|
37
40
|
const assistants_app_2 = require("./assistants.app");
|
|
38
41
|
const console_logs_app_2 = require("./console-logs.app");
|
|
39
42
|
const contacts_app_2 = require("./contacts.app");
|
|
@@ -75,6 +78,7 @@ exports.systemApps = [
|
|
|
75
78
|
groups_app_2.groupsApp,
|
|
76
79
|
join_group_app_2.joinGroupApp,
|
|
77
80
|
// User & Settings Apps
|
|
81
|
+
account_app_2.accountApp,
|
|
78
82
|
settings_app_2.settingsApp,
|
|
79
83
|
// Mobile Settings (only in React Native)
|
|
80
84
|
...(isReactNative() ? [mobile_settings_app_2.mobileSettingsApp] : []),
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@peers-app/peers-ui",
|
|
3
|
-
"version": "0.16.
|
|
3
|
+
"version": "0.16.1",
|
|
4
4
|
"repository": {
|
|
5
5
|
"type": "git",
|
|
6
6
|
"url": "git+https://github.com/peers-app/peers-ui.git"
|
|
@@ -28,7 +28,7 @@
|
|
|
28
28
|
"lint:fix": "biome check --write ."
|
|
29
29
|
},
|
|
30
30
|
"peerDependencies": {
|
|
31
|
-
"@peers-app/peers-sdk": "^0.16.
|
|
31
|
+
"@peers-app/peers-sdk": "^0.16.1",
|
|
32
32
|
"bootstrap": "^5.3.3",
|
|
33
33
|
"react": "^18.0.0",
|
|
34
34
|
"react-dom": "^18.0.0"
|
|
@@ -39,7 +39,7 @@
|
|
|
39
39
|
"@babel/preset-env": "^7.24.5",
|
|
40
40
|
"@babel/preset-react": "^7.24.1",
|
|
41
41
|
"@babel/preset-typescript": "^7.27.1",
|
|
42
|
-
"@peers-app/peers-sdk": "0.16.
|
|
42
|
+
"@peers-app/peers-sdk": "0.16.1",
|
|
43
43
|
"@testing-library/dom": "^10.4.0",
|
|
44
44
|
"@testing-library/jest-dom": "^6.6.3",
|
|
45
45
|
"@testing-library/react": "^16.3.0",
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import * as globals from "../globals";
|
|
2
2
|
import { useObservable } from "../hooks";
|
|
3
|
+
import { AccountScreen } from "../screens/account/account-screen";
|
|
3
4
|
import { AssistantDetails } from "../screens/assistants/assistant-details";
|
|
4
5
|
import { AssistantList } from "../screens/assistants/assistant-list";
|
|
5
6
|
import { PackageDetails } from "../screens/packages/package-details";
|
|
@@ -54,6 +55,9 @@ export function Router({ path: providedPath }: { path?: string } = {}) {
|
|
|
54
55
|
if (path === "settings" || path === "profile") {
|
|
55
56
|
return <SettingsPage />;
|
|
56
57
|
}
|
|
58
|
+
if (path === "account") {
|
|
59
|
+
return <AccountScreen />;
|
|
60
|
+
}
|
|
57
61
|
if (path === "threads" || path === "") {
|
|
58
62
|
return <ChannelMessages />;
|
|
59
63
|
}
|
|
@@ -0,0 +1,141 @@
|
|
|
1
|
+
import { rpcServerCalls, userVar } from "@peers-app/peers-sdk";
|
|
2
|
+
import { useState } from "react";
|
|
3
|
+
import { Tooltip } from "../../components/tooltip";
|
|
4
|
+
import { useObservable } from "../../hooks";
|
|
5
|
+
|
|
6
|
+
const registrationStatusPvar = userVar<string>("PEERS_SERVICES_REGISTERED", {
|
|
7
|
+
defaultValue: "",
|
|
8
|
+
});
|
|
9
|
+
|
|
10
|
+
const servicesTokenPvar = userVar<string>("PEERS_SERVICES_TOKEN", {
|
|
11
|
+
isSecret: true,
|
|
12
|
+
defaultValue: "",
|
|
13
|
+
});
|
|
14
|
+
|
|
15
|
+
const INFO_TEXT = `### What does registering do?
|
|
16
|
+
|
|
17
|
+
Registering your account links your **public key** with the Peers cloud service. This enables cloud-powered features like:
|
|
18
|
+
|
|
19
|
+
- **AI Assistant** - use the built-in assistant powered by hosted LLM inference
|
|
20
|
+
- **Cloud relay** - improved connectivity between your devices
|
|
21
|
+
- **Future services** - new cloud features as they become available
|
|
22
|
+
|
|
23
|
+
### Is it safe?
|
|
24
|
+
|
|
25
|
+
Registration uses a **cryptographic challenge-response** to prove you own your secret key.
|
|
26
|
+
Your **secret key never leaves your device**. Only your public key is shared with the server.
|
|
27
|
+
|
|
28
|
+
### Do I have to register?
|
|
29
|
+
|
|
30
|
+
No. Peers works fully in local/peer-to-peer mode without registration. Cloud features simply won't be available until you register.`;
|
|
31
|
+
|
|
32
|
+
export function AccountScreen() {
|
|
33
|
+
const [registrationStatus] = useObservable(registrationStatusPvar);
|
|
34
|
+
const [isRegistering, setIsRegistering] = useState(false);
|
|
35
|
+
const [error, setError] = useState<string | null>(null);
|
|
36
|
+
const [success, setSuccess] = useState<string | null>(null);
|
|
37
|
+
|
|
38
|
+
const isRegistered = !!registrationStatus;
|
|
39
|
+
|
|
40
|
+
const handleRegister = async () => {
|
|
41
|
+
setIsRegistering(true);
|
|
42
|
+
setError(null);
|
|
43
|
+
setSuccess(null);
|
|
44
|
+
|
|
45
|
+
try {
|
|
46
|
+
const token = await rpcServerCalls.registerWithPeersServices();
|
|
47
|
+
servicesTokenPvar(token);
|
|
48
|
+
registrationStatusPvar(new Date().toISOString());
|
|
49
|
+
setSuccess("Account registered successfully.");
|
|
50
|
+
} catch (err) {
|
|
51
|
+
setError(`Registration failed: ${String(err)}`);
|
|
52
|
+
} finally {
|
|
53
|
+
setIsRegistering(false);
|
|
54
|
+
}
|
|
55
|
+
};
|
|
56
|
+
|
|
57
|
+
return (
|
|
58
|
+
<div className="container-fluid p-3" style={{ maxWidth: 600 }}>
|
|
59
|
+
<h4 className="mb-3 d-flex align-items-center gap-2">
|
|
60
|
+
<i className="bi bi-person-circle" />
|
|
61
|
+
Account
|
|
62
|
+
</h4>
|
|
63
|
+
|
|
64
|
+
{error && (
|
|
65
|
+
<div className="alert alert-danger alert-dismissible" role="alert">
|
|
66
|
+
<i className="bi bi-exclamation-triangle me-2" />
|
|
67
|
+
{error}
|
|
68
|
+
<button
|
|
69
|
+
type="button"
|
|
70
|
+
className="btn-close"
|
|
71
|
+
onClick={() => setError(null)}
|
|
72
|
+
aria-label="Close"
|
|
73
|
+
/>
|
|
74
|
+
</div>
|
|
75
|
+
)}
|
|
76
|
+
|
|
77
|
+
{success && (
|
|
78
|
+
<div className="alert alert-success alert-dismissible" role="alert">
|
|
79
|
+
<i className="bi bi-check-circle me-2" />
|
|
80
|
+
{success}
|
|
81
|
+
<button
|
|
82
|
+
type="button"
|
|
83
|
+
className="btn-close"
|
|
84
|
+
onClick={() => setSuccess(null)}
|
|
85
|
+
aria-label="Close"
|
|
86
|
+
/>
|
|
87
|
+
</div>
|
|
88
|
+
)}
|
|
89
|
+
|
|
90
|
+
<div className="card">
|
|
91
|
+
<div className="card-body">
|
|
92
|
+
<h5 className="card-title d-flex align-items-center gap-2">
|
|
93
|
+
Peers Services Registration
|
|
94
|
+
<Tooltip markdownContent={INFO_TEXT} />
|
|
95
|
+
</h5>
|
|
96
|
+
|
|
97
|
+
{isRegistered ? (
|
|
98
|
+
<div>
|
|
99
|
+
<div className="d-flex align-items-center gap-2 mb-2">
|
|
100
|
+
<i className="bi bi-check-circle-fill text-success" style={{ fontSize: "1.2em" }} />
|
|
101
|
+
<span>Registered</span>
|
|
102
|
+
</div>
|
|
103
|
+
<small className="text-muted">
|
|
104
|
+
Registered on{" "}
|
|
105
|
+
{new Date(registrationStatus as string).toLocaleDateString(undefined, {
|
|
106
|
+
year: "numeric",
|
|
107
|
+
month: "long",
|
|
108
|
+
day: "numeric",
|
|
109
|
+
})}
|
|
110
|
+
</small>
|
|
111
|
+
</div>
|
|
112
|
+
) : (
|
|
113
|
+
<div>
|
|
114
|
+
<p className="text-muted mb-3">
|
|
115
|
+
Register your account to enable cloud-powered features like the AI assistant.
|
|
116
|
+
</p>
|
|
117
|
+
<button
|
|
118
|
+
type="button"
|
|
119
|
+
className="btn btn-primary"
|
|
120
|
+
onClick={handleRegister}
|
|
121
|
+
disabled={isRegistering}
|
|
122
|
+
>
|
|
123
|
+
{isRegistering ? (
|
|
124
|
+
<>
|
|
125
|
+
<span className="spinner-border spinner-border-sm me-2" />
|
|
126
|
+
Registering...
|
|
127
|
+
</>
|
|
128
|
+
) : (
|
|
129
|
+
<>
|
|
130
|
+
<i className="bi bi-cloud-upload me-2" />
|
|
131
|
+
Register Account
|
|
132
|
+
</>
|
|
133
|
+
)}
|
|
134
|
+
</button>
|
|
135
|
+
</div>
|
|
136
|
+
)}
|
|
137
|
+
</div>
|
|
138
|
+
</div>
|
|
139
|
+
</div>
|
|
140
|
+
);
|
|
141
|
+
}
|
|
@@ -46,6 +46,11 @@ export const SetupUser = () => {
|
|
|
46
46
|
console.error("Error auto-installing peers-core:", err);
|
|
47
47
|
});
|
|
48
48
|
|
|
49
|
+
// Register with peers-services
|
|
50
|
+
await rpcServerCalls.registerWithPeersServices().catch((err: unknown) => {
|
|
51
|
+
console.warn("Auto-registration with peers-services deferred:", err);
|
|
52
|
+
});
|
|
53
|
+
|
|
49
54
|
// Success - reload the app
|
|
50
55
|
window.location.reload();
|
|
51
56
|
} catch (err) {
|
package/src/system-apps/index.ts
CHANGED
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import type { IAppNav, IPackage } from "@peers-app/peers-sdk";
|
|
2
2
|
|
|
3
|
+
export { accountApp } from "./account.app";
|
|
3
4
|
export { assistantsApp } from "./assistants.app";
|
|
4
5
|
export { consoleLogsApp } from "./console-logs.app";
|
|
5
6
|
export { contactsApp } from "./contacts.app";
|
|
@@ -18,6 +19,7 @@ export { typesApp } from "./types.app";
|
|
|
18
19
|
export { variablesApp } from "./variables.app";
|
|
19
20
|
export { workflowsApp } from "./workflows.app";
|
|
20
21
|
|
|
22
|
+
import { accountApp } from "./account.app";
|
|
21
23
|
import { assistantsApp } from "./assistants.app";
|
|
22
24
|
import { consoleLogsApp } from "./console-logs.app";
|
|
23
25
|
import { contactsApp } from "./contacts.app";
|
|
@@ -64,6 +66,7 @@ export const systemApps: IAppNav[] = [
|
|
|
64
66
|
joinGroupApp,
|
|
65
67
|
|
|
66
68
|
// User & Settings Apps
|
|
69
|
+
accountApp,
|
|
67
70
|
settingsApp,
|
|
68
71
|
// Mobile Settings (only in React Native)
|
|
69
72
|
...(isReactNative() ? [mobileSettingsApp] : []),
|