@korala/api-client 1.0.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 +122 -0
- package/dist/client.d.ts +23 -0
- package/dist/client.d.ts.map +1 -0
- package/dist/client.js +36 -0
- package/dist/errors.d.ts +14 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +23 -0
- package/dist/http.d.ts +18 -0
- package/dist/http.d.ts.map +1 -0
- package/dist/http.js +100 -0
- package/dist/index.d.ts +8 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +22 -0
- package/dist/resources/documents.d.ts +17 -0
- package/dist/resources/documents.d.ts.map +1 -0
- package/dist/resources/documents.js +34 -0
- package/dist/resources/fields.d.ts +10 -0
- package/dist/resources/fields.d.ts.map +1 -0
- package/dist/resources/fields.js +19 -0
- package/dist/resources/signatures.d.ts +13 -0
- package/dist/resources/signatures.d.ts.map +1 -0
- package/dist/resources/signatures.js +25 -0
- package/dist/resources/signers.d.ts +10 -0
- package/dist/resources/signers.d.ts.map +1 -0
- package/dist/resources/signers.js +19 -0
- package/dist/resources/templates.d.ts +24 -0
- package/dist/resources/templates.d.ts.map +1 -0
- package/dist/resources/templates.js +67 -0
- package/dist/resources/webhooks.d.ts +14 -0
- package/dist/resources/webhooks.d.ts.map +1 -0
- package/dist/resources/webhooks.js +31 -0
- package/dist/webhooks/verify.d.ts +8 -0
- package/dist/webhooks/verify.d.ts.map +1 -0
- package/dist/webhooks/verify.js +7 -0
- package/package.json +51 -0
package/README.md
ADDED
|
@@ -0,0 +1,122 @@
|
|
|
1
|
+
# @korala/api-client
|
|
2
|
+
|
|
3
|
+
TypeScript API client for the [Korala](https://korala.ai) document signing platform.
|
|
4
|
+
|
|
5
|
+
## Installation
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
npm install @korala/api-client
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Authentication
|
|
12
|
+
|
|
13
|
+
Korala uses HMAC signature authentication. You'll need an API key ID and secret from your [Korala dashboard](https://korala.ai).
|
|
14
|
+
|
|
15
|
+
```typescript
|
|
16
|
+
import { KoralaClient } from '@korala/api-client';
|
|
17
|
+
|
|
18
|
+
const client = new KoralaClient({
|
|
19
|
+
apiKeyId: 'your-api-key-id',
|
|
20
|
+
apiSecret: 'your-api-secret',
|
|
21
|
+
baseUrl: 'https://api.korala.ai/api/v1', // optional, defaults to production
|
|
22
|
+
});
|
|
23
|
+
```
|
|
24
|
+
|
|
25
|
+
## Usage
|
|
26
|
+
|
|
27
|
+
### Create and send a document
|
|
28
|
+
|
|
29
|
+
```typescript
|
|
30
|
+
// Upload a PDF
|
|
31
|
+
const { documentId, uploadUrl } = await client.documents.createUploadUrl({
|
|
32
|
+
fileName: 'contract.pdf',
|
|
33
|
+
contentType: 'application/pdf',
|
|
34
|
+
});
|
|
35
|
+
|
|
36
|
+
// Upload the file to the presigned URL
|
|
37
|
+
await fetch(uploadUrl, { method: 'PUT', body: pdfBuffer });
|
|
38
|
+
|
|
39
|
+
// Confirm the upload
|
|
40
|
+
await client.documents.confirmUpload(documentId);
|
|
41
|
+
|
|
42
|
+
// Add a signer
|
|
43
|
+
const signer = await client.signers.create(documentId, {
|
|
44
|
+
name: 'John Doe',
|
|
45
|
+
email: 'john@example.com',
|
|
46
|
+
});
|
|
47
|
+
|
|
48
|
+
// Add a signature field
|
|
49
|
+
await client.fields.create(documentId, {
|
|
50
|
+
signerId: signer.id,
|
|
51
|
+
fieldType: 'signature',
|
|
52
|
+
pageNumber: 1,
|
|
53
|
+
xPosition: 100,
|
|
54
|
+
yPosition: 500,
|
|
55
|
+
width: 200,
|
|
56
|
+
height: 50,
|
|
57
|
+
});
|
|
58
|
+
|
|
59
|
+
// Send for signing
|
|
60
|
+
await client.documents.send(documentId);
|
|
61
|
+
```
|
|
62
|
+
|
|
63
|
+
### Create a document from a template
|
|
64
|
+
|
|
65
|
+
```typescript
|
|
66
|
+
const document = await client.templates.createDocument(templateId, {
|
|
67
|
+
name: 'Sales Agreement - Acme Corp',
|
|
68
|
+
signers: {
|
|
69
|
+
buyer: { name: 'Jane Smith', email: 'jane@acme.com' },
|
|
70
|
+
},
|
|
71
|
+
variables: {
|
|
72
|
+
company_name: 'Acme Corporation',
|
|
73
|
+
contract_date: '2026-03-16',
|
|
74
|
+
},
|
|
75
|
+
});
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
### Bulk sign (countersign)
|
|
79
|
+
|
|
80
|
+
Sign multiple documents at once using a saved signature:
|
|
81
|
+
|
|
82
|
+
```typescript
|
|
83
|
+
// Create a saved signature for the signer
|
|
84
|
+
await client.signatures.create({
|
|
85
|
+
email: 'ceo@company.com',
|
|
86
|
+
name: 'Jane Smith',
|
|
87
|
+
signatureImageUrl: 'https://example.com/signature.png',
|
|
88
|
+
isDefault: true,
|
|
89
|
+
});
|
|
90
|
+
|
|
91
|
+
// Bulk sign all pending documents
|
|
92
|
+
const result = await client.documents.bulkSign({
|
|
93
|
+
documentIds: ['doc-1', 'doc-2', 'doc-3'],
|
|
94
|
+
signerEmail: 'ceo@company.com',
|
|
95
|
+
});
|
|
96
|
+
|
|
97
|
+
console.log(`${result.signed} signed, ${result.failed} failed`);
|
|
98
|
+
```
|
|
99
|
+
|
|
100
|
+
### Webhooks
|
|
101
|
+
|
|
102
|
+
```typescript
|
|
103
|
+
const webhook = await client.webhooks.create({
|
|
104
|
+
url: 'https://your-app.com/webhooks/korala',
|
|
105
|
+
events: ['document.completed', 'document.signed'],
|
|
106
|
+
});
|
|
107
|
+
```
|
|
108
|
+
|
|
109
|
+
## API Reference
|
|
110
|
+
|
|
111
|
+
| Resource | Methods |
|
|
112
|
+
|----------|---------|
|
|
113
|
+
| `client.documents` | `createUploadUrl`, `confirmUpload`, `list`, `get`, `send`, `void`, `getAuditTrail`, `bulkSign` |
|
|
114
|
+
| `client.signers` | `list`, `create` |
|
|
115
|
+
| `client.fields` | `list`, `create`, `update`, `delete` |
|
|
116
|
+
| `client.signatures` | `list`, `get`, `create`, `delete` |
|
|
117
|
+
| `client.templates` | `list`, `get`, `createDocument`, `generate` |
|
|
118
|
+
| `client.webhooks` | `list`, `get`, `create`, `update`, `delete` |
|
|
119
|
+
|
|
120
|
+
## License
|
|
121
|
+
|
|
122
|
+
MIT
|
package/dist/client.d.ts
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
import { DocumentsResource } from './resources/documents.js';
|
|
2
|
+
import { FieldsResource } from './resources/fields.js';
|
|
3
|
+
import { SignaturesResource } from './resources/signatures.js';
|
|
4
|
+
import { SignersResource } from './resources/signers.js';
|
|
5
|
+
import { TemplatesResource } from './resources/templates.js';
|
|
6
|
+
import { WebhooksResource } from './resources/webhooks.js';
|
|
7
|
+
export interface KoralaClientConfig {
|
|
8
|
+
apiKeyId: string;
|
|
9
|
+
apiSecret: string;
|
|
10
|
+
baseUrl?: string;
|
|
11
|
+
timeout?: number;
|
|
12
|
+
}
|
|
13
|
+
export declare class KoralaClient {
|
|
14
|
+
readonly documents: DocumentsResource;
|
|
15
|
+
readonly signers: SignersResource;
|
|
16
|
+
readonly fields: FieldsResource;
|
|
17
|
+
readonly signatures: SignaturesResource;
|
|
18
|
+
readonly templates: TemplatesResource;
|
|
19
|
+
readonly webhooks: WebhooksResource;
|
|
20
|
+
private readonly http;
|
|
21
|
+
constructor(config: KoralaClientConfig);
|
|
22
|
+
}
|
|
23
|
+
//# sourceMappingURL=client.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"client.d.ts","sourceRoot":"","sources":["../src/client.ts"],"names":[],"mappings":"AACA,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,cAAc,EAAE,MAAM,uBAAuB,CAAC;AACvD,OAAO,EAAE,kBAAkB,EAAE,MAAM,2BAA2B,CAAC;AAC/D,OAAO,EAAE,eAAe,EAAE,MAAM,wBAAwB,CAAC;AACzD,OAAO,EAAE,iBAAiB,EAAE,MAAM,0BAA0B,CAAC;AAC7D,OAAO,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAE3D,MAAM,WAAW,kBAAkB;IACjC,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,OAAO,CAAC,EAAE,MAAM,CAAC;CAClB;AAKD,qBAAa,YAAY;IACvB,SAAgB,SAAS,EAAE,iBAAiB,CAAC;IAC7C,SAAgB,OAAO,EAAE,eAAe,CAAC;IACzC,SAAgB,MAAM,EAAE,cAAc,CAAC;IACvC,SAAgB,UAAU,EAAE,kBAAkB,CAAC;IAC/C,SAAgB,SAAS,EAAE,iBAAiB,CAAC;IAC7C,SAAgB,QAAQ,EAAE,gBAAgB,CAAC;IAE3C,OAAO,CAAC,QAAQ,CAAC,IAAI,CAAa;gBAEtB,MAAM,EAAE,kBAAkB;CAevC"}
|
package/dist/client.js
ADDED
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KoralaClient = void 0;
|
|
4
|
+
const http_js_1 = require("./http.js");
|
|
5
|
+
const documents_js_1 = require("./resources/documents.js");
|
|
6
|
+
const fields_js_1 = require("./resources/fields.js");
|
|
7
|
+
const signatures_js_1 = require("./resources/signatures.js");
|
|
8
|
+
const signers_js_1 = require("./resources/signers.js");
|
|
9
|
+
const templates_js_1 = require("./resources/templates.js");
|
|
10
|
+
const webhooks_js_1 = require("./resources/webhooks.js");
|
|
11
|
+
const DEFAULT_BASE_URL = 'https://api.korala.ai/api/v1';
|
|
12
|
+
const DEFAULT_TIMEOUT = 30000;
|
|
13
|
+
class KoralaClient {
|
|
14
|
+
documents;
|
|
15
|
+
signers;
|
|
16
|
+
fields;
|
|
17
|
+
signatures;
|
|
18
|
+
templates;
|
|
19
|
+
webhooks;
|
|
20
|
+
http;
|
|
21
|
+
constructor(config) {
|
|
22
|
+
this.http = new http_js_1.HttpClient({
|
|
23
|
+
apiKeyId: config.apiKeyId,
|
|
24
|
+
apiSecret: config.apiSecret,
|
|
25
|
+
baseUrl: config.baseUrl ?? DEFAULT_BASE_URL,
|
|
26
|
+
timeout: config.timeout ?? DEFAULT_TIMEOUT,
|
|
27
|
+
});
|
|
28
|
+
this.documents = new documents_js_1.DocumentsResource(this.http);
|
|
29
|
+
this.signers = new signers_js_1.SignersResource(this.http);
|
|
30
|
+
this.fields = new fields_js_1.FieldsResource(this.http);
|
|
31
|
+
this.signatures = new signatures_js_1.SignaturesResource(this.http);
|
|
32
|
+
this.templates = new templates_js_1.TemplatesResource(this.http);
|
|
33
|
+
this.webhooks = new webhooks_js_1.WebhooksResource(this.http);
|
|
34
|
+
}
|
|
35
|
+
}
|
|
36
|
+
exports.KoralaClient = KoralaClient;
|
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
export declare class KoralaError extends Error {
|
|
2
|
+
readonly status: number;
|
|
3
|
+
readonly code?: string | undefined;
|
|
4
|
+
constructor(status: number, message: string, code?: string | undefined);
|
|
5
|
+
}
|
|
6
|
+
export interface ValidationError {
|
|
7
|
+
field: string;
|
|
8
|
+
message: string;
|
|
9
|
+
}
|
|
10
|
+
export declare class KoralaValidationError extends KoralaError {
|
|
11
|
+
readonly errors: ValidationError[];
|
|
12
|
+
constructor(message: string, errors: ValidationError[]);
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA,qBAAa,WAAY,SAAQ,KAAK;aAElB,MAAM,EAAE,MAAM;aAEd,IAAI,CAAC,EAAE,MAAM;gBAFb,MAAM,EAAE,MAAM,EAC9B,OAAO,EAAE,MAAM,EACC,IAAI,CAAC,EAAE,MAAM,YAAA;CAKhC;AAED,MAAM,WAAW,eAAe;IAC9B,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,qBAAsB,SAAQ,WAAW;aAGlC,MAAM,EAAE,eAAe,EAAE;gBADzC,OAAO,EAAE,MAAM,EACC,MAAM,EAAE,eAAe,EAAE;CAK5C"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,23 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.KoralaValidationError = exports.KoralaError = void 0;
|
|
4
|
+
class KoralaError extends Error {
|
|
5
|
+
status;
|
|
6
|
+
code;
|
|
7
|
+
constructor(status, message, code) {
|
|
8
|
+
super(message);
|
|
9
|
+
this.status = status;
|
|
10
|
+
this.code = code;
|
|
11
|
+
this.name = 'KoralaError';
|
|
12
|
+
}
|
|
13
|
+
}
|
|
14
|
+
exports.KoralaError = KoralaError;
|
|
15
|
+
class KoralaValidationError extends KoralaError {
|
|
16
|
+
errors;
|
|
17
|
+
constructor(message, errors) {
|
|
18
|
+
super(400, message, 'validation_error');
|
|
19
|
+
this.errors = errors;
|
|
20
|
+
this.name = 'KoralaValidationError';
|
|
21
|
+
}
|
|
22
|
+
}
|
|
23
|
+
exports.KoralaValidationError = KoralaValidationError;
|
package/dist/http.d.ts
ADDED
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
export interface HttpClientConfig {
|
|
2
|
+
apiKeyId: string;
|
|
3
|
+
apiSecret: string;
|
|
4
|
+
baseUrl: string;
|
|
5
|
+
timeout: number;
|
|
6
|
+
}
|
|
7
|
+
export declare class HttpClient {
|
|
8
|
+
private readonly config;
|
|
9
|
+
private readonly hashedSecret;
|
|
10
|
+
constructor(config: HttpClientConfig);
|
|
11
|
+
request<T>(method: string, path: string, body?: unknown): Promise<T>;
|
|
12
|
+
private handleError;
|
|
13
|
+
get<T>(path: string): Promise<T>;
|
|
14
|
+
post<T>(path: string, body?: unknown): Promise<T>;
|
|
15
|
+
patch<T>(path: string, body?: unknown): Promise<T>;
|
|
16
|
+
delete<T>(path: string): Promise<T>;
|
|
17
|
+
}
|
|
18
|
+
//# sourceMappingURL=http.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"http.d.ts","sourceRoot":"","sources":["../src/http.ts"],"names":[],"mappings":"AAIA,MAAM,WAAW,gBAAgB;IAC/B,QAAQ,EAAE,MAAM,CAAC;IACjB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,EAAE,MAAM,CAAC;IAChB,OAAO,EAAE,MAAM,CAAC;CACjB;AAED,qBAAa,UAAU;IAGT,OAAO,CAAC,QAAQ,CAAC,MAAM;IAFnC,OAAO,CAAC,QAAQ,CAAC,YAAY,CAAS;gBAET,MAAM,EAAE,gBAAgB;IAK/C,OAAO,CAAC,CAAC,EAAE,MAAM,EAAE,MAAM,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;YAkE5D,WAAW;IAmCzB,GAAG,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;IAIhC,IAAI,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAIjD,KAAK,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,EAAE,IAAI,CAAC,EAAE,OAAO,GAAG,OAAO,CAAC,CAAC,CAAC;IAIlD,MAAM,CAAC,CAAC,EAAE,IAAI,EAAE,MAAM,GAAG,OAAO,CAAC,CAAC,CAAC;CAGpC"}
|
package/dist/http.js
ADDED
|
@@ -0,0 +1,100 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.HttpClient = void 0;
|
|
4
|
+
const auth_1 = require("@korala/auth");
|
|
5
|
+
const internal_1 = require("@korala/auth/internal");
|
|
6
|
+
const errors_js_1 = require("./errors.js");
|
|
7
|
+
class HttpClient {
|
|
8
|
+
config;
|
|
9
|
+
hashedSecret;
|
|
10
|
+
constructor(config) {
|
|
11
|
+
this.config = config;
|
|
12
|
+
// Hash the secret to match how the server stores and verifies signatures
|
|
13
|
+
this.hashedSecret = (0, internal_1.hashSecret)(config.apiSecret);
|
|
14
|
+
}
|
|
15
|
+
async request(method, path, body) {
|
|
16
|
+
const url = `${this.config.baseUrl}${path}`;
|
|
17
|
+
const bodyString = body ? JSON.stringify(body) : undefined;
|
|
18
|
+
// Extract the path from baseUrl to get the full API path for signing
|
|
19
|
+
const baseUrlPath = new URL(this.config.baseUrl).pathname;
|
|
20
|
+
const fullPath = `${baseUrlPath}${path}`;
|
|
21
|
+
const authHeaders = (0, auth_1.signRequest)({ method, path: fullPath, body: bodyString }, this.config.apiKeyId, this.hashedSecret);
|
|
22
|
+
const headers = {
|
|
23
|
+
...authHeaders,
|
|
24
|
+
};
|
|
25
|
+
// Only set Content-Type if there's a body
|
|
26
|
+
if (bodyString) {
|
|
27
|
+
headers['Content-Type'] = 'application/json';
|
|
28
|
+
}
|
|
29
|
+
const controller = new AbortController();
|
|
30
|
+
const timeoutId = setTimeout(() => controller.abort(), this.config.timeout);
|
|
31
|
+
try {
|
|
32
|
+
const response = await fetch(url, {
|
|
33
|
+
method,
|
|
34
|
+
headers,
|
|
35
|
+
body: bodyString,
|
|
36
|
+
signal: controller.signal,
|
|
37
|
+
});
|
|
38
|
+
clearTimeout(timeoutId);
|
|
39
|
+
if (!response.ok) {
|
|
40
|
+
await this.handleError(response);
|
|
41
|
+
}
|
|
42
|
+
// Handle empty responses (e.g., 204 No Content)
|
|
43
|
+
const text = await response.text();
|
|
44
|
+
if (!text) {
|
|
45
|
+
return undefined;
|
|
46
|
+
}
|
|
47
|
+
return JSON.parse(text);
|
|
48
|
+
}
|
|
49
|
+
catch (error) {
|
|
50
|
+
clearTimeout(timeoutId);
|
|
51
|
+
if (error instanceof errors_js_1.KoralaError) {
|
|
52
|
+
throw error;
|
|
53
|
+
}
|
|
54
|
+
if (error instanceof Error && error.name === 'AbortError') {
|
|
55
|
+
throw new errors_js_1.KoralaError(0, 'Request timeout', 'timeout');
|
|
56
|
+
}
|
|
57
|
+
throw new errors_js_1.KoralaError(0, error instanceof Error ? error.message : 'Unknown error', 'network_error');
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
async handleError(response) {
|
|
61
|
+
let errorData = {};
|
|
62
|
+
try {
|
|
63
|
+
const text = await response.text();
|
|
64
|
+
if (text) {
|
|
65
|
+
errorData = JSON.parse(text);
|
|
66
|
+
}
|
|
67
|
+
}
|
|
68
|
+
catch {
|
|
69
|
+
// Ignore JSON parse errors
|
|
70
|
+
}
|
|
71
|
+
const message = errorData.message || errorData.error || response.statusText;
|
|
72
|
+
// Check for validation errors
|
|
73
|
+
if (response.status === 400 && Array.isArray(errorData.errors)) {
|
|
74
|
+
throw new errors_js_1.KoralaValidationError(message, errorData.errors.map((e) => {
|
|
75
|
+
if (typeof e === 'object' && e !== null) {
|
|
76
|
+
const err = e;
|
|
77
|
+
return {
|
|
78
|
+
field: String(err.field || err.property || 'unknown'),
|
|
79
|
+
message: String(err.message || err.constraints || 'Invalid'),
|
|
80
|
+
};
|
|
81
|
+
}
|
|
82
|
+
return { field: 'unknown', message: String(e) };
|
|
83
|
+
}));
|
|
84
|
+
}
|
|
85
|
+
throw new errors_js_1.KoralaError(response.status, message);
|
|
86
|
+
}
|
|
87
|
+
get(path) {
|
|
88
|
+
return this.request('GET', path);
|
|
89
|
+
}
|
|
90
|
+
post(path, body) {
|
|
91
|
+
return this.request('POST', path, body);
|
|
92
|
+
}
|
|
93
|
+
patch(path, body) {
|
|
94
|
+
return this.request('PATCH', path, body);
|
|
95
|
+
}
|
|
96
|
+
delete(path) {
|
|
97
|
+
return this.request('DELETE', path);
|
|
98
|
+
}
|
|
99
|
+
}
|
|
100
|
+
exports.HttpClient = HttpClient;
|
package/dist/index.d.ts
ADDED
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
export type { AddFieldDto, AddSignerDto, AuditEventDto, CreateDocumentFromTemplateDto, CreateSignerRoleDto, CreateTemplateDto, CreateTemplateFieldDto, CreateTemplateUploadUrlDto, CreateUploadUrlDto, CreateWebhookDto, DocumentDto, FieldDto, GenerateDocumentDto, GeneratedDocumentDto, SignerDto, TemplateDto, TemplateFieldDto, TemplateSignerRoleDto, TemplateUploadUrlResponseDto, TemplateWithDetailsDto, UpdateSignerRoleDto, UpdateTemplateDto, UpdateTemplateFieldDto, UpdateWebhookDto, UploadUrlResponseDto, WebhookDeliveryDto, WebhookDto, WebhookWithSecretDto, } from '@korala/public-dtos';
|
|
2
|
+
export { AuthMethod, DocumentStatus, FieldType, SignerRole, SignerStatus, WebhookDeliveryStatus, WebhookEventType, } from '@korala/public-dtos';
|
|
3
|
+
export { KoralaClient, type KoralaClientConfig } from './client.js';
|
|
4
|
+
export type { ValidationError } from './errors.js';
|
|
5
|
+
export { KoralaError, KoralaValidationError } from './errors.js';
|
|
6
|
+
export type { VerifyWebhookOptions } from './webhooks/verify.js';
|
|
7
|
+
export { verifyWebhookSignature } from './webhooks/verify.js';
|
|
8
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAGA,YAAY,EAEV,WAAW,EAEX,YAAY,EACZ,aAAa,EAEb,6BAA6B,EAC7B,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,0BAA0B,EAE1B,kBAAkB,EAElB,gBAAgB,EAChB,WAAW,EACX,QAAQ,EACR,mBAAmB,EACnB,oBAAoB,EACpB,SAAS,EACT,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,4BAA4B,EAC5B,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,gBAAgB,EAChB,oBAAoB,EACpB,kBAAkB,EAClB,UAAU,EACV,oBAAoB,GACrB,MAAM,qBAAqB,CAAC;AAE7B,OAAO,EACL,UAAU,EACV,cAAc,EACd,SAAS,EACT,UAAU,EACV,YAAY,EACZ,qBAAqB,EACrB,gBAAgB,GACjB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,EAAE,YAAY,EAAE,KAAK,kBAAkB,EAAE,MAAM,aAAa,CAAC;AACpE,YAAY,EAAE,eAAe,EAAE,MAAM,aAAa,CAAC;AAEnD,OAAO,EAAE,WAAW,EAAE,qBAAqB,EAAE,MAAM,aAAa,CAAC;AACjE,YAAY,EAAE,oBAAoB,EAAE,MAAM,sBAAsB,CAAC;AAEjE,OAAO,EAAE,sBAAsB,EAAE,MAAM,sBAAsB,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,22 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
// Client
|
|
3
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
4
|
+
exports.verifyWebhookSignature = exports.KoralaValidationError = exports.KoralaError = exports.KoralaClient = exports.WebhookEventType = exports.WebhookDeliveryStatus = exports.SignerStatus = exports.SignerRole = exports.FieldType = exports.DocumentStatus = exports.AuthMethod = void 0;
|
|
5
|
+
// Re-export enums as values (not just types)
|
|
6
|
+
var public_dtos_1 = require("@korala/public-dtos");
|
|
7
|
+
Object.defineProperty(exports, "AuthMethod", { enumerable: true, get: function () { return public_dtos_1.AuthMethod; } });
|
|
8
|
+
Object.defineProperty(exports, "DocumentStatus", { enumerable: true, get: function () { return public_dtos_1.DocumentStatus; } });
|
|
9
|
+
Object.defineProperty(exports, "FieldType", { enumerable: true, get: function () { return public_dtos_1.FieldType; } });
|
|
10
|
+
Object.defineProperty(exports, "SignerRole", { enumerable: true, get: function () { return public_dtos_1.SignerRole; } });
|
|
11
|
+
Object.defineProperty(exports, "SignerStatus", { enumerable: true, get: function () { return public_dtos_1.SignerStatus; } });
|
|
12
|
+
Object.defineProperty(exports, "WebhookDeliveryStatus", { enumerable: true, get: function () { return public_dtos_1.WebhookDeliveryStatus; } });
|
|
13
|
+
Object.defineProperty(exports, "WebhookEventType", { enumerable: true, get: function () { return public_dtos_1.WebhookEventType; } });
|
|
14
|
+
var client_js_1 = require("./client.js");
|
|
15
|
+
Object.defineProperty(exports, "KoralaClient", { enumerable: true, get: function () { return client_js_1.KoralaClient; } });
|
|
16
|
+
// Errors
|
|
17
|
+
var errors_js_1 = require("./errors.js");
|
|
18
|
+
Object.defineProperty(exports, "KoralaError", { enumerable: true, get: function () { return errors_js_1.KoralaError; } });
|
|
19
|
+
Object.defineProperty(exports, "KoralaValidationError", { enumerable: true, get: function () { return errors_js_1.KoralaValidationError; } });
|
|
20
|
+
// Webhook verification
|
|
21
|
+
var verify_js_1 = require("./webhooks/verify.js");
|
|
22
|
+
Object.defineProperty(exports, "verifyWebhookSignature", { enumerable: true, get: function () { return verify_js_1.verifyWebhookSignature; } });
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import type { AuditEventDto, BulkSignRequestDto, BulkSignResponseDto, CreateUploadUrlDto, DocumentDto, UploadUrlResponseDto } from '@korala/public-dtos';
|
|
2
|
+
import type { HttpClient } from '../http.js';
|
|
3
|
+
export declare class DocumentsResource {
|
|
4
|
+
private readonly http;
|
|
5
|
+
constructor(http: HttpClient);
|
|
6
|
+
createUploadUrl(data: CreateUploadUrlDto): Promise<UploadUrlResponseDto>;
|
|
7
|
+
confirmUpload(documentId: string): Promise<DocumentDto>;
|
|
8
|
+
list(): Promise<DocumentDto[]>;
|
|
9
|
+
get(documentId: string): Promise<DocumentDto>;
|
|
10
|
+
send(documentId: string, options?: {
|
|
11
|
+
suppressNotifications?: boolean;
|
|
12
|
+
}): Promise<DocumentDto>;
|
|
13
|
+
void(documentId: string): Promise<DocumentDto>;
|
|
14
|
+
getAuditTrail(documentId: string): Promise<AuditEventDto[]>;
|
|
15
|
+
bulkSign(data: BulkSignRequestDto): Promise<BulkSignResponseDto>;
|
|
16
|
+
}
|
|
17
|
+
//# sourceMappingURL=documents.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"documents.d.ts","sourceRoot":"","sources":["../../src/resources/documents.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,aAAa,EACb,kBAAkB,EAClB,mBAAmB,EACnB,kBAAkB,EAClB,WAAW,EACX,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,eAAe,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAIxE,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAIvD,IAAI,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAI9B,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAI7C,IAAI,CACF,UAAU,EAAE,MAAM,EAClB,OAAO,CAAC,EAAE;QAAE,qBAAqB,CAAC,EAAE,OAAO,CAAA;KAAE,GAC5C,OAAO,CAAC,WAAW,CAAC;IAOvB,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,WAAW,CAAC;IAI9C,aAAa,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,aAAa,EAAE,CAAC;IAM3D,QAAQ,CAAC,IAAI,EAAE,kBAAkB,GAAG,OAAO,CAAC,mBAAmB,CAAC;CAGjE"}
|
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.DocumentsResource = void 0;
|
|
4
|
+
class DocumentsResource {
|
|
5
|
+
http;
|
|
6
|
+
constructor(http) {
|
|
7
|
+
this.http = http;
|
|
8
|
+
}
|
|
9
|
+
createUploadUrl(data) {
|
|
10
|
+
return this.http.post('/documents/upload-url', data);
|
|
11
|
+
}
|
|
12
|
+
confirmUpload(documentId) {
|
|
13
|
+
return this.http.post(`/documents/${documentId}/confirm`);
|
|
14
|
+
}
|
|
15
|
+
list() {
|
|
16
|
+
return this.http.get('/documents');
|
|
17
|
+
}
|
|
18
|
+
get(documentId) {
|
|
19
|
+
return this.http.get(`/documents/${documentId}`);
|
|
20
|
+
}
|
|
21
|
+
send(documentId, options) {
|
|
22
|
+
return this.http.post(`/documents/${documentId}/send`, options);
|
|
23
|
+
}
|
|
24
|
+
void(documentId) {
|
|
25
|
+
return this.http.post(`/documents/${documentId}/void`);
|
|
26
|
+
}
|
|
27
|
+
getAuditTrail(documentId) {
|
|
28
|
+
return this.http.get(`/documents/${documentId}/audit-trail`);
|
|
29
|
+
}
|
|
30
|
+
bulkSign(data) {
|
|
31
|
+
return this.http.post('/documents/bulk-sign', data);
|
|
32
|
+
}
|
|
33
|
+
}
|
|
34
|
+
exports.DocumentsResource = DocumentsResource;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AddFieldDto, FieldDto } from '@korala/public-dtos';
|
|
2
|
+
import type { HttpClient } from '../http.js';
|
|
3
|
+
export declare class FieldsResource {
|
|
4
|
+
private readonly http;
|
|
5
|
+
constructor(http: HttpClient);
|
|
6
|
+
create(documentId: string, data: AddFieldDto): Promise<FieldDto>;
|
|
7
|
+
list(documentId: string): Promise<FieldDto[]>;
|
|
8
|
+
delete(documentId: string, fieldId: string): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=fields.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"fields.d.ts","sourceRoot":"","sources":["../../src/resources/fields.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,WAAW,EAAE,QAAQ,EAAE,MAAM,qBAAqB,CAAC;AACjE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,qBAAa,cAAc;IACb,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,WAAW,GAAG,OAAO,CAAC,QAAQ,CAAC;IAIhE,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,QAAQ,EAAE,CAAC;IAI7C,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAG3D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.FieldsResource = void 0;
|
|
4
|
+
class FieldsResource {
|
|
5
|
+
http;
|
|
6
|
+
constructor(http) {
|
|
7
|
+
this.http = http;
|
|
8
|
+
}
|
|
9
|
+
create(documentId, data) {
|
|
10
|
+
return this.http.post(`/documents/${documentId}/fields`, data);
|
|
11
|
+
}
|
|
12
|
+
list(documentId) {
|
|
13
|
+
return this.http.get(`/documents/${documentId}/fields`);
|
|
14
|
+
}
|
|
15
|
+
delete(documentId, fieldId) {
|
|
16
|
+
return this.http.delete(`/documents/${documentId}/fields/${fieldId}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.FieldsResource = FieldsResource;
|
|
@@ -0,0 +1,13 @@
|
|
|
1
|
+
import type { CreateSavedSignatureDto, SavedSignatureDto } from '@korala/public-dtos';
|
|
2
|
+
import type { HttpClient } from '../http.js';
|
|
3
|
+
export declare class SignaturesResource {
|
|
4
|
+
private readonly http;
|
|
5
|
+
constructor(http: HttpClient);
|
|
6
|
+
create(data: CreateSavedSignatureDto): Promise<SavedSignatureDto>;
|
|
7
|
+
list(params?: {
|
|
8
|
+
email?: string;
|
|
9
|
+
}): Promise<SavedSignatureDto[]>;
|
|
10
|
+
get(id: string): Promise<SavedSignatureDto>;
|
|
11
|
+
delete(id: string): Promise<void>;
|
|
12
|
+
}
|
|
13
|
+
//# sourceMappingURL=signatures.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signatures.d.ts","sourceRoot":"","sources":["../../src/resources/signatures.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,uBAAuB,EACvB,iBAAiB,EAClB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,qBAAa,kBAAkB;IACjB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,MAAM,CAAC,IAAI,EAAE,uBAAuB,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAIjE,IAAI,CAAC,MAAM,CAAC,EAAE;QAAE,KAAK,CAAC,EAAE,MAAM,CAAA;KAAE,GAAG,OAAO,CAAC,iBAAiB,EAAE,CAAC;IAO/D,GAAG,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC;IAI3C,MAAM,CAAC,EAAE,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAGlC"}
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SignaturesResource = void 0;
|
|
4
|
+
class SignaturesResource {
|
|
5
|
+
http;
|
|
6
|
+
constructor(http) {
|
|
7
|
+
this.http = http;
|
|
8
|
+
}
|
|
9
|
+
create(data) {
|
|
10
|
+
return this.http.post('/signatures', data);
|
|
11
|
+
}
|
|
12
|
+
list(params) {
|
|
13
|
+
const query = params?.email
|
|
14
|
+
? `?email=${encodeURIComponent(params.email)}`
|
|
15
|
+
: '';
|
|
16
|
+
return this.http.get(`/signatures${query}`);
|
|
17
|
+
}
|
|
18
|
+
get(id) {
|
|
19
|
+
return this.http.get(`/signatures/${id}`);
|
|
20
|
+
}
|
|
21
|
+
delete(id) {
|
|
22
|
+
return this.http.delete(`/signatures/${id}`);
|
|
23
|
+
}
|
|
24
|
+
}
|
|
25
|
+
exports.SignaturesResource = SignaturesResource;
|
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
import type { AddSignerDto, SignerDto } from '@korala/public-dtos';
|
|
2
|
+
import type { HttpClient } from '../http.js';
|
|
3
|
+
export declare class SignersResource {
|
|
4
|
+
private readonly http;
|
|
5
|
+
constructor(http: HttpClient);
|
|
6
|
+
create(documentId: string, data: AddSignerDto): Promise<SignerDto>;
|
|
7
|
+
list(documentId: string): Promise<SignerDto[]>;
|
|
8
|
+
delete(documentId: string, signerId: string): Promise<void>;
|
|
9
|
+
}
|
|
10
|
+
//# sourceMappingURL=signers.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"signers.d.ts","sourceRoot":"","sources":["../../src/resources/signers.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,YAAY,EAAE,SAAS,EAAE,MAAM,qBAAqB,CAAC;AACnE,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,qBAAa,eAAe;IACd,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,YAAY,GAAG,OAAO,CAAC,SAAS,CAAC;IAIlE,IAAI,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,EAAE,CAAC;IAI9C,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;CAK5D"}
|
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.SignersResource = void 0;
|
|
4
|
+
class SignersResource {
|
|
5
|
+
http;
|
|
6
|
+
constructor(http) {
|
|
7
|
+
this.http = http;
|
|
8
|
+
}
|
|
9
|
+
create(documentId, data) {
|
|
10
|
+
return this.http.post(`/documents/${documentId}/signers`, data);
|
|
11
|
+
}
|
|
12
|
+
list(documentId) {
|
|
13
|
+
return this.http.get(`/documents/${documentId}/signers`);
|
|
14
|
+
}
|
|
15
|
+
delete(documentId, signerId) {
|
|
16
|
+
return this.http.delete(`/documents/${documentId}/signers/${signerId}`);
|
|
17
|
+
}
|
|
18
|
+
}
|
|
19
|
+
exports.SignersResource = SignersResource;
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
import type { CreateDocumentFromTemplateDto, CreateSignerRoleDto, CreateTemplateDto, CreateTemplateFieldDto, CreateTemplateUploadUrlDto, DetectedMergeFieldDto, DocumentDto, GenerateDocumentDto, GeneratedDocumentDto, TemplateDto, TemplateFieldDto, TemplateSignerRoleDto, TemplateUploadUrlResponseDto, TemplateWithDetailsDto, UpdateSignerRoleDto, UpdateTemplateDto, UpdateTemplateFieldDto } from '@korala/public-dtos';
|
|
2
|
+
import type { HttpClient } from '../http.js';
|
|
3
|
+
export declare class TemplatesResource {
|
|
4
|
+
private readonly http;
|
|
5
|
+
constructor(http: HttpClient);
|
|
6
|
+
createUploadUrl(data: CreateTemplateUploadUrlDto): Promise<TemplateUploadUrlResponseDto>;
|
|
7
|
+
confirmUpload(templateId: string, data: CreateTemplateDto): Promise<TemplateDto>;
|
|
8
|
+
list(): Promise<TemplateDto[]>;
|
|
9
|
+
get(templateId: string): Promise<TemplateWithDetailsDto>;
|
|
10
|
+
update(templateId: string, data: UpdateTemplateDto): Promise<TemplateDto>;
|
|
11
|
+
delete(templateId: string): Promise<void>;
|
|
12
|
+
addSignerRole(templateId: string, data: CreateSignerRoleDto): Promise<TemplateSignerRoleDto>;
|
|
13
|
+
getSignerRoles(templateId: string): Promise<TemplateSignerRoleDto[]>;
|
|
14
|
+
updateSignerRole(templateId: string, roleId: string, data: UpdateSignerRoleDto): Promise<TemplateSignerRoleDto>;
|
|
15
|
+
deleteSignerRole(templateId: string, roleId: string): Promise<void>;
|
|
16
|
+
addField(templateId: string, data: CreateTemplateFieldDto): Promise<TemplateFieldDto>;
|
|
17
|
+
getFields(templateId: string): Promise<TemplateFieldDto[]>;
|
|
18
|
+
updateField(templateId: string, fieldId: string, data: UpdateTemplateFieldDto): Promise<TemplateFieldDto>;
|
|
19
|
+
deleteField(templateId: string, fieldId: string): Promise<void>;
|
|
20
|
+
getMergeFields(templateId: string): Promise<DetectedMergeFieldDto[]>;
|
|
21
|
+
createDocument(templateId: string, data: CreateDocumentFromTemplateDto): Promise<DocumentDto>;
|
|
22
|
+
generate(templateId: string, data?: GenerateDocumentDto): Promise<GeneratedDocumentDto>;
|
|
23
|
+
}
|
|
24
|
+
//# sourceMappingURL=templates.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"templates.d.ts","sourceRoot":"","sources":["../../src/resources/templates.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,6BAA6B,EAC7B,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACtB,0BAA0B,EAC1B,qBAAqB,EACrB,WAAW,EACX,mBAAmB,EACnB,oBAAoB,EACpB,WAAW,EACX,gBAAgB,EAChB,qBAAqB,EACrB,4BAA4B,EAC5B,sBAAsB,EACtB,mBAAmB,EACnB,iBAAiB,EACjB,sBAAsB,EACvB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,qBAAa,iBAAiB;IAChB,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAI7C,eAAe,CACb,IAAI,EAAE,0BAA0B,GAC/B,OAAO,CAAC,4BAA4B,CAAC;IAOxC,aAAa,CACX,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,iBAAiB,GACtB,OAAO,CAAC,WAAW,CAAC;IAOvB,IAAI,IAAI,OAAO,CAAC,WAAW,EAAE,CAAC;IAI9B,GAAG,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,sBAAsB,CAAC;IAIxD,MAAM,CAAC,UAAU,EAAE,MAAM,EAAE,IAAI,EAAE,iBAAiB,GAAG,OAAO,CAAC,WAAW,CAAC;IAIzE,MAAM,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMzC,aAAa,CACX,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,qBAAqB,CAAC;IAOjC,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAMpE,gBAAgB,CACd,UAAU,EAAE,MAAM,EAClB,MAAM,EAAE,MAAM,EACd,IAAI,EAAE,mBAAmB,GACxB,OAAO,CAAC,qBAAqB,CAAC;IAOjC,gBAAgB,CAAC,UAAU,EAAE,MAAM,EAAE,MAAM,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAMnE,QAAQ,CACN,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,gBAAgB,CAAC;IAO5B,SAAS,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,gBAAgB,EAAE,CAAC;IAI1D,WAAW,CACT,UAAU,EAAE,MAAM,EAClB,OAAO,EAAE,MAAM,EACf,IAAI,EAAE,sBAAsB,GAC3B,OAAO,CAAC,gBAAgB,CAAC;IAO5B,WAAW,CAAC,UAAU,EAAE,MAAM,EAAE,OAAO,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAM/D,cAAc,CAAC,UAAU,EAAE,MAAM,GAAG,OAAO,CAAC,qBAAqB,EAAE,CAAC;IAQpE,cAAc,CACZ,UAAU,EAAE,MAAM,EAClB,IAAI,EAAE,6BAA6B,GAClC,OAAO,CAAC,WAAW,CAAC;IASvB,QAAQ,CACN,UAAU,EAAE,MAAM,EAClB,IAAI,GAAE,mBAAwB,GAC7B,OAAO,CAAC,oBAAoB,CAAC;CAMjC"}
|
|
@@ -0,0 +1,67 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.TemplatesResource = void 0;
|
|
4
|
+
class TemplatesResource {
|
|
5
|
+
http;
|
|
6
|
+
constructor(http) {
|
|
7
|
+
this.http = http;
|
|
8
|
+
}
|
|
9
|
+
// Template CRUD
|
|
10
|
+
createUploadUrl(data) {
|
|
11
|
+
return this.http.post('/templates/upload-url', data);
|
|
12
|
+
}
|
|
13
|
+
confirmUpload(templateId, data) {
|
|
14
|
+
return this.http.post(`/templates/${templateId}/confirm`, data);
|
|
15
|
+
}
|
|
16
|
+
list() {
|
|
17
|
+
return this.http.get('/templates');
|
|
18
|
+
}
|
|
19
|
+
get(templateId) {
|
|
20
|
+
return this.http.get(`/templates/${templateId}`);
|
|
21
|
+
}
|
|
22
|
+
update(templateId, data) {
|
|
23
|
+
return this.http.patch(`/templates/${templateId}`, data);
|
|
24
|
+
}
|
|
25
|
+
delete(templateId) {
|
|
26
|
+
return this.http.delete(`/templates/${templateId}`);
|
|
27
|
+
}
|
|
28
|
+
// Signer Roles
|
|
29
|
+
addSignerRole(templateId, data) {
|
|
30
|
+
return this.http.post(`/templates/${templateId}/signer-roles`, data);
|
|
31
|
+
}
|
|
32
|
+
getSignerRoles(templateId) {
|
|
33
|
+
return this.http.get(`/templates/${templateId}/signer-roles`);
|
|
34
|
+
}
|
|
35
|
+
updateSignerRole(templateId, roleId, data) {
|
|
36
|
+
return this.http.patch(`/templates/${templateId}/signer-roles/${roleId}`, data);
|
|
37
|
+
}
|
|
38
|
+
deleteSignerRole(templateId, roleId) {
|
|
39
|
+
return this.http.delete(`/templates/${templateId}/signer-roles/${roleId}`);
|
|
40
|
+
}
|
|
41
|
+
// Fields
|
|
42
|
+
addField(templateId, data) {
|
|
43
|
+
return this.http.post(`/templates/${templateId}/fields`, data);
|
|
44
|
+
}
|
|
45
|
+
getFields(templateId) {
|
|
46
|
+
return this.http.get(`/templates/${templateId}/fields`);
|
|
47
|
+
}
|
|
48
|
+
updateField(templateId, fieldId, data) {
|
|
49
|
+
return this.http.patch(`/templates/${templateId}/fields/${fieldId}`, data);
|
|
50
|
+
}
|
|
51
|
+
deleteField(templateId, fieldId) {
|
|
52
|
+
return this.http.delete(`/templates/${templateId}/fields/${fieldId}`);
|
|
53
|
+
}
|
|
54
|
+
// Merge Fields (DOCX templates)
|
|
55
|
+
getMergeFields(templateId) {
|
|
56
|
+
return this.http.get(`/templates/${templateId}/merge-fields`);
|
|
57
|
+
}
|
|
58
|
+
// Create document from template
|
|
59
|
+
createDocument(templateId, data) {
|
|
60
|
+
return this.http.post(`/templates/${templateId}/create-document`, data);
|
|
61
|
+
}
|
|
62
|
+
// Generate PDF from template (no signing workflow)
|
|
63
|
+
generate(templateId, data = {}) {
|
|
64
|
+
return this.http.post(`/templates/${templateId}/generate`, data);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
exports.TemplatesResource = TemplatesResource;
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import type { CreateWebhookDto, UpdateWebhookDto, WebhookDeliveryDto, WebhookDto, WebhookWithSecretDto } from '@korala/public-dtos';
|
|
2
|
+
import type { HttpClient } from '../http.js';
|
|
3
|
+
export declare class WebhooksResource {
|
|
4
|
+
private readonly http;
|
|
5
|
+
constructor(http: HttpClient);
|
|
6
|
+
create(data: CreateWebhookDto): Promise<WebhookWithSecretDto>;
|
|
7
|
+
list(): Promise<WebhookDto[]>;
|
|
8
|
+
get(webhookId: string): Promise<WebhookDto>;
|
|
9
|
+
update(webhookId: string, data: UpdateWebhookDto): Promise<WebhookDto>;
|
|
10
|
+
delete(webhookId: string): Promise<void>;
|
|
11
|
+
getDeliveries(webhookId: string): Promise<WebhookDeliveryDto[]>;
|
|
12
|
+
sendTestEvent(webhookId: string): Promise<WebhookDeliveryDto>;
|
|
13
|
+
}
|
|
14
|
+
//# sourceMappingURL=webhooks.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"webhooks.d.ts","sourceRoot":"","sources":["../../src/resources/webhooks.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACV,gBAAgB,EAChB,gBAAgB,EAChB,kBAAkB,EAClB,UAAU,EACV,oBAAoB,EACrB,MAAM,qBAAqB,CAAC;AAC7B,OAAO,KAAK,EAAE,UAAU,EAAE,MAAM,YAAY,CAAC;AAE7C,qBAAa,gBAAgB;IACf,OAAO,CAAC,QAAQ,CAAC,IAAI;gBAAJ,IAAI,EAAE,UAAU;IAE7C,MAAM,CAAC,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,oBAAoB,CAAC;IAI7D,IAAI,IAAI,OAAO,CAAC,UAAU,EAAE,CAAC;IAI7B,GAAG,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,UAAU,CAAC;IAI3C,MAAM,CAAC,SAAS,EAAE,MAAM,EAAE,IAAI,EAAE,gBAAgB,GAAG,OAAO,CAAC,UAAU,CAAC;IAItE,MAAM,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,IAAI,CAAC;IAIxC,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,EAAE,CAAC;IAM/D,aAAa,CAAC,SAAS,EAAE,MAAM,GAAG,OAAO,CAAC,kBAAkB,CAAC;CAG9D"}
|
|
@@ -0,0 +1,31 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WebhooksResource = void 0;
|
|
4
|
+
class WebhooksResource {
|
|
5
|
+
http;
|
|
6
|
+
constructor(http) {
|
|
7
|
+
this.http = http;
|
|
8
|
+
}
|
|
9
|
+
create(data) {
|
|
10
|
+
return this.http.post('/webhooks', data);
|
|
11
|
+
}
|
|
12
|
+
list() {
|
|
13
|
+
return this.http.get('/webhooks');
|
|
14
|
+
}
|
|
15
|
+
get(webhookId) {
|
|
16
|
+
return this.http.get(`/webhooks/${webhookId}`);
|
|
17
|
+
}
|
|
18
|
+
update(webhookId, data) {
|
|
19
|
+
return this.http.patch(`/webhooks/${webhookId}`, data);
|
|
20
|
+
}
|
|
21
|
+
delete(webhookId) {
|
|
22
|
+
return this.http.delete(`/webhooks/${webhookId}`);
|
|
23
|
+
}
|
|
24
|
+
getDeliveries(webhookId) {
|
|
25
|
+
return this.http.get(`/webhooks/${webhookId}/deliveries`);
|
|
26
|
+
}
|
|
27
|
+
sendTestEvent(webhookId) {
|
|
28
|
+
return this.http.post(`/webhooks/${webhookId}/test`);
|
|
29
|
+
}
|
|
30
|
+
}
|
|
31
|
+
exports.WebhooksResource = WebhooksResource;
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../../src/webhooks/verify.ts"],"names":[],"mappings":"AAEA,MAAM,WAAW,oBAAoB;IACnC,MAAM,EAAE,MAAM,CAAC;IACf,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,IAAI,EAAE,MAAM,CAAC;CACd;AAED,wBAAgB,sBAAsB,CAAC,OAAO,EAAE,oBAAoB,GAAG,OAAO,CAO7E"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.verifyWebhookSignature = verifyWebhookSignature;
|
|
4
|
+
const auth_1 = require("@korala/auth");
|
|
5
|
+
function verifyWebhookSignature(options) {
|
|
6
|
+
return (0, auth_1.verifyWebhookSignature)(options.body, options.timestamp, options.signature, options.secret);
|
|
7
|
+
}
|
package/package.json
ADDED
|
@@ -0,0 +1,51 @@
|
|
|
1
|
+
{
|
|
2
|
+
"name": "@korala/api-client",
|
|
3
|
+
"version": "1.0.0",
|
|
4
|
+
"description": "TypeScript API client for Korala document signing API",
|
|
5
|
+
"license": "MIT",
|
|
6
|
+
"repository": {
|
|
7
|
+
"type": "git",
|
|
8
|
+
"url": "git+https://github.com/korala-ai/korala.git",
|
|
9
|
+
"directory": "packages/api-client"
|
|
10
|
+
},
|
|
11
|
+
"main": "./dist/index.js",
|
|
12
|
+
"types": "./dist/index.d.ts",
|
|
13
|
+
"exports": {
|
|
14
|
+
".": {
|
|
15
|
+
"types": "./dist/index.d.ts",
|
|
16
|
+
"import": "./dist/index.js",
|
|
17
|
+
"default": "./dist/index.js"
|
|
18
|
+
}
|
|
19
|
+
},
|
|
20
|
+
"files": [
|
|
21
|
+
"dist",
|
|
22
|
+
"README.md"
|
|
23
|
+
],
|
|
24
|
+
"publishConfig": {
|
|
25
|
+
"access": "public"
|
|
26
|
+
},
|
|
27
|
+
"keywords": [
|
|
28
|
+
"korala",
|
|
29
|
+
"document-signing",
|
|
30
|
+
"e-signature",
|
|
31
|
+
"pdf-signing",
|
|
32
|
+
"api-client",
|
|
33
|
+
"typescript"
|
|
34
|
+
],
|
|
35
|
+
"dependencies": {
|
|
36
|
+
"@korala/auth": "^1.0.0",
|
|
37
|
+
"@korala/public-dtos": "^1.0.0"
|
|
38
|
+
},
|
|
39
|
+
"devDependencies": {
|
|
40
|
+
"typescript": "^5.9.3"
|
|
41
|
+
},
|
|
42
|
+
"engines": {
|
|
43
|
+
"node": ">=20.0"
|
|
44
|
+
},
|
|
45
|
+
"scripts": {
|
|
46
|
+
"build": "tsc",
|
|
47
|
+
"dev": "tsc --watch",
|
|
48
|
+
"typecheck": "tsc --noEmit",
|
|
49
|
+
"check": "biome check --write ."
|
|
50
|
+
}
|
|
51
|
+
}
|