agntcy-dir 0.3.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/README.md +119 -0
- package/dist/agntcy-dir.d.ts +2619 -0
- package/dist/index.cjs +10869 -0
- package/dist/index.mjs +10843 -0
- package/dist/index.mjs.map +1 -0
- package/package.json +78 -0
package/README.md
ADDED
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# Directory JavaScript SDK
|
|
2
|
+
|
|
3
|
+
## Overview
|
|
4
|
+
|
|
5
|
+
Dir JavaScript SDK provides a simple way to interact with the Directory API.
|
|
6
|
+
It allows developers to integrate and use Directory functionality from their applications with ease.
|
|
7
|
+
The SDK supports both JavaScript and TypeScript applications.
|
|
8
|
+
|
|
9
|
+
**Note for users:** The SDK is intended for use in Node.js applications and will not work in Web applications.
|
|
10
|
+
|
|
11
|
+
## Features
|
|
12
|
+
|
|
13
|
+
The Directory SDK provides comprehensive access to all Directory APIs with a simple, intuitive interface:
|
|
14
|
+
|
|
15
|
+
### **Store API**
|
|
16
|
+
- **Record Management**: Push records to the store and pull them by reference
|
|
17
|
+
- **Metadata Operations**: Look up record metadata without downloading full content
|
|
18
|
+
- **Data Lifecycle**: Delete records permanently from the store
|
|
19
|
+
- **Referrer Support**: Push and pull artifacts for existing records
|
|
20
|
+
- **Sync Management**: Manage storage synchronization policies between Directory servers
|
|
21
|
+
|
|
22
|
+
### **Search API**
|
|
23
|
+
- **Flexible Search**: Search stored records using text, semantic, and structured queries
|
|
24
|
+
- **Advanced Filtering**: Filter results by metadata, content type, and other criteria
|
|
25
|
+
|
|
26
|
+
### **Routing API**
|
|
27
|
+
- **Network Publishing**: Publish records to make them discoverable across the network
|
|
28
|
+
- **Content Discovery**: List and query published records across the network
|
|
29
|
+
- **Network Management**: Unpublish records to remove them from network discovery
|
|
30
|
+
|
|
31
|
+
### **Signing and Verification**
|
|
32
|
+
- **Local Signing**: Sign records locally using private keys or OIDC-based authentication.
|
|
33
|
+
Requires [dirctl](https://github.com/agntcy/dir/releases) binary to perform signing.
|
|
34
|
+
- **Remote Verification**: Verify record signatures using the Directory gRPC API
|
|
35
|
+
|
|
36
|
+
### **Developer Experience**
|
|
37
|
+
- **Type Safety**: Full type hints for better IDE support and fewer runtime errors
|
|
38
|
+
- **Async Support**: Non-blocking operations with streaming responses for large datasets
|
|
39
|
+
- **Error Handling**: Comprehensive gRPC error handling with detailed error messages
|
|
40
|
+
- **Configuration**: Flexible configuration via environment variables or direct instantiation
|
|
41
|
+
|
|
42
|
+
## Installation
|
|
43
|
+
|
|
44
|
+
Install the SDK using one of available JS package managers like [npm](https://www.npmjs.com/)
|
|
45
|
+
|
|
46
|
+
1. Initialize the project:
|
|
47
|
+
```bash
|
|
48
|
+
npm init -y
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
2. Add the SDK to your project:
|
|
52
|
+
```bash
|
|
53
|
+
npm install agntcy-dir
|
|
54
|
+
```
|
|
55
|
+
|
|
56
|
+
## Configuration
|
|
57
|
+
|
|
58
|
+
The SDK can be configured via environment variables or direct instantiation:
|
|
59
|
+
|
|
60
|
+
```js
|
|
61
|
+
// Environment variables
|
|
62
|
+
process.env.DIRECTORY_CLIENT_SERVER_ADDRESS = "localhost:8888";
|
|
63
|
+
process.env.DIRCTL_PATH = "/path/to/dirctl";
|
|
64
|
+
|
|
65
|
+
// Or configure directly
|
|
66
|
+
import {Config, Client} from 'agntcy-dir';
|
|
67
|
+
|
|
68
|
+
const config = new Config(
|
|
69
|
+
serverAddress="localhost:8888",
|
|
70
|
+
dirctlPath="/usr/local/bin/dirctl"
|
|
71
|
+
);
|
|
72
|
+
const client = new Client(config);
|
|
73
|
+
|
|
74
|
+
// Use SPIRE for mTLS communication
|
|
75
|
+
const config = new Config(spiffeEndpointSocket="/tmp/agent.sock");
|
|
76
|
+
const transport = await Client.createGRPCTransport(config);
|
|
77
|
+
const spiffeClient = new Client(config, transport);
|
|
78
|
+
```
|
|
79
|
+
|
|
80
|
+
## Getting Started
|
|
81
|
+
|
|
82
|
+
### Prerequisites
|
|
83
|
+
|
|
84
|
+
- [NodeJS](https://nodejs.org/en/) - JavaScript runtime
|
|
85
|
+
- [npm](https://www.npmjs.com/) - Package manager
|
|
86
|
+
- [dirctl](https://github.com/agntcy/dir/releases) - Directory CLI binary
|
|
87
|
+
- Directory server instance (see setup below)
|
|
88
|
+
|
|
89
|
+
### 1. Server Setup
|
|
90
|
+
|
|
91
|
+
**Option A: Local Development Server**
|
|
92
|
+
|
|
93
|
+
```bash
|
|
94
|
+
# Clone the repository and start the server using Taskfile
|
|
95
|
+
task server:start
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Option B: Custom Server**
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
# Set your Directory server address
|
|
102
|
+
export DIRECTORY_CLIENT_SERVER_ADDRESS="your-server:8888"
|
|
103
|
+
```
|
|
104
|
+
|
|
105
|
+
### 2. SDK Installation
|
|
106
|
+
|
|
107
|
+
```bash
|
|
108
|
+
# Add the Directory SDK
|
|
109
|
+
npm install agntcy-dir
|
|
110
|
+
```
|
|
111
|
+
|
|
112
|
+
### Usage Examples
|
|
113
|
+
|
|
114
|
+
See the [Example JavaScript Project](../examples/example-js/) for a complete working example that demonstrates all SDK features.
|
|
115
|
+
|
|
116
|
+
```bash
|
|
117
|
+
npm install
|
|
118
|
+
npm run example
|
|
119
|
+
```
|