@absolutejs/agent 0.4.2 → 0.4.3
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/actions.js.map +2 -2
- package/dist/authAgency.js.map +2 -2
- package/package.json +2 -2
package/dist/actions.js.map
CHANGED
|
@@ -2,10 +2,10 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/authAgency.ts", "../src/actions.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type { ActionRequestInput } from \"@absolutejs/agency\";\nimport type {\n AgentDelegation,\n AgentDelegationStore,\n} from \"@absolutejs/auth/agents\";\nimport { Type, type Static } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\n\nexport const AUTH_AGENCY_AUTHORIZATION_DETAIL_TYPE =\n \"urn:absolutejs:authorization-detail:agency-delegation\";\n\nexport const AuthAgencyAuthorizationDetailSchema = Type.Object(\n {\n actions: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),\n audience: Type.String({ minLength: 1 }),\n effects: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),\n resourceIds: Type.Optional(\n Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),\n ),\n resourceTypes: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),\n type: Type.Literal(AUTH_AGENCY_AUTHORIZATION_DETAIL_TYPE),\n },\n { additionalProperties: false },\n);\n\nexport type AuthAgencyAuthorizationDetail = Static<\n typeof AuthAgencyAuthorizationDetailSchema\n>;\n\nexport const authAgencyAuthorizationDetail = (\n detail: Omit<AuthAgencyAuthorizationDetail, \"type\">,\n): AuthAgencyAuthorizationDetail => ({\n ...detail,\n type: AUTH_AGENCY_AUTHORIZATION_DETAIL_TYPE,\n});\n\nconst subset = (required: readonly string[], available: readonly string[]) =>\n required.every((value) => available.includes(value));\n\nconst audienceOf = (action: ActionRequestInput) => {\n const audience = action.context?.audience;\n\n return typeof audience === \"string\" ? audience : undefined;\n};\n\nconst activeDelegation = async (\n store: AgentDelegationStore,\n action: ActionRequestInput,\n now: number,\n) => {\n const { delegationId } = action.actor;\n\n if (!delegationId) throw new Error(\"Agency action requires a delegation\");\n const delegation = await store.findByDelegationId(delegationId);\n\n if (!delegation) throw new Error(\"Unknown authenticated delegation\");\n if (delegation.status !== \"active\")\n throw new Error(\"Authenticated delegation is revoked\");\n if (delegation.expiresAt !== undefined && delegation.expiresAt <= now)\n throw new Error(\"Authenticated delegation is expired\");\n\n return delegation;\n};\n\nconst assertActor = (\n action: ActionRequestInput,\n delegation: AgentDelegation,\n) => {\n if (\n action.actor.agentId !== delegation.agentId ||\n action.actor.userId !== delegation.userId ||\n action.actor.organizationId !== delegation.organizationId\n )\n throw new Error(\"Agency actor does not match authenticated delegation\");\n if (!subset(action.actor.scopes, delegation.scopes))\n throw new Error(\"Agency actor scopes exceed authenticated delegation\");\n};\n\nconst authorizationDetails = (delegation: AgentDelegation) =>\n (delegation.authorizationDetails ?? []).filter(\n (detail): detail is AuthAgencyAuthorizationDetail =>\n Value.Check(AuthAgencyAuthorizationDetailSchema, detail),\n );\n\nconst detailAllows = (\n detail: AuthAgencyAuthorizationDetail,\n action: ActionRequestInput,\n) =>\n detail.audience === audienceOf(action) &&\n detail.actions.includes(action.action) &&\n subset(action.effects, detail.effects) &&\n detail.resourceTypes.includes(action.resource.type) &&\n (!detail.resourceIds || detail.resourceIds.includes(action.resource.id));\n\n/** Bridges Absolute Auth's verified principal grant directly into Agency.\n * The same delegation ID is re-read at request, lease, and execution time; no\n * shadow grant or manual synchronization is required. */\nexport const createAuthAgencyDelegationAuthority = (options: {\n now?: () => number;\n store: AgentDelegationStore;\n}) => ({\n assertAllows: async (action: ActionRequestInput) => {\n const delegation = await activeDelegation(\n options.store,\n action,\n (options.now ?? Date.now)(),\n );\n assertActor(action, delegation);\n if (!authorizationDetails(delegation).some((detail)
|
|
5
|
+
"import type { ActionRequestInput } from \"@absolutejs/agency\";\nimport type {\n AgentDelegation,\n AgentDelegationStore,\n} from \"@absolutejs/auth/agents\";\nimport { Type, type Static } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\n\nexport const AUTH_AGENCY_AUTHORIZATION_DETAIL_TYPE =\n \"urn:absolutejs:authorization-detail:agency-delegation\";\n\nexport const AuthAgencyAuthorizationDetailSchema = Type.Object(\n {\n actions: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),\n audience: Type.String({ minLength: 1 }),\n effects: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),\n resourceIds: Type.Optional(\n Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),\n ),\n resourceTypes: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),\n type: Type.Literal(AUTH_AGENCY_AUTHORIZATION_DETAIL_TYPE),\n },\n { additionalProperties: false },\n);\n\nexport type AuthAgencyAuthorizationDetail = Static<\n typeof AuthAgencyAuthorizationDetailSchema\n>;\n\nexport const authAgencyAuthorizationDetail = (\n detail: Omit<AuthAgencyAuthorizationDetail, \"type\">,\n): AuthAgencyAuthorizationDetail => ({\n ...detail,\n type: AUTH_AGENCY_AUTHORIZATION_DETAIL_TYPE,\n});\n\nconst subset = (required: readonly string[], available: readonly string[]) =>\n required.every((value) => available.includes(value));\n\nconst audienceOf = (action: ActionRequestInput) => {\n const audience = action.context?.audience;\n\n return typeof audience === \"string\" ? audience : undefined;\n};\n\nconst activeDelegation = async (\n store: AgentDelegationStore,\n action: ActionRequestInput,\n now: number,\n) => {\n const { delegationId } = action.actor;\n\n if (!delegationId) throw new Error(\"Agency action requires a delegation\");\n const delegation = await store.findByDelegationId(delegationId);\n\n if (!delegation) throw new Error(\"Unknown authenticated delegation\");\n if (delegation.status !== \"active\")\n throw new Error(\"Authenticated delegation is revoked\");\n if (delegation.expiresAt !== undefined && delegation.expiresAt <= now)\n throw new Error(\"Authenticated delegation is expired\");\n\n return delegation;\n};\n\nconst assertActor = (\n action: ActionRequestInput,\n delegation: AgentDelegation,\n) => {\n if (\n action.actor.agentId !== delegation.agentId ||\n action.actor.userId !== delegation.userId ||\n action.actor.organizationId !== delegation.organizationId\n )\n throw new Error(\"Agency actor does not match authenticated delegation\");\n if (!subset(action.actor.scopes, delegation.scopes))\n throw new Error(\"Agency actor scopes exceed authenticated delegation\");\n};\n\nconst authorizationDetails = (delegation: AgentDelegation) =>\n (delegation.authorizationDetails ?? []).filter(\n (detail): detail is AuthAgencyAuthorizationDetail =>\n Value.Check(AuthAgencyAuthorizationDetailSchema, detail),\n );\n\nconst detailAllows = (\n detail: AuthAgencyAuthorizationDetail,\n action: ActionRequestInput,\n) =>\n detail.audience === audienceOf(action) &&\n detail.actions.includes(action.action) &&\n subset(action.effects, detail.effects) &&\n detail.resourceTypes.includes(action.resource.type) &&\n (!detail.resourceIds || detail.resourceIds.includes(action.resource.id));\n\n/** Bridges Absolute Auth's verified principal grant directly into Agency.\n * The same delegation ID is re-read at request, lease, and execution time; no\n * shadow grant or manual synchronization is required. */\nexport const createAuthAgencyDelegationAuthority = (options: {\n now?: () => number;\n store: AgentDelegationStore;\n}) => ({\n assertAllows: async (action: ActionRequestInput) => {\n const delegation = await activeDelegation(\n options.store,\n action,\n (options.now ?? Date.now)(),\n );\n assertActor(action, delegation);\n if (\n !authorizationDetails(delegation).some((detail) =>\n detailAllows(detail, action),\n )\n )\n throw new Error(\"Agency action is outside authenticated delegation\");\n\n return {\n ...(delegation.expiresAt === undefined\n ? {}\n : { expiresAt: delegation.expiresAt }),\n };\n },\n});\n",
|
|
6
6
|
"export * from \"@absolutejs/agency\";\nexport * from \"./authAgency\";\n"
|
|
7
7
|
],
|
|
8
|
-
"mappings": ";;AAKA;AACA;AAEO,IAAM,wCACX;AAEK,IAAM,sCAAsC,KAAK,OACtD;AAAA,EACE,SAAS,KAAK,MAAM,KAAK,OAAO,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,CAAC;AAAA,EAClE,UAAU,KAAK,OAAO,EAAE,WAAW,EA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M,KACrC,OAAO,QAAQ,SAAS,OAAO,MAAM,KACrC,OAAO,OAAO,SAAS,OAAO,OAAO,KACrC,OAAO,cAAc,SAAS,OAAO,SAAS,IAAI,MACjD,CAAC,OAAO,eAAe,OAAO,YAAY,SAAS,OAAO,SAAS,EAAE;AAKjE,IAAM,sCAAsC,CAAC,aAG7C;AAAA,EACL,cAAc,OAAO,WAA+B;AAAA,IAClD,MAAM,aAAa,MAAM,iBACvB,QAAQ,OACR,SACC,QAAQ,OAAO,KAAK,KAAK,CAC5B;AAAA,IACA,YAAY,QAAQ,UAAU;AAAA,IAC9B,IACE,CAAC,qBAAqB,UAAU,EAAE,KAAK,CAAC,WACtC,aAAa,QAAQ,MAAM,CAC7B;AAAA,MAEA,MAAM,IAAI,MAAM,mDAAmD;AAAA,IAErE,OAAO;AAAA,SACD,WAAW,cAAc,YACzB,CAAC,IACD,EAAE,WAAW,WAAW,UAAU;AAAA,IACxC;AAAA;AAEJ;;;ACzHA;",
|
|
9
9
|
"debugId": "C399317D4FE0652364756E2164756E21",
|
|
10
10
|
"names": []
|
|
11
11
|
}
|
package/dist/authAgency.js.map
CHANGED
|
@@ -2,9 +2,9 @@
|
|
|
2
2
|
"version": 3,
|
|
3
3
|
"sources": ["../src/authAgency.ts"],
|
|
4
4
|
"sourcesContent": [
|
|
5
|
-
"import type { ActionRequestInput } from \"@absolutejs/agency\";\nimport type {\n AgentDelegation,\n AgentDelegationStore,\n} from \"@absolutejs/auth/agents\";\nimport { Type, type Static } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\n\nexport const AUTH_AGENCY_AUTHORIZATION_DETAIL_TYPE =\n \"urn:absolutejs:authorization-detail:agency-delegation\";\n\nexport const AuthAgencyAuthorizationDetailSchema = Type.Object(\n {\n actions: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),\n audience: Type.String({ minLength: 1 }),\n effects: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),\n resourceIds: Type.Optional(\n Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),\n ),\n resourceTypes: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),\n type: Type.Literal(AUTH_AGENCY_AUTHORIZATION_DETAIL_TYPE),\n },\n { additionalProperties: false },\n);\n\nexport type AuthAgencyAuthorizationDetail = Static<\n typeof AuthAgencyAuthorizationDetailSchema\n>;\n\nexport const authAgencyAuthorizationDetail = (\n detail: Omit<AuthAgencyAuthorizationDetail, \"type\">,\n): AuthAgencyAuthorizationDetail => ({\n ...detail,\n type: AUTH_AGENCY_AUTHORIZATION_DETAIL_TYPE,\n});\n\nconst subset = (required: readonly string[], available: readonly string[]) =>\n required.every((value) => available.includes(value));\n\nconst audienceOf = (action: ActionRequestInput) => {\n const audience = action.context?.audience;\n\n return typeof audience === \"string\" ? audience : undefined;\n};\n\nconst activeDelegation = async (\n store: AgentDelegationStore,\n action: ActionRequestInput,\n now: number,\n) => {\n const { delegationId } = action.actor;\n\n if (!delegationId) throw new Error(\"Agency action requires a delegation\");\n const delegation = await store.findByDelegationId(delegationId);\n\n if (!delegation) throw new Error(\"Unknown authenticated delegation\");\n if (delegation.status !== \"active\")\n throw new Error(\"Authenticated delegation is revoked\");\n if (delegation.expiresAt !== undefined && delegation.expiresAt <= now)\n throw new Error(\"Authenticated delegation is expired\");\n\n return delegation;\n};\n\nconst assertActor = (\n action: ActionRequestInput,\n delegation: AgentDelegation,\n) => {\n if (\n action.actor.agentId !== delegation.agentId ||\n action.actor.userId !== delegation.userId ||\n action.actor.organizationId !== delegation.organizationId\n )\n throw new Error(\"Agency actor does not match authenticated delegation\");\n if (!subset(action.actor.scopes, delegation.scopes))\n throw new Error(\"Agency actor scopes exceed authenticated delegation\");\n};\n\nconst authorizationDetails = (delegation: AgentDelegation) =>\n (delegation.authorizationDetails ?? []).filter(\n (detail): detail is AuthAgencyAuthorizationDetail =>\n Value.Check(AuthAgencyAuthorizationDetailSchema, detail),\n );\n\nconst detailAllows = (\n detail: AuthAgencyAuthorizationDetail,\n action: ActionRequestInput,\n) =>\n detail.audience === audienceOf(action) &&\n detail.actions.includes(action.action) &&\n subset(action.effects, detail.effects) &&\n detail.resourceTypes.includes(action.resource.type) &&\n (!detail.resourceIds || detail.resourceIds.includes(action.resource.id));\n\n/** Bridges Absolute Auth's verified principal grant directly into Agency.\n * The same delegation ID is re-read at request, lease, and execution time; no\n * shadow grant or manual synchronization is required. */\nexport const createAuthAgencyDelegationAuthority = (options: {\n now?: () => number;\n store: AgentDelegationStore;\n}) => ({\n assertAllows: async (action: ActionRequestInput) => {\n const delegation = await activeDelegation(\n options.store,\n action,\n (options.now ?? Date.now)(),\n );\n assertActor(action, delegation);\n if (!authorizationDetails(delegation).some((detail)
|
|
5
|
+
"import type { ActionRequestInput } from \"@absolutejs/agency\";\nimport type {\n AgentDelegation,\n AgentDelegationStore,\n} from \"@absolutejs/auth/agents\";\nimport { Type, type Static } from \"@sinclair/typebox\";\nimport { Value } from \"@sinclair/typebox/value\";\n\nexport const AUTH_AGENCY_AUTHORIZATION_DETAIL_TYPE =\n \"urn:absolutejs:authorization-detail:agency-delegation\";\n\nexport const AuthAgencyAuthorizationDetailSchema = Type.Object(\n {\n actions: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),\n audience: Type.String({ minLength: 1 }),\n effects: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),\n resourceIds: Type.Optional(\n Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),\n ),\n resourceTypes: Type.Array(Type.String({ minLength: 1 }), { minItems: 1 }),\n type: Type.Literal(AUTH_AGENCY_AUTHORIZATION_DETAIL_TYPE),\n },\n { additionalProperties: false },\n);\n\nexport type AuthAgencyAuthorizationDetail = Static<\n typeof AuthAgencyAuthorizationDetailSchema\n>;\n\nexport const authAgencyAuthorizationDetail = (\n detail: Omit<AuthAgencyAuthorizationDetail, \"type\">,\n): AuthAgencyAuthorizationDetail => ({\n ...detail,\n type: AUTH_AGENCY_AUTHORIZATION_DETAIL_TYPE,\n});\n\nconst subset = (required: readonly string[], available: readonly string[]) =>\n required.every((value) => available.includes(value));\n\nconst audienceOf = (action: ActionRequestInput) => {\n const audience = action.context?.audience;\n\n return typeof audience === \"string\" ? audience : undefined;\n};\n\nconst activeDelegation = async (\n store: AgentDelegationStore,\n action: ActionRequestInput,\n now: number,\n) => {\n const { delegationId } = action.actor;\n\n if (!delegationId) throw new Error(\"Agency action requires a delegation\");\n const delegation = await store.findByDelegationId(delegationId);\n\n if (!delegation) throw new Error(\"Unknown authenticated delegation\");\n if (delegation.status !== \"active\")\n throw new Error(\"Authenticated delegation is revoked\");\n if (delegation.expiresAt !== undefined && delegation.expiresAt <= now)\n throw new Error(\"Authenticated delegation is expired\");\n\n return delegation;\n};\n\nconst assertActor = (\n action: ActionRequestInput,\n delegation: AgentDelegation,\n) => {\n if (\n action.actor.agentId !== delegation.agentId ||\n action.actor.userId !== delegation.userId ||\n action.actor.organizationId !== delegation.organizationId\n )\n throw new Error(\"Agency actor does not match authenticated delegation\");\n if (!subset(action.actor.scopes, delegation.scopes))\n throw new Error(\"Agency actor scopes exceed authenticated delegation\");\n};\n\nconst authorizationDetails = (delegation: AgentDelegation) =>\n (delegation.authorizationDetails ?? []).filter(\n (detail): detail is AuthAgencyAuthorizationDetail =>\n Value.Check(AuthAgencyAuthorizationDetailSchema, detail),\n );\n\nconst detailAllows = (\n detail: AuthAgencyAuthorizationDetail,\n action: ActionRequestInput,\n) =>\n detail.audience === audienceOf(action) &&\n detail.actions.includes(action.action) &&\n subset(action.effects, detail.effects) &&\n detail.resourceTypes.includes(action.resource.type) &&\n (!detail.resourceIds || detail.resourceIds.includes(action.resource.id));\n\n/** Bridges Absolute Auth's verified principal grant directly into Agency.\n * The same delegation ID is re-read at request, lease, and execution time; no\n * shadow grant or manual synchronization is required. */\nexport const createAuthAgencyDelegationAuthority = (options: {\n now?: () => number;\n store: AgentDelegationStore;\n}) => ({\n assertAllows: async (action: ActionRequestInput) => {\n const delegation = await activeDelegation(\n options.store,\n action,\n (options.now ?? Date.now)(),\n );\n assertActor(action, delegation);\n if (\n !authorizationDetails(delegation).some((detail) =>\n detailAllows(detail, action),\n )\n )\n throw new Error(\"Agency action is outside authenticated delegation\");\n\n return {\n ...(delegation.expiresAt === undefined\n ? {}\n : { expiresAt: delegation.expiresAt }),\n };\n },\n});\n"
|
|
6
6
|
],
|
|
7
|
-
"mappings": ";;AAKA;AACA;AAEO,IAAM,wCACX;AAEK,IAAM,sCAAsC,KAAK,OACtD;AAAA,EACE,SAAS,KAAK,MAAM,KAAK,OAAO,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,CAAC;AAAA,EAClE,UAAU,KAAK,OAAO,EAAE,WAAW,EAAE,CAAC;AAAA,EACtC,SAAS,KAAK,MAAM,KAAK,OAAO,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,CAAC;AAAA,EAClE,aAAa,KAAK,SAChB,KAAK,MAAM,KAAK,OAAO,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,CAAC,CAC3D;AAAA,EACA,eAAe,KAAK,MAAM,KAAK,OAAO,EAAE,WAAW,EAAE,CAAC,GAAG,EAAE,UAAU,EAAE,CAAC;AAAA,EACxE,MAAM,KAAK,QAAQ,qCAAqC;AAC1D,GACA,EAAE,sBAAsB,MAAM,CAChC;AAMO,IAAM,gCAAgC,CAC3C,YACmC;AAAA,KAChC;AAAA,EACH,MAAM;AACR;AAEA,IAAM,SAAS,CAAC,UAA6B,cAC3C,SAAS,MAAM,CAAC,UAAU,UAAU,SAAS,KAAK,CAAC;AAErD,IAAM,aAAa,CAAC,WAA+B;AAAA,EACjD,MAAM,WAAW,OAAO,SAAS;AAAA,EAEjC,OAAO,OAAO,aAAa,WAAW,WAAW;AAAA;AAGnD,IAAM,mBAAmB,OACvB,OACA,QACA,QACG;AAAA,EACH,QAAQ,iBAAiB,OAAO;AAAA,EAEhC,IAAI,CAAC;AAAA,IAAc,MAAM,IA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
|
3
|
+
"version": "0.4.3",
|
|
4
4
|
"description": "The production-grade, provider-neutral agent stack for AbsoluteJS: auth, actions, runtime, sandboxing, trust, memory, inbox, discovery, MCP, A2A, policy, wallet limits, controls, and conformance.",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"license": "MIT",
|
|
@@ -131,7 +131,7 @@
|
|
|
131
131
|
"@absolutejs/agent-runtime": "^0.1.0",
|
|
132
132
|
"@absolutejs/agent-sandbox": "^0.1.0",
|
|
133
133
|
"@absolutejs/agent-trust": "^0.1.0",
|
|
134
|
-
"@absolutejs/auth": "^0.56.
|
|
134
|
+
"@absolutejs/auth": "^0.56.6",
|
|
135
135
|
"@absolutejs/execution": "^0.2.0",
|
|
136
136
|
"@absolutejs/manifest": "^0.3.0",
|
|
137
137
|
"@absolutejs/mcp": "^0.10.2",
|