@t-0/provider-starter-ts 1.1.5 → 1.1.6

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,204 +1,95 @@
1
- # t-0 Network Provider Starter
1
+ # T-0 Provider Starter -- TypeScript
2
2
 
3
- CLI tool to quickly bootstrap a Node.js TypeScript integration service for the t-0 Network.
4
-
5
- ## Overview
6
-
7
- This CLI tool scaffolds a complete TypeScript project configured to integrate with the t-0 Network as a provider. It automatically generates secp256k1 cryptographic key pairs, sets up your development environment, and includes all necessary dependencies to get started immediately.
8
-
9
- ## Prerequisites
10
-
11
- Before using this tool, ensure you have:
12
-
13
- - **Node.js** >= 14.0.0
14
- - **npm** >= 6.0.0
15
- - **OpenSSL** (for cryptographic key generation)
3
+ CLI tool to scaffold a Node.js TypeScript provider project for the T-0 Network.
16
4
 
17
5
  ## Quick Start
18
6
 
19
- ### Using npx (Recommended)
20
-
21
- Run the following command to create a new t-0 Network integration:
22
-
23
7
  ```bash
24
8
  npx @t-0/provider-starter-ts
25
9
  ```
26
10
 
27
- ### Alternative: Global Installation
28
-
29
- ```bash
30
- npm install -g @t-0/provider-starter-ts
31
- provider-starter-ts
32
- ```
33
-
34
- ## What It Does
35
-
36
- When you run the CLI tool, it performs the following steps automatically:
37
-
38
- 1. **Interactive Prompt** - Asks for your project name
39
- 2. **Project Directory** - Creates a new directory with your project name
40
- 3. **Template Setup** - Copies pre-configured TypeScript project structure
41
- 4. **Key Generation** - Generates a secp256k1 cryptographic key pair using OpenSSL
42
- 5. **Environment Configuration** - Creates `.env` file with:
43
- - Generated private key (`PROVIDER_PRIVATE_KEY`)
44
- - Generated public key (as comment for reference)
45
- - t-0 Network public key (`NETWORK_PUBLIC_KEY`)
46
- - Server configuration (`PORT`, `NODE_ENV`)
47
- - Optional quote publishing interval
48
- 6. **Git Initialization** - Initializes git repository with `.gitignore`
49
- 7. **Dependency Installation** - Runs `npm install` to install all dependencies
11
+ The CLI will prompt for a project name, then create a ready-to-run project with a secp256k1 keypair (via OpenSSL), environment config, provider service stubs, and a Dockerfile.
50
12
 
51
13
  ## Generated Project Structure
52
14
 
53
- After running the CLI, your new project will have the following structure:
54
-
55
15
  ```
56
16
  your-project-name/
57
17
  ├── src/
58
- │ ├── index.ts # Main entry point
18
+ │ ├── index.ts # Entry point
59
19
  │ ├── service.ts # Provider service implementation
60
20
  │ ├── publish_quotes.ts # Quote publishing logic
61
21
  │ ├── get_quote.ts # Quote retrieval logic
62
22
  │ ├── submit_payment.ts # Payment submission logic
63
23
  │ └── lib.ts # Utility functions
24
+ ├── Dockerfile # Docker configuration
64
25
  ├── .env # Environment variables (with generated keys)
65
26
  ├── .env.example # Example environment file
66
- ├── .eslintrc.json # ESLint configuration
67
- ├── .gitignore # Git ignore rules
68
- ├── package.json # Project dependencies
69
- └── tsconfig.json # TypeScript configuration
27
+ ├── .eslintrc.json # ESLint configuration
28
+ ├── .gitignore # Git ignore rules
29
+ ├── package.json # Project dependencies
30
+ └── tsconfig.json # TypeScript configuration
70
31
  ```
71
32
 
72
- ## Environment Variables
73
-
74
- The generated `.env` file includes:
75
-
76
- | Variable | Description |
77
- |----------|-------------|
78
- | `NETWORK_PUBLIC_KEY` | t-0 Network's public key (pre-configured) |
79
- | `PROVIDER_PRIVATE_KEY` | Your generated private key (keep secret!) |
80
- | `PORT` | Server port (default: 3000) |
81
- | `NODE_ENV` | Environment mode (default: development) |
82
- | `TZERO_ENDPOINT` | t-0 Network API endpoint (default: sandbox) |
83
- | `QUOTE_PUBLISHING_INTERVAL` | Quote publishing frequency in ms (optional) |
84
-
85
- ## Available Scripts
86
-
87
- In your generated project, you can run:
88
-
89
- ### `npm run dev`
90
-
91
- Runs the service in development mode using `ts-node`.
92
-
93
- ### `npm run build`
33
+ ## Key Files to Modify
94
34
 
