@muhkoo/connect 0.6.0-alpha.11 → 0.7.0-alpha.4
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 +11 -13
- package/dist/browser/index.js +618 -75
- package/dist/browser/index.js.map +1 -1
- package/dist/connect.d.ts +326 -10
- package/dist/server/index.js +618 -75
- package/dist/server/index.js.map +1 -1
- package/package.json +1 -1
package/dist/connect.d.ts
CHANGED
|
@@ -1812,15 +1812,17 @@ interface AuthSuccess {
|
|
|
1812
1812
|
token: string;
|
|
1813
1813
|
username: string;
|
|
1814
1814
|
}
|
|
1815
|
-
/** A vault factor record (M1.0). Wrap/iv are base64 AES-GCM; absent for phrase. */
|
|
1815
|
+
/** A vault factor record (M1.0 + M2 gated types). Wrap/iv are base64 AES-GCM; absent for phrase. */
|
|
1816
1816
|
interface VaultFactor {
|
|
1817
1817
|
id: string;
|
|
1818
|
-
type: "password" | "passkey" | "phrase-marker";
|
|
1818
|
+
type: "password" | "passkey" | "phrase-marker" | "email" | "google";
|
|
1819
1819
|
wrap?: string;
|
|
1820
1820
|
iv?: string;
|
|
1821
1821
|
params?: Record<string, unknown>;
|
|
1822
1822
|
label?: string;
|
|
1823
1823
|
createdAt?: number;
|
|
1824
|
+
/** Display hint for gated factors ("m•••@gmail.com") — list responses only. */
|
|
1825
|
+
masked?: string;
|
|
1824
1826
|
}
|
|
1825
1827
|
interface AuthClientOptions {
|
|
1826
1828
|
/** Absolute URL of the accelerator worker (no trailing slash required). */
|
|
@@ -1850,12 +1852,82 @@ declare class AuthClient {
|
|
|
1850
1852
|
oprfEvaluate(username: string, blinded: string): Promise<{
|
|
1851
1853
|
evaluated: string;
|
|
1852
1854
|
}>;
|
|
1853
|
-
/**
|
|
1854
|
-
|
|
1855
|
+
/**
|
|
1856
|
+
* Gated split-key OPRF evaluation (M2 — email/google factors). Requires a
|
|
1857
|
+
* live `verifyToken` from {@link emailOtpVerify}; returns BOTH trust
|
|
1858
|
+
* domains' evaluations. The recover token is consumed by this call.
|
|
1859
|
+
*/
|
|
1860
|
+
oprfEvaluateGated(username: string, blinded: string, factorType: "email" | "google", purpose: "enroll" | "recover", verifyToken: string): Promise<{
|
|
1861
|
+
evaluated: string;
|
|
1862
|
+
evaluated2: string;
|
|
1863
|
+
}>;
|
|
1864
|
+
/**
|
|
1865
|
+
* Request an email OTP. With a session `token` this is the ENROLL flow
|
|
1866
|
+
* (code sent to `email`); without one it's RECOVER (code sent to the
|
|
1867
|
+
* account's enrolled address — the response is uniform either way).
|
|
1868
|
+
*/
|
|
1869
|
+
emailOtpStart(opts: {
|
|
1870
|
+
token?: string;
|
|
1871
|
+
email?: string;
|
|
1872
|
+
username?: string;
|
|
1873
|
+
}): Promise<void>;
|
|
1874
|
+
/** Trade an emailed code for a single-use verifyToken (+ the proven address). */
|
|
1875
|
+
emailOtpVerify(opts: {
|
|
1876
|
+
code: string;
|
|
1877
|
+
token?: string;
|
|
1878
|
+
username?: string;
|
|
1879
|
+
}): Promise<{
|
|
1880
|
+
verifyToken: string;
|
|
1881
|
+
email: string;
|
|
1882
|
+
}>;
|
|
1883
|
+
/**
|
|
1884
|
+
* Verify a Google ID token (M2.3). With a session `token` it's the ENROLL
|
|
1885
|
+
* gate; without, it's RECOVER/LOGIN (the Google account must already be
|
|
1886
|
+
* linked). Returns a single-use verifyToken bound to the account's `sub`.
|
|
1887
|
+
*/
|
|
1888
|
+
googleVerify(opts: {
|
|
1889
|
+
idToken: string;
|
|
1890
|
+
token?: string;
|
|
1891
|
+
username?: string;
|
|
1892
|
+
}): Promise<{
|
|
1893
|
+
verifyToken: string;
|
|
1894
|
+
sub: string;
|
|
1895
|
+
emailHint: string | null;
|
|
1896
|
+
}>;
|
|
1897
|
+
/** Mint a single-use authorization code for an app (called by the hosted page; session-authed). */
|
|
1898
|
+
grant(token: string, body: {
|
|
1899
|
+
appId: string;
|
|
1900
|
+
redirectUri: string;
|
|
1901
|
+
codeChallenge: string;
|
|
1902
|
+
sealedKeys: string;
|
|
1903
|
+
}): Promise<{
|
|
1904
|
+
code: string;
|
|
1905
|
+
}>;
|
|
1906
|
+
/** Exchange an authorization code + PKCE verifier for the session + sealed key material. */
|
|
1907
|
+
token(body: {
|
|
1908
|
+
code: string;
|
|
1909
|
+
codeVerifier: string;
|
|
1910
|
+
appId?: string;
|
|
1911
|
+
}): Promise<{
|
|
1912
|
+
sessionToken: string;
|
|
1913
|
+
username: string;
|
|
1914
|
+
commitment: string;
|
|
1915
|
+
sealedKeys: string;
|
|
1916
|
+
appId: string;
|
|
1917
|
+
}>;
|
|
1918
|
+
/**
|
|
1919
|
+
* Read a factor record for `username` (returns an indistinguishable decoy if
|
|
1920
|
+
* absent). Gated types (email) require the recover `verifyToken`.
|
|
1921
|
+
*/
|
|
1922
|
+
vaultRead(username: string, factorType: VaultFactor["type"], verifyToken?: string): Promise<{
|
|
1855
1923
|
factor: VaultFactor | null;
|
|
1856
1924
|
}>;
|
|
1857
|
-
/**
|
|
1858
|
-
|
|
1925
|
+
/**
|
|
1926
|
+
* Add/replace a factor (session-authed; the seed is already wrapped
|
|
1927
|
+
* client-side). Email factors additionally require (and consume) the
|
|
1928
|
+
* enroll `verifyToken`; the stored address must be the verified one.
|
|
1929
|
+
*/
|
|
1930
|
+
vaultPutFactor(token: string, factor: VaultFactor, verifyToken?: string): Promise<{
|
|
1859
1931
|
ok: boolean;
|
|
1860
1932
|
id: string;
|
|
1861
1933
|
}>;
|
|
@@ -2052,6 +2124,44 @@ declare function exportPublicKeyBase64(publicKey: CryptoKey): Promise<string>;
|
|
|
2052
2124
|
/** Sign a UTF-8 `message` with an ECDSA private key. Returns base64. */
|
|
2053
2125
|
declare function signMessage(message: string, privateKey: CryptoKey): Promise<string>;
|
|
2054
2126
|
|
|
2127
|
+
/**
|
|
2128
|
+
* Hosted-auth handoff crypto (auth.muhkoo.dev — AUTH_HOSTED_PLAN.md §3).
|
|
2129
|
+
*
|
|
2130
|
+
* The hosted page authenticates the user and ends up holding the master seed.
|
|
2131
|
+
* To pass it to the developer's app without it ever sitting server-readable or
|
|
2132
|
+
* landing in browser history:
|
|
2133
|
+
*
|
|
2134
|
+
* 1. {@link sealSeed} generates a one-time key K_t, AES-256-GCM-seals the seed
|
|
2135
|
+
* under it, and returns the ciphertext envelope (`sealedKeys`, stored in
|
|
2136
|
+
* the grant the server relays but can't read) plus K_t (`fragmentKey`,
|
|
2137
|
+
* placed ONLY in the redirect URL fragment — fragments never hit a server).
|
|
2138
|
+
* 2. The app exchanges the code for `sealedKeys`, reads K_t from the fragment,
|
|
2139
|
+
* and {@link unsealSeed} recovers the seed, then strips the fragment.
|
|
2140
|
+
*
|
|
2141
|
+
* Trust-equivalent to today's embedded SDK (the app still ends up with the
|
|
2142
|
+
* seed) while moving credential entry onto the Muhkoo origin. The envelope is
|
|
2143
|
+
* versioned so a future per-app-key handoff (v2) can swap in without a protocol
|
|
2144
|
+
* change.
|
|
2145
|
+
*/
|
|
2146
|
+
interface SealedHandoff {
|
|
2147
|
+
/** base64 JSON envelope — relayed by the server in the grant; server-opaque. */
|
|
2148
|
+
sealedKeys: string;
|
|
2149
|
+
/** base64url one-time key — rides ONLY in the redirect URL fragment. */
|
|
2150
|
+
fragmentKey: string;
|
|
2151
|
+
}
|
|
2152
|
+
/** Seal the master seed under a fresh one-time key for the redirect handoff. */
|
|
2153
|
+
declare function sealSeed(seed: Uint8Array): Promise<SealedHandoff>;
|
|
2154
|
+
/** Recover the master seed from the sealed envelope + the fragment key. */
|
|
2155
|
+
declare function unsealSeed(sealedKeys: string, fragmentKey: string): Promise<Uint8Array>;
|
|
2156
|
+
interface Pkce {
|
|
2157
|
+
codeVerifier: string;
|
|
2158
|
+
codeChallenge: string;
|
|
2159
|
+
}
|
|
2160
|
+
/** Generate a PKCE verifier + S256 challenge for the authorize→token exchange. */
|
|
2161
|
+
declare function generatePkce(): Promise<Pkce>;
|
|
2162
|
+
/** A random URL-safe value for the OAuth `state` (CSRF binding on the callback). */
|
|
2163
|
+
declare function randomState(): string;
|
|
2164
|
+
|
|
2055
2165
|
/**
|
|
2056
2166
|
* `SessionState` — the in-memory source of truth for "who is signed in" on a
|
|
2057
2167
|
* {@link Client}.
|
|
@@ -2162,6 +2272,87 @@ declare class SessionState {
|
|
|
2162
2272
|
clear(): Promise<void>;
|
|
2163
2273
|
}
|
|
2164
2274
|
|
|
2275
|
+
/**
|
|
2276
|
+
* `client.auth.hosted` — centralized hosted auth (auth.muhkoo.dev).
|
|
2277
|
+
* AUTH_HOSTED_PLAN.md.
|
|
2278
|
+
*
|
|
2279
|
+
* Two sides share this class:
|
|
2280
|
+
* - **Developer apps** call {@link login} (redirect to the hosted page) and
|
|
2281
|
+
* {@link handleCallback} (exchange the returned code → session + seed). The
|
|
2282
|
+
* app carries no snarkjs and never sees the user's credentials.
|
|
2283
|
+
* - **The hosted page** (the muhkoo/auth SPA), once it has authenticated the
|
|
2284
|
+
* user via the normal `client.auth.zk.*` flow, calls
|
|
2285
|
+
* {@link completeAuthorize} to seal the seed, mint the grant, and build the
|
|
2286
|
+
* redirect-back URL.
|
|
2287
|
+
*
|
|
2288
|
+
* Flow (authorization-code + PKCE + sealed-seed handoff):
|
|
2289
|
+
* app → GET auth.muhkoo.dev/authorize?app_id&redirect_uri&state&code_challenge
|
|
2290
|
+
* page → (user authenticates) → POST /api/auth/grant → redirect_uri?code&state#k=<K_t>
|
|
2291
|
+
* app → POST /api/auth/token {code, code_verifier} → {sessionToken, sealedKeys}
|
|
2292
|
+
* → unseal sealedKeys with K_t → master seed → session ready
|
|
2293
|
+
*/
|
|
2294
|
+
|
|
2295
|
+
interface HostedAuthDeps {
|
|
2296
|
+
auth: AuthClient;
|
|
2297
|
+
session: SessionState;
|
|
2298
|
+
/** Base URL of the hosted auth SPA (e.g. https://auth.muhkoo.dev). */
|
|
2299
|
+
authBaseUrl: string;
|
|
2300
|
+
}
|
|
2301
|
+
interface AuthUser$1 {
|
|
2302
|
+
username: string;
|
|
2303
|
+
commitment: string;
|
|
2304
|
+
}
|
|
2305
|
+
declare class HostedAuth {
|
|
2306
|
+
private readonly deps;
|
|
2307
|
+
constructor(deps: HostedAuthDeps);
|
|
2308
|
+
/**
|
|
2309
|
+
* (App side) Begin hosted login: stash a PKCE verifier + state, then send
|
|
2310
|
+
* the browser to the hosted authorize page. Returns the URL it redirects to
|
|
2311
|
+
* (also useful for popup mode / tests). `redirectUri` must be registered for
|
|
2312
|
+
* the app in the portal.
|
|
2313
|
+
*/
|
|
2314
|
+
login(opts: {
|
|
2315
|
+
appId: string;
|
|
2316
|
+
redirectUri: string;
|
|
2317
|
+
redirect?: boolean;
|
|
2318
|
+
}): Promise<string>;
|
|
2319
|
+
/**
|
|
2320
|
+
* (App side) Send the user to centralized account & security management on
|
|
2321
|
+
* the hosted page (auth.muhkoo.dev/security) — manage passkeys, recovery
|
|
2322
|
+
* phrase, email, Google, change password, and remove login methods, all in
|
|
2323
|
+
* one place. `returnUri` (default: the current URL) gives the hosted page a
|
|
2324
|
+
* "Back to app" target. Redirects the browser; resolves to the URL.
|
|
2325
|
+
*/
|
|
2326
|
+
manageAccount(opts?: {
|
|
2327
|
+
returnUri?: string;
|
|
2328
|
+
}): Promise<string>;
|
|
2329
|
+
/** Whether the current URL looks like a hosted-auth callback (has code + state). */
|
|
2330
|
+
isCallback(): boolean;
|
|
2331
|
+
/**
|
|
2332
|
+
* (App side) Complete login on the callback URL: verify state, exchange the
|
|
2333
|
+
* code (+ PKCE verifier) for the session, unseal the seed from the fragment,
|
|
2334
|
+
* establish the session, and scrub the URL. Returns the signed-in user.
|
|
2335
|
+
*/
|
|
2336
|
+
handleCallback(): Promise<AuthUser$1>;
|
|
2337
|
+
/**
|
|
2338
|
+
* (Hosted-page side) Finish an /authorize request after the user has
|
|
2339
|
+
* authenticated here: seal the in-memory seed, mint the grant, and return
|
|
2340
|
+
* the URL to redirect the browser back to. The seed must be held (the user
|
|
2341
|
+
* just signed in via `client.auth.zk.*`).
|
|
2342
|
+
*/
|
|
2343
|
+
completeAuthorize(opts: {
|
|
2344
|
+
appId: string;
|
|
2345
|
+
redirectUri: string;
|
|
2346
|
+
codeChallenge: string;
|
|
2347
|
+
state: string;
|
|
2348
|
+
}): Promise<string>;
|
|
2349
|
+
private location;
|
|
2350
|
+
private store;
|
|
2351
|
+
private take;
|
|
2352
|
+
/** Drop `code`, `state`, and the `#k` fragment from the address bar. */
|
|
2353
|
+
private scrubUrl;
|
|
2354
|
+
}
|
|
2355
|
+
|
|
2165
2356
|
/**
|
|
2166
2357
|
* `client.auth` — user authentication, exposed today through the `zk`
|
|
2167
2358
|
* sub-namespace (`client.auth.zk.login(...)`). Leaving room under `auth` for
|
|
@@ -2290,6 +2481,54 @@ declare class ZkAuth {
|
|
|
2290
2481
|
* call {@link changePassword} to set a new password. No server lookup needed.
|
|
2291
2482
|
*/
|
|
2292
2483
|
recoverWithPhrase(username: string, mnemonic: string, opts?: LoginOptions): Promise<AuthUser>;
|
|
2484
|
+
/**
|
|
2485
|
+
* Add an **email** as a recovery + login factor (M2 verification-gated:
|
|
2486
|
+
* the server only releases the split-key OPRF eval after the address is
|
|
2487
|
+
* OTP-verified). Sends the code, then returns a `confirm` continuation:
|
|
2488
|
+
*
|
|
2489
|
+
* const { confirm } = await client.auth.zk.enrollEmailFactor("me@x.com");
|
|
2490
|
+
* await confirm(codeFromInbox);
|
|
2491
|
+
*
|
|
2492
|
+
* Requires being signed in with the seed held (like the other enrolls).
|
|
2493
|
+
* Custody note: gated factors trade some custody for recoverability — the
|
|
2494
|
+
* trade-off should be disclosed in the enroll UI.
|
|
2495
|
+
*/
|
|
2496
|
+
enrollEmailFactor(email: string): Promise<{
|
|
2497
|
+
email: string;
|
|
2498
|
+
confirm: (code: string) => Promise<void>;
|
|
2499
|
+
}>;
|
|
2500
|
+
/**
|
|
2501
|
+
* Recover an account via its enrolled **email** factor. Sends a code to the
|
|
2502
|
+
* enrolled address (the response never reveals whether one exists), then
|
|
2503
|
+
* `confirm(code)` completes: gated read + split-key eval → unwrap seed →
|
|
2504
|
+
* normal ZK login. After this, call {@link changePassword} to set a new
|
|
2505
|
+
* password.
|
|
2506
|
+
*
|
|
2507
|
+
* const { confirm } = await client.auth.zk.recoverWithEmail("alice");
|
|
2508
|
+
* const user = await confirm(codeFromInbox);
|
|
2509
|
+
*/
|
|
2510
|
+
recoverWithEmail(username: string, opts?: LoginOptions): Promise<{
|
|
2511
|
+
confirm: (code: string) => Promise<AuthUser>;
|
|
2512
|
+
}>;
|
|
2513
|
+
/**
|
|
2514
|
+
* Link a Google account as a recovery + login factor. Requires being signed
|
|
2515
|
+
* in with the seed held. `idToken` is a fresh Google ID token (GIS).
|
|
2516
|
+
*/
|
|
2517
|
+
enrollGoogleFactor(idToken: string): Promise<void>;
|
|
2518
|
+
/**
|
|
2519
|
+
* Sign in with Google — verify the ID token, unlock the seed via the gated
|
|
2520
|
+
* split-key eval, and establish a session. Same machinery serves "Sign in
|
|
2521
|
+
* with Google" and "recover with Google"; the account must have linked the
|
|
2522
|
+
* factor first.
|
|
2523
|
+
*/
|
|
2524
|
+
loginWithGoogle(username: string, idToken: string, opts?: LoginOptions): Promise<AuthUser>;
|
|
2525
|
+
/**
|
|
2526
|
+
* Register a brand-new, **passwordless** account whose only factor is Google.
|
|
2527
|
+
* A random master seed is generated and wrapped under the Google-gated key;
|
|
2528
|
+
* the user can add a password / passkey / phrase later. The ZK registration
|
|
2529
|
+
* is identical to a password signup.
|
|
2530
|
+
*/
|
|
2531
|
+
registerWithGoogle(username: string, idToken: string): Promise<AuthUser>;
|
|
2293
2532
|
/**
|
|
2294
2533
|
* Change the password — re-wraps the (unchanged) master seed under the new
|
|
2295
2534
|
* password's OPRF-gated key. The identity/commitment never moves. Requires
|
|
@@ -2322,12 +2561,17 @@ declare class ZkAuth {
|
|
|
2322
2561
|
* its PRF, unwraps the master seed → identity → session.
|
|
2323
2562
|
*/
|
|
2324
2563
|
loginWithPasskey(username: string, opts?: LoginOptions): Promise<AuthUser>;
|
|
2325
|
-
/**
|
|
2564
|
+
/**
|
|
2565
|
+
* List the user's enrolled login methods (metadata only). Session-authed.
|
|
2566
|
+
* Gated factors (email/google) carry a `masked` display hint
|
|
2567
|
+
* ("m•••@gmail.com"); the full value is never returned.
|
|
2568
|
+
*/
|
|
2326
2569
|
listFactors(): Promise<Array<{
|
|
2327
2570
|
id: string;
|
|
2328
2571
|
type: string;
|
|
2329
2572
|
label?: string;
|
|
2330
2573
|
createdAt?: number;
|
|
2574
|
+
masked?: string;
|
|
2331
2575
|
}>>;
|
|
2332
2576
|
/** Remove a login method by id (can't remove your only one). Session-authed. */
|
|
2333
2577
|
removeFactor(id: string): Promise<void>;
|
|
@@ -2385,7 +2629,11 @@ declare class ZkAuth {
|
|
|
2385
2629
|
/** `client.auth` — the auth namespace. Strategies hang off here. */
|
|
2386
2630
|
declare class AuthNamespace {
|
|
2387
2631
|
readonly zk: ZkAuth;
|
|
2388
|
-
|
|
2632
|
+
/** Centralized hosted auth (auth.muhkoo.dev) — `client.auth.hosted.login(...)`. */
|
|
2633
|
+
readonly hosted: HostedAuth;
|
|
2634
|
+
constructor(deps: ZkAuthDeps & {
|
|
2635
|
+
authBaseUrl: string;
|
|
2636
|
+
});
|
|
2389
2637
|
/** Convenience pass-through: the currently signed-in user, or `null`. */
|
|
2390
2638
|
get user(): AuthUser | null;
|
|
2391
2639
|
}
|
|
@@ -3625,6 +3873,7 @@ declare class AgentsNamespace {
|
|
|
3625
3873
|
* });
|
|
3626
3874
|
* // HTTP-reachable at hello--<slug>.fns.muhkoo.dev
|
|
3627
3875
|
* await client.functions.enable(appId, config.functionId, spaceId); // Space-bound
|
|
3876
|
+
* const out = await client.functions.invoke({ name: 'hello', slug }, { body: { q: 1 } });
|
|
3628
3877
|
*
|
|
3629
3878
|
* These are MANAGEMENT calls — the function itself runs on the accelerator
|
|
3630
3879
|
* (uploaded just-in-time, decrypted only at invocation). Only an app's owner or
|
|
@@ -3694,6 +3943,29 @@ interface FunctionDeployInput {
|
|
|
3694
3943
|
type FunctionUpdateInput = Partial<FunctionDeployInput>;
|
|
3695
3944
|
interface FunctionsNamespaceDeps {
|
|
3696
3945
|
http: HttpClient;
|
|
3946
|
+
/**
|
|
3947
|
+
* Wildcard zone HTTP functions are served from
|
|
3948
|
+
* (`<name>--<slug>.<suffix>`). Defaults to the hosted platform's
|
|
3949
|
+
* {@link DEFAULT_FN_HOST_SUFFIX}; override for staging / self-hosted.
|
|
3950
|
+
*/
|
|
3951
|
+
fnHostSuffix?: string;
|
|
3952
|
+
}
|
|
3953
|
+
/** The hosted platform's HTTP-function zone. */
|
|
3954
|
+
declare const DEFAULT_FN_HOST_SUFFIX = "fns.muhkoo.dev";
|
|
3955
|
+
/** Options for {@link FunctionsNamespace.invoke}. */
|
|
3956
|
+
interface FunctionInvokeOptions {
|
|
3957
|
+
/** HTTP method. Defaults to `POST` when `body` is present, else `GET`. */
|
|
3958
|
+
method?: string;
|
|
3959
|
+
/**
|
|
3960
|
+
* Request body. Plain objects/arrays are JSON-encoded (with
|
|
3961
|
+
* `Content-Type: application/json`); strings, `FormData`, `Blob`,
|
|
3962
|
+
* `ArrayBuffer`/views and `URLSearchParams` are sent as-is.
|
|
3963
|
+
*/
|
|
3964
|
+
body?: unknown;
|
|
3965
|
+
/** Extra headers, merged over the SDK's credential headers. */
|
|
3966
|
+
headers?: HeadersInit;
|
|
3967
|
+
/** Sub-path (and query) on the function's host, e.g. `/reports?from=...`. */
|
|
3968
|
+
path?: string;
|
|
3697
3969
|
}
|
|
3698
3970
|
/** Common option: a management Space for delegated (non-owner) access. */
|
|
3699
3971
|
interface FunctionScopeOpts {
|
|
@@ -3734,11 +4006,42 @@ declare class FunctionsNamespace {
|
|
|
3734
4006
|
disable(appId: string, functionId: string, spaceId: string, opts?: FunctionScopeOpts): Promise<{
|
|
3735
4007
|
config: FunctionConfig;
|
|
3736
4008
|
}>;
|
|
4009
|
+
/**
|
|
4010
|
+
* Invoke an HTTP-triggered function and parse its JSON response.
|
|
4011
|
+
*
|
|
4012
|
+
* const out = await client.functions.invoke({ name: 'hello', slug: 'myapp' });
|
|
4013
|
+
* const out = await client.functions.invoke('hello--myapp', { body: { q: 1 } });
|
|
4014
|
+
* const out = await client.functions.invoke('https://hello--myapp.fns.muhkoo.dev/x');
|
|
4015
|
+
*
|
|
4016
|
+
* The request carries the SDK's credentials (`X-Muhkoo-Key` and, when a
|
|
4017
|
+
* user is signed in, `X-Muhkoo-Session`) — the platform passes the session
|
|
4018
|
+
* token through to the function, which can verify it server-side via
|
|
4019
|
+
* `POST /api/auth/verify` to establish the caller's identity.
|
|
4020
|
+
*
|
|
4021
|
+
* Non-2xx responses throw {@link HttpError}. For functions that return
|
|
4022
|
+
* something other than JSON, use {@link invokeRaw}.
|
|
4023
|
+
*/
|
|
4024
|
+
invoke<T = unknown>(target: string | {
|
|
4025
|
+
name: string;
|
|
4026
|
+
slug: string;
|
|
4027
|
+
}, opts?: FunctionInvokeOptions): Promise<T>;
|
|
4028
|
+
/** Invoke an HTTP-triggered function and return the raw `Response`. */
|
|
4029
|
+
invokeRaw(target: string | {
|
|
4030
|
+
name: string;
|
|
4031
|
+
slug: string;
|
|
4032
|
+
}, opts?: FunctionInvokeOptions): Promise<Response>;
|
|
4033
|
+
/** Resolve an invoke target to the function's absolute URL. */
|
|
4034
|
+
invokeUrl(target: string | {
|
|
4035
|
+
name: string;
|
|
4036
|
+
slug: string;
|
|
4037
|
+
}, path?: string): string;
|
|
3737
4038
|
private path;
|
|
3738
4039
|
}
|
|
3739
4040
|
|
|
3740
4041
|
/** The hosted Muhkoo Accelerator — the default {@link ClientOptions.baseUrl}. */
|
|
3741
4042
|
declare const DEFAULT_BASE_URL = "https://api.muhkoo.dev";
|
|
4043
|
+
/** The hosted auth SPA — the default {@link ClientOptions.authBaseUrl}. */
|
|
4044
|
+
declare const DEFAULT_AUTH_BASE_URL = "https://auth.muhkoo.dev";
|
|
3742
4045
|
interface ClientOptions {
|
|
3743
4046
|
/**
|
|
3744
4047
|
* App / publishable key issued by the accelerator (e.g. `mk_test_pk_…`).
|
|
@@ -3769,6 +4072,19 @@ interface ClientOptions {
|
|
|
3769
4072
|
fetch?: typeof fetch;
|
|
3770
4073
|
/** Optional log level for the SDK logger. */
|
|
3771
4074
|
logLevel?: string;
|
|
4075
|
+
/**
|
|
4076
|
+
* Wildcard zone HTTP serverless functions are served from
|
|
4077
|
+
* (`<name>--<slug>.<suffix>`), used by `client.functions.invoke(...)`.
|
|
4078
|
+
* Defaults to the hosted platform's zone (`fns.muhkoo.dev`); override for
|
|
4079
|
+
* staging or a self-hosted deployment.
|
|
4080
|
+
*/
|
|
4081
|
+
functionsHostSuffix?: string;
|
|
4082
|
+
/**
|
|
4083
|
+
* Base URL of the centralized hosted auth SPA (`client.auth.hosted`).
|
|
4084
|
+
* Defaults to {@link DEFAULT_AUTH_BASE_URL} (`auth.muhkoo.dev`); override for
|
|
4085
|
+
* staging (`auth.staging.muhkoo.dev`) or a self-hosted deployment.
|
|
4086
|
+
*/
|
|
4087
|
+
authBaseUrl?: string;
|
|
3772
4088
|
}
|
|
3773
4089
|
declare class Client {
|
|
3774
4090
|
readonly baseUrl: string;
|
|
@@ -4008,5 +4324,5 @@ declare class KeyringClient implements KeyringTransport {
|
|
|
4008
4324
|
fetchMetadata(): Promise<SpaceMetadata | null>;
|
|
4009
4325
|
}
|
|
4010
4326
|
|
|
4011
|
-
export { AES_GCM_IV_BYTES, AES_GCM_KEY_BYTES, AES_GCM_TAG_BYTES, AgentsNamespace, AuthClient, AuthNamespace, AuthPublicInput, Authenticator, BroadcastChannel, BroadcastChannelEvents, ChannelExistsError, ChannelNotFoundError, ChunkCipher, Client, DEFAULT_BASE_URL, DoubleRatchet, DoubleRatchetCipher, DoubleRatchetManager, EncryptedSession, EventCore, EventCoreEvents, Field, Field as FieldElement, FileStorage, FunctionsNamespace, HashKnowledge, HttpClient, HttpError, KEEPER_MEMBER_ID, KeyStore, KeyringClient, KvNamespace, LocalStorageSessionStore, MemorySessionStore, Message, Message as MessageDefault, MessageNamespace, MuhkooAgent, MuhkooDB, MuhkooFunction, MuhkooSpace, PBKDF2_DEFAULT_ITERATIONS, PREIMAGE_POK_VERIFICATION_KEY, Packet, PersonalSpaceClient, Poseidon, PreimagePoK, ReedSolomonCodec, Space as Room, SerializeMessage, SessionState, ShardClient, SharedSpaceClient, Space, SpaceKeyring, SpaceNamespace, SpacePacketCipher, StorageNamespace, VaultUnavailableError, WSTransport, ZkAuth, buildCommitment, compilePrograms, decodeFromHex, decorators, decryptAesGcm, defaultCircuitUrls, defaultSessionStore, deriveAesKeyFromPassphrase, deriveBitsHkdf, deriveIdentity, deriveIdentityFromSeed, deriveMasterSeedFromPassword, ejectAgentPrompt, ejectAgentTools, encodeToHex, encryptAesGcm, exportPublicKeyBase64, exportPublicKeyHex, generateAuthProof, getMuhkooAppDescriptor, getSubtle, initBn128Wasm, initRsWasm, initializeCircuits, manifestToStat, poseidonHash, quickVerify, randomBytes, shardHash, signMessage, toField, unwrapWithPassphrase, verify, verifyGroth16, verifyHashKnowledge, verifyPreimagePoK, wrapWithPassphrase };
|
|
4012
|
-
export type { ACL, ACLEntry, AgentConfig, AgentCreateInput, AgentDbToolMode, AgentProvisioned, AgentScopeOpts, AgentSkill, AgentToolsConfig, AgentTrigger, AgentTriggerType, AgentUpdateInput, AgentsNamespaceDeps, AuthClientOptions, AuthKeyPair, AuthSuccess, AuthToken, AuthType, AuthUser, Bn128WasmInstance, BroadcastChannelEvent, BroadcastChannelOptions, ChannelLike, ChunkKeyMaterial, ChunkManifest, CipherFrame, CipherMessage, CipherMessageHeader, CircuitBufferConfig, CircuitUrls, ClientOptions, DehydratedKeypair, DehydratedKeys, DoubleRatchetCipherDeps, ECDHCurve, EncodeResult, EphemeralEvent, EpochKeyProvider, FileManifest, FileNamespaceDeps, FileStat, FileStorageOptions, FunctionCaps, FunctionConfig, FunctionDeployInput, FunctionScopeOpts, FunctionTrigger, FunctionTriggerType, FunctionTriggers, FunctionUpdateInput, FunctionsNamespaceDeps, Groth16Proof, HttpClientOptions, IncomingFrame, KeyExchangeFrame, KeyPair, Keypair, KeyringClientDeps, KeyringTransport, KvNamespaceDeps, LoginOptions, MessageBody, MessageDeletedEvent, MessageEvent, MessageHeaders, MessageNamespaceDeps, MessageOptions, MessageSubscription, MuhkooAgentMeta, MuhkooAgentToolsConfig, MuhkooAppDescriptor, MuhkooDBAccess, MuhkooDBMeta, MuhkooFunctionMeta, MuhkooMessageEvent, MuhkooSpaceMeta, OAuthProvider, PacketCipher, PacketHeaders, PacketOptions, Participant, Permission, PermissionCheckRequest, PermissionCheckResult, PersonalSpaceClientOptions, PublicKeyJWK, RatchetState, ReceiveResult, RegisterParams, Role, SpaceDeps as RoomDeps, SpaceFileMetadata as RoomFileMetadata, SealedHeaders, Session, SessionOptions, SessionStore, SetOptions, ShardClientOptions, SharedSpaceClientOptions, SnarkProof, SpaceChannelLike, SpaceDeps, SpaceFileMetadata, SpaceKeyCache, SpaceKeyringDeps, SpaceMessageEvent, SpaceNamespaceDeps, StorageChangeEvent, StoredSession, Subscription, UserIdentity, VaultFactor, VerificationKey, WSMessage, WSMessageType, WSTransportOptions, WrappedPayload, WriteFileInput, WriteFileOptions, WriteToShardsInput, ZkAuthDeps, ZkAuthenticateRequest, ZkChallengeResponse, ZkCompiled, ZkIdentity, ZkRegisterRequest, ZkRegisterResponse };
|
|
4327
|
+
export { AES_GCM_IV_BYTES, AES_GCM_KEY_BYTES, AES_GCM_TAG_BYTES, AgentsNamespace, AuthClient, AuthNamespace, AuthPublicInput, Authenticator, BroadcastChannel, BroadcastChannelEvents, ChannelExistsError, ChannelNotFoundError, ChunkCipher, Client, DEFAULT_AUTH_BASE_URL, DEFAULT_BASE_URL, DEFAULT_FN_HOST_SUFFIX, DoubleRatchet, DoubleRatchetCipher, DoubleRatchetManager, EncryptedSession, EventCore, EventCoreEvents, Field, Field as FieldElement, FileStorage, FunctionsNamespace, HashKnowledge, HttpClient, HttpError, KEEPER_MEMBER_ID, KeyStore, KeyringClient, KvNamespace, LocalStorageSessionStore, MemorySessionStore, Message, Message as MessageDefault, MessageNamespace, MuhkooAgent, MuhkooDB, MuhkooFunction, MuhkooSpace, PBKDF2_DEFAULT_ITERATIONS, PREIMAGE_POK_VERIFICATION_KEY, Packet, PersonalSpaceClient, Poseidon, PreimagePoK, ReedSolomonCodec, Space as Room, SerializeMessage, SessionState, ShardClient, SharedSpaceClient, Space, SpaceKeyring, SpaceNamespace, SpacePacketCipher, StorageNamespace, VaultUnavailableError, WSTransport, ZkAuth, buildCommitment, compilePrograms, decodeFromHex, decorators, decryptAesGcm, defaultCircuitUrls, defaultSessionStore, deriveAesKeyFromPassphrase, deriveBitsHkdf, deriveIdentity, deriveIdentityFromSeed, deriveMasterSeedFromPassword, ejectAgentPrompt, ejectAgentTools, encodeToHex, encryptAesGcm, exportPublicKeyBase64, exportPublicKeyHex, generateAuthProof, generatePkce, getMuhkooAppDescriptor, getSubtle, initBn128Wasm, initRsWasm, initializeCircuits, manifestToStat, poseidonHash, quickVerify, randomBytes, randomState, sealSeed, shardHash, signMessage, toField, unsealSeed, unwrapWithPassphrase, verify, verifyGroth16, verifyHashKnowledge, verifyPreimagePoK, wrapWithPassphrase };
|
|
4328
|
+
export type { ACL, ACLEntry, AgentConfig, AgentCreateInput, AgentDbToolMode, AgentProvisioned, AgentScopeOpts, AgentSkill, AgentToolsConfig, AgentTrigger, AgentTriggerType, AgentUpdateInput, AgentsNamespaceDeps, AuthClientOptions, AuthKeyPair, AuthSuccess, AuthToken, AuthType, AuthUser, Bn128WasmInstance, BroadcastChannelEvent, BroadcastChannelOptions, ChannelLike, ChunkKeyMaterial, ChunkManifest, CipherFrame, CipherMessage, CipherMessageHeader, CircuitBufferConfig, CircuitUrls, ClientOptions, DehydratedKeypair, DehydratedKeys, DoubleRatchetCipherDeps, ECDHCurve, EncodeResult, EphemeralEvent, EpochKeyProvider, FileManifest, FileNamespaceDeps, FileStat, FileStorageOptions, FunctionCaps, FunctionConfig, FunctionDeployInput, FunctionInvokeOptions, FunctionScopeOpts, FunctionTrigger, FunctionTriggerType, FunctionTriggers, FunctionUpdateInput, FunctionsNamespaceDeps, Groth16Proof, HttpClientOptions, IncomingFrame, KeyExchangeFrame, KeyPair, Keypair, KeyringClientDeps, KeyringTransport, KvNamespaceDeps, LoginOptions, MessageBody, MessageDeletedEvent, MessageEvent, MessageHeaders, MessageNamespaceDeps, MessageOptions, MessageSubscription, MuhkooAgentMeta, MuhkooAgentToolsConfig, MuhkooAppDescriptor, MuhkooDBAccess, MuhkooDBMeta, MuhkooFunctionMeta, MuhkooMessageEvent, MuhkooSpaceMeta, OAuthProvider, PacketCipher, PacketHeaders, PacketOptions, Participant, Permission, PermissionCheckRequest, PermissionCheckResult, PersonalSpaceClientOptions, Pkce, PublicKeyJWK, RatchetState, ReceiveResult, RegisterParams, Role, SpaceDeps as RoomDeps, SpaceFileMetadata as RoomFileMetadata, SealedHandoff, SealedHeaders, Session, SessionOptions, SessionStore, SetOptions, ShardClientOptions, SharedSpaceClientOptions, SnarkProof, SpaceChannelLike, SpaceDeps, SpaceFileMetadata, SpaceKeyCache, SpaceKeyringDeps, SpaceMessageEvent, SpaceNamespaceDeps, StorageChangeEvent, StoredSession, Subscription, UserIdentity, VaultFactor, VerificationKey, WSMessage, WSMessageType, WSTransportOptions, WrappedPayload, WriteFileInput, WriteFileOptions, WriteToShardsInput, ZkAuthDeps, ZkAuthenticateRequest, ZkChallengeResponse, ZkCompiled, ZkIdentity, ZkRegisterRequest, ZkRegisterResponse };
|