Skip to content

API reference

static newDeviceId(): string
static open<K>(opts: EngineOptions<K>): Promise<SkmEngine<K>>
// graphs
openGraph(graphId, o?: SubscriptionSpec & {create?: boolean}): Promise<GraphStatus>
subscribe(graphId, spec: SubscriptionSpec): void
graphs(): string[]
hasKey(graphId): boolean
// records
put(graphId, {id?, kind, data, deleted?, by?}): Promise<GraphRecord>
putMany(graphId, partials[]): Promise<GraphRecord[]>
remove(graphId, id): Promise<void>
removeMany(graphId, ids[]): Promise<void>
get(graphId, id): Promise<GraphRecord | null>
list(graphId): Promise<GraphRecord[]>
listKind(graphId, kind, limit?): Promise<GraphRecord[]>
search(graphId, query, limit?): Promise<GraphRecord[]>
searchAll(query, limit?): Promise<Array<{graphId, record}>>
personalId(kind, target): Promise<string>
// reactivity
watch<T>(graphId, query, onResult): () => void
on(event: EngineEventName | '*', fn): () => void
readonly status: EngineStatus
// sync
sync(): Promise<void>
syncGraph(graphId): Promise<void>
flush(): Promise<void>
poke(graphId): Promise<void>
startAutoSync(everyMs?): void
stopAutoSync(): void
close(): Promise<void>
// keys and devices
createGraphKey(graphId): Promise<GraphStatus>
grantPending(graphId): Promise<number>
rotate(graphId): Promise<number>
listDevices(): Promise<Array<{deviceId, label, createdAt, revokedAt}>>
revokeDevice(deviceId): Promise<{rotated: string[]; failed: string[]; owed: number}>
// invites and recovery
sealKeyringForInvite(graphId): Promise<{salt, sealedKeyring, keySecret} | null>
acceptInviteKeyring(graphId, {salt, sealedKeyring, keySecret}): Promise<boolean>
exportBundle(passphrase): Promise<string>
importBundle(blob, passphrase): Promise<void>
// blobs
uploadBlob(graphId, bytes, {policy?, ttlMs?}): Promise<string>
downloadBlob(graphId, blobId): Promise<Uint8Array>
ackBlob(graphId, blobId): Promise<void>
(SkmEngine, HttpTransport, TransportError);
(MemoryGraphStore, IdbGraphStore, OpfsGraphStore, SqlGraphStore, bestStore, migrateStore);
(MemoryKeyStore, IdbKeyStore);
(defineKinds, validateRecord, recordBytes);
// types
(EngineOptions,
EngineStatus,
EngineEvent,
EngineEventName,
GraphStatus,
GraphKeyState,
RetryPolicy,
SubscriptionSpec,
Transport,
HttpTransportOptions,
PullFilter,
GraphStore,
KeyStore,
KindRegistry,
KindValidator,
KindData,
ValidationFailure,
GraphRecord,
RosterDevice);

@skm/client/node: NodeSqliteGraphStore, FileKeyStore, SqlGraphStore. @skm/client/opfs-worker: the worker entry point for OpfsGraphStore.

(registerRelay, sweepBlobs, DEFAULT_QUOTAS);
(openDb, migrate, transact, now, Statements, SCHEMA_VERSION);
(SqliteDirectory, SqliteBlobStore, FileBlobStore, MemoryRateLimiter, NO_LIMIT);
// types
(RelayOptions,
RelayQuotas,
RelayRateLimits,
RelayEvent,
SkmIdentity,
PokeEvent,
SweepOptions,
Db,
OpenDbOptions,
Directory,
BlobStore,
RateLimiter,
BucketSpec);
skmcrypto; // the whole crypto boundary, namespaced
(LIMITS, PBKDF2_ITERATIONS, clearKeyCache, parse);
(composeInvite, splitInvite);
(recordSigningBytes, recordAad, blobAad, storageKeyFor, isSafeId, splitFilter);
// schemas and types
(GraphId,
GraphOpIn,
GraphOpOut,
GraphPush,
GraphPushResp,
GraphPullResp,
PullQuery,
GraphRecordShape,
RecordEnvelope,
GraphRecord,
Keyring,
KeyringShape,
DeviceRegister,
RosterDevice,
KeyGap,
GraphKeysPut,
GraphKeysResp,
RecoveryBundle,
RecoveryPayload,
Sealed,
WrappedKey,
DeviceKeyPair);