@tinycloud/sdk-core 2.2.0-beta.0 → 2.2.0-beta.1
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 +29 -17
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +8 -4
- package/dist/index.d.ts +8 -4
- package/dist/index.js +29 -17
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -2834,9 +2834,7 @@ function parseExpiry(duration) {
|
|
|
2834
2834
|
`expiry must be a non-empty duration string (got ${JSON.stringify(duration)})`
|
|
2835
2835
|
);
|
|
2836
2836
|
}
|
|
2837
|
-
const parsed = (0, import_ms.default)(
|
|
2838
|
-
duration
|
|
2839
|
-
);
|
|
2837
|
+
const parsed = (0, import_ms.default)(duration);
|
|
2840
2838
|
if (typeof parsed !== "number" || !Number.isFinite(parsed) || parsed <= 0) {
|
|
2841
2839
|
throw new ManifestValidationError(
|
|
2842
2840
|
`invalid expiry duration: ${JSON.stringify(duration)}`
|
|
@@ -2891,23 +2889,33 @@ function validateManifest(input) {
|
|
|
2891
2889
|
);
|
|
2892
2890
|
}
|
|
2893
2891
|
if (typeof m.app_id !== "string" || m.app_id.length === 0) {
|
|
2894
|
-
throw new ManifestValidationError(
|
|
2892
|
+
throw new ManifestValidationError(
|
|
2893
|
+
"manifest.app_id is required and must be a non-empty string"
|
|
2894
|
+
);
|
|
2895
2895
|
}
|
|
2896
2896
|
if (typeof m.name !== "string" || m.name.length === 0) {
|
|
2897
|
-
throw new ManifestValidationError(
|
|
2897
|
+
throw new ManifestValidationError(
|
|
2898
|
+
"manifest.name is required and must be a non-empty string"
|
|
2899
|
+
);
|
|
2898
2900
|
}
|
|
2899
2901
|
if (m.did !== void 0 && (typeof m.did !== "string" || m.did.length === 0)) {
|
|
2900
|
-
throw new ManifestValidationError(
|
|
2902
|
+
throw new ManifestValidationError(
|
|
2903
|
+
"manifest.did must be a non-empty DID string"
|
|
2904
|
+
);
|
|
2901
2905
|
}
|
|
2902
2906
|
if (m.space !== void 0 && (typeof m.space !== "string" || m.space.length === 0)) {
|
|
2903
|
-
throw new ManifestValidationError(
|
|
2907
|
+
throw new ManifestValidationError(
|
|
2908
|
+
"manifest.space must be a non-empty string"
|
|
2909
|
+
);
|
|
2904
2910
|
}
|
|
2905
2911
|
if (m.expiry !== void 0) {
|
|
2906
2912
|
parseExpiry(m.expiry);
|
|
2907
2913
|
}
|
|
2908
2914
|
if (m.permissions !== void 0) {
|
|
2909
2915
|
if (!Array.isArray(m.permissions)) {
|
|
2910
|
-
throw new ManifestValidationError(
|
|
2916
|
+
throw new ManifestValidationError(
|
|
2917
|
+
"manifest.permissions must be an array"
|
|
2918
|
+
);
|
|
2911
2919
|
}
|
|
2912
2920
|
m.permissions.forEach(
|
|
2913
2921
|
(p, i) => validatePermissionEntry(p, `permissions[${i}]`)
|
|
@@ -2924,7 +2932,9 @@ function validatePermissionEntry(p, path) {
|
|
|
2924
2932
|
throw new ManifestValidationError(`${path}.service is required`);
|
|
2925
2933
|
}
|
|
2926
2934
|
if (entry.space !== void 0 && (typeof entry.space !== "string" || entry.space.length === 0)) {
|
|
2927
|
-
throw new ManifestValidationError(
|
|
2935
|
+
throw new ManifestValidationError(
|
|
2936
|
+
`${path}.space must be a non-empty string`
|
|
2937
|
+
);
|
|
2928
2938
|
}
|
|
2929
2939
|
if (typeof entry.path !== "string") {
|
|
2930
2940
|
throw new ManifestValidationError(
|
|
@@ -3015,7 +3025,8 @@ function resolveEntry(entry, prefix, _inheritedExpiryMs, inheritedSpace) {
|
|
|
3015
3025
|
// Only populate `expiryMs` when the entry had its own expiry override.
|
|
3016
3026
|
// When absent, callers use the parent (delegation or manifest) expiry
|
|
3017
3027
|
// which is carried on ResolvedDelegate.expiryMs / ResolvedCapabilities.expiryMs.
|
|
3018
|
-
...entryExpiryMs !== void 0 ? { expiryMs: entryExpiryMs } : {}
|
|
3028
|
+
...entryExpiryMs !== void 0 ? { expiryMs: entryExpiryMs } : {},
|
|
3029
|
+
...entry.description !== void 0 ? { description: entry.description } : {}
|
|
3019
3030
|
};
|
|
3020
3031
|
}
|
|
3021
3032
|
function cloneResourceCapability(entry) {
|
|
@@ -3024,7 +3035,8 @@ function cloneResourceCapability(entry) {
|
|
|
3024
3035
|
space: entry.space,
|
|
3025
3036
|
path: entry.path,
|
|
3026
3037
|
actions: [...entry.actions],
|
|
3027
|
-
...entry.expiryMs !== void 0 ? { expiryMs: entry.expiryMs } : {}
|
|
3038
|
+
...entry.expiryMs !== void 0 ? { expiryMs: entry.expiryMs } : {},
|
|
3039
|
+
...entry.description !== void 0 ? { description: entry.description } : {}
|
|
3028
3040
|
};
|
|
3029
3041
|
}
|
|
3030
3042
|
function clonePermissionEntry(entry) {
|
|
@@ -3034,7 +3046,8 @@ function clonePermissionEntry(entry) {
|
|
|
3034
3046
|
path: entry.path,
|
|
3035
3047
|
actions: [...entry.actions],
|
|
3036
3048
|
...entry.skipPrefix !== void 0 ? { skipPrefix: entry.skipPrefix } : {},
|
|
3037
|
-
...entry.expiry !== void 0 ? { expiry: entry.expiry } : {}
|
|
3049
|
+
...entry.expiry !== void 0 ? { expiry: entry.expiry } : {},
|
|
3050
|
+
...entry.description !== void 0 ? { description: entry.description } : {}
|
|
3038
3051
|
};
|
|
3039
3052
|
}
|
|
3040
3053
|
function dedupeResources(resources) {
|
|
@@ -3053,6 +3066,9 @@ function dedupeResources(resources) {
|
|
|
3053
3066
|
seen.add(action);
|
|
3054
3067
|
}
|
|
3055
3068
|
}
|
|
3069
|
+
if (existing.description === void 0 && resource.description !== void 0) {
|
|
3070
|
+
existing.description = resource.description;
|
|
3071
|
+
}
|
|
3056
3072
|
}
|
|
3057
3073
|
return [...byKey.values()];
|
|
3058
3074
|
}
|
|
@@ -3061,11 +3077,7 @@ function accountRegistryPermission() {
|
|
|
3061
3077
|
service: "tinycloud.kv",
|
|
3062
3078
|
space: ACCOUNT_REGISTRY_SPACE,
|
|
3063
3079
|
path: ACCOUNT_REGISTRY_PATH,
|
|
3064
|
-
actions: [
|
|
3065
|
-
"tinycloud.kv/get",
|
|
3066
|
-
"tinycloud.kv/put",
|
|
3067
|
-
"tinycloud.kv/list"
|
|
3068
|
-
]
|
|
3080
|
+
actions: ["tinycloud.kv/get", "tinycloud.kv/put", "tinycloud.kv/list"]
|
|
3069
3081
|
};
|
|
3070
3082
|
}
|
|
3071
3083
|
function composeManifestRequest(inputs, options = {}) {
|