@tinycloud/node-sdk 2.4.0-beta.1 → 2.4.0-beta.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.
@@ -1,4 +1,4 @@
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';
1
+ import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, IWasmBindings, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignInOptions, Delegation, DelegatedResource, PermissionEntry, TelemetryConfig, IKVService, ISQLService, IDuckDbService, IHooksService, INotificationHandler, IENSResolver, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, 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
 
@@ -540,6 +540,69 @@ interface PortableDelegation extends Omit<Delegation, "isRevoked"> {
540
540
  */
541
541
  resources?: DelegatedResource[];
542
542
  }
543
+ /**
544
+ * The transport shape `tc auth request --emit` produces and that an owner
545
+ * grants to its requester. Only the fields the grant logic needs are declared;
546
+ * the CLI artifact carries more (posture, captured command, ...) and remains a
547
+ * structural superset of this interface.
548
+ */
549
+ interface AuthRequestArtifact {
550
+ kind: "tinycloud.auth.request";
551
+ version: 1;
552
+ requestId: string;
553
+ /** The requester's session DID — the audience the grant is issued to. */
554
+ sessionDid: string;
555
+ /** The capabilities the requester is asking the owner to delegate. */
556
+ requested: PermissionEntry[];
557
+ /** Optional lifetime override carried from the request. */
558
+ requestedExpiry?: string | number;
559
+ }
560
+ /**
561
+ * The transport shape returned by {@link grantAuthRequest} (and written by
562
+ * `tc auth grant`). `tc auth import` accepts this artifact directly.
563
+ */
564
+ interface AuthDelegationArtifact {
565
+ kind: "tinycloud.auth.delegation";
566
+ version: 1;
567
+ requestId: string;
568
+ delegationCid: string;
569
+ delegation: PortableDelegation;
570
+ permissions: PermissionEntry[];
571
+ expiry: string;
572
+ /** Whether issuing the delegation triggered a wallet prompt. */
573
+ prompted: boolean;
574
+ }
575
+ /**
576
+ * Minimal owner-side capability {@link grantAuthRequest} needs: the signed
577
+ * `delegateTo` primitive. `TinyCloudNode` satisfies this directly; web/SDK
578
+ * contexts can supply any object that exposes the same method.
579
+ */
580
+ interface DelegationAuthority {
581
+ delegateTo(did: string, permissions: PermissionEntry[], options?: {
582
+ expiry?: string | number;
583
+ forceWalletSign?: boolean;
584
+ }): Promise<{
585
+ delegation: PortableDelegation;
586
+ prompted: boolean;
587
+ }>;
588
+ }
589
+ /**
590
+ * Turn a delegation REQUEST into a signed GRANT.
591
+ *
592
+ * Lifts the body of `tc auth grant` into the SDK so the request→grant
593
+ * handshake is callable programmatically (future SDK/web owner tooling and the
594
+ * KV delegation inbox), with the CLI verb reduced to a thin wrapper. The owner
595
+ * `authority` (a `TinyCloudNode`) signs a delegation scoped to exactly the
596
+ * requested caps, audienced to the requester's `sessionDid`, honoring the
597
+ * request's expiry. The returned artifact round-trips through `tc auth import`.
598
+ *
599
+ * Authorization is enforced cryptographically by `delegateTo`: caps that are
600
+ * not derivable from the owner's own session capability chain are rejected
601
+ * (it throws), so this never widens authority the owner doesn't hold.
602
+ */
603
+ declare function grantAuthRequest(authority: DelegationAuthority, request: AuthRequestArtifact, options?: {
604
+ expiry?: string | number;
605
+ }): Promise<AuthDelegationArtifact>;
543
606
  /**
544
607
  * Serialize a PortableDelegation for transport (e.g., over network).
545
608
  */
