@qpher/sdk 0.1.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/LICENSE +21 -0
- package/README.md +266 -0
- package/dist/client.d.ts +32 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +55 -0
- package/dist/client.js.map +1 -0
- package/dist/errors.d.ts +35 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +106 -0
- package/dist/errors.js.map +1 -0
- package/dist/esm/client.d.ts +32 -0
- package/dist/esm/client.d.ts.map +1 -0
- package/dist/esm/client.js +51 -0
- package/dist/esm/client.js.map +1 -0
- package/dist/esm/errors.d.ts +35 -0
- package/dist/esm/errors.d.ts.map +1 -0
- package/dist/esm/errors.js +93 -0
- package/dist/esm/errors.js.map +1 -0
- package/dist/esm/http-client.d.ts +21 -0
- package/dist/esm/http-client.d.ts.map +1 -0
- package/dist/esm/http-client.js +104 -0
- package/dist/esm/http-client.js.map +1 -0
- package/dist/esm/index.d.ts +10 -0
- package/dist/esm/index.d.ts.map +1 -0
- package/dist/esm/index.js +12 -0
- package/dist/esm/index.js.map +1 -0
- package/dist/esm/kem.d.ts +24 -0
- package/dist/esm/kem.d.ts.map +1 -0
- package/dist/esm/kem.js +52 -0
- package/dist/esm/kem.js.map +1 -0
- package/dist/esm/keys.d.ts +52 -0
- package/dist/esm/keys.d.ts.map +1 -0
- package/dist/esm/keys.js +110 -0
- package/dist/esm/keys.js.map +1 -0
- package/dist/esm/signatures.d.ts +24 -0
- package/dist/esm/signatures.d.ts.map +1 -0
- package/dist/esm/signatures.js +49 -0
- package/dist/esm/signatures.js.map +1 -0
- package/dist/esm/types.d.ts +122 -0
- package/dist/esm/types.d.ts.map +1 -0
- package/dist/esm/types.js +5 -0
- package/dist/esm/types.js.map +1 -0
- package/dist/http-client.d.ts +21 -0
- package/dist/http-client.d.ts.map +1 -0
- package/dist/http-client.js +108 -0
- package/dist/http-client.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +25 -0
- package/dist/index.js.map +1 -0
- package/dist/kem.d.ts +24 -0
- package/dist/kem.d.ts.map +1 -0
- package/dist/kem.js +56 -0
- package/dist/kem.js.map +1 -0
- package/dist/keys.d.ts +52 -0
- package/dist/keys.d.ts.map +1 -0
- package/dist/keys.js +114 -0
- package/dist/keys.js.map +1 -0
- package/dist/signatures.d.ts +24 -0
- package/dist/signatures.d.ts.map +1 -0
- package/dist/signatures.js +53 -0
- package/dist/signatures.js.map +1 -0
- package/dist/types.d.ts +122 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/package.json +55 -0
package/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Qpher
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
package/README.md
ADDED
|
@@ -0,0 +1,266 @@
|
|
|
1
|
+
# @qpher/sdk
|
|
2
|
+
|
|
3
|
+
Official Node.js SDK for the [Qpher](https://qpher.ai) Post-Quantum Cryptography API.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @qpher/sdk
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Requirements
|
|
12
|
+
|
|
13
|
+
- Node.js 18+
|
|
14
|
+
|
|
15
|
+
## Quick Start
|
|
16
|
+
|
|
17
|
+
```typescript
|
|
18
|
+
import { Qpher } from '@qpher/sdk';
|
|
19
|
+
|
|
20
|
+
// Initialize the client
|
|
21
|
+
const client = new Qpher({ apiKey: 'qph_live_your_api_key' });
|
|
22
|
+
|
|
23
|
+
// Encrypt data using Kyber768 KEM
|
|
24
|
+
const encrypted = await client.kem.encrypt({
|
|
25
|
+
plaintext: Buffer.from('Hello, Quantum World!'),
|
|
26
|
+
keyVersion: 1,
|
|
27
|
+
});
|
|
28
|
+
console.log('Ciphertext:', encrypted.ciphertext.toString('hex'));
|
|
29
|
+
|
|
30
|
+
// Decrypt data
|
|
31
|
+
const decrypted = await client.kem.decrypt({
|
|
32
|
+
ciphertext: encrypted.ciphertext,
|
|
33
|
+
keyVersion: encrypted.keyVersion,
|
|
34
|
+
});
|
|
35
|
+
console.log('Plaintext:', decrypted.plaintext.toString());
|
|
36
|
+
|
|
37
|
+
// Sign a message using Dilithium3
|
|
38
|
+
const signed = await client.signatures.sign({
|
|
39
|
+
message: Buffer.from('Invoice #12345'),
|
|
40
|
+
keyVersion: 1,
|
|
41
|
+
});
|
|
42
|
+
console.log('Signature:', signed.signature.toString('hex'));
|
|
43
|
+
|
|
44
|
+
// Verify a signature
|
|
45
|
+
const verified = await client.signatures.verify({
|
|
46
|
+
message: Buffer.from('Invoice #12345'),
|
|
47
|
+
signature: signed.signature,
|
|
48
|
+
keyVersion: signed.keyVersion,
|
|
49
|
+
});
|
|
50
|
+
console.log('Valid:', verified.valid);
|
|
51
|
+
```
|
|
52
|
+
|
|
53
|
+
## API Reference
|
|
54
|
+
|
|
55
|
+
### Client Initialization
|
|
56
|
+
|
|
57
|
+
```typescript
|
|
58
|
+
import { Qpher } from '@qpher/sdk';
|
|
59
|
+
|
|
60
|
+
const client = new Qpher({
|
|
61
|
+
apiKey: 'qph_live_your_api_key', // Required
|
|
62
|
+
baseUrl: 'https://api.qpher.ai', // Optional, default
|
|
63
|
+
timeout: 30000, // Optional, milliseconds
|
|
64
|
+
maxRetries: 3, // Optional
|
|
65
|
+
});
|
|
66
|
+
```
|
|
67
|
+
|
|
68
|
+
### KEM Operations (Kyber768)
|
|
69
|
+
|
|
70
|
+
#### Encrypt
|
|
71
|
+
|
|
72
|
+
```typescript
|
|
73
|
+
const result = await client.kem.encrypt({
|
|
74
|
+
plaintext: Buffer.from('secret data'),
|
|
75
|
+
keyVersion: 1,
|
|
76
|
+
mode: 'standard', // Optional: 'standard' | 'deterministic'
|
|
77
|
+
salt: Buffer.alloc(32), // Required if mode='deterministic'
|
|
78
|
+
});
|
|
79
|
+
// result.ciphertext: Buffer
|
|
80
|
+
// result.keyVersion: number
|
|
81
|
+
// result.algorithm: string ('Kyber768')
|
|
82
|
+
// result.requestId: string
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
#### Decrypt
|
|
86
|
+
|
|
87
|
+
```typescript
|
|
88
|
+
const result = await client.kem.decrypt({
|
|
89
|
+
ciphertext: encryptedData,
|
|
90
|
+
keyVersion: 1,
|
|
91
|
+
});
|
|
92
|
+
// result.plaintext: Buffer
|
|
93
|
+
// result.keyVersion: number
|
|
94
|
+
// result.algorithm: string
|
|
95
|
+
// result.requestId: string
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
### Signature Operations (Dilithium3)
|
|
99
|
+
|
|
100
|
+
#### Sign
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
const result = await client.signatures.sign({
|
|
104
|
+
message: Buffer.from('document to sign'),
|
|
105
|
+
keyVersion: 1,
|
|
106
|
+
});
|
|
107
|
+
// result.signature: Buffer (3,293 bytes)
|
|
108
|
+
// result.keyVersion: number
|
|
109
|
+
// result.algorithm: string ('Dilithium3')
|
|
110
|
+
// result.requestId: string
|
|
111
|
+
```
|
|
112
|
+
|
|
113
|
+
#### Verify
|
|
114
|
+
|
|
115
|
+
```typescript
|
|
116
|
+
const result = await client.signatures.verify({
|
|
117
|
+
message: Buffer.from('document to sign'),
|
|
118
|
+
signature: signatureBuffer,
|
|
119
|
+
keyVersion: 1,
|
|
120
|
+
});
|
|
121
|
+
// result.valid: boolean
|
|
122
|
+
// result.keyVersion: number
|
|
123
|
+
// result.algorithm: string
|
|
124
|
+
// result.requestId: string
|
|
125
|
+
```
|
|
126
|
+
|
|
127
|
+
### Key Management
|
|
128
|
+
|
|
129
|
+
#### Generate Key
|
|
130
|
+
|
|
131
|
+
```typescript
|
|
132
|
+
const result = await client.keys.generate({ algorithm: 'Kyber768' });
|
|
133
|
+
// result.keyVersion: number
|
|
134
|
+
// result.algorithm: string
|
|
135
|
+
// result.status: string ('active')
|
|
136
|
+
// result.publicKey: Buffer
|
|
137
|
+
// result.createdAt: string
|
|
138
|
+
```
|
|
139
|
+
|
|
140
|
+
#### Rotate Key
|
|
141
|
+
|
|
142
|
+
```typescript
|
|
143
|
+
const result = await client.keys.rotate({ algorithm: 'Kyber768' });
|
|
144
|
+
// result.keyVersion: number (new)
|
|
145
|
+
// result.oldKeyVersion: number
|
|
146
|
+
// result.algorithm: string
|
|
147
|
+
// result.publicKey: Buffer
|
|
148
|
+
```
|
|
149
|
+
|
|
150
|
+
#### Get Active Key
|
|
151
|
+
|
|
152
|
+
```typescript
|
|
153
|
+
const keyInfo = await client.keys.getActive({ algorithm: 'Kyber768' });
|
|
154
|
+
// keyInfo.keyVersion: number
|
|
155
|
+
// keyInfo.algorithm: string
|
|
156
|
+
// keyInfo.status: string
|
|
157
|
+
// keyInfo.publicKey: Buffer
|
|
158
|
+
// keyInfo.createdAt: string
|
|
159
|
+
```
|
|
160
|
+
|
|
161
|
+
#### List Keys
|
|
162
|
+
|
|
163
|
+
```typescript
|
|
164
|
+
const result = await client.keys.list({
|
|
165
|
+
algorithm: 'Kyber768', // Optional filter
|
|
166
|
+
status: 'active', // Optional filter
|
|
167
|
+
});
|
|
168
|
+
// result.keys: KeyInfo[]
|
|
169
|
+
// result.total: number
|
|
170
|
+
```
|
|
171
|
+
|
|
172
|
+
#### Retire Key
|
|
173
|
+
|
|
174
|
+
```typescript
|
|
175
|
+
const result = await client.keys.retire({
|
|
176
|
+
algorithm: 'Kyber768',
|
|
177
|
+
keyVersion: 1,
|
|
178
|
+
});
|
|
179
|
+
// result.keyVersion: number
|
|
180
|
+
// result.status: string ('retired')
|
|
181
|
+
```
|
|
182
|
+
|
|
183
|
+
## Error Handling
|
|
184
|
+
|
|
185
|
+
```typescript
|
|
186
|
+
import {
|
|
187
|
+
Qpher,
|
|
188
|
+
QpherError,
|
|
189
|
+
AuthenticationError,
|
|
190
|
+
ValidationError,
|
|
191
|
+
NotFoundError,
|
|
192
|
+
RateLimitError,
|
|
193
|
+
} from '@qpher/sdk';
|
|
194
|
+
|
|
195
|
+
try {
|
|
196
|
+
const result = await client.kem.encrypt({
|
|
197
|
+
plaintext: Buffer.from('data'),
|
|
198
|
+
keyVersion: 99,
|
|
199
|
+
});
|
|
200
|
+
} catch (err) {
|
|
201
|
+
if (err instanceof NotFoundError) {
|
|
202
|
+
console.log(`Key not found: ${err.message}`);
|
|
203
|
+
console.log(`Error code: ${err.errorCode}`);
|
|
204
|
+
console.log(`Request ID: ${err.requestId}`);
|
|
205
|
+
} else if (err instanceof RateLimitError) {
|
|
206
|
+
console.log('Rate limit exceeded, please retry later');
|
|
207
|
+
} else if (err instanceof AuthenticationError) {
|
|
208
|
+
console.log('Invalid API key');
|
|
209
|
+
} else if (err instanceof ValidationError) {
|
|
210
|
+
console.log(`Invalid input: ${err.message}`);
|
|
211
|
+
} else if (err instanceof QpherError) {
|
|
212
|
+
console.log(`API error: ${err.message}`);
|
|
213
|
+
}
|
|
214
|
+
}
|
|
215
|
+
```
|
|
216
|
+
|
|
217
|
+
## Error Types
|
|
218
|
+
|
|
219
|
+
| Exception | HTTP Status | Description |
|
|
220
|
+
|-----------|-------------|-------------|
|
|
221
|
+
| `AuthenticationError` | 401 | Invalid or missing API key |
|
|
222
|
+
| `ValidationError` | 400 | Invalid request parameters |
|
|
223
|
+
| `ForbiddenError` | 403 | Operation not allowed |
|
|
224
|
+
| `NotFoundError` | 404 | Resource not found |
|
|
225
|
+
| `RateLimitError` | 429 | Rate limit exceeded |
|
|
226
|
+
| `ServerError` | 500+ | Server-side errors |
|
|
227
|
+
| `TimeoutError` | 504 | Request timed out |
|
|
228
|
+
| `ConnectionError` | 503 | Connection failed |
|
|
229
|
+
|
|
230
|
+
## TypeScript Support
|
|
231
|
+
|
|
232
|
+
This SDK is written in TypeScript and provides full type definitions. All input and output types are exported:
|
|
233
|
+
|
|
234
|
+
```typescript
|
|
235
|
+
import {
|
|
236
|
+
QpherOptions,
|
|
237
|
+
EncryptInput,
|
|
238
|
+
EncryptResult,
|
|
239
|
+
DecryptInput,
|
|
240
|
+
DecryptResult,
|
|
241
|
+
SignInput,
|
|
242
|
+
SignResult,
|
|
243
|
+
VerifyInput,
|
|
244
|
+
VerifyResult,
|
|
245
|
+
KeyInfo,
|
|
246
|
+
KeyListResult,
|
|
247
|
+
// ... and more
|
|
248
|
+
} from '@qpher/sdk';
|
|
249
|
+
```
|
|
250
|
+
|
|
251
|
+
## Supported Algorithms
|
|
252
|
+
|
|
253
|
+
| Algorithm | Type | Security Level |
|
|
254
|
+
|-----------|------|----------------|
|
|
255
|
+
| Kyber768 | KEM (Encryption) | NIST Level 3 |
|
|
256
|
+
| Dilithium3 | Digital Signatures | NIST Level 3 |
|
|
257
|
+
|
|
258
|
+
## License
|
|
259
|
+
|
|
260
|
+
MIT License - see [LICENSE](LICENSE) for details.
|
|
261
|
+
|
|
262
|
+
## Links
|
|
263
|
+
|
|
264
|
+
- [Qpher Website](https://qpher.ai)
|
|
265
|
+
- [API Documentation](https://docs.qpher.ai)
|
|
266
|
+
- [GitHub Repository](https://github.com/qpher/qpher-node)
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main Qpher client class.
|
|
3
|
+
*/
|
|
4
|
+
import { KEMModule } from './kem';
|
|
5
|
+
import { SignaturesModule } from './signatures';
|
|
6
|
+
import { KeysModule } from './keys';
|
|
7
|
+
import { QpherOptions } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Qpher PQC API client.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { Qpher } from '@qpher/sdk';
|
|
14
|
+
*
|
|
15
|
+
* const client = new Qpher({ apiKey: 'qph_live_abc123' });
|
|
16
|
+
*
|
|
17
|
+
* const result = await client.kem.encrypt({
|
|
18
|
+
* plaintext: Buffer.from('Hello!'),
|
|
19
|
+
* keyVersion: 1,
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* console.log(result.ciphertext);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class Qpher {
|
|
26
|
+
readonly kem: KEMModule;
|
|
27
|
+
readonly signatures: SignaturesModule;
|
|
28
|
+
readonly keys: KeysModule;
|
|
29
|
+
private readonly http;
|
|
30
|
+
constructor(options: QpherOptions);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMvC;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,KAAK;IAChB,SAAgB,GAAG,EAAE,SAAS,CAAC;IAC/B,SAAgB,UAAU,EAAE,gBAAgB,CAAC;IAC7C,SAAgB,IAAI,EAAE,UAAU,CAAC;IAEjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;gBAEtB,OAAO,EAAE,YAAY;CAmBlC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,55 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Main Qpher client class.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.Qpher = void 0;
|
|
7
|
+
const http_client_1 = require("./http-client");
|
|
8
|
+
const kem_1 = require("./kem");
|
|
9
|
+
const signatures_1 = require("./signatures");
|
|
10
|
+
const keys_1 = require("./keys");
|
|
11
|
+
const DEFAULT_BASE_URL = 'https://api.qpher.ai';
|
|
12
|
+
const DEFAULT_TIMEOUT = 30_000; // 30 seconds
|
|
13
|
+
const DEFAULT_MAX_RETRIES = 3;
|
|
14
|
+
/**
|
|
15
|
+
* Qpher PQC API client.
|
|
16
|
+
*
|
|
17
|
+
* @example
|
|
18
|
+
* ```typescript
|
|
19
|
+
* import { Qpher } from '@qpher/sdk';
|
|
20
|
+
*
|
|
21
|
+
* const client = new Qpher({ apiKey: 'qph_live_abc123' });
|
|
22
|
+
*
|
|
23
|
+
* const result = await client.kem.encrypt({
|
|
24
|
+
* plaintext: Buffer.from('Hello!'),
|
|
25
|
+
* keyVersion: 1,
|
|
26
|
+
* });
|
|
27
|
+
*
|
|
28
|
+
* console.log(result.ciphertext);
|
|
29
|
+
* ```
|
|
30
|
+
*/
|
|
31
|
+
class Qpher {
|
|
32
|
+
kem;
|
|
33
|
+
signatures;
|
|
34
|
+
keys;
|
|
35
|
+
http;
|
|
36
|
+
constructor(options) {
|
|
37
|
+
if (!options.apiKey) {
|
|
38
|
+
throw new Error('apiKey is required');
|
|
39
|
+
}
|
|
40
|
+
if (!options.apiKey.startsWith('qph_')) {
|
|
41
|
+
throw new Error("apiKey must start with 'qph_'");
|
|
42
|
+
}
|
|
43
|
+
this.http = new http_client_1.HttpClient({
|
|
44
|
+
apiKey: options.apiKey,
|
|
45
|
+
baseUrl: (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, ''),
|
|
46
|
+
timeout: options.timeout ?? DEFAULT_TIMEOUT,
|
|
47
|
+
maxRetries: options.maxRetries ?? DEFAULT_MAX_RETRIES,
|
|
48
|
+
});
|
|
49
|
+
this.kem = new kem_1.KEMModule(this.http);
|
|
50
|
+
this.signatures = new signatures_1.SignaturesModule(this.http);
|
|
51
|
+
this.keys = new keys_1.KeysModule(this.http);
|
|
52
|
+
}
|
|
53
|
+
}
|
|
54
|
+
exports.Qpher = Qpher;
|
|
55
|
+
//# sourceMappingURL=client.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.js","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAEH,+CAA2C;AAC3C,+BAAkC;AAClC,6CAAgD;AAChD,iCAAoC;AAGpC,MAAM,gBAAgB,GAAG,sBAAsB,CAAC;AAChD,MAAM,eAAe,GAAG,MAAM,CAAC,CAAC,aAAa;AAC7C,MAAM,mBAAmB,GAAG,CAAC,CAAC;AAE9B;;;;;;;;;;;;;;;;GAgBG;AACH,MAAa,KAAK;IACA,GAAG,CAAY;IACf,UAAU,CAAmB;IAC7B,IAAI,CAAa;IAEhB,IAAI,CAAa;IAElC,YAAY,OAAqB;QAC/B,IAAI,CAAC,OAAO,CAAC,MAAM,EAAE,CAAC;YACpB,MAAM,IAAI,KAAK,CAAC,oBAAoB,CAAC,CAAC;QACxC,CAAC;QACD,IAAI,CAAC,OAAO,CAAC,MAAM,CAAC,UAAU,CAAC,MAAM,CAAC,EAAE,CAAC;YACvC,MAAM,IAAI,KAAK,CAAC,+BAA+B,CAAC,CAAC;QACnD,CAAC;QAED,IAAI,CAAC,IAAI,GAAG,IAAI,wBAAU,CAAC;YACzB,MAAM,EAAE,OAAO,CAAC,MAAM;YACtB,OAAO,EAAE,CAAC,OAAO,CAAC,OAAO,IAAI,gBAAgB,CAAC,CAAC,OAAO,CAAC,KAAK,EAAE,EAAE,CAAC;YACjE,OAAO,EAAE,OAAO,CAAC,OAAO,IAAI,eAAe;YAC3C,UAAU,EAAE,OAAO,CAAC,UAAU,IAAI,mBAAmB;SACtD,CAAC,CAAC;QAEH,IAAI,CAAC,GAAG,GAAG,IAAI,eAAS,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QACpC,IAAI,CAAC,UAAU,GAAG,IAAI,6BAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,IAAI,iBAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CACF;AA1BD,sBA0BC"}
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Qpher SDK error classes.
|
|
3
|
+
*/
|
|
4
|
+
export declare class QpherError extends Error {
|
|
5
|
+
readonly errorCode: string;
|
|
6
|
+
readonly statusCode: number;
|
|
7
|
+
readonly requestId?: string;
|
|
8
|
+
constructor(message: string, errorCode: string, statusCode: number, requestId?: string);
|
|
9
|
+
}
|
|
10
|
+
export declare class AuthenticationError extends QpherError {
|
|
11
|
+
constructor(message: string, errorCode: string, requestId?: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class ValidationError extends QpherError {
|
|
14
|
+
constructor(message: string, errorCode: string, requestId?: string);
|
|
15
|
+
}
|
|
16
|
+
export declare class NotFoundError extends QpherError {
|
|
17
|
+
constructor(message: string, errorCode: string, requestId?: string);
|
|
18
|
+
}
|
|
19
|
+
export declare class ForbiddenError extends QpherError {
|
|
20
|
+
constructor(message: string, errorCode: string, requestId?: string);
|
|
21
|
+
}
|
|
22
|
+
export declare class RateLimitError extends QpherError {
|
|
23
|
+
constructor(message: string, errorCode: string, requestId?: string);
|
|
24
|
+
}
|
|
25
|
+
export declare class ServerError extends QpherError {
|
|
26
|
+
constructor(message: string, errorCode: string, statusCode: number, requestId?: string);
|
|
27
|
+
}
|
|
28
|
+
export declare class TimeoutError extends QpherError {
|
|
29
|
+
constructor(message: string, requestId?: string);
|
|
30
|
+
}
|
|
31
|
+
export declare class ConnectionError extends QpherError {
|
|
32
|
+
constructor(message: string, requestId?: string);
|
|
33
|
+
}
|
|
34
|
+
export declare function parseErrorResponse(statusCode: number, body: unknown, fallbackMessage: string): QpherError;
|
|
35
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,qBAAa,UAAW,SAAQ,KAAK;IACnC,SAAgB,SAAS,EAAE,MAAM,CAAC;IAClC,SAAgB,UAAU,EAAE,MAAM,CAAC;IACnC,SAAgB,SAAS,CAAC,EAAE,MAAM,CAAC;gBAGjC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM;CAarB;AAED,qBAAa,mBAAoB,SAAQ,UAAU;gBACrC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAInE;AAED,qBAAa,eAAgB,SAAQ,UAAU;gBACjC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAInE;AAED,qBAAa,aAAc,SAAQ,UAAU;gBAC/B,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAInE;AAED,qBAAa,cAAe,SAAQ,UAAU;gBAChC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAInE;AAED,qBAAa,cAAe,SAAQ,UAAU;gBAChC,OAAO,EAAE,MAAM,EAAE,SAAS,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAInE;AAED,qBAAa,WAAY,SAAQ,UAAU;gBAEvC,OAAO,EAAE,MAAM,EACf,SAAS,EAAE,MAAM,EACjB,UAAU,EAAE,MAAM,EAClB,SAAS,CAAC,EAAE,MAAM;CAKrB;AAED,qBAAa,YAAa,SAAQ,UAAU;gBAC9B,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAIhD;AAED,qBAAa,eAAgB,SAAQ,UAAU;gBACjC,OAAO,EAAE,MAAM,EAAE,SAAS,CAAC,EAAE,MAAM;CAIhD;AAaD,wBAAgB,kBAAkB,CAChC,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,OAAO,EACb,eAAe,EAAE,MAAM,GACtB,UAAU,CAwBZ"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
/**
|
|
3
|
+
* Qpher SDK error classes.
|
|
4
|
+
*/
|
|
5
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
+
exports.ConnectionError = exports.TimeoutError = exports.ServerError = exports.RateLimitError = exports.ForbiddenError = exports.NotFoundError = exports.ValidationError = exports.AuthenticationError = exports.QpherError = void 0;
|
|
7
|
+
exports.parseErrorResponse = parseErrorResponse;
|
|
8
|
+
class QpherError extends Error {
|
|
9
|
+
errorCode;
|
|
10
|
+
statusCode;
|
|
11
|
+
requestId;
|
|
12
|
+
constructor(message, errorCode, statusCode, requestId) {
|
|
13
|
+
super(message);
|
|
14
|
+
this.name = 'QpherError';
|
|
15
|
+
this.errorCode = errorCode;
|
|
16
|
+
this.statusCode = statusCode;
|
|
17
|
+
this.requestId = requestId;
|
|
18
|
+
// Maintain proper stack trace for where error was thrown (only available on V8)
|
|
19
|
+
if (Error.captureStackTrace) {
|
|
20
|
+
Error.captureStackTrace(this, QpherError);
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
}
|
|
24
|
+
exports.QpherError = QpherError;
|
|
25
|
+
class AuthenticationError extends QpherError {
|
|
26
|
+
constructor(message, errorCode, requestId) {
|
|
27
|
+
super(message, errorCode, 401, requestId);
|
|
28
|
+
this.name = 'AuthenticationError';
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.AuthenticationError = AuthenticationError;
|
|
32
|
+
class ValidationError extends QpherError {
|
|
33
|
+
constructor(message, errorCode, requestId) {
|
|
34
|
+
super(message, errorCode, 400, requestId);
|
|
35
|
+
this.name = 'ValidationError';
|
|
36
|
+
}
|
|
37
|
+
}
|
|
38
|
+
exports.ValidationError = ValidationError;
|
|
39
|
+
class NotFoundError extends QpherError {
|
|
40
|
+
constructor(message, errorCode, requestId) {
|
|
41
|
+
super(message, errorCode, 404, requestId);
|
|
42
|
+
this.name = 'NotFoundError';
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
exports.NotFoundError = NotFoundError;
|
|
46
|
+
class ForbiddenError extends QpherError {
|
|
47
|
+
constructor(message, errorCode, requestId) {
|
|
48
|
+
super(message, errorCode, 403, requestId);
|
|
49
|
+
this.name = 'ForbiddenError';
|
|
50
|
+
}
|
|
51
|
+
}
|
|
52
|
+
exports.ForbiddenError = ForbiddenError;
|
|
53
|
+
class RateLimitError extends QpherError {
|
|
54
|
+
constructor(message, errorCode, requestId) {
|
|
55
|
+
super(message, errorCode, 429, requestId);
|
|
56
|
+
this.name = 'RateLimitError';
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
exports.RateLimitError = RateLimitError;
|
|
60
|
+
class ServerError extends QpherError {
|
|
61
|
+
constructor(message, errorCode, statusCode, requestId) {
|
|
62
|
+
super(message, errorCode, statusCode, requestId);
|
|
63
|
+
this.name = 'ServerError';
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
exports.ServerError = ServerError;
|
|
67
|
+
class TimeoutError extends QpherError {
|
|
68
|
+
constructor(message, requestId) {
|
|
69
|
+
super(message, 'ERR_TIMEOUT_001', 504, requestId);
|
|
70
|
+
this.name = 'TimeoutError';
|
|
71
|
+
}
|
|
72
|
+
}
|
|
73
|
+
exports.TimeoutError = TimeoutError;
|
|
74
|
+
class ConnectionError extends QpherError {
|
|
75
|
+
constructor(message, requestId) {
|
|
76
|
+
super(message, 'ERR_SERVICE_001', 503, requestId);
|
|
77
|
+
this.name = 'ConnectionError';
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
exports.ConnectionError = ConnectionError;
|
|
81
|
+
const STATUS_TO_ERROR = {
|
|
82
|
+
400: ValidationError,
|
|
83
|
+
401: AuthenticationError,
|
|
84
|
+
403: ForbiddenError,
|
|
85
|
+
404: NotFoundError,
|
|
86
|
+
429: RateLimitError,
|
|
87
|
+
};
|
|
88
|
+
function parseErrorResponse(statusCode, body, fallbackMessage) {
|
|
89
|
+
let errorCode = `ERR_UNKNOWN_${statusCode}`;
|
|
90
|
+
let message = fallbackMessage;
|
|
91
|
+
let requestId;
|
|
92
|
+
if (body && typeof body === 'object') {
|
|
93
|
+
const errorBody = body;
|
|
94
|
+
if (errorBody.error) {
|
|
95
|
+
errorCode = errorBody.error.error_code ?? errorCode;
|
|
96
|
+
message = errorBody.error.message ?? message;
|
|
97
|
+
}
|
|
98
|
+
requestId = errorBody.request_id;
|
|
99
|
+
}
|
|
100
|
+
const ErrorClass = STATUS_TO_ERROR[statusCode];
|
|
101
|
+
if (ErrorClass) {
|
|
102
|
+
return new ErrorClass(message, errorCode, requestId);
|
|
103
|
+
}
|
|
104
|
+
return new ServerError(message, errorCode, statusCode, requestId);
|
|
105
|
+
}
|
|
106
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":";AAAA;;GAEG;;;AAkGH,gDA4BC;AA5HD,MAAa,UAAW,SAAQ,KAAK;IACnB,SAAS,CAAS;IAClB,UAAU,CAAS;IACnB,SAAS,CAAU;IAEnC,YACE,OAAe,EACf,SAAiB,EACjB,UAAkB,EAClB,SAAkB;QAElB,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,YAAY,CAAC;QACzB,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAC3B,IAAI,CAAC,UAAU,GAAG,UAAU,CAAC;QAC7B,IAAI,CAAC,SAAS,GAAG,SAAS,CAAC;QAE3B,gFAAgF;QAChF,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,UAAU,CAAC,CAAC;QAC5C,CAAC;IACH,CAAC;CACF;AAtBD,gCAsBC;AAED,MAAa,mBAAoB,SAAQ,UAAU;IACjD,YAAY,OAAe,EAAE,SAAiB,EAAE,SAAkB;QAChE,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI,GAAG,qBAAqB,CAAC;IACpC,CAAC;CACF;AALD,kDAKC;AAED,MAAa,eAAgB,SAAQ,UAAU;IAC7C,YAAY,OAAe,EAAE,SAAiB,EAAE,SAAkB;QAChE,KAAK,CAAC,OAAO,EAAE,SAAS,EAAE,GAAG,EAAE,SAAS,CAAC,CAAC;QAC1C,IAAI,CAAC,IAAI,GAAG,iBAAiB,CAAC;IAChC,CAAC;CACF;AALD,0CAKC;AAED,MAAa,aAAc,SAAQ,UAAU;IAC3C,YAAY,OAAe,EAAE,SAAiB,EAAE,S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AAC;CACF;AALD,0CAKC;AAED,MAAM,eAAe,GAGjB;IACF,GAAG,EAAE,eAAe;IACpB,GAAG,EAAE,mBAAmB;IACxB,GAAG,EAAE,cAAc;IACnB,GAAG,EAAE,aAAa;IAClB,GAAG,EAAE,cAAc;CACpB,CAAC;AAEF,SAAgB,kBAAkB,CAChC,UAAkB,EAClB,IAAa,EACb,eAAuB;IAEvB,IAAI,SAAS,GAAG,eAAe,UAAU,EAAE,CAAC;IAC5C,IAAI,OAAO,GAAG,eAAe,CAAC;IAC9B,IAAI,SAA6B,CAAC;IAElC,IAAI,IAAI,IAAI,OAAO,IAAI,KAAK,QAAQ,EAAE,CAAC;QACrC,MAAM,SAAS,GAAG,IAGjB,CAAC;QAEF,IAAI,SAAS,CAAC,KAAK,EAAE,CAAC;YACpB,SAAS,GAAG,SAAS,CAAC,KAAK,CAAC,UAAU,IAAI,SAAS,CAAC;YACpD,OAAO,GAAG,SAAS,CAAC,KAAK,CAAC,OAAO,IAAI,OAAO,CAAC;QAC/C,CAAC;QACD,SAAS,GAAG,SAAS,CAAC,UAAU,CAAC;IACnC,CAAC;IAED,MAAM,UAAU,GAAG,eAAe,CAAC,UAAU,CAAC,CAAC;IAC/C,IAAI,UAAU,EAAE,CAAC;QACf,OAAO,IAAI,UAAU,CAAC,OAAO,EAAE,SAAS,EAAE,SAAS,CAAC,CAAC;IACvD,CAAC;IAED,OAAO,IAAI,WAAW,CAAC,OAAO,EAAE,SAAS,EAAE,UAAU,EAAE,SAAS,CAAC,CAAC;AACpE,CAAC"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main Qpher client class.
|
|
3
|
+
*/
|
|
4
|
+
import { KEMModule } from './kem';
|
|
5
|
+
import { SignaturesModule } from './signatures';
|
|
6
|
+
import { KeysModule } from './keys';
|
|
7
|
+
import { QpherOptions } from './types';
|
|
8
|
+
/**
|
|
9
|
+
* Qpher PQC API client.
|
|
10
|
+
*
|
|
11
|
+
* @example
|
|
12
|
+
* ```typescript
|
|
13
|
+
* import { Qpher } from '@qpher/sdk';
|
|
14
|
+
*
|
|
15
|
+
* const client = new Qpher({ apiKey: 'qph_live_abc123' });
|
|
16
|
+
*
|
|
17
|
+
* const result = await client.kem.encrypt({
|
|
18
|
+
* plaintext: Buffer.from('Hello!'),
|
|
19
|
+
* keyVersion: 1,
|
|
20
|
+
* });
|
|
21
|
+
*
|
|
22
|
+
* console.log(result.ciphertext);
|
|
23
|
+
* ```
|
|
24
|
+
*/
|
|
25
|
+
export declare class Qpher {
|
|
26
|
+
readonly kem: KEMModule;
|
|
27
|
+
readonly signatures: SignaturesModule;
|
|
28
|
+
readonly keys: KeysModule;
|
|
29
|
+
private readonly http;
|
|
30
|
+
constructor(options: QpherOptions);
|
|
31
|
+
}
|
|
32
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../../src/client.ts"],"names":[],"mappings":"AAAA;;GAEG;AAGH,OAAO,EAAE,SAAS,EAAE,MAAM,OAAO,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,cAAc,CAAC;AAChD,OAAO,EAAE,UAAU,EAAE,MAAM,QAAQ,CAAC;AACpC,OAAO,EAAE,YAAY,EAAE,MAAM,SAAS,CAAC;AAMvC;;;;;;;;;;;;;;;;GAgBG;AACH,qBAAa,KAAK;IAChB,SAAgB,GAAG,EAAE,SAAS,CAAC;IAC/B,SAAgB,UAAU,EAAE,gBAAgB,CAAC;IAC7C,SAAgB,IAAI,EAAE,UAAU,CAAC;IAEjC,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;gBAEtB,OAAO,EAAE,YAAY;CAmBlC"}
|
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Main Qpher client class.
|
|
3
|
+
*/
|
|
4
|
+
import { HttpClient } from './http-client';
|
|
5
|
+
import { KEMModule } from './kem';
|
|
6
|
+
import { SignaturesModule } from './signatures';
|
|
7
|
+
import { KeysModule } from './keys';
|
|
8
|
+
const DEFAULT_BASE_URL = 'https://api.qpher.ai';
|
|
9
|
+
const DEFAULT_TIMEOUT = 30_000; // 30 seconds
|
|
10
|
+
const DEFAULT_MAX_RETRIES = 3;
|
|
11
|
+
/**
|
|
12
|
+
* Qpher PQC API client.
|
|
13
|
+
*
|
|
14
|
+
* @example
|
|
15
|
+
* ```typescript
|
|
16
|
+
* import { Qpher } from '@qpher/sdk';
|
|
17
|
+
*
|
|
18
|
+
* const client = new Qpher({ apiKey: 'qph_live_abc123' });
|
|
19
|
+
*
|
|
20
|
+
* const result = await client.kem.encrypt({
|
|
21
|
+
* plaintext: Buffer.from('Hello!'),
|
|
22
|
+
* keyVersion: 1,
|
|
23
|
+
* });
|
|
24
|
+
*
|
|
25
|
+
* console.log(result.ciphertext);
|
|
26
|
+
* ```
|
|
27
|
+
*/
|
|
28
|
+
export class Qpher {
|
|
29
|
+
kem;
|
|
30
|
+
signatures;
|
|
31
|
+
keys;
|
|
32
|
+
http;
|
|
33
|
+
constructor(options) {
|
|
34
|
+
if (!options.apiKey) {
|
|
35
|
+
throw new Error('apiKey is required');
|
|
36
|
+
}
|
|
37
|
+
if (!options.apiKey.startsWith('qph_')) {
|
|
38
|
+
throw new Error("apiKey must start with 'qph_'");
|
|
39
|
+
}
|
|
40
|
+
this.http = new HttpClient({
|
|
41
|
+
apiKey: options.apiKey,
|
|
42
|
+
baseUrl: (options.baseUrl ?? DEFAULT_BASE_URL).replace(/\/$/, ''),
|
|
43
|
+
timeout: options.timeout ?? DEFAULT_TIMEOUT,
|
|
44
|
+
maxRetries: options.maxRetries ?? DEFAULT_MAX_RETRIES,
|
|
45
|
+
});
|
|
46
|
+
this.kem = new KEMModule(this.http);
|
|
47
|
+
this.signatures = new SignaturesModule(this.http);
|
|
48
|
+
this.keys = new KeysModule(this.http);
|
|
49
|
+
}
|
|
50
|
+
}
|
|
51
|
+
//# sourceMappingURL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IAAI,CAAC,UAAU,GAAG,IAAI,gBAAgB,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;QAClD,IAAI,CAAC,IAAI,GAAG,IAAI,UAAU,CAAC,IAAI,CAAC,IAAI,CAAC,CAAC;IACxC,CAAC;CACF"}
|
|
@@ -0,0 +1,35 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Qpher SDK error classes.
|
|
3
|
+
*/
|
|
4
|
+
export declare class QpherError extends Error {
|
|
5
|
+
readonly errorCode: string;
|
|
6
|
+
readonly statusCode: number;
|
|
7
|
+
readonly requestId?: string;
|
|
8
|
+
constructor(message: string, errorCode: string, statusCode: number, requestId?: string);
|
|
9
|
+
}
|
|
10
|
+
export declare class AuthenticationError extends QpherError {
|
|
11
|
+
constructor(message: string, errorCode: string, requestId?: string);
|
|
12
|
+
}
|
|
13
|
+
export declare class ValidationError extends QpherError {
|
|
14
|
+
constructor(message: string, errorCode: string, requestId?: string);
|
|
15
|
+
}
|
|
16
|
+
export declare class NotFoundError extends QpherError {
|
|
17
|
+
constructor(message: string, errorCode: string, requestId?: string);
|
|
18
|
+
}
|
|
19
|
+
export declare class ForbiddenError extends QpherError {
|
|
20
|
+
constructor(message: string, errorCode: string, requestId?: string);
|
|
21
|
+
}
|
|
22
|
+
export declare class RateLimitError extends QpherError {
|
|
23
|
+
constructor(message: string, errorCode: string, requestId?: string);
|
|
24
|
+
}
|
|
25
|
+
export declare class ServerError extends QpherError {
|
|
26
|
+
constructor(message: string, errorCode: string, statusCode: number, requestId?: string);
|
|
27
|
+
}
|
|
28
|
+
export declare class TimeoutError extends QpherError {
|
|
29
|
+
constructor(message: string, requestId?: string);
|
|
30
|
+
}
|
|
31
|
+
export declare class ConnectionError extends QpherError {
|
|
32
|
+
constructor(message: string, requestId?: string);
|
|
33
|
+
}
|
|
34
|
+
export declare function parseErrorResponse(statusCode: number, body: unknown, fallbackMessage: string): QpherError;
|
|
35
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 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