auth-agents 0.1.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 Zeliang Cheng
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.
@@ -0,0 +1,114 @@
1
+ interface AuthAgentsConfig {
2
+ /** Base URL of the Auth-Agents API. Defaults to https://auth.auth-agents.com */
3
+ baseUrl?: string;
4
+ }
5
+ interface VerifyResult {
6
+ valid: true;
7
+ did: string;
8
+ agent_name: string | null;
9
+ agent_model: string | null;
10
+ agent_provider: string | null;
11
+ agent_purpose: string | null;
12
+ key_fingerprint: string | null;
13
+ issued_at: string | null;
14
+ expires_at: string | null;
15
+ }
16
+ interface VerifyError {
17
+ valid: false;
18
+ error: "credential_expired" | "invalid_issuer" | "signature_invalid";
19
+ message: string;
20
+ }
21
+ type VerifyResponse = VerifyResult | VerifyError;
22
+ interface RegisterInput {
23
+ agent_name: string;
24
+ agent_model: string;
25
+ agent_provider: string;
26
+ agent_purpose: string;
27
+ public_key_jwk?: {
28
+ kty: string;
29
+ crv: string;
30
+ x: string;
31
+ };
32
+ }
33
+ interface RegisterResult {
34
+ did: string;
35
+ credential: string;
36
+ key_fingerprint: string;
37
+ private_key_jwk?: {
38
+ kty: string;
39
+ crv: string;
40
+ x: string;
41
+ d: string;
42
+ };
43
+ _notice?: string;
44
+ }
45
+ interface ChallengeResult {
46
+ challenge_id: string;
47
+ nonce: string;
48
+ expires_in: number;
49
+ }
50
+ interface AuthVerifyInput {
51
+ challenge_id: string;
52
+ did: string;
53
+ signature: string;
54
+ }
55
+ interface AuthVerifyResult {
56
+ valid: true;
57
+ session_token: string;
58
+ credential: string;
59
+ agent: {
60
+ did: string;
61
+ agent_name: string;
62
+ agent_model: string;
63
+ agent_provider: string;
64
+ agent_purpose: string;
65
+ key_fingerprint: string;
66
+ };
67
+ expires_in: number;
68
+ }
69
+ interface AuthVerifyError {
70
+ valid: false;
71
+ error: string;
72
+ message: string;
73
+ }
74
+ type AuthVerifyResponse = AuthVerifyResult | AuthVerifyError;
75
+ declare class AuthAgents {
76
+ private baseUrl;
77
+ constructor(config?: AuthAgentsConfig);
78
+ /**
79
+ * Verify a VC-JWT credential issued by Auth-Agents.
80
+ *
81
+ * @param credential - The VC-JWT string from the agent
82
+ * @returns Verified agent identity or error details
83
+ */
84
+ verify(credential: string): Promise<VerifyResponse>;
85
+ /**
86
+ * Register a new agent identity. The server generates an Ed25519 keypair
87
+ * and returns a DID, credential, and private key.
88
+ *
89
+ * @param input - Agent metadata (name, model, provider, purpose)
90
+ * @returns DID, credential, and private key (save securely!)
91
+ */
92
+ register(input: RegisterInput): Promise<RegisterResult>;
93
+ /**
94
+ * Request an authentication challenge nonce.
95
+ *
96
+ * @param did - The agent's DID
97
+ * @returns Challenge ID and nonce to sign
98
+ */
99
+ challenge(did: string): Promise<ChallengeResult>;
100
+ /**
101
+ * Submit a signed challenge to authenticate and receive a fresh credential.
102
+ *
103
+ * @param input - challenge_id, did, and base64url signature
104
+ * @returns Session token and fresh VC-JWT credential
105
+ */
106
+ authenticate(input: AuthVerifyInput): Promise<AuthVerifyResponse>;
107
+ }
108
+ /**
109
+ * Verify a credential with default settings.
110
+ * Shorthand for `new AuthAgents().verify(credential)`.
111
+ */
112
+ declare function verify(credential: string): Promise<VerifyResponse>;
113
+
114
+ export { AuthAgents, type AuthAgentsConfig, type AuthVerifyError, type AuthVerifyInput, type AuthVerifyResponse, type AuthVerifyResult, type ChallengeResult, type RegisterInput, type RegisterResult, type VerifyError, type VerifyResponse, type VerifyResult, verify };
@@ -0,0 +1,114 @@
1
+ interface AuthAgentsConfig {
2
+ /** Base URL of the Auth-Agents API. Defaults to https://auth.auth-agents.com */
3
+ baseUrl?: string;
4
+ }
5
+ interface VerifyResult {
6
+ valid: true;
7
+ did: string;
8
+ agent_name: string | null;
9
+ agent_model: string | null;
10
+ agent_provider: string | null;
11
+ agent_purpose: string | null;
12
+ key_fingerprint: string | null;
13
+ issued_at: string | null;
14
+ expires_at: string | null;
15
+ }
16
+ interface VerifyError {
17
+ valid: false;
18
+ error: "credential_expired" | "invalid_issuer" | "signature_invalid";
19
+ message: string;
20
+ }
21
+ type VerifyResponse = VerifyResult | VerifyError;
22
+ interface RegisterInput {
23
+ agent_name: string;
24
+ agent_model: string;
25
+ agent_provider: string;
26
+ agent_purpose: string;
27
+ public_key_jwk?: {
28
+ kty: string;
29
+ crv: string;
30
+ x: string;
31
+ };
32
+ }
33
+ interface RegisterResult {
34
+ did: string;
35
+ credential: string;
36
+ key_fingerprint: string;
37
+ private_key_jwk?: {
38
+ kty: string;
39
+ crv: string;
40
+ x: string;
41
+ d: string;
42
+ };
43
+ _notice?: string;
44
+ }
45
+ interface ChallengeResult {
46
+ challenge_id: string;
47
+ nonce: string;
48
+ expires_in: number;
49
+ }
50
+ interface AuthVerifyInput {
51
+ challenge_id: string;
52
+ did: string;
53
+ signature: string;
54
+ }
55
+ interface AuthVerifyResult {
56
+ valid: true;
57
+ session_token: string;
58
+ credential: string;
59
+ agent: {
60
+ did: string;
61
+ agent_name: string;
62
+ agent_model: string;
63
+ agent_provider: string;
64
+ agent_purpose: string;
65
+ key_fingerprint: string;
66
+ };
67
+ expires_in: number;
68
+ }
69
+ interface AuthVerifyError {
70
+ valid: false;
71
+ error: string;
72
+ message: string;
73
+ }
74
+ type AuthVerifyResponse = AuthVerifyResult | AuthVerifyError;
75
+ declare class AuthAgents {
76
+ private baseUrl;
77
+ constructor(config?: AuthAgentsConfig);
78
+ /**
79
+ * Verify a VC-JWT credential issued by Auth-Agents.
80
+ *
81
+ * @param credential - The VC-JWT string from the agent
82
+ * @returns Verified agent identity or error details
83
+ */
84
+ verify(credential: string): Promise<VerifyResponse>;
85
+ /**
86
+ * Register a new agent identity. The server generates an Ed25519 keypair
87
+ * and returns a DID, credential, and private key.
88
+ *
89
+ * @param input - Agent metadata (name, model, provider, purpose)
90
+ * @returns DID, credential, and private key (save securely!)
91
+ */
92
+ register(input: RegisterInput): Promise<RegisterResult>;
93
+ /**
94
+ * Request an authentication challenge nonce.
95
+ *
96
+ * @param did - The agent's DID
97
+ * @returns Challenge ID and nonce to sign
98
+ */
99
+ challenge(did: string): Promise<ChallengeResult>;
100
+ /**
101
+ * Submit a signed challenge to authenticate and receive a fresh credential.
102
+ *
103
+ * @param input - challenge_id, did, and base64url signature
104
+ * @returns Session token and fresh VC-JWT credential
105
+ */
106
+ authenticate(input: AuthVerifyInput): Promise<AuthVerifyResponse>;
107
+ }
108
+ /**
109
+ * Verify a credential with default settings.
110
+ * Shorthand for `new AuthAgents().verify(credential)`.
111
+ */
112
+ declare function verify(credential: string): Promise<VerifyResponse>;
113
+
114
+ export { AuthAgents, type AuthAgentsConfig, type AuthVerifyError, type AuthVerifyInput, type AuthVerifyResponse, type AuthVerifyResult, type ChallengeResult, type RegisterInput, type RegisterResult, type VerifyError, type VerifyResponse, type VerifyResult, verify };
package/dist/index.js ADDED
@@ -0,0 +1,112 @@
1
+ "use strict";
2
+ var __defProp = Object.defineProperty;
3
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
4
+ var __getOwnPropNames = Object.getOwnPropertyNames;
5
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
6
+ var __export = (target, all) => {
7
+ for (var name in all)
8
+ __defProp(target, name, { get: all[name], enumerable: true });
9
+ };
10
+ var __copyProps = (to, from, except, desc) => {
11
+ if (from && typeof from === "object" || typeof from === "function") {
12
+ for (let key of __getOwnPropNames(from))
13
+ if (!__hasOwnProp.call(to, key) && key !== except)
14
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
15
+ }
16
+ return to;
17
+ };
18
+ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
19
+
20
+ // src/index.ts
21
+ var index_exports = {};
22
+ __export(index_exports, {
23
+ AuthAgents: () => AuthAgents,
24
+ verify: () => verify
25
+ });
26
+ module.exports = __toCommonJS(index_exports);
27
+ var DEFAULT_BASE_URL = "https://auth.auth-agents.com";
28
+ var AuthAgents = class {
29
+ constructor(config) {
30
+ this.baseUrl = (config?.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
31
+ }
32
+ // ---- Credential Verification (for websites) ----------------------------
33
+ /**
34
+ * Verify a VC-JWT credential issued by Auth-Agents.
35
+ *
36
+ * @param credential - The VC-JWT string from the agent
37
+ * @returns Verified agent identity or error details
38
+ */
39
+ async verify(credential) {
40
+ const res = await fetch(`${this.baseUrl}/v1/credentials/verify`, {
41
+ method: "POST",
42
+ headers: { "Content-Type": "application/json" },
43
+ body: JSON.stringify({ credential })
44
+ });
45
+ return res.json();
46
+ }
47
+ // ---- Agent Registration ------------------------------------------------
48
+ /**
49
+ * Register a new agent identity. The server generates an Ed25519 keypair
50
+ * and returns a DID, credential, and private key.
51
+ *
52
+ * @param input - Agent metadata (name, model, provider, purpose)
53
+ * @returns DID, credential, and private key (save securely!)
54
+ */
55
+ async register(input) {
56
+ const res = await fetch(`${this.baseUrl}/v1/identities`, {
57
+ method: "POST",
58
+ headers: { "Content-Type": "application/json" },
59
+ body: JSON.stringify(input)
60
+ });
61
+ if (!res.ok) {
62
+ const body = await res.json().catch(() => ({}));
63
+ throw new Error(
64
+ body.error ?? `Registration failed (${res.status})`
65
+ );
66
+ }
67
+ return res.json();
68
+ }
69
+ // ---- Challenge-Response Auth -------------------------------------------
70
+ /**
71
+ * Request an authentication challenge nonce.
72
+ *
73
+ * @param did - The agent's DID
74
+ * @returns Challenge ID and nonce to sign
75
+ */
76
+ async challenge(did) {
77
+ const res = await fetch(`${this.baseUrl}/v1/auth/challenge`, {
78
+ method: "POST",
79
+ headers: { "Content-Type": "application/json" },
80
+ body: JSON.stringify({ did })
81
+ });
82
+ if (!res.ok) {
83
+ const body = await res.json().catch(() => ({}));
84
+ throw new Error(
85
+ body.error ?? `Challenge failed (${res.status})`
86
+ );
87
+ }
88
+ return res.json();
89
+ }
90
+ /**
91
+ * Submit a signed challenge to authenticate and receive a fresh credential.
92
+ *
93
+ * @param input - challenge_id, did, and base64url signature
94
+ * @returns Session token and fresh VC-JWT credential
95
+ */
96
+ async authenticate(input) {
97
+ const res = await fetch(`${this.baseUrl}/v1/auth/verify`, {
98
+ method: "POST",
99
+ headers: { "Content-Type": "application/json" },
100
+ body: JSON.stringify(input)
101
+ });
102
+ return res.json();
103
+ }
104
+ };
105
+ async function verify(credential) {
106
+ return new AuthAgents().verify(credential);
107
+ }
108
+ // Annotate the CommonJS export names for ESM import in node:
109
+ 0 && (module.exports = {
110
+ AuthAgents,
111
+ verify
112
+ });
package/dist/index.mjs ADDED
@@ -0,0 +1,86 @@
1
+ // src/index.ts
2
+ var DEFAULT_BASE_URL = "https://auth.auth-agents.com";
3
+ var AuthAgents = class {
4
+ constructor(config) {
5
+ this.baseUrl = (config?.baseUrl ?? DEFAULT_BASE_URL).replace(/\/+$/, "");
6
+ }
7
+ // ---- Credential Verification (for websites) ----------------------------
8
+ /**
9
+ * Verify a VC-JWT credential issued by Auth-Agents.
10
+ *
11
+ * @param credential - The VC-JWT string from the agent
12
+ * @returns Verified agent identity or error details
13
+ */
14
+ async verify(credential) {
15
+ const res = await fetch(`${this.baseUrl}/v1/credentials/verify`, {
16
+ method: "POST",
17
+ headers: { "Content-Type": "application/json" },
18
+ body: JSON.stringify({ credential })
19
+ });
20
+ return res.json();
21
+ }
22
+ // ---- Agent Registration ------------------------------------------------
23
+ /**
24
+ * Register a new agent identity. The server generates an Ed25519 keypair
25
+ * and returns a DID, credential, and private key.
26
+ *
27
+ * @param input - Agent metadata (name, model, provider, purpose)
28
+ * @returns DID, credential, and private key (save securely!)
29
+ */
30
+ async register(input) {
31
+ const res = await fetch(`${this.baseUrl}/v1/identities`, {
32
+ method: "POST",
33
+ headers: { "Content-Type": "application/json" },
34
+ body: JSON.stringify(input)
35
+ });
36
+ if (!res.ok) {
37
+ const body = await res.json().catch(() => ({}));
38
+ throw new Error(
39
+ body.error ?? `Registration failed (${res.status})`
40
+ );
41
+ }
42
+ return res.json();
43
+ }
44
+ // ---- Challenge-Response Auth -------------------------------------------
45
+ /**
46
+ * Request an authentication challenge nonce.
47
+ *
48
+ * @param did - The agent's DID
49
+ * @returns Challenge ID and nonce to sign
50
+ */
51
+ async challenge(did) {
52
+ const res = await fetch(`${this.baseUrl}/v1/auth/challenge`, {
53
+ method: "POST",
54
+ headers: { "Content-Type": "application/json" },
55
+ body: JSON.stringify({ did })
56
+ });
57
+ if (!res.ok) {
58
+ const body = await res.json().catch(() => ({}));
59
+ throw new Error(
60
+ body.error ?? `Challenge failed (${res.status})`
61
+ );
62
+ }
63
+ return res.json();
64
+ }
65
+ /**
66
+ * Submit a signed challenge to authenticate and receive a fresh credential.
67
+ *
68
+ * @param input - challenge_id, did, and base64url signature
69
+ * @returns Session token and fresh VC-JWT credential
70
+ */
71
+ async authenticate(input) {
72
+ const res = await fetch(`${this.baseUrl}/v1/auth/verify`, {
73
+ method: "POST",
74
+ headers: { "Content-Type": "application/json" },
75
+ body: JSON.stringify(input)
76
+ });
77
+ return res.json();
78
+ }
79
+ };
80
+ async function verify(credential) {
81
+ return new AuthAgents().verify(credential);
82
+ }
83
+ export {
84
+ AuthAgents,
85
+ verify
86
+ };
package/package.json ADDED
@@ -0,0 +1,42 @@
1
+ {
2
+ "name": "auth-agents",
3
+ "version": "0.1.0",
4
+ "description": "Verify AI agent identities with Auth-Agents. DID-based authentication using Ed25519 and Verifiable Credentials.",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "exports": {
8
+ ".": {
9
+ "types": "./dist/index.d.ts",
10
+ "import": "./dist/index.mjs",
11
+ "require": "./dist/index.js"
12
+ }
13
+ },
14
+ "files": [
15
+ "dist"
16
+ ],
17
+ "scripts": {
18
+ "build": "tsup src/index.ts --format cjs,esm --dts --clean",
19
+ "prepublishOnly": "npm run build"
20
+ },
21
+ "keywords": [
22
+ "auth-agents",
23
+ "ai-agent",
24
+ "did",
25
+ "verifiable-credential",
26
+ "ed25519",
27
+ "authentication",
28
+ "identity",
29
+ "decentralized-identity"
30
+ ],
31
+ "author": "Zeliang Cheng",
32
+ "license": "MIT",
33
+ "repository": {
34
+ "type": "git",
35
+ "url": "https://github.com/AgenthAgent/auth-agents-sdk-node"
36
+ },
37
+ "homepage": "https://auth-agents.com",
38
+ "devDependencies": {
39
+ "tsup": "^8.0.0",
40
+ "typescript": "^5.0.0"
41
+ }
42
+ }