@fkn/lib 0.9.43 → 0.9.45
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/{api-H1TzWitc.d.ts → api-Cuf3ynZX.d.ts} +83 -30
- package/api.d.ts +2 -2
- package/attach-policy.d.ts +11 -15
- package/cloud/dns.d.ts +1 -1
- package/cloud/fetch.d.ts +1 -1
- package/cloud/fs/promises.d.ts +1 -1
- package/cloud/fs.d.ts +3 -3
- package/cloud/net.d.ts +1 -1
- package/cloud-CKCrMMB_.cjs +1 -0
- package/cloud-CVWGyZRT.js +559 -0
- package/{cloud-Y0FzWpFT.d.ts → cloud-KBzjWzt1.d.ts} +4 -4
- package/cloud.cjs +1 -1
- package/cloud.d.ts +4 -4
- package/cloud.js +1 -1
- package/{contract-DJxGa8lb.d.ts → contract-DP_jc5pZ.d.ts} +161 -27
- package/contract.cjs +1 -1
- package/contract.d.ts +4 -4
- package/contract.js +9 -3
- package/dgram.d.ts +7 -14
- package/dns.d.ts +1 -1
- package/extension-Dmnh5pcs.js +94 -0
- package/{extension-BtDg-F2g.d.ts → extension-X8cnvZej.d.ts} +19 -37
- package/extension-YBe6Q6r_.cjs +1 -0
- package/extension.cjs +1 -1
- package/extension.d.ts +2 -2
- package/extension.js +3 -3
- package/fs/promises.d.ts +1 -1
- package/{fs-D0MMRnHC.d.ts → fs-KA1Mgisv.d.ts} +2 -2
- package/fs.d.ts +3 -3
- package/http.d.ts +1 -1
- package/{index-Cgnfjh9o.d.ts → index-C8Y-YHrU.d.ts} +42 -58
- package/{index-D2lvaQDs.d.ts → index-DKr9L2RI.d.ts} +6 -11
- package/index.cjs +1 -1
- package/index.d.ts +35 -38
- package/index.js +12 -12
- package/lib-D4uqe_rb.cjs +53 -0
- package/{lib-C3UwxjVs.js → lib-H5-e2A1h.js} +483 -468
- package/messages-d7pvCXPn.d.ts +34 -0
- package/messages.d.ts +1 -1
- package/{net-BOswhyfE.d.ts → net-eyWUIVn2.d.ts} +3 -19
- package/net.d.ts +1 -1
- package/package.json +1 -1
- package/packages.d.ts +1 -1
- package/{proxy-ylK5lpw8.d.ts → proxy-8Zp-G5da.d.ts} +2 -2
- package/rooms.cjs +1 -1
- package/rooms.d.ts +94 -15
- package/rooms.js +118 -90
- package/{storage-BVr2Rb-d.d.ts → storage-BLBsmkmp.d.ts} +14 -28
- package/{wire-Gbo-D74t.d.ts → wire-BwA4JjZH.d.ts} +6 -12
- package/wire.d.ts +1 -1
- package/cloud-Bx64HSkQ.cjs +0 -1
- package/cloud-D-vDUzzx.js +0 -552
- package/extension-CzZn0bY2.js +0 -94
- package/extension-DvFf7uoG.cjs +0 -1
- package/lib-fqQfEPk6.cjs +0 -53
- package/messages-CRcziTuC.d.ts +0 -46
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
//#region src/messages.d.ts
|
|
2
|
+
declare const E2E_LOCKED_MESSAGE = "fkn:e2e-locked";
|
|
3
|
+
declare const E2E_STALE_EPOCH_MESSAGE = "fkn:e2e-stale-epoch: this file is encrypted under a previous key you reset";
|
|
4
|
+
declare const E2E_INTEGRITY_MESSAGE = "fkn:e2e-integrity: stored data failed its integrity check";
|
|
5
|
+
/** sealed in an envelope older than v3; distinct from integrity, since the bytes are intact */
|
|
6
|
+
declare const E2E_RETIRED_FORMAT_MESSAGE = "fkn:e2e-retired-format: stored data is in a format this version no longer opens";
|
|
7
|
+
/**
|
|
8
|
+
* The error code for "there is no object at this path", so a caller tests absence instead of parsing
|
|
9
|
+
* a message. osra drops custom codes at the SharedWorker boundary, so storage.ts's rethrow re-mints
|
|
10
|
+
* it from the message on the app side.
|
|
11
|
+
*/
|
|
12
|
+
declare const STORAGE_NOT_FOUND = "FKN_STORAGE_NOT_FOUND";
|
|
13
|
+
/**
|
|
14
|
+
* The error code for "the api never answered". A caller that relaxes anything when the server is
|
|
15
|
+
* unreachable must never relax it on an answered error: an answered 500 lands exactly when a key
|
|
16
|
+
* rotation or a setting flip may be propagating. Across the SharedWorker hop the message prefix is
|
|
17
|
+
* the wire contract, since osra drops the code; same-realm callers can test the code.
|
|
18
|
+
*/
|
|
19
|
+
declare const STORAGE_UNREACHABLE = "FKN_API_UNREACHABLE";
|
|
20
|
+
/**
|
|
21
|
+
* The account pin's refusals, as message prefixes the broker throws. `ACCOUNT_CHANGED_MESSAGE`: the
|
|
22
|
+
* signed-in account is not the one the pin was taken under. `ACCOUNT_PIN_INVALID_MESSAGE`: the api
|
|
23
|
+
* could not read the pin. `ACCOUNT_PIN_UNSUPPORTED_MESSAGE`: a hop (the broker document or its shared
|
|
24
|
+
* worker) predates the pin, so the call was refused rather than sent unpinned. None is a sign-out.
|
|
25
|
+
*/
|
|
26
|
+
declare const ACCOUNT_CHANGED_MESSAGE = "fkn:account-changed";
|
|
27
|
+
declare const ACCOUNT_PIN_INVALID_MESSAGE = "fkn:account-pin-invalid";
|
|
28
|
+
declare const ACCOUNT_PIN_UNSUPPORTED_MESSAGE = "fkn:account-pin-unsupported";
|
|
29
|
+
/** The code of `StorageAccountChangedError`: a call made under one account was refused under another. */
|
|
30
|
+
declare const STORAGE_ACCOUNT_CHANGED = "FKN_ACCOUNT_CHANGED";
|
|
31
|
+
/** The code of `StorageAccountPinUnsupportedError`: the broker cannot pin calls, so none was sent. */
|
|
32
|
+
declare const STORAGE_ACCOUNT_PIN_UNSUPPORTED = "FKN_ACCOUNT_PIN_UNSUPPORTED";
|
|
33
|
+
//#endregion
|
|
34
|
+
export { E2E_LOCKED_MESSAGE as a, STORAGE_ACCOUNT_CHANGED as c, STORAGE_UNREACHABLE as d, E2E_INTEGRITY_MESSAGE as i, STORAGE_ACCOUNT_PIN_UNSUPPORTED as l, ACCOUNT_PIN_INVALID_MESSAGE as n, E2E_RETIRED_FORMAT_MESSAGE as o, ACCOUNT_PIN_UNSUPPORTED_MESSAGE as r, E2E_STALE_EPOCH_MESSAGE as s, ACCOUNT_CHANGED_MESSAGE as t, STORAGE_NOT_FOUND as u };
|
package/messages.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as E2E_LOCKED_MESSAGE, c as STORAGE_ACCOUNT_CHANGED, d as STORAGE_UNREACHABLE, i as E2E_INTEGRITY_MESSAGE, l as STORAGE_ACCOUNT_PIN_UNSUPPORTED, n as ACCOUNT_PIN_INVALID_MESSAGE, o as E2E_RETIRED_FORMAT_MESSAGE, r as ACCOUNT_PIN_UNSUPPORTED_MESSAGE, s as E2E_STALE_EPOCH_MESSAGE, t as ACCOUNT_CHANGED_MESSAGE, u as STORAGE_NOT_FOUND } from "./messages-
|
|
1
|
+
import { a as E2E_LOCKED_MESSAGE, c as STORAGE_ACCOUNT_CHANGED, d as STORAGE_UNREACHABLE, i as E2E_INTEGRITY_MESSAGE, l as STORAGE_ACCOUNT_PIN_UNSUPPORTED, n as ACCOUNT_PIN_INVALID_MESSAGE, o as E2E_RETIRED_FORMAT_MESSAGE, r as ACCOUNT_PIN_UNSUPPORTED_MESSAGE, s as E2E_STALE_EPOCH_MESSAGE, t as ACCOUNT_CHANGED_MESSAGE, u as STORAGE_NOT_FOUND } from "./messages-d7pvCXPn.js";
|
|
2
2
|
export { ACCOUNT_CHANGED_MESSAGE, ACCOUNT_PIN_INVALID_MESSAGE, ACCOUNT_PIN_UNSUPPORTED_MESSAGE, E2E_INTEGRITY_MESSAGE, E2E_LOCKED_MESSAGE, E2E_RETIRED_FORMAT_MESSAGE, E2E_STALE_EPOCH_MESSAGE, STORAGE_ACCOUNT_CHANGED, STORAGE_ACCOUNT_PIN_UNSUPPORTED, STORAGE_NOT_FOUND, STORAGE_UNREACHABLE };
|
|
@@ -1,6 +1,6 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { o as TcpSocketOption } from "./wire-
|
|
3
|
-
import "./api-
|
|
1
|
+
import { Dt as TcpSocketListenerResult, X as Resolvers, kt as TcpSocketResult } from "./contract-DP_jc5pZ.js";
|
|
2
|
+
import { o as TcpSocketOption } from "./wire-BwA4JjZH.js";
|
|
3
|
+
import "./api-Cuf3ynZX.js";
|
|
4
4
|
import { AddressInfo, ListenOptions, Server, ServerOpts, Socket, SocketConnectOpts, SocketConstructorOpts } from "net";
|
|
5
5
|
import { DuplexOptions, Stream } from "stream";
|
|
6
6
|
import { EventEmitter } from "events";
|
|
@@ -32,19 +32,6 @@ declare class Socket$2 extends Stream.Duplex implements Socket {
|
|
|
32
32
|
constructor(options?: SocketConstructorOpts & DuplexOptions & {
|
|
33
33
|
connection?: ReturnType<WebVpnTcpSocket>;
|
|
34
34
|
});
|
|
35
|
-
/**
|
|
36
|
-
* `endpoints` publishes the four addresses SYNCHRONOUSLY, for a socket whose connection is
|
|
37
|
-
* already in hand.
|
|
38
|
-
*
|
|
39
|
-
* Node fills an accepted socket's endpoints in before it emits 'connection', and consumers read
|
|
40
|
-
* them right there in the handler. Without this the values only land in the `.then()` below, one
|
|
41
|
-
* microtask after the emit, and until then every address getter on this class THROWS
|
|
42
|
-
* `Socket is not connected` rather than answering undefined, so a caller reading them the way
|
|
43
|
-
* Node allows gets an exception and, if it wrapped all four in one try block, loses every one of
|
|
44
|
-
* them. libtorrent-wasm's socket shim does exactly that on accept, and libtorrent drops a peer it
|
|
45
|
-
* cannot name with no alert and no reply, which reads from outside as the relay never delivering
|
|
46
|
-
* the connection at all.
|
|
47
|
-
*/
|
|
48
35
|
_busyRelease?: () => void;
|
|
49
36
|
__webvpn_tcp_socket_init__(connection: ReturnType<WebVpnTcpSocket>, endpoints?: Awaited<ReturnType<WebVpnTcpSocket>>): Promise<(TcpSocketResult & {
|
|
50
37
|
reader: ReadableStreamDefaultReader<Uint8Array>;
|
|
@@ -95,9 +82,6 @@ declare class Socket$2 extends Stream.Duplex implements Socket {
|
|
|
95
82
|
timeout?: number | undefined;
|
|
96
83
|
}
|
|
97
84
|
interface EventEmitterOptions {
|
|
98
|
-
/**
|
|
99
|
-
* Enables automatic capturing of promise rejection.
|
|
100
|
-
*/
|
|
101
85
|
captureRejections?: boolean | undefined;
|
|
102
86
|
}
|
|
103
87
|
declare class Server$1 extends EventEmitter implements Server {
|
package/net.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import { a as createConnection, c as isIP, i as connect, l as isIPv4, n as Socket, o as createServer, r as _default, t as Server, u as isIPv6 } from "./net-
|
|
1
|
+
import { a as createConnection, c as isIP, i as connect, l as isIPv4, n as Socket, o as createServer, r as _default, t as Server, u as isIPv6 } from "./net-eyWUIVn2.js";
|
|
2
2
|
export { Server, Socket, _default, _default as default, connect, createConnection, createServer, isIP, isIPv4, isIPv6 };
|
package/package.json
CHANGED
package/packages.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { E as InstalledPackage, F as
|
|
1
|
+
import { B as Placement, E as InstalledPackage, F as PackageQuery, I as PackageResult, L as PackagesErrorCode, T as InstallOptions, Tt as SurfaceRect, Y as Radii, m as ConnectOptions, z as PickOptions } from "./contract-DP_jc5pZ.js";
|
|
2
2
|
import { Remote } from "osra";
|
|
3
3
|
declare namespace packages_d_exports {
|
|
4
4
|
export { AppConnectOptions, Connect, ConnectOptions, ConnectPayload, IncomingConnection, IncomingConnectionInfo, InstallOptions, InstalledPackage, MountOptions, MountedPackage, PackageConnection, PackageQuery, PackageResult, PackageView, PackagesError, PackagesErrorCode, PickOptions, Placement, Radii, RawPackageConnection, ShowOptions, SurfaceRect, attach, connect, hide, install, isVisible, list, mount, onConnect, onVisibilityChange, pick, search, show, uninstall };
|
|
@@ -1,5 +1,5 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import "./api-
|
|
1
|
+
import { X as Resolvers } from "./contract-DP_jc5pZ.js";
|
|
2
|
+
import "./api-Cuf3ynZX.js";
|
|
3
3
|
//#region src/proxy.d.ts
|
|
4
4
|
type ProxyFetch = Resolvers['cloud']['fetch'];
|
|
5
5
|
type FetchParameters = Parameters<ProxyFetch>;
|
package/rooms.cjs
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api--LOXTOpv.cjs"),n=require("./busy-Dv8wzE5M.cjs"),r=require("./contract.cjs");var i=e.t({available:()=>
|
|
1
|
+
Object.defineProperty(exports,Symbol.toStringTag,{value:`Module`});const e=require("./rolldown-runtime-BIInC43l.cjs"),t=require("./api--LOXTOpv.cjs"),n=require("./busy-Dv8wzE5M.cjs"),r=require("./contract.cjs");var i=e.t({available:()=>h,create:()=>_,join:()=>v,open:()=>g}),a={wrongKey:`rooms: wrong room key`,inviteNoKey:`rooms: the invite carries no key`,badName:`rooms: the name is not one a room can have`,badKeyOption:`rooms: the key is not 32 bytes base64url`,noSuchMember:`rooms: no such member`,noSuchMessage:`rooms: no such message`,roomFull:`rooms: the room is full`,tooManyConnections:`rooms: too many connections`,tooManyBlocks:`rooms: too many blocks`,tooManyClaims:`rooms: too many claims`,mailboxFull:`rooms: the mailbox is full`,outOfStorage:`rooms: the owner is out of storage`,outOfQuota:`rooms: out of daily bandwidth`,blocked:`rooms: you are blocked from this room`,cannotSend:`rooms: you cannot send here`,permissionDenied:`rooms: permission denied`,notOwner:`rooms: not the room owner`,ownerNotRemovable:`rooms: the owner cannot be removed`,ownerKeepsEvery:`rooms: the owner keeps every permission`,removeYourself:`rooms: you cannot remove yourself`,needsAccount:`rooms: claiming needs an account`,needsPremium:`rooms: claiming needs premium`,nameClaimed:`rooms: the name is claimed`,notClaimed:`rooms: the room is not claimed`,noMailbox:`rooms: the room keeps no messages`,badLimit:`rooms: the limit is out of range`,badDescription:`rooms: the description is not one a claim can carry`,notClaimer:`rooms: only the app that claimed the room can describe it`,notReleaser:`rooms: only the app that claimed the room can release it`,notClaimingApp:`rooms: only the app that claimed the room can change it`,badTemporary:`rooms: the temporary duration is not one a claim can carry`,notTemporaryClaimer:`rooms: only the app that claimed the room can set when it expires`,temporaryUnavailable:`rooms: temporary claims are not available`,mailboxUnavailable:`rooms: the mailbox switch is not available`,tooFast:`rooms: sending too fast`,tooLarge:`rooms: the message is too large`,unavailable:`rooms: rooms are unavailable`,notEnabled:`rooms: rooms are not available`,alreadyJoined:`rooms: already joined`,notJoined:`rooms: not joined`,malformed:`rooms: malformed frame`,ended:`rooms: the room has ended`},o=(e,t)=>Object.assign(Error(t),{code:e}),s=e=>e instanceof Error&&typeof e.code==`string`,c={send:!0,receive:!0,maxMessageBytes:262144},l=()=>({messages:0,bytes:0,cap:5e8,archived:!1}),u=async()=>{if(!t.l)return;let e=(await t.s(`a room`).catch(()=>void 0))?.rooms;return typeof e?.open==`function`?e:void 0},d=()=>{throw o(`unavailable`,a.unavailable)},f=e=>e===`blocked`?`blocked`:e===`not-found`?`ended`:`unavailable`,p=e=>{if(e!==void 0&&e!==!1)return e===!0?r.ROOM_TEMPORARY_MS.default:typeof e!=`number`||!Number.isInteger(e)?null:e>=r.ROOM_TEMPORARY_MS.min&&e<=r.ROOM_TEMPORARY_MS.max?e:null},m=async e=>{let r=e.invite,i=e,u=0,d=e.self,m=e.owner,h=e.claimed,g=e.mailbox,_=0,v=await e.defaults().catch(()=>c),y=!1,b=new Set,x=new Set,S=n.t(`room`),C=()=>{},w=()=>{},T=new Promise(e=>{w=e}),E=e=>{let t=[...x];x.clear();for(let n of t)try{n(e)}catch{}},D=e=>{y||(y=!0,C(),b.clear(),S(),E(o(`closed`,a.ended)),w({reason:e}))},O=e=>{if(y)return;let t=e;if(t.type===`defaults`&&(v=t.defaults),t.type===`permissions`&&t.id===d.id&&(d={id:d.id,permissions:t.permissions,maxMessageBytes:t.maxMessageBytes}),t.type===`claim`){_+=1;let e=t.claimed&&t.mailbox!==!1;t={type:`claim`,claimed:t.claimed,owner:t.owner,mailbox:e},h=t.claimed,m=t.owner,g=e?l():null}for(let e of[...b])try{e(t)}catch{}},k=(e,t)=>{Promise.resolve(e.on(O)).catch(()=>{}),Promise.resolve(e.closed).then(e=>{t===u&&D(e.reason)},()=>{})},A=async(e,t)=>{if(typeof e?.join!=`function`)return D(`unavailable`);let n=await e.join(r).catch(()=>void 0);if(y||t!==u)return;if(!n)return D(`unavailable`);if(`error`in n)return D(f(n.error));if(n.self.id!==d.id)return Promise.resolve(n.leave()).catch(()=>{}),D(`unavailable`);i=n,d=n.self,m=n.owner,h=n.claimed,g=n.mailbox,k(n,t);let a=await n.defaults().catch(()=>void 0);a&&!y&&t===u&&(v=a)};C=t.u((e,t)=>{let n=u;u=t,!(y||n===0||n===t)&&(E(o(`unavailable`,a.unavailable)),A(e.rooms,t))}),k(e,u);let j=async e=>{if(y)throw o(`closed`,a.ended);let t=()=>{},n=new Promise((e,n)=>{t=n});x.add(t);try{return await Promise.race([Promise.resolve(e(i)),n])}catch(e){throw s(e)?e:o(`unavailable`,a.unavailable)}finally{x.delete(t)}},M=async e=>{let t=await j(e);if(`error`in t)throw o(t.error,t.message)},N=async e=>{let t=await j(e);if(typeof t==`object`&&t&&`error`in t)throw o(t.error,t.message);return t};return{id:e.id,name:e.name,key:e.key,invite:r,get self(){return d},get owner(){return m},get claimed(){return h},get mailbox(){return g},defaults:()=>v,members:()=>j(e=>e.members()),send:e=>M(t=>t.send(e)),edit:(e,t)=>M(n=>n.edit(e,t)),delete:(e,t)=>M(n=>n.delete(e,t)),backlog:(e,t)=>N(n=>n.backlog(e,t)),setDefault:(e,t)=>M(n=>n.setDefault(e,t)),limit:(e,t)=>M(n=>n.limit(e,t)),grant:(e,t)=>M(n=>n.grant(e,t)),revoke:(e,t)=>M(n=>n.revoke(e,t)),remove:e=>M(t=>t.remove(e)),block:e=>M(t=>t.block(e)),unblock:e=>M(t=>t.unblock(e)),claim:async e=>{let t=e?.description;if(t!==void 0&&typeof t!=`string`)throw o(`invalid`,a.badDescription);let n=p(e?.temporary);if(n===null)throw o(`invalid`,a.badTemporary);let r=e?.mailbox;if(r!==void 0&&typeof r!=`boolean`)throw o(`invalid`,a.malformed);let i={...t===void 0?{}:{description:t},...n===void 0?{}:{temporary:n},...r===void 0?{}:{mailbox:r}};return Object.keys(i).length===0?M(e=>e.claim()):M(e=>{if(n!==void 0&&e.temporaryClaims!==!0)throw o(`unavailable`,a.temporaryUnavailable);if(r===!1&&e.mailboxSwitch!==!0)throw o(`unavailable`,a.mailboxUnavailable);return e.claim(i)})},setMailbox:async e=>{if(typeof e!=`boolean`)throw o(`invalid`,a.malformed);let t=_;await M(t=>{if(t.mailboxSwitch!==!0)throw o(`unavailable`,a.mailboxUnavailable);return t.setMailbox(e)}),_===t&&(e?g===null&&(g=l()):g=null)},release:()=>M(e=>e.release()),usage:async()=>{let e=await N(e=>e.usage());return g=e,e},on:async e=>y?()=>{}:(b.add(e),()=>{b.delete(e)}),leave:async()=>{await Promise.resolve(i.leave()).catch(()=>{}),D(`left`)},closed:T}},h=async()=>{let e=await u();return e?e.available().catch(()=>!1):!1},g=async(e,t)=>{if(typeof e!=`string`||e.length===0||e.length>72)throw o(`invalid`,a.badName);let n=await u();if(!n)throw o(`unavailable`,a.unavailable);let r=await n.open(e,t).catch(d);if(`error`in r)throw o(r.error,r.message);return m(r)},_=async e=>{let t=await u();if(!t)throw o(`unavailable`,a.unavailable);let n=await t.create(e).catch(d);if(`error`in n)throw o(n.error,n.message);return m(n)},v=async(e,t)=>{let n=typeof e==`string`?e.indexOf(`.`):-1;if(n<=0||n===e.length-1)throw o(`invalid`,a.inviteNoKey);let r=await u();if(!r)throw o(`unavailable`,a.unavailable);let i=await r.join(e,t).catch(d);if(`error`in i)throw o(i.error,i.message);return m(i)};exports.available=h,exports.create=_,exports.join=v,exports.open=g,Object.defineProperty(exports,"t",{enumerable:!0,get:function(){return i}});
|
package/rooms.d.ts
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { $ as RoomCreateOptions, Q as RoomClaimOptions, Z as RoomBacklog, at as RoomMailbox, ct as RoomOpenOptions, dt as RoomsErrorCode, et as RoomDefaults, it as RoomJoinOptions, lt as RoomPermission, nt as RoomEvent, ot as RoomMember, st as RoomMessage, tt as RoomEnd, ut as RoomPermissions } from "./contract-DP_jc5pZ.js";
|
|
2
2
|
declare namespace rooms_d_exports {
|
|
3
3
|
export { RoomClaimOptions as ClaimOptions, RoomCreateOptions as CreateOptions, RoomJoinOptions as JoinOptions, RoomOpenOptions as OpenOptions, Room, RoomBacklog, RoomDefaults, RoomEnd, RoomEvent, RoomMailbox, RoomMember, RoomMessage, RoomPermission, RoomPermissions, RoomsError, RoomsErrorCode, available, create, join, open };
|
|
4
4
|
}
|
|
@@ -22,44 +22,87 @@ export type Room = {
|
|
|
22
22
|
readonly self: RoomMember;
|
|
23
23
|
/** the owner's member id, or '' while a claimed room's owner has never joined */
|
|
24
24
|
readonly owner: string;
|
|
25
|
-
/** whether a premium account keeps this name
|
|
25
|
+
/** whether a premium account keeps this name. Whether it keeps the messages too is `mailbox`. */
|
|
26
26
|
readonly claimed: boolean;
|
|
27
27
|
/**
|
|
28
|
-
* what the mailbox holds, as the room last said. Null
|
|
29
|
-
*
|
|
30
|
-
*
|
|
28
|
+
* what the mailbox holds, as the room last said. Null while the room keeps no messages: nobody has
|
|
29
|
+
* claimed it, or its claim keeps none. The account can clear the room, unclaim it, turn its messages
|
|
30
|
+
* off or on, or set a lower `cap` from its fkn.app settings, which the app hears as a `deleted` or a
|
|
31
|
+
* `claim` event; `usage()` reads the figures again.
|
|
31
32
|
*/
|
|
32
33
|
readonly mailbox: RoomMailbox | null;
|
|
33
34
|
defaults: () => RoomDefaults;
|
|
34
35
|
members: () => Promise<RoomMember[]>;
|
|
35
36
|
/** sealed before it leaves the browser. Rejects `too-large` past `self.maxMessageBytes` on the wire, never truncates. */
|
|
36
37
|
send: (text: string) => Promise<void>;
|
|
37
|
-
/**
|
|
38
|
+
/**
|
|
39
|
+
* replaces a stored message's text: one of your own, or any as the owner. On a room claimed under an
|
|
40
|
+
* app's scope, from another app of the claim's account, it is refused `denied` (`rooms: only the app
|
|
41
|
+
* that claimed the room can change it`), the account's own messages included, as `claim` says.
|
|
42
|
+
*/
|
|
38
43
|
edit: (seq: number, text: string) => Promise<void>;
|
|
39
|
-
/**
|
|
44
|
+
/**
|
|
45
|
+
* drops stored messages: one of your own, or any range as the owner. On a room claimed under an app's
|
|
46
|
+
* scope, from another app of the claim's account, it is refused `denied` (`rooms: only the app that
|
|
47
|
+
* claimed the room can change it`), the account's own messages included, as `claim` says.
|
|
48
|
+
*/
|
|
40
49
|
delete: (from: number, to?: number) => Promise<void>;
|
|
41
50
|
/** replays stored messages above `after` as `message` events marked `replayed`, one page at a time */
|
|
42
51
|
backlog: (after: number, limit?: number) => Promise<RoomBacklog>;
|
|
52
|
+
/**
|
|
53
|
+
* whether a member with no override may send or receive, from the owner only (`denied`, `rooms: not
|
|
54
|
+
* the room owner`). On a room claimed under an app's scope, from another app of the claim's account,
|
|
55
|
+
* it is refused `denied` (`rooms: only the app that claimed the room can change it`), as `claim` says.
|
|
56
|
+
*/
|
|
43
57
|
setDefault: (permission: 'send' | 'receive', value: boolean) => Promise<void>;
|
|
44
58
|
/**
|
|
45
59
|
* the message size cap, from 1 to 33,554,432. With no id it sets the room default, which is always
|
|
46
|
-
* a number. With an id it sets that member's override, and null clears the override.
|
|
60
|
+
* a number. With an id it sets that member's override, and null clears the override. From the owner
|
|
61
|
+
* only (`denied`, `rooms: not the room owner`); on a room claimed under an app's scope, from another
|
|
62
|
+
* app of the claim's account, it is refused `denied` (`rooms: only the app that claimed the room can
|
|
63
|
+
* change it`), as `claim` says.
|
|
47
64
|
*/
|
|
48
65
|
limit: {
|
|
49
66
|
(maxMessageBytes: number, id?: string): Promise<void>;
|
|
50
67
|
(maxMessageBytes: number | null, id: string): Promise<void>;
|
|
51
68
|
};
|
|
69
|
+
/**
|
|
70
|
+
* gives a member a permission over the room default, from the owner only (`denied`, `rooms: not the
|
|
71
|
+
* room owner`). On a room claimed under an app's scope, from another app of the claim's account, it is
|
|
72
|
+
* refused `denied` (`rooms: only the app that claimed the room can change it`), as `claim` says.
|
|
73
|
+
*/
|
|
52
74
|
grant: (id: string, permission: RoomPermission) => Promise<void>;
|
|
75
|
+
/**
|
|
76
|
+
* takes a permission from a member over the room default, from the owner only (`denied`, `rooms: not
|
|
77
|
+
* the room owner`). On a room claimed under an app's scope, from another app of the claim's account, it
|
|
78
|
+
* is refused `denied` (`rooms: only the app that claimed the room can change it`), as `claim` says.
|
|
79
|
+
*/
|
|
53
80
|
revoke: (id: string, permission: RoomPermission) => Promise<void>;
|
|
81
|
+
/**
|
|
82
|
+
* sends a member out of the room, which they may join again, with the `remove` permission (`denied`,
|
|
83
|
+
* `rooms: permission denied`). On a room claimed under an app's scope, from another app of the claim's
|
|
84
|
+
* account, it is refused `denied` (`rooms: only the app that claimed the room can change it`), as
|
|
85
|
+
* `claim` says.
|
|
86
|
+
*/
|
|
54
87
|
remove: (id: string) => Promise<void>;
|
|
88
|
+
/**
|
|
89
|
+
* sends a member out of the room and keeps them out, with the `block` permission (`denied`, `rooms:
|
|
90
|
+
* permission denied`). On a room claimed under an app's scope, from another app of the claim's account,
|
|
91
|
+
* it is refused `denied` (`rooms: only the app that claimed the room can change it`), as `claim` says.
|
|
92
|
+
*/
|
|
55
93
|
block: (id: string) => Promise<void>;
|
|
94
|
+
/**
|
|
95
|
+
* lets a blocked member join again, with the `block` permission (`denied`, `rooms: permission denied`).
|
|
96
|
+
* On a room claimed under an app's scope, from another app of the claim's account, it is refused
|
|
97
|
+
* `denied` (`rooms: only the app that claimed the room can change it`), as `claim` says.
|
|
98
|
+
*/
|
|
56
99
|
unblock: (id: string) => Promise<void>;
|
|
57
100
|
/**
|
|
58
|
-
* keeps the name
|
|
59
|
-
* buys. `description` says what the room is for, shown to the account in its
|
|
60
|
-
* permanent claim with an unchanged one on every open is free. Claiming on every
|
|
61
|
-
* room again after the account unclaims it from fkn.app, so claim when the person
|
|
62
|
-
* or make it `temporary`.
|
|
101
|
+
* keeps the name for the signed-in premium account, and a mailbox unless asked not to. The only thing
|
|
102
|
+
* in rooms that premium buys. `description` says what the room is for, shown to the account in its
|
|
103
|
+
* fkn.app settings; a permanent claim with an unchanged one on every open is free. Claiming on every
|
|
104
|
+
* open also claims the room again after the account unclaims it from fkn.app, so claim when the person
|
|
105
|
+
* wants the room kept, or make it `temporary`.
|
|
63
106
|
*
|
|
64
107
|
* `temporary` makes the claim end by itself, in milliseconds (`true` is 7 days), that long after its
|
|
65
108
|
* last claim: a temporary claim goes to the account's ledger every time, which is what restarts its
|
|
@@ -67,6 +110,22 @@ export type Room = {
|
|
|
67
110
|
* from fkn.app, and the stored messages are gone. A broker too old to carry it refuses the call
|
|
68
111
|
* `unavailable` (`rooms: temporary claims are not available`) rather than make the claim permanent.
|
|
69
112
|
*
|
|
113
|
+
* `mailbox: false` keeps the name and stores nothing: the room relays as an unclaimed one does. It is
|
|
114
|
+
* read only when the call starts the claim and ignored on a room the account already holds, so claiming
|
|
115
|
+
* on every open never undoes the owner's choice.
|
|
116
|
+
*
|
|
117
|
+
* Who changes a claimed room depends on its scope. A room under an app's scope, which is every room
|
|
118
|
+
* but a `global` one, is changed by the claim's account only through the app that claimed it (the
|
|
119
|
+
* same app once it is verified): from another app of the account `setDefault`, `limit`, `grant`,
|
|
120
|
+
* `revoke`, `remove`, `block`, `unblock`, `setMailbox`, `edit` and `delete` are refused `denied`
|
|
121
|
+
* (`rooms: only the app that claimed the room can change it`), the account's own messages included,
|
|
122
|
+
* and nothing changes. That other app, which reaches the room through its invite, still joins, reads
|
|
123
|
+
* and sends. A claimed `global` room is changed by any app of the account, which also describes it,
|
|
124
|
+
* sets its `temporary` and releases it. The account changes every room it claimed
|
|
125
|
+
* from its fkn.app settings, whichever app claimed it, and members of other accounts are answered as
|
|
126
|
+
* in any room. While the room cannot tell whether two apps are one, such a change is refused
|
|
127
|
+
* `unavailable` (`rooms: rooms are unavailable`) and can be sent again.
|
|
128
|
+
*
|
|
70
129
|
* Past the account's room limit the call waits while fkn.app shows the person their claimed rooms over
|
|
71
130
|
* your app, with Unclaim on each: it resolves once one is unclaimed and this claim is made, and rejects
|
|
72
131
|
* `full` (`rooms: too many claims`) when they close the card or when fkn.app cannot show it. Nothing
|
|
@@ -74,8 +133,28 @@ export type Room = {
|
|
|
74
133
|
*/
|
|
75
134
|
claim: (options?: RoomClaimOptions) => Promise<void>;
|
|
76
135
|
/**
|
|
77
|
-
*
|
|
78
|
-
*
|
|
136
|
+
* turns a claimed room's mailbox off or on, from the room's owner only, which in a claimed room is the
|
|
137
|
+
* claim's account. Off deletes every stored message at once, the archive included, and the room then
|
|
138
|
+
* relays as an unclaimed one does while keeping its claim; whoever is present hears a `claim` event
|
|
139
|
+
* with `mailbox: false` and no `deleted`, so what an app shows stays. On starts an empty mailbox that
|
|
140
|
+
* keeps messages from the next `seq`, and nothing deleted comes back. Turning it on needs premium, as a
|
|
141
|
+
* claim does (`denied`, `rooms: claiming needs premium`); turning it off never does. Setting what it
|
|
142
|
+
* already is changes nothing. Resolves once the room answered, with `mailbox` reading the new state,
|
|
143
|
+
* or a newer one when a release or the account's own switch landed before the answer.
|
|
144
|
+
*
|
|
145
|
+
* Refused `invalid` (`rooms: the room is not claimed`) on an unclaimed room, `denied` (`rooms: not the
|
|
146
|
+
* room owner`) from anyone else, `denied` (`rooms: only the app that claimed the room can change it`)
|
|
147
|
+
* from another app of the claim's account on a room claimed under an app's scope, as `claim` says, and
|
|
148
|
+
* `invalid` (`rooms: malformed frame`) for anything but a boolean. A broker too old to carry it refuses
|
|
149
|
+
* `unavailable` (`rooms: the mailbox switch is not available`). The account can do the same from its
|
|
150
|
+
* fkn.app settings, whichever app claimed the room.
|
|
151
|
+
*/
|
|
152
|
+
setMailbox: (on: boolean) => Promise<void>;
|
|
153
|
+
/**
|
|
154
|
+
* gives the claim back: the mailbox is deleted and whoever is present stays in an ordinary room. On a
|
|
155
|
+
* room under an app's scope, the app that claimed it only (the same app once it is verified), and from
|
|
156
|
+
* another app it is refused `denied` (`rooms: only the app that claimed the room can release it`); on a
|
|
157
|
+
* `global` room, any app of the account. The account can also unclaim it from its fkn.app settings.
|
|
79
158
|
*/
|
|
80
159
|
release: () => Promise<void>;
|
|
81
160
|
usage: () => Promise<RoomMailbox | null>;
|
package/rooms.js
CHANGED
|
@@ -4,10 +4,10 @@ import { t as i } from "./busy-B189uX--.js";
|
|
|
4
4
|
import { ROOM_TEMPORARY_MS as a } from "./contract.js";
|
|
5
5
|
//#region src/rooms.ts
|
|
6
6
|
var o = /* @__PURE__ */ e({
|
|
7
|
-
available: () =>
|
|
8
|
-
create: () =>
|
|
9
|
-
join: () =>
|
|
10
|
-
open: () =>
|
|
7
|
+
available: () => _,
|
|
8
|
+
create: () => y,
|
|
9
|
+
join: () => b,
|
|
10
|
+
open: () => v
|
|
11
11
|
}), s = {
|
|
12
12
|
wrongKey: "rooms: wrong room key",
|
|
13
13
|
inviteNoKey: "rooms: the invite carries no key",
|
|
@@ -38,9 +38,11 @@ var o = /* @__PURE__ */ e({
|
|
|
38
38
|
badDescription: "rooms: the description is not one a claim can carry",
|
|
39
39
|
notClaimer: "rooms: only the app that claimed the room can describe it",
|
|
40
40
|
notReleaser: "rooms: only the app that claimed the room can release it",
|
|
41
|
+
notClaimingApp: "rooms: only the app that claimed the room can change it",
|
|
41
42
|
badTemporary: "rooms: the temporary duration is not one a claim can carry",
|
|
42
43
|
notTemporaryClaimer: "rooms: only the app that claimed the room can set when it expires",
|
|
43
44
|
temporaryUnavailable: "rooms: temporary claims are not available",
|
|
45
|
+
mailboxUnavailable: "rooms: the mailbox switch is not available",
|
|
44
46
|
tooFast: "rooms: sending too fast",
|
|
45
47
|
tooLarge: "rooms: the message is too large",
|
|
46
48
|
unavailable: "rooms: rooms are unavailable",
|
|
@@ -53,73 +55,87 @@ var o = /* @__PURE__ */ e({
|
|
|
53
55
|
send: !0,
|
|
54
56
|
receive: !0,
|
|
55
57
|
maxMessageBytes: 262144
|
|
56
|
-
}, d =
|
|
58
|
+
}, d = () => ({
|
|
59
|
+
messages: 0,
|
|
60
|
+
bytes: 0,
|
|
61
|
+
cap: 5e8,
|
|
62
|
+
archived: !1
|
|
63
|
+
}), f = async () => {
|
|
57
64
|
if (!t) return;
|
|
58
65
|
let e = (await n("a room").catch(() => void 0))?.rooms;
|
|
59
66
|
return typeof e?.open == "function" ? e : void 0;
|
|
60
|
-
},
|
|
67
|
+
}, p = () => {
|
|
61
68
|
throw c("unavailable", s.unavailable);
|
|
62
|
-
},
|
|
69
|
+
}, m = (e) => e === "blocked" ? "blocked" : e === "not-found" ? "ended" : "unavailable", h = (e) => {
|
|
63
70
|
if (e !== void 0 && e !== !1) return e === !0 ? a.default : typeof e != "number" || !Number.isInteger(e) ? null : e >= a.min && e <= a.max ? e : null;
|
|
64
|
-
},
|
|
65
|
-
let t = e.invite, n = e, a = 0, o = e.self,
|
|
66
|
-
|
|
67
|
-
}),
|
|
68
|
-
let t = [...
|
|
69
|
-
|
|
71
|
+
}, g = async (e) => {
|
|
72
|
+
let t = e.invite, n = e, a = 0, o = e.self, f = e.owner, p = e.claimed, g = e.mailbox, _ = 0, v = await e.defaults().catch(() => u), y = !1, b = /* @__PURE__ */ new Set(), x = /* @__PURE__ */ new Set(), S = i("room"), C = () => {}, w = () => {}, T = new Promise((e) => {
|
|
73
|
+
w = e;
|
|
74
|
+
}), E = (e) => {
|
|
75
|
+
let t = [...x];
|
|
76
|
+
x.clear();
|
|
70
77
|
for (let n of t) try {
|
|
71
78
|
n(e);
|
|
72
79
|
} catch {}
|
|
73
|
-
},
|
|
74
|
-
|
|
75
|
-
},
|
|
76
|
-
if (
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
80
|
+
}, D = (e) => {
|
|
81
|
+
y || (y = !0, C(), b.clear(), S(), E(c("closed", s.ended)), w({ reason: e }));
|
|
82
|
+
}, O = (e) => {
|
|
83
|
+
if (y) return;
|
|
84
|
+
let t = e;
|
|
85
|
+
if (t.type === "defaults" && (v = t.defaults), t.type === "permissions" && t.id === o.id && (o = {
|
|
86
|
+
id: o.id,
|
|
87
|
+
permissions: t.permissions,
|
|
88
|
+
maxMessageBytes: t.maxMessageBytes
|
|
89
|
+
}), t.type === "claim") {
|
|
90
|
+
_ += 1;
|
|
91
|
+
let e = t.claimed && t.mailbox !== !1;
|
|
92
|
+
t = {
|
|
93
|
+
type: "claim",
|
|
94
|
+
claimed: t.claimed,
|
|
95
|
+
owner: t.owner,
|
|
96
|
+
mailbox: e
|
|
97
|
+
}, p = t.claimed, f = t.owner, g = e ? d() : null;
|
|
85
98
|
}
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
99
|
+
for (let e of [...b]) try {
|
|
100
|
+
e(t);
|
|
101
|
+
} catch {}
|
|
102
|
+
}, k = (e, t) => {
|
|
103
|
+
Promise.resolve(e.on(O)).catch(() => {}), Promise.resolve(e.closed).then((e) => {
|
|
104
|
+
t === a && D(e.reason);
|
|
89
105
|
}, () => {});
|
|
90
|
-
},
|
|
91
|
-
if (typeof e?.join != "function") return
|
|
106
|
+
}, A = async (e, r) => {
|
|
107
|
+
if (typeof e?.join != "function") return D("unavailable");
|
|
92
108
|
let i = await e.join(t).catch(() => void 0);
|
|
93
|
-
if (
|
|
94
|
-
if (!i) return
|
|
95
|
-
if ("error" in i) return
|
|
96
|
-
if (i.self.id !== o.id) return Promise.resolve(i.leave()).catch(() => {}),
|
|
97
|
-
n = i, o = i.self,
|
|
109
|
+
if (y || r !== a) return;
|
|
110
|
+
if (!i) return D("unavailable");
|
|
111
|
+
if ("error" in i) return D(m(i.error));
|
|
112
|
+
if (i.self.id !== o.id) return Promise.resolve(i.leave()).catch(() => {}), D("unavailable");
|
|
113
|
+
n = i, o = i.self, f = i.owner, p = i.claimed, g = i.mailbox, k(i, r);
|
|
98
114
|
let s = await i.defaults().catch(() => void 0);
|
|
99
|
-
s && !
|
|
115
|
+
s && !y && r === a && (v = s);
|
|
100
116
|
};
|
|
101
|
-
|
|
117
|
+
C = r((e, t) => {
|
|
102
118
|
let n = a;
|
|
103
|
-
a = t, !(
|
|
104
|
-
}),
|
|
105
|
-
let
|
|
106
|
-
if (
|
|
119
|
+
a = t, !(y || n === 0 || n === t) && (E(c("unavailable", s.unavailable)), A(e.rooms, t));
|
|
120
|
+
}), k(e, a);
|
|
121
|
+
let j = async (e) => {
|
|
122
|
+
if (y) throw c("closed", s.ended);
|
|
107
123
|
let t = () => {}, r = new Promise((e, n) => {
|
|
108
124
|
t = n;
|
|
109
125
|
});
|
|
110
|
-
|
|
126
|
+
x.add(t);
|
|
111
127
|
try {
|
|
112
128
|
return await Promise.race([Promise.resolve(e(n)), r]);
|
|
113
129
|
} catch (e) {
|
|
114
130
|
throw l(e) ? e : c("unavailable", s.unavailable);
|
|
115
131
|
} finally {
|
|
116
|
-
|
|
132
|
+
x.delete(t);
|
|
117
133
|
}
|
|
118
|
-
},
|
|
119
|
-
let t = await
|
|
134
|
+
}, M = async (e) => {
|
|
135
|
+
let t = await j(e);
|
|
120
136
|
if ("error" in t) throw c(t.error, t.message);
|
|
121
|
-
},
|
|
122
|
-
let t = await
|
|
137
|
+
}, N = async (e) => {
|
|
138
|
+
let t = await j(e);
|
|
123
139
|
if (typeof t == "object" && t && "error" in t) throw c(t.error, t.message);
|
|
124
140
|
return t;
|
|
125
141
|
};
|
|
@@ -132,78 +148,90 @@ var o = /* @__PURE__ */ e({
|
|
|
132
148
|
return o;
|
|
133
149
|
},
|
|
134
150
|
get owner() {
|
|
135
|
-
return
|
|
151
|
+
return f;
|
|
136
152
|
},
|
|
137
153
|
get claimed() {
|
|
138
|
-
return
|
|
154
|
+
return p;
|
|
139
155
|
},
|
|
140
156
|
get mailbox() {
|
|
141
|
-
return
|
|
157
|
+
return g;
|
|
142
158
|
},
|
|
143
|
-
defaults: () =>
|
|
144
|
-
members: () =>
|
|
145
|
-
send: (e) =>
|
|
146
|
-
edit: (e, t) =>
|
|
147
|
-
delete: (e, t) =>
|
|
148
|
-
backlog: (e, t) =>
|
|
149
|
-
setDefault: (e, t) =>
|
|
150
|
-
limit: (e, t) =>
|
|
151
|
-
grant: (e, t) =>
|
|
152
|
-
revoke: (e, t) =>
|
|
153
|
-
remove: (e) =>
|
|
154
|
-
block: (e) =>
|
|
155
|
-
unblock: (e) =>
|
|
159
|
+
defaults: () => v,
|
|
160
|
+
members: () => j((e) => e.members()),
|
|
161
|
+
send: (e) => M((t) => t.send(e)),
|
|
162
|
+
edit: (e, t) => M((n) => n.edit(e, t)),
|
|
163
|
+
delete: (e, t) => M((n) => n.delete(e, t)),
|
|
164
|
+
backlog: (e, t) => N((n) => n.backlog(e, t)),
|
|
165
|
+
setDefault: (e, t) => M((n) => n.setDefault(e, t)),
|
|
166
|
+
limit: (e, t) => M((n) => n.limit(e, t)),
|
|
167
|
+
grant: (e, t) => M((n) => n.grant(e, t)),
|
|
168
|
+
revoke: (e, t) => M((n) => n.revoke(e, t)),
|
|
169
|
+
remove: (e) => M((t) => t.remove(e)),
|
|
170
|
+
block: (e) => M((t) => t.block(e)),
|
|
171
|
+
unblock: (e) => M((t) => t.unblock(e)),
|
|
156
172
|
claim: async (e) => {
|
|
157
173
|
let t = e?.description;
|
|
158
174
|
if (t !== void 0 && typeof t != "string") throw c("invalid", s.badDescription);
|
|
159
|
-
let n =
|
|
175
|
+
let n = h(e?.temporary);
|
|
160
176
|
if (n === null) throw c("invalid", s.badTemporary);
|
|
161
|
-
let r =
|
|
177
|
+
let r = e?.mailbox;
|
|
178
|
+
if (r !== void 0 && typeof r != "boolean") throw c("invalid", s.malformed);
|
|
179
|
+
let i = {
|
|
162
180
|
...t === void 0 ? {} : { description: t },
|
|
163
|
-
...n === void 0 ? {} : { temporary: n }
|
|
181
|
+
...n === void 0 ? {} : { temporary: n },
|
|
182
|
+
...r === void 0 ? {} : { mailbox: r }
|
|
164
183
|
};
|
|
165
|
-
return Object.keys(
|
|
184
|
+
return Object.keys(i).length === 0 ? M((e) => e.claim()) : M((e) => {
|
|
166
185
|
if (n !== void 0 && e.temporaryClaims !== !0) throw c("unavailable", s.temporaryUnavailable);
|
|
167
|
-
|
|
186
|
+
if (r === !1 && e.mailboxSwitch !== !0) throw c("unavailable", s.mailboxUnavailable);
|
|
187
|
+
return e.claim(i);
|
|
168
188
|
});
|
|
169
189
|
},
|
|
170
|
-
|
|
190
|
+
setMailbox: async (e) => {
|
|
191
|
+
if (typeof e != "boolean") throw c("invalid", s.malformed);
|
|
192
|
+
let t = _;
|
|
193
|
+
await M((t) => {
|
|
194
|
+
if (t.mailboxSwitch !== !0) throw c("unavailable", s.mailboxUnavailable);
|
|
195
|
+
return t.setMailbox(e);
|
|
196
|
+
}), _ === t && (e ? g === null && (g = d()) : g = null);
|
|
197
|
+
},
|
|
198
|
+
release: () => M((e) => e.release()),
|
|
171
199
|
usage: async () => {
|
|
172
|
-
let e = await
|
|
173
|
-
return
|
|
200
|
+
let e = await N((e) => e.usage());
|
|
201
|
+
return g = e, e;
|
|
174
202
|
},
|
|
175
|
-
on: async (e) =>
|
|
176
|
-
|
|
203
|
+
on: async (e) => y ? () => {} : (b.add(e), () => {
|
|
204
|
+
b.delete(e);
|
|
177
205
|
}),
|
|
178
206
|
leave: async () => {
|
|
179
|
-
await Promise.resolve(n.leave()).catch(() => {}),
|
|
207
|
+
await Promise.resolve(n.leave()).catch(() => {}), D("left");
|
|
180
208
|
},
|
|
181
|
-
closed:
|
|
209
|
+
closed: T
|
|
182
210
|
};
|
|
183
|
-
},
|
|
184
|
-
let e = await
|
|
211
|
+
}, _ = async () => {
|
|
212
|
+
let e = await f();
|
|
185
213
|
return e ? e.available().catch(() => !1) : !1;
|
|
186
|
-
},
|
|
214
|
+
}, v = async (e, t) => {
|
|
187
215
|
if (typeof e != "string" || e.length === 0 || e.length > 72) throw c("invalid", s.badName);
|
|
188
|
-
let n = await
|
|
216
|
+
let n = await f();
|
|
189
217
|
if (!n) throw c("unavailable", s.unavailable);
|
|
190
|
-
let r = await n.open(e, t).catch(
|
|
218
|
+
let r = await n.open(e, t).catch(p);
|
|
191
219
|
if ("error" in r) throw c(r.error, r.message);
|
|
192
|
-
return
|
|
193
|
-
},
|
|
194
|
-
let t = await
|
|
220
|
+
return g(r);
|
|
221
|
+
}, y = async (e) => {
|
|
222
|
+
let t = await f();
|
|
195
223
|
if (!t) throw c("unavailable", s.unavailable);
|
|
196
|
-
let n = await t.create(e).catch(
|
|
224
|
+
let n = await t.create(e).catch(p);
|
|
197
225
|
if ("error" in n) throw c(n.error, n.message);
|
|
198
|
-
return
|
|
199
|
-
},
|
|
226
|
+
return g(n);
|
|
227
|
+
}, b = async (e, t) => {
|
|
200
228
|
let n = typeof e == "string" ? e.indexOf(".") : -1;
|
|
201
229
|
if (n <= 0 || n === e.length - 1) throw c("invalid", s.inviteNoKey);
|
|
202
|
-
let r = await
|
|
230
|
+
let r = await f();
|
|
203
231
|
if (!r) throw c("unavailable", s.unavailable);
|
|
204
|
-
let i = await r.join(e, t).catch(
|
|
232
|
+
let i = await r.join(e, t).catch(p);
|
|
205
233
|
if ("error" in i) throw c(i.error, i.message);
|
|
206
|
-
return
|
|
234
|
+
return g(i);
|
|
207
235
|
};
|
|
208
236
|
//#endregion
|
|
209
|
-
export {
|
|
237
|
+
export { _ as available, y as create, b as join, v as open, o as t };
|