@abraca/dabra 0.7.0 → 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/dist/abracadabra-provider.cjs +18 -1
- package/dist/abracadabra-provider.cjs.map +1 -1
- package/dist/abracadabra-provider.esm.js +18 -1
- package/dist/abracadabra-provider.esm.js.map +1 -1
- package/dist/index.d.ts +25 -1
- package/package.json +1 -1
- package/src/AbracadabraClient.ts +27 -0
- package/src/types.ts +13 -0
package/dist/index.d.ts
CHANGED
|
@@ -206,6 +206,7 @@ declare class AbracadabraClient {
|
|
|
206
206
|
password: string;
|
|
207
207
|
email?: string;
|
|
208
208
|
displayName?: string;
|
|
209
|
+
inviteCode?: string;
|
|
209
210
|
}): Promise<UserProfile>;
|
|
210
211
|
/**
|
|
211
212
|
* Register a new user with an Ed25519 public key (crypto auth).
|
|
@@ -217,6 +218,7 @@ declare class AbracadabraClient {
|
|
|
217
218
|
deviceName?: string;
|
|
218
219
|
displayName?: string;
|
|
219
220
|
email?: string;
|
|
221
|
+
inviteCode?: string;
|
|
220
222
|
}): Promise<UserProfile>;
|
|
221
223
|
/** Login with username + password. Auto-persists returned token. */
|
|
222
224
|
login(opts: {
|
|
@@ -289,6 +291,18 @@ declare class AbracadabraClient {
|
|
|
289
291
|
getUpload(docId: string, uploadId: string): Promise<Blob>;
|
|
290
292
|
/** Delete an upload (requires uploader or document Owner). */
|
|
291
293
|
deleteUpload(docId: string, uploadId: string): Promise<void>;
|
|
294
|
+
/** Create an invite code (requires permission per server config). */
|
|
295
|
+
createInvite(opts?: {
|
|
296
|
+
role?: string;
|
|
297
|
+
maxUses?: number;
|
|
298
|
+
expiresIn?: number;
|
|
299
|
+
}): Promise<InviteRow>;
|
|
300
|
+
/** List invite codes visible to the current user. */
|
|
301
|
+
listInvites(): Promise<InviteRow[]>;
|
|
302
|
+
/** Revoke an invite by its code. */
|
|
303
|
+
revokeInvite(code: string): Promise<void>;
|
|
304
|
+
/** Redeem an invite code for the currently authenticated user. */
|
|
305
|
+
redeemInvite(code: string): Promise<void>;
|
|
292
306
|
/** Health check — no auth required. */
|
|
293
307
|
health(): Promise<HealthStatus>;
|
|
294
308
|
/**
|
|
@@ -763,6 +777,16 @@ interface SearchResult {
|
|
|
763
777
|
/** Number of matching trigrams — higher is better. */
|
|
764
778
|
score: number;
|
|
765
779
|
}
|
|
780
|
+
interface InviteRow {
|
|
781
|
+
code: string;
|
|
782
|
+
createdBy: string | null;
|
|
783
|
+
role: string;
|
|
784
|
+
maxUses: number;
|
|
785
|
+
useCount: number;
|
|
786
|
+
expiresAt: number | null;
|
|
787
|
+
revoked: boolean;
|
|
788
|
+
createdAt: number;
|
|
789
|
+
}
|
|
766
790
|
type UploadQueueStatus = "pending" | "uploading" | "done" | "error";
|
|
767
791
|
interface UploadQueueEntry {
|
|
768
792
|
/** Client-generated UUID. */
|
|
@@ -1243,4 +1267,4 @@ declare class FileBlobStore extends EventEmitter {
|
|
|
1243
1267
|
destroy(): void;
|
|
1244
1268
|
}
|
|
1245
1269
|
//#endregion
|
|
1246
|
-
export { AbracadabraBaseProvider, AbracadabraBaseProviderConfiguration, AbracadabraClient, AbracadabraClientConfig, AbracadabraOutgoingMessageArguments, AbracadabraProvider, AbracadabraProviderConfiguration, AbracadabraWS, AbracadabraWSConfiguration, AbracadabraWebSocketConn, AuthMessageType, AuthorizedScope, AwarenessError, CloseEvent, CompleteAbracadabraBaseProviderConfiguration, CompleteAbracadabraWSConfiguration, CompleteHocuspocusProviderConfiguration, CompleteHocuspocusProviderWebsocketConfiguration, ConnectionTimeout, Constructable, ConstructableOutgoingMessage, CryptoIdentity, CryptoIdentityKeystore, DocumentCache, type DocumentCacheOptions, DocumentMeta, EffectiveRole, FileBlobStore, Forbidden, HealthStatus, HocusPocusWebSocket, HocuspocusProvider, HocuspocusProviderConfiguration, HocuspocusProviderWebsocket, HocuspocusProviderWebsocketConfiguration, HocuspocusWebSocket, MessageTooBig, MessageType, OfflineStore, OutgoingMessageArguments, OutgoingMessageInterface, PendingSubdoc, PermissionEntry, PublicKeyInfo, ResetConnection, SearchIndex, SearchResult, ServerInfo, StatesArray, SubdocMessage, SubdocRegisteredEvent, Unauthorized, UploadInfo, UploadMeta, UploadQueueEntry, UploadQueueStatus, UserProfile, WebSocketStatus, WsReadyStates, awarenessStatesToArray, onAuthenticatedParameters, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onStatusParameters, onSubdocLoadedParameters, onSubdocRegisteredParameters, onSyncedParameters, onUnsyncedChangesParameters, readAuthMessage, writeAuthenticated, writeAuthentication, writePermissionDenied, writeTokenSyncRequest };
|
|
1270
|
+
export { AbracadabraBaseProvider, AbracadabraBaseProviderConfiguration, AbracadabraClient, AbracadabraClientConfig, AbracadabraOutgoingMessageArguments, AbracadabraProvider, AbracadabraProviderConfiguration, AbracadabraWS, AbracadabraWSConfiguration, AbracadabraWebSocketConn, AuthMessageType, AuthorizedScope, AwarenessError, CloseEvent, CompleteAbracadabraBaseProviderConfiguration, CompleteAbracadabraWSConfiguration, CompleteHocuspocusProviderConfiguration, CompleteHocuspocusProviderWebsocketConfiguration, ConnectionTimeout, Constructable, ConstructableOutgoingMessage, CryptoIdentity, CryptoIdentityKeystore, DocumentCache, type DocumentCacheOptions, DocumentMeta, EffectiveRole, FileBlobStore, Forbidden, HealthStatus, HocusPocusWebSocket, HocuspocusProvider, HocuspocusProviderConfiguration, HocuspocusProviderWebsocket, HocuspocusProviderWebsocketConfiguration, HocuspocusWebSocket, InviteRow, MessageTooBig, MessageType, OfflineStore, OutgoingMessageArguments, OutgoingMessageInterface, PendingSubdoc, PermissionEntry, PublicKeyInfo, ResetConnection, SearchIndex, SearchResult, ServerInfo, StatesArray, SubdocMessage, SubdocRegisteredEvent, Unauthorized, UploadInfo, UploadMeta, UploadQueueEntry, UploadQueueStatus, UserProfile, WebSocketStatus, WsReadyStates, awarenessStatesToArray, onAuthenticatedParameters, onAuthenticationFailedParameters, onAwarenessChangeParameters, onAwarenessUpdateParameters, onCloseParameters, onDisconnectParameters, onMessageParameters, onOpenParameters, onOutgoingMessageParameters, onStatelessParameters, onStatusParameters, onSubdocLoadedParameters, onSubdocRegisteredParameters, onSyncedParameters, onUnsyncedChangesParameters, readAuthMessage, writeAuthenticated, writeAuthentication, writePermissionDenied, writeTokenSyncRequest };
|
package/package.json
CHANGED
package/src/AbracadabraClient.ts
CHANGED
|
@@ -7,6 +7,7 @@ import type {
|
|
|
7
7
|
PermissionEntry,
|
|
8
8
|
HealthStatus,
|
|
9
9
|
ServerInfo,
|
|
10
|
+
InviteRow,
|
|
10
11
|
} from "./types.ts";
|
|
11
12
|
import type { DocumentCache } from "./DocumentCache.ts";
|
|
12
13
|
|
|
@@ -85,6 +86,7 @@ export class AbracadabraClient {
|
|
|
85
86
|
password: string;
|
|
86
87
|
email?: string;
|
|
87
88
|
displayName?: string;
|
|
89
|
+
inviteCode?: string;
|
|
88
90
|
}): Promise<UserProfile> {
|
|
89
91
|
return this.request<UserProfile>("POST", "/auth/register", {
|
|
90
92
|
body: opts,
|
|
@@ -102,6 +104,7 @@ export class AbracadabraClient {
|
|
|
102
104
|
deviceName?: string;
|
|
103
105
|
displayName?: string;
|
|
104
106
|
email?: string;
|
|
107
|
+
inviteCode?: string;
|
|
105
108
|
}): Promise<UserProfile> {
|
|
106
109
|
const username = opts.username ?? `user-${opts.publicKey.slice(0, 8)}`;
|
|
107
110
|
return this.request<UserProfile>("POST", "/auth/register", {
|
|
@@ -111,6 +114,7 @@ export class AbracadabraClient {
|
|
|
111
114
|
deviceName: opts.deviceName,
|
|
112
115
|
displayName: opts.displayName,
|
|
113
116
|
email: opts.email,
|
|
117
|
+
inviteCode: opts.inviteCode,
|
|
114
118
|
},
|
|
115
119
|
auth: false,
|
|
116
120
|
});
|
|
@@ -368,6 +372,29 @@ export class AbracadabraClient {
|
|
|
368
372
|
}
|
|
369
373
|
}
|
|
370
374
|
|
|
375
|
+
// ── Invites ──────────────────────────────────────────────────────────────
|
|
376
|
+
|
|
377
|
+
/** Create an invite code (requires permission per server config). */
|
|
378
|
+
async createInvite(opts?: { role?: string; maxUses?: number; expiresIn?: number }): Promise<InviteRow> {
|
|
379
|
+
return this.request<InviteRow>("POST", "/invites", { body: opts ?? {} });
|
|
380
|
+
}
|
|
381
|
+
|
|
382
|
+
/** List invite codes visible to the current user. */
|
|
383
|
+
async listInvites(): Promise<InviteRow[]> {
|
|
384
|
+
const res = await this.request<{ invites: InviteRow[] }>("GET", "/invites");
|
|
385
|
+
return res.invites;
|
|
386
|
+
}
|
|
387
|
+
|
|
388
|
+
/** Revoke an invite by its code. */
|
|
389
|
+
async revokeInvite(code: string): Promise<void> {
|
|
390
|
+
await this.request("DELETE", `/invites/${encodeURIComponent(code)}`);
|
|
391
|
+
}
|
|
392
|
+
|
|
393
|
+
/** Redeem an invite code for the currently authenticated user. */
|
|
394
|
+
async redeemInvite(code: string): Promise<void> {
|
|
395
|
+
await this.request("POST", "/invites/redeem", { body: { code } });
|
|
396
|
+
}
|
|
397
|
+
|
|
371
398
|
// ── System ───────────────────────────────────────────────────────────────
|
|
372
399
|
|
|
373
400
|
/** Health check — no auth required. */
|
package/src/types.ts
CHANGED
|
@@ -222,6 +222,19 @@ export interface SearchResult {
|
|
|
222
222
|
score: number;
|
|
223
223
|
}
|
|
224
224
|
|
|
225
|
+
// ── Invites ──────────────────────────────────────────────────────────────────
|
|
226
|
+
|
|
227
|
+
export interface InviteRow {
|
|
228
|
+
code: string;
|
|
229
|
+
createdBy: string | null;
|
|
230
|
+
role: string;
|
|
231
|
+
maxUses: number;
|
|
232
|
+
useCount: number;
|
|
233
|
+
expiresAt: number | null;
|
|
234
|
+
revoked: boolean;
|
|
235
|
+
createdAt: number;
|
|
236
|
+
}
|
|
237
|
+
|
|
225
238
|
// ── Upload queue ─────────────────────────────────────────────────────────────
|
|
226
239
|
|
|
227
240
|
export type UploadQueueStatus = "pending" | "uploading" | "done" | "error";
|