@tinycloud/operations 0.7.0-beta.32 → 0.7.0-beta.34
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/cli-runtime.cjs +35 -4
- package/dist/cli-runtime.cjs.map +1 -1
- package/dist/cli-runtime.js +33 -2
- package/dist/cli-runtime.js.map +1 -1
- package/dist/index.cjs +35 -4
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +33 -2
- package/dist/index.js.map +1 -1
- package/dist/revoked-grant.cjs +56 -0
- package/dist/revoked-grant.cjs.map +1 -0
- package/dist/revoked-grant.d.cts +9 -0
- package/dist/revoked-grant.d.ts +9 -0
- package/dist/revoked-grant.js +30 -0
- package/dist/revoked-grant.js.map +1 -0
- package/package.json +9 -4
package/dist/index.js
CHANGED
|
@@ -5860,10 +5860,37 @@ var init_rules_generated = __esm({
|
|
|
5860
5860
|
}
|
|
5861
5861
|
});
|
|
5862
5862
|
|
|
5863
|
+
// src/revoked-grant.ts
|
|
5864
|
+
import { authorizationVerdictOf } from "@tinycloud/sdk-services";
|
|
5865
|
+
function isRevokedGrantRefusal(error) {
|
|
5866
|
+
if (authorizationVerdictOf(error) !== "unauthenticated") return false;
|
|
5867
|
+
const seen = /* @__PURE__ */ new Set();
|
|
5868
|
+
let node = error;
|
|
5869
|
+
for (let depth = 0; depth < MAX_CAUSE_DEPTH && typeof node === "object" && node !== null && !seen.has(node); depth += 1) {
|
|
5870
|
+
seen.add(node);
|
|
5871
|
+
const { code, message, cause } = node;
|
|
5872
|
+
if (REVOKED_GRANT_CODES.has(code)) return true;
|
|
5873
|
+
if (typeof message === "string" && REVOKED_GRANT_BODY.test(message)) return true;
|
|
5874
|
+
node = cause;
|
|
5875
|
+
}
|
|
5876
|
+
return false;
|
|
5877
|
+
}
|
|
5878
|
+
var MAX_CAUSE_DEPTH, REVOKED_GRANT_BODY, REVOKED_GRANT_CODES, REVOKED_GRANT_MESSAGE;
|
|
5879
|
+
var init_revoked_grant = __esm({
|
|
5880
|
+
"src/revoked-grant.ts"() {
|
|
5881
|
+
"use strict";
|
|
5882
|
+
init_cli_name();
|
|
5883
|
+
MAX_CAUSE_DEPTH = 8;
|
|
5884
|
+
REVOKED_GRANT_BODY = /\b401 - (?:Invalid invocation: )?delegation-(?:revoked: [A-Za-z0-9]+|ancestor-revoked: ancestor=[A-Za-z0-9]+ invoked=[A-Za-z0-9]+)\s*$/;
|
|
5885
|
+
REVOKED_GRANT_CODES = /* @__PURE__ */ new Set(["AUTH_DELEGATION_REVOKED", "AUTH_DELEGATION_ANCESTOR_REVOKED"]);
|
|
5886
|
+
REVOKED_GRANT_MESSAGE = `This grant was revoked. Ask the owner for a new grant (\`${CLI_NAME} auth request ...\`).`;
|
|
5887
|
+
}
|
|
5888
|
+
});
|
|
5889
|
+
|
|
5863
5890
|
// src/kv-failure.ts
|
|
5864
|
-
import { authorizationVerdictOf, validatedCapabilityOf } from "@tinycloud/sdk-services";
|
|
5891
|
+
import { authorizationVerdictOf as authorizationVerdictOf2, validatedCapabilityOf } from "@tinycloud/sdk-services";
|
|
5865
5892
|
function kvRefusal(error) {
|
|
5866
|
-
const verdict =
|
|
5893
|
+
const verdict = authorizationVerdictOf2(error);
|
|
5867
5894
|
if (verdict === "unauthenticated") {
|
|
5868
5895
|
return validatedCapabilityOf(error) === void 0 ? "auth_required" : "permission_denied";
|
|
5869
5896
|
}
|
|
@@ -5872,6 +5899,9 @@ function kvRefusal(error) {
|
|
|
5872
5899
|
function authorizationFailure(error, action) {
|
|
5873
5900
|
switch (kvRefusal(error)) {
|
|
5874
5901
|
case "auth_required":
|
|
5902
|
+
if (isRevokedGrantRefusal(error)) {
|
|
5903
|
+
return { status: "error", error: operationError("AUTH_REQUIRED", REVOKED_GRANT_MESSAGE) };
|
|
5904
|
+
}
|
|
5875
5905
|
return { status: "error", error: operationError("AUTH_REQUIRED", `Authentication is required to ${action}.`) };
|
|
5876
5906
|
case "permission_denied":
|
|
5877
5907
|
return { status: "error", error: operationError("PERMISSION_DENIED", `Permission is denied to ${action}.`) };
|
|
@@ -5883,6 +5913,7 @@ var init_kv_failure = __esm({
|
|
|
5883
5913
|
"src/kv-failure.ts"() {
|
|
5884
5914
|
"use strict";
|
|
5885
5915
|
init_errors2();
|
|
5916
|
+
init_revoked_grant();
|
|
5886
5917
|
}
|
|
5887
5918
|
});
|
|
5888
5919
|
|