@witbitz/sdk 0.0.0-stage → 4.3.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/LICENSE +21 -0
- package/README.md +20 -2
- package/a2aCore.js +200 -0
- package/a2aShared.js +27 -0
- package/accountErase.js +223 -0
- package/accountIndexDoc.js +122 -0
- package/accountOwner.js +59 -0
- package/accountRecord.js +90 -0
- package/accountScope.js +114 -0
- package/accountSeal.js +42 -0
- package/accountStores.js +173 -0
- package/acctV2App.js +619 -0
- package/acctV2Check.js +29 -0
- package/acctV2Client.js +382 -0
- package/acctV2Keys.js +43 -0
- package/acctV2Legacy.js +14 -0
- package/acctV2Switch.js +80 -0
- package/acctV2UiCore.js +857 -0
- package/acctV2WebAuthn.js +61 -0
- package/acctV2Wire.js +59 -0
- package/address.js +42 -0
- package/attestedBox.js +30 -0
- package/attestedRooms.js +78 -0
- package/awsKey.js +98 -0
- package/backupRecord.js +106 -0
- package/backupVault.js +97 -0
- package/blocks.js +115 -0
- package/blocksPush.js +64 -0
- package/browseSeal.js +103 -0
- package/cbor.js +225 -0
- package/changePush.js +75 -0
- package/chatLock.js +149 -0
- package/chatLockSw.js +13 -0
- package/cloudDeviceBuilds.js +11 -0
- package/cloudDevicePins.js +33 -0
- package/cloudDeviceSeal.js +53 -0
- package/codeBrowse.js +224 -0
- package/codeCloud.js +652 -0
- package/codeCloudKeys.js +112 -0
- package/codeCommands.js +167 -0
- package/codeComputers.js +388 -0
- package/codeEgress.js +123 -0
- package/codeFilesRoutes.js +17 -0
- package/codeMkdir.js +8 -0
- package/codeModes.js +57 -0
- package/codeOrphanKeys.js +42 -0
- package/codeOutputs.js +141 -0
- package/codeRelay.js +505 -0
- package/codeSentinel.js +86 -0
- package/codeTransport.js +295 -0
- package/codeUndo.js +48 -0
- package/compress.js +24 -0
- package/config.js +11 -0
- package/connCatalog.js +164 -0
- package/connDisp.js +76 -0
- package/connOtherWays.js +74 -0
- package/connPending.js +16 -0
- package/connWrap.js +53 -0
- package/connectionEntry.js +89 -0
- package/connections.js +562 -0
- package/credits.js +30 -0
- package/csAttest.js +112 -0
- package/decrypt.html +384 -0
- package/deviceAttest.js +521 -0
- package/deviceCall.js +54 -0
- package/deviceKeyCore.js +41 -0
- package/deviceSeal.js +59 -0
- package/e2ee.js +323 -0
- package/eat.js +103 -0
- package/emailFork.js +275 -0
- package/emailSignIn.js +81 -0
- package/emptySpaces.js +111 -0
- package/encSource.js +55 -0
- package/enclaveAccept.js +214 -0
- package/enclaveClaim.js +241 -0
- package/enclaveRoute.js +102 -0
- package/enclaveSnapshotMerge.js +44 -0
- package/entrySig.js +165 -0
- package/env.js +73 -0
- package/eraseFile.js +58 -0
- package/followImage.js +86 -0
- package/healNames.js +45 -0
- package/idb.js +97 -0
- package/idbSeal.js +119 -0
- package/indexGone.js +12 -0
- package/invite.js +51 -0
- package/inviteEnroll.js +67 -0
- package/inviteSend.js +68 -0
- package/jobAgents.js +87 -0
- package/keptMerge.js +84 -0
- package/l1-worker-src.js +2 -0
- package/l1-worker.js +831 -0
- package/laneConfig.js +57 -0
- package/laneLinkCore.js +177 -0
- package/ledgerView.js +64 -0
- package/manifest.json +220 -0
- package/mcpRecommended.js +25 -0
- package/memberChange.js +123 -0
- package/mkseal.js +101 -0
- package/nativePush.js +153 -0
- package/nitroVerify.js +220 -0
- package/noble-p256.js +27 -0
- package/notice.js +116 -0
- package/notifKey.js +58 -0
- package/offlineBundle.js +62 -0
- package/ohttp.js +177 -0
- package/opencodeWire.js +282 -0
- package/oprf.js +70 -0
- package/ownAgentLink.js +96 -0
- package/ownerPolicy.js +117 -0
- package/package.json +254 -4
- package/pollVerdict.js +33 -0
- package/prefetchPoll.js +60 -0
- package/protectedLocal.js +410 -0
- package/pushCore.js +42 -0
- package/recovery.js +107 -0
- package/regions.js +42 -0
- package/removedMessage.js +11 -0
- package/renameRefusal.js +9 -0
- package/replyQuote.js +34 -0
- package/reqEnvelope.js +126 -0
- package/roomDefaultPrefs.js +76 -0
- package/roomDelete.js +109 -0
- package/roomName.js +177 -0
- package/roomPass.js +256 -0
- package/roomRoster.js +289 -0
- package/roomSettings.js +61 -0
- package/roomState.js +58 -0
- package/roomStreamClient.js +115 -0
- package/rosterCount.js +49 -0
- package/rosterHash.js +13 -0
- package/rowSchema.js +113 -0
- package/safeMedia.js +116 -0
- package/safeMediaPins.js +17 -0
- package/schedulesDoc.js +78 -0
- package/sdkA2A.js +404 -0
- package/sdkAccount.js +470 -0
- package/sdkAccountDoc.js +81 -0
- package/sdkAccountSections.js +223 -0
- package/sdkAgui.js +141 -0
- package/sdkAttest.js +34 -0
- package/sdkBackup.js +480 -0
- package/sdkBackupV2.js +630 -0
- package/sdkBrowserPrivate.js +28 -0
- package/sdkBuilds.js +208 -0
- package/sdkCloudDevice.js +215 -0
- package/sdkComputers.js +480 -0
- package/sdkDictation.js +142 -0
- package/sdkErase.js +283 -0
- package/sdkExports.js +69 -0
- package/sdkInvitations.js +34 -0
- package/sdkKeptAgent.js +188 -0
- package/sdkLaneLink.js +205 -0
- package/sdkPlan.js +94 -0
- package/sdkProtect.js +228 -0
- package/sdkRedact.js +36 -0
- package/sdkRekey.js +307 -0
- package/sdkReport.js +68 -0
- package/sdkSafeMedia.js +255 -0
- package/sdkSchedules.js +39 -0
- package/sdkSpeech.js +54 -0
- package/sdkTurn.js +117 -0
- package/sdkVault.js +124 -0
- package/sealShare.js +18 -0
- package/sealedNames.js +64 -0
- package/sealedReceipt.js +17 -0
- package/sentinelRelease.js +154 -0
- package/shamir.js +85 -0
- package/sharedViews.js +38 -0
- package/sheetChrome.js +450 -0
- package/siri.js +171 -0
- package/spaceClient.js +1418 -0
- package/spaceConfig.js +81 -0
- package/spaceEmailGate.js +813 -0
- package/spaceExport.js +125 -0
- package/spaceFork.js +216 -0
- package/spaceLock.js +358 -0
- package/spacePasskey.js +180 -0
- package/speechOut.js +100 -0
- package/splitKeyClient.js +90 -0
- package/store.js +587 -0
- package/streamHint.js +36 -0
- package/sttCloud.js +220 -0
- package/sttWorklet.js +38 -0
- package/sw-notif-core.js +538 -0
- package/tempList.js +48 -0
- package/tinfoilVerifier.js +78 -0
- package/toolBooks.js +31 -0
- package/toolRules.js +52 -0
- package/turnCerts.js +254 -0
- package/turnFeed.js +58 -0
- package/turnVerdict.js +36 -0
- package/usageReceipts.js +176 -0
- package/usageSummary.js +90 -0
- package/util.js +181 -0
- package/vault-core.js +1958 -0
- package/vault-kit.mjs +354 -0
- package/vault-screens.js +263 -0
- package/vaultAtRest.js +177 -0
- package/vaultCoreLock.js +111 -0
- package/vaultCorePush.js +140 -0
- package/vaultDeviceKey.js +95 -0
- package/vaultEnclaveHandoff.js +114 -0
- package/vaultKeep.js +281 -0
- package/vaultSealedStore.js +77 -0
- package/vaultWorkerHost.js +98 -0
- package/vcWorker.js +34 -0
- package/voiceAttest.js +50 -0
- package/voiceCert.js +51 -0
- package/witbitz-admin.d.ts +135 -0
- package/witbitz-admin.js +529 -0
- package/witbitz-admin.mjs +1459 -0
- package/witbitz-sdk.d.ts +1106 -0
- package/witbitz-sdk.js +3835 -0
- package/workerClient.js +16 -0
- package/workerLiveness.js +21 -0
- package/x509.js +218 -0
package/voiceAttest.js
ADDED
|
@@ -0,0 +1,50 @@
|
|
|
1
|
+
// voiceAttest.js — THE PAGE CHECKS THE VOICE SERVICE ITSELF before it uses a press-to-talk or Play aloud key (docs/stt-cloud.md,
|
|
2
|
+
// 2026-10-17). op:'stt' / op:'tts' (agent/sttKey.mjs) mint the key only after the Lambda verified inference.tinfoil.sh's
|
|
3
|
+
// attestation, and the answer carries that evidence (`bundleGz`: the gzipped ATC bundle — AMD's SEV-SNP report, the
|
|
4
|
+
// Sigstore-signed release, the enclave's TLS certificate) and the certificate made from it (`cert`). The page used to take
|
|
5
|
+
// the Lambda's word. Now it verifies the evidence itself with Tinfoil's verifier (tinfoilVerifier.js, offline: AMD's root
|
|
6
|
+
// and Sigstore's trust root are compiled in; no network), against the HOST and REPO pinned here, and uses the key only when
|
|
7
|
+
// the evidence holds, is the certificate's own (same sha256) and names the certificate's TLS key. Fail closed: no
|
|
8
|
+
// microphone and no text to an endpoint the page could not check.
|
|
9
|
+
// Honest scope (docs/turn-certificates.md): a browser cannot pin its own websocket's TLS key, so the connection itself is
|
|
10
|
+
// ordinary TLS to that host; what this adds is that the PAGE, not only our server, saw the host prove its code.
|
|
11
|
+
export const VOICE_HOST = 'inference.tinfoil.sh'
|
|
12
|
+
export const VOICE_REPO = 'tinfoilsh/confidential-model-router'
|
|
13
|
+
|
|
14
|
+
const HEX64 = /^[0-9a-f]{64}$/
|
|
15
|
+
const refuse = (why) => Object.assign(new Error('the voice service did not prove what it runs (' + why + ') — not used'), { code: 'voice_unattested' })
|
|
16
|
+
let _verifier = null
|
|
17
|
+
const loadTinfoilVerifier = () => (_verifier = _verifier || import('./tinfoilVerifier.js').then((m) => m.Verifier).catch((e) => { _verifier = null; throw e }))
|
|
18
|
+
const _verified = new Map() // evidence sha256 → the TLS key it proved (this page's lifetime)
|
|
19
|
+
|
|
20
|
+
async function gunzipText (b64) {
|
|
21
|
+
const bin = Uint8Array.from(atob(b64), (c) => c.charCodeAt(0))
|
|
22
|
+
const out = new Response(new Response(bin).body.pipeThrough(new DecompressionStream('gzip')))
|
|
23
|
+
return out.text()
|
|
24
|
+
}
|
|
25
|
+
async function sha256hex (text) {
|
|
26
|
+
const d = new Uint8Array(await crypto.subtle.digest('SHA-256', new TextEncoder().encode(text)))
|
|
27
|
+
return [...d].map((b) => b.toString(16).padStart(2, '0')).join('')
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** Check a speech key's evidence. → the certificate, or throws { code: 'voice_unattested' }. */
|
|
31
|
+
export async function checkSpeechKey (k, { loadVerifier = loadTinfoilVerifier, cache = _verified } = {}) {
|
|
32
|
+
const c = k && k.cert
|
|
33
|
+
if (!c || typeof k.bundleGz !== 'string' || !k.bundleGz) throw refuse('no proof came with the key')
|
|
34
|
+
if (c.host !== VOICE_HOST || c.repo !== VOICE_REPO) throw refuse('the certificate is for another service')
|
|
35
|
+
const tls = String(c.tls || '').toLowerCase(), sum = String(c.bundle || '').toLowerCase()
|
|
36
|
+
if (!HEX64.test(tls) || !HEX64.test(sum)) throw refuse('the certificate is incomplete')
|
|
37
|
+
if (cache.get(sum) === tls) return c
|
|
38
|
+
let bundle
|
|
39
|
+
try {
|
|
40
|
+
const text = await gunzipText(k.bundleGz)
|
|
41
|
+
if (await sha256hex(text) !== sum) throw new Error('the evidence is not the certificate\'s')
|
|
42
|
+
bundle = JSON.parse(text)
|
|
43
|
+
} catch (e) { throw refuse(String((e && e.message) || 'unreadable evidence')) }
|
|
44
|
+
if (!bundle || bundle.domain !== VOICE_HOST) throw refuse('the evidence is for another host')
|
|
45
|
+
let r
|
|
46
|
+
try { const V = await loadVerifier(); r = await new V({ configRepo: VOICE_REPO }).verifyBundle(bundle) } catch (e) { throw refuse('the evidence does not verify') }
|
|
47
|
+
if (String((r && r.tlsPublicKeyFingerprint) || '').toLowerCase() !== tls) throw refuse('the evidence names another TLS key')
|
|
48
|
+
cache.set(sum, tls)
|
|
49
|
+
return c
|
|
50
|
+
}
|
package/voiceCert.js
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
// voiceCert.js — the press-to-talk certificate on a dictated message (docs/turn-certificates.md § Press-to-talk).
|
|
2
|
+
//
|
|
3
|
+
// op:'stt' answers with { cert, bundleGz }: Witbitz verified inference.tinfoil.sh's attestation (AMD root, the
|
|
4
|
+
// Sigstore-signed release, the TLS key) before it issued the key. A message the member dictated carries `voice` with
|
|
5
|
+
// that certificate. The raw ATC evidence (`bundleGz`, ~21 KB) rides only the FIRST dictated message per room per bundle,
|
|
6
|
+
// so the room keeps it once per Tinfoil release rather than once per message; this device remembers which it sent.
|
|
7
|
+
|
|
8
|
+
const SENT_KEY = 'wbVoiceBundles'
|
|
9
|
+
const MAX_ROOMS = 200
|
|
10
|
+
|
|
11
|
+
function sentMap() {
|
|
12
|
+
try { const m = JSON.parse(localStorage.getItem(SENT_KEY) || '{}'); return m && typeof m === 'object' ? m : {} } catch { return {} }
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
/** The `voice` field for a message about to be sent. `stt` = the op:'stt' answer the dictation used. */
|
|
16
|
+
export function voicePayload(room, stt) {
|
|
17
|
+
if (!stt || !stt.cert || !stt.cert.bundle) return null
|
|
18
|
+
const m = sentMap()
|
|
19
|
+
const had = Array.isArray(m[room]) && m[room].includes(stt.cert.bundle)
|
|
20
|
+
if (!had) {
|
|
21
|
+
m[room] = [...(Array.isArray(m[room]) ? m[room] : []), stt.cert.bundle].slice(-8)
|
|
22
|
+
const rooms = Object.keys(m)
|
|
23
|
+
for (const r of rooms.slice(0, Math.max(0, rooms.length - MAX_ROOMS))) delete m[r]
|
|
24
|
+
try { localStorage.setItem(SENT_KEY, JSON.stringify(m)) } catch { /* the bundle simply rides again next time */ }
|
|
25
|
+
}
|
|
26
|
+
return { model: stt.model || undefined, cert: stt.cert, ...(!had && stt.bundleGz ? { bundleGz: stt.bundleGz } : {}) }
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
const short = (h) => String(h || '').slice(0, 12)
|
|
30
|
+
const when = (iso) => { try { return new Date(iso).toLocaleString(undefined, { dateStyle: 'medium', timeStyle: 'short' }) } catch { return String(iso || '') } }
|
|
31
|
+
|
|
32
|
+
// What served the endpoint, and what Certificate Transparency says could have (agent/sttAudit.mjs).
|
|
33
|
+
function auditLine(a) {
|
|
34
|
+
if (!a || !a.live) return []
|
|
35
|
+
const live = `${a.live.addresses === 1 ? 'Its one live address serves' : `All ${a.live.addresses} live addresses serve`} the attested key`
|
|
36
|
+
const ct = !a.ct || a.ct.error ? 'Certificate Transparency could not be read' : `${a.ct.valid} valid certificates for the host: ${a.ct.recentVerified} of ${a.ct.recent} issued in the last day verified, ${a.ct.older} older not verifiable`
|
|
37
|
+
return [`${live}. ${ct} (checked ${when(a.checkedAt)}).`]
|
|
38
|
+
}
|
|
39
|
+
|
|
40
|
+
/** Readable lines for the long-press sheet. */
|
|
41
|
+
export function describeVoice(entry) {
|
|
42
|
+
const v = entry && entry.voice
|
|
43
|
+
if (!v || !v.cert) return []
|
|
44
|
+
const c = v.cert
|
|
45
|
+
return [
|
|
46
|
+
'🎙 Dictated. Speech-to-text ran in Tinfoil’s confidential enclave' + (v.model ? ` (${v.model})` : '') + '.',
|
|
47
|
+
`Verified by Witbitz before the key was issued, ${when(c.verifiedAt)}: ${c.host} runs ${c.repo}${c.release ? ' ' + c.release : ''} on AMD SEV-SNP.`,
|
|
48
|
+
`Measurement ${short(c.measurement)}… · TLS key ${short(c.tls)}… · evidence ${short(c.bundle)}…`,
|
|
49
|
+
...auditLine(c.audit),
|
|
50
|
+
]
|
|
51
|
+
}
|
|
@@ -0,0 +1,135 @@
|
|
|
1
|
+
// witbitz-admin.d.ts — types for https://witbitz-spaces.pages.dev/witbitz-admin.js, the builder's SERVER-SIDE client
|
|
2
|
+
// (2026-10-05). It takes your tenant SECRET key: never ship it, or this module, to a page.
|
|
3
|
+
// Held to the code by spaces/test/sdkTypesDrift.test.mjs. Prose: https://witbitz.chat/docs/sdk-builder.md#builder-calls
|
|
4
|
+
|
|
5
|
+
export interface WitbitzAdminOptions {
|
|
6
|
+
/** Your tenant's id (t_…) — the key proves it, the id names it. */
|
|
7
|
+
tenant?: string
|
|
8
|
+
/** Your tenant secret key (wsk_…). */
|
|
9
|
+
tenantKey: string
|
|
10
|
+
/** Your tenant's Ed25519 PRIVATE signing key (a JWK, or its JSON string) — `WitbitzAdmin.generateSigningKey()`. With it, every
|
|
11
|
+
* Sentinel request is signed, and once its public half is registered the Sentinel refuses an unsigned one. */
|
|
12
|
+
signingKey?: { kty: 'OKP'; crv: 'Ed25519'; d: string; x: string } | string
|
|
13
|
+
/** The Space endpoint; the authenticated tenant endpoint is derived from it. */
|
|
14
|
+
endpoint?: string
|
|
15
|
+
tenantEndpoint?: string
|
|
16
|
+
fetchImpl?: typeof fetch
|
|
17
|
+
sentinel?: unknown
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
/** Your app's name — what a sign-in mail from your declared origins says. 1–40 characters, never "Witbitz". */
|
|
21
|
+
export interface TenantApp {
|
|
22
|
+
rename(name: string): Promise<{ name: string }>
|
|
23
|
+
name(): Promise<string>
|
|
24
|
+
}
|
|
25
|
+
/** The page origins that act for this tenant. Declaring REPLACES the list. */
|
|
26
|
+
export interface Origins {
|
|
27
|
+
declare(origins: string[]): Promise<{ origins: string[]; unproven: { origin: string; how: string }[] }>
|
|
28
|
+
list(): Promise<string[]>
|
|
29
|
+
}
|
|
30
|
+
/** The hosts your users may attach a key for. Declaring REPLACES the list. */
|
|
31
|
+
export interface DeclaredHosts {
|
|
32
|
+
declare(hosts: string[]): Promise<{ hosts: string[] }>
|
|
33
|
+
list(): Promise<string[]>
|
|
34
|
+
}
|
|
35
|
+
/** Your own OAuth apps; the client secret is sealed to the attested enclave. */
|
|
36
|
+
export interface Providers {
|
|
37
|
+
attach(opts: { kind?: 'google'; clientId: string; clientSecret: string; redirectUri: string; scopes: string[]; label?: string; tenant?: string }): Promise<{ id: string; kind: string; tenant: string }>
|
|
38
|
+
/** A registered MCP client for an issuer that does not let apps register themselves (GitHub, Asana, Box…). */
|
|
39
|
+
/** `webhookSecret`: the secret the service signs its "the person removed your app" notices with (Zoom: the app's Secret Token) —
|
|
40
|
+
* point the service at https://api.witbitz.chat/v1/connections/removed/{vendor}/{tenant} and that person's connections are deleted. */
|
|
41
|
+
attachMcp(opts: { issuer: string; clientId: string; clientSecret?: string; redirectUris: string[]; label?: string; tenant?: string; webhookSecret?: string; scopes?: string | string[] }): Promise<{ id: string; kind: 'mcp'; tenant: string }>
|
|
42
|
+
list(): Promise<Array<{ id: string; kind: string; label?: string; [k: string]: unknown }>>
|
|
43
|
+
revoke(id: string): Promise<{ revoked: number; connections: number }>
|
|
44
|
+
}
|
|
45
|
+
export type Retain = 'none' | 'backups' | 'grace'
|
|
46
|
+
/** Delete or restore one of your rooms (sdk-builder.md#delete). */
|
|
47
|
+
export interface TenantRooms {
|
|
48
|
+
delete(room: string, opts?: { retain?: Retain; graceDays?: number; after?: 'none' | 'backups' }): Promise<{ deleted: boolean; room: string; [k: string]: unknown }>
|
|
49
|
+
restore(room: string): Promise<{ restored: true; room: string }>
|
|
50
|
+
/** Your rooms, a page at a time; pass `next` back as `cursor`. `lastUsedAt` is recorded since 2026-10-07. */
|
|
51
|
+
list(opts?: { cursor?: string; limit?: number }): Promise<{ rooms: TenantRoom[]; next: string | null }>
|
|
52
|
+
/** Hold rooms no member used for `days` (30–3650) for 30 days, then delete them; `null` turns it off. */
|
|
53
|
+
idleDeletion(days: number | null): Promise<{ idleRoomDays: number | null }>
|
|
54
|
+
}
|
|
55
|
+
export interface TenantRoom { room: string; createdAt: string | null; lastUsedAt: string | null; kind: string; split: boolean; gated: boolean; held: { purgeAt: string } | null }
|
|
56
|
+
export interface Customer { userId: string; userRef: string; capMonthlyUsd: number; createdAt?: string | number; revoked?: boolean }
|
|
57
|
+
/** Your app's billed customers — each with its own capped provider key. Not Witbitz accounts. */
|
|
58
|
+
export interface Customers {
|
|
59
|
+
create(opts: { userRef: string; capMonthlyUsd?: number }): Promise<Customer>
|
|
60
|
+
list(): Promise<Customer[]>
|
|
61
|
+
update(userId: string, opts: { capMonthlyUsd: number }): Promise<Customer>
|
|
62
|
+
revoke(userId: string): Promise<{ revoked: true; userId: string }>
|
|
63
|
+
/** Delete the Spaces this person created in your app that nobody else used (https://witbitz.chat/docs/sdk-builder.md#user-erasure). */
|
|
64
|
+
erase(opts: { email: string }): Promise<{ filed: boolean; rooms: number; deleted: number; shared: number; notTheirs: number; failed: number; cleared: boolean; [k: string]: unknown }>
|
|
65
|
+
/** A short-lived token for this customer's page (`wb.useUserToken`). `expiresAt` is unix seconds. */
|
|
66
|
+
token(userId: string, opts?: { ttlSec?: number }): Promise<{ token: string; expiresAt: number }>
|
|
67
|
+
}
|
|
68
|
+
/** What you are billed, in the provider's numbers (amounts in microdollars). */
|
|
69
|
+
export interface Billing {
|
|
70
|
+
get(): Promise<{ tenant: string; rate: unknown; month: unknown; storage: unknown; days: unknown[]; users: unknown[]; userDays: unknown[]; at: string | number }>
|
|
71
|
+
requireUserToken(on?: boolean): Promise<{ requireUserToken: boolean }>
|
|
72
|
+
/** Questions a day people who are not signed in may ask in your rooms — per network and in total; null turns it off (sdk-builder.md#visitor-limits). */
|
|
73
|
+
visitorLimit(limit: { perNetwork: number; total: number } | null): Promise<{ visitorLimit: { perNetwork: number; total: number } | null }>
|
|
74
|
+
csv(opts?: { byUser?: boolean }): Promise<string>
|
|
75
|
+
/** Your prepaid balance, or null when your app is not on prepaid billing. While `paused`, every op that spends in your rooms is refused (402 tenant_out_of_credit). */
|
|
76
|
+
/** `canBuy`: whether buying credit is open to your app now (while it is in testing, only to the apps in the test) — when false, topUp is refused.
|
|
77
|
+
* Each pack's `credit`: the dollars it adds to your balance — its price (`dollars`) less the payment seller's fee. */
|
|
78
|
+
balance(): Promise<{ balanceMicros: number; paused: string | null; lowWarned: boolean; earlyAccess: boolean; canBuy: boolean; packs: { pack: string; dollars: number; credit: number }[]; history: { at: number; kind: 'topup' | 'refund' | 'grant'; micros: number; orderId?: string; test?: boolean }[] } | null>
|
|
79
|
+
/** A payment page for one credit pack; send the person who pays to `url`. Refusals (`err.code`): `payments_not_open` (503, buying is not open yet),
|
|
80
|
+
* `not_prepaid` (409, your app is not on prepaid billing), `not_a_tester` (403, buying is in testing and not open to your app), `checkout_unavailable`
|
|
81
|
+
* (502, the payment page could not be made — try again), `forbidden` (403, not a secret key). */
|
|
82
|
+
topUp(pack: 'pack25' | 'pack100' | 'pack500', opts?: { redirectUrl?: string }): Promise<{ url: string; pack: string; dollars: number; testMode: boolean }>
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
/** What a RESTRICTED key (wrk_) may do — each opens the routes that need it, nothing else. */
|
|
86
|
+
export type Capability = 'customers:read' | 'customers:write' | 'customers:tokens' | 'customers:erase' | 'rooms:read' | 'rooms:write' | 'rooms:delete' | 'settings:read' | 'settings:write' | 'origins:write' | 'integrations:write' | 'billing:read' | 'wallets:grant' | 'apps:release'
|
|
87
|
+
export interface ApiKeyInfo { keyId: string; type: 'secret' | 'publishable' | 'restricted'; label: string; createdAt: string; revoked: boolean; display: string; scopes?: Capability[]; expiresAt?: string | null; maxCustomerCapUsd?: number | null }
|
|
88
|
+
/** Your API keys. Managed with your SECRET key only; a restricted key can never mint, revoke or list keys. */
|
|
89
|
+
export interface TenantKeys {
|
|
90
|
+
list(): Promise<ApiKeyInfo[]>
|
|
91
|
+
/** `key` is shown ONCE. A restricted key needs `scopes`; `expiresAt` (≤ 2 years) and `maxCustomerCapUsd` are optional. */
|
|
92
|
+
create(opts: { type?: 'restricted' | 'secret' | 'publishable'; label?: string; scopes?: Capability[]; expiresAt?: string | number; maxCustomerCapUsd?: number }): Promise<{ key: string; keyId: string; type: string; scopes?: Capability[]; maxCustomerCapUsd?: number | null; expiresAt?: string | null }>
|
|
93
|
+
revoke(keyId: string): Promise<{ revoked: true; keyId: string }>
|
|
94
|
+
}
|
|
95
|
+
|
|
96
|
+
export interface TenantSigning {
|
|
97
|
+
/** File a signing key's PUBLIC half (default: this client's own). The first on the tenant key alone; a new one only signed by the current one. */
|
|
98
|
+
register(publicKey?: string): Promise<{ ok: true; key: string }>
|
|
99
|
+
/** Which key the Sentinel holds for this tenant — watch it: a record can be deleted from the store, never forged. */
|
|
100
|
+
status(): Promise<{ registered: boolean; key: string | null; origins: string[] | null }>
|
|
101
|
+
/** File your SIGNED origin list with the Sentinel (default: origins.list()); then only those pages may name your tenant there. */
|
|
102
|
+
publishOrigins(origins?: string[]): Promise<{ ok: true; origins: string[] }>
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
/** RETIRED in 4.0.0 — the owner rule (rooms only your app may use): its only rule required a page SERVED as your app, which a web page
|
|
106
|
+
* cannot prove. Every call rejects with `owner_rule_retired`. Kept as a name so old code fails loudly, not with a TypeError. */
|
|
107
|
+
export interface TenantOwner {
|
|
108
|
+
/** @deprecated retired in 4.0.0 — rejects with `owner_rule_retired` */ register(...args: unknown[]): Promise<never>
|
|
109
|
+
/** @deprecated retired in 4.0.0 — rejects with `owner_rule_retired` */ rotate(...args: unknown[]): Promise<never>
|
|
110
|
+
/** @deprecated retired in 4.0.0 — rejects with `owner_rule_retired` */ room(...args: unknown[]): Promise<never>
|
|
111
|
+
}
|
|
112
|
+
export declare class WitbitzAdmin {
|
|
113
|
+
constructor(opts: WitbitzAdminOptions)
|
|
114
|
+
/** A new Ed25519 signing key: keep `privateKey` on your server; `publicKey` (raw, base64url) is what `signing.register` files. */
|
|
115
|
+
static generateSigningKey(): Promise<{ privateKey: { kty: 'OKP'; crv: 'Ed25519'; d: string; x: string }; publicKey: string }>
|
|
116
|
+
/** @deprecated retired in 4.0.0 (the owner rule) — rejects with `owner_rule_retired` */
|
|
117
|
+
static generateOwnerKey(): Promise<never>
|
|
118
|
+
readonly signing: TenantSigning
|
|
119
|
+
readonly origins: Origins
|
|
120
|
+
/** Your app's name, as your users see it in a sign-in mail. */
|
|
121
|
+
readonly app: TenantApp
|
|
122
|
+
readonly hosts: DeclaredHosts
|
|
123
|
+
readonly providers: Providers
|
|
124
|
+
readonly rooms: TenantRooms
|
|
125
|
+
readonly customers: Customers
|
|
126
|
+
readonly billing: Billing
|
|
127
|
+
readonly keys: TenantKeys
|
|
128
|
+
/** @deprecated retired in 4.0.0 — every call rejects with `owner_rule_retired` */
|
|
129
|
+
readonly owner: TenantOwner
|
|
130
|
+
/** Is this key good, and whose is it? A refused key answers `ok: false`; a missing key throws. */
|
|
131
|
+
verifyTenantKey(): Promise<{ ok: true; tenant: string } | { ok: false; reason: string; code?: string }>
|
|
132
|
+
/** What logs and serialisers see: never the key. */
|
|
133
|
+
toJSON(): { tenant: string | null; tenantKey: '[REDACTED]' | null; signingKey?: '[REDACTED]' }
|
|
134
|
+
}
|
|
135
|
+
export declare const DEFAULT_ENDPOINT: string
|