@peers-app/peers-sdk 0.27.4 → 0.28.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/dist/context/user-context.d.ts +7 -1
- package/dist/context/user-context.js +4 -9
- package/dist/contracts/contract-proxy.d.ts +5 -0
- package/dist/contracts/contract-proxy.js +2 -2
- package/dist/contracts/contract-resolvers.d.ts +2 -2
- package/dist/contracts/contract-resolvers.js +14 -15
- package/dist/contracts/contract-transport.d.ts +2 -1
- package/dist/contracts/contract-transport.js +24 -2
- package/dist/contracts/system/network-contracts.d.ts +1 -1
- package/dist/contracts/tool-catalog-service.js +1 -1
- package/dist/contracts/tool-catalog.js +6 -2
- package/dist/data/assistants.d.ts +3 -3
- package/dist/data/authority-write-checks.d.ts +42 -0
- package/dist/data/authority-write-checks.js +324 -0
- package/dist/data/change-tracking.d.ts +4 -4
- package/dist/data/create-group.js +1 -0
- package/dist/data/devices.d.ts +27 -4
- package/dist/data/devices.js +31 -0
- package/dist/data/group-authority.d.ts +111 -0
- package/dist/data/group-authority.js +281 -0
- package/dist/data/group-members.d.ts +8 -2
- package/dist/data/group-members.js +41 -18
- package/dist/data/group-permissions.d.ts +15 -31
- package/dist/data/group-permissions.js +25 -95
- package/dist/data/group-resign.d.ts +38 -0
- package/dist/data/group-resign.js +71 -0
- package/dist/data/groups.d.ts +11 -0
- package/dist/data/groups.js +31 -13
- package/dist/data/index.d.ts +3 -0
- package/dist/data/index.js +3 -0
- package/dist/data/invites.d.ts +14 -0
- package/dist/data/orm/index.d.ts +1 -0
- package/dist/data/orm/index.js +1 -0
- package/dist/data/orm/sql.data-source.d.ts +2 -2
- package/dist/data/orm/sql.data-source.js +8 -9
- package/dist/data/orm/table-container.js +14 -8
- package/dist/data/orm/write-checks.d.ts +89 -0
- package/dist/data/orm/write-checks.js +115 -0
- package/dist/data/package-table-identity.d.ts +6 -0
- package/dist/data/package-table-identity.js +51 -0
- package/dist/data/package-version-resolver.d.ts +15 -0
- package/dist/data/package-version-resolver.js +58 -3
- package/dist/data/package-versions.d.ts +20 -14
- package/dist/data/package-versions.js +15 -9
- package/dist/data/packages.d.ts +6 -1
- package/dist/data/packages.js +15 -20
- package/dist/data/persistent-vars.js +2 -39
- package/dist/data/sync-recovery-queue.d.ts +4 -4
- package/dist/data/sync-recovery-queue.js +7 -1
- package/dist/data/tool-access-approvals.d.ts +3 -3
- package/dist/data/user-permissions.d.ts +33 -2
- package/dist/data/user-permissions.js +87 -10
- package/dist/data/users.d.ts +49 -12
- package/dist/data/users.js +21 -1
- package/dist/data/workflows.d.ts +1 -1
- package/dist/device/binary-peer-connection-v2.d.ts +8 -16
- package/dist/device/binary-peer-connection-v2.js +15 -31
- package/dist/device/connection.d.ts +35 -44
- package/dist/device/connection.js +188 -186
- package/dist/device/device.d.ts +1 -8
- package/dist/device/device.js +1 -30
- package/dist/device/frame-cipher.d.ts +1 -1
- package/dist/device/frame-cipher.js +1 -1
- package/dist/device/get-trust-level-fn.js +3 -6
- package/dist/device/socket.type.d.ts +6 -12
- package/dist/device-pairing/types.d.ts +26 -26
- package/dist/identity/user-row-change.d.ts +3 -1
- package/dist/identity/user-row-change.js +33 -18
- package/dist/invites/group-approval.js +23 -24
- package/dist/invites/invite-messages.d.ts +250 -28
- package/dist/invites/invite-token.d.ts +18 -0
- package/dist/invites/invite-token.js +2 -0
- package/dist/keys.d.ts +7 -0
- package/dist/keys.js +27 -0
- package/dist/package-installer/package-installer.d.ts +1 -1
- package/dist/package-installer/package-installer.js +8 -3
- package/dist/package-installer/package-propagation.d.ts +2 -0
- package/dist/package-installer/package-propagation.js +20 -38
- package/dist/package-installer/package-remote-checker.js +15 -3
- package/dist/package-loader/isolated-artifact.js +0 -2
- package/dist/package-loader/package-loader.js +6 -0
- package/dist/types/peer-device.d.ts +2 -0
- package/dist/types/workflow.d.ts +2 -2
- package/package.json +1 -1
- package/dist/data/package-permissions.d.ts +0 -14
- package/dist/data/package-permissions.js +0 -26
- package/dist/data/package-version-permissions.d.ts +0 -14
- package/dist/data/package-version-permissions.js +0 -30
- package/dist/device/binary-peer-connection.d.ts +0 -58
- package/dist/device/binary-peer-connection.js +0 -516
- package/dist/device/streamed-socket.d.ts +0 -23
- package/dist/device/streamed-socket.js +0 -255
|
@@ -8,12 +8,10 @@ export type GetTrustLevel = (deviceInfo: IDeviceInfo, registerNew?: boolean) =>
|
|
|
8
8
|
* Authenticated RPC connection between two Peers devices.
|
|
9
9
|
*
|
|
10
10
|
* The handshake (`doHandshake` on the client, `completeHandshake` on the
|
|
11
|
-
* server) authenticates both identities with signed, boxed messages
|
|
12
|
-
*
|
|
13
|
-
*
|
|
14
|
-
*
|
|
15
|
-
* Against a peer that does not advertise `frameCrypto` the connection falls
|
|
16
|
-
* back to the legacy behaviour and logs a warning.
|
|
11
|
+
* server) authenticates both identities with signed, boxed messages and agrees
|
|
12
|
+
* on per-connection frame-cipher keys (`frame-cipher.ts`), then arms the
|
|
13
|
+
* socket: every frame after the handshake is sealed. A peer that does not
|
|
14
|
+
* offer frame encryption (a build before 0.25.7) is refused.
|
|
17
15
|
*/
|
|
18
16
|
export declare class Connection {
|
|
19
17
|
readonly localDevice: Device;
|
|
@@ -21,23 +19,9 @@ export declare class Connection {
|
|
|
21
19
|
protected readonly getTrustLevel: GetTrustLevel;
|
|
22
20
|
private _verified;
|
|
23
21
|
private _remoteDeviceInfo;
|
|
24
|
-
/**
|
|
25
|
-
* @deprecated Legacy transport classification, only consulted when the frame
|
|
26
|
-
* cipher is not armed. Removed once legacy peers are no longer supported.
|
|
27
|
-
*/
|
|
28
|
-
secureLocal: boolean;
|
|
29
|
-
/** @deprecated See {@link Connection.secureLocal}. */
|
|
30
|
-
secureRemote: boolean;
|
|
31
|
-
/**
|
|
32
|
-
* Legacy per-message encryption override. Ignored once the frame cipher is
|
|
33
|
-
* armed. `"dont-encrypt-traffic-after-handshake"` is honoured only under
|
|
34
|
-
* `NODE_ENV=test`.
|
|
35
|
-
* @deprecated Removed with the legacy path.
|
|
36
|
-
*/
|
|
37
|
-
overrideEncryption?: "encrypt-traffic-regardless-of-protocol" | "dont-encrypt-traffic-after-handshake";
|
|
38
22
|
/** Trust assigned to the remote identity once the handshake completes. */
|
|
39
23
|
trustLevel: TrustLevel;
|
|
40
|
-
/** Server-side hook fired shortly after
|
|
24
|
+
/** Server-side hook fired shortly after the successful handshake reply has been sent. */
|
|
41
25
|
onHandshakeComplete: ((deviceInfo: IDeviceInfo) => void) | undefined;
|
|
42
26
|
/** RPC timeout for {@link Connection.emit}. */
|
|
43
27
|
timeoutMs: number;
|
|
@@ -53,34 +37,26 @@ export declare class Connection {
|
|
|
53
37
|
private pendingClientHandshake;
|
|
54
38
|
/** Server side: keys to arm for sending right after the handshake response frame. */
|
|
55
39
|
private pendingSendArm;
|
|
40
|
+
/** Bumped by every {@link Connection.reset}, so a handshake can tell it was cut short. */
|
|
41
|
+
private handshakeGeneration;
|
|
56
42
|
constructor(socket: ISocket, localDevice: Device, localDeviceServerAddresses?: string[] | undefined, getTrustLevel?: GetTrustLevel);
|
|
57
43
|
/** True once the remote identity has been authenticated by the handshake. */
|
|
58
44
|
get verified(): boolean;
|
|
59
45
|
/** True when every frame on this connection is sealed by the frame cipher. */
|
|
60
46
|
get frameCipherArmed(): boolean;
|
|
61
|
-
/**
|
|
62
|
-
* Whether to apply the legacy per-message envelope (sign + box) to RPC payloads.
|
|
63
|
-
*
|
|
64
|
-
* Always false once the frame cipher is armed: the frame layer already gives
|
|
65
|
-
* confidentiality, integrity, and sender binding for every frame. Otherwise
|
|
66
|
-
* (legacy peer) the transport classification below applies:
|
|
67
|
-
* - skipped when both sides agreed the transport is secure (`secureLocal && secureRemote`)
|
|
68
|
-
* - applied on plain `ws` / `http`
|
|
69
|
-
*/
|
|
70
|
-
get encryptTraffic(): boolean;
|
|
71
47
|
/** Copy of the authenticated remote device identity (empty before the handshake). */
|
|
72
48
|
get remoteDeviceInfo(): {
|
|
73
49
|
publicKey: string;
|
|
74
50
|
userId: string;
|
|
75
|
-
deviceId: string;
|
|
76
51
|
publicBoxKey: string;
|
|
52
|
+
deviceId: string;
|
|
77
53
|
userName?: string | undefined;
|
|
78
54
|
deviceName?: string | undefined;
|
|
79
55
|
};
|
|
80
56
|
/** Socket ID shared by both ends; also the frame-cipher AAD and HKDF salt. */
|
|
81
57
|
get connectionId(): string;
|
|
82
|
-
|
|
83
|
-
private
|
|
58
|
+
/** The socket's frame-cipher arming; throws when the transport can't encrypt frames. */
|
|
59
|
+
private requireFrameCipher;
|
|
84
60
|
private readonly handleCompleteHandshakeRPC;
|
|
85
61
|
/**
|
|
86
62
|
* Get connection throughput stats with calculated rates.
|
|
@@ -105,10 +81,15 @@ export declare class Connection {
|
|
|
105
81
|
exposeRPC<T extends Function>(fn: T): void;
|
|
106
82
|
/** Calls a remote RPC handler and resolves with its result (rejects on error or timeout). */
|
|
107
83
|
emit<T = any>(eventName: string, ...args: any): Promise<T>;
|
|
84
|
+
/**
|
|
85
|
+
* Sends one RPC. `onReply`, when given, runs synchronously while the reply frame is
|
|
86
|
+
* processed, before any later frame from the peer; its return value (or throw) settles
|
|
87
|
+
* the call.
|
|
88
|
+
*/
|
|
89
|
+
private request;
|
|
108
90
|
/**
|
|
109
91
|
* Registers an RPC handler. Events other than the handshake set are rejected
|
|
110
|
-
* until the connection is verified
|
|
111
|
-
* when {@link Connection.encryptTraffic} is true.
|
|
92
|
+
* until the connection is verified.
|
|
112
93
|
*/
|
|
113
94
|
on(eventName: string, handler: Function): void;
|
|
114
95
|
/** Removes RPC handlers for `eventName`, or all handlers when omitted. */
|
|
@@ -120,26 +101,36 @@ export declare class Connection {
|
|
|
120
101
|
*/
|
|
121
102
|
reset(): void;
|
|
122
103
|
/**
|
|
123
|
-
* Client side: builds the signed handshake (
|
|
124
|
-
*
|
|
125
|
-
* remote device.
|
|
104
|
+
* Client side: builds the signed handshake (offering frame encryption with a
|
|
105
|
+
* fresh ephemeral key) and boxes it to the remote device.
|
|
126
106
|
*/
|
|
127
107
|
initiateHandshake(serverAddress: string, remoteDeviceInfo?: IDeviceInfo): IDataBox;
|
|
128
108
|
/**
|
|
129
109
|
* Server side: verifies the client's handshake, resolves trust, and returns
|
|
130
|
-
* the (unsigned) response for the caller to sign and box.
|
|
131
|
-
* offered `frameCrypto` and this socket can arm a cipher, derives the frame
|
|
110
|
+
* the (unsigned) response for the caller to sign and box. Derives the frame
|
|
132
111
|
* keys, arms the receive direction immediately, and schedules the send
|
|
133
112
|
* direction to arm right after the response frame (see
|
|
134
|
-
* {@link Connection.handleCompleteHandshakeRPC}).
|
|
113
|
+
* {@link Connection.handleCompleteHandshakeRPC}). A client that does not
|
|
114
|
+
* offer frame encryption is refused.
|
|
135
115
|
*/
|
|
136
116
|
completeHandshake(boxedHandshake: IDataBox): Promise<IDeviceHandshake>;
|
|
137
117
|
/**
|
|
138
118
|
* Client side: runs the full handshake against `remoteAddress`. On success
|
|
139
|
-
* the remote identity is verified and
|
|
140
|
-
*
|
|
119
|
+
* the remote identity is verified and the frame cipher is armed in both
|
|
120
|
+
* directions before this resolves.
|
|
141
121
|
*/
|
|
142
122
|
doHandshake(remoteAddress: string): Promise<IDeviceHandshake>;
|
|
123
|
+
/**
|
|
124
|
+
* Client side: checks the server's handshake reply, arms the frame cipher, and records the
|
|
125
|
+
* verified identity. Runs synchronously while the reply frame is processed, so a sealed
|
|
126
|
+
* frame read right after it finds the cipher armed and the connection verified.
|
|
127
|
+
*/
|
|
128
|
+
private acceptHandshakeReply;
|
|
129
|
+
/**
|
|
130
|
+
* Throws when the connection was reset or closed after the handshake started: a handshake
|
|
131
|
+
* cut short must fail, not finish on a dead or reused connection.
|
|
132
|
+
*/
|
|
133
|
+
private assertHandshakeCurrent;
|
|
143
134
|
/**
|
|
144
135
|
* Resets this side and asks the remote to do the same. The remote call is a courtesy: a
|
|
145
136
|
* peer that is not a server has no `reset` handler, and a peer we just refused may already
|