@gibwork/sdk 0.0.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/CHANGELOG.md +11 -0
- package/README.md +176 -0
- package/dist/chunk-24XHBDMZ.js +773 -0
- package/dist/chunk-24XHBDMZ.js.map +1 -0
- package/dist/index.cjs +788 -0
- package/dist/index.cjs.map +1 -0
- package/dist/index.d.cts +356 -0
- package/dist/index.d.ts +356 -0
- package/dist/index.js +3 -0
- package/dist/index.js.map +1 -0
- package/dist/node.cjs +870 -0
- package/dist/node.cjs.map +1 -0
- package/dist/node.d.cts +14 -0
- package/dist/node.d.ts +14 -0
- package/dist/node.js +85 -0
- package/dist/node.js.map +1 -0
- package/package.json +81 -0
package/CHANGELOG.md
ADDED
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
All notable changes to this package will be documented here.
|
|
4
|
+
|
|
5
|
+
## Unreleased
|
|
6
|
+
|
|
7
|
+
- Add the typed Gibwork client with complete External API route coverage.
|
|
8
|
+
- Add high-level task creation, refund, and submission approval workflows.
|
|
9
|
+
- Add injected-wallet and Node private-key signer support.
|
|
10
|
+
- Add typed HTTP, timeout, cancellation, and ambiguous-submit errors.
|
|
11
|
+
- Embed `https://sdk.gib.work` by default with a build-time API URL override.
|
package/README.md
ADDED
|
@@ -0,0 +1,176 @@
|
|
|
1
|
+
# Gibwork SDK
|
|
2
|
+
|
|
3
|
+
TypeScript SDK for the wallet-authenticated Gibwork External API.
|
|
4
|
+
|
|
5
|
+
It handles wallet addresses, nonces, timestamps, payload normalization,
|
|
6
|
+
message signatures, HTTP requests, and Solana transaction signing for you.
|
|
7
|
+
|
|
8
|
+
## Installation
|
|
9
|
+
|
|
10
|
+
The package is currently private while its npm name and license are finalized.
|
|
11
|
+
Once published:
|
|
12
|
+
|
|
13
|
+
```bash
|
|
14
|
+
npm install @gibwork/sdk
|
|
15
|
+
```
|
|
16
|
+
|
|
17
|
+
Requires Node.js 22 or newer.
|
|
18
|
+
|
|
19
|
+
## Quick start
|
|
20
|
+
|
|
21
|
+
Load your environment variables in the application, then pass the private key
|
|
22
|
+
to the Node entry point. The SDK never loads `.env` implicitly.
|
|
23
|
+
|
|
24
|
+
```dotenv
|
|
25
|
+
SOLANA_PRIVATE_KEY=[1,2,3,...]
|
|
26
|
+
```
|
|
27
|
+
|
|
28
|
+
```ts
|
|
29
|
+
import { createGibworkClient } from '@gibwork/sdk/node';
|
|
30
|
+
|
|
31
|
+
const gibwork = createGibworkClient({
|
|
32
|
+
privateKey: process.env.SOLANA_PRIVATE_KEY!,
|
|
33
|
+
});
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
The SDK uses the embedded `https://sdk.gib.work` API URL by default, so
|
|
37
|
+
application users do not need to configure an API origin.
|
|
38
|
+
|
|
39
|
+
`SOLANA_PRIVATE_KEY` may be a base58-encoded 32-byte seed or 64-byte secret
|
|
40
|
+
key, or a JSON array containing 32 or 64 byte values.
|
|
41
|
+
|
|
42
|
+
Applications using a wallet adapter or custom custody provider can inject a
|
|
43
|
+
signer instead:
|
|
44
|
+
|
|
45
|
+
```ts
|
|
46
|
+
import { GibworkClient, type WalletSigner } from '@gibwork/sdk';
|
|
47
|
+
|
|
48
|
+
declare const signer: WalletSigner;
|
|
49
|
+
|
|
50
|
+
const gibwork = new GibworkClient({
|
|
51
|
+
signer,
|
|
52
|
+
});
|
|
53
|
+
```
|
|
54
|
+
|
|
55
|
+
### API URL builds
|
|
56
|
+
|
|
57
|
+
`https://sdk.gib.work` is embedded into normal package builds. SDK maintainers
|
|
58
|
+
can produce an environment-specific build by setting `GIBWORK_SDK_API_URL`
|
|
59
|
+
while building:
|
|
60
|
+
|
|
61
|
+
```bash
|
|
62
|
+
GIBWORK_SDK_API_URL=https://sdk-stage.gib.work npm run build
|
|
63
|
+
```
|
|
64
|
+
|
|
65
|
+
The selected URL is compiled into `dist`; installed applications do not need
|
|
66
|
+
that environment variable. `DEFAULT_GIBWORK_API_URL` exposes the embedded
|
|
67
|
+
value.
|
|
68
|
+
|
|
69
|
+
For local tests or custom deployments, `baseUrl` remains an optional runtime
|
|
70
|
+
override:
|
|
71
|
+
|
|
72
|
+
```ts
|
|
73
|
+
const gibwork = createGibworkClient({
|
|
74
|
+
privateKey: process.env.SOLANA_PRIVATE_KEY!,
|
|
75
|
+
baseUrl: 'http://localhost:3334',
|
|
76
|
+
});
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Methods
|
|
80
|
+
|
|
81
|
+
```ts
|
|
82
|
+
const task = await gibwork.tasks.create({
|
|
83
|
+
title: 'Write an SDK guide',
|
|
84
|
+
content: '<p>Document the Gibwork SDK.</p>',
|
|
85
|
+
tags: ['Docs'],
|
|
86
|
+
payment: {
|
|
87
|
+
mintAddress: 'EPjFWdd5AufqSSqeM2qN1xzybapC8G4wEGGkZwyTDt1v',
|
|
88
|
+
amount: '25.00',
|
|
89
|
+
},
|
|
90
|
+
minSubmissionAmount: '5.00',
|
|
91
|
+
});
|
|
92
|
+
|
|
93
|
+
const tasks = await gibwork.tasks.list();
|
|
94
|
+
const submissions = await gibwork.submissions.list(task.taskId);
|
|
95
|
+
|
|
96
|
+
await gibwork.submissions.approve(task.taskId, submissionId, {
|
|
97
|
+
amount: '5.00',
|
|
98
|
+
rating: 5,
|
|
99
|
+
});
|
|
100
|
+
|
|
101
|
+
await gibwork.submissions.reject(
|
|
102
|
+
task.taskId,
|
|
103
|
+
submissionId,
|
|
104
|
+
'Please include the source files.',
|
|
105
|
+
);
|
|
106
|
+
|
|
107
|
+
const comments = await gibwork.submissions.comments.list(
|
|
108
|
+
task.taskId,
|
|
109
|
+
submissionId,
|
|
110
|
+
);
|
|
111
|
+
await gibwork.submissions.comments.create(
|
|
112
|
+
task.taskId,
|
|
113
|
+
submissionId,
|
|
114
|
+
'Thanks for the update.',
|
|
115
|
+
);
|
|
116
|
+
|
|
117
|
+
await gibwork.tasks.refund(task.taskId);
|
|
118
|
+
```
|
|
119
|
+
|
|
120
|
+
`tasks.create`, `tasks.refund`, and `submissions.approve` perform the complete
|
|
121
|
+
prepare, sign, and submit sequence. Advanced callers can control the phases
|
|
122
|
+
with:
|
|
123
|
+
|
|
124
|
+
- `tasks.prepareCreate` and `tasks.submitCreate`
|
|
125
|
+
- `tasks.prepareRefund` and `tasks.submitRefund`
|
|
126
|
+
- `submissions.prepareApproval` and `submissions.submitApproval`
|
|
127
|
+
- `signPreparedTransaction`
|
|
128
|
+
|
|
129
|
+
All request methods accept an optional final `{ signal }` argument for
|
|
130
|
+
cancellation. Set the default request timeout with `timeoutMs` when creating
|
|
131
|
+
the client.
|
|
132
|
+
|
|
133
|
+
## Errors
|
|
134
|
+
|
|
135
|
+
API failures throw `GibworkApiError` with `status` and the parsed response
|
|
136
|
+
`body`. Network failures and timeouts use typed SDK errors.
|
|
137
|
+
|
|
138
|
+
Transaction submits are never retried automatically. If the network or server
|
|
139
|
+
fails while submitting, the SDK throws `GibworkAmbiguousSubmitError` with safe
|
|
140
|
+
task, submission, and intent identifiers. Do not resubmit the same intent
|
|
141
|
+
blindly.
|
|
142
|
+
|
|
143
|
+
## Development
|
|
144
|
+
|
|
145
|
+
```bash
|
|
146
|
+
npm install
|
|
147
|
+
npm run check
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
The package is intentionally marked `private` and `UNLICENSED` while its public
|
|
151
|
+
API, npm ownership, and license are undecided. Those release gates must be
|
|
152
|
+
resolved before the first npm publish.
|
|
153
|
+
|
|
154
|
+
## Structure
|
|
155
|
+
|
|
156
|
+
```text
|
|
157
|
+
src/
|
|
158
|
+
auth/ Request normalization, hashing, nonces, and signatures
|
|
159
|
+
client/ Top-level SDK client and configuration
|
|
160
|
+
errors/ Typed SDK and API errors
|
|
161
|
+
resources/ Task and submission resource clients
|
|
162
|
+
signers/ Wallet signer contracts and opt-in adapters
|
|
163
|
+
transactions/ Prepare, sign, and submit orchestration
|
|
164
|
+
transport/ HTTP transport, response parsing, and retry policy
|
|
165
|
+
types/ Public request and response types
|
|
166
|
+
tests/
|
|
167
|
+
integration/ Tests against a running External API
|
|
168
|
+
unit/ Isolated SDK behavior tests
|
|
169
|
+
```
|
|
170
|
+
|
|
171
|
+
## Private-key safety
|
|
172
|
+
|
|
173
|
+
The SDK never transmits the private key, loads `.env` implicitly, or includes
|
|
174
|
+
key material in its errors. Never expose the Node private-key entry point in a
|
|
175
|
+
browser bundle. Browser consumers should provide a wallet-adapter-backed
|
|
176
|
+
signer.
|