@hauska-sdk/core 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/CHANGELOG.md +29 -0
- package/README.md +263 -0
- package/dist/CNSSDK.d.ts +115 -0
- package/dist/CNSSDK.d.ts.map +1 -0
- package/dist/CNSSDK.js +389 -0
- package/dist/CNSSDK.js.map +1 -0
- package/dist/EventAnchoringService.d.ts +58 -0
- package/dist/EventAnchoringService.d.ts.map +1 -0
- package/dist/EventAnchoringService.js +84 -0
- package/dist/EventAnchoringService.js.map +1 -0
- package/dist/errors.d.ts +160 -0
- package/dist/errors.d.ts.map +1 -0
- package/dist/errors.js +202 -0
- package/dist/errors.js.map +1 -0
- package/dist/index.d.ts +10 -0
- package/dist/index.d.ts.map +1 -0
- package/dist/index.js +10 -0
- package/dist/index.js.map +1 -0
- package/dist/types/index.d.ts +39 -0
- package/dist/types/index.d.ts.map +1 -0
- package/dist/types/index.js +5 -0
- package/dist/types/index.js.map +1 -0
- package/dist/types.d.ts +181 -0
- package/dist/types.d.ts.map +1 -0
- package/dist/types.js +6 -0
- package/dist/types.js.map +1 -0
- package/docs/api-reference.md +433 -0
- package/docs/examples.md +362 -0
- package/docs/getting-started.md +265 -0
- package/docs/troubleshooting.md +398 -0
- package/package.json +74 -0
package/dist/errors.d.ts
ADDED
|
@@ -0,0 +1,160 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hauska-sdk/core
|
|
3
|
+
* Custom Error Types for CNS Protocol SDK
|
|
4
|
+
*
|
|
5
|
+
* Provides structured error types with error codes, context, and actionable messages.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Base SDK Error class
|
|
9
|
+
*
|
|
10
|
+
* All SDK errors extend this class to provide consistent error handling.
|
|
11
|
+
*/
|
|
12
|
+
export declare class SDKError extends Error {
|
|
13
|
+
/**
|
|
14
|
+
* Error code for programmatic error handling
|
|
15
|
+
*/
|
|
16
|
+
readonly code: string;
|
|
17
|
+
/**
|
|
18
|
+
* Additional context about the error
|
|
19
|
+
*/
|
|
20
|
+
readonly context?: Record<string, any>;
|
|
21
|
+
/**
|
|
22
|
+
* HTTP status code (if applicable)
|
|
23
|
+
*/
|
|
24
|
+
readonly statusCode?: number;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the error is retryable
|
|
27
|
+
*/
|
|
28
|
+
readonly retryable: boolean;
|
|
29
|
+
constructor(message: string, code: string, options?: {
|
|
30
|
+
context?: Record<string, any>;
|
|
31
|
+
statusCode?: number;
|
|
32
|
+
retryable?: boolean;
|
|
33
|
+
cause?: Error;
|
|
34
|
+
});
|
|
35
|
+
/**
|
|
36
|
+
* Convert error to JSON for logging/monitoring
|
|
37
|
+
*/
|
|
38
|
+
toJSON(): Record<string, any>;
|
|
39
|
+
}
|
|
40
|
+
/**
|
|
41
|
+
* Payment-related errors
|
|
42
|
+
*/
|
|
43
|
+
export declare class PaymentError extends SDKError {
|
|
44
|
+
constructor(message: string, code: string, options?: {
|
|
45
|
+
context?: Record<string, any>;
|
|
46
|
+
statusCode?: number;
|
|
47
|
+
retryable?: boolean;
|
|
48
|
+
cause?: Error;
|
|
49
|
+
});
|
|
50
|
+
}
|
|
51
|
+
/**
|
|
52
|
+
* VDA-related errors
|
|
53
|
+
*/
|
|
54
|
+
export declare class VDAError extends SDKError {
|
|
55
|
+
constructor(message: string, code: string, options?: {
|
|
56
|
+
context?: Record<string, any>;
|
|
57
|
+
statusCode?: number;
|
|
58
|
+
retryable?: boolean;
|
|
59
|
+
cause?: Error;
|
|
60
|
+
});
|
|
61
|
+
}
|
|
62
|
+
/**
|
|
63
|
+
* Retrieval-related errors
|
|
64
|
+
*/
|
|
65
|
+
export declare class RetrievalError extends SDKError {
|
|
66
|
+
constructor(message: string, code: string, options?: {
|
|
67
|
+
context?: Record<string, any>;
|
|
68
|
+
statusCode?: number;
|
|
69
|
+
retryable?: boolean;
|
|
70
|
+
cause?: Error;
|
|
71
|
+
});
|
|
72
|
+
}
|
|
73
|
+
/**
|
|
74
|
+
* Wallet-related errors
|
|
75
|
+
*/
|
|
76
|
+
export declare class WalletError extends SDKError {
|
|
77
|
+
constructor(message: string, code: string, options?: {
|
|
78
|
+
context?: Record<string, any>;
|
|
79
|
+
statusCode?: number;
|
|
80
|
+
retryable?: boolean;
|
|
81
|
+
cause?: Error;
|
|
82
|
+
});
|
|
83
|
+
}
|
|
84
|
+
/**
|
|
85
|
+
* Configuration-related errors
|
|
86
|
+
*/
|
|
87
|
+
export declare class ConfigurationError extends SDKError {
|
|
88
|
+
constructor(message: string, code: string, options?: {
|
|
89
|
+
context?: Record<string, any>;
|
|
90
|
+
statusCode?: number;
|
|
91
|
+
retryable?: boolean;
|
|
92
|
+
cause?: Error;
|
|
93
|
+
});
|
|
94
|
+
}
|
|
95
|
+
/**
|
|
96
|
+
* Common error codes
|
|
97
|
+
*/
|
|
98
|
+
export declare const ErrorCodes: {
|
|
99
|
+
readonly PAYMENT_VERIFICATION_FAILED: "PAYMENT_VERIFICATION_FAILED";
|
|
100
|
+
readonly PAYMENT_NOT_FOUND: "PAYMENT_NOT_FOUND";
|
|
101
|
+
readonly PAYMENT_ALREADY_VERIFIED: "PAYMENT_ALREADY_VERIFIED";
|
|
102
|
+
readonly PAYMENT_INVALID_AMOUNT: "PAYMENT_INVALID_AMOUNT";
|
|
103
|
+
readonly PAYMENT_INVALID_CURRENCY: "PAYMENT_INVALID_CURRENCY";
|
|
104
|
+
readonly PAYMENT_STORAGE_ERROR: "PAYMENT_STORAGE_ERROR";
|
|
105
|
+
readonly VDA_NOT_FOUND: "VDA_NOT_FOUND";
|
|
106
|
+
readonly VDA_ALREADY_EXISTS: "VDA_ALREADY_EXISTS";
|
|
107
|
+
readonly VDA_INVALID_METADATA: "VDA_INVALID_METADATA";
|
|
108
|
+
readonly VDA_OWNERSHIP_DENIED: "VDA_OWNERSHIP_DENIED";
|
|
109
|
+
readonly VDA_ACCESS_DENIED: "VDA_ACCESS_DENIED";
|
|
110
|
+
readonly VDA_ACCESS_PASS_EXPIRED: "VDA_ACCESS_PASS_EXPIRED";
|
|
111
|
+
readonly VDA_ACCESS_PASS_REVOKED: "VDA_ACCESS_PASS_REVOKED";
|
|
112
|
+
readonly VDA_STORAGE_ERROR: "VDA_STORAGE_ERROR";
|
|
113
|
+
readonly VDA_TRANSFER_FAILED: "VDA_TRANSFER_FAILED";
|
|
114
|
+
readonly RETRIEVAL_DOCUMENT_NOT_FOUND: "RETRIEVAL_DOCUMENT_NOT_FOUND";
|
|
115
|
+
readonly RETRIEVAL_ACCESS_DENIED: "RETRIEVAL_ACCESS_DENIED";
|
|
116
|
+
readonly RETRIEVAL_DECRYPTION_FAILED: "RETRIEVAL_DECRYPTION_FAILED";
|
|
117
|
+
readonly RETRIEVAL_ENCRYPTION_KEY_MISSING: "RETRIEVAL_ENCRYPTION_KEY_MISSING";
|
|
118
|
+
readonly RETRIEVAL_NETWORK_ERROR: "RETRIEVAL_NETWORK_ERROR";
|
|
119
|
+
readonly RETRIEVAL_PINATA_ERROR: "RETRIEVAL_PINATA_ERROR";
|
|
120
|
+
readonly RETRIEVAL_INVALID_CID: "RETRIEVAL_INVALID_CID";
|
|
121
|
+
readonly WALLET_NOT_FOUND: "WALLET_NOT_FOUND";
|
|
122
|
+
readonly WALLET_CREATION_FAILED: "WALLET_CREATION_FAILED";
|
|
123
|
+
readonly WALLET_DECRYPTION_FAILED: "WALLET_DECRYPTION_FAILED";
|
|
124
|
+
readonly WALLET_INVALID_PASSWORD: "WALLET_INVALID_PASSWORD";
|
|
125
|
+
readonly WALLET_IMPORT_FAILED: "WALLET_IMPORT_FAILED";
|
|
126
|
+
readonly WALLET_EXPORT_FAILED: "WALLET_EXPORT_FAILED";
|
|
127
|
+
readonly CONFIG_MISSING_REQUIRED: "CONFIG_MISSING_REQUIRED";
|
|
128
|
+
readonly CONFIG_INVALID_VALUE: "CONFIG_INVALID_VALUE";
|
|
129
|
+
readonly CONFIG_STORAGE_NOT_CONFIGURED: "CONFIG_STORAGE_NOT_CONFIGURED";
|
|
130
|
+
readonly CONFIG_PINATA_NOT_CONFIGURED: "CONFIG_PINATA_NOT_CONFIGURED";
|
|
131
|
+
};
|
|
132
|
+
/**
|
|
133
|
+
* Helper function to create payment errors
|
|
134
|
+
*/
|
|
135
|
+
export declare function createPaymentError(code: keyof typeof ErrorCodes, message: string, context?: Record<string, any>): PaymentError;
|
|
136
|
+
/**
|
|
137
|
+
* Helper function to create VDA errors
|
|
138
|
+
*/
|
|
139
|
+
export declare function createVDAError(code: keyof typeof ErrorCodes, message: string, context?: Record<string, any>): VDAError;
|
|
140
|
+
/**
|
|
141
|
+
* Helper function to create retrieval errors
|
|
142
|
+
*/
|
|
143
|
+
export declare function createRetrievalError(code: keyof typeof ErrorCodes, message: string, context?: Record<string, any>): RetrievalError;
|
|
144
|
+
/**
|
|
145
|
+
* Helper function to create wallet errors
|
|
146
|
+
*/
|
|
147
|
+
export declare function createWalletError(code: keyof typeof ErrorCodes, message: string, context?: Record<string, any>): WalletError;
|
|
148
|
+
/**
|
|
149
|
+
* Helper function to create configuration errors
|
|
150
|
+
*/
|
|
151
|
+
export declare function createConfigurationError(code: keyof typeof ErrorCodes, message: string, context?: Record<string, any>): ConfigurationError;
|
|
152
|
+
/**
|
|
153
|
+
* Check if an error is an SDK error
|
|
154
|
+
*/
|
|
155
|
+
export declare function isSDKError(error: unknown): error is SDKError;
|
|
156
|
+
/**
|
|
157
|
+
* Check if an error is retryable
|
|
158
|
+
*/
|
|
159
|
+
export declare function isRetryableError(error: unknown): boolean;
|
|
160
|
+
//# sourceMappingURL=errors.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.d.ts","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;GAIG;AACH,qBAAa,QAAS,SAAQ,KAAK;IACjC;;OAEG;IACH,SAAgB,IAAI,EAAE,MAAM,CAAC;IAE7B;;OAEG;IACH,SA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EG;AACH,wBAAgB,oBAAoB,CAClC,IAAI,EAAE,MAAM,OAAO,UAAU,EAC7B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC5B,cAAc,CAEhB;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,IAAI,EAAE,MAAM,OAAO,UAAU,EAC7B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC5B,WAAW,CAEb;AAED;;GAEG;AACH,wBAAgB,wBAAwB,CACtC,IAAI,EAAE,MAAM,OAAO,UAAU,EAC7B,OAAO,EAAE,MAAM,EACf,OAAO,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GAC5B,kBAAkB,CAEpB;AAED;;GAEG;AACH,wBAAgB,UAAU,CAAC,KAAK,EAAE,OAAO,GAAG,KAAK,IAAI,QAAQ,CAE5D;AAED;;GAEG;AACH,wBAAgB,gBAAgB,CAAC,KAAK,EAAE,OAAO,GAAG,OAAO,CAKxD"}
|
package/dist/errors.js
ADDED
|
@@ -0,0 +1,202 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hauska-sdk/core
|
|
3
|
+
* Custom Error Types for CNS Protocol SDK
|
|
4
|
+
*
|
|
5
|
+
* Provides structured error types with error codes, context, and actionable messages.
|
|
6
|
+
*/
|
|
7
|
+
/**
|
|
8
|
+
* Base SDK Error class
|
|
9
|
+
*
|
|
10
|
+
* All SDK errors extend this class to provide consistent error handling.
|
|
11
|
+
*/
|
|
12
|
+
export class SDKError extends Error {
|
|
13
|
+
/**
|
|
14
|
+
* Error code for programmatic error handling
|
|
15
|
+
*/
|
|
16
|
+
code;
|
|
17
|
+
/**
|
|
18
|
+
* Additional context about the error
|
|
19
|
+
*/
|
|
20
|
+
context;
|
|
21
|
+
/**
|
|
22
|
+
* HTTP status code (if applicable)
|
|
23
|
+
*/
|
|
24
|
+
statusCode;
|
|
25
|
+
/**
|
|
26
|
+
* Whether the error is retryable
|
|
27
|
+
*/
|
|
28
|
+
retryable;
|
|
29
|
+
constructor(message, code, options) {
|
|
30
|
+
super(message);
|
|
31
|
+
this.name = this.constructor.name;
|
|
32
|
+
this.code = code;
|
|
33
|
+
this.context = options?.context;
|
|
34
|
+
this.statusCode = options?.statusCode;
|
|
35
|
+
this.retryable = options?.retryable ?? false;
|
|
36
|
+
// Maintain proper stack trace
|
|
37
|
+
if (Error.captureStackTrace) {
|
|
38
|
+
Error.captureStackTrace(this, this.constructor);
|
|
39
|
+
}
|
|
40
|
+
// Set cause if provided (for error chaining)
|
|
41
|
+
if (options?.cause) {
|
|
42
|
+
this.cause = options.cause;
|
|
43
|
+
}
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Convert error to JSON for logging/monitoring
|
|
47
|
+
*/
|
|
48
|
+
toJSON() {
|
|
49
|
+
return {
|
|
50
|
+
name: this.name,
|
|
51
|
+
message: this.message,
|
|
52
|
+
code: this.code,
|
|
53
|
+
context: this.context,
|
|
54
|
+
statusCode: this.statusCode,
|
|
55
|
+
retryable: this.retryable,
|
|
56
|
+
stack: this.stack,
|
|
57
|
+
};
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
/**
|
|
61
|
+
* Payment-related errors
|
|
62
|
+
*/
|
|
63
|
+
export class PaymentError extends SDKError {
|
|
64
|
+
constructor(message, code, options) {
|
|
65
|
+
super(message, `PAYMENT_${code}`, {
|
|
66
|
+
...options,
|
|
67
|
+
statusCode: options?.statusCode ?? 402, // HTTP 402 Payment Required
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
}
|
|
71
|
+
/**
|
|
72
|
+
* VDA-related errors
|
|
73
|
+
*/
|
|
74
|
+
export class VDAError extends SDKError {
|
|
75
|
+
constructor(message, code, options) {
|
|
76
|
+
super(message, `VDA_${code}`, {
|
|
77
|
+
...options,
|
|
78
|
+
statusCode: options?.statusCode ?? 400,
|
|
79
|
+
});
|
|
80
|
+
}
|
|
81
|
+
}
|
|
82
|
+
/**
|
|
83
|
+
* Retrieval-related errors
|
|
84
|
+
*/
|
|
85
|
+
export class RetrievalError extends SDKError {
|
|
86
|
+
constructor(message, code, options) {
|
|
87
|
+
super(message, `RETRIEVAL_${code}`, {
|
|
88
|
+
...options,
|
|
89
|
+
statusCode: options?.statusCode ?? 404, // HTTP 404 Not Found
|
|
90
|
+
});
|
|
91
|
+
}
|
|
92
|
+
}
|
|
93
|
+
/**
|
|
94
|
+
* Wallet-related errors
|
|
95
|
+
*/
|
|
96
|
+
export class WalletError extends SDKError {
|
|
97
|
+
constructor(message, code, options) {
|
|
98
|
+
super(message, `WALLET_${code}`, {
|
|
99
|
+
...options,
|
|
100
|
+
statusCode: options?.statusCode ?? 401, // HTTP 401 Unauthorized
|
|
101
|
+
});
|
|
102
|
+
}
|
|
103
|
+
}
|
|
104
|
+
/**
|
|
105
|
+
* Configuration-related errors
|
|
106
|
+
*/
|
|
107
|
+
export class ConfigurationError extends SDKError {
|
|
108
|
+
constructor(message, code, options) {
|
|
109
|
+
super(message, `CONFIG_${code}`, {
|
|
110
|
+
...options,
|
|
111
|
+
statusCode: options?.statusCode ?? 500,
|
|
112
|
+
});
|
|
113
|
+
}
|
|
114
|
+
}
|
|
115
|
+
/**
|
|
116
|
+
* Common error codes
|
|
117
|
+
*/
|
|
118
|
+
export const ErrorCodes = {
|
|
119
|
+
// Payment errors
|
|
120
|
+
PAYMENT_VERIFICATION_FAILED: "PAYMENT_VERIFICATION_FAILED",
|
|
121
|
+
PAYMENT_NOT_FOUND: "PAYMENT_NOT_FOUND",
|
|
122
|
+
PAYMENT_ALREADY_VERIFIED: "PAYMENT_ALREADY_VERIFIED",
|
|
123
|
+
PAYMENT_INVALID_AMOUNT: "PAYMENT_INVALID_AMOUNT",
|
|
124
|
+
PAYMENT_INVALID_CURRENCY: "PAYMENT_INVALID_CURRENCY",
|
|
125
|
+
PAYMENT_STORAGE_ERROR: "PAYMENT_STORAGE_ERROR",
|
|
126
|
+
// VDA errors
|
|
127
|
+
VDA_NOT_FOUND: "VDA_NOT_FOUND",
|
|
128
|
+
VDA_ALREADY_EXISTS: "VDA_ALREADY_EXISTS",
|
|
129
|
+
VDA_INVALID_METADATA: "VDA_INVALID_METADATA",
|
|
130
|
+
VDA_OWNERSHIP_DENIED: "VDA_OWNERSHIP_DENIED",
|
|
131
|
+
VDA_ACCESS_DENIED: "VDA_ACCESS_DENIED",
|
|
132
|
+
VDA_ACCESS_PASS_EXPIRED: "VDA_ACCESS_PASS_EXPIRED",
|
|
133
|
+
VDA_ACCESS_PASS_REVOKED: "VDA_ACCESS_PASS_REVOKED",
|
|
134
|
+
VDA_STORAGE_ERROR: "VDA_STORAGE_ERROR",
|
|
135
|
+
VDA_TRANSFER_FAILED: "VDA_TRANSFER_FAILED",
|
|
136
|
+
// Retrieval errors
|
|
137
|
+
RETRIEVAL_DOCUMENT_NOT_FOUND: "RETRIEVAL_DOCUMENT_NOT_FOUND",
|
|
138
|
+
RETRIEVAL_ACCESS_DENIED: "RETRIEVAL_ACCESS_DENIED",
|
|
139
|
+
RETRIEVAL_DECRYPTION_FAILED: "RETRIEVAL_DECRYPTION_FAILED",
|
|
140
|
+
RETRIEVAL_ENCRYPTION_KEY_MISSING: "RETRIEVAL_ENCRYPTION_KEY_MISSING",
|
|
141
|
+
RETRIEVAL_NETWORK_ERROR: "RETRIEVAL_NETWORK_ERROR",
|
|
142
|
+
RETRIEVAL_PINATA_ERROR: "RETRIEVAL_PINATA_ERROR",
|
|
143
|
+
RETRIEVAL_INVALID_CID: "RETRIEVAL_INVALID_CID",
|
|
144
|
+
// Wallet errors
|
|
145
|
+
WALLET_NOT_FOUND: "WALLET_NOT_FOUND",
|
|
146
|
+
WALLET_CREATION_FAILED: "WALLET_CREATION_FAILED",
|
|
147
|
+
WALLET_DECRYPTION_FAILED: "WALLET_DECRYPTION_FAILED",
|
|
148
|
+
WALLET_INVALID_PASSWORD: "WALLET_INVALID_PASSWORD",
|
|
149
|
+
WALLET_IMPORT_FAILED: "WALLET_IMPORT_FAILED",
|
|
150
|
+
WALLET_EXPORT_FAILED: "WALLET_EXPORT_FAILED",
|
|
151
|
+
// Configuration errors
|
|
152
|
+
CONFIG_MISSING_REQUIRED: "CONFIG_MISSING_REQUIRED",
|
|
153
|
+
CONFIG_INVALID_VALUE: "CONFIG_INVALID_VALUE",
|
|
154
|
+
CONFIG_STORAGE_NOT_CONFIGURED: "CONFIG_STORAGE_NOT_CONFIGURED",
|
|
155
|
+
CONFIG_PINATA_NOT_CONFIGURED: "CONFIG_PINATA_NOT_CONFIGURED",
|
|
156
|
+
};
|
|
157
|
+
/**
|
|
158
|
+
* Helper function to create payment errors
|
|
159
|
+
*/
|
|
160
|
+
export function createPaymentError(code, message, context) {
|
|
161
|
+
return new PaymentError(message, code, { context });
|
|
162
|
+
}
|
|
163
|
+
/**
|
|
164
|
+
* Helper function to create VDA errors
|
|
165
|
+
*/
|
|
166
|
+
export function createVDAError(code, message, context) {
|
|
167
|
+
return new VDAError(message, code, { context });
|
|
168
|
+
}
|
|
169
|
+
/**
|
|
170
|
+
* Helper function to create retrieval errors
|
|
171
|
+
*/
|
|
172
|
+
export function createRetrievalError(code, message, context) {
|
|
173
|
+
return new RetrievalError(message, code, { context });
|
|
174
|
+
}
|
|
175
|
+
/**
|
|
176
|
+
* Helper function to create wallet errors
|
|
177
|
+
*/
|
|
178
|
+
export function createWalletError(code, message, context) {
|
|
179
|
+
return new WalletError(message, code, { context });
|
|
180
|
+
}
|
|
181
|
+
/**
|
|
182
|
+
* Helper function to create configuration errors
|
|
183
|
+
*/
|
|
184
|
+
export function createConfigurationError(code, message, context) {
|
|
185
|
+
return new ConfigurationError(message, code, { context });
|
|
186
|
+
}
|
|
187
|
+
/**
|
|
188
|
+
* Check if an error is an SDK error
|
|
189
|
+
*/
|
|
190
|
+
export function isSDKError(error) {
|
|
191
|
+
return error instanceof SDKError;
|
|
192
|
+
}
|
|
193
|
+
/**
|
|
194
|
+
* Check if an error is retryable
|
|
195
|
+
*/
|
|
196
|
+
export function isRetryableError(error) {
|
|
197
|
+
if (isSDKError(error)) {
|
|
198
|
+
return error.retryable;
|
|
199
|
+
}
|
|
200
|
+
return false;
|
|
201
|
+
}
|
|
202
|
+
//# sourceMappingURL=errors.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"errors.js","sourceRoot":"","sources":["../src/errors.ts"],"names":[],"mappings":"AAAA;;;;;GAKG;AAEH;;;;GAIG;AACH,MAAM,OAAO,QAAS,SAAQ,KAAK;IACjC;;OAEG;IACa,IAAI,CAAS;IAE7B;;OAEG;IACa,OAAO,CAAuB;IAE9C;;OAEG;IACa,UAAU,CAAU;IAEpC;;OAEG;IACa,SAAS,CAAU;IAEnC,YACE,OAAe,EACf,IAAY,EACZ,OAKC;QAED,KAAK,CAAC,OAAO,CAAC,CAAC;QACf,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC,WAAW,CAAC,IAAI,CAAC;QAClC,IAAI,CAAC,IAAI,GAAG,IAAI,CAAC;QACjB,IAAI,CAAC,OAAO,GAAG,OAAO,EAAE,OAAO,CAAC;QAChC,IAAI,CAAC,UAAU,GAAG,OAAO,EAAE,UAAU,CAAC;QACtC,IAAI,CAAC,SAAS,GAAG,OAAO,EAAE,SAAS,IAAI,KAAK,CAAC;QAE7C,8BAA8B;QAC9B,IAAI,KAAK,CAAC,iBAAiB,EAAE,CAAC;YAC5B,KAAK,CAAC,iBAAiB,CAAC,IAAI,EAAE,IAAI,CAAC,WAAW,CAAC,CAAC;QAClD,CAAC;QAED,6CAA6C;QAC7C,IAAI,OAAO,EAAE,KAAK,EAAE,CAAC;YACnB,IAAI,CAAC,KAAK,GAAG,OAAO,CAAC,KAAK,CAAC;QAC7B,CAAC;IACH,CAAC;IAED;;OAEG;IACH,MAAM;QACJ,OAAO;YACL,IAAI,EAAE,IAAI,CAAC,IAAI;YACf,OAAO,EAAE,IAAI,CAAC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.d.ts
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hauska-sdk/core
|
|
3
|
+
* CNS Protocol Core SDK - Unified SDK for Payment, VDA, and Document Retrieval
|
|
4
|
+
*/
|
|
5
|
+
export { CNSSDK } from "./CNSSDK";
|
|
6
|
+
export type { CNSSDKConfig, WalletOptions, PurchaseAndMintVDAOptions, CreateDataRoomOptions, RetrieveDocumentOptions, LogHook, MetricsHook, } from "./types";
|
|
7
|
+
export { EventAnchoringService, computeEventHash } from "./EventAnchoringService";
|
|
8
|
+
export type { AuditEvent, AuditEventType, EventLogRow, EventLogStorage, } from "./EventAnchoringService";
|
|
9
|
+
export { SDKError, PaymentError, VDAError, RetrievalError, WalletError, ConfigurationError, ErrorCodes, createPaymentError, createVDAError, createRetrievalError, createWalletError, createConfigurationError, isSDKError, isRetryableError, } from "./errors";
|
|
10
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAClC,YAAY,EACV,YAAY,EACZ,aAAa,EACb,yBAAyB,EACzB,qBAAqB,EACrB,uBAAuB,EACvB,OAAO,EACP,WAAW,GACZ,MAAM,SAAS,CAAC;AAGjB,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAClF,YAAY,EACV,UAAU,EACV,cAAc,EACd,WAAW,EACX,eAAe,GAChB,MAAM,yBAAyB,CAAC;AAGjC,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,wBAAwB,EACxB,UAAU,EACV,gBAAgB,GACjB,MAAM,UAAU,CAAC"}
|
package/dist/index.js
ADDED
|
@@ -0,0 +1,10 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hauska-sdk/core
|
|
3
|
+
* CNS Protocol Core SDK - Unified SDK for Payment, VDA, and Document Retrieval
|
|
4
|
+
*/
|
|
5
|
+
export { CNSSDK } from "./CNSSDK";
|
|
6
|
+
// Export EventAnchoringService
|
|
7
|
+
export { EventAnchoringService, computeEventHash } from "./EventAnchoringService";
|
|
8
|
+
// Export error types
|
|
9
|
+
export { SDKError, PaymentError, VDAError, RetrievalError, WalletError, ConfigurationError, ErrorCodes, createPaymentError, createVDAError, createRetrievalError, createWalletError, createConfigurationError, isSDKError, isRetryableError, } from "./errors";
|
|
10
|
+
//# sourceMappingURL=index.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA;;;GAGG;AAEH,OAAO,EAAE,MAAM,EAAE,MAAM,UAAU,CAAC;AAWlC,+BAA+B;AAC/B,OAAO,EAAE,qBAAqB,EAAE,gBAAgB,EAAE,MAAM,yBAAyB,CAAC;AAQlF,qBAAqB;AACrB,OAAO,EACL,QAAQ,EACR,YAAY,EACZ,QAAQ,EACR,cAAc,EACd,WAAW,EACX,kBAAkB,EAClB,UAAU,EACV,kBAAkB,EAClB,cAAc,EACd,oBAAoB,EACpB,iBAAiB,EACjB,wBAAwB,EACxB,UAAU,EACV,gBAAgB,GACjB,MAAM,UAAU,CAAC"}
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Shared types for CNS Protocol SDK
|
|
3
|
+
*/
|
|
4
|
+
export interface VDA {
|
|
5
|
+
id: string;
|
|
6
|
+
metadata: VDAMetadata;
|
|
7
|
+
}
|
|
8
|
+
export interface VDAMetadata {
|
|
9
|
+
assetId: string;
|
|
10
|
+
assetType: string;
|
|
11
|
+
address?: string;
|
|
12
|
+
legalDesc?: string;
|
|
13
|
+
patientId?: string;
|
|
14
|
+
api14?: string;
|
|
15
|
+
ownerWallet: string;
|
|
16
|
+
grantorWallet?: string;
|
|
17
|
+
spoke: string;
|
|
18
|
+
ipfsCid?: string;
|
|
19
|
+
expiry?: number;
|
|
20
|
+
accessibleVDAs?: string[];
|
|
21
|
+
permissions?: string[];
|
|
22
|
+
metadata?: Record<string, any>;
|
|
23
|
+
createdAt: number;
|
|
24
|
+
updatedAt: number;
|
|
25
|
+
}
|
|
26
|
+
export interface PaymentRecord {
|
|
27
|
+
resourceId: string;
|
|
28
|
+
amount: string;
|
|
29
|
+
currency: string;
|
|
30
|
+
method: "crypto" | "fiat";
|
|
31
|
+
txHash?: string;
|
|
32
|
+
paymentIntentId?: string;
|
|
33
|
+
fromAddress?: string;
|
|
34
|
+
toAddress: string;
|
|
35
|
+
verified: boolean;
|
|
36
|
+
timestamp: number;
|
|
37
|
+
metadata?: Record<string, any>;
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=index.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG;AAEH,MAAM,WAAW,GAAG;IAClB,EAAE,EAAE,MAAM,CAAC;IACX,QAAQ,EAAE,WAAW,CAAC;CACvB;AAED,MAAM,WAAW,WAAW;IAC1B,OAAO,EAAE,MAAM,CAAC;IAChB,SAAS,EAAE,MAAM,CAAC;IAClB,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,WAAW,EAAE,MAAM,CAAC;IACpB,aAAa,CAAC,EAAE,MAAM,CAAC;IACvB,KAAK,EAAE,MAAM,CAAC;IACd,OAAO,CAAC,EAAE,MAAM,CAAC;IACjB,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,cAAc,CAAC,EAAE,MAAM,EAAE,CAAC;IAC1B,WAAW,CAAC,EAAE,MAAM,EAAE,CAAC;IACvB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;IAC/B,SAAS,EAAE,MAAM,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,aAAa;IAC5B,UAAU,EAAE,MAAM,CAAC;IACnB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,MAAM,EAAE,QAAQ,GAAG,MAAM,CAAC;IAC1B,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,eAAe,CAAC,EAAE,MAAM,CAAC;IACzB,WAAW,CAAC,EAAE,MAAM,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,EAAE,OAAO,CAAC;IAClB,SAAS,EAAE,MAAM,CAAC;IAClB,QAAQ,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,CAAC;CAChC"}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/types/index.ts"],"names":[],"mappings":"AAAA;;GAEG"}
|
package/dist/types.d.ts
ADDED
|
@@ -0,0 +1,181 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* @hauska-sdk/core
|
|
3
|
+
* Unified CNS SDK Type Definitions
|
|
4
|
+
*/
|
|
5
|
+
import type { WalletManager } from "@hauska-sdk/wallet";
|
|
6
|
+
import type { PaymentSDKConfig } from "@hauska-sdk/payment";
|
|
7
|
+
import type { VDASDKConfig } from "@hauska-sdk/vda";
|
|
8
|
+
import type { RetrievalSDKConfig } from "@hauska-sdk/retrieval";
|
|
9
|
+
import type { AssetType, SpokeType } from "@hauska-sdk/vda";
|
|
10
|
+
import type { EventAnchoringService } from "./EventAnchoringService";
|
|
11
|
+
/**
|
|
12
|
+
* Logging hook function type
|
|
13
|
+
*/
|
|
14
|
+
export type LogHook = (level: "info" | "warn" | "error", message: string, data?: any) => void;
|
|
15
|
+
/**
|
|
16
|
+
* Metrics hook function type
|
|
17
|
+
*
|
|
18
|
+
* Called for important events/operations for monitoring and analytics.
|
|
19
|
+
*/
|
|
20
|
+
export type MetricsHook = (event: string, data?: Record<string, any>) => void;
|
|
21
|
+
/**
|
|
22
|
+
* Unified CNS SDK Configuration
|
|
23
|
+
*
|
|
24
|
+
* Combines configuration for Payment, VDA, and Retrieval SDKs
|
|
25
|
+
*/
|
|
26
|
+
export interface CNSSDKConfig {
|
|
27
|
+
/**
|
|
28
|
+
* Wallet manager (optional, will be created if not provided)
|
|
29
|
+
* Shared across all modules
|
|
30
|
+
*/
|
|
31
|
+
walletManager?: WalletManager;
|
|
32
|
+
/**
|
|
33
|
+
* Payment SDK configuration
|
|
34
|
+
*/
|
|
35
|
+
payment?: Omit<PaymentSDKConfig, "walletManager">;
|
|
36
|
+
/**
|
|
37
|
+
* VDA SDK configuration
|
|
38
|
+
*/
|
|
39
|
+
vda: Omit<VDASDKConfig, "walletManager">;
|
|
40
|
+
/**
|
|
41
|
+
* Retrieval SDK configuration
|
|
42
|
+
* Note: vdaSdk will be automatically provided by CNSSDK
|
|
43
|
+
*/
|
|
44
|
+
retrieval: Omit<RetrievalSDKConfig, "vdaSdk">;
|
|
45
|
+
/**
|
|
46
|
+
* Optional logging hook for monitoring and debugging
|
|
47
|
+
*/
|
|
48
|
+
logHook?: LogHook;
|
|
49
|
+
/**
|
|
50
|
+
* Optional metrics hook for monitoring and analytics
|
|
51
|
+
*/
|
|
52
|
+
metricsHook?: MetricsHook;
|
|
53
|
+
/**
|
|
54
|
+
* Optional event anchoring service for immutable audit trail.
|
|
55
|
+
* When provided, all four top-level SDK operations auto-emit audit events.
|
|
56
|
+
*/
|
|
57
|
+
anchoring?: EventAnchoringService;
|
|
58
|
+
}
|
|
59
|
+
/**
|
|
60
|
+
* Options for wallet creation/retrieval
|
|
61
|
+
*/
|
|
62
|
+
export interface WalletOptions {
|
|
63
|
+
/**
|
|
64
|
+
* User ID (required for wallet lookup)
|
|
65
|
+
*/
|
|
66
|
+
userId: string;
|
|
67
|
+
/**
|
|
68
|
+
* User password for wallet encryption
|
|
69
|
+
*/
|
|
70
|
+
password: string;
|
|
71
|
+
/**
|
|
72
|
+
* Whether to create wallet if it doesn't exist
|
|
73
|
+
* @default true
|
|
74
|
+
*/
|
|
75
|
+
autoCreate?: boolean;
|
|
76
|
+
}
|
|
77
|
+
/**
|
|
78
|
+
* Options for purchasing and minting a VDA
|
|
79
|
+
*/
|
|
80
|
+
export interface PurchaseAndMintVDAOptions {
|
|
81
|
+
/**
|
|
82
|
+
* Wallet options (for auto-wallet creation)
|
|
83
|
+
*/
|
|
84
|
+
wallet: WalletOptions;
|
|
85
|
+
/**
|
|
86
|
+
* Payment amount
|
|
87
|
+
*/
|
|
88
|
+
amount: string;
|
|
89
|
+
/**
|
|
90
|
+
* Payment currency
|
|
91
|
+
*/
|
|
92
|
+
currency: string;
|
|
93
|
+
/**
|
|
94
|
+
* Payment method
|
|
95
|
+
*/
|
|
96
|
+
method: "crypto" | "fiat";
|
|
97
|
+
/**
|
|
98
|
+
* VDA minting parameters
|
|
99
|
+
*/
|
|
100
|
+
vdaParams: {
|
|
101
|
+
assetType: AssetType;
|
|
102
|
+
ownerWallet?: string;
|
|
103
|
+
spoke: SpokeType;
|
|
104
|
+
address?: string;
|
|
105
|
+
legalDesc?: string;
|
|
106
|
+
patientId?: string;
|
|
107
|
+
api14?: string;
|
|
108
|
+
[key: string]: any;
|
|
109
|
+
};
|
|
110
|
+
/**
|
|
111
|
+
* Optional payment metadata
|
|
112
|
+
*/
|
|
113
|
+
paymentMetadata?: Record<string, any>;
|
|
114
|
+
/**
|
|
115
|
+
* Optional VDA metadata
|
|
116
|
+
*/
|
|
117
|
+
vdaMetadata?: Record<string, any>;
|
|
118
|
+
}
|
|
119
|
+
/**
|
|
120
|
+
* Options for creating a data room
|
|
121
|
+
*/
|
|
122
|
+
export interface CreateDataRoomOptions {
|
|
123
|
+
/**
|
|
124
|
+
* Wallet options for the data room owner
|
|
125
|
+
*/
|
|
126
|
+
ownerWallet: WalletOptions;
|
|
127
|
+
/**
|
|
128
|
+
* VDA parameters for the data room
|
|
129
|
+
*/
|
|
130
|
+
vdaParams: {
|
|
131
|
+
assetType: AssetType;
|
|
132
|
+
spoke: SpokeType;
|
|
133
|
+
address?: string;
|
|
134
|
+
legalDesc?: string;
|
|
135
|
+
patientId?: string;
|
|
136
|
+
api14?: string;
|
|
137
|
+
[key: string]: any;
|
|
138
|
+
};
|
|
139
|
+
/**
|
|
140
|
+
* Optional document to upload
|
|
141
|
+
*/
|
|
142
|
+
document?: {
|
|
143
|
+
content: Buffer;
|
|
144
|
+
name?: string;
|
|
145
|
+
encrypt?: boolean;
|
|
146
|
+
};
|
|
147
|
+
/**
|
|
148
|
+
* Optional access pass configuration
|
|
149
|
+
*/
|
|
150
|
+
accessPass?: {
|
|
151
|
+
recipientWallet: WalletOptions;
|
|
152
|
+
permissions: string[];
|
|
153
|
+
expiry: number;
|
|
154
|
+
};
|
|
155
|
+
}
|
|
156
|
+
/**
|
|
157
|
+
* Options for retrieving a document
|
|
158
|
+
*/
|
|
159
|
+
export interface RetrieveDocumentOptions {
|
|
160
|
+
/**
|
|
161
|
+
* Wallet options for the requester
|
|
162
|
+
*/
|
|
163
|
+
wallet: WalletOptions;
|
|
164
|
+
/**
|
|
165
|
+
* IPFS Content Identifier
|
|
166
|
+
*/
|
|
167
|
+
cid: string;
|
|
168
|
+
/**
|
|
169
|
+
* Required permissions
|
|
170
|
+
*/
|
|
171
|
+
requiredPermissions?: string[];
|
|
172
|
+
/**
|
|
173
|
+
* Whether to decrypt the document
|
|
174
|
+
*/
|
|
175
|
+
decrypt?: boolean;
|
|
176
|
+
/**
|
|
177
|
+
* Whether to apply watermark (for access pass viewers)
|
|
178
|
+
*/
|
|
179
|
+
watermark?: boolean;
|
|
180
|
+
}
|
|
181
|
+
//# sourceMappingURL=types.d.ts.map
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