@witbitz/sdk 0.0.0-stage → 4.4.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 +221 -0
- package/a2aShared.js +27 -0
- package/accountErase.js +228 -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/agentDoorTools.js +28 -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 +165 -0
- package/chatLockSw.js +13 -0
- package/cloudDeviceBuilds.js +11 -0
- package/cloudDevicePins.js +33 -0
- package/cloudDeviceSeal.js +53 -0
- package/codeAttachments.js +100 -0
- package/codeBrowse.js +224 -0
- package/codeCache.js +149 -0
- package/codeCloud.js +650 -0
- package/codeCloudKeys.js +112 -0
- package/codeCommands.js +167 -0
- package/codeComputers.js +389 -0
- package/codeEgress.js +123 -0
- package/codeFilesRoutes.js +17 -0
- package/codeFolders.js +116 -0
- package/codeHistory.js +76 -0
- package/codeLanguage.js +54 -0
- package/codeMkdir.js +8 -0
- package/codeModes.js +59 -0
- package/codeOrphanKeys.js +42 -0
- package/codeOutputs.js +141 -0
- package/codeProgress.js +54 -0
- package/codeRelay.js +505 -0
- package/codeSent.js +68 -0
- package/codeSentinel.js +86 -0
- package/codeSubagents.js +107 -0
- package/codeTransport.js +317 -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 +561 -0
- package/credits.js +30 -0
- package/csAttest.js +112 -0
- package/decrypt.html +384 -0
- package/deviceAttest.js +527 -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 +113 -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 +91 -0
- package/l1-worker-src.js +2 -0
- package/l1-worker.js +894 -0
- package/laneAssociation.js +68 -0
- package/laneConfig.js +58 -0
- package/laneLinkCore.js +177 -0
- package/ledgerView.js +64 -0
- package/manifest.json +239 -0
- package/mcpRecommended.js +25 -0
- package/memberChange.js +125 -0
- package/mirrorBatch.js +47 -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/opRouting.js +10 -0
- package/opencodeWire.js +282 -0
- package/oprf.js +70 -0
- package/ownAgentLink.js +96 -0
- package/ownerPolicy.js +117 -0
- package/package.json +273 -4
- package/pdfOptions.js +13 -0
- package/pdfText.js +107 -0
- package/pdfjs.mjs +28 -0
- package/pdfjs.worker.mjs +28 -0
- package/pollVerdict.js +33 -0
- package/prefetchPoll.js +60 -0
- package/protectedLocal.js +426 -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/roomEmbed.js +111 -0
- package/roomName.js +177 -0
- package/roomPass.js +256 -0
- package/roomRoster.js +305 -0
- package/roomSettings.js +61 -0
- package/roomState.js +58 -0
- package/roomStreamClient.js +115 -0
- package/rosterCount.js +52 -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 +524 -0
- package/sdkAccount.js +483 -0
- package/sdkAccountDoc.js +89 -0
- package/sdkAccountSections.js +332 -0
- package/sdkAgui.js +141 -0
- package/sdkAttest.js +34 -0
- package/sdkBackup.js +507 -0
- package/sdkBackupV2.js +630 -0
- package/sdkBrowserPrivate.js +28 -0
- package/sdkBuilds.js +208 -0
- package/sdkCloudDevice.js +221 -0
- package/sdkComputers.js +1009 -0
- package/sdkDictation.js +232 -0
- package/sdkErase.js +288 -0
- package/sdkExports.js +71 -0
- package/sdkInvitations.js +34 -0
- package/sdkKeptAgent.js +188 -0
- package/sdkLaneLink.js +205 -0
- package/sdkPlan.js +96 -0
- package/sdkProtect.js +228 -0
- package/sdkRedact.js +36 -0
- package/sdkRekey.js +340 -0
- package/sdkReport.js +68 -0
- package/sdkSafeMedia.js +255 -0
- package/sdkSchedules.js +39 -0
- package/sdkSpeech.js +71 -0
- package/sdkTemporaryRooms.js +123 -0
- package/sdkTurn.js +117 -0
- package/sdkVault.js +180 -0
- package/sealShare.js +18 -0
- package/sealedNames.js +64 -0
- package/sealedReceipt.js +17 -0
- package/sentinelRelease.js +155 -0
- package/shamir.js +85 -0
- package/sharedViews.js +52 -0
- package/sheetChrome.js +450 -0
- package/siri.js +278 -0
- package/spaceClient.js +1429 -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/spaceTemplates.js +99 -0
- package/speechOut.js +102 -0
- package/splitKeyClient.js +90 -0
- package/store.js +656 -0
- package/streamHint.js +36 -0
- package/sttCloud.js +220 -0
- package/sttWorklet.js +38 -0
- package/sw-notif-core.js +540 -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 +37 -0
- package/usageReceipts.js +176 -0
- package/usageSummary.js +90 -0
- package/util.js +181 -0
- package/vault-core.js +2326 -0
- package/vault-kit.mjs +354 -0
- package/vault-screens.js +261 -0
- package/vaultAtRest.js +208 -0
- package/vaultCoreLock.js +111 -0
- package/vaultCorePush.js +140 -0
- package/vaultDeviceKey.js +95 -0
- package/vaultEnclaveHandoff.js +114 -0
- package/vaultKeep.js +287 -0
- package/vaultSealedStore.js +77 -0
- package/vaultWorkerHost.js +117 -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 +1460 -0
- package/witbitz-sdk.d.ts +1197 -0
- package/witbitz-sdk.js +4258 -0
- package/workerClient.js +16 -0
- package/workerLiveness.js +21 -0
- package/x509.js +218 -0
package/spaceConfig.js
ADDED
|
@@ -0,0 +1,81 @@
|
|
|
1
|
+
// M3 — Configurable Space: build a Space from a CONFIG (docs/configurable-space-m3.md). Generalizes the shared-presence
|
|
2
|
+
// KEY MODEL — 1-of-1 (solo) / 2-of-2 (couple) / k-of-n (team) — so ONE engine serves any small private AI Space, not
|
|
3
|
+
// just couples. The config is to a Space what the manifest is to an agent: { keyModel, agent(persona), tools,
|
|
4
|
+
// presence }. This module handles the KEY part (mint + distribute + reassemble); the agent/tools/presence are config
|
|
5
|
+
// fields the engine (spaceService) reads. A Space's capabilities are just TOOLS (declaredTools) — already config, no
|
|
6
|
+
// separate "actions" concept; the only async-Space addition is delegatedAuthority (approve-then-execute + audit).
|
|
7
|
+
import { newKey, splitKey, combineShares, commit } from './e2ee.js'
|
|
8
|
+
import { shamirSplit, shamirCombine } from './shamir.js'
|
|
9
|
+
import { newRoomId } from './regions.js'
|
|
10
|
+
|
|
11
|
+
const enc = (s) => encodeURIComponent(String(s))
|
|
12
|
+
|
|
13
|
+
/** Normalize a keyModel → { k, n }. '1-of-1' → {1,1} (solo); '2-of-2' → {2,2} (couple); { k, n } → a k-of-n team. */
|
|
14
|
+
export function normalizeKeyModel(km) {
|
|
15
|
+
if (km == null || km === '1-of-1') return { k: 1, n: 1 }
|
|
16
|
+
if (km === '2-of-2') return { k: 2, n: 2 }
|
|
17
|
+
if (km && Number.isInteger(km.k) && Number.isInteger(km.n) && km.k >= 1 && km.k <= km.n) return { k: km.k, n: km.n }
|
|
18
|
+
throw new Error('bad keyModel')
|
|
19
|
+
}
|
|
20
|
+
|
|
21
|
+
/** Build a Space from a config. Mints mk, distributes it per the key model, returns { room, commit, keyModel:{k,n},
|
|
22
|
+
* links[] }. Each link carries the room (query, server-visible) + ONE piece in the FRAGMENT — a share (`#s=`), or, for
|
|
23
|
+
* 1-of-1, mk itself (`#mk=`). mk is DISCARDED (reconstructable from the shares); the server stores only commit(mk). */
|
|
24
|
+
export async function createConfiguredSpace(config = {}, { base = '' } = {}) {
|
|
25
|
+
const { k, n } = normalizeKeyModel(config.keyModel)
|
|
26
|
+
// A SOLO room may be made with a key the caller derived (the SDK's account index, sdkAccount.js: every device holding
|
|
27
|
+
// the account derives the same room and key, so two devices can never make two indexes). Any other model mints.
|
|
28
|
+
const mk = (n === 1 && typeof config.mk === 'string' && config.mk.length >= 40) ? config.mk : newKey()
|
|
29
|
+
// `region`: the room's HOME region (regions.js, docs/multi-region.md) — the caller decides: a lane takes its shared room's,
|
|
30
|
+
// a moved room keeps its own, a new Space takes its creator's; the account's own rooms (index, pipes) pass none and stay
|
|
31
|
+
// in the default region. Never sealed into the config — it is in the id.
|
|
32
|
+
const room = config.room || newRoomId(config.region)
|
|
33
|
+
const c = await commit(mk)
|
|
34
|
+
const link = (frag) => `${String(base).replace(/\/+$/, '')}/space?room=${enc(room)}#${frag}`
|
|
35
|
+
let links
|
|
36
|
+
if (n === 1) {
|
|
37
|
+
links = [link(`mk=${enc(mk)}`)] // solo: the single member's link carries mk (like the gift today)
|
|
38
|
+
} else if (k === 2 && n === 2) {
|
|
39
|
+
const { shareA, shareB } = splitKey(mk) // couple: XOR 2-of-2 (the simplest, perfect case)
|
|
40
|
+
links = [link(`s=${enc(shareA)}`), link(`s=${enc(shareB)}`)]
|
|
41
|
+
} else {
|
|
42
|
+
links = shamirSplit(mk, k, n).map((s) => link(`s=${enc(s)}`)) // team: Shamir k-of-n
|
|
43
|
+
}
|
|
44
|
+
return { room, commit: c, keyModel: { k, n }, links }
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
/** Assemble the room key from the present members' pieces, per the config's key model, verified against the commitment.
|
|
48
|
+
* `pieces` = the shares from present members (or [mk] for solo). Returns mk, or null if the threshold isn't met / the
|
|
49
|
+
* reconstruction doesn't match the commit (the room stays sealed). */
|
|
50
|
+
export async function assembleConfiguredKey(pieces, config, expectedCommit) {
|
|
51
|
+
const { k, n } = normalizeKeyModel(config && config.keyModel)
|
|
52
|
+
const arr = Array.isArray(pieces) ? pieces.filter(Boolean) : pieces ? [pieces] : []
|
|
53
|
+
let mk = null
|
|
54
|
+
if (n === 1) mk = arr[0] || null // solo: the piece IS mk
|
|
55
|
+
else if (k === 2 && n === 2) mk = arr.length >= 2 ? combineShares(arr[0], arr[1]) : null
|
|
56
|
+
else mk = arr.length >= k ? shamirCombine(arr) : null // team: need ≥ k
|
|
57
|
+
if (mk == null) return null
|
|
58
|
+
// §6.4 (tenant-split-key-design.md): a MULTI-SHARE reconstruction (n > 1: couple/team) is only trustworthy once checked
|
|
59
|
+
// against the room's registered commitment. Refuse to return a combined key with no commit to verify it — the solo case
|
|
60
|
+
// (n === 1: the link IS mk) is exempt, since a wrong link simply fails AES-GCM downstream, not a silent wrong-key.
|
|
61
|
+
if (n > 1 && !expectedCommit) return null
|
|
62
|
+
if (expectedCommit && (await commit(mk)) !== expectedCommit) return null
|
|
63
|
+
return mk
|
|
64
|
+
}
|
|
65
|
+
|
|
66
|
+
/** Read a Space link → { room, share?, mk? } (room from the query; share/mk from the fragment). */
|
|
67
|
+
export function parseConfiguredLink(url) {
|
|
68
|
+
try {
|
|
69
|
+
const u = new URL(url)
|
|
70
|
+
// The fragment is `<space-params>?<identity-params>` — a member link appends `?gk=…>=…&sk=…` (see entrySig
|
|
71
|
+
// appendIdentity) after `#mk=…`/`#s=…`. Parse ONLY the part before that first `?`, or `mk`/`s` would swallow the
|
|
72
|
+
// whole identity blob (`mk=<key>?gk=…`) and fail to base64-decode → the invite lands on the create screen. Identity
|
|
73
|
+
// is read separately (readIdentity, from after the `?`).
|
|
74
|
+
const raw = (u.hash || '').replace(/^#/, '')
|
|
75
|
+
const q = raw.indexOf('?')
|
|
76
|
+
const frag = new URLSearchParams(q >= 0 ? raw.slice(0, q) : raw)
|
|
77
|
+
return { room: u.searchParams.get('room') || '', share: frag.get('s') || '', mk: frag.get('mk') || '' }
|
|
78
|
+
} catch {
|
|
79
|
+
return { room: '', share: '', mk: '' }
|
|
80
|
+
}
|
|
81
|
+
}
|