95
- Compiles TypeScript to JavaScript in the `dist/` directory.
35
+ | File | Purpose |
36
+ |------|---------|
37
+ | `src/service.ts` | Implement your payment processing logic. Look for `TODO` comments. |
38
+ | `src/publish_quotes.ts` | Replace sample quotes with your FX rate source. |
96
39
 
97
- ### `npm start`
98
-
99
- Runs the compiled production build from `dist/`.
100
-
101
- ### `npm run lint`
102
-
103
- Lints TypeScript files in the `src/` directory using ESLint.
104
-
105
- ## Getting Started with Your Integration
106
-
107
- After creating your project:
108
-
109
- 1. **Navigate to project directory:**
110
- ```bash
111
- cd your-project-name
112
- ```
113
-
114
- 2. **Review the generated keys:**
115
- - Open `.env` file
116
- - Your private key is stored in `PROVIDER_PRIVATE_KEY`
117
- - Your public key is shown as a comment (you'll need to share this)
118
-
119
- 3. **Share your public key with t-0 team:**
120
- - Find your public key in the `.env` file (marked as "Step 1.2")
121
- - Contact the t-0 team to register your provider
122
-
123
- 4. **Implement quote publishing:**
124
- - Edit `src/publish_quotes.ts` to implement your quote publishing logic
125
- - This determines how you provide exchange rate quotes to the network
40
+ ## Environment Variables
126
41
 
127
- 5. **Start development server:**
128
- ```bash
129
- npm run dev
130
- ```
42
+ | Variable | Required | Default | Description |
43
+ |----------|----------|---------|-------------|
44
+ | `PROVIDER_PRIVATE_KEY` | Yes | Auto-generated | Your secp256k1 private key (hex) |
45
+ | `NETWORK_PUBLIC_KEY` | Yes | Sandbox key | T-0 Network public key for signature verification |
46
+ | `TZERO_ENDPOINT` | No | `https://api-sandbox.t-0.network` | T-0 Network API endpoint |
47
+ | `PORT` | No | `3000` | Server port |
48
+ | `QUOTE_PUBLISHING_INTERVAL` | No | -- | Quote publishing frequency in milliseconds |
131
49
 
132
- 6. **Test your integration:**
133
- - Follow the TODO comments in `src/index.ts` for step-by-step guidance
134
- - Test quote retrieval
135
- - Test payment submission
136
- - Verify payout endpoint
50
+ ## Getting Started
137
51
 
52
+ ### Phase 1: Quoting
138
53
 
139
- ## Key Features
54
+ 1. Open `.env` and find your generated public key (marked as "Step 1.2"). Share it with the T-0 team to register your provider.
55
+ 2. Implement your quote publishing logic in `src/publish_quotes.ts`.
56
+ 3. Start the dev server (`npm run dev`) and verify quotes are published.
57
+ 4. Confirm quote retrieval works by checking the output of `getQuote` in `src/index.ts`.
140
58
 
141
- - **Type Safety** - Full TypeScript support with strict mode enabled
142
- - **Automatic Key Generation** - Secure secp256k1 key pairs generated via OpenSSL
143
- - **Pre-configured SDK** - t-0 Provider SDK integrated and ready to use
144
- - **Development Ready** - Hot reload support with ts-node
145
- - **Production Ready** - Optimized build configuration
146
- - **Security First** - `.env` automatically excluded from git
147
- - **Code Quality** - ESLint configured with TypeScript rules
59
+ ### Phase 2: Payments
148
60
 
61
+ 1. Implement `updatePayment` handler in `src/service.ts`.
62
+ 2. Deploy your service and share the base URL with the T-0 team.
63
+ 3. Implement `payOut` handler in `src/service.ts`.
64
+ 4. Test payment submission by uncommenting the `submitPayment` call in `src/index.ts`.
65
+ 5. Coordinate with the T-0 team to test end-to-end payment flows.
149
66
 
150
- ## Security Considerations
67
+ ## Available Commands
151
68
 
152
- - **Never commit `.env` file** - It's automatically added to `.gitignore`
153
- - **Keep private key secure** - The `PROVIDER_PRIVATE_KEY` must remain confidential
154
- - **Share only public key** - Only the public key should be shared with t-0 team
155
- - **Use environment-specific configs** - Different keys for dev/staging/production
69
+ ```bash
70
+ npm run dev # Run in development mode with ts-node
71
+ npm run build # Compile TypeScript to dist/
72
+ npm start # Run compiled production build
73
+ npm run lint # Lint TypeScript source with ESLint
74
+ ```
156
75
 
157
76
  ## Deployment
158
77
 
159
- When ready to deploy:
160
-
161
- 1. **Build your project:**
162
- ```bash
163
- npm run build
164
- ```
165
-
166
- 2. **Set environment variables** on your hosting platform
78
+ ```bash
79
+ docker build -t my-provider .
80
+ docker run -p 3000:3000 --env-file .env my-provider
81
+ ```
167
82
 
168
- 3. **Provide your base URL to t-0 team** for network registration
83
+ ## SDK Reference
169
84
 
170
- 4. **Start the service:**
171
- ```bash
172
- npm start
173
- ```
85
+ For direct SDK usage (without the starter), see the [TypeScript SDK documentation](../sdk/README.md).
174
86
 
175
87
  ## Troubleshooting
176
88
 
177
- ### "Directory already exists" Error
178
- The project directory name is already taken. Choose a different project name.
179
-
180
- ### "OpenSSL not found" Error
181
- Install OpenSSL:
182
- - **macOS:** `brew install openssl`
183
- - **Ubuntu/Debian:** `sudo apt-get install openssl`
184
- - **Windows:** Download from [openssl.org](https://www.openssl.org/)
89
+ **"Directory already exists"** -- Choose a different project name.
185
90
 
186
- ### Key Generation Fails
187
- Ensure OpenSSL is installed and accessible in your PATH. Try running:
188
- ```bash
189
- openssl version
190
- ```
191
-
192
- ### npm install Fails
193
- Check your Node.js and npm versions:
194
- ```bash
195
- node --version # Should be >= 14
196
- npm --version # Should be >= 6
197
- ```
91
+ **"OpenSSL not found"** -- Install OpenSSL (`brew install openssl` on macOS, `sudo apt-get install openssl` on Debian/Ubuntu).
198
92
 
199
- ## Support
93
+ **Key generation fails** -- Ensure OpenSSL is in your PATH: `openssl version`.
200
94
 
201
- For issues or questions:
202
- - Review the generated code comments and TODO markers
203
- - Check the [t-0 Network documentation](https://t-0.network)
204
- - Contact the t-0 team for integration support
95
+ **npm install fails** -- Check Node.js >= 18 and npm >= 8: `node --version && npm --version`.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@t-0/provider-starter-ts",
3
- "version": "1.1.5",
3
+ "version": "1.1.6",
4
4
  "description": "CLI tool to scaffold a Node.js t-0 Network integration service",
5
5
  "main": "dist/create.js",
6
6
  "bin": {
@@ -31,13 +31,13 @@
31
31
  "license": "MIT",
32
32
  "dependencies": {
33
33
  "chalk": "^5.6.2",
34
- "fs-extra": "^11.1.1",
34
+ "fs-extra": "^11.3.4",
35
35
  "inquirer": "^13.3.0"
36
36
  },
37
37
  "devDependencies": {
38
38
  "@types/fs-extra": "^11.0.4",
39
- "@types/inquirer": "^8.2.10",
39
+ "@types/inquirer": "^9.0.9",
40
40
  "@types/node": "^25.4.0",
41
- "typescript": "^5.3.2"
41
+ "typescript": "^5.9.3"
42
42
  }
43
43
  }
@@ -12,7 +12,7 @@
12
12
  "author": "",
13
13
  "license": "MIT",
14
14
  "dependencies": {
15
- "@t-0/provider-sdk": "^1.1.5",
15
+ "@t-0/provider-sdk": "^1.1.6",
16
16
  "dotenv": "^16.3.1",
17
17
  "tiny-invariant": "^1.3.3"
18
18
  },