@tinycloud/operations 0.3.3-beta.11 → 0.3.3-beta.13

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.js CHANGED
@@ -3618,16 +3618,17 @@ var init_dist2 = __esm({
3618
3618
  ...options?.ifNoneMatch === void 0 ? {} : { "if-none-match": options.ifNoneMatch }
3619
3619
  }
3620
3620
  );
3621
+ if (response.status === 401 || response.status === 403) {
3622
+ const errorText = await response.text();
3623
+ const message = errorText.trim().length > 0 ? errorText : `Failed to put key "${key}": ${response.status} - ${response.statusText || "authorization failed"}`;
3624
+ const { resource, action: requiredAction } = parseAuthError(errorText);
3625
+ return err(authUnauthorizedError("kv", message, {
3626
+ status: response.status,
3627
+ ...requiredAction && { requiredAction },
3628
+ ...resource && { resource }
3629
+ }));
3630
+ }
3621
3631
  if (!response.ok) {
3622
- if (response.status === 401) {
3623
- const errorText2 = await response.text();
3624
- const { resource, action } = parseAuthError(errorText2);
3625
- return err(authUnauthorizedError("kv", errorText2, {
3626
- status: response.status,
3627
- ...action && { requiredAction: action },
3628
- ...resource && { resource }
3629
- }));
3630
- }
3631
3632
  const errorText = await response.text();
3632
3633
  if (response.status === 412) {
3633
3634
  return err(serviceError(