@tinycloud/sdk-core 2.2.0-beta.10 → 2.2.0-beta.11
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 +19 -3
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +34 -2
- package/dist/index.d.ts +34 -2
- package/dist/index.js +18 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.d.cts
CHANGED
|
@@ -384,7 +384,12 @@ declare class ManifestValidationError extends Error {
|
|
|
384
384
|
}
|
|
385
385
|
/**
|
|
386
386
|
* Default expiry when neither the manifest, delegation, nor permission
|
|
387
|
-
* specifies one. Spec: 30 days.
|
|
387
|
+
* specifies one. APP tier — see `expiry.ts`. Spec: 30 days.
|
|
388
|
+
*
|
|
389
|
+
* Kept as an ms-format string because the manifest schema stores expiry
|
|
390
|
+
* as a string and the parser is shared between this default and
|
|
391
|
+
* caller-provided values; converting `EXPIRY.APP_MS` back to a string
|
|
392
|
+
* here would duplicate that same `30d` literal in another form.
|
|
388
393
|
*/
|
|
389
394
|
declare const DEFAULT_EXPIRY = "30d";
|
|
390
395
|
/**
|
|
@@ -4589,4 +4594,31 @@ declare function resolveTinyCloudHosts(subject: string, options?: ResolveTinyClo
|
|
|
4589
4594
|
declare function multiaddrToHttpUrl(input: string): string;
|
|
4590
4595
|
declare function httpUrlToMultiaddr(input: string): string;
|
|
4591
4596
|
|
|
4592
|
-
|
|
4597
|
+
/**
|
|
4598
|
+
* Default lifetimes for the various delegation shapes the SDK mints.
|
|
4599
|
+
*
|
|
4600
|
+
* The SDK has many delegation flows (session sign-in, runtime grants,
|
|
4601
|
+
* share links, manifest installs, public-space sub-delegations, …) and
|
|
4602
|
+
* each one used to pick its own number freehand. That made it hard to
|
|
4603
|
+
* tell whether a chosen value was deliberate or copy-pasted, and made
|
|
4604
|
+
* silent inconsistencies easy to ship.
|
|
4605
|
+
*
|
|
4606
|
+
* Every default below answers two questions:
|
|
4607
|
+
* - Who recovers if the delegation leaks? (re-auth, revocation, no one)
|
|
4608
|
+
* - Who is the principal at use time? (issuer, third party)
|
|
4609
|
+
*
|
|
4610
|
+
* The five tiers fall out of those answers. Pick a tier, not a number,
|
|
4611
|
+
* when introducing a new delegation surface.
|
|
4612
|
+
*
|
|
4613
|
+
* @packageDocumentation
|
|
4614
|
+
*/
|
|
4615
|
+
declare const EXPIRY: {
|
|
4616
|
+
readonly EPHEMERAL_MS: number;
|
|
4617
|
+
readonly SESSION_MS: number;
|
|
4618
|
+
readonly SHARE_MS: number;
|
|
4619
|
+
readonly APP_MS: number;
|
|
4620
|
+
readonly MAX_MS: number;
|
|
4621
|
+
};
|
|
4622
|
+
type ExpiryTier = keyof typeof EXPIRY;
|
|
4623
|
+
|
|
4624
|
+
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_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, 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, verifyLocationRecord };
|
package/dist/index.d.ts
CHANGED
|
@@ -384,7 +384,12 @@ declare class ManifestValidationError extends Error {
|
|
|
384
384
|
}
|
|
385
385
|
/**
|
|
386
386
|
* Default expiry when neither the manifest, delegation, nor permission
|
|
387
|
-
* specifies one. Spec: 30 days.
|
|
387
|
+
* specifies one. APP tier — see `expiry.ts`. Spec: 30 days.
|
|
388
|
+
*
|
|
389
|
+
* Kept as an ms-format string because the manifest schema stores expiry
|
|
390
|
+
* as a string and the parser is shared between this default and
|
|
391
|
+
* caller-provided values; converting `EXPIRY.APP_MS` back to a string
|
|
392
|
+
* here would duplicate that same `30d` literal in another form.
|
|
388
393
|
*/
|
|
389
394
|
declare const DEFAULT_EXPIRY = "30d";
|
|
390
395
|
/**
|
|
@@ -4589,4 +4594,31 @@ declare function resolveTinyCloudHosts(subject: string, options?: ResolveTinyClo
|
|
|
4589
4594
|
declare function multiaddrToHttpUrl(input: string): string;
|
|
4590
4595
|
declare function httpUrlToMultiaddr(input: string): string;
|
|
4591
4596
|
|
|
4592
|
-
|
|
4597
|
+
/**
|
|
4598
|
+
* Default lifetimes for the various delegation shapes the SDK mints.
|
|
4599
|
+
*
|
|
4600
|
+
* The SDK has many delegation flows (session sign-in, runtime grants,
|
|
4601
|
+
* share links, manifest installs, public-space sub-delegations, …) and
|
|
4602
|
+
* each one used to pick its own number freehand. That made it hard to
|
|
4603
|
+
* tell whether a chosen value was deliberate or copy-pasted, and made
|
|
4604
|
+
* silent inconsistencies easy to ship.
|
|
4605
|
+
*
|
|
4606
|
+
* Every default below answers two questions:
|
|
4607
|
+
* - Who recovers if the delegation leaks? (re-auth, revocation, no one)
|
|
4608
|
+
* - Who is the principal at use time? (issuer, third party)
|
|
4609
|
+
*
|
|
4610
|
+
* The five tiers fall out of those answers. Pick a tier, not a number,
|
|
4611
|
+
* when introducing a new delegation surface.
|
|
4612
|
+
*
|
|
4613
|
+
* @packageDocumentation
|
|
4614
|
+
*/
|
|
4615
|
+
declare const EXPIRY: {
|
|
4616
|
+
readonly EPHEMERAL_MS: number;
|
|
4617
|
+
readonly SESSION_MS: number;
|
|
4618
|
+
readonly SHARE_MS: number;
|
|
4619
|
+
readonly APP_MS: number;
|
|
4620
|
+
readonly MAX_MS: number;
|
|
4621
|
+
};
|
|
4622
|
+
type ExpiryTier = keyof typeof EXPIRY;
|
|
4623
|
+
|
|
4624
|
+
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_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, 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, verifyLocationRecord };
|
package/dist/index.js
CHANGED
|
@@ -728,6 +728,20 @@ function validateServerSpaceInfoResponse(data) {
|
|
|
728
728
|
return { ok: true, data: result.data };
|
|
729
729
|
}
|
|
730
730
|
|
|
731
|
+
// src/expiry.ts
|
|
732
|
+
var EPHEMERAL_MS = 60 * 60 * 1e3;
|
|
733
|
+
var SESSION_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
734
|
+
var SHARE_MS = 7 * 24 * 60 * 60 * 1e3;
|
|
735
|
+
var APP_MS = 30 * 24 * 60 * 60 * 1e3;
|
|
736
|
+
var MAX_MS = 10 * 365 * 24 * 60 * 60 * 1e3;
|
|
737
|
+
var EXPIRY = {
|
|
738
|
+
EPHEMERAL_MS,
|
|
739
|
+
SESSION_MS,
|
|
740
|
+
SHARE_MS,
|
|
741
|
+
APP_MS,
|
|
742
|
+
MAX_MS
|
|
743
|
+
};
|
|
744
|
+
|
|
731
745
|
// src/spaces/SpaceService.ts
|
|
732
746
|
var SERVICE_NAME = "space";
|
|
733
747
|
var SpaceErrorCodes = {
|
|
@@ -804,7 +818,7 @@ function transformServerDelegations(validatedData, defaultSpaceId) {
|
|
|
804
818
|
spaceId,
|
|
805
819
|
path,
|
|
806
820
|
actions,
|
|
807
|
-
expiry: info.expiry ? new Date(info.expiry) : new Date(Date.now() +
|
|
821
|
+
expiry: info.expiry ? new Date(info.expiry) : new Date(Date.now() + EXPIRY.SHARE_MS),
|
|
808
822
|
isRevoked: false,
|
|
809
823
|
createdAt: info.issued_at ? new Date(info.issued_at) : void 0,
|
|
810
824
|
parentCid: firstStringParent
|
|
@@ -2212,7 +2226,7 @@ var DelegationManager = class {
|
|
|
2212
2226
|
spaceId: this.session.spaceId,
|
|
2213
2227
|
path: params.path,
|
|
2214
2228
|
actions: params.actions,
|
|
2215
|
-
expiry: params.expiry ?? new Date(Date.now() +
|
|
2229
|
+
expiry: params.expiry ?? new Date(Date.now() + EXPIRY.SHARE_MS),
|
|
2216
2230
|
isRevoked: false,
|
|
2217
2231
|
allowSubDelegation: !(params.disableSubDelegation ?? false),
|
|
2218
2232
|
createdAt: /* @__PURE__ */ new Date()
|
|
@@ -3391,7 +3405,7 @@ function inferShortServiceFromActionUrns(actions) {
|
|
|
3391
3405
|
return short;
|
|
3392
3406
|
}
|
|
3393
3407
|
var DEFAULT_READ_ACTIONS = ["tinycloud.kv/get", "tinycloud.kv/metadata"];
|
|
3394
|
-
var DEFAULT_EXPIRY_MS =
|
|
3408
|
+
var DEFAULT_EXPIRY_MS = EXPIRY.SHARE_MS;
|
|
3395
3409
|
var BASE64_PREFIX = "tc1:";
|
|
3396
3410
|
function createError2(code, message, cause, meta) {
|
|
3397
3411
|
return {
|
|
@@ -5046,6 +5060,7 @@ export {
|
|
|
5046
5060
|
DuckDbAction,
|
|
5047
5061
|
DuckDbDatabaseHandle,
|
|
5048
5062
|
DuckDbService2 as DuckDbService,
|
|
5063
|
+
EXPIRY,
|
|
5049
5064
|
EnsDataSchema,
|
|
5050
5065
|
ErrorCodes2 as ErrorCodes,
|
|
5051
5066
|
HooksService2 as HooksService,
|