@tinycloud/sdk-services 2.11.0 → 3.0.0-beta.14

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/kv/index.js CHANGED
@@ -620,7 +620,7 @@ var KVService = class extends BaseService {
620
620
  */
621
621
  getFullPath(key, prefixOverride) {
622
622
  const prefix = prefixOverride ?? this._config.prefix ?? "";
623
- return prefix ? `${prefix}/${key}` : key;
623
+ return prefix ? key === "" ? prefix : `${prefix}/${key}` : key;
624
624
  }
625
625
  /**
626
626
  * Get the host URL.
@@ -1104,16 +1104,17 @@ var KVService = class extends BaseService {
1104
1104
  ...options?.ifNoneMatch === void 0 ? {} : { "if-none-match": options.ifNoneMatch }
1105
1105
  }
1106
1106
  );
1107
+ if (response.status === 401 || response.status === 403) {
1108
+ const errorText = await response.text();
1109
+ const message = errorText.trim().length > 0 ? errorText : `Failed to put key "${key}": ${response.status} - ${response.statusText || "authorization failed"}`;
1110
+ const { resource, action: requiredAction } = parseAuthError(errorText);
1111
+ return err(authUnauthorizedError("kv", message, {
1112
+ status: response.status,
1113
+ ...requiredAction && { requiredAction },
1114
+ ...resource && { resource }
1115
+ }));
1116
+ }
1107
1117
  if (!response.ok) {
1108
- if (response.status === 401) {
1109
- const errorText2 = await response.text();
1110
- const { resource, action } = parseAuthError(errorText2);
1111
- return err(authUnauthorizedError("kv", errorText2, {
1112
- status: response.status,
1113
- ...action && { requiredAction: action },
1114
- ...resource && { resource }
1115
- }));
1116
- }
1117
1118
  const errorText = await response.text();
1118
1119
  if (response.status === 412) {
1119
1120
  return err(serviceError(