@tinycloud/sdk-services 3.12.0-beta.4 → 3.12.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.
@@ -1,18 +1,44 @@
1
- import { F as FetchFunction, P as PermissionHint } from './types-DjAP8dve.js';
1
+ import { F as FetchFunction, e as FetchResponse, S as ServiceSession, P as PermissionHint } from './types-DjAP8dve.js';
2
2
 
3
3
  type ResourceAccess = "read" | "write" | "host" | "encryption";
4
4
  interface ResourceDestination {
5
5
  readonly url: string;
6
6
  readonly nodeDid?: string;
7
7
  }
8
+ interface ResourceNodeInfo {
9
+ readonly nodeId: string;
10
+ readonly features?: unknown;
11
+ }
8
12
  interface ResourceRoutingConfig {
9
13
  resolveResource(resource: string, access: ResourceAccess): Promise<readonly ResourceDestination[]>;
10
14
  bindAudience(authorization: string, nodeDid: string): Promise<string>;
11
15
  /** Defaults to the raw transport's public node identity checks. */
12
- verifyDestination?(target: ResourceDestination): Promise<void>;
16
+ verifyDestination?(target: ResourceDestination): Promise<void | ResourceNodeInfo>;
17
+ }
18
+ /** An identity-checked destination bound to one live resource-routing decision. */
19
+ interface ResourceTransportTarget {
20
+ readonly url: string;
21
+ readonly nodeDid: string;
22
+ readonly fetch: FetchFunction;
23
+ readonly nodeInfo: ResourceNodeInfo;
24
+ bindAudience(authorization: string): Promise<string>;
25
+ }
26
+ interface ResourceTransportOptions {
27
+ /** CID-only controls are node-local and must not choose among several destinations. */
28
+ readonly nodeLocal?: boolean;
29
+ /** An existing node-bound authority must match the resolved destination. */
30
+ readonly nodeDid?: string;
31
+ /** A verified imported grant activates its resources independently, not atomically. */
32
+ readonly independentResources?: boolean;
33
+ /** Captured, verified share-session key for its own locally created invocations. */
34
+ readonly invocationSession?: ServiceSession;
13
35
  }
36
+ type ResourceTransport = (resources: readonly {
37
+ resource: string;
38
+ access: ResourceAccess;
39
+ }[], send: (target: ResourceTransportTarget) => Promise<FetchResponse>, options?: ResourceTransportOptions) => Promise<FetchResponse>;
14
40
  /** Compare both public node identity surfaces before sending a capability. */
