@tinycloud/sdk-core 2.4.0-beta.9 → 2.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/dist/bootstrap/index.cjs +25 -0
- package/dist/bootstrap/index.cjs.map +1 -0
- package/dist/bootstrap/index.d.cts +1 -0
- package/dist/bootstrap/index.d.ts +1 -0
- package/dist/bootstrap/index.js +3 -0
- package/dist/bootstrap/index.js.map +1 -0
- package/dist/index.cjs +211 -63
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +92 -8
- package/dist/index.d.ts +92 -8
- package/dist/index.js +208 -63
- package/dist/index.js.map +1 -1
- package/package.json +8 -2
package/dist/index.js
CHANGED
|
@@ -188,7 +188,15 @@ var PersistedSessionDataSchema = z2.object({
|
|
|
188
188
|
/** Schema version for migrations */
|
|
189
189
|
version: z2.string(),
|
|
190
190
|
/** Optional ENS data */
|
|
191
|
-
ens: EnsDataSchema2.optional()
|
|
191
|
+
ens: EnsDataSchema2.optional(),
|
|
192
|
+
/**
|
|
193
|
+
* TinyCloud hosts this session was created against. Persisted so a
|
|
194
|
+
* restored session resolves to the same node without re-running the
|
|
195
|
+
* registry/fallback resolution (or the wallet sign-in flow). Optional
|
|
196
|
+
* for backward compatibility with sessions persisted before this field
|
|
197
|
+
* existed — those restore and lazily re-resolve their hosts.
|
|
198
|
+
*/
|
|
199
|
+
tinycloudHosts: z2.array(z2.string()).optional()
|
|
192
200
|
});
|
|
193
201
|
var TinyCloudSessionSchema = z2.object({
|
|
194
202
|
/** User's Ethereum address */
|
|
@@ -2172,6 +2180,7 @@ import {
|
|
|
2172
2180
|
// src/manifest.ts
|
|
2173
2181
|
import ms from "ms";
|
|
2174
2182
|
import { resolveSecretPath, SECRET_NAME_RE } from "@tinycloud/sdk-services";
|
|
2183
|
+
var DEFAULT_KNOWLEDGE_ROOT = "knowledge/index.md";
|
|
2175
2184
|
var ManifestValidationError = class extends Error {
|
|
2176
2185
|
constructor(message) {
|
|
2177
2186
|
super(`Manifest validation failed: ${message}`);
|
|
@@ -2226,7 +2235,7 @@ var DEFAULT_ADMIN_ENTRIES = [
|
|
|
2226
2235
|
service: "tinycloud.sql",
|
|
2227
2236
|
space: DEFAULT_MANIFEST_SPACE,
|
|
2228
2237
|
path: "/",
|
|
2229
|
-
actions: ["read", "write", "
|
|
2238
|
+
actions: ["read", "write", "schema"]
|
|
2230
2239
|
}
|
|
2231
2240
|
];
|
|
2232
2241
|
var DEFAULT_ALL_ENTRIES = [
|
|
@@ -2240,7 +2249,7 @@ var DEFAULT_ALL_ENTRIES = [
|
|
|
2240
2249
|
service: "tinycloud.sql",
|
|
2241
2250
|
space: DEFAULT_MANIFEST_SPACE,
|
|
2242
2251
|
path: "/",
|
|
2243
|
-
actions: ["read", "write", "
|
|
2252
|
+
actions: ["read", "write", "schema"]
|
|
2244
2253
|
},
|
|
2245
2254
|
{
|
|
2246
2255
|
service: "tinycloud.duckdb",
|
|
@@ -2398,6 +2407,9 @@ function validateManifest(input) {
|
|
|
2398
2407
|
if (m.expiry !== void 0) {
|
|
2399
2408
|
parseExpiry(m.expiry);
|
|
2400
2409
|
}
|
|
2410
|
+
if (m.knowledge !== void 0) {
|
|
2411
|
+
resolveManifestKnowledgeRoot(m.knowledge);
|
|
2412
|
+
}
|
|
2401
2413
|
if (m.permissions !== void 0) {
|
|
2402
2414
|
if (!Array.isArray(m.permissions)) {
|
|
2403
2415
|
throw new ManifestValidationError(
|
|
@@ -2413,6 +2425,25 @@ function validateManifest(input) {
|
|
|
2413
2425
|
}
|
|
2414
2426
|
return m;
|
|
2415
2427
|
}
|
|
2428
|
+
function resolveManifestKnowledgeRoot(knowledge) {
|
|
2429
|
+
if (knowledge === void 0) {
|
|
2430
|
+
return void 0;
|
|
2431
|
+
}
|
|
2432
|
+
if (knowledge === true) {
|
|
2433
|
+
return DEFAULT_KNOWLEDGE_ROOT;
|
|
2434
|
+
}
|
|
2435
|
+
if (typeof knowledge !== "string" || knowledge.length === 0) {
|
|
2436
|
+
throw new ManifestValidationError(
|
|
2437
|
+
"manifest.knowledge must be true or a knowledge/*.md root path"
|
|
2438
|
+
);
|
|
2439
|
+
}
|
|
2440
|
+
if (!/^knowledge\/.+\.md$/.test(knowledge)) {
|
|
2441
|
+
throw new ManifestValidationError(
|
|
2442
|
+
"manifest.knowledge must be true or a knowledge/*.md root path"
|
|
2443
|
+
);
|
|
2444
|
+
}
|
|
2445
|
+
return knowledge;
|
|
2446
|
+
}
|
|
2416
2447
|
function validateManifestSecrets(secrets) {
|
|
2417
2448
|
if (secrets === null || typeof secrets !== "object" || Array.isArray(secrets)) {
|
|
2418
2449
|
throw new ManifestValidationError("manifest.secrets must be an object");
|
|
@@ -2812,7 +2843,7 @@ function accountRegistryIndexPermission() {
|
|
|
2812
2843
|
service: "tinycloud.sql",
|
|
2813
2844
|
space: ACCOUNT_REGISTRY_SPACE,
|
|
2814
2845
|
path: "account",
|
|
2815
|
-
actions: ["tinycloud.sql/read", "tinycloud.sql/write", "tinycloud.sql/
|
|
2846
|
+
actions: ["tinycloud.sql/read", "tinycloud.sql/write", "tinycloud.sql/schema"]
|
|
2816
2847
|
};
|
|
2817
2848
|
}
|
|
2818
2849
|
function composeManifestRequest(inputs, options = {}) {
|
|
@@ -2917,8 +2948,10 @@ function manifestAbilitiesUnion(resolved) {
|
|
|
2917
2948
|
}
|
|
2918
2949
|
|
|
2919
2950
|
// src/account/AccountService.ts
|
|
2951
|
+
import { ACCOUNT_INDEX_SCHEMA } from "@tinycloud/bootstrap";
|
|
2920
2952
|
var SERVICE_NAME2 = "account";
|
|
2921
2953
|
var ACCOUNT_INDEX_DB = "account";
|
|
2954
|
+
var ACCOUNT_INDEX_NAMESPACE = "tinycloud.account.index";
|
|
2922
2955
|
var ACCOUNT_SPACES_PATH = "spaces/";
|
|
2923
2956
|
var AccountService = class {
|
|
2924
2957
|
constructor(config) {
|
|
@@ -3113,6 +3146,13 @@ var AccountService = class {
|
|
|
3113
3146
|
}
|
|
3114
3147
|
};
|
|
3115
3148
|
this.index = {
|
|
3149
|
+
ensure: async () => {
|
|
3150
|
+
const dbResult = this.accountDb();
|
|
3151
|
+
if (!dbResult.ok) return dbResult;
|
|
3152
|
+
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
3153
|
+
if (!schema.ok) return schema;
|
|
3154
|
+
return ok3({ database: ACCOUNT_INDEX_DB });
|
|
3155
|
+
},
|
|
3116
3156
|
rebuild: async () => {
|
|
3117
3157
|
const dbResult = this.accountDb();
|
|
3118
3158
|
if (!dbResult.ok) return dbResult;
|
|
@@ -3123,8 +3163,9 @@ var AccountService = class {
|
|
|
3123
3163
|
const delegations = await this.delegations.list();
|
|
3124
3164
|
if (!delegations.ok) return delegations;
|
|
3125
3165
|
const syncedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
3166
|
+
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
3167
|
+
if (!schema.ok) return schema;
|
|
3126
3168
|
const statements = [
|
|
3127
|
-
...ACCOUNT_INDEX_SCHEMA.map((sql) => ({ sql })),
|
|
3128
3169
|
{ sql: "DELETE FROM applications" },
|
|
3129
3170
|
{ sql: "DELETE FROM application_state" },
|
|
3130
3171
|
{ sql: "DELETE FROM spaces" },
|
|
@@ -3321,7 +3362,7 @@ var AccountService = class {
|
|
|
3321
3362
|
async indexHasApplicationHash(appId, manifestHash) {
|
|
3322
3363
|
const dbResult = this.accountDb();
|
|
3323
3364
|
if (!dbResult.ok) return false;
|
|
3324
|
-
const schema = await dbResult.data
|
|
3365
|
+
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
3325
3366
|
if (!schema.ok) return false;
|
|
3326
3367
|
const queried = await dbResult.data.query(
|
|
3327
3368
|
"SELECT 1 FROM application_state WHERE app_id = ? AND manifest_hash = ? LIMIT 1",
|
|
@@ -3335,10 +3376,11 @@ var AccountService = class {
|
|
|
3335
3376
|
async upsertApplicationIndex(app) {
|
|
3336
3377
|
const dbResult = this.accountDb();
|
|
3337
3378
|
if (!dbResult.ok) return ok3(void 0);
|
|
3379
|
+
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
3380
|
+
if (!schema.ok) return schema;
|
|
3338
3381
|
const updatedAt = app.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
3339
3382
|
const manifestHash = app.manifestHash ?? hashJson(app.manifests);
|
|
3340
3383
|
const written = await dbResult.data.batch([
|
|
3341
|
-
...ACCOUNT_INDEX_SCHEMA.map((sql) => ({ sql })),
|
|
3342
3384
|
{
|
|
3343
3385
|
sql: "INSERT OR REPLACE INTO applications (app_id, name, description, updated_at, manifest_json) VALUES (?, ?, ?, ?, ?)",
|
|
3344
3386
|
params: [
|
|
@@ -3363,8 +3405,9 @@ var AccountService = class {
|
|
|
3363
3405
|
async deleteApplicationIndex(appId) {
|
|
3364
3406
|
const dbResult = this.accountDb();
|
|
3365
3407
|
if (!dbResult.ok) return ok3(void 0);
|
|
3408
|
+
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
3409
|
+
if (!schema.ok) return schema;
|
|
3366
3410
|
const deleted = await dbResult.data.batch([
|
|
3367
|
-
...ACCOUNT_INDEX_SCHEMA.map((sql) => ({ sql })),
|
|
3368
3411
|
{ sql: "DELETE FROM applications WHERE app_id = ?", params: [appId] },
|
|
3369
3412
|
{ sql: "DELETE FROM application_state WHERE app_id = ?", params: [appId] }
|
|
3370
3413
|
]);
|
|
@@ -3377,9 +3420,10 @@ var AccountService = class {
|
|
|
3377
3420
|
async upsertSpaceIndex(space) {
|
|
3378
3421
|
const dbResult = this.accountDb();
|
|
3379
3422
|
if (!dbResult.ok) return ok3(void 0);
|
|
3423
|
+
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
3424
|
+
if (!schema.ok) return schema;
|
|
3380
3425
|
const updatedAt = space.updatedAt ?? (/* @__PURE__ */ new Date()).toISOString();
|
|
3381
3426
|
const written = await dbResult.data.batch([
|
|
3382
|
-
...ACCOUNT_INDEX_SCHEMA.map((sql) => ({ sql })),
|
|
3383
3427
|
{
|
|
3384
3428
|
sql: "INSERT OR REPLACE INTO spaces (space_id, name, owner_did, type, permissions_json, status, registered_at, updated_at, expires_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
|
3385
3429
|
params: [
|
|
@@ -3404,8 +3448,9 @@ var AccountService = class {
|
|
|
3404
3448
|
async deleteSpaceIndex(spaceId) {
|
|
3405
3449
|
const dbResult = this.accountDb();
|
|
3406
3450
|
if (!dbResult.ok) return ok3(void 0);
|
|
3451
|
+
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
3452
|
+
if (!schema.ok) return schema;
|
|
3407
3453
|
const deleted = await dbResult.data.batch([
|
|
3408
|
-
...ACCOUNT_INDEX_SCHEMA.map((sql) => ({ sql })),
|
|
3409
3454
|
{ sql: "DELETE FROM spaces WHERE space_id = ?", params: [spaceId] }
|
|
3410
3455
|
]);
|
|
3411
3456
|
if (!deleted.ok) return accountErr(deleted.error);
|
|
@@ -3427,8 +3472,9 @@ var AccountService = class {
|
|
|
3427
3472
|
const dbResult = this.accountDb();
|
|
3428
3473
|
if (!dbResult.ok) return;
|
|
3429
3474
|
const syncedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
3475
|
+
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
3476
|
+
if (!schema.ok) return;
|
|
3430
3477
|
await dbResult.data.batch([
|
|
3431
|
-
...ACCOUNT_INDEX_SCHEMA.map((sql) => ({ sql })),
|
|
3432
3478
|
{ sql: "DELETE FROM applications" },
|
|
3433
3479
|
{ sql: "DELETE FROM application_state" },
|
|
3434
3480
|
...applications.map((app) => ({
|
|
@@ -3457,8 +3503,9 @@ var AccountService = class {
|
|
|
3457
3503
|
const dbResult = this.accountDb();
|
|
3458
3504
|
if (!dbResult.ok) return;
|
|
3459
3505
|
const syncedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
3506
|
+
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
3507
|
+
if (!schema.ok) return;
|
|
3460
3508
|
await dbResult.data.batch([
|
|
3461
|
-
...ACCOUNT_INDEX_SCHEMA.map((sql) => ({ sql })),
|
|
3462
3509
|
{ sql: "DELETE FROM spaces" },
|
|
3463
3510
|
...spaces.map((space) => ({
|
|
3464
3511
|
sql: "INSERT OR REPLACE INTO spaces (space_id, name, owner_did, type, permissions_json, status, registered_at, updated_at, expires_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
|
@@ -3486,8 +3533,9 @@ var AccountService = class {
|
|
|
3486
3533
|
const dbResult = this.accountDb();
|
|
3487
3534
|
if (!dbResult.ok) return;
|
|
3488
3535
|
const syncedAt = (/* @__PURE__ */ new Date()).toISOString();
|
|
3536
|
+
const schema = await this.ensureAccountIndex(dbResult.data);
|
|
3537
|
+
if (!schema.ok) return;
|
|
3489
3538
|
await dbResult.data.batch([
|
|
3490
|
-
...ACCOUNT_INDEX_SCHEMA.map((sql) => ({ sql })),
|
|
3491
3539
|
{ sql: "DELETE FROM delegations" },
|
|
3492
3540
|
...delegations.map((delegation) => ({
|
|
3493
3541
|
sql: "INSERT OR REPLACE INTO delegations (cid, direction, space_id, space_name, counterparty_did, delegate_did, delegator_did, path, actions_json, expiry, status, created_at, updated_at) VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?, ?)",
|
|
@@ -3514,57 +3562,20 @@ var AccountService = class {
|
|
|
3514
3562
|
]);
|
|
3515
3563
|
});
|
|
3516
3564
|
}
|
|
3565
|
+
async ensureAccountIndex(db) {
|
|
3566
|
+
const migrated = await db.migrations.apply({
|
|
3567
|
+
namespace: ACCOUNT_INDEX_NAMESPACE,
|
|
3568
|
+
migrations: [
|
|
3569
|
+
{
|
|
3570
|
+
id: "001_initial",
|
|
3571
|
+
sql: [...ACCOUNT_INDEX_SCHEMA]
|
|
3572
|
+
}
|
|
3573
|
+
]
|
|
3574
|
+
});
|
|
3575
|
+
if (!migrated.ok) return accountErr(migrated.error);
|
|
3576
|
+
return ok3(void 0);
|
|
3577
|
+
}
|
|
3517
3578
|
};
|
|
3518
|
-
var ACCOUNT_INDEX_SCHEMA = [
|
|
3519
|
-
`CREATE TABLE IF NOT EXISTS applications (
|
|
3520
|
-
app_id TEXT PRIMARY KEY,
|
|
3521
|
-
name TEXT,
|
|
3522
|
-
description TEXT,
|
|
3523
|
-
updated_at TEXT,
|
|
3524
|
-
manifest_json TEXT NOT NULL
|
|
3525
|
-
)`,
|
|
3526
|
-
`CREATE TABLE IF NOT EXISTS application_state (
|
|
3527
|
-
app_id TEXT PRIMARY KEY,
|
|
3528
|
-
manifest_hash TEXT NOT NULL,
|
|
3529
|
-
indexed_at TEXT NOT NULL
|
|
3530
|
-
)`,
|
|
3531
|
-
`CREATE TABLE IF NOT EXISTS spaces (
|
|
3532
|
-
space_id TEXT PRIMARY KEY,
|
|
3533
|
-
name TEXT NOT NULL,
|
|
3534
|
-
owner_did TEXT NOT NULL,
|
|
3535
|
-
type TEXT NOT NULL,
|
|
3536
|
-
permissions_json TEXT NOT NULL,
|
|
3537
|
-
status TEXT NOT NULL,
|
|
3538
|
-
registered_at TEXT,
|
|
3539
|
-
updated_at TEXT NOT NULL,
|
|
3540
|
-
expires_at TEXT
|
|
3541
|
-
)`,
|
|
3542
|
-
`CREATE TABLE IF NOT EXISTS delegations (
|
|
3543
|
-
cid TEXT PRIMARY KEY,
|
|
3544
|
-
direction TEXT NOT NULL,
|
|
3545
|
-
space_id TEXT NOT NULL,
|
|
3546
|
-
space_name TEXT,
|
|
3547
|
-
counterparty_did TEXT NOT NULL,
|
|
3548
|
-
delegate_did TEXT NOT NULL,
|
|
3549
|
-
delegator_did TEXT,
|
|
3550
|
-
path TEXT NOT NULL,
|
|
3551
|
-
actions_json TEXT NOT NULL,
|
|
3552
|
-
expiry TEXT NOT NULL,
|
|
3553
|
-
status TEXT NOT NULL,
|
|
3554
|
-
created_at TEXT,
|
|
3555
|
-
updated_at TEXT NOT NULL
|
|
3556
|
-
)`,
|
|
3557
|
-
`CREATE TABLE IF NOT EXISTS sync_state (
|
|
3558
|
-
source TEXT PRIMARY KEY,
|
|
3559
|
-
synced_at TEXT NOT NULL,
|
|
3560
|
-
count INTEGER NOT NULL
|
|
3561
|
-
)`,
|
|
3562
|
-
"CREATE INDEX IF NOT EXISTS idx_delegations_direction ON delegations(direction)",
|
|
3563
|
-
"CREATE INDEX IF NOT EXISTS idx_delegations_space ON delegations(space_id)",
|
|
3564
|
-
"CREATE INDEX IF NOT EXISTS idx_delegations_counterparty ON delegations(counterparty_did)",
|
|
3565
|
-
"CREATE INDEX IF NOT EXISTS idx_spaces_owner ON spaces(owner_did)",
|
|
3566
|
-
"CREATE INDEX IF NOT EXISTS idx_spaces_type ON spaces(type)"
|
|
3567
|
-
];
|
|
3568
3579
|
function applicationKey(appId) {
|
|
3569
3580
|
return `${ACCOUNT_REGISTRY_PATH}${appId}`;
|
|
3570
3581
|
}
|
|
@@ -3739,6 +3750,13 @@ import {
|
|
|
3739
3750
|
err as err5,
|
|
3740
3751
|
serviceError as serviceError5,
|
|
3741
3752
|
ErrorCodes as ErrorCodes2,
|
|
3753
|
+
TinyCloudDebugLogger,
|
|
3754
|
+
tinyCloudDebugLogger,
|
|
3755
|
+
enableTinyCloudDebug,
|
|
3756
|
+
disableTinyCloudDebug,
|
|
3757
|
+
getTinyCloudDebugLogs,
|
|
3758
|
+
clearTinyCloudDebugLogs,
|
|
3759
|
+
installTinyCloudDebugGlobals,
|
|
3742
3760
|
defaultRetryPolicy as defaultRetryPolicy2,
|
|
3743
3761
|
SQLService as SQLService2,
|
|
3744
3762
|
DatabaseHandle,
|
|
@@ -5539,6 +5557,76 @@ function createCapabilityKeyRegistry() {
|
|
|
5539
5557
|
}
|
|
5540
5558
|
|
|
5541
5559
|
// src/authorization/strategies.ts
|
|
5560
|
+
async function resolveOpenKeyToken(token) {
|
|
5561
|
+
return typeof token === "function" ? token() : token;
|
|
5562
|
+
}
|
|
5563
|
+
async function resolveOpenKeyHeaders(headers) {
|
|
5564
|
+
return typeof headers === "function" ? headers() : headers ?? {};
|
|
5565
|
+
}
|
|
5566
|
+
function openKeyApprovalReason(body) {
|
|
5567
|
+
if (body.reason) return body.reason;
|
|
5568
|
+
if (body.error) return body.error;
|
|
5569
|
+
if (body.approvalUrl) {
|
|
5570
|
+
return `OpenKey explicit approval required: ${body.approvalUrl}`;
|
|
5571
|
+
}
|
|
5572
|
+
return "OpenKey explicit approval required";
|
|
5573
|
+
}
|
|
5574
|
+
function createOpenKeyCallbackSigningStrategy(options) {
|
|
5575
|
+
return {
|
|
5576
|
+
type: "callback",
|
|
5577
|
+
openKeyAutoSign: true,
|
|
5578
|
+
handler: async (request) => {
|
|
5579
|
+
const fetchImpl = options.fetch ?? globalThis.fetch;
|
|
5580
|
+
if (!fetchImpl) {
|
|
5581
|
+
throw new Error("OpenKey signing strategy requires a fetch implementation");
|
|
5582
|
+
}
|
|
5583
|
+
const token = await resolveOpenKeyToken(options.token);
|
|
5584
|
+
const extraHeaders = await resolveOpenKeyHeaders(options.headers);
|
|
5585
|
+
const body = {
|
|
5586
|
+
...request,
|
|
5587
|
+
...options.keyId ? { keyId: options.keyId } : {}
|
|
5588
|
+
};
|
|
5589
|
+
const response = await fetchImpl(options.endpoint, {
|
|
5590
|
+
method: "POST",
|
|
5591
|
+
credentials: options.credentials,
|
|
5592
|
+
headers: {
|
|
5593
|
+
"content-type": "application/json",
|
|
5594
|
+
...token ? { authorization: `Bearer ${token}` } : {},
|
|
5595
|
+
...extraHeaders
|
|
5596
|
+
},
|
|
5597
|
+
body: JSON.stringify(body)
|
|
5598
|
+
});
|
|
5599
|
+
let parsed;
|
|
5600
|
+
try {
|
|
5601
|
+
parsed = await response.json();
|
|
5602
|
+
} catch {
|
|
5603
|
+
parsed = void 0;
|
|
5604
|
+
}
|
|
5605
|
+
if (!response.ok) {
|
|
5606
|
+
return {
|
|
5607
|
+
approved: false,
|
|
5608
|
+
reason: parsed?.reason ?? parsed?.error ?? `OpenKey signing failed with HTTP ${response.status}`
|
|
5609
|
+
};
|
|
5610
|
+
}
|
|
5611
|
+
if (parsed?.needsApproval || parsed?.approved === false) {
|
|
5612
|
+
return {
|
|
5613
|
+
approved: false,
|
|
5614
|
+
reason: openKeyApprovalReason(parsed)
|
|
5615
|
+
};
|
|
5616
|
+
}
|
|
5617
|
+
if (typeof parsed?.signature === "string" && parsed.signature.length > 0) {
|
|
5618
|
+
return {
|
|
5619
|
+
approved: true,
|
|
5620
|
+
signature: parsed.signature
|
|
5621
|
+
};
|
|
5622
|
+
}
|
|
5623
|
+
return {
|
|
5624
|
+
approved: false,
|
|
5625
|
+
reason: "OpenKey signing response did not include a signature"
|
|
5626
|
+
};
|
|
5627
|
+
}
|
|
5628
|
+
};
|
|
5629
|
+
}
|
|
5542
5630
|
var defaultSignStrategy = { type: "auto-sign" };
|
|
5543
5631
|
|
|
5544
5632
|
// src/authorization/spaceCreation.ts
|
|
@@ -5614,6 +5702,31 @@ async function checkNodeInfo(host, sdkProtocol, fetchFn = globalThis.fetch.bind(
|
|
|
5614
5702
|
};
|
|
5615
5703
|
}
|
|
5616
5704
|
|
|
5705
|
+
// src/index.ts
|
|
5706
|
+
import {
|
|
5707
|
+
ACCOUNT_INDEX_SCHEMA as ACCOUNT_INDEX_SCHEMA2,
|
|
5708
|
+
BOOTSTRAP_ALLOWLIST,
|
|
5709
|
+
BOOTSTRAP_DEFAULT_SPACE,
|
|
5710
|
+
BOOTSTRAP_ENCRYPTION_NETWORK_NAME,
|
|
5711
|
+
BOOTSTRAP_ENCRYPTION_NETWORK_RESOURCE_TEMPLATE,
|
|
5712
|
+
BOOTSTRAP_MANIFEST,
|
|
5713
|
+
BOOTSTRAP_PERSISTED_APPLICATION_MANIFESTS,
|
|
5714
|
+
BOOTSTRAP_PUBLIC_SPACE,
|
|
5715
|
+
BOOTSTRAP_SESSION_REQUESTS,
|
|
5716
|
+
BOOTSTRAP_SPACE_MANIFESTS,
|
|
5717
|
+
BOOTSTRAP_SPACE_NAMES,
|
|
5718
|
+
SECRET_RECORDS_SCHEMA,
|
|
5719
|
+
TINYCLOUD_ACCOUNT_SPACE_MANIFEST,
|
|
5720
|
+
TINYCLOUD_APPLICATIONS_SPACE_MANIFEST,
|
|
5721
|
+
TINYCLOUD_DEFAULT_SPACE_MANIFEST,
|
|
5722
|
+
TINYCLOUD_PUBLIC_SPACE_MANIFEST,
|
|
5723
|
+
TINYCLOUD_SECRETS_BOOTSTRAP_MANIFEST,
|
|
5724
|
+
bootstrapEncryptionNetworkId,
|
|
5725
|
+
bootstrapSpaceId,
|
|
5726
|
+
bootstrapSteps,
|
|
5727
|
+
composeBootstrapSpaceManifest
|
|
5728
|
+
} from "@tinycloud/bootstrap";
|
|
5729
|
+
|
|
5617
5730
|
// src/location.ts
|
|
5618
5731
|
import { multiaddr } from "@multiformats/multiaddr";
|
|
5619
5732
|
import { multiaddrToUri } from "@multiformats/multiaddr-to-uri";
|
|
@@ -6123,10 +6236,21 @@ function parseRecapCapabilities(parseWasm, siwe) {
|
|
|
6123
6236
|
return normalized;
|
|
6124
6237
|
}
|
|
6125
6238
|
export {
|
|
6239
|
+
ACCOUNT_INDEX_SCHEMA2 as ACCOUNT_INDEX_SCHEMA,
|
|
6126
6240
|
ACCOUNT_REGISTRY_PATH,
|
|
6127
6241
|
ACCOUNT_REGISTRY_SPACE,
|
|
6128
6242
|
AccountService,
|
|
6129
6243
|
AutoApproveSpaceCreationHandler,
|
|
6244
|
+
BOOTSTRAP_ALLOWLIST,
|
|
6245
|
+
BOOTSTRAP_DEFAULT_SPACE,
|
|
6246
|
+
BOOTSTRAP_ENCRYPTION_NETWORK_NAME,
|
|
6247
|
+
BOOTSTRAP_ENCRYPTION_NETWORK_RESOURCE_TEMPLATE,
|
|
6248
|
+
BOOTSTRAP_MANIFEST,
|
|
6249
|
+
BOOTSTRAP_PERSISTED_APPLICATION_MANIFESTS,
|
|
6250
|
+
BOOTSTRAP_PUBLIC_SPACE,
|
|
6251
|
+
BOOTSTRAP_SESSION_REQUESTS,
|
|
6252
|
+
BOOTSTRAP_SPACE_MANIFESTS,
|
|
6253
|
+
BOOTSTRAP_SPACE_NAMES,
|
|
6130
6254
|
CapabilityKeyRegistry,
|
|
6131
6255
|
CapabilityKeyRegistryErrorCodes,
|
|
6132
6256
|
ClientSessionSchema,
|
|
@@ -6138,6 +6262,7 @@ export {
|
|
|
6138
6262
|
DEFAULT_ENCRYPTION_ALG,
|
|
6139
6263
|
DEFAULT_EXPIRY,
|
|
6140
6264
|
DEFAULT_KEY_VERSION,
|
|
6265
|
+
DEFAULT_KNOWLEDGE_ROOT,
|
|
6141
6266
|
DEFAULT_MANIFEST_SPACE,
|
|
6142
6267
|
DEFAULT_MANIFEST_VERSION,
|
|
6143
6268
|
DEFAULT_SIGNED_READ_URL_EXPIRY_MS,
|
|
@@ -6170,7 +6295,9 @@ export {
|
|
|
6170
6295
|
PermissionNotInManifestError,
|
|
6171
6296
|
PrefixedKVService,
|
|
6172
6297
|
ProtocolMismatchError,
|
|
6298
|
+
SECRETS_SPACE,
|
|
6173
6299
|
SECRET_NAME_RE2 as SECRET_NAME_RE,
|
|
6300
|
+
SECRET_RECORDS_SCHEMA,
|
|
6174
6301
|
SERVICE_LONG_TO_SHORT,
|
|
6175
6302
|
SERVICE_SHORT_TO_LONG,
|
|
6176
6303
|
SQLAction,
|
|
@@ -6185,7 +6312,13 @@ export {
|
|
|
6185
6312
|
Space,
|
|
6186
6313
|
SpaceErrorCodes,
|
|
6187
6314
|
SpaceService,
|
|
6315
|
+
TINYCLOUD_ACCOUNT_SPACE_MANIFEST,
|
|
6316
|
+
TINYCLOUD_APPLICATIONS_SPACE_MANIFEST,
|
|
6317
|
+
TINYCLOUD_DEFAULT_SPACE_MANIFEST,
|
|
6318
|
+
TINYCLOUD_PUBLIC_SPACE_MANIFEST,
|
|
6319
|
+
TINYCLOUD_SECRETS_BOOTSTRAP_MANIFEST,
|
|
6188
6320
|
TinyCloud,
|
|
6321
|
+
TinyCloudDebugLogger,
|
|
6189
6322
|
UnsupportedFeatureError,
|
|
6190
6323
|
VAULT_PERMISSION_SERVICE,
|
|
6191
6324
|
VaultHeaders,
|
|
@@ -6194,6 +6327,9 @@ export {
|
|
|
6194
6327
|
activateSessionWithHost,
|
|
6195
6328
|
addressStorageKey,
|
|
6196
6329
|
applyPrefix,
|
|
6330
|
+
bootstrapEncryptionNetworkId,
|
|
6331
|
+
bootstrapSpaceId,
|
|
6332
|
+
bootstrapSteps,
|
|
6197
6333
|
buildCanonicalDecryptRequest,
|
|
6198
6334
|
buildDecryptAttenuation,
|
|
6199
6335
|
buildDecryptFacts,
|
|
@@ -6211,8 +6347,11 @@ export {
|
|
|
6211
6347
|
canonicalizeSecretScope,
|
|
6212
6348
|
checkDecryptInvocationInput,
|
|
6213
6349
|
checkNodeInfo,
|
|
6350
|
+
clearTinyCloudDebugLogs,
|
|
6351
|
+
composeBootstrapSpaceManifest,
|
|
6214
6352
|
composeManifestRequest,
|
|
6215
6353
|
createCapabilityKeyRegistry,
|
|
6354
|
+
createOpenKeyCallbackSigningStrategy,
|
|
6216
6355
|
createSharingService,
|
|
6217
6356
|
createSpaceService,
|
|
6218
6357
|
createVaultCrypto,
|
|
@@ -6223,7 +6362,9 @@ export {
|
|
|
6223
6362
|
deriveSignedReceiverKey,
|
|
6224
6363
|
didCacheKey,
|
|
6225
6364
|
didEquals,
|
|
6365
|
+
disableTinyCloudDebug,
|
|
6226
6366
|
discoverNetwork,
|
|
6367
|
+
enableTinyCloudDebug,
|
|
6227
6368
|
encryptToNetwork,
|
|
6228
6369
|
base64Decode as encryptionBase64Decode,
|
|
6229
6370
|
base64Encode as encryptionBase64Encode,
|
|
@@ -6238,9 +6379,11 @@ export {
|
|
|
6238
6379
|
fetchLocationRecord,
|
|
6239
6380
|
fetchPeerId,
|
|
6240
6381
|
generateRandomReceiverKey,
|
|
6382
|
+
getTinyCloudDebugLogs,
|
|
6241
6383
|
hexDecode,
|
|
6242
6384
|
hexEncode,
|
|
6243
6385
|
httpUrlToMultiaddr,
|
|
6386
|
+
installTinyCloudDebugGlobals,
|
|
6244
6387
|
isCapabilitySubset,
|
|
6245
6388
|
isEvmAddress,
|
|
6246
6389
|
isNetworkId,
|
|
@@ -6265,6 +6408,7 @@ export {
|
|
|
6265
6408
|
principalDidEquals,
|
|
6266
6409
|
resolveCloudLocation,
|
|
6267
6410
|
resolveManifest,
|
|
6411
|
+
resolveManifestKnowledgeRoot,
|
|
6268
6412
|
resolveSecretListPrefix,
|
|
6269
6413
|
resolveSecretPath2 as resolveSecretPath,
|
|
6270
6414
|
resolveTinyCloudHosts,
|
|
@@ -6273,6 +6417,7 @@ export {
|
|
|
6273
6417
|
serviceError5 as serviceError,
|
|
6274
6418
|
signLocationRecord,
|
|
6275
6419
|
submitHostDelegation,
|
|
6420
|
+
tinyCloudDebugLogger,
|
|
6276
6421
|
validateClientSession,
|
|
6277
6422
|
validateEnvelope,
|
|
6278
6423
|
validateLocationRecord,
|