@authentify2026/langchain 0.0.0-stage → 0.2.0

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/LICENSE ADDED
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 4Sure Technologies LLC
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
package/README.md CHANGED
@@ -1,3 +1,47 @@
1
- # Temporary Holding Version
1
+ # @authentify2026/langchain
2
2
 
3
- This version is a temporary placeholder for this package. An operational version to replace this has been submitted for review and is awaiting a staged release.
3
+ A [LangChain](https://js.langchain.com) tool wrapper around [`@authentify2026/sdk`](https://www.npmjs.com/package/@authentify2026/sdk), so a LangChain agent can call Authentify's `/authorize` gate as a native tool instead of your application hand-rolling a custom tool around a raw `fetch` call.
4
+
5
+ ## Install
6
+
7
+ ```bash
8
+ npm install @authentify2026/langchain @authentify2026/sdk @langchain/core zod
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```ts
14
+ import { AuthentifyClient } from '@authentify2026/sdk';
15
+ import { createAuthentifyAuthorizeTool } from '@authentify2026/langchain';
16
+ import { ChatOpenAI } from '@langchain/openai'; // or any chat model
17
+ import { createToolCallingAgent, AgentExecutor } from 'langchain/agents';
18
+
19
+ const authentify = new AuthentifyClient({
20
+ clientId: process.env.AUTHENTIFY_KEY_ID!,
21
+ clientSecret: process.env.AUTHENTIFY_KEY_SECRET!,
22
+ environment: 'production',
23
+ });
24
+
25
+ const authorizeTool = createAuthentifyAuthorizeTool(authentify);
26
+
27
+ const agent = await createToolCallingAgent({
28
+ llm: new ChatOpenAI({ model: 'gpt-4o' }),
29
+ tools: [authorizeTool /* , ...your other tools */],
30
+ prompt: /* your prompt, instructing the agent to call authentify_authorize
31
+ before any account action, and to check `decision` on the
32
+ result -- 'escalate' means the request is on record awaiting
33
+ human approval, which is a pending state, not a denial */,
34
+ });
35
+
36
+ const executor = new AgentExecutor({ agent, tools: [authorizeTool] });
37
+ ```
38
+
39
+ The tool's schema (`action`, `resource: { id, type? }`, `context`, `endUserId`) mirrors `AuthentifyClient.authorize()`'s params directly -- a malformed tool call from the model is rejected by the zod schema before it ever reaches the API.
40
+
41
+ **Making this the only path**: for the authorization gate to mean anything, the agent's tool list should have no *other*, un-gated way to perform the same action -- e.g. don't also give it a raw HTTP tool that could call the same downstream system directly. Authentify enforces every call that reaches it; it can't enforce a call that never does. See `docs/partner-integration-guide.md`'s go-live checklist for this same point.
42
+
43
+ Only `authorize()` is wrapped today. If you need a tool around consent-session creation or approval-request approval too, wrap the corresponding `AuthentifyClient` method the same way `tools.ts` does for this one.
44
+
45
+ ## Python
46
+
47
+ Building a Python-based LangChain agent instead? A Python SDK and LangChain wrapper are available on request during early access -- email support via [authentify.bz/contact](https://authentify.bz/contact).
@@ -0,0 +1 @@
1
+ export { createAuthentifyAuthorizeTool } from './tools';
package/dist/index.js ADDED
@@ -0,0 +1,5 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createAuthentifyAuthorizeTool = void 0;
4
+ var tools_1 = require("./tools");
5
+ Object.defineProperty(exports, "createAuthentifyAuthorizeTool", { enumerable: true, get: function () { return tools_1.createAuthentifyAuthorizeTool; } });
@@ -0,0 +1,60 @@
1
+ import { DynamicStructuredTool } from '@langchain/core/tools';
2
+ import { z } from 'zod';
3
+ import type { AuthentifyClient } from '@authentify2026/sdk';
4
+ /**
5
+ * Wraps AuthentifyClient.authorize() as a LangChain tool, so an agent can
6
+ * call Authentify's authorization gate as a native tool call instead of
7
+ * the surrounding application hand-rolling a fetch inside a custom tool.
8
+ *
9
+ * The tool's observation is the raw JSON result: `decision` is
10
+ * `'allow' | 'deny' | 'escalate'` -- treat `escalate` as "not yet
11
+ * approved, on record for human review" rather than a denial (an
12
+ * `approvalRequestId` is included when escalated).
13
+ */
14
+ export declare function createAuthentifyAuthorizeTool(client: AuthentifyClient): DynamicStructuredTool<z.ZodObject<{
15
+ action: z.ZodOptional<z.ZodString>;
16
+ resource: z.ZodObject<{
17
+ id: z.ZodString;
18
+ type: z.ZodOptional<z.ZodString>;
19
+ }, "strip", z.ZodTypeAny, {
20
+ id: string;
21
+ type?: string | undefined;
22
+ }, {
23
+ id: string;
24
+ type?: string | undefined;
25
+ }>;
26
+ context: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodUnknown>>;
27
+ endUserId: z.ZodOptional<z.ZodString>;
28
+ }, "strip", z.ZodTypeAny, {
29
+ resource: {
30
+ id: string;
31
+ type?: string | undefined;
32
+ };
33
+ action?: string | undefined;
34
+ context?: Record<string, unknown> | undefined;
35
+ endUserId?: string | undefined;
36
+ }, {
37
+ resource: {
38
+ id: string;
39
+ type?: string | undefined;
40
+ };
41
+ action?: string | undefined;
42
+ context?: Record<string, unknown> | undefined;
43
+ endUserId?: string | undefined;
44
+ }>, {
45
+ resource: {
46
+ id: string;
47
+ type?: string | undefined;
48
+ };
49
+ action?: string | undefined;
50
+ context?: Record<string, unknown> | undefined;
51
+ endUserId?: string | undefined;
52
+ }, {
53
+ resource: {
54
+ id: string;
55
+ type?: string | undefined;
56
+ };
57
+ action?: string | undefined;
58
+ context?: Record<string, unknown> | undefined;
59
+ endUserId?: string | undefined;
60
+ }, string, unknown, "authentify_authorize">;
package/dist/tools.js ADDED
@@ -0,0 +1,40 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.createAuthentifyAuthorizeTool = createAuthentifyAuthorizeTool;
4
+ const tools_1 = require("@langchain/core/tools");
5
+ const zod_1 = require("zod");
6
+ const authorizeSchema = zod_1.z.object({
7
+ action: zod_1.z.string().optional().describe('The action being requested, e.g. READ, TRANSFER, APPROVE_CLAIM, EXECUTE_LEASE.'),
8
+ resource: zod_1.z.object({
9
+ id: zod_1.z.string().describe('The resource this action targets (an account ID, claim ID, lease ID, etc.).'),
10
+ type: zod_1.z.string().optional().describe('The resource\'s type, if relevant, e.g. CHECKING, INSURANCE_CLAIM, PROPERTY.'),
11
+ }),
12
+ context: zod_1.z.record(zod_1.z.unknown()).optional().describe('Free-form domain data, e.g. { amount: 500 } for ceiling-based autonomy, or any other key a customer-authored ' +
13
+ 'rule may reference as context.<key>. Not interpreted by name except "amount".'),
14
+ endUserId: zod_1.z.string().optional().describe('The retail customer this call is on behalf of, if applicable -- gates on their consent.'),
15
+ });
16
+ /**
17
+ * Wraps AuthentifyClient.authorize() as a LangChain tool, so an agent can
18
+ * call Authentify's authorization gate as a native tool call instead of
19
+ * the surrounding application hand-rolling a fetch inside a custom tool.
20
+ *
21
+ * The tool's observation is the raw JSON result: `decision` is
22
+ * `'allow' | 'deny' | 'escalate'` -- treat `escalate` as "not yet
23
+ * approved, on record for human review" rather than a denial (an
24
+ * `approvalRequestId` is included when escalated).
25
+ */
26
+ function createAuthentifyAuthorizeTool(client) {
27
+ return new tools_1.DynamicStructuredTool({
28
+ name: 'authentify_authorize',
29
+ description: "Check whether the current agent is authorized to perform an action via Authentify. " +
30
+ "Call this before taking any action that requires authorization (e.g. reading account data, " +
31
+ "transferring funds, approving a claim). Returns { authorizationRequestId, decision, reason, ... } " +
32
+ "where decision is 'allow', 'deny', or 'escalate' -- 'escalate' means the request is on record " +
33
+ "awaiting human approval, not a denial.",
34
+ schema: authorizeSchema,
35
+ func: async (input) => {
36
+ const result = await client.authorize(input);
37
+ return JSON.stringify(result);
38
+ },
39
+ });
40
+ }
package/package.json CHANGED
@@ -1,6 +1,36 @@
1
1
  {
2
2
  "name": "@authentify2026/langchain",
3
- "version": "0.0.0-stage",
4
- "stub": true,
5
- "description": "Temporary package placeholder for staged publishing"
6
- }
3
+ "version": "0.2.0",
4
+ "description": "LangChain tool wrapper for the Authentify authorization API",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "typecheck": "tsc --noEmit"
13
+ },
14
+ "license": "MIT",
15
+ "engines": {
16
+ "node": ">=18"
17
+ },
18
+ "dependencies": {
19
+ "@authentify2026/sdk": "^0.1.0"
20
+ },
21
+ "peerDependencies": {
22
+ "@langchain/core": ">=0.2.0",
23
+ "zod": "3.23.8"
24
+ },
25
+ "devDependencies": {
26
+ "@langchain/core": "^1.2.13",
27
+ "@types/node": "^20.0.0",
28
+ "typescript": "^5.5.0",
29
+ "zod": "3.23.8"
30
+ },
31
+ "publishConfig": {
32
+ "access": "public"
33
+ },
34
+ "homepage": "https://authentify.bz/integration",
35
+ "author": "4Sure Technologies LLC"
36
+ }