15
- declare function verifyResourceDestination(target: ResourceDestination, fetchFn: FetchFunction): Promise<void>;
41
+ declare function verifyResourceDestination(target: ResourceDestination, fetchFn: FetchFunction): Promise<ResourceNodeInfo | undefined>;
16
42
  declare class NodeNotRespondingError extends Error {
17
43
  readonly hosts: readonly string[];
18
44
  readonly cause?: unknown | undefined;
@@ -54,6 +80,15 @@ interface RoutingFailure {
54
80
  }
55
81
  /** Preserve routing failures through service-specific Result/error adapters. */
56
82
  declare function routingFailure(error: unknown): RoutingFailure | undefined;
83
+ /** Extract the signed resource without inferring an account for node-local names. */
84
+ declare function routingResourceOf(uri: string): string;
85
+ /** Share target selection and read/write outcomes with resource-specific adapters. */
86
+ declare function routeResourceRequest(resources: readonly {
87
+ resource: string;
88
+ access: ResourceAccess;
89
+ }[], routing: Pick<ResourceRoutingConfig, "resolveResource">, send: (target: ResourceDestination) => Promise<FetchResponse>, options?: ResourceTransportOptions): Promise<FetchResponse>;
90
+ /** Route only locally generated data invocations through a captured share session. */
91
+ declare function createResourceTransportInvocationFetch(transport: ResourceTransport, session: ServiceSession): FetchFunction;
57
92
  /** Route signed /invoke traffic. Non-invocation endpoints retain their own resource-specific adapters. */
58
93
  declare function createResourceRoutingFetch(fetchFn: FetchFunction, routing: ResourceRoutingConfig): FetchFunction;
59
94
 
@@ -387,4 +422,4 @@ declare function encryptionError(input: EncryptionErrorInput): EncryptionError;
387
422
  /** Re-export for ergonomic typing of canonical payloads. */
388
423
  type CanonicalJson = Json;
389
424
 
390
- export { canonicalize as A, type BuildDecryptInvocationInput as B, type CanonicalJson as C, type DecryptCapabilityProof as D, type EncryptionCrypto as E, createResourceRoutingFetch as F, encryptionError as G, hexDecode as H, type InlineEncryptedEnvelope as I, type Json as J, hexEncode as K, routingFailure as L, utf8Decode as M, type NetworkDescriptor as N, utf8Encode as O, PartialNodeWriteError as P, verifyResourceDestination as Q, type RoutingFailure as R, type BuiltDecryptInvocation as a, DECRYPT_ACTION as b, DECRYPT_FACT_TYPE as c, DECRYPT_RESULT_TYPE as d, DEFAULT_ENCRYPTION_ALG as e, DEFAULT_KEY_VERSION as f, type DecryptInvocationFact as g, type DecryptInvocationSigner as h, type DecryptRequestBody as i, type DecryptResponseBody as j, ENCRYPTION_SERVICE as k, ENCRYPTION_SERVICE_SHORT as l, ENVELOPE_VERSION as m, type EncryptionError as n, type EncryptionErrorInput as o, NodeIdentityMismatchError as p, NodeNotRespondingError as q, type ReceiverKeyPair as r, type ReceiverKeySigner as s, type ResourceAccess as t, type ResourceDestination as u, ResourceNotRoutedError as v, type ResourceRoutingConfig as w, base64Decode as x, base64Encode as y, canonicalHashHex as z };
425
+ export { type ResourceTransportTarget as A, type BuildDecryptInvocationInput as B, type CanonicalJson as C, type DecryptCapabilityProof as D, type EncryptionCrypto as E, base64Decode as F, base64Encode as G, canonicalHashHex as H, type InlineEncryptedEnvelope as I, type Json as J, canonicalize as K, createResourceRoutingFetch as L, createResourceTransportInvocationFetch as M, type NetworkDescriptor as N, encryptionError as O, PartialNodeWriteError as P, hexDecode as Q, type RoutingFailure as R, hexEncode as S, routeResourceRequest as T, routingFailure as U, routingResourceOf as V, utf8Decode as W, utf8Encode as X, verifyResourceDestination as Y, type BuiltDecryptInvocation as a, DECRYPT_ACTION as b, DECRYPT_FACT_TYPE as c, DECRYPT_RESULT_TYPE as d, DEFAULT_ENCRYPTION_ALG as e, DEFAULT_KEY_VERSION as f, type DecryptInvocationFact as g, type DecryptInvocationSigner as h, type DecryptRequestBody as i, type DecryptResponseBody as j, ENCRYPTION_SERVICE as k, ENCRYPTION_SERVICE_SHORT as l, ENVELOPE_VERSION as m, type EncryptionError as n, type EncryptionErrorInput as o, NodeIdentityMismatchError as p, NodeNotRespondingError as q, type ReceiverKeyPair as r, type ReceiverKeySigner as s, type ResourceAccess as t, type ResourceDestination as u, type ResourceNodeInfo as v, ResourceNotRoutedError as w, type ResourceRoutingConfig as x, type ResourceTransport as y, type ResourceTransportOptions as z };
@@ -1,18 +1,44 @@
1
- import { F as FetchFunction, P as PermissionHint } from './types-DjAP8dve.cjs';
1
+ import { F as FetchFunction, e as FetchResponse, S as ServiceSession, P as PermissionHint } from './types-DjAP8dve.cjs';
2
2
 
3
3
  type ResourceAccess = "read" | "write" | "host" | "encryption";
4
4
  interface ResourceDestination {
5
5
  readonly url: string;
6
6
  readonly nodeDid?: string;
7
7
  }
8
+ interface ResourceNodeInfo {
9
+ readonly nodeId: string;
10
+ readonly features?: unknown;
11
+ }
8
12
  interface ResourceRoutingConfig {
9
13
  resolveResource(resource: string, access: ResourceAccess): Promise<readonly ResourceDestination[]>;
10
14
  bindAudience(authorization: string, nodeDid: string): Promise<string>;
11
15
  /** Defaults to the raw transport's public node identity checks. */
12
- verifyDestination?(target: ResourceDestination): Promise<void>;
16
+ verifyDestination?(target: ResourceDestination): Promise<void | ResourceNodeInfo>;
17
+ }
18
+ /** An identity-checked destination bound to one live resource-routing decision. */
19
+ interface ResourceTransportTarget {
20
+ readonly url: string;
21
+ readonly nodeDid: string;
22
+ readonly fetch: FetchFunction;
23
+ readonly nodeInfo: ResourceNodeInfo;
24
+ bindAudience(authorization: string): Promise<string>;
25
+ }
26
+ interface ResourceTransportOptions {
27
+ /** CID-only controls are node-local and must not choose among several destinations. */
28
+ readonly nodeLocal?: boolean;
29
+ /** An existing node-bound authority must match the resolved destination. */
30
+ readonly nodeDid?: string;
31
+ /** A verified imported grant activates its resources independently, not atomically. */
32
+ readonly independentResources?: boolean;
33
+ /** Captured, verified share-session key for its own locally created invocations. */
34
+ readonly invocationSession?: ServiceSession;
13
35
  }
36
+ type ResourceTransport = (resources: readonly {
37
+ resource: string;
38
+ access: ResourceAccess;
39
+ }[], send: (target: ResourceTransportTarget) => Promise<FetchResponse>, options?: ResourceTransportOptions) => Promise<FetchResponse>;
14
40
  /** Compare both public node identity surfaces before sending a capability. */
15
- declare function verifyResourceDestination(target: ResourceDestination, fetchFn: FetchFunction): Promise<void>;
41
+ declare function verifyResourceDestination(target: ResourceDestination, fetchFn: FetchFunction): Promise<ResourceNodeInfo | undefined>;
16
42
  declare class NodeNotRespondingError extends Error {
17
43
  readonly hosts: readonly string[];
18
44
  readonly cause?: unknown | undefined;
@@ -54,6 +80,15 @@ interface RoutingFailure {
54
80
  }
55
81
  /** Preserve routing failures through service-specific Result/error adapters. */
56
82
  declare function routingFailure(error: unknown): RoutingFailure | undefined;
83
+ /** Extract the signed resource without inferring an account for node-local names. */
84
+ declare function routingResourceOf(uri: string): string;
85
+ /** Share target selection and read/write outcomes with resource-specific adapters. */
86
+ declare function routeResourceRequest(resources: readonly {
87
+ resource: string;
88
+ access: ResourceAccess;
89
+ }[], routing: Pick<ResourceRoutingConfig, "resolveResource">, send: (target: ResourceDestination) => Promise<FetchResponse>, options?: ResourceTransportOptions): Promise<FetchResponse>;
90
+ /** Route only locally generated data invocations through a captured share session. */
91
+ declare function createResourceTransportInvocationFetch(transport: ResourceTransport, session: ServiceSession): FetchFunction;
57
92
  /** Route signed /invoke traffic. Non-invocation endpoints retain their own resource-specific adapters. */
58
93
  declare function createResourceRoutingFetch(fetchFn: FetchFunction, routing: ResourceRoutingConfig): FetchFunction;
59
94
 
@@ -387,4 +422,4 @@ declare function encryptionError(input: EncryptionErrorInput): EncryptionError;
387
422
  /** Re-export for ergonomic typing of canonical payloads. */
388
423
  type CanonicalJson = Json;
389
424
 
390
- export { canonicalize as A, type BuildDecryptInvocationInput as B, type CanonicalJson as C, type DecryptCapabilityProof as D, type EncryptionCrypto as E, createResourceRoutingFetch as F, encryptionError as G, hexDecode as H, type InlineEncryptedEnvelope as I, type Json as J, hexEncode as K, routingFailure as L, utf8Decode as M, type NetworkDescriptor as N, utf8Encode as O, PartialNodeWriteError as P, verifyResourceDestination as Q, type RoutingFailure as R, type BuiltDecryptInvocation as a, DECRYPT_ACTION as b, DECRYPT_FACT_TYPE as c, DECRYPT_RESULT_TYPE as d, DEFAULT_ENCRYPTION_ALG as e, DEFAULT_KEY_VERSION as f, type DecryptInvocationFact as g, type DecryptInvocationSigner as h, type DecryptRequestBody as i, type DecryptResponseBody as j, ENCRYPTION_SERVICE as k, ENCRYPTION_SERVICE_SHORT as l, ENVELOPE_VERSION as m, type EncryptionError as n, type EncryptionErrorInput as o, NodeIdentityMismatchError as p, NodeNotRespondingError as q, type ReceiverKeyPair as r, type ReceiverKeySigner as s, type ResourceAccess as t, type ResourceDestination as u, ResourceNotRoutedError as v, type ResourceRoutingConfig as w, base64Decode as x, base64Encode as y, canonicalHashHex as z };
425
+ export { type ResourceTransportTarget as A, type BuildDecryptInvocationInput as B, type CanonicalJson as C, type DecryptCapabilityProof as D, type EncryptionCrypto as E, base64Decode as F, base64Encode as G, canonicalHashHex as H, type InlineEncryptedEnvelope as I, type Json as J, canonicalize as K, createResourceRoutingFetch as L, createResourceTransportInvocationFetch as M, type NetworkDescriptor as N, encryptionError as O, PartialNodeWriteError as P, hexDecode as Q, type RoutingFailure as R, hexEncode as S, routeResourceRequest as T, routingFailure as U, routingResourceOf as V, utf8Decode as W, utf8Encode as X, verifyResourceDestination as Y, type BuiltDecryptInvocation as a, DECRYPT_ACTION as b, DECRYPT_FACT_TYPE as c, DECRYPT_RESULT_TYPE as d, DEFAULT_ENCRYPTION_ALG as e, DEFAULT_KEY_VERSION as f, type DecryptInvocationFact as g, type DecryptInvocationSigner as h, type DecryptRequestBody as i, type DecryptResponseBody as j, ENCRYPTION_SERVICE as k, ENCRYPTION_SERVICE_SHORT as l, ENVELOPE_VERSION as m, type EncryptionError as n, type EncryptionErrorInput as o, NodeIdentityMismatchError as p, NodeNotRespondingError as q, type ReceiverKeyPair as r, type ReceiverKeySigner as s, type ResourceAccess as t, type ResourceDestination as u, type ResourceNodeInfo as v, ResourceNotRoutedError as w, type ResourceRoutingConfig as x, type ResourceTransport as y, type ResourceTransportOptions as z };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tinycloud/sdk-services",
3
- "version": "3.12.0-beta.4",
3
+ "version": "3.12.0-beta.8",
4
4
  "description": "TinyCloud SDK Services - Platform-agnostic service implementations",
5
5
  "author": "TinyCloud, Inc.",
6
6
  "license": "EGPL",