@@ -1669,4 +1732,4 @@ declare class WasmKeyProvider implements KeyProvider {
1669
1732
  */
1670
1733
  declare function createWasmKeyProvider(sessionManager: SessionManagerWithListing): WasmKeyProvider;
1671
1734
 
1672
- export { type DelegateToOptions as D, FileSessionStorage as F, MemorySessionStorage as M, type NodeEventEmitterStrategy as N, type PortableDelegation as P, type RestorableSession as R, type SignStrategy as S, TinyCloudNode as T, WasmKeyProvider as W, type DelegateToResult as a, DelegatedAccess as b, NodeUserAuthorization as c, type NodeUserAuthorizationConfig as d, type RuntimePermissionGrantOptions as e, type TinyCloudNodeConfig as f, type WasmKeyProviderConfig as g, createWasmKeyProvider as h, defaultSignStrategy as i, deserializeDelegation as j, serializeDelegation as s };
1735
+ export { type AuthDelegationArtifact as A, type DelegateToOptions as D, FileSessionStorage as F, MemorySessionStorage as M, type NodeEventEmitterStrategy as N, type PortableDelegation as P, type RestorableSession as R, type SignStrategy as S, TinyCloudNode as T, WasmKeyProvider as W, type AuthRequestArtifact as a, type DelegateToResult as b, DelegatedAccess as c, type DelegationAuthority as d, NodeUserAuthorization as e, type NodeUserAuthorizationConfig as f, type RuntimePermissionGrantOptions as g, type TinyCloudNodeConfig as h, type WasmKeyProviderConfig as i, createWasmKeyProvider as j, defaultSignStrategy as k, deserializeDelegation as l, grantAuthRequest as m, serializeDelegation as s };
@@ -1,4 +1,4 @@
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';
1
+ import { ISessionStorage, PersistedSessionData, AutoSignStrategy, AutoRejectStrategy, CallbackStrategy, IUserAuthorization, ISigner, ISpaceCreationHandler, IWasmBindings, SiweConfig, Manifest, ComposedManifestRequest, ClientSession, TinyCloudSession, Extension, SignInOptions, Delegation, DelegatedResource, PermissionEntry, TelemetryConfig, IKVService, ISQLService, IDuckDbService, IHooksService, INotificationHandler, IENSResolver, IDataVaultService, IEncryptionService, NetworkDescriptor, ISecretsService, ICapabilityKeyRegistry, 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
 
@@ -540,6 +540,69 @@ interface PortableDelegation extends Omit<Delegation, "isRevoked"> {
540
540
  */
541
541
  resources?: DelegatedResource[];
542
542
  }
543
+ /**
544
+ * The transport shape `tc auth request --emit` produces and that an owner
545
+ * grants to its requester. Only the fields the grant logic needs are declared;
546
+ * the CLI artifact carries more (posture, captured command, ...) and remains a
547
+ * structural superset of this interface.
548
+ */
549
+ interface AuthRequestArtifact {
550
+ kind: "tinycloud.auth.request";
551
+ version: 1;
552
+ requestId: string;
553
+ /** The requester's session DID — the audience the grant is issued to. */
554
+ sessionDid: string;
555
+ /** The capabilities the requester is asking the owner to delegate. */
556
+ requested: PermissionEntry[];
557
+ /** Optional lifetime override carried from the request. */
558
+ requestedExpiry?: string | number;
559
+ }
560
+ /**
561
+ * The transport shape returned by {@link grantAuthRequest} (and written by
562
+ * `tc auth grant`). `tc auth import` accepts this artifact directly.
563
+ */
564
+ interface AuthDelegationArtifact {
565
+ kind: "tinycloud.auth.delegation";
566
+ version: 1;
567
+ requestId: string;
568
+ delegationCid: string;
569
+ delegation: PortableDelegation;
570
+ permissions: PermissionEntry[];
571
+ expiry: string;
572
+ /** Whether issuing the delegation triggered a wallet prompt. */
573
+ prompted: boolean;
574
+ }
575
+ /**
576
+ * Minimal owner-side capability {@link grantAuthRequest} needs: the signed
577
+ * `delegateTo` primitive. `TinyCloudNode` satisfies this directly; web/SDK
578
+ * contexts can supply any object that exposes the same method.
579
+ */
580
+ interface DelegationAuthority {
581
+ delegateTo(did: string, permissions: PermissionEntry[], options?: {
582
+ expiry?: string | number;
583
+ forceWalletSign?: boolean;
584
+ }): Promise<{
585
+ delegation: PortableDelegation;
586
+ prompted: boolean;
587
+ }>;
588
+ }
589
+ /**
590
+ * Turn a delegation REQUEST into a signed GRANT.
591
+ *
592
+ * Lifts the body of `tc auth grant` into the SDK so the request→grant
593
+ * handshake is callable programmatically (future SDK/web owner tooling and the
594
+ * KV delegation inbox), with the CLI verb reduced to a thin wrapper. The owner
595
+ * `authority` (a `TinyCloudNode`) signs a delegation scoped to exactly the
596
+ * requested caps, audienced to the requester's `sessionDid`, honoring the
597
+ * request's expiry. The returned artifact round-trips through `tc auth import`.
598
+ *
599
+ * Authorization is enforced cryptographically by `delegateTo`: caps that are
600
+ * not derivable from the owner's own session capability chain are rejected
601
+ * (it throws), so this never widens authority the owner doesn't hold.
602
+ */
603
+ declare function grantAuthRequest(authority: DelegationAuthority, request: AuthRequestArtifact, options?: {
604
+ expiry?: string | number;
605
+ }): Promise<AuthDelegationArtifact>;
543
606
  /**
544
607
  * Serialize a PortableDelegation for transport (e.g., over network).
545
608
  */
@@ -1669,4 +1732,4 @@ declare class WasmKeyProvider implements KeyProvider {
1669
1732
  */
1670
1733
  declare function createWasmKeyProvider(sessionManager: SessionManagerWithListing): WasmKeyProvider;
1671
1734
 
1672
- export { type DelegateToOptions as D, FileSessionStorage as F, MemorySessionStorage as M, type NodeEventEmitterStrategy as N, type PortableDelegation as P, type RestorableSession as R, type SignStrategy as S, TinyCloudNode as T, WasmKeyProvider as W, type DelegateToResult as a, DelegatedAccess as b, NodeUserAuthorization as c, type NodeUserAuthorizationConfig as d, type RuntimePermissionGrantOptions as e, type TinyCloudNodeConfig as f, type WasmKeyProviderConfig as g, createWasmKeyProvider as h, defaultSignStrategy as i, deserializeDelegation as j, serializeDelegation as s };
1735
+ export { type AuthDelegationArtifact as A, type DelegateToOptions as D, FileSessionStorage as F, MemorySessionStorage as M, type NodeEventEmitterStrategy as N, type PortableDelegation as P, type RestorableSession as R, type SignStrategy as S, TinyCloudNode as T, WasmKeyProvider as W, type AuthRequestArtifact as a, type DelegateToResult as b, DelegatedAccess as c, type DelegationAuthority as d, NodeUserAuthorization as e, type NodeUserAuthorizationConfig as f, type RuntimePermissionGrantOptions as g, type TinyCloudNodeConfig as h, type WasmKeyProviderConfig as i, createWasmKeyProvider as j, defaultSignStrategy as k, deserializeDelegation as l, grantAuthRequest as m, serializeDelegation as s };