@abraca/dabra 0.7.0 → 0.9.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.
@@ -2297,7 +2297,15 @@ var AbracadabraProvider = class AbracadabraProvider extends AbracadabraBaseProvi
2297
2297
  }
2298
2298
  authenticatedHandler(scope) {
2299
2299
  super.authenticatedHandler(scope);
2300
- this.effectiveRole = scope === "read-write" ? "editor" : "viewer";
2300
+ this.effectiveRole = {
2301
+ service: "service",
2302
+ admin: "admin",
2303
+ owner: "owner",
2304
+ editor: "editor",
2305
+ viewer: "viewer",
2306
+ "read-write": "editor",
2307
+ readonly: "viewer"
2308
+ }[scope] ?? "viewer";
2301
2309
  this.offlineStore?.savePermissionSnapshot(this.effectiveRole);
2302
2310
  }
2303
2311
  /**
@@ -2352,7 +2360,7 @@ var AbracadabraProvider = class AbracadabraProvider extends AbracadabraBaseProvi
2352
2360
  if (role && !this.effectiveRole) this.effectiveRole = role;
2353
2361
  }
2354
2362
  get canWrite() {
2355
- return this.effectiveRole === "owner" || this.effectiveRole === "editor";
2363
+ return this.effectiveRole != null && this.effectiveRole !== "viewer";
2356
2364
  }
2357
2365
  /** The AbracadabraClient instance for REST API access, if configured. */
2358
2366
  get client() {
@@ -2562,7 +2570,8 @@ var AbracadabraClient = class {
2562
2570
  identityPublicKey: opts.publicKey,
2563
2571
  deviceName: opts.deviceName,
2564
2572
  displayName: opts.displayName,
2565
- email: opts.email
2573
+ email: opts.email,
2574
+ inviteCode: opts.inviteCode
2566
2575
  },
2567
2576
  auth: false
2568
2577
  });
@@ -2728,6 +2737,22 @@ var AbracadabraClient = class {
2728
2737
  await this.request("DELETE", `/docs/${encodeURIComponent(docId)}/uploads/${encodeURIComponent(uploadId)}`);
2729
2738
  if (this.cache) await this.cache.invalidateUploads(docId).catch(() => null);
2730
2739
  }
2740
+ /** Create an invite code (requires permission per server config). */
2741
+ async createInvite(opts) {
2742
+ return this.request("POST", "/invites", { body: opts ?? {} });
2743
+ }
2744
+ /** List invite codes visible to the current user. */
2745
+ async listInvites() {
2746
+ return (await this.request("GET", "/invites")).invites;
2747
+ }
2748
+ /** Revoke an invite by its code. */
2749
+ async revokeInvite(code) {
2750
+ await this.request("DELETE", `/invites/${encodeURIComponent(code)}`);
2751
+ }
2752
+ /** Redeem an invite code for the currently authenticated user. */
2753
+ async redeemInvite(code) {
2754
+ await this.request("POST", "/invites/redeem", { body: { code } });
2755
+ }
2731
2756
  /** Health check — no auth required. */
2732
2757
  async health() {
2733
2758
  return this.request("GET", "/health", { auth: false });