@alfe.ai/openclaw-identity 0.0.4 → 0.0.5

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/plugin.cjs CHANGED
@@ -73,6 +73,7 @@ const plugin = {
73
73
  version: "0.0.1",
74
74
  activate(api) {
75
75
  const log = api.logger;
76
+ if (api.registrationMode && api.registrationMode !== "full") return;
76
77
  log.info("Alfe Identity plugin activating...");
77
78
  let client;
78
79
  try {
@@ -85,6 +86,14 @@ const plugin = {
85
86
  log.error(`Identity plugin: failed to resolve config — ${err instanceof Error ? err.message : String(err)}`);
86
87
  return;
87
88
  }
89
+ let failureMode = "open";
90
+ client.getIntegrationConfig("alfe").then((alfeConfig) => {
91
+ const mode = alfeConfig.config.identity_failure_mode;
92
+ if (mode === "open" || mode === "closed" || mode === "permissive") failureMode = mode;
93
+ log.info(`Identity failure mode: ${failureMode}`);
94
+ }).catch(() => {
95
+ log.info(`Identity failure mode: ${failureMode} (default — config fetch failed)`);
96
+ });
88
97
  const identityToolNames = /* @__PURE__ */ new Set();
89
98
  const tools = [
90
99
  defineTool({
@@ -296,6 +305,10 @@ const plugin = {
296
305
  log.info(`Identity resolved: ${senderId} → ${resolveResult.identityId ?? "unknown"} (${resolveResult.status})`);
297
306
  } catch (e) {
298
307
  log.error(`Identity resolution failed for ${senderId}: ${e.message}`);
308
+ if (failureMode === "closed") return {
309
+ block: true,
310
+ blockReason: "Identity: identity service unavailable — access denied (closed mode)"
311
+ };
299
312
  }
300
313
  }, { priority: 100 });
301
314
  api.on("before_tool_call", async (...args) => {
@@ -305,14 +318,20 @@ const plugin = {
305
318
  const sessionKey = ctx.sessionKey;
306
319
  if (!sessionKey) return;
307
320
  const perms = getCached(sessionKey);
308
- if (!perms) return {
309
- block: true,
310
- blockReason: "Identity: no identity context established — tool access denied"
311
- };
312
- if (!perms.identified) return {
313
- block: true,
314
- blockReason: "Identity: unknown sender identity — tool access denied"
315
- };
321
+ if (!perms) {
322
+ if (failureMode === "permissive") return;
323
+ return {
324
+ block: true,
325
+ blockReason: "Identity: no identity context established — tool access denied"
326
+ };
327
+ }
328
+ if (!perms.identified) {
329
+ if (failureMode === "permissive") return;
330
+ return {
331
+ block: true,
332
+ blockReason: "Identity: unknown sender identity — tool access denied"
333
+ };
334
+ }
316
335
  if (perms.deniedTools.includes("*") || perms.deniedTools.includes(event.toolName)) return {
317
336
  block: true,
318
337
  blockReason: `Identity: tool '${event.toolName}' is denied for your role`
package/dist/plugin.d.cts CHANGED
@@ -23,6 +23,7 @@ interface ToolDef {
23
23
  }
24
24
  interface PluginApi {
25
25
  logger: PluginLogger;
26
+ registrationMode?: "full" | "setup-only" | "setup-runtime" | "cli-metadata";
26
27
  registerTool: (tool: ToolDef) => void;
27
28
  on: (event: string, handler: (...args: unknown[]) => Promise<unknown>, options?: {
28
29
  priority?: number;
package/dist/plugin.d.ts CHANGED
@@ -23,6 +23,7 @@ interface ToolDef {
23
23
  }
24
24
  interface PluginApi {
25
25
  logger: PluginLogger;
26
+ registrationMode?: "full" | "setup-only" | "setup-runtime" | "cli-metadata";
26
27
  registerTool: (tool: ToolDef) => void;
27
28
  on: (event: string, handler: (...args: unknown[]) => Promise<unknown>, options?: {
28
29
  priority?: number;
package/dist/plugin.js CHANGED
@@ -73,6 +73,7 @@ const plugin = {
73
73
  version: "0.0.1",
74
74
  activate(api) {
75
75
  const log = api.logger;
76
+ if (api.registrationMode && api.registrationMode !== "full") return;
76
77
  log.info("Alfe Identity plugin activating...");
77
78
  let client;
78
79
  try {
@@ -85,6 +86,14 @@ const plugin = {
85
86
  log.error(`Identity plugin: failed to resolve config — ${err instanceof Error ? err.message : String(err)}`);
86
87
  return;
87
88
  }
89
+ let failureMode = "open";
90
+ client.getIntegrationConfig("alfe").then((alfeConfig) => {
91
+ const mode = alfeConfig.config.identity_failure_mode;
92
+ if (mode === "open" || mode === "closed" || mode === "permissive") failureMode = mode;
93
+ log.info(`Identity failure mode: ${failureMode}`);
94
+ }).catch(() => {
95
+ log.info(`Identity failure mode: ${failureMode} (default — config fetch failed)`);
96
+ });
88
97
  const identityToolNames = /* @__PURE__ */ new Set();
89
98
  const tools = [
90
99
  defineTool({
@@ -296,6 +305,10 @@ const plugin = {
296
305
  log.info(`Identity resolved: ${senderId} → ${resolveResult.identityId ?? "unknown"} (${resolveResult.status})`);
297
306
  } catch (e) {
298
307
  log.error(`Identity resolution failed for ${senderId}: ${e.message}`);
308
+ if (failureMode === "closed") return {
309
+ block: true,
310
+ blockReason: "Identity: identity service unavailable — access denied (closed mode)"
311
+ };
299
312
  }
300
313
  }, { priority: 100 });
301
314
  api.on("before_tool_call", async (...args) => {
@@ -305,14 +318,20 @@ const plugin = {
305
318
  const sessionKey = ctx.sessionKey;
306
319
  if (!sessionKey) return;
307
320
  const perms = getCached(sessionKey);
308
- if (!perms) return {
309
- block: true,
310
- blockReason: "Identity: no identity context established — tool access denied"
311
- };
312
- if (!perms.identified) return {
313
- block: true,
314
- blockReason: "Identity: unknown sender identity — tool access denied"
315
- };
321
+ if (!perms) {
322
+ if (failureMode === "permissive") return;
323
+ return {
324
+ block: true,
325
+ blockReason: "Identity: no identity context established — tool access denied"
326
+ };
327
+ }
328
+ if (!perms.identified) {
329
+ if (failureMode === "permissive") return;
330
+ return {
331
+ block: true,
332
+ blockReason: "Identity: unknown sender identity — tool access denied"
333
+ };
334
+ }
316
335
  if (perms.deniedTools.includes("*") || perms.deniedTools.includes(event.toolName)) return {
317
336
  block: true,
318
337
  blockReason: `Identity: tool '${event.toolName}' is denied for your role`
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@alfe.ai/openclaw-identity",
3
- "version": "0.0.4",
3
+ "version": "0.0.5",
4
4
  "description": "OpenClaw identity plugin — identity resolution, access gating, permission enforcement",
5
5
  "type": "module",
6
6
  "main": "./dist/plugin.js",