sh3-core 0.22.1 → 0.22.2
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/dist/api.d.ts +1 -0
- package/dist/server-shard/types.d.ts +56 -0
- package/dist/version.d.ts +1 -1
- package/dist/version.js +1 -1
- package/package.json +1 -1
package/dist/api.d.ts
CHANGED
|
@@ -55,6 +55,7 @@ export declare const capabilities: {
|
|
|
55
55
|
readonly hotInstall: boolean;
|
|
56
56
|
};
|
|
57
57
|
export type { ServerShard, ServerShardContext, TenantDocumentAPI } from './server-shard/types';
|
|
58
|
+
export type { ApiKeyPublic as ServerApiKeyPublic } from './server-shard/types';
|
|
58
59
|
export type { Verb, VerbContext, Sh3Api, VerbSchema, PortableJSONSchema, DispatchToTerminalResult, } from './verbs/types';
|
|
59
60
|
export type { Scrollback } from './shell-shard/scrollback.svelte';
|
|
60
61
|
export type { SessionClient } from './shell-shard/session-client.svelte';
|
|
@@ -12,6 +12,19 @@
|
|
|
12
12
|
*/
|
|
13
13
|
import type { DocumentMeta } from '../documents/types';
|
|
14
14
|
import type { SyncPolicy, ConflictFile } from '../documents/sync-types';
|
|
15
|
+
/** Public shape of an API key — never includes the secret value. */
|
|
16
|
+
export interface ApiKeyPublic {
|
|
17
|
+
id: string;
|
|
18
|
+
label: string;
|
|
19
|
+
scopeId: string | null;
|
|
20
|
+
ownerUserId: string | null;
|
|
21
|
+
mintedByShardId: string | null;
|
|
22
|
+
scopes: string[];
|
|
23
|
+
peerRole?: 'primary' | 'replica';
|
|
24
|
+
peerId?: string;
|
|
25
|
+
createdAt: string;
|
|
26
|
+
expiresAt?: string;
|
|
27
|
+
}
|
|
15
28
|
/**
|
|
16
29
|
* Per-tenant document API exposed to server shards via
|
|
17
30
|
* `ServerShardContext.documents(tenantId)`. Every method is
|
|
@@ -95,6 +108,49 @@ export interface ServerShardContext {
|
|
|
95
108
|
* Absent => 'primary' behavior at the store.
|
|
96
109
|
*/
|
|
97
110
|
setPeerRole(tenant: string, role: 'primary' | 'replica'): void;
|
|
111
|
+
/**
|
|
112
|
+
* Redeem a consent ticket and return the freshly-minted key.
|
|
113
|
+
*
|
|
114
|
+
* The browser side of your shard calls `POST /api/keys/consent` to issue
|
|
115
|
+
* a ticket bound to the user's session. The server side hands the
|
|
116
|
+
* ticket to this method to mint the key. The ticket carries the
|
|
117
|
+
* `(scopeId, userId, shardId, label, scopes, expiresIn?)` from consent
|
|
118
|
+
* — none of those are caller-controlled here, so a shard cannot escalate
|
|
119
|
+
* its own scopes or mint for a different tenant.
|
|
120
|
+
*
|
|
121
|
+
* The caller's `scopeId` is read from the Hono request context (`c`) and
|
|
122
|
+
* must match the scope recorded on the ticket; mismatches return `null`
|
|
123
|
+
* (same as expired / unknown ticket — probe-resistant).
|
|
124
|
+
*
|
|
125
|
+
* The returned `key` is the full secret string. Return it to the user
|
|
126
|
+
* exactly once and never persist it server-side; subsequent calls only
|
|
127
|
+
* see `key.id` via `listKeys`.
|
|
128
|
+
*
|
|
129
|
+
* @param c The Hono request context for the route handler.
|
|
130
|
+
* @param ticket The opaque token issued by /api/keys/consent.
|
|
131
|
+
* @returns `{ id, key }` on success, `null` on invalid / expired / scope-mismatch.
|
|
132
|
+
*/
|
|
133
|
+
redeemKeyTicket(c: unknown, ticket: string): Promise<{
|
|
134
|
+
id: string;
|
|
135
|
+
key: string;
|
|
136
|
+
} | null>;
|
|
137
|
+
/**
|
|
138
|
+
* List API keys this shard has minted for the calling caller's scope.
|
|
139
|
+
* Filtered to `mintedByShardId === ctx.shardId`. Other shards' keys are
|
|
140
|
+
* invisible. Returns an empty array if the caller has no scope.
|
|
141
|
+
*/
|
|
142
|
+
listKeys(c: unknown): Promise<ApiKeyPublic[]>;
|
|
143
|
+
/**
|
|
144
|
+
* Revoke an API key by id. Only revokes keys minted by this shard
|
|
145
|
+
* (`mintedByShardId === ctx.shardId`) for the calling caller's scope.
|
|
146
|
+
* Attempting to revoke another shard's key or a key in a different
|
|
147
|
+
* tenant returns `false` without raising.
|
|
148
|
+
*
|
|
149
|
+
* Successful revocations fire `onKeyRevoked` on the client side via
|
|
150
|
+
* the existing SSE channel — same path the browser-driven DELETE
|
|
151
|
+
* already takes.
|
|
152
|
+
*/
|
|
153
|
+
revokeKey(c: unknown, id: string): Promise<boolean>;
|
|
98
154
|
/**
|
|
99
155
|
* Translate an SH3 document path to a real filesystem path on the host.
|
|
100
156
|
*
|
package/dist/version.d.ts
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Auto-generated from package.json — do not edit manually. */
|
|
2
|
-
export declare const VERSION = "0.22.
|
|
2
|
+
export declare const VERSION = "0.22.2";
|
package/dist/version.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
1
|
/** Auto-generated from package.json — do not edit manually. */
|
|
2
|
-
export const VERSION = '0.22.
|
|
2
|
+
export const VERSION = '0.22.2';
|