@tinycloud/node-sdk 3.1.0-beta.1 → 3.1.0-beta.10
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-Bm76PnOz.d.cts → core-CC7uDKZP.d.cts} +77 -6
- package/dist/{core-Bm76PnOz.d.ts → core-CC7uDKZP.d.ts} +77 -6
- package/dist/core.cjs +308 -111
- package/dist/core.cjs.map +1 -1
- package/dist/core.d.cts +1 -1
- package/dist/core.d.ts +1 -1
- package/dist/core.js +314 -112
- package/dist/core.js.map +1 -1
- package/dist/index.cjs +366 -143
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +3 -2
- package/dist/index.d.ts +3 -2
- package/dist/index.js +372 -145
- package/dist/index.js.map +1 -1
- package/package.json +4 -4
|
@@ -758,6 +758,17 @@ interface PortableDelegation extends Omit<Delegation, "isRevoked"> {
|
|
|
758
758
|
* fields are authoritative (legacy single-resource shape).
|
|
759
759
|
*/
|
|
760
760
|
resources?: DelegatedResource[];
|
|
761
|
+
/**
|
|
762
|
+
* The wallet-signed SIWE message and EIP-191 signature behind a
|
|
763
|
+
* `delegationHeader` that is a CACAO session grant (OpenKey `/delegate`,
|
|
764
|
+
* {@link TinyCloudNode.grantRuntimePermissions}) rather than a compact UCAN.
|
|
765
|
+
* Not authority: activation rebuilds the CACAO from them and accepts only
|
|
766
|
+
* byte-identical authorization bytes.
|
|
767
|
+
*/
|
|
768
|
+
siweProof?: {
|
|
769
|
+
siwe: string;
|
|
770
|
+
signature: string;
|
|
771
|
+
};
|
|
761
772
|
}
|
|
762
773
|
/**
|
|
763
774
|
* The transport shape `tc auth request --emit` produces and that an owner
|
|
@@ -819,6 +830,11 @@ interface RuntimeDelegationActivator {
|
|
|
819
830
|
useRuntimeDelegation(delegation: PortableDelegation): Promise<void>;
|
|
820
831
|
useDelegation?(delegation: PortableDelegation): Promise<unknown>;
|
|
821
832
|
getRuntimePermissionDelegations(): PortableDelegation[];
|
|
833
|
+
/**
|
|
834
|
+
* Verify a wallet-signed session grant issued to this runtime's live session
|
|
835
|
+
* key. Required to activate a CACAO grant; compact UCANs do not use it.
|
|
836
|
+
*/
|
|
837
|
+
verifySessionGrant?(grant: SessionGrantProof): VerifiedSessionGrant;
|
|
822
838
|
}
|
|
823
839
|
/** The installed authority returned by {@link activateValidatedRuntimeDelegation}. */
|
|
824
840
|
interface ValidatedRuntimeDelegation {
|
|
@@ -842,16 +858,59 @@ interface CompactRuntimeDelegationInput {
|
|
|
842
858
|
readonly ownerAddress: string;
|
|
843
859
|
readonly chainId: number;
|
|
844
860
|
}
|
|
861
|
+
/** A CACAO session grant and the signed SIWE proof it was built from. */
|
|
862
|
+
interface SessionGrantProof {
|
|
863
|
+
readonly delegationHeader: {
|
|
864
|
+
Authorization: string;
|
|
865
|
+
};
|
|
866
|
+
readonly delegationCid: string;
|
|
867
|
+
readonly spaceId: string;
|
|
868
|
+
readonly address: string;
|
|
869
|
+
readonly chainId: number;
|
|
870
|
+
readonly siwe: string;
|
|
871
|
+
readonly signature: string;
|
|
872
|
+
}
|
|
873
|
+
/** Authority read from a verified session grant's signed ReCap. */
|
|
874
|
+
interface VerifiedSessionGrant {
|
|
875
|
+
readonly recap: readonly {
|
|
876
|
+
service: string;
|
|
877
|
+
space: string;
|
|
878
|
+
path: string;
|
|
879
|
+
actions: string[];
|
|
880
|
+
caveats?: Record<string, unknown>[];
|
|
881
|
+
}[];
|
|
882
|
+
readonly expiresAt: Date;
|
|
883
|
+
}
|
|
845
884
|
/**
|
|
846
|
-
*
|
|
885
|
+
* Stable reasons {@link activateValidatedRuntimeDelegation} refuses a
|
|
886
|
+
* delegation for. The error message is for the caller and may quote
|
|
887
|
+
* transport fields or a node's response; the reason is safe to publish.
|
|
888
|
+
*/
|
|
889
|
+
declare const RUNTIME_DELEGATION_REJECTIONS: readonly ["host_mismatch", "expired", "cid_mismatch", "authority_invalid", "proof_missing", "proof_invalid", "owner_mismatch", "audience_mismatch", "resources_mismatch", "unsupported", "activation_rejected"];
|
|
890
|
+
type RuntimeDelegationRejection = typeof RUNTIME_DELEGATION_REJECTIONS[number];
|
|
891
|
+
declare class RuntimeDelegationRejectedError extends Error {
|
|
892
|
+
readonly reason: RuntimeDelegationRejection;
|
|
893
|
+
constructor(reason: RuntimeDelegationRejection, message: string);
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* CID-bind and activate one runtime delegation.
|
|
897
|
+
*
|
|
898
|
+
* A compact UCAN's audience, expiry and permissions come from its signed
|
|
899
|
+
* payload, and its transport fields must agree with them. A CACAO session
|
|
900
|
+
* grant (OpenKey `/delegate`, `grantRuntimePermissions`) is verified from its
|
|
901
|
+
* `siweProof` against this runtime's live session key; its installed
|
|
902
|
+
* authority is exactly the verified ReCap, and its transport `resources` are
|
|
903
|
+
* display data that is never consulted. Either way the helper then invokes
|
|
904
|
+
* {@link TinyCloudNode.useRuntimeDelegation}; the node activation call remains
|
|
905
|
+
* the authority and delegation-chain validation boundary.
|
|
847
906
|
*
|
|
848
|
-
*
|
|
849
|
-
*
|
|
850
|
-
*
|
|
851
|
-
* remains the authority and delegation-chain validation boundary.
|
|
907
|
+
* `options.authorize`, when given, sees the signed capabilities before
|
|
908
|
+
* anything is activated or installed; returning `false` refuses the
|
|
909
|
+
* delegation.
|
|
852
910
|
*/
|
|
853
911
|
declare function activateValidatedRuntimeDelegation(node: RuntimeDelegationActivator, delegation: PortableDelegation, options: {
|
|
854
912
|
host: string;
|
|
913
|
+
authorize?: (effectivePermissions: readonly PermissionEntry[]) => boolean;
|
|
855
914
|
}): Promise<ValidatedRuntimeDelegation>;
|
|
856
915
|
/**
|
|
857
916
|
* Import compact UCAN bytes returned by an authority ceremony through the
|
|
@@ -1966,6 +2025,18 @@ declare class TinyCloudNode {
|
|
|
1966
2025
|
* live authority must combine this with {@link getVerifiedSessionCapabilities}.
|
|
1967
2026
|
*/
|
|
1968
2027
|
getEffectiveRuntimePermissionEntries(): PermissionEntry[];
|
|
2028
|
+
/**
|
|
2029
|
+
* Verify a wallet-signed session grant (a CACAO built from a SIWE and its
|
|
2030
|
+
* EIP-191 signature) issued to this instance's live session key. The
|
|
2031
|
+
* verifier rebuilds the CACAO from `siwe` and `signature`, so the grant is
|
|
2032
|
+
* accepted only when its authorization bytes and CID are exactly that CACAO,
|
|
2033
|
+
* its signer is `address`, its audience is this session key, it is valid
|
|
2034
|
+
* now, and its ReCap covers `spaceId` or names only raw encryption networks
|
|
2035
|
+
* (a decrypt-only grant has no space). Returns the signed ReCap and expiry.
|
|
2036
|
+
* Bindings without `validateSessionGrant` fall back to the session verifier,
|
|
2037
|
+
* which also refuses decrypt-only grants.
|
|
2038
|
+
*/
|
|
2039
|
+
verifySessionGrant(grant: SessionGrantProof): VerifiedSessionGrant;
|
|
1969
2040
|
/**
|
|
1970
2041
|
* Install a portable runtime permission delegation into this SDK instance so
|
|
1971
2042
|
* matching service calls and downstream `delegateTo()` calls can use it.
|
|
@@ -2474,4 +2545,4 @@ declare class WasmKeyProvider implements KeyProvider {
|
|
|
2474
2545
|
*/
|
|
2475
2546
|
declare function createWasmKeyProvider(sessionManager: SessionManagerWithListing): WasmKeyProvider;
|
|
2476
2547
|
|
|
2477
|
-
export { ACCEPTED_MARKER_VERSIONS as A, BOOTSTRAP_COMPLETION_MARKER_KEY as B, type CompactRuntimeDelegationInput as C, type DelegateToOptions as D, type EnsureEncryptionNetworkOptions as E, FileSessionStorage as F,
|
|
2548
|
+
export { ACCEPTED_MARKER_VERSIONS as A, BOOTSTRAP_COMPLETION_MARKER_KEY as B, type CompactRuntimeDelegationInput as C, type DelegateToOptions as D, type EnsureEncryptionNetworkOptions as E, FileSessionStorage as F, activateValidatedRuntimeDelegation as G, createWasmKeyProvider as H, InvalidRestoredSessionError as I, defaultSignStrategy as J, deserializeDelegation as K, grantAuthRequest as L, MemorySessionStorage as M, type NodeEventEmitterStrategy as N, type OwnerDelegationReceipt as O, type PortableDelegation as P, serializeDelegation as Q, RUNTIME_DELEGATION_REJECTIONS as R, type SecretPermissionHint as S, TinyCloudNode as T, type UnifiedOwnerRootInput as U, type ValidatedRuntimeDelegation as V, WasmKeyProvider as W, type AuthDelegationArtifact as a, type AuthRequestArtifact as b, BOOTSTRAP_COMPLETION_MARKER_VERSION as c, type BootstrapCompletionMarker as d, type BootstrapWarning as e, type CreateOwnerDelegationParams as f, type DelegateToResult as g, DelegatedAccess as h, type DelegationAuthority as i, NodeUserAuthorization as j, type NodeUserAuthorizationConfig as k, type RestorableSession as l, type RuntimeDelegationActivator as m, RuntimeDelegationRejectedError as n, type RuntimeDelegationRejection as o, type RuntimePermissionGrantOptions as p, type SecretReadInput as q, type SecretReadResult as r, type SessionGrantProof as s, type SignStrategy as t, type TinyCloudNodeConfig as u, type UnifiedOwnerRootReceipt as v, UnsupportedSessionRestoreError as w, type VerifiedSessionGrant as x, type WasmKeyProviderConfig as y, activateCompactRuntimeDelegation as z };
|
|
@@ -758,6 +758,17 @@ interface PortableDelegation extends Omit<Delegation, "isRevoked"> {
|
|
|
758
758
|
* fields are authoritative (legacy single-resource shape).
|
|
759
759
|
*/
|
|
760
760
|
resources?: DelegatedResource[];
|
|
761
|
+
/**
|
|
762
|
+
* The wallet-signed SIWE message and EIP-191 signature behind a
|
|
763
|
+
* `delegationHeader` that is a CACAO session grant (OpenKey `/delegate`,
|
|
764
|
+
* {@link TinyCloudNode.grantRuntimePermissions}) rather than a compact UCAN.
|
|
765
|
+
* Not authority: activation rebuilds the CACAO from them and accepts only
|
|
766
|
+
* byte-identical authorization bytes.
|
|
767
|
+
*/
|
|
768
|
+
siweProof?: {
|
|
769
|
+
siwe: string;
|
|
770
|
+
signature: string;
|
|
771
|
+
};
|
|
761
772
|
}
|
|
762
773
|
/**
|
|
763
774
|
* The transport shape `tc auth request --emit` produces and that an owner
|
|
@@ -819,6 +830,11 @@ interface RuntimeDelegationActivator {
|
|
|
819
830
|
useRuntimeDelegation(delegation: PortableDelegation): Promise<void>;
|
|
820
831
|
useDelegation?(delegation: PortableDelegation): Promise<unknown>;
|
|
821
832
|
getRuntimePermissionDelegations(): PortableDelegation[];
|
|
833
|
+
/**
|
|
834
|
+
* Verify a wallet-signed session grant issued to this runtime's live session
|
|
835
|
+
* key. Required to activate a CACAO grant; compact UCANs do not use it.
|
|
836
|
+
*/
|
|
837
|
+
verifySessionGrant?(grant: SessionGrantProof): VerifiedSessionGrant;
|
|
822
838
|
}
|
|
823
839
|
/** The installed authority returned by {@link activateValidatedRuntimeDelegation}. */
|
|
824
840
|
interface ValidatedRuntimeDelegation {
|
|
@@ -842,16 +858,59 @@ interface CompactRuntimeDelegationInput {
|
|
|
842
858
|
readonly ownerAddress: string;
|
|
843
859
|
readonly chainId: number;
|
|
844
860
|
}
|
|
861
|
+
/** A CACAO session grant and the signed SIWE proof it was built from. */
|
|
862
|
+
interface SessionGrantProof {
|
|
863
|
+
readonly delegationHeader: {
|
|
864
|
+
Authorization: string;
|
|
865
|
+
};
|
|
866
|
+
readonly delegationCid: string;
|
|
867
|
+
readonly spaceId: string;
|
|
868
|
+
readonly address: string;
|
|
869
|
+
readonly chainId: number;
|
|
870
|
+
readonly siwe: string;
|
|
871
|
+
readonly signature: string;
|
|
872
|
+
}
|
|
873
|
+
/** Authority read from a verified session grant's signed ReCap. */
|
|
874
|
+
interface VerifiedSessionGrant {
|
|
875
|
+
readonly recap: readonly {
|
|
876
|
+
service: string;
|
|
877
|
+
space: string;
|
|
878
|
+
path: string;
|
|
879
|
+
actions: string[];
|
|
880
|
+
caveats?: Record<string, unknown>[];
|
|
881
|
+
}[];
|
|
882
|
+
readonly expiresAt: Date;
|
|
883
|
+
}
|
|
845
884
|
/**
|
|
846
|
-
*
|
|
885
|
+
* Stable reasons {@link activateValidatedRuntimeDelegation} refuses a
|
|
886
|
+
* delegation for. The error message is for the caller and may quote
|
|
887
|
+
* transport fields or a node's response; the reason is safe to publish.
|
|
888
|
+
*/
|
|
889
|
+
declare const RUNTIME_DELEGATION_REJECTIONS: readonly ["host_mismatch", "expired", "cid_mismatch", "authority_invalid", "proof_missing", "proof_invalid", "owner_mismatch", "audience_mismatch", "resources_mismatch", "unsupported", "activation_rejected"];
|
|
890
|
+
type RuntimeDelegationRejection = typeof RUNTIME_DELEGATION_REJECTIONS[number];
|
|
891
|
+
declare class RuntimeDelegationRejectedError extends Error {
|
|
892
|
+
readonly reason: RuntimeDelegationRejection;
|
|
893
|
+
constructor(reason: RuntimeDelegationRejection, message: string);
|
|
894
|
+
}
|
|
895
|
+
/**
|
|
896
|
+
* CID-bind and activate one runtime delegation.
|
|
897
|
+
*
|
|
898
|
+
* A compact UCAN's audience, expiry and permissions come from its signed
|
|
899
|
+
* payload, and its transport fields must agree with them. A CACAO session
|
|
900
|
+
* grant (OpenKey `/delegate`, `grantRuntimePermissions`) is verified from its
|
|
901
|
+
* `siweProof` against this runtime's live session key; its installed
|
|
902
|
+
* authority is exactly the verified ReCap, and its transport `resources` are
|
|
903
|
+
* display data that is never consulted. Either way the helper then invokes
|
|
904
|
+
* {@link TinyCloudNode.useRuntimeDelegation}; the node activation call remains
|
|
905
|
+
* the authority and delegation-chain validation boundary.
|
|
847
906
|
*
|
|
848
|
-
*
|
|
849
|
-
*
|
|
850
|
-
*
|
|
851
|
-
* remains the authority and delegation-chain validation boundary.
|
|
907
|
+
* `options.authorize`, when given, sees the signed capabilities before
|
|
908
|
+
* anything is activated or installed; returning `false` refuses the
|
|
909
|
+
* delegation.
|
|
852
910
|
*/
|
|
853
911
|
declare function activateValidatedRuntimeDelegation(node: RuntimeDelegationActivator, delegation: PortableDelegation, options: {
|
|
854
912
|
host: string;
|
|
913
|
+
authorize?: (effectivePermissions: readonly PermissionEntry[]) => boolean;
|
|
855
914
|
}): Promise<ValidatedRuntimeDelegation>;
|
|
856
915
|
/**
|
|
857
916
|
* Import compact UCAN bytes returned by an authority ceremony through the
|
|
@@ -1966,6 +2025,18 @@ declare class TinyCloudNode {
|
|
|
1966
2025
|
* live authority must combine this with {@link getVerifiedSessionCapabilities}.
|
|
1967
2026
|
*/
|
|
1968
2027
|
getEffectiveRuntimePermissionEntries(): PermissionEntry[];
|
|
2028
|
+
/**
|
|
2029
|
+
* Verify a wallet-signed session grant (a CACAO built from a SIWE and its
|
|
2030
|
+
* EIP-191 signature) issued to this instance's live session key. The
|
|
2031
|
+
* verifier rebuilds the CACAO from `siwe` and `signature`, so the grant is
|
|
2032
|
+
* accepted only when its authorization bytes and CID are exactly that CACAO,
|
|
2033
|
+
* its signer is `address`, its audience is this session key, it is valid
|
|
2034
|
+
* now, and its ReCap covers `spaceId` or names only raw encryption networks
|
|
2035
|
+
* (a decrypt-only grant has no space). Returns the signed ReCap and expiry.
|
|
2036
|
+
* Bindings without `validateSessionGrant` fall back to the session verifier,
|
|
2037
|
+
* which also refuses decrypt-only grants.
|
|
2038
|
+
*/
|
|
2039
|
+
verifySessionGrant(grant: SessionGrantProof): VerifiedSessionGrant;
|
|
1969
2040
|
/**
|
|
1970
2041
|
* Install a portable runtime permission delegation into this SDK instance so
|
|
1971
2042
|
* matching service calls and downstream `delegateTo()` calls can use it.
|
|
@@ -2474,4 +2545,4 @@ declare class WasmKeyProvider implements KeyProvider {
|
|
|
2474
2545
|
*/
|
|
2475
2546
|
declare function createWasmKeyProvider(sessionManager: SessionManagerWithListing): WasmKeyProvider;
|
|
2476
2547
|
|
|
2477
|
-
export { ACCEPTED_MARKER_VERSIONS as A, BOOTSTRAP_COMPLETION_MARKER_KEY as B, type CompactRuntimeDelegationInput as C, type DelegateToOptions as D, type EnsureEncryptionNetworkOptions as E, FileSessionStorage as F,
|
|
2548
|
+
export { ACCEPTED_MARKER_VERSIONS as A, BOOTSTRAP_COMPLETION_MARKER_KEY as B, type CompactRuntimeDelegationInput as C, type DelegateToOptions as D, type EnsureEncryptionNetworkOptions as E, FileSessionStorage as F, activateValidatedRuntimeDelegation as G, createWasmKeyProvider as H, InvalidRestoredSessionError as I, defaultSignStrategy as J, deserializeDelegation as K, grantAuthRequest as L, MemorySessionStorage as M, type NodeEventEmitterStrategy as N, type OwnerDelegationReceipt as O, type PortableDelegation as P, serializeDelegation as Q, RUNTIME_DELEGATION_REJECTIONS as R, type SecretPermissionHint as S, TinyCloudNode as T, type UnifiedOwnerRootInput as U, type ValidatedRuntimeDelegation as V, WasmKeyProvider as W, type AuthDelegationArtifact as a, type AuthRequestArtifact as b, BOOTSTRAP_COMPLETION_MARKER_VERSION as c, type BootstrapCompletionMarker as d, type BootstrapWarning as e, type CreateOwnerDelegationParams as f, type DelegateToResult as g, DelegatedAccess as h, type DelegationAuthority as i, NodeUserAuthorization as j, type NodeUserAuthorizationConfig as k, type RestorableSession as l, type RuntimeDelegationActivator as m, RuntimeDelegationRejectedError as n, type RuntimeDelegationRejection as o, type RuntimePermissionGrantOptions as p, type SecretReadInput as q, type SecretReadResult as r, type SessionGrantProof as s, type SignStrategy as t, type TinyCloudNodeConfig as u, type UnifiedOwnerRootReceipt as v, UnsupportedSessionRestoreError as w, type VerifiedSessionGrant as x, type WasmKeyProviderConfig as y, activateCompactRuntimeDelegation as z };
|