@minca/core 0.1.11 → 0.1.13
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/identity/channel.d.ts +1 -1
- package/dist/identity/channel.d.ts.map +1 -1
- package/dist/identity/channel.js +1 -1
- package/dist/identity/channel.js.map +1 -1
- package/dist/inbox/inbox.d.ts +1 -9
- package/dist/inbox/inbox.d.ts.map +1 -1
- package/dist/inbox/inbox.js +3 -18
- package/dist/inbox/inbox.js.map +1 -1
- package/dist/inbox/index.d.ts +3 -3
- package/dist/inbox/index.d.ts.map +1 -1
- package/dist/inbox/index.js +2 -2
- package/dist/inbox/index.js.map +1 -1
- package/dist/index.d.ts +6 -4
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +2 -2
- package/dist/index.js.map +1 -1
- package/dist/network/introductions.d.ts +1 -1
- package/dist/network/introductions.d.ts.map +1 -1
- package/dist/network/mesh.d.ts +4 -2
- package/dist/network/mesh.d.ts.map +1 -1
- package/dist/network/mesh.js +31 -45
- package/dist/network/mesh.js.map +1 -1
- package/dist/network/peer-auth.d.ts +4 -0
- package/dist/network/peer-auth.d.ts.map +1 -1
- package/dist/network/peer-auth.js +9 -7
- package/dist/network/peer-auth.js.map +1 -1
- package/dist/network/relay-minca.d.ts +6 -0
- package/dist/network/relay-minca.d.ts.map +1 -0
- package/dist/network/relay-minca.js +146 -0
- package/dist/network/relay-minca.js.map +1 -0
- package/dist/network/relay-nostr.d.ts +10 -0
- package/dist/network/relay-nostr.d.ts.map +1 -0
- package/dist/network/relay-nostr.js +247 -0
- package/dist/network/relay-nostr.js.map +1 -0
- package/dist/network/relay-socket.d.ts +87 -0
- package/dist/network/relay-socket.d.ts.map +1 -0
- package/dist/network/{signaling.js → relay-socket.js} +201 -167
- package/dist/network/relay-socket.js.map +1 -0
- package/dist/network/relays.d.ts +87 -0
- package/dist/network/relays.d.ts.map +1 -0
- package/dist/network/relays.js +43 -0
- package/dist/network/relays.js.map +1 -0
- package/dist/network/remote-transport.d.ts +1 -1
- package/dist/network/remote-transport.d.ts.map +1 -1
- package/dist/network/remote-transport.js +6 -31
- package/dist/network/remote-transport.js.map +1 -1
- package/dist/network/rendezvous.d.ts +59 -0
- package/dist/network/rendezvous.d.ts.map +1 -0
- package/dist/network/rendezvous.js +380 -0
- package/dist/network/rendezvous.js.map +1 -0
- package/dist/network/rtc-transport.d.ts.map +1 -1
- package/dist/network/rtc-transport.js +32 -17
- package/dist/network/rtc-transport.js.map +1 -1
- package/dist/network/transport.d.ts +7 -5
- package/dist/network/transport.d.ts.map +1 -1
- package/dist/node/carrier.js +1 -1
- package/dist/node/carrier.js.map +1 -1
- package/dist/node/node.d.ts.map +1 -1
- package/dist/node/node.js +15 -24
- package/dist/node/node.js.map +1 -1
- package/dist/node/space-runtime.d.ts +4 -1
- package/dist/node/space-runtime.d.ts.map +1 -1
- package/dist/node/space-runtime.js +3 -6
- package/dist/node/space-runtime.js.map +1 -1
- package/dist/node/types.d.ts +3 -3
- package/dist/node/types.d.ts.map +1 -1
- package/dist/session/auth.d.ts +5 -6
- package/dist/session/auth.d.ts.map +1 -1
- package/dist/session/auth.js +4 -5
- package/dist/session/auth.js.map +1 -1
- package/dist/session/channel-room.d.ts.map +1 -1
- package/dist/session/channel-room.js +3 -2
- package/dist/session/channel-room.js.map +1 -1
- package/dist/session/connect-code.d.ts +69 -55
- package/dist/session/connect-code.d.ts.map +1 -1
- package/dist/session/connect-code.js +189 -89
- package/dist/session/connect-code.js.map +1 -1
- package/dist/session/connect.d.ts +11 -15
- package/dist/session/connect.d.ts.map +1 -1
- package/dist/session/connect.js +8 -21
- package/dist/session/connect.js.map +1 -1
- package/dist/session/index.d.ts +2 -2
- package/dist/session/index.d.ts.map +1 -1
- package/dist/session/index.js +1 -1
- package/dist/session/index.js.map +1 -1
- package/dist/space/roles.d.ts.map +1 -1
- package/dist/space/roles.js +4 -2
- package/dist/space/roles.js.map +1 -1
- package/docs/agents.md +59 -37
- package/docs/inbox.md +1 -1
- package/docs/node.md +32 -22
- package/docs/sign-in.md +5 -7
- package/package.json +2 -1
- package/dist/network/mailbox.d.ts +0 -45
- package/dist/network/mailbox.d.ts.map +0 -1
- package/dist/network/mailbox.js +0 -135
- package/dist/network/mailbox.js.map +0 -1
- package/dist/network/multi-signaling.d.ts +0 -41
- package/dist/network/multi-signaling.d.ts.map +0 -1
- package/dist/network/multi-signaling.js +0 -209
- package/dist/network/multi-signaling.js.map +0 -1
- package/dist/network/signaling.d.ts +0 -95
- package/dist/network/signaling.d.ts.map +0 -1
- package/dist/network/signaling.js.map +0 -1
|
@@ -1,61 +1,55 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* @module session/connect-code
|
|
3
|
-
* Connecting a program that has no browser of its own (`minca connect
|
|
4
|
-
*
|
|
5
|
-
* (
|
|
6
|
-
*
|
|
7
|
-
*
|
|
8
|
-
*
|
|
9
|
-
*
|
|
10
|
-
*
|
|
11
|
-
* sees the code later.
|
|
3
|
+
* Connecting a program that has no browser of its own (`minca connect`) to an
|
|
4
|
+
* account. The program makes a one-time code and opens the account home with
|
|
5
|
+
* it (`<home>/connect#mc_…`). The two meet on the code's channel
|
|
6
|
+
* (`identity/channel.ts`, `CODE_CHANNEL`): the home says where it lives, the
|
|
7
|
+
* program says which key it holds, the person signs in and allows it there,
|
|
8
|
+
* and the home hands back a records-only note made out to the program's key.
|
|
9
|
+
* The relay learns and changes nothing, and a recording of the room is no use
|
|
10
|
+
* to someone who sees the code later.
|
|
12
11
|
*/
|
|
13
12
|
import type { PeerTransport } from '../network/transport.js';
|
|
14
|
-
import { type AppKey, type Grant } from './connect.js';
|
|
13
|
+
import { type AppKey, type Grant, type IncomingRequest } from './connect.js';
|
|
15
14
|
/** Who is asking, as the program said */
|
|
16
15
|
export interface CodeAsking {
|
|
17
16
|
/** The program's key: the note is made out to it */
|
|
18
17
|
readonly did: string;
|
|
19
18
|
/** What the program calls itself, e.g. "Agent on leifs-macbook". Shown, not trusted. */
|
|
20
19
|
readonly name: string;
|
|
21
|
-
/** The key's proof that it holds itself, for
|
|
20
|
+
/** The key's proof that it holds itself, for a records-only note (`keyProof`, `via: code`, the home's origin) */
|
|
22
21
|
readonly proof: string;
|
|
23
|
-
/**
|
|
24
|
-
* Whether it asks for a note that grants records only. Only a request: the
|
|
25
|
-
* app decides what to ask the home for. The proof binds what the program
|
|
26
|
-
* asked, so an app that won't give that denies it.
|
|
27
|
-
*/
|
|
28
|
-
readonly recordsOnly: boolean;
|
|
29
22
|
}
|
|
30
23
|
/** Where the two sides meet */
|
|
31
24
|
interface CodeNetwork {
|
|
32
|
-
/** Relays to meet on. The
|
|
25
|
+
/** Relays to meet on. The home's and the program's must share one. */
|
|
33
26
|
readonly relays: ReadonlyArray<string>;
|
|
34
27
|
/** A transport instead of WebRTC — for tests */
|
|
35
28
|
readonly transport?: (did: string) => PeerTransport;
|
|
36
29
|
}
|
|
37
|
-
/**
|
|
38
|
-
export
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
/** The start of the fingerprint of the account the app is signed in to: a grant must come from it */
|
|
42
|
-
readonly account: Uint8Array;
|
|
43
|
-
}
|
|
44
|
-
/** A new code for the app signed in to `account`: `mc_`, 128 random bits and the account's fingerprint */
|
|
45
|
-
export declare function newConnectCode(account: string): Promise<string>;
|
|
30
|
+
/** A new code: `mc_` and 128 random bits */
|
|
31
|
+
export declare function newConnectCode(): string;
|
|
32
|
+
/** Where the person allows a program: the home's connect page, with the code after `#` so it never reaches a server */
|
|
33
|
+
export declare const connectCodeUrl: (home: string, code: string) => string;
|
|
46
34
|
/**
|
|
47
|
-
*
|
|
48
|
-
*
|
|
35
|
+
* The secret a code holds, from anything it is found in: the code, or the
|
|
36
|
+
* link the program opened.
|
|
49
37
|
* @throws When there is no code in it
|
|
50
38
|
*/
|
|
51
|
-
export declare function readConnectCode(input: string):
|
|
39
|
+
export declare function readConnectCode(input: string): Uint8Array;
|
|
40
|
+
/** The code in a link the home was opened at, or null: `#mc_…` */
|
|
41
|
+
export declare function connectCodeIn(hash: string): string | null;
|
|
52
42
|
export type ConnectCodeStage = {
|
|
53
43
|
readonly kind: 'waiting';
|
|
54
44
|
}
|
|
55
|
-
/**
|
|
45
|
+
/**
|
|
46
|
+
* The program is there. Show `check`, for the person to give the program,
|
|
47
|
+
* then sign it a records-only note and `allow` it, or `deny`.
|
|
48
|
+
*/
|
|
56
49
|
| {
|
|
57
50
|
readonly kind: 'asking';
|
|
58
51
|
readonly asking: CodeAsking;
|
|
52
|
+
readonly check: string;
|
|
59
53
|
allow(grant: Grant): Promise<void>;
|
|
60
54
|
deny(reason?: string): void;
|
|
61
55
|
} | {
|
|
@@ -65,48 +59,68 @@ export type ConnectCodeStage = {
|
|
|
65
59
|
readonly kind: 'failed';
|
|
66
60
|
readonly reason: string;
|
|
67
61
|
};
|
|
68
|
-
|
|
69
|
-
|
|
62
|
+
/**
|
|
63
|
+
* Answers the program that opened the home with a code. Keep it running while
|
|
64
|
+
* the page is open: the first program whose sealed ask opens is the one asked
|
|
65
|
+
* about, and nobody after it.
|
|
66
|
+
*
|
|
67
|
+
* @param options.code The code from the link the home was opened at
|
|
68
|
+
* @param options.origin Where this home lives: the program's proof names it. Default: this page's.
|
|
69
|
+
* @returns A way to stop listening; the code stops working
|
|
70
|
+
*/
|
|
71
|
+
export declare function answerConnectCode(options: CodeNetwork & {
|
|
70
72
|
readonly code: string;
|
|
71
|
-
|
|
73
|
+
readonly origin?: string;
|
|
74
|
+
/** How long to wait for the program to ask. Default 60 s: it is waiting when its link opens, unless it has gone or another home answered it. */
|
|
75
|
+
readonly findTimeoutMs?: number;
|
|
76
|
+
}, onStage: (stage: ConnectCodeStage) => void): Promise<{
|
|
72
77
|
stop(): void;
|
|
73
|
-
}
|
|
78
|
+
}>;
|
|
74
79
|
/**
|
|
75
|
-
*
|
|
76
|
-
*
|
|
77
|
-
*
|
|
78
|
-
*
|
|
79
|
-
*
|
|
80
|
+
* The account home's connect page, opened at a code: answers the program and
|
|
81
|
+
* hands its ask to the same approval as an app's, as a request for records in
|
|
82
|
+
* the whole account. `approve` sends the note, `deny` says no. `onAnswered`
|
|
83
|
+
* says how it went, since this page was opened by a person, not an app, and
|
|
84
|
+
* stays open: allowed only once the program says it has the note.
|
|
80
85
|
*
|
|
81
|
-
* @
|
|
82
|
-
* @param options.origin Where this app lives, as the home will see it. Default: this page's.
|
|
86
|
+
* @returns The program's request, or null when none came
|
|
83
87
|
*/
|
|
84
|
-
export declare function
|
|
85
|
-
readonly
|
|
88
|
+
export declare function receiveConnectCode(options: CodeNetwork & {
|
|
89
|
+
readonly code: string;
|
|
86
90
|
readonly origin?: string;
|
|
87
|
-
|
|
91
|
+
readonly onAnswered?: (answer: {
|
|
92
|
+
readonly allowed: boolean;
|
|
93
|
+
}) => void;
|
|
94
|
+
}): Promise<IncomingRequest | null>;
|
|
88
95
|
/**
|
|
89
|
-
* Connects this program with
|
|
96
|
+
* Connects this program with a code it made ({@link newConnectCode}): open
|
|
97
|
+
* {@link connectCodeUrl} for the person, then wait here for their home.
|
|
90
98
|
*
|
|
91
|
-
* @param params.
|
|
99
|
+
* @param params.home The account home it opened: only a peer saying it is that home is asked, and the grant keeps it
|
|
100
|
+
* @param params.key This program's key — the note will be made out to it, and it signs the proof for the home's origin
|
|
92
101
|
* @param params.name What the person sees, e.g. "Agent on leifs-macbook"
|
|
93
|
-
* @param params.
|
|
94
|
-
* @
|
|
95
|
-
* @
|
|
96
|
-
* @throws When the code is wrong or stale, the person says no, or nothing answers in time
|
|
102
|
+
* @param params.onWaiting Told once the home has heard, and the person is deciding, with where the home lives
|
|
103
|
+
* @returns The grant, checked: a records-only note for this key, with `home` the one it opened
|
|
104
|
+
* @throws When the person says no, or nothing answers in time
|
|
97
105
|
*/
|
|
98
106
|
export declare function connectWithCode(params: {
|
|
99
107
|
readonly code: string;
|
|
108
|
+
readonly home: string;
|
|
100
109
|
readonly key: AppKey;
|
|
101
110
|
readonly name: string;
|
|
102
|
-
readonly recordsOnly: boolean;
|
|
103
111
|
readonly network: CodeNetwork;
|
|
104
|
-
readonly onWaiting?: (
|
|
112
|
+
readonly onWaiting?: (home: {
|
|
105
113
|
readonly origin: string;
|
|
106
114
|
}) => void;
|
|
107
|
-
/**
|
|
115
|
+
/**
|
|
116
|
+
* Asks the person for the check code the home shows, until `matches` says
|
|
117
|
+
* it does; rejecting gives up. The note is kept only once it matches: so a
|
|
118
|
+
* home the person never saw can't connect it.
|
|
119
|
+
*/
|
|
120
|
+
readonly check: (matches: (typed: string) => boolean) => Promise<void>;
|
|
121
|
+
/** How long to wait for the home to open at all. Default 10 minutes: the person may make an account first. */
|
|
108
122
|
readonly findTimeoutMs?: number;
|
|
109
|
-
/** How long the person has to decide. Default
|
|
123
|
+
/** How long the person has to decide once it has. Default 30 minutes. */
|
|
110
124
|
readonly decideTimeoutMs?: number;
|
|
111
125
|
}): Promise<Grant>;
|
|
112
126
|
export {};
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"connect-code.d.ts","sourceRoot":"","sources":["../../src/session/connect-code.ts"],"names":[],"mappings":"AAAA
|
|
1
|
+
{"version":3,"file":"connect-code.d.ts","sourceRoot":"","sources":["../../src/session/connect-code.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;GAUG;AACH,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,yBAAyB,CAAC;AAU7D,OAAO,EAAwB,KAAK,MAAM,EAAE,KAAK,KAAK,EAAE,KAAK,eAAe,EAAE,MAAM,cAAc,CAAC;AAuBnG,yCAAyC;AACzC,MAAM,WAAW,UAAU;IACzB,oDAAoD;IACpD,QAAQ,CAAC,GAAG,EAAE,MAAM,CAAC;IACrB,wFAAwF;IACxF,QAAQ,CAAC,IAAI,EAAE,MAAM,CAAC;IACtB,iHAAiH;IACjH,QAAQ,CAAC,KAAK,EAAE,MAAM,CAAC;CACxB;AAKD,+BAA+B;AAC/B,UAAU,WAAW;IACnB,sEAAsE;IACtE,QAAQ,CAAC,MAAM,EAAE,aAAa,CA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