@semiotic-labs/agentium-sdk 0.2.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/dist/index.d.ts +64 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +58 -0
- package/dist/index.js.map +1 -0
- package/package.json +7 -1
package/dist/index.d.ts
ADDED
|
@@ -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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@semiotic-labs/agentium-sdk",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.1",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "",
|
|
6
6
|
"main": "dist/index.js",
|
|
@@ -25,6 +25,12 @@
|
|
|
25
25
|
},
|
|
26
26
|
"keywords": [],
|
|
27
27
|
"author": "",
|
|
28
|
+
"exports": {
|
|
29
|
+
".": {
|
|
30
|
+
"import": "./dist/index.js",
|
|
31
|
+
"require": "./dist/index.js"
|
|
32
|
+
}
|
|
33
|
+
},
|
|
28
34
|
"license": "MIT",
|
|
29
35
|
"bugs": {
|
|
30
36
|
"url": "https://github.com/semiotic-agentium/agentium-sdk/issues"
|