@tinycloud/sdk-core 2.3.0-beta.2 → 2.3.0-beta.3
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/index.cjs +144 -14
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +30 -1
- package/dist/index.d.ts +30 -1
- package/dist/index.js +129 -12
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -798,6 +798,35 @@ interface ISigner {
|
|
|
798
798
|
signMessage(message: Bytes | string): Promise<string>;
|
|
799
799
|
}
|
|
800
800
|
|
|
801
|
+
type CanonicalAddress = `0x${string}`;
|
|
802
|
+
interface PkhDidParts {
|
|
803
|
+
method: "pkh";
|
|
804
|
+
namespace: "eip155";
|
|
805
|
+
chainId: number;
|
|
806
|
+
address: CanonicalAddress;
|
|
807
|
+
}
|
|
808
|
+
interface DidEqualsOptions {
|
|
809
|
+
ignoreFragment?: boolean;
|
|
810
|
+
}
|
|
811
|
+
interface DidCacheKeyOptions {
|
|
812
|
+
preserveFragment?: boolean;
|
|
813
|
+
}
|
|
814
|
+
declare class IdentityParseError extends Error {
|
|
815
|
+
constructor(message: string);
|
|
816
|
+
}
|
|
817
|
+
declare function isEvmAddress(input: string): boolean;
|
|
818
|
+
declare function canonicalizeAddress(address: string): CanonicalAddress;
|
|
819
|
+
declare function addressStorageKey(address: string): CanonicalAddress;
|
|
820
|
+
declare function pkhDid(address: string, chainId?: number): string;
|
|
821
|
+
declare function parsePkhDid(did: string): PkhDidParts | null;
|
|
822
|
+
declare function canonicalizeDid(did: string): string;
|
|
823
|
+
declare function canonicalizeDidUrl(didUrl: string): string;
|
|
824
|
+
declare function principalDid(didUrl: string): string;
|
|
825
|
+
declare function didEquals(a: string, b: string, options?: DidEqualsOptions): boolean;
|
|
826
|
+
declare function principalDidEquals(a: string, b: string): boolean;
|
|
827
|
+
declare function didCacheKey(input: string, options?: DidCacheKeyOptions): string;
|
|
828
|
+
declare function makePkhSpaceId(address: string, chainId: number, name: string): string;
|
|
829
|
+
|
|
801
830
|
/**
|
|
802
831
|
* Zod schemas for session persistence types.
|
|
803
832
|
*
|
|
@@ -4649,4 +4678,4 @@ declare const EXPIRY: {
|
|
|
4649
4678
|
declare const DEFAULT_SIGNED_READ_URL_EXPIRY_MS: number;
|
|
4650
4679
|
type ExpiryTier = keyof typeof EXPIRY;
|
|
4651
4680
|
|
|
4652
|
-
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, AutoApproveSpaceCreationHandler, type AutoRejectStrategy, type AutoSignStrategy, type Bytes, type CallbackStrategy, type CapabilityEntry, CapabilityKeyRegistry, type CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, type ClientSession, ClientSessionSchema, CloudLocationResolutionError, type ComposeManifestOptions, type ComposedManifestRequest, type CreateDelegationFunction, type CreateDelegationParams, type CreateDelegationWasmParams, type CreateDelegationWasmResult, DEFAULT_DEFAULTS, DEFAULT_EXPIRY, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DEFAULT_TINYCLOUD_FALLBACK_HOST, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, type DelegatedResource, type Delegation, type DelegationApiResponse, type DelegationChain, type DelegationChainV2, type DelegationDirection, type DelegationError, type DelegationErrorCode, DelegationErrorCodes, type DelegationFilters, DelegationManager, type DelegationManagerConfig, type DelegationRecord, type Result as DelegationResult, ENCRYPTION_MANIFEST_SPACE, ENCRYPTION_PERMISSION_SERVICE, EXPIRY, type EncodedShareData, type EnsData, EnsDataSchema, type EventEmitterStrategy, type ExpiryTier, type Extension, type GenerateShareParams, type ICapabilityKeyRegistry, type IENSResolver, type INotificationHandler, type ISessionManager, type ISessionStorage, type ISharingService, type ISigner, type ISpace, type ISpaceCreationHandler, type ISpaceScopedDelegations, type ISpaceScopedSharing, type ISpaceService, type IUserAuthorization, type IWasmBindings, type IngestOptions, type JWK, type KeyInfo, type KeyProvider, type KeyType, type LocationCandidate, type LocationCandidateInput, type LocationRecord, type LocationRecordPayload, type LocationRecordSigner, LocationRecordValidationError, type LocationResolutionAttempt, type LocationSource, type Manifest, type ManifestDefaults, type ManifestRegistryRecord, type ManifestSecretActions, ManifestValidationError, type NodeInfo, type ParseRecapFromSiwe, type PartialSiweMessage, type PermissionEntry, PermissionNotInManifestError, type PersistedSessionData, type PersistedTinyCloudSession, ProtocolMismatchError, type ReceiveOptions, type ResolveCloudLocationOptions, type ResolveTinyCloudHostsOptions, type ResolvedCapabilities, type ResolvedCloudLocation, type ResolvedDelegate, type ResolvedTinyCloudHosts, type ResourceCapability, SERVICE_LONG_TO_SHORT, SERVICE_SHORT_TO_LONG, type ServerHost, SessionExpiredError, type ShareAccess, type ShareLink, type ShareLinkData, type ShareSchema, SharingService, type SharingServiceConfig, type SignCallback, type SignInOptions, type SignRequest, type SignResponse, type SignStrategy, SilentNotificationHandler, type SiweConfig, SiweConfigSchema, Space, type SpaceAbilitiesMap, type SpaceConfig, type SpaceCreationContext, type SpaceDelegationParams, type SpaceErrorCode, SpaceErrorCodes, type SpaceHostResult, type SpaceInfo, type SpaceOwnership, SpaceService, type SpaceServiceConfig, type StoredDelegationChain, type SubsetCheckResult, TinyCloud, type TinyCloudConfig, type TinyCloudSession, UnsupportedFeatureError, type UserAuthorizationConfig, VAULT_PERMISSION_SERVICE, type ValidationError, VersionCheckError, type WasmRecapEntry, activateSessionWithHost, applyPrefix, buildSpaceUri, canonicalLocationPayload, checkNodeInfo, composeManifestRequest, createCapabilityKeyRegistry, createSharingService, createSpaceService, defaultSignStrategy, defaultSpaceCreationHandler, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, fetchLocationRecord, fetchPeerId, httpUrlToMultiaddr, isCapabilitySubset, loadManifest, locationPayloadForRecord, makePublicSpaceId, manifestAbilitiesUnion, multiaddrToHttpUrl, normalizeDefaults, parseExpiry, parseRecapCapabilities, parseSpaceUri, resolveCloudLocation, resolveManifest, resolveTinyCloudHosts, resourceCapabilitiesToAbilitiesMap, resourceCapabilitiesToSpaceAbilitiesMap, signLocationRecord, submitHostDelegation, validateClientSession, validateLocationRecord, validateLocationRecordPayload, validateManifest, validatePersistedSessionData, verifyDidKeyEd25519Signature, verifyLocationRecord };
|
|
4681
|
+
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, AutoApproveSpaceCreationHandler, type AutoRejectStrategy, type AutoSignStrategy, type Bytes, type CallbackStrategy, type CanonicalAddress, type CapabilityEntry, CapabilityKeyRegistry, type CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, type ClientSession, ClientSessionSchema, CloudLocationResolutionError, type ComposeManifestOptions, type ComposedManifestRequest, type CreateDelegationFunction, type CreateDelegationParams, type CreateDelegationWasmParams, type CreateDelegationWasmResult, DEFAULT_DEFAULTS, DEFAULT_EXPIRY, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DEFAULT_TINYCLOUD_FALLBACK_HOST, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, type DelegatedResource, type Delegation, type DelegationApiResponse, type DelegationChain, type DelegationChainV2, type DelegationDirection, type DelegationError, type DelegationErrorCode, DelegationErrorCodes, type DelegationFilters, DelegationManager, type DelegationManagerConfig, type DelegationRecord, type Result as DelegationResult, type DidCacheKeyOptions, type DidEqualsOptions, ENCRYPTION_MANIFEST_SPACE, ENCRYPTION_PERMISSION_SERVICE, EXPIRY, type EncodedShareData, type EnsData, EnsDataSchema, type EventEmitterStrategy, type ExpiryTier, type Extension, type GenerateShareParams, type ICapabilityKeyRegistry, type IENSResolver, type INotificationHandler, type ISessionManager, type ISessionStorage, type ISharingService, type ISigner, type ISpace, type ISpaceCreationHandler, type ISpaceScopedDelegations, type ISpaceScopedSharing, type ISpaceService, type IUserAuthorization, type IWasmBindings, IdentityParseError, type IngestOptions, type JWK, type KeyInfo, type KeyProvider, type KeyType, type LocationCandidate, type LocationCandidateInput, type LocationRecord, type LocationRecordPayload, type LocationRecordSigner, LocationRecordValidationError, type LocationResolutionAttempt, type LocationSource, type Manifest, type ManifestDefaults, type ManifestRegistryRecord, type ManifestSecretActions, ManifestValidationError, type NodeInfo, type ParseRecapFromSiwe, type PartialSiweMessage, type PermissionEntry, PermissionNotInManifestError, type PersistedSessionData, type PersistedTinyCloudSession, type PkhDidParts, ProtocolMismatchError, type ReceiveOptions, type ResolveCloudLocationOptions, type ResolveTinyCloudHostsOptions, type ResolvedCapabilities, type ResolvedCloudLocation, type ResolvedDelegate, type ResolvedTinyCloudHosts, type ResourceCapability, SERVICE_LONG_TO_SHORT, SERVICE_SHORT_TO_LONG, type ServerHost, SessionExpiredError, type ShareAccess, type ShareLink, type ShareLinkData, type ShareSchema, SharingService, type SharingServiceConfig, type SignCallback, type SignInOptions, type SignRequest, type SignResponse, type SignStrategy, SilentNotificationHandler, type SiweConfig, SiweConfigSchema, Space, type SpaceAbilitiesMap, type SpaceConfig, type SpaceCreationContext, type SpaceDelegationParams, type SpaceErrorCode, SpaceErrorCodes, type SpaceHostResult, type SpaceInfo, type SpaceOwnership, SpaceService, type SpaceServiceConfig, type StoredDelegationChain, type SubsetCheckResult, TinyCloud, type TinyCloudConfig, type TinyCloudSession, UnsupportedFeatureError, type UserAuthorizationConfig, VAULT_PERMISSION_SERVICE, type ValidationError, VersionCheckError, type WasmRecapEntry, activateSessionWithHost, addressStorageKey, applyPrefix, buildSpaceUri, canonicalLocationPayload, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, checkNodeInfo, composeManifestRequest, createCapabilityKeyRegistry, createSharingService, createSpaceService, defaultSignStrategy, defaultSpaceCreationHandler, didCacheKey, didEquals, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, fetchLocationRecord, fetchPeerId, httpUrlToMultiaddr, isCapabilitySubset, isEvmAddress, loadManifest, locationPayloadForRecord, makePkhSpaceId, makePublicSpaceId, manifestAbilitiesUnion, multiaddrToHttpUrl, normalizeDefaults, parseExpiry, parsePkhDid, parseRecapCapabilities, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveCloudLocation, resolveManifest, resolveTinyCloudHosts, resourceCapabilitiesToAbilitiesMap, resourceCapabilitiesToSpaceAbilitiesMap, signLocationRecord, submitHostDelegation, validateClientSession, validateLocationRecord, validateLocationRecordPayload, validateManifest, validatePersistedSessionData, verifyDidKeyEd25519Signature, verifyLocationRecord };
|
package/dist/index.d.ts
CHANGED
|
@@ -798,6 +798,35 @@ interface ISigner {
|
|
|
798
798
|
signMessage(message: Bytes | string): Promise<string>;
|
|
799
799
|
}
|
|
800
800
|
|
|
801
|
+
type CanonicalAddress = `0x${string}`;
|
|
802
|
+
interface PkhDidParts {
|
|
803
|
+
method: "pkh";
|
|
804
|
+
namespace: "eip155";
|
|
805
|
+
chainId: number;
|
|
806
|
+
address: CanonicalAddress;
|
|
807
|
+
}
|
|
808
|
+
interface DidEqualsOptions {
|
|
809
|
+
ignoreFragment?: boolean;
|
|
810
|
+
}
|
|
811
|
+
interface DidCacheKeyOptions {
|
|
812
|
+
preserveFragment?: boolean;
|
|
813
|
+
}
|
|
814
|
+
declare class IdentityParseError extends Error {
|
|
815
|
+
constructor(message: string);
|
|
816
|
+
}
|
|
817
|
+
declare function isEvmAddress(input: string): boolean;
|
|
818
|
+
declare function canonicalizeAddress(address: string): CanonicalAddress;
|
|
819
|
+
declare function addressStorageKey(address: string): CanonicalAddress;
|
|
820
|
+
declare function pkhDid(address: string, chainId?: number): string;
|
|
821
|
+
declare function parsePkhDid(did: string): PkhDidParts | null;
|
|
822
|
+
declare function canonicalizeDid(did: string): string;
|
|
823
|
+
declare function canonicalizeDidUrl(didUrl: string): string;
|
|
824
|
+
declare function principalDid(didUrl: string): string;
|
|
825
|
+
declare function didEquals(a: string, b: string, options?: DidEqualsOptions): boolean;
|
|
826
|
+
declare function principalDidEquals(a: string, b: string): boolean;
|
|
827
|
+
declare function didCacheKey(input: string, options?: DidCacheKeyOptions): string;
|
|
828
|
+
declare function makePkhSpaceId(address: string, chainId: number, name: string): string;
|
|
829
|
+
|
|
801
830
|
/**
|
|
802
831
|
* Zod schemas for session persistence types.
|
|
803
832
|
*
|
|
@@ -4649,4 +4678,4 @@ declare const EXPIRY: {
|
|
|
4649
4678
|
declare const DEFAULT_SIGNED_READ_URL_EXPIRY_MS: number;
|
|
4650
4679
|
type ExpiryTier = keyof typeof EXPIRY;
|
|
4651
4680
|
|
|
4652
|
-
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, AutoApproveSpaceCreationHandler, type AutoRejectStrategy, type AutoSignStrategy, type Bytes, type CallbackStrategy, type CapabilityEntry, CapabilityKeyRegistry, type CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, type ClientSession, ClientSessionSchema, CloudLocationResolutionError, type ComposeManifestOptions, type ComposedManifestRequest, type CreateDelegationFunction, type CreateDelegationParams, type CreateDelegationWasmParams, type CreateDelegationWasmResult, DEFAULT_DEFAULTS, DEFAULT_EXPIRY, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DEFAULT_TINYCLOUD_FALLBACK_HOST, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, type DelegatedResource, type Delegation, type DelegationApiResponse, type DelegationChain, type DelegationChainV2, type DelegationDirection, type DelegationError, type DelegationErrorCode, DelegationErrorCodes, type DelegationFilters, DelegationManager, type DelegationManagerConfig, type DelegationRecord, type Result as DelegationResult, ENCRYPTION_MANIFEST_SPACE, ENCRYPTION_PERMISSION_SERVICE, EXPIRY, type EncodedShareData, type EnsData, EnsDataSchema, type EventEmitterStrategy, type ExpiryTier, type Extension, type GenerateShareParams, type ICapabilityKeyRegistry, type IENSResolver, type INotificationHandler, type ISessionManager, type ISessionStorage, type ISharingService, type ISigner, type ISpace, type ISpaceCreationHandler, type ISpaceScopedDelegations, type ISpaceScopedSharing, type ISpaceService, type IUserAuthorization, type IWasmBindings, type IngestOptions, type JWK, type KeyInfo, type KeyProvider, type KeyType, type LocationCandidate, type LocationCandidateInput, type LocationRecord, type LocationRecordPayload, type LocationRecordSigner, LocationRecordValidationError, type LocationResolutionAttempt, type LocationSource, type Manifest, type ManifestDefaults, type ManifestRegistryRecord, type ManifestSecretActions, ManifestValidationError, type NodeInfo, type ParseRecapFromSiwe, type PartialSiweMessage, type PermissionEntry, PermissionNotInManifestError, type PersistedSessionData, type PersistedTinyCloudSession, ProtocolMismatchError, type ReceiveOptions, type ResolveCloudLocationOptions, type ResolveTinyCloudHostsOptions, type ResolvedCapabilities, type ResolvedCloudLocation, type ResolvedDelegate, type ResolvedTinyCloudHosts, type ResourceCapability, SERVICE_LONG_TO_SHORT, SERVICE_SHORT_TO_LONG, type ServerHost, SessionExpiredError, type ShareAccess, type ShareLink, type ShareLinkData, type ShareSchema, SharingService, type SharingServiceConfig, type SignCallback, type SignInOptions, type SignRequest, type SignResponse, type SignStrategy, SilentNotificationHandler, type SiweConfig, SiweConfigSchema, Space, type SpaceAbilitiesMap, type SpaceConfig, type SpaceCreationContext, type SpaceDelegationParams, type SpaceErrorCode, SpaceErrorCodes, type SpaceHostResult, type SpaceInfo, type SpaceOwnership, SpaceService, type SpaceServiceConfig, type StoredDelegationChain, type SubsetCheckResult, TinyCloud, type TinyCloudConfig, type TinyCloudSession, UnsupportedFeatureError, type UserAuthorizationConfig, VAULT_PERMISSION_SERVICE, type ValidationError, VersionCheckError, type WasmRecapEntry, activateSessionWithHost, applyPrefix, buildSpaceUri, canonicalLocationPayload, checkNodeInfo, composeManifestRequest, createCapabilityKeyRegistry, createSharingService, createSpaceService, defaultSignStrategy, defaultSpaceCreationHandler, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, fetchLocationRecord, fetchPeerId, httpUrlToMultiaddr, isCapabilitySubset, loadManifest, locationPayloadForRecord, makePublicSpaceId, manifestAbilitiesUnion, multiaddrToHttpUrl, normalizeDefaults, parseExpiry, parseRecapCapabilities, parseSpaceUri, resolveCloudLocation, resolveManifest, resolveTinyCloudHosts, resourceCapabilitiesToAbilitiesMap, resourceCapabilitiesToSpaceAbilitiesMap, signLocationRecord, submitHostDelegation, validateClientSession, validateLocationRecord, validateLocationRecordPayload, validateManifest, validatePersistedSessionData, verifyDidKeyEd25519Signature, verifyLocationRecord };
|
|
4681
|
+
export { ACCOUNT_REGISTRY_PATH, ACCOUNT_REGISTRY_SPACE, type AbilitiesMap, AutoApproveSpaceCreationHandler, type AutoRejectStrategy, type AutoSignStrategy, type Bytes, type CallbackStrategy, type CanonicalAddress, type CapabilityEntry, CapabilityKeyRegistry, type CapabilityKeyRegistryErrorCode, CapabilityKeyRegistryErrorCodes, type ClientSession, ClientSessionSchema, CloudLocationResolutionError, type ComposeManifestOptions, type ComposedManifestRequest, type CreateDelegationFunction, type CreateDelegationParams, type CreateDelegationWasmParams, type CreateDelegationWasmResult, DEFAULT_DEFAULTS, DEFAULT_EXPIRY, DEFAULT_MANIFEST_SPACE, DEFAULT_MANIFEST_VERSION, DEFAULT_SIGNED_READ_URL_EXPIRY_MS, DEFAULT_TINYCLOUD_FALLBACK_HOST, DEFAULT_TINYCLOUD_LOCATION_REGISTRY_URL, type DelegatedResource, type Delegation, type DelegationApiResponse, type DelegationChain, type DelegationChainV2, type DelegationDirection, type DelegationError, type DelegationErrorCode, DelegationErrorCodes, type DelegationFilters, DelegationManager, type DelegationManagerConfig, type DelegationRecord, type Result as DelegationResult, type DidCacheKeyOptions, type DidEqualsOptions, ENCRYPTION_MANIFEST_SPACE, ENCRYPTION_PERMISSION_SERVICE, EXPIRY, type EncodedShareData, type EnsData, EnsDataSchema, type EventEmitterStrategy, type ExpiryTier, type Extension, type GenerateShareParams, type ICapabilityKeyRegistry, type IENSResolver, type INotificationHandler, type ISessionManager, type ISessionStorage, type ISharingService, type ISigner, type ISpace, type ISpaceCreationHandler, type ISpaceScopedDelegations, type ISpaceScopedSharing, type ISpaceService, type IUserAuthorization, type IWasmBindings, IdentityParseError, type IngestOptions, type JWK, type KeyInfo, type KeyProvider, type KeyType, type LocationCandidate, type LocationCandidateInput, type LocationRecord, type LocationRecordPayload, type LocationRecordSigner, LocationRecordValidationError, type LocationResolutionAttempt, type LocationSource, type Manifest, type ManifestDefaults, type ManifestRegistryRecord, type ManifestSecretActions, ManifestValidationError, type NodeInfo, type ParseRecapFromSiwe, type PartialSiweMessage, type PermissionEntry, PermissionNotInManifestError, type PersistedSessionData, type PersistedTinyCloudSession, type PkhDidParts, ProtocolMismatchError, type ReceiveOptions, type ResolveCloudLocationOptions, type ResolveTinyCloudHostsOptions, type ResolvedCapabilities, type ResolvedCloudLocation, type ResolvedDelegate, type ResolvedTinyCloudHosts, type ResourceCapability, SERVICE_LONG_TO_SHORT, SERVICE_SHORT_TO_LONG, type ServerHost, SessionExpiredError, type ShareAccess, type ShareLink, type ShareLinkData, type ShareSchema, SharingService, type SharingServiceConfig, type SignCallback, type SignInOptions, type SignRequest, type SignResponse, type SignStrategy, SilentNotificationHandler, type SiweConfig, SiweConfigSchema, Space, type SpaceAbilitiesMap, type SpaceConfig, type SpaceCreationContext, type SpaceDelegationParams, type SpaceErrorCode, SpaceErrorCodes, type SpaceHostResult, type SpaceInfo, type SpaceOwnership, SpaceService, type SpaceServiceConfig, type StoredDelegationChain, type SubsetCheckResult, TinyCloud, type TinyCloudConfig, type TinyCloudSession, UnsupportedFeatureError, type UserAuthorizationConfig, VAULT_PERMISSION_SERVICE, type ValidationError, VersionCheckError, type WasmRecapEntry, activateSessionWithHost, addressStorageKey, applyPrefix, buildSpaceUri, canonicalLocationPayload, canonicalizeAddress, canonicalizeDid, canonicalizeDidUrl, checkNodeInfo, composeManifestRequest, createCapabilityKeyRegistry, createSharingService, createSpaceService, defaultSignStrategy, defaultSpaceCreationHandler, didCacheKey, didEquals, expandActionShortNames, expandPermissionEntries, expandPermissionEntry, fetchLocationRecord, fetchPeerId, httpUrlToMultiaddr, isCapabilitySubset, isEvmAddress, loadManifest, locationPayloadForRecord, makePkhSpaceId, makePublicSpaceId, manifestAbilitiesUnion, multiaddrToHttpUrl, normalizeDefaults, parseExpiry, parsePkhDid, parseRecapCapabilities, parseSpaceUri, pkhDid, principalDid, principalDidEquals, resolveCloudLocation, resolveManifest, resolveTinyCloudHosts, resourceCapabilitiesToAbilitiesMap, resourceCapabilitiesToSpaceAbilitiesMap, signLocationRecord, submitHostDelegation, validateClientSession, validateLocationRecord, validateLocationRecordPayload, validateManifest, validatePersistedSessionData, verifyDidKeyEd25519Signature, verifyLocationRecord };
|
package/dist/index.js
CHANGED
|
@@ -40,6 +40,97 @@ var SilentNotificationHandler = class {
|
|
|
40
40
|
}
|
|
41
41
|
};
|
|
42
42
|
|
|
43
|
+
// src/identity.ts
|
|
44
|
+
import { getAddress, isAddress } from "viem";
|
|
45
|
+
var IdentityParseError = class extends Error {
|
|
46
|
+
constructor(message) {
|
|
47
|
+
super(message);
|
|
48
|
+
this.name = "IdentityParseError";
|
|
49
|
+
}
|
|
50
|
+
};
|
|
51
|
+
var PKH_DID_RE = /^did:pkh:eip155:(\d+):(0x[a-fA-F0-9]{40})$/;
|
|
52
|
+
var DID_RE = /^did:[a-z0-9]+:.+$/;
|
|
53
|
+
function splitDidUrl(input) {
|
|
54
|
+
const fragmentIndex = input.indexOf("#");
|
|
55
|
+
if (fragmentIndex < 0) {
|
|
56
|
+
return { did: input, fragment: "" };
|
|
57
|
+
}
|
|
58
|
+
return {
|
|
59
|
+
did: input.slice(0, fragmentIndex),
|
|
60
|
+
fragment: input.slice(fragmentIndex)
|
|
61
|
+
};
|
|
62
|
+
}
|
|
63
|
+
function assertValidChainId(chainId) {
|
|
64
|
+
if (!Number.isSafeInteger(chainId) || chainId <= 0) {
|
|
65
|
+
throw new IdentityParseError(`Invalid EIP-155 chain ID: ${chainId}`);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
function isEvmAddress(input) {
|
|
69
|
+
return isAddress(input, { strict: false });
|
|
70
|
+
}
|
|
71
|
+
function canonicalizeAddress(address) {
|
|
72
|
+
if (!isEvmAddress(address)) {
|
|
73
|
+
throw new IdentityParseError(`Invalid EVM address: ${address}`);
|
|
74
|
+
}
|
|
75
|
+
return getAddress(address);
|
|
76
|
+
}
|
|
77
|
+
function addressStorageKey(address) {
|
|
78
|
+
return canonicalizeAddress(address).toLowerCase();
|
|
79
|
+
}
|
|
80
|
+
function pkhDid(address, chainId = 1) {
|
|
81
|
+
assertValidChainId(chainId);
|
|
82
|
+
return `did:pkh:eip155:${chainId}:${canonicalizeAddress(address)}`;
|
|
83
|
+
}
|
|
84
|
+
function parsePkhDid(did) {
|
|
85
|
+
const match = did.match(PKH_DID_RE);
|
|
86
|
+
if (!match) return null;
|
|
87
|
+
const chainId = Number(match[1]);
|
|
88
|
+
assertValidChainId(chainId);
|
|
89
|
+
return {
|
|
90
|
+
method: "pkh",
|
|
91
|
+
namespace: "eip155",
|
|
92
|
+
chainId,
|
|
93
|
+
address: canonicalizeAddress(match[2])
|
|
94
|
+
};
|
|
95
|
+
}
|
|
96
|
+
function canonicalizeDid(did) {
|
|
97
|
+
const pkh = parsePkhDid(did);
|
|
98
|
+
if (pkh) {
|
|
99
|
+
return pkhDid(pkh.address, pkh.chainId);
|
|
100
|
+
}
|
|
101
|
+
if (DID_RE.test(did)) {
|
|
102
|
+
return did;
|
|
103
|
+
}
|
|
104
|
+
throw new IdentityParseError(`Invalid DID: ${did}`);
|
|
105
|
+
}
|
|
106
|
+
function canonicalizeDidUrl(didUrl) {
|
|
107
|
+
const { did, fragment } = splitDidUrl(didUrl);
|
|
108
|
+
return `${canonicalizeDid(did)}${fragment}`;
|
|
109
|
+
}
|
|
110
|
+
function principalDid(didUrl) {
|
|
111
|
+
return canonicalizeDid(splitDidUrl(didUrl).did);
|
|
112
|
+
}
|
|
113
|
+
function didEquals(a, b, options = {}) {
|
|
114
|
+
const canonicalize = options.ignoreFragment ? principalDid : canonicalizeDidUrl;
|
|
115
|
+
return canonicalize(a) === canonicalize(b);
|
|
116
|
+
}
|
|
117
|
+
function principalDidEquals(a, b) {
|
|
118
|
+
return didEquals(a, b, { ignoreFragment: true });
|
|
119
|
+
}
|
|
120
|
+
function didCacheKey(input, options = {}) {
|
|
121
|
+
const { did, fragment } = splitDidUrl(input);
|
|
122
|
+
const pkh = parsePkhDid(did);
|
|
123
|
+
const base = pkh ? `did:pkh:eip155:${pkh.chainId}:${addressStorageKey(pkh.address)}` : canonicalizeDid(did);
|
|
124
|
+
return options.preserveFragment ? `${base}${fragment}` : base;
|
|
125
|
+
}
|
|
126
|
+
function makePkhSpaceId(address, chainId, name) {
|
|
127
|
+
assertValidChainId(chainId);
|
|
128
|
+
if (!name) {
|
|
129
|
+
throw new IdentityParseError("Space name cannot be empty");
|
|
130
|
+
}
|
|
131
|
+
return `tinycloud:pkh:eip155:${chainId}:${canonicalizeAddress(address)}:${name}`;
|
|
132
|
+
}
|
|
133
|
+
|
|
43
134
|
// src/storage.schema.ts
|
|
44
135
|
import { z as z2 } from "zod";
|
|
45
136
|
var ethereumAddressPattern = /^0x[a-fA-F0-9]{40}$/;
|
|
@@ -747,6 +838,14 @@ var DEFAULT_SIGNED_READ_URL_EXPIRY_MS = EXPIRY.SIGNED_READ_URL_MS;
|
|
|
747
838
|
|
|
748
839
|
// src/spaces/SpaceService.ts
|
|
749
840
|
var SERVICE_NAME = "space";
|
|
841
|
+
function ownerDidEquals(a, b) {
|
|
842
|
+
if (!b) return false;
|
|
843
|
+
try {
|
|
844
|
+
return principalDidEquals(a, b);
|
|
845
|
+
} catch {
|
|
846
|
+
return a === b;
|
|
847
|
+
}
|
|
848
|
+
}
|
|
750
849
|
var SpaceErrorCodes = {
|
|
751
850
|
/** Space not found */
|
|
752
851
|
NOT_FOUND: "SPACE_NOT_FOUND",
|
|
@@ -764,7 +863,7 @@ var SpaceErrorCodes = {
|
|
|
764
863
|
NOT_INITIALIZED: "NOT_INITIALIZED"
|
|
765
864
|
};
|
|
766
865
|
function makePublicSpaceId(address, chainId) {
|
|
767
|
-
return
|
|
866
|
+
return makePkhSpaceId(address, chainId, "public");
|
|
768
867
|
}
|
|
769
868
|
function parseSpaceUri(uri) {
|
|
770
869
|
const fullUriMatch = uri.match(
|
|
@@ -772,12 +871,18 @@ function parseSpaceUri(uri) {
|
|
|
772
871
|
);
|
|
773
872
|
if (fullUriMatch) {
|
|
774
873
|
const [, chainId, address, name] = fullUriMatch;
|
|
775
|
-
|
|
776
|
-
|
|
777
|
-
|
|
778
|
-
|
|
779
|
-
|
|
780
|
-
|
|
874
|
+
try {
|
|
875
|
+
const chainIdNumber = Number(chainId);
|
|
876
|
+
const canonicalAddress = canonicalizeAddress(address);
|
|
877
|
+
return {
|
|
878
|
+
owner: pkhDid(canonicalAddress, chainIdNumber),
|
|
879
|
+
name,
|
|
880
|
+
chainId: String(chainIdNumber),
|
|
881
|
+
address: canonicalAddress
|
|
882
|
+
};
|
|
883
|
+
} catch {
|
|
884
|
+
return null;
|
|
885
|
+
}
|
|
781
886
|
}
|
|
782
887
|
if (/^[a-zA-Z0-9_-]+$/.test(uri)) {
|
|
783
888
|
return {
|
|
@@ -789,10 +894,9 @@ function parseSpaceUri(uri) {
|
|
|
789
894
|
return null;
|
|
790
895
|
}
|
|
791
896
|
function buildSpaceUri(owner, name) {
|
|
792
|
-
const
|
|
793
|
-
if (
|
|
794
|
-
|
|
795
|
-
return `tinycloud:pkh:eip155:${chainId}:${address}:${name}`;
|
|
897
|
+
const pkh = parsePkhDid(owner);
|
|
898
|
+
if (pkh) {
|
|
899
|
+
return makePkhSpaceId(pkh.address, pkh.chainId, name);
|
|
796
900
|
}
|
|
797
901
|
return `tinycloud:${owner}:${name}`;
|
|
798
902
|
}
|
|
@@ -1241,7 +1345,7 @@ var SpaceService = class {
|
|
|
1241
1345
|
id: data.id,
|
|
1242
1346
|
name: data.name ?? this.extractNameFromId(data.id),
|
|
1243
1347
|
owner: data.owner,
|
|
1244
|
-
type: data.type ?? (data.owner
|
|
1348
|
+
type: data.type ?? (ownerDidEquals(data.owner, this.userDid) ? "owned" : "delegated"),
|
|
1245
1349
|
permissions: data.permissions,
|
|
1246
1350
|
expiresAt: data.expiresAt ? new Date(data.expiresAt) : void 0
|
|
1247
1351
|
};
|
|
@@ -5199,6 +5303,7 @@ export {
|
|
|
5199
5303
|
EnsDataSchema,
|
|
5200
5304
|
ErrorCodes2 as ErrorCodes,
|
|
5201
5305
|
HooksService2 as HooksService,
|
|
5306
|
+
IdentityParseError,
|
|
5202
5307
|
KVService2 as KVService,
|
|
5203
5308
|
LocationRecordValidationError,
|
|
5204
5309
|
ManifestValidationError,
|
|
@@ -5229,6 +5334,7 @@ export {
|
|
|
5229
5334
|
VaultPublicSpaceKVActions,
|
|
5230
5335
|
VersionCheckError,
|
|
5231
5336
|
activateSessionWithHost,
|
|
5337
|
+
addressStorageKey,
|
|
5232
5338
|
applyPrefix,
|
|
5233
5339
|
buildCanonicalDecryptRequest,
|
|
5234
5340
|
buildDecryptAttenuation,
|
|
@@ -5239,6 +5345,9 @@ export {
|
|
|
5239
5345
|
canonicalHashHex,
|
|
5240
5346
|
canonicalLocationPayload,
|
|
5241
5347
|
canonicalSignedResponse,
|
|
5348
|
+
canonicalizeAddress,
|
|
5349
|
+
canonicalizeDid,
|
|
5350
|
+
canonicalizeDidUrl,
|
|
5242
5351
|
canonicalizeEncryptionJson,
|
|
5243
5352
|
canonicalizeSecretScope,
|
|
5244
5353
|
checkDecryptInvocationInput,
|
|
@@ -5253,6 +5362,8 @@ export {
|
|
|
5253
5362
|
defaultSignStrategy,
|
|
5254
5363
|
defaultSpaceCreationHandler,
|
|
5255
5364
|
deriveSignedReceiverKey,
|
|
5365
|
+
didCacheKey,
|
|
5366
|
+
didEquals,
|
|
5256
5367
|
discoverNetwork,
|
|
5257
5368
|
encryptToNetwork,
|
|
5258
5369
|
base64Decode as encryptionBase64Decode,
|
|
@@ -5272,9 +5383,11 @@ export {
|
|
|
5272
5383
|
hexEncode,
|
|
5273
5384
|
httpUrlToMultiaddr,
|
|
5274
5385
|
isCapabilitySubset,
|
|
5386
|
+
isEvmAddress,
|
|
5275
5387
|
isNetworkId,
|
|
5276
5388
|
loadManifest,
|
|
5277
5389
|
locationPayloadForRecord,
|
|
5390
|
+
makePkhSpaceId,
|
|
5278
5391
|
makePublicSpaceId,
|
|
5279
5392
|
manifestAbilitiesUnion,
|
|
5280
5393
|
multiaddrToHttpUrl,
|
|
@@ -5284,8 +5397,12 @@ export {
|
|
|
5284
5397
|
openWrappedKey,
|
|
5285
5398
|
parseExpiry,
|
|
5286
5399
|
parseNetworkId,
|
|
5400
|
+
parsePkhDid,
|
|
5287
5401
|
parseRecapCapabilities,
|
|
5288
5402
|
parseSpaceUri,
|
|
5403
|
+
pkhDid,
|
|
5404
|
+
principalDid,
|
|
5405
|
+
principalDidEquals,
|
|
5289
5406
|
resolveCloudLocation,
|
|
5290
5407
|
resolveManifest,
|
|
5291
5408
|
resolveSecretListPrefix,
|