@rnzeus/heimdall-sdk 0.7.1 → 0.8.0
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/README.md +20 -1
- package/dist/core/cloud/client.d.ts +2 -1
- package/dist/core/cloud/client.js +2 -2
- package/dist/core/cloud/link-device.d.ts +2 -1
- package/dist/core/cloud/link-device.js +2 -1
- package/dist/core/connection/session/create-session.js +1 -0
- package/dist/core/connection/session/types.d.ts +2 -0
- package/dist/core/connection/socket/connect-socket.js +18 -5
- package/dist/core/connection/socket/unreachable-message.d.ts +12 -0
- package/dist/core/connection/socket/unreachable-message.js +11 -0
- package/dist/public/prompt/views/cloud-view.js +1 -1
- package/dist/public/prompt/views/manual-view.d.ts +1 -1
- package/dist/public/prompt/views/use-cloud-view.js +2 -0
- package/dist/types/options.d.ts +11 -1
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +2 -2
package/README.md
CHANGED
|
@@ -184,7 +184,8 @@ disconnect();
|
|
|
184
184
|
| `captureEarlyEvents` | `boolean` | `false` | buffer events that happen before the connection is up |
|
|
185
185
|
| `keepAlive` | `boolean` | `false` | reconnect on app start: to the last channel, or through the cloud again if the last connection came from it |
|
|
186
186
|
| `captureConsole` | `boolean` | `true` | console, uncaught errors, unhandled rejections |
|
|
187
|
-
| `cloud` | `{ url: string }` | — | optional, see [Connecting without typing an address](#connecting-without-typing-an-address) |
|
|
187
|
+
| `cloud` | `{ url: string; appKey?: string }` | — | optional, see [Connecting without typing an address](#connecting-without-typing-an-address) and [Team apps](#team-apps) |
|
|
188
|
+
| `ai` | `"strict" \| "off"` | — | what AI may get from this app's data in Heimdall, see [Team apps](#team-apps) |
|
|
188
189
|
|
|
189
190
|
`<HeimdallConnectPrompt />` accepts `onCopyToClipboard?: (text: string) => void` to plug in your clipboard library.
|
|
190
191
|
|
|
@@ -215,6 +216,24 @@ The cloud only stores accounts, devices and the current address of the desktop.
|
|
|
215
216
|
|
|
216
217
|
**Devices.** A device in the account is a phone, a tablet or a simulator; several apps (for example dev and stage builds) can be linked to it. Linking an Android app to an iPhone, or an emulator to a real device, asks for confirmation. Pass `device` (see [Options](#options)) to make the iOS simulator recognisable too.
|
|
217
218
|
|
|
219
|
+
## Team apps
|
|
220
|
+
|
|
221
|
+
A team in Heimdall Cloud registers its app on the team's **Apps** page and gets a public **app key** (`hk_…`). It is not a secret: it ties the app to the team, like a DSN.
|
|
222
|
+
|
|
223
|
+
```ts
|
|
224
|
+
configureConnectPrompt({
|
|
225
|
+
// ...
|
|
226
|
+
cloud: { url: "https://heimdall.rnzeus.dev", appKey: "hk_..." },
|
|
227
|
+
ai: "strict", // optional
|
|
228
|
+
});
|
|
229
|
+
```
|
|
230
|
+
|
|
231
|
+
- **Find me** links the device straight into the team's devices; the tester doesn't pick a team.
|
|
232
|
+
- Heimdall applies the team's AI rule for the app (Member's choice, Strict or Off) to bug reports with its events, through the cloud and in manual mode alike. Without a key Heimdall matches the app by `appId`.
|
|
233
|
+
- `ai` is the app developers' own limit on what AI clients may get from the app's data in Heimdall: `"strict"` — the Strict data set, no screenshots; `"off"` — nothing. It can only make Heimdall stricter, never looser than the team's rule.
|
|
234
|
+
|
|
235
|
+
Older Heimdall versions ignore both.
|
|
236
|
+
|
|
218
237
|
## Production safety
|
|
219
238
|
|
|
220
239
|
- `enabled` defaults to `__DEV__`. In a release build the SDK does nothing unless you pass `enabled: true`.
|
|
@@ -32,8 +32,9 @@ export type CloudConnection = {
|
|
|
32
32
|
};
|
|
33
33
|
token?: string;
|
|
34
34
|
};
|
|
35
|
-
export declare function createClaim({ baseUrl, appId, platform, installId, device, }: {
|
|
35
|
+
export declare function createClaim({ baseUrl, appKey, appId, platform, installId, device, }: {
|
|
36
36
|
baseUrl: string;
|
|
37
|
+
appKey?: string;
|
|
37
38
|
appId?: string;
|
|
38
39
|
platform?: string;
|
|
39
40
|
installId?: string;
|
|
@@ -24,12 +24,12 @@ async function request({ baseUrl, path, method = "GET", token, body, }) {
|
|
|
24
24
|
clearTimeout(timeout);
|
|
25
25
|
}
|
|
26
26
|
}
|
|
27
|
-
export async function createClaim({ baseUrl, appId, platform, installId, device, }) {
|
|
27
|
+
export async function createClaim({ baseUrl, appKey, appId, platform, installId, device, }) {
|
|
28
28
|
const { status, data } = await request({
|
|
29
29
|
baseUrl,
|
|
30
30
|
path: "/claims",
|
|
31
31
|
method: "POST",
|
|
32
|
-
body: { appId, platform, installId, device },
|
|
32
|
+
body: { appKey, appId, platform, installId, device },
|
|
33
33
|
});
|
|
34
34
|
if (status !== 201)
|
|
35
35
|
throw new Error(`Cloud error ${status}`);
|
|
@@ -7,8 +7,9 @@ export type LinkDeviceResult = {
|
|
|
7
7
|
} | {
|
|
8
8
|
status: "cancelled";
|
|
9
9
|
};
|
|
10
|
-
export declare function linkDevice({ baseUrl, appId, platform, installId, device, isCancelled, }: {
|
|
10
|
+
export declare function linkDevice({ baseUrl, appKey, appId, platform, installId, device, isCancelled, }: {
|
|
11
11
|
baseUrl: string;
|
|
12
|
+
appKey?: string;
|
|
12
13
|
appId?: string;
|
|
13
14
|
platform?: string;
|
|
14
15
|
installId?: string;
|
|
@@ -3,9 +3,10 @@ import { createClaim, pollClaim } from "./client.js";
|
|
|
3
3
|
import { saveCloudDevice } from "./storage.js";
|
|
4
4
|
const POLL_INTERVAL_MS = 2000;
|
|
5
5
|
const delay = (ms) => new Promise((resolve) => setTimeout(() => resolve(), ms));
|
|
6
|
-
export async function linkDevice({ baseUrl, appId, platform, installId, device, isCancelled, }) {
|
|
6
|
+
export async function linkDevice({ baseUrl, appKey, appId, platform, installId, device, isCancelled, }) {
|
|
7
7
|
const claim = await createClaim({
|
|
8
8
|
baseUrl,
|
|
9
|
+
appKey,
|
|
9
10
|
appId,
|
|
10
11
|
platform,
|
|
11
12
|
installId,
|
|
@@ -6,6 +6,8 @@ export type HeimdallSession = {
|
|
|
6
6
|
createdAt: string;
|
|
7
7
|
options: HeimdallConnectOptions;
|
|
8
8
|
secure?: SecureTransport;
|
|
9
|
+
/** where the host address came from: shown when the host can't be reached */
|
|
10
|
+
source?: ConnectionSource;
|
|
9
11
|
};
|
|
10
12
|
export type ConnectionSource = "cloud" | "manual";
|
|
11
13
|
export type LastConnection = {
|
|
@@ -4,6 +4,7 @@ import { isConnected, getSocket, setConnected, setSocket, setLastError, } from "
|
|
|
4
4
|
import { handleSocketLost } from "./handle-socket-lost.js";
|
|
5
5
|
import { flushEarlyEvents } from "./flush-early-events.js";
|
|
6
6
|
import { normalizeSocketError } from "./normalize-socket-error.js";
|
|
7
|
+
import { unreachableMessage } from "./unreachable-message.js";
|
|
7
8
|
import { SOCKET } from "./constants.js";
|
|
8
9
|
import { getCapabilities } from "./capabilities.js";
|
|
9
10
|
import { handleHostLine } from "./host-message.js";
|
|
@@ -14,7 +15,7 @@ import { normaliseAppInfo, readDeviceInfo } from "../../system/index.js";
|
|
|
14
15
|
import { CERTIFICATE_MISMATCH, NO_ANSWER, matchesPin, parseHostAnswer, readPeerCertificate, rejectionMessage, } from "./secure-transport.js";
|
|
15
16
|
const HOST_ANSWER_TIMEOUT_MS = 5000;
|
|
16
17
|
function buildHello({ session, options, secure, }) {
|
|
17
|
-
var _a, _b;
|
|
18
|
+
var _a, _b, _c;
|
|
18
19
|
const activeSession = getCurrentSession();
|
|
19
20
|
const hello = {
|
|
20
21
|
kind: "hello",
|
|
@@ -31,8 +32,11 @@ function buildHello({ session, options, secure, }) {
|
|
|
31
32
|
if (device)
|
|
32
33
|
hello.device = device;
|
|
33
34
|
const app = normaliseAppInfo(options.app);
|
|
34
|
-
|
|
35
|
-
|
|
35
|
+
const key = (_c = options.cloud) === null || _c === void 0 ? void 0 : _c.appKey;
|
|
36
|
+
if (app || key)
|
|
37
|
+
hello.app = { ...app, ...(key ? { key } : {}) };
|
|
38
|
+
if (options.ai)
|
|
39
|
+
hello.policy = { ai: options.ai };
|
|
36
40
|
if (secure)
|
|
37
41
|
hello.auth = { token: secure.token };
|
|
38
42
|
const capabilities = getCapabilities();
|
|
@@ -147,16 +151,25 @@ export function connectSocket(optionsOrSession) {
|
|
|
147
151
|
const newSocket = secure
|
|
148
152
|
? TcpSocket.connectTLS({ host: options.host, port: options.port, ca: secure.cert }, () => void onSecureConnect())
|
|
149
153
|
: TcpSocket.createConnection({ host: options.host, port: options.port }, onPlainConnect);
|
|
154
|
+
const unreachable = (reason) => {
|
|
155
|
+
var _a;
|
|
156
|
+
return unreachableMessage({
|
|
157
|
+
host: options.host,
|
|
158
|
+
port: options.port,
|
|
159
|
+
source: (_a = session.source) !== null && _a !== void 0 ? _a : "manual",
|
|
160
|
+
reason,
|
|
161
|
+
});
|
|
162
|
+
};
|
|
150
163
|
const connectTimeout = setTimeout(() => {
|
|
151
164
|
if (getSocket() !== newSocket || isConnected())
|
|
152
165
|
return;
|
|
153
|
-
setLastError(
|
|
166
|
+
setLastError(unreachable("no answer"));
|
|
154
167
|
handleSocketLost();
|
|
155
168
|
}, SOCKET.CONNECT_TIMEOUT_MS);
|
|
156
169
|
newSocket.on("error", (error) => {
|
|
157
170
|
clearTimeout(connectTimeout);
|
|
158
171
|
const message = normalizeSocketError(error);
|
|
159
|
-
setLastError(message);
|
|
172
|
+
setLastError(isConnected() ? message : unreachable(message));
|
|
160
173
|
if (__DEV__) {
|
|
161
174
|
console.warn("[Heimdall] socket error:", message);
|
|
162
175
|
}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
import type { ConnectionSource } from "../session";
|
|
2
|
+
/**
|
|
3
|
+
* Why a connection to the host failed, with the address and where it came from: an old address from the cloud,
|
|
4
|
+
* an old one typed by hand and a phone that can't see the computer look alike otherwise. The system's reason
|
|
5
|
+
* stays in the text, the iOS Local Network check reads it.
|
|
6
|
+
*/
|
|
7
|
+
export declare function unreachableMessage({ host, port, source, reason, }: {
|
|
8
|
+
host: string;
|
|
9
|
+
port: number;
|
|
10
|
+
source: ConnectionSource;
|
|
11
|
+
reason: string;
|
|
12
|
+
}): string;
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Why a connection to the host failed, with the address and where it came from: an old address from the cloud,
|
|
3
|
+
* an old one typed by hand and a phone that can't see the computer look alike otherwise. The system's reason
|
|
4
|
+
* stays in the text, the iOS Local Network check reads it.
|
|
5
|
+
*/
|
|
6
|
+
export function unreachableMessage({ host, port, source, reason, }) {
|
|
7
|
+
const hint = source === "manual"
|
|
8
|
+
? "Same Wi-Fi, no VPN? The address may have changed: see Heimdall → Settings → Connection."
|
|
9
|
+
: "Same Wi-Fi as the computer, no VPN?";
|
|
10
|
+
return `Can't reach Heimdall at ${host}:${port} (${source}): ${reason.replace(/\.$/, "")}. ${hint}`;
|
|
11
|
+
}
|
|
@@ -15,7 +15,7 @@ const CloudView = ({ baseUrl, visible, socketError, theme, isConnecting, notice,
|
|
|
15
15
|
return (_jsxs(_Fragment, { children: [_jsx(Header, { title: "Heimdall", status: "busy", theme: theme }), _jsx(Text, { style: [styles.text, { color: theme.muted }], children: "Sign in and pick this device in the browser, then come back." }), _jsx(Footer, { primary: _jsx(ActionButton, { title: "Cancel", variant: "link", theme: theme, onPress: onCancelLinking }) })] }));
|
|
16
16
|
}
|
|
17
17
|
return (_jsxs(_Fragment, { children: [_jsx(Header, { title: deviceName !== null && deviceName !== void 0 ? deviceName : "Heimdall", status: error ? "error" : isBusy ? "busy" : "idle", theme: theme }), _jsx(Text, { style: [styles.text, { color: theme.muted }], children: deviceName
|
|
18
|
-
? "Start Heimdall for this device on your
|
|
18
|
+
? "Start Heimdall for this device on your computer."
|
|
19
19
|
: "Link this device with your Heimdall account." }), _jsx(StatusLine, { error: error, notice: notice, theme: theme }), _jsx(ScreenRecording, { theme: theme }), _jsx(Footer, { start: _jsx(ActionButton, { title: "Enter manually", variant: "link", theme: theme, disabled: isBusy, onPress: onManual }), end: deviceName ? (_jsx(ActionButton, { title: "Unlink", variant: "quiet", theme: theme, disabled: isBusy, onPress: onUnlink })) : null, primary: _jsx(ActionButton, { title: isConnecting ? "Connecting…" : deviceName ? "Connect" : "Find me", theme: theme, disabled: isBusy, onPress: deviceName ? onConnect : onFindMe }) })] }));
|
|
20
20
|
};
|
|
21
21
|
export default CloudView;
|
|
@@ -9,7 +9,7 @@ type Props = {
|
|
|
9
9
|
canCopy: boolean;
|
|
10
10
|
onCopyChannel: () => void;
|
|
11
11
|
onConnect: () => void;
|
|
12
|
-
/** back to finding the
|
|
12
|
+
/** back to finding the computer through Heimdall cloud: the counterpart of “Enter manually” */
|
|
13
13
|
onAuto?: () => void;
|
|
14
14
|
isConnecting: boolean;
|
|
15
15
|
/** a step the user takes while it connects, e.g. the iOS Local Network question */
|
|
@@ -17,6 +17,7 @@ const useCloudView = ({ baseUrl, visible, startConnecting, }) => {
|
|
|
17
17
|
setMessage(null);
|
|
18
18
|
}, [visible]);
|
|
19
19
|
const onFindMe = useCallback(async () => {
|
|
20
|
+
var _a;
|
|
20
21
|
const defaults = getPromptState().defaults;
|
|
21
22
|
cancelledRef.current = false;
|
|
22
23
|
setMessage(null);
|
|
@@ -24,6 +25,7 @@ const useCloudView = ({ baseUrl, visible, startConnecting, }) => {
|
|
|
24
25
|
try {
|
|
25
26
|
const result = await linkDevice({
|
|
26
27
|
baseUrl,
|
|
28
|
+
appKey: (_a = defaults === null || defaults === void 0 ? void 0 : defaults.cloud) === null || _a === void 0 ? void 0 : _a.appKey,
|
|
27
29
|
appId: defaults === null || defaults === void 0 ? void 0 : defaults.appId,
|
|
28
30
|
platform: defaults === null || defaults === void 0 ? void 0 : defaults.platform,
|
|
29
31
|
installId: getOrCreateClientId(),
|
package/dist/types/options.d.ts
CHANGED
|
@@ -31,8 +31,18 @@ export type HeimdallConnectOptions = {
|
|
|
31
31
|
id?: string;
|
|
32
32
|
isEmulator?: boolean;
|
|
33
33
|
};
|
|
34
|
-
/**
|
|
34
|
+
/**
|
|
35
|
+
* heimdall-cloud service: enables "Find me" device linking in the connect prompt.
|
|
36
|
+
* `appKey` — the app's public key from the team's Apps page: linked devices go to the team, and Heimdall
|
|
37
|
+
* applies the team's AI rules to this app. Not a secret.
|
|
38
|
+
*/
|
|
35
39
|
cloud?: {
|
|
36
40
|
url: string;
|
|
41
|
+
appKey?: string;
|
|
37
42
|
};
|
|
43
|
+
/**
|
|
44
|
+
* What AI may get from this app's data in Heimdall, set by the app's developers: "strict" — the Strict data set,
|
|
45
|
+
* no screenshots; "off" — nothing. It can only make Heimdall stricter. Not set — Heimdall's own rules apply.
|
|
46
|
+
*/
|
|
47
|
+
ai?: "strict" | "off";
|
|
38
48
|
};
|
package/dist/version.d.ts
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export declare const SDK_VERSION = "0.
|
|
1
|
+
export declare const SDK_VERSION = "0.8.0";
|
package/dist/version.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
export const SDK_VERSION = "0.
|
|
1
|
+
export const SDK_VERSION = "0.8.0";
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@rnzeus/heimdall-sdk",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.8.0",
|
|
4
4
|
"description": "React Native client for Heimdall — a desktop debug inspector for network, WebSocket, Zustand and console",
|
|
5
5
|
"license": "MIT",
|
|
6
6
|
"author": "Volodymyr Dudkevych",
|
|
@@ -111,7 +111,7 @@
|
|
|
111
111
|
}
|
|
112
112
|
},
|
|
113
113
|
"dependencies": {
|
|
114
|
-
"@rnzeus/heimdall-protocol": "^0.
|
|
114
|
+
"@rnzeus/heimdall-protocol": "^0.7.0"
|
|
115
115
|
},
|
|
116
116
|
"devDependencies": {
|
|
117
117
|
"@rnzeus/heimdall-lens": "^0.1.0",
|