@semiotic-labs/agentium-sdk 0.1.0 → 0.2.1

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/README.md CHANGED
@@ -1 +1,117 @@
1
- # agentium-sdk
1
+ <!--
2
+ SPDX-FileCopyrightText: 2025 Semiotic AI, Inc.
3
+
4
+ SPDX-License-Identifier: MIT
5
+ -->
6
+
7
+ # @semiotic-labs/agentium-sdk
8
+
9
+ A TypeScript SDK to simplify interaction with the `/v1/identity/connect` API endpoint.
10
+
11
+ ## Installation
12
+
13
+ Install the package using npm:
14
+
15
+ ```bash
16
+ npm install @semiotic-labs/agentium-sdk
17
+ ```
18
+
19
+ ## Usage
20
+
21
+ ### Basic Usage
22
+
23
+ To connect to the default production API:
24
+
25
+ ```typescript
26
+ import { AgentiumClient } from '@semiotic-labs/agentium-sdk';
27
+
28
+ const client = new AgentiumClient();
29
+
30
+ async function connectIdentity() {
31
+ try {
32
+ const googleToken = 'YOUR_GOOGLE_JWT'; // Replace with your actual Google JWT
33
+ const response = await client.connectGoogleIdentity(googleToken);
34
+ console.log('Connected Identity:', response);
35
+ } catch (error) {
36
+ console.error('Failed to connect identity:', error);
37
+ }
38
+ }
39
+
40
+ connectIdentity();
41
+ ```
42
+
43
+ ### Advanced Usage: Custom Endpoint
44
+
45
+ You can specify a custom `baseURL` in the constructor, which is useful for testing against local or staging environments.
46
+
47
+ ```typescript
48
+ import { AgentiumClient } from '@semiotic-labs/agentium-sdk';
49
+
50
+ // Example for a local development server
51
+ const localClient = new AgentiumClient({
52
+ baseURL: 'http://localhost:8080',
53
+ });
54
+
55
+ async function connectIdentityLocal() {
56
+ try {
57
+ const googleToken = 'YOUR_GOOGLE_JWT';
58
+ const response = await localClient.connectGoogleIdentity(googleToken);
59
+ console.log('Connected Identity (Local):', response);
60
+ } catch (error) {
61
+ console.error('Failed to connect identity (Local):', error);
62
+ }
63
+ }
64
+
65
+ connectIdentityLocal();
66
+ ```
67
+
68
+ ## For Developers
69
+
70
+ ### Project Setup
71
+
72
+ 1. Clone the repository.
73
+ 2. Install dependencies:
74
+ ```bash
75
+ npm install
76
+ ```
77
+
78
+ ### REUSE Compliance
79
+
80
+ This project follows the [REUSE Specification](https://reuse.software/spec/). To ensure compliance:
81
+
82
+ 1. **Install REUSE Tool:** You'll need to install the `reuse` command-line tool globally via `pip`:
83
+ ```bash
84
+ pip install reuse
85
+ ```
86
+
87
+ ### Applying SPDX Headers
88
+
89
+ To add or update SPDX license and copyright headers to all relevant files:
90
+
91
+ ```bash
92
+ npm run reuse:write
93
+ ```
94
+
95
+ ### Verify Compliance
96
+
97
+ To check if the project is fully REUSE compliant:
98
+
99
+ ```bash
100
+ npm run reuse:check
101
+ ```
102
+
103
+ ### Running Tests
104
+
105
+ To run the test suite:
106
+
107
+ ```bash
108
+ npm test
109
+ ```
110
+
111
+ ### Building the Project
112
+
113
+ To compile the TypeScript code into JavaScript in the `dist` folder:
114
+
115
+ ```bash
116
+ npm run build
117
+ ```
@@ -0,0 +1,64 @@
1
+ /**
2
+ * Options for configuring the AgentiumClient.
3
+ */
4
+ export interface AgentiumClientOptions {
5
+ /**
6
+ * The base URL of the Agentium API.
7
+ * @default https://api.agentium.network
8
+ */
9
+ baseURL?: string;
10
+ }
11
+ /**
12
+ * Represents the status of a user's badge.
13
+ */
14
+ export interface Badge {
15
+ status: string;
16
+ }
17
+ /**
18
+ * The response payload from a successful connect identity call.
19
+ */
20
+ export interface ConnectIdentityResponse {
21
+ /**
22
+ * The user's Privy ID.
23
+ */
24
+ privy_user_id: string;
25
+ /**
26
+ * The user's Decentralized Identifier (DID).
27
+ */
28
+ did: string;
29
+ /**
30
+ * Information about the user's badge status.
31
+ */
32
+ badge: Badge;
33
+ }
34
+ /**
35
+ * Custom error class for API-related errors from the AgentiumClient.
36
+ */
37
+ export declare class AgentiumApiError extends Error {
38
+ readonly statusCode: number | undefined;
39
+ constructor(message: string, statusCode?: number);
40
+ }
41
+ /**
42
+ * A client for interacting with the Agentium API.
43
+ */
44
+ export declare class AgentiumClient {
45
+ private readonly axiosInstance;
46
+ private readonly DEFAULT_BASE_URL;
47
+ private readonly CONNECT_PATH;
48
+ /**
49
+ * Creates an instance of the AgentiumClient.
50
+ * @param options - Configuration options for the client.
51
+ */
52
+ constructor(options?: AgentiumClientOptions);
53
+ /**
54
+ * Connects a Google identity to an Agentium identity.
55
+ * @param googleToken - The JWT token obtained from Google Sign-In.
56
+ * @returns A promise that resolves with the connection response, containing the user's DID and Privy ID.
57
+ * @throws {AgentiumApiError} Will throw a custom API error if the call fails.
58
+ * - **400 (Bad Request):** The request was malformed (e.g., missing `id_token`).
59
+ * - **401 (Unauthorized):** The provided JWT token is invalid or expired.
60
+ * - **500 (Internal Server Error):** An unexpected error occurred on the server.
61
+ */
62
+ connectGoogleIdentity(googleToken: string): Promise<ConnectIdentityResponse>;
63
+ }
64
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAMA;;GAEG;AACH,MAAM,WAAW,qBAAqB;IACpC;;;OAGG;IACH,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAED;;GAEG;AACH,MAAM,WAAW,KAAK;IACpB,MAAM,EAAE,MAAM,CAAC;CAChB;AAED;;GAEG;AACH,MAAM,WAAW,uBAAuB;IACtC;;OAEG;IACH,aAAa,EAAE,MAAM,CAAC;IACtB;;OAEG;IACH,GAAG,EAAE,MAAM,CAAC;IACZ;;OAEG;IACH,KAAK,EAAE,KAAK,CAAC;CACd;AAED;;GAEG;AACH,qBAAa,gBAAiB,SAAQ,KAAK;IACzC,SAAgB,UAAU,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEnC,OAAO,EAAE,MAAM,EAAE,UAAU,CAAC,EAAE,MAAM;CAKjD;AAED;;GAEG;AACH,qBAAa,cAAc;IACzB,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAgB;IAC9C,OAAO,CAAC,QAAQ,CAAC,gBAAgB,CAAkC;IACnE,OAAO,CAAC,QAAQ,CAAC,YAAY,CAA0B;IAEvD;;;OAGG;gBACS,OAAO,GAAE,qBAA0B;IAO/C;;;;;;;;OAQG;IACG,qBAAqB,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,uBAAuB,CAAC;CAcnF"}
package/dist/index.js ADDED
@@ -0,0 +1,58 @@
1
+ // SPDX-FileCopyrightText: 2025 Semiotic AI, Inc.
2
+ //
3
+ // SPDX-License-Identifier: MIT
4
+ import axios, { isAxiosError } from 'axios';
5
+ /**
6
+ * Custom error class for API-related errors from the AgentiumClient.
7
+ */
8
+ export class AgentiumApiError extends Error {
9
+ statusCode;
10
+ constructor(message, statusCode) {
11
+ super(message);
12
+ this.name = 'AgentiumApiError';
13
+ this.statusCode = statusCode;
14
+ }
15
+ }
16
+ /**
17
+ * A client for interacting with the Agentium API.
18
+ */
19
+ export class AgentiumClient {
20
+ axiosInstance;
21
+ DEFAULT_BASE_URL = 'https://api.agentium.network';
22
+ CONNECT_PATH = '/v1/identity/connect';
23
+ /**
24
+ * Creates an instance of the AgentiumClient.
25
+ * @param options - Configuration options for the client.
26
+ */
27
+ constructor(options = {}) {
28
+ const baseURL = options.baseURL || this.DEFAULT_BASE_URL;
29
+ this.axiosInstance = axios.create({
30
+ baseURL: baseURL,
31
+ });
32
+ }
33
+ /**
34
+ * Connects a Google identity to an Agentium identity.
35
+ * @param googleToken - The JWT token obtained from Google Sign-In.
36
+ * @returns A promise that resolves with the connection response, containing the user's DID and Privy ID.
37
+ * @throws {AgentiumApiError} Will throw a custom API error if the call fails.
38
+ * - **400 (Bad Request):** The request was malformed (e.g., missing `id_token`).
39
+ * - **401 (Unauthorized):** The provided JWT token is invalid or expired.
40
+ * - **500 (Internal Server Error):** An unexpected error occurred on the server.
41
+ */
42
+ async connectGoogleIdentity(googleToken) {
43
+ try {
44
+ const response = await this.axiosInstance.post(this.CONNECT_PATH, {
45
+ id_token: googleToken,
46
+ });
47
+ return response.data;
48
+ }
49
+ catch (error) {
50
+ if (isAxiosError(error)) {
51
+ throw new AgentiumApiError(error.message, error.response?.status);
52
+ }
53
+ // Re-throw other unexpected errors
54
+ throw error;
55
+ }
56
+ }
57
+ }
58
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,iDAAiD;AACjD,EAAE;AACF,+BAA+B;AAE/B,OAAO,KAAK,EAAE,EAAE,YAAY,EAAsB,MAAM,OAAO,CAAC;AAsChE;;GAEG;AACH,MAAM,OAAO,gBAAiB,SAAQ,KAAK;IACzB,UAAU,CAAqB;IAE/C,YAAY,OAAe,EAAE,UAAmB;QAC9C,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,kBAAkB,CAAC;QAC/B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;IAC/B,CAAC;CACF;AAED;;GAEG;AACH,MAAM,OAAO,cAAc;IACR,aAAa,CAAgB;IAC7B,gBAAgB,GAAG,8BAA8B,CAAC;IAClD,YAAY,GAAG,sBAAsB,CAAC;IAEvD;;;OAGG;IACH,YAAY,UAAiC,EAAE;QAC7C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,IAAI,IAAI,CAAC,gBAAgB,CAAC;QACzD,IAAI,CAAC,aAAa,GAAG,KAAK,CAAC,MAAM,CAAC;YAChC,OAAO,EAAE,OAAO;SACjB,CAAC,CAAC;IACL,CAAC;IAED;;;;;;;;OAQG;IACH,KAAK,CAAC,qBAAqB,CAAC,WAAmB;QAC7C,IAAI,CAAC;YACH,MAAM,QAAQ,GAAG,MAAM,IAAI,CAAC,aAAa,CAAC,IAAI,CAA0B,IAAI,CAAC,YAAY,EAAE;gBACzF,QAAQ,EAAE,WAAW;aACtB,CAAC,CAAC;YACH,OAAO,QAAQ,CAAC,IAAI,CAAC;QACvB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,IAAI,YAAY,CAAC,KAAK,CAAC,EAAE,CAAC;gBACxB,MAAM,IAAI,gBAAgB,CAAC,KAAK,CAAC,OAAO,EAAE,KAAK,CAAC,QAAQ,EAAE,MAAM,CAAC,CAAC;YACpE,CAAC;YACD,mCAAmC;YACnC,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC;CACF"}
package/package.json CHANGED
@@ -1,10 +1,23 @@
1
1
  {
2
2
  "name": "@semiotic-labs/agentium-sdk",
3
- "version": "0.1.0",
3
+ "version": "0.2.1",
4
+ "type": "module",
4
5
  "description": "",
5
- "main": "index.js",
6
+ "main": "dist/index.js",
7
+ "types": "dist/index.d.ts",
8
+ "files": [
9
+ "dist"
10
+ ],
6
11
  "scripts": {
7
- "test": "echo \"Error: no test specified\" && exit 1"
12
+ "test": "vitest",
13
+ "build": "tsc",
14
+ "docs": "typedoc",
15
+ "lint": "eslint src/**/*.ts",
16
+ "format:check": "prettier --check .",
17
+ "format:write": "prettier --write .",
18
+ "check": "npm run lint && npm run format:check",
19
+ "reuse:check": "reuse lint",
20
+ "reuse:write": "reuse annotate --license MIT --copyright \"Semiotic AI, Inc.\" --year 2025 -r . --fallback-dot-license --skip-existing"
8
21
  },
9
22
  "repository": {
10
23
  "type": "git",
@@ -12,9 +25,34 @@
12
25
  },
13
26
  "keywords": [],
14
27
  "author": "",
28
+ "exports": {
29
+ ".": {
30
+ "import": "./dist/index.js",
31
+ "require": "./dist/index.js"
32
+ }
33
+ },
15
34
  "license": "MIT",
16
35
  "bugs": {
17
36
  "url": "https://github.com/semiotic-agentium/agentium-sdk/issues"
18
37
  },
19
- "homepage": "https://github.com/semiotic-agentium/agentium-sdk#readme"
38
+ "homepage": "https://github.com/semiotic-agentium/agentium-sdk#readme",
39
+ "engines": {
40
+ "node": ">=22.0.0"
41
+ },
42
+ "devDependencies": {
43
+ "@types/node": "^24.10.1",
44
+ "axios-mock-adapter": "^2.1.0",
45
+ "eslint": "^9.39.1",
46
+ "eslint-config-prettier": "^10.1.8",
47
+ "eslint-plugin-prettier": "^5.5.4",
48
+ "prettier": "^3.7.4",
49
+ "ts-node": "^10.9.2",
50
+ "typedoc": "^0.28.15",
51
+ "typescript": "^5.9.3",
52
+ "typescript-eslint": "^8.48.1",
53
+ "vitest": "^4.0.15"
54
+ },
55
+ "dependencies": {
56
+ "axios": "^1.13.2"
57
+ }
20
58
  }