@tinycloud/node-sdk 2.3.0-beta.7 → 2.3.0-beta.8
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/{core-CNyXnUx9.d.cts → core-BdlIWB-K.d.cts} +19 -2
- package/dist/{core-CNyXnUx9.d.ts → core-BdlIWB-K.d.ts} +19 -2
- package/dist/core.cjs +66 -14
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +2 -2
- package/dist/core.d.ts +2 -2
- package/dist/core.js +66 -14
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +66 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +2 -2
- package/dist/index.d.ts +2 -2
- package/dist/index.js +66 -14
- package/dist/index.js.map +1 -1
- package/package.json +2 -2
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, IWasmBindings, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignInOptions, Delegation, DelegatedResource, IKVService, ISQLService, IDuckDbService, IHooksService, INotificationHandler, IENSResolver, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, PermissionEntry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, ResolvedDelegate, KeyProvider, ISessionManager, JWK } from '@tinycloud/sdk-core';
|
|
1
|
+
import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, IWasmBindings, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignInOptions, Delegation, DelegatedResource, TelemetryConfig, IKVService, ISQLService, IDuckDbService, IHooksService, INotificationHandler, IENSResolver, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, PermissionEntry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, ResolvedDelegate, KeyProvider, ISessionManager, JWK } from '@tinycloud/sdk-core';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { InvokeFunction } from '@tinycloud/sdk-services';
|
|
4
4
|
|
|
@@ -587,7 +587,7 @@ declare class DelegatedAccess {
|
|
|
587
587
|
private _sql;
|
|
588
588
|
private _duckdb;
|
|
589
589
|
private _hooks;
|
|
590
|
-
constructor(session: TinyCloudSession, delegation: PortableDelegation, host: string, invoke: InvokeFunction);
|
|
590
|
+
constructor(session: TinyCloudSession, delegation: PortableDelegation, host: string, invoke: InvokeFunction, telemetry?: TelemetryConfig);
|
|
591
591
|
/**
|
|
592
592
|
* Get the delegation this access was created from.
|
|
593
593
|
*/
|
|
@@ -723,6 +723,8 @@ interface TinyCloudNodeConfig {
|
|
|
723
723
|
capabilityRequest?: ComposedManifestRequest;
|
|
724
724
|
/** Include implicit account registry permissions when composing `manifest`. Default true. */
|
|
725
725
|
includeAccountRegistryPermissions?: boolean;
|
|
726
|
+
/** Default-off service telemetry. */
|
|
727
|
+
telemetry?: TelemetryConfig;
|
|
726
728
|
}
|
|
727
729
|
/**
|
|
728
730
|
* Options for {@link TinyCloudNode.delegateTo}.
|
|
@@ -1076,6 +1078,21 @@ declare class TinyCloudNode {
|
|
|
1076
1078
|
* @param spaceId - Full space URI (`tinycloud:pkh:eip155:<chain>:<addr>:<name>`).
|
|
1077
1079
|
*/
|
|
1078
1080
|
sqlForSpace(spaceId: string): ISQLService;
|
|
1081
|
+
/**
|
|
1082
|
+
* Get a KV service scoped to a specific space.
|
|
1083
|
+
*
|
|
1084
|
+
* The KV counterpart to {@link sqlForSpace}: clones the active service
|
|
1085
|
+
* context and overrides its session's spaceId so that subsequent
|
|
1086
|
+
* `kv/<action>` invocations route to that space. Useful for reading data
|
|
1087
|
+
* that a manifest app stores outside the primary space (e.g. transcripts a
|
|
1088
|
+
* `defaults: true` app keeps under the owner's `applications` space), when
|
|
1089
|
+
* the caller already holds a delegation covering the target space.
|
|
1090
|
+
*
|
|
1091
|
+
* Does NOT auto-create the space.
|
|
1092
|
+
*
|
|
1093
|
+
* @param spaceId - Full space URI (`tinycloud:pkh:eip155:<chain>:<addr>:<name>`).
|
|
1094
|
+
*/
|
|
1095
|
+
kvForSpace(spaceId: string): IKVService;
|
|
1079
1096
|
/**
|
|
1080
1097
|
* DuckDB database operations on this user's space.
|
|
1081
1098
|
*/
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, IWasmBindings, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignInOptions, Delegation, DelegatedResource, IKVService, ISQLService, IDuckDbService, IHooksService, INotificationHandler, IENSResolver, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, PermissionEntry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, ResolvedDelegate, KeyProvider, ISessionManager, JWK } from '@tinycloud/sdk-core';
|
|
1
|
+
import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, IWasmBindings, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignInOptions, Delegation, DelegatedResource, TelemetryConfig, IKVService, ISQLService, IDuckDbService, IHooksService, INotificationHandler, IENSResolver, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, PermissionEntry, DelegationManager, ISpaceService, ISpace, ISharingService, CreateDelegationParams, DelegationResult, ResolvedDelegate, KeyProvider, ISessionManager, JWK } from '@tinycloud/sdk-core';
|
|
2
2
|
import { EventEmitter } from 'events';
|
|
3
3
|
import { InvokeFunction } from '@tinycloud/sdk-services';
|
|
4
4
|
|
|
@@ -587,7 +587,7 @@ declare class DelegatedAccess {
|
|
|
587
587
|
private _sql;
|
|
588
588
|
private _duckdb;
|
|
589
589
|
private _hooks;
|
|
590
|
-
constructor(session: TinyCloudSession, delegation: PortableDelegation, host: string, invoke: InvokeFunction);
|
|
590
|
+
constructor(session: TinyCloudSession, delegation: PortableDelegation, host: string, invoke: InvokeFunction, telemetry?: TelemetryConfig);
|
|
591
591
|
/**
|
|
592
592
|
* Get the delegation this access was created from.
|
|
593
593
|
*/
|
|
@@ -723,6 +723,8 @@ interface TinyCloudNodeConfig {
|
|
|
723
723
|
capabilityRequest?: ComposedManifestRequest;
|
|
724
724
|
/** Include implicit account registry permissions when composing `manifest`. Default true. */
|
|
725
725
|
includeAccountRegistryPermissions?: boolean;
|
|
726
|
+
/** Default-off service telemetry. */
|
|
727
|
+
telemetry?: TelemetryConfig;
|
|
726
728
|
}
|
|
727
729
|
/**
|
|
728
730
|
* Options for {@link TinyCloudNode.delegateTo}.
|
|
@@ -1076,6 +1078,21 @@ declare class TinyCloudNode {
|
|
|
1076
1078
|
* @param spaceId - Full space URI (`tinycloud:pkh:eip155:<chain>:<addr>:<name>`).
|
|
1077
1079
|
*/
|
|
1078
1080
|
sqlForSpace(spaceId: string): ISQLService;
|
|
1081
|
+
/**
|
|
1082
|
+
* Get a KV service scoped to a specific space.
|
|
1083
|
+
*
|
|
1084
|
+
* The KV counterpart to {@link sqlForSpace}: clones the active service
|
|
1085
|
+
* context and overrides its session's spaceId so that subsequent
|
|
1086
|
+
* `kv/<action>` invocations route to that space. Useful for reading data
|
|
1087
|
+
* that a manifest app stores outside the primary space (e.g. transcripts a
|
|
1088
|
+
* `defaults: true` app keeps under the owner's `applications` space), when
|
|
1089
|
+
* the caller already holds a delegation covering the target space.
|
|
1090
|
+
*
|
|
1091
|
+
* Does NOT auto-create the space.
|
|
1092
|
+
*
|
|
1093
|
+
* @param spaceId - Full space URI (`tinycloud:pkh:eip155:<chain>:<addr>:<name>`).
|
|
1094
|
+
*/
|
|
1095
|
+
kvForSpace(spaceId: string): IKVService;
|
|
1079
1096
|
/**
|
|
1080
1097
|
* DuckDB database operations on this user's space.
|
|
1081
1098
|
*/
|
package/dist/core.cjs
CHANGED
|
@@ -518,11 +518,13 @@ var NodeUserAuthorization = class {
|
|
|
518
518
|
const request = this.getCapabilityRequest();
|
|
519
519
|
if (request === void 0) {
|
|
520
520
|
const defaultNetworkId = this.defaultEncryptionNetworkId(address, chainId);
|
|
521
|
+
const primarySpaceId2 = (0, import_sdk_core2.makePkhSpaceId)(address, chainId, this.spacePrefix);
|
|
521
522
|
const secretsSpaceId = (0, import_sdk_core2.makePkhSpaceId)(address, chainId, "secrets");
|
|
522
523
|
return {
|
|
523
524
|
abilities: this.defaultActions,
|
|
524
|
-
spaceId:
|
|
525
|
+
spaceId: primarySpaceId2,
|
|
525
526
|
spaceAbilities: {
|
|
527
|
+
[primarySpaceId2]: this.defaultActions,
|
|
526
528
|
[secretsSpaceId]: {
|
|
527
529
|
kv: {
|
|
528
530
|
"vault/secrets/": [
|
|
@@ -1122,14 +1124,15 @@ var import_sdk_core6 = require("@tinycloud/sdk-core");
|
|
|
1122
1124
|
// src/DelegatedAccess.ts
|
|
1123
1125
|
var import_sdk_core3 = require("@tinycloud/sdk-core");
|
|
1124
1126
|
var DelegatedAccess = class {
|
|
1125
|
-
constructor(session, delegation, host, invoke) {
|
|
1127
|
+
constructor(session, delegation, host, invoke, telemetry) {
|
|
1126
1128
|
this.session = session;
|
|
1127
1129
|
this._delegation = delegation;
|
|
1128
1130
|
this.host = host;
|
|
1129
1131
|
this._serviceContext = new import_sdk_core3.ServiceContext({
|
|
1130
1132
|
invoke,
|
|
1131
1133
|
fetch: globalThis.fetch.bind(globalThis),
|
|
1132
|
-
hosts: [host]
|
|
1134
|
+
hosts: [host],
|
|
1135
|
+
telemetry
|
|
1133
1136
|
});
|
|
1134
1137
|
const prefix = this._delegation.path.replace(/\/$/, "");
|
|
1135
1138
|
this._kv = new import_sdk_core3.KVService({ prefix });
|
|
@@ -1710,7 +1713,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1710
1713
|
const kvContext = new import_sdk_core6.ServiceContext({
|
|
1711
1714
|
invoke: config2.invoke,
|
|
1712
1715
|
fetch: config2.fetch ?? globalThis.fetch.bind(globalThis),
|
|
1713
|
-
hosts: config2.hosts
|
|
1716
|
+
hosts: config2.hosts,
|
|
1717
|
+
telemetry: this.config.telemetry
|
|
1714
1718
|
});
|
|
1715
1719
|
kvContext.setSession(config2.session);
|
|
1716
1720
|
kvService.initialize(kvContext);
|
|
@@ -1767,7 +1771,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1767
1771
|
includeAccountRegistryPermissions: config.includeAccountRegistryPermissions
|
|
1768
1772
|
});
|
|
1769
1773
|
this.tc = new import_sdk_core6.TinyCloud(this.auth, {
|
|
1770
|
-
invokeAny: this.invokeAnyWithRuntimePermissions
|
|
1774
|
+
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
1775
|
+
telemetry: config.telemetry
|
|
1771
1776
|
});
|
|
1772
1777
|
}
|
|
1773
1778
|
syncResolvedHostFromAuth() {
|
|
@@ -1999,7 +2004,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
1999
2004
|
invoke: this.invokeWithRuntimePermissions,
|
|
2000
2005
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
2001
2006
|
fetch: globalThis.fetch.bind(globalThis),
|
|
2002
|
-
hosts: [this.config.host]
|
|
2007
|
+
hosts: [this.config.host],
|
|
2008
|
+
telemetry: this.config.telemetry
|
|
2003
2009
|
});
|
|
2004
2010
|
this._kv = new import_sdk_core6.KVService({});
|
|
2005
2011
|
this._kv.initialize(this._serviceContext);
|
|
@@ -2110,7 +2116,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2110
2116
|
includeAccountRegistryPermissions: this.config.includeAccountRegistryPermissions
|
|
2111
2117
|
});
|
|
2112
2118
|
this.tc = new import_sdk_core6.TinyCloud(this.auth, {
|
|
2113
|
-
invokeAny: this.invokeAnyWithRuntimePermissions
|
|
2119
|
+
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
2120
|
+
telemetry: this.config.telemetry
|
|
2114
2121
|
});
|
|
2115
2122
|
this.config.prefix = prefix;
|
|
2116
2123
|
}
|
|
@@ -2154,7 +2161,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2154
2161
|
includeAccountRegistryPermissions: this.config.includeAccountRegistryPermissions
|
|
2155
2162
|
});
|
|
2156
2163
|
this.tc = new import_sdk_core6.TinyCloud(this.auth, {
|
|
2157
|
-
invokeAny: this.invokeAnyWithRuntimePermissions
|
|
2164
|
+
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
2165
|
+
telemetry: this.config.telemetry
|
|
2158
2166
|
});
|
|
2159
2167
|
this.config.prefix = prefix;
|
|
2160
2168
|
}
|
|
@@ -2172,7 +2180,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2172
2180
|
invoke: this.invokeWithRuntimePermissions,
|
|
2173
2181
|
invokeAny: this.invokeAnyWithRuntimePermissions,
|
|
2174
2182
|
fetch: globalThis.fetch.bind(globalThis),
|
|
2175
|
-
hosts: [this.config.host]
|
|
2183
|
+
hosts: [this.config.host],
|
|
2184
|
+
telemetry: this.config.telemetry
|
|
2176
2185
|
});
|
|
2177
2186
|
this._kv = new import_sdk_core6.KVService({});
|
|
2178
2187
|
this._kv.initialize(this._serviceContext);
|
|
@@ -2211,7 +2220,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2211
2220
|
const spaceScopedContext = new import_sdk_core6.ServiceContext({
|
|
2212
2221
|
invoke: this._serviceContext.invoke,
|
|
2213
2222
|
fetch: this._serviceContext.fetch,
|
|
2214
|
-
hosts: this._serviceContext.hosts
|
|
2223
|
+
hosts: this._serviceContext.hosts,
|
|
2224
|
+
telemetry: this.config.telemetry
|
|
2215
2225
|
});
|
|
2216
2226
|
const session = this._serviceContext.session;
|
|
2217
2227
|
if (session) {
|
|
@@ -2776,12 +2786,41 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
2776
2786
|
const spaceScopedContext = new import_sdk_core6.ServiceContext({
|
|
2777
2787
|
invoke: this._serviceContext.invoke,
|
|
2778
2788
|
fetch: this._serviceContext.fetch,
|
|
2779
|
-
hosts: this._serviceContext.hosts
|
|
2789
|
+
hosts: this._serviceContext.hosts,
|
|
2790
|
+
telemetry: this.config.telemetry
|
|
2780
2791
|
});
|
|
2781
2792
|
spaceScopedContext.setSession({ ...this._serviceContext.session, spaceId });
|
|
2782
2793
|
sql.initialize(spaceScopedContext);
|
|
2783
2794
|
return sql;
|
|
2784
2795
|
}
|
|
2796
|
+
/**
|
|
2797
|
+
* Get a KV service scoped to a specific space.
|
|
2798
|
+
*
|
|
2799
|
+
* The KV counterpart to {@link sqlForSpace}: clones the active service
|
|
2800
|
+
* context and overrides its session's spaceId so that subsequent
|
|
2801
|
+
* `kv/<action>` invocations route to that space. Useful for reading data
|
|
2802
|
+
* that a manifest app stores outside the primary space (e.g. transcripts a
|
|
2803
|
+
* `defaults: true` app keeps under the owner's `applications` space), when
|
|
2804
|
+
* the caller already holds a delegation covering the target space.
|
|
2805
|
+
*
|
|
2806
|
+
* Does NOT auto-create the space.
|
|
2807
|
+
*
|
|
2808
|
+
* @param spaceId - Full space URI (`tinycloud:pkh:eip155:<chain>:<addr>:<name>`).
|
|
2809
|
+
*/
|
|
2810
|
+
kvForSpace(spaceId) {
|
|
2811
|
+
if (!this._serviceContext || !this._serviceContext.session) {
|
|
2812
|
+
throw new Error("Not signed in. Call signIn() first.");
|
|
2813
|
+
}
|
|
2814
|
+
const kv = new import_sdk_core6.KVService({});
|
|
2815
|
+
const spaceScopedContext = new import_sdk_core6.ServiceContext({
|
|
2816
|
+
invoke: this._serviceContext.invoke,
|
|
2817
|
+
fetch: this._serviceContext.fetch,
|
|
2818
|
+
hosts: this._serviceContext.hosts
|
|
2819
|
+
});
|
|
2820
|
+
spaceScopedContext.setSession({ ...this._serviceContext.session, spaceId });
|
|
2821
|
+
kv.initialize(spaceScopedContext);
|
|
2822
|
+
return kv;
|
|
2823
|
+
}
|
|
2785
2824
|
/**
|
|
2786
2825
|
* DuckDB database operations on this user's space.
|
|
2787
2826
|
*/
|
|
@@ -3348,7 +3387,8 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
3348
3387
|
const publicContext = new import_sdk_core6.ServiceContext({
|
|
3349
3388
|
invoke: this.invokeWithRuntimePermissions,
|
|
3350
3389
|
fetch: this._serviceContext.fetch,
|
|
3351
|
-
hosts: this._serviceContext.hosts
|
|
3390
|
+
hosts: this._serviceContext.hosts,
|
|
3391
|
+
telemetry: this.config.telemetry
|
|
3352
3392
|
});
|
|
3353
3393
|
publicContext.setSession({
|
|
3354
3394
|
delegationHeader: delegationSession.delegationHeader,
|
|
@@ -4244,7 +4284,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4244
4284
|
},
|
|
4245
4285
|
delegation.expiry
|
|
4246
4286
|
);
|
|
4247
|
-
return new DelegatedAccess(
|
|
4287
|
+
return new DelegatedAccess(
|
|
4288
|
+
session2,
|
|
4289
|
+
delegation,
|
|
4290
|
+
targetHost,
|
|
4291
|
+
this.wasmBindings.invoke,
|
|
4292
|
+
this.config.telemetry
|
|
4293
|
+
);
|
|
4248
4294
|
}
|
|
4249
4295
|
const mySession = this.auth?.tinyCloudSession;
|
|
4250
4296
|
if (!mySession) {
|
|
@@ -4322,7 +4368,13 @@ var _TinyCloudNode = class _TinyCloudNode {
|
|
|
4322
4368
|
},
|
|
4323
4369
|
expirationTime
|
|
4324
4370
|
);
|
|
4325
|
-
return new DelegatedAccess(
|
|
4371
|
+
return new DelegatedAccess(
|
|
4372
|
+
session,
|
|
4373
|
+
delegation,
|
|
4374
|
+
targetHost,
|
|
4375
|
+
this.wasmBindings.invoke,
|
|
4376
|
+
this.config.telemetry
|
|
4377
|
+
);
|
|
4326
4378
|
}
|
|
4327
4379
|
/**
|
|
4328
4380
|
* Create a sub-delegation from a received delegation.
|