@wtfalch/calls 0.4.1 → 0.5.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/README.md CHANGED
@@ -12,7 +12,7 @@ await calls.joinAdmission(sessionId, { video: false, requestId: crypto.randomUUI
12
12
 
13
13
  `waiting(sessionId)` lists the guests waiting in the lobby, oldest first, for a host who holds `calls.participants:admit`. `record(sessionId)` reads what happened in a call: when it started and ended, and when each participant was admitted and left. Anyone who was in the call can read it, and so can holders of `calls.records:read`. A guest's copy carries no member's `actorId`.
14
14
 
15
- Member requests use same-origin cookies and exact-origin requests, unless `token` supplies a bearer instead. `baseUrl` may carry a path prefix, and `deviceId` is sent as `x-calls-device` on member requests. `createCallEndpoint` in the browser entry takes the same three options and sends every request, gateway included, under the prefix; see `docs/control-sdk.md`. Guest link redemption returns a handle whose opaque credential remains private to the handle. Errors are typed `CallsError`; requests are bounded and are never retried automatically.
15
+ Member requests use same-origin cookies and exact-origin requests, unless `token` supplies a bearer instead. `baseUrl` may carry a path prefix, and `deviceId` is sent as `x-calls-device` on member requests. `createCallEndpoint` in the browser entry takes the same three options and sends every request, gateway included, under the prefix; see `docs/control-sdk.md`. Guest link redemption returns a handle whose opaque credential remains private to the handle. `guestPreview(secret)` answers for a valid guest link, without a name and without using up the link, `{ companyName, roomName, hostName, inCall: { displayName }[], expiresAt, recording }`; it needs the host to supply a `directory`, and answers `not_configured` until it does. Errors are typed `CallsError`; requests are bounded and are never retried automatically.
16
16
 
17
17
  `@wtfalch/calls/browser` is the media-ready call handle. `join()` returns a `CallHandle` with:
18
18
 
package/index.d.ts CHANGED
@@ -46,6 +46,8 @@ export interface CallsClient {
46
46
  createGuestLink(sessionId: string, input: { validFrom: number; expiresAt: number; maxRedemptions: number; requestId: string }): Promise<OperationResult & { linkId: string; expiresAt: number; secret: string | null }>;
47
47
  revokeGuestLink(sessionId: string, input: { linkId: string; requestId: string }): Promise<OperationResult & { linkId: string }>;
48
48
  redeemGuestLink(input: { secret: string; displayName: string }): Promise<GuestHandle>;
49
+ guestPreview(secret: string): Promise<GuestPreview>;
49
50
  dispose(): void;
50
51
  }
52
+ export interface GuestPreview { companyName: string; roomName: string; hostName: string | null; inCall: { displayName: string }[]; expiresAt: number; recording: boolean; }
51
53
  export interface GuestHandle { readonly sessionId: string; readonly admissionId: string; readonly expiresAt: number; readonly state: 'waiting' | 'admitted'; status(): Promise<{ sessionId: string; admissionId: string; state: 'waiting' | 'admitted'; expiresAt: number }>; rotate(): Promise<{ sessionId: string; admissionId: string; expiresAt: number }>; leave(input: { requestId: string }): Promise<OperationResult & { admissionId: string }>; dispose(): void; }
package/index.mjs CHANGED
@@ -224,6 +224,14 @@ export function createCallsClient(options) {
224
224
  };
225
225
  });
226
226
  },
227
+ guestPreview(secret) {
228
+ if (typeof secret !== 'string' || !/^[A-Za-z0-9_-]{43}$/.test(secret)) throw new TypeError('invalid guest link');
229
+ return wire.call('/v1/guests/preview', { secret }, undefined, undefined, true).then(v => {
230
+ const str = x => { if (typeof x !== 'string') throw new CallsError('invalid_response'); return x; };
231
+ if (!v || typeof v !== 'object' || !Array.isArray(v.inCall) || typeof v.recording !== 'boolean' || !(v.hostName === null || typeof v.hostName === 'string')) throw new CallsError('invalid_response');
232
+ return { companyName: str(v.companyName), roomName: str(v.roomName), hostName: v.hostName, inCall: v.inCall.map(p => { if (!p || typeof p !== 'object') throw new CallsError('invalid_response'); return { displayName: str(p.displayName) }; }), expiresAt: expires(v.expiresAt), recording: v.recording };
233
+ });
234
+ },
227
235
  dispose() { if (!disposed) { disposed = true; wire.close(); } },
228
236
  };
229
237
  return client;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@wtfalch/calls",
3
- "version": "0.4.1",
3
+ "version": "0.5.0",
4
4
  "description": "Framework-independent SDK for Agora calls: session control (admission, guest links, moderation) and a media-ready browser call handle.",
5
5
  "license": "MIT",
6
6
  "type": "module",