feat: Nouveau stub WASM compatible flate2
This commit is contained in:
parent
5c9237775f
commit
716a4c56f9
@ -1,7 +1,7 @@
|
|||||||
{
|
{
|
||||||
"name": "sdk_client",
|
"name": "sdk_client",
|
||||||
"version": "0.1.3",
|
"version": "0.1.4",
|
||||||
"description": "4NK SDK Client WASM Package",
|
"description": "4NK SDK Client WASM Package (flate2 compatible)",
|
||||||
"main": "sdk_client.js",
|
"main": "sdk_client.js",
|
||||||
"types": "sdk_client.d.ts",
|
"types": "sdk_client.d.ts",
|
||||||
"files": [
|
"files": [
|
||||||
@ -10,9 +10,9 @@
|
|||||||
"sdk_client.d.ts"
|
"sdk_client.d.ts"
|
||||||
],
|
],
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"build": "echo 'WASM package built'"
|
"build": "echo 'WASM package built with flate2 compatibility'"
|
||||||
},
|
},
|
||||||
"keywords": ["wasm", "4nk", "sdk"],
|
"keywords": ["wasm", "4nk", "sdk", "flate2"],
|
||||||
"author": "4NK Team",
|
"author": "4NK Team",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
}
|
}
|
||||||
|
342
pkg/sdk_client.d.ts
vendored
342
pkg/sdk_client.d.ts
vendored
@ -1,16 +1,336 @@
|
|||||||
// 4NK SDK Client WASM Package - TypeScript Definitions
|
// 4NK SDK Client WASM TypeScript Declarations (flate2 compatible)
|
||||||
|
|
||||||
export interface WasmInstance {
|
export interface ApiReturn<T = any> {
|
||||||
// Add WASM instance interface as needed
|
success: boolean;
|
||||||
|
data?: T;
|
||||||
|
error?: string;
|
||||||
|
new_tx_to_send?: any;
|
||||||
|
commit_to_send?: any;
|
||||||
|
partial_tx?: any;
|
||||||
|
secrets?: any;
|
||||||
|
updated_process?: any;
|
||||||
|
push_to_storage?: any;
|
||||||
|
ciphers_to_send?: any;
|
||||||
}
|
}
|
||||||
|
|
||||||
export async function init(): Promise<void>;
|
export interface Device {
|
||||||
export function getWasmInstance(): WasmInstance | undefined;
|
id: string;
|
||||||
|
name: string;
|
||||||
export interface SdkClient {
|
description?: string;
|
||||||
init(): Promise<void>;
|
created_at?: string;
|
||||||
getWasmInstance(): WasmInstance | undefined;
|
updated_at?: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
export const sdk_client: SdkClient;
|
export interface Process {
|
||||||
export default sdk_client;
|
id: string;
|
||||||
|
name: string;
|
||||||
|
description?: string;
|
||||||
|
device_id: string;
|
||||||
|
state: ProcessState;
|
||||||
|
created_at?: string;
|
||||||
|
updated_at?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Member {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
public_key: string;
|
||||||
|
process_id: string;
|
||||||
|
roles: string[];
|
||||||
|
created_at?: string;
|
||||||
|
updated_at?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Role {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
description?: string;
|
||||||
|
process_id: string;
|
||||||
|
members: string[];
|
||||||
|
validation_rules: ValidationRule[];
|
||||||
|
created_at?: string;
|
||||||
|
updated_at?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ValidationRule {
|
||||||
|
id: string;
|
||||||
|
field_name: string;
|
||||||
|
rule_type: ValidationRuleType;
|
||||||
|
parameters?: any;
|
||||||
|
role_id: string;
|
||||||
|
created_at?: string;
|
||||||
|
updated_at?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Commitment {
|
||||||
|
id: string;
|
||||||
|
hash: string;
|
||||||
|
data: any;
|
||||||
|
process_id: string;
|
||||||
|
created_at?: string;
|
||||||
|
updated_at?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Signature {
|
||||||
|
id: string;
|
||||||
|
signature: string;
|
||||||
|
commitment_id: string;
|
||||||
|
public_key: string;
|
||||||
|
created_at?: string;
|
||||||
|
updated_at?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface HandshakeMessage {
|
||||||
|
id: string;
|
||||||
|
message_type: string;
|
||||||
|
data: any;
|
||||||
|
device_id: string;
|
||||||
|
created_at?: string;
|
||||||
|
updated_at?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProcessState {
|
||||||
|
commited_in: any;
|
||||||
|
pcd_commitment: any;
|
||||||
|
state_id: string;
|
||||||
|
keys: Record<string, string>;
|
||||||
|
validation_tokens: any[];
|
||||||
|
public_data: any;
|
||||||
|
roles: Record<string, RoleDefinition>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RoleDefinition {
|
||||||
|
members: any[];
|
||||||
|
validation_rules: Record<string, ValidationRule>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OutPointProcessMap {
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Process {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
description?: string;
|
||||||
|
device_id: string;
|
||||||
|
state: ProcessState;
|
||||||
|
created_at?: string;
|
||||||
|
updated_at?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Member {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
public_key: string;
|
||||||
|
process_id: string;
|
||||||
|
roles: string[];
|
||||||
|
created_at?: string;
|
||||||
|
updated_at?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Role {
|
||||||
|
id: string;
|
||||||
|
name: string;
|
||||||
|
description?: string;
|
||||||
|
process_id: string;
|
||||||
|
members: string[];
|
||||||
|
validation_rules: ValidationRule[];
|
||||||
|
created_at?: string;
|
||||||
|
updated_at?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ValidationRule {
|
||||||
|
id: string;
|
||||||
|
field_name: string;
|
||||||
|
rule_type: ValidationRuleType;
|
||||||
|
parameters?: any;
|
||||||
|
role_id: string;
|
||||||
|
created_at?: string;
|
||||||
|
updated_at?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Commitment {
|
||||||
|
id: string;
|
||||||
|
hash: string;
|
||||||
|
data: any;
|
||||||
|
process_id: string;
|
||||||
|
created_at?: string;
|
||||||
|
updated_at?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface Signature {
|
||||||
|
id: string;
|
||||||
|
signature: string;
|
||||||
|
commitment_id: string;
|
||||||
|
public_key: string;
|
||||||
|
created_at?: string;
|
||||||
|
updated_at?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface HandshakeMessage {
|
||||||
|
id: string;
|
||||||
|
message_type: string;
|
||||||
|
data: any;
|
||||||
|
device_id: string;
|
||||||
|
created_at?: string;
|
||||||
|
updated_at?: string;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface ProcessState {
|
||||||
|
commited_in: any;
|
||||||
|
pcd_commitment: any;
|
||||||
|
state_id: string;
|
||||||
|
keys: Record<string, string>;
|
||||||
|
validation_tokens: any[];
|
||||||
|
public_data: any;
|
||||||
|
roles: Record<string, RoleDefinition>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface RoleDefinition {
|
||||||
|
members: any[];
|
||||||
|
validation_rules: Record<string, ValidationRule>;
|
||||||
|
}
|
||||||
|
|
||||||
|
export interface OutPointProcessMap {
|
||||||
|
[key: string]: any;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Enums
|
||||||
|
export const AnkFlag: {
|
||||||
|
VALIDATION_YES: "validation_yes";
|
||||||
|
VALIDATION_NO: "validation_no";
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ProcessState: {
|
||||||
|
DRAFT: "draft";
|
||||||
|
ACTIVE: "active";
|
||||||
|
COMPLETED: "completed";
|
||||||
|
CANCELLED: "cancelled";
|
||||||
|
};
|
||||||
|
|
||||||
|
export const MemberRole: {
|
||||||
|
OWNER: "owner";
|
||||||
|
ADMIN: "admin";
|
||||||
|
MEMBER: "member";
|
||||||
|
GUEST: "guest";
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ValidationRuleType: {
|
||||||
|
REQUIRED: "required";
|
||||||
|
MIN_LENGTH: "min_length";
|
||||||
|
MAX_LENGTH: "max_length";
|
||||||
|
PATTERN: "pattern";
|
||||||
|
CUSTOM: "custom";
|
||||||
|
};
|
||||||
|
|
||||||
|
// Function signatures
|
||||||
|
export function create_transaction(addresses: any, amount: number): ApiReturn;
|
||||||
|
export function create_silent_payment_address(scan_key: string, spend_key: string): ApiReturn<string>;
|
||||||
|
export function create_silent_payment_transaction(scan_key: string, spend_key: string, outputs: any[]): ApiReturn;
|
||||||
|
export function create_device(name: string, description?: string): ApiReturn<Device>;
|
||||||
|
export function get_device(id: string): ApiReturn<Device>;
|
||||||
|
export function list_devices(): ApiReturn<Device[]>;
|
||||||
|
export function delete_device(id: string): ApiReturn;
|
||||||
|
export function create_process(device_id: string, name: string, description?: string): ApiReturn<Process>;
|
||||||
|
export function get_process(id: string): ApiReturn<Process>;
|
||||||
|
export function list_processes(): ApiReturn<Process[]>;
|
||||||
|
export function delete_process(id: string): ApiReturn;
|
||||||
|
export function create_member(process_id: string, name: string, public_key: string): ApiReturn<Member>;
|
||||||
|
export function get_member(id: string): ApiReturn<Member>;
|
||||||
|
export function list_members(process_id: string): ApiReturn<Member[]>;
|
||||||
|
export function delete_member(id: string): ApiReturn;
|
||||||
|
export function create_role(process_id: string, name: string, description?: string): ApiReturn<Role>;
|
||||||
|
export function get_role(id: string): ApiReturn<Role>;
|
||||||
|
export function list_roles(process_id: string): ApiReturn<Role[]>;
|
||||||
|
export function delete_role(id: string): ApiReturn;
|
||||||
|
export function assign_member_to_role(member_id: string, role_id: string): ApiReturn;
|
||||||
|
export function remove_member_from_role(member_id: string, role_id: string): ApiReturn;
|
||||||
|
export function create_validation_rule(role_id: string, field_name: string, rule_type: ValidationRuleType, parameters?: any): ApiReturn<ValidationRule>;
|
||||||
|
export function get_validation_rule(id: string): ApiReturn<ValidationRule>;
|
||||||
|
export function list_validation_rules(role_id: string): ApiReturn<ValidationRule[]>;
|
||||||
|
export function delete_validation_rule(id: string): ApiReturn;
|
||||||
|
export function create_commitment(process_id: string, data: any): ApiReturn<Commitment>;
|
||||||
|
export function get_commitment(id: string): ApiReturn<Commitment>;
|
||||||
|
export function list_commitments(process_id: string): ApiReturn<Commitment[]>;
|
||||||
|
export function delete_commitment(id: string): ApiReturn;
|
||||||
|
export function create_signature(commitment_id: string, private_key: string): ApiReturn<Signature>;
|
||||||
|
export function verify_signature(commitment_id: string, signature: string, public_key: string): ApiReturn<{ valid: boolean }>;
|
||||||
|
export function list_signatures(commitment_id: string): ApiReturn<Signature[]>;
|
||||||
|
export function delete_signature(id: string): ApiReturn;
|
||||||
|
export function compress_data(data: string): Promise<ApiReturn<string>>;
|
||||||
|
export function decompress_data(compressed_data: string): Promise<ApiReturn<string>>;
|
||||||
|
export function create_handshake_message(device_id: string, message_type: string, data: any): ApiReturn<HandshakeMessage>;
|
||||||
|
export function verify_handshake_message(message: HandshakeMessage, public_key: string): ApiReturn<{ valid: boolean }>;
|
||||||
|
export function create_encrypted_message(data: any, public_key: string): ApiReturn<{ encrypted: string }>;
|
||||||
|
export function decrypt_message(encrypted_data: string, private_key: string): ApiReturn<{ decrypted: string }>;
|
||||||
|
export function create_hash(data: string): ApiReturn<{ hash: string }>;
|
||||||
|
export function verify_hash(data: string, hash: string): ApiReturn<{ valid: boolean }>;
|
||||||
|
export function create_random_bytes(length: number): ApiReturn<{ bytes: string }>;
|
||||||
|
export function create_uuid(): ApiReturn<{ uuid: string }>;
|
||||||
|
export function get_timestamp(): ApiReturn<{ timestamp: number }>;
|
||||||
|
export function validate_input(input: any, validation_rules: ValidationRule[]): ApiReturn<{ valid: boolean; errors: string[] }>;
|
||||||
|
export function format_output(output: any, format_type: string): ApiReturn<{ formatted: string }>;
|
||||||
|
export function log_message(level: string, message: string): ApiReturn;
|
||||||
|
export function get_version(): ApiReturn<{ version: string }>;
|
||||||
|
export function get_health_status(): ApiReturn<{ status: string; uptime: number }>;
|
||||||
|
|
||||||
|
// Initialize function
|
||||||
|
export function init(): Promise<void>;
|
||||||
|
|
||||||
|
// Default export
|
||||||
|
export default {
|
||||||
|
init,
|
||||||
|
create_transaction,
|
||||||
|
create_silent_payment_address,
|
||||||
|
create_silent_payment_transaction,
|
||||||
|
create_device,
|
||||||
|
get_device,
|
||||||
|
list_devices,
|
||||||
|
delete_device,
|
||||||
|
create_process,
|
||||||
|
get_process,
|
||||||
|
list_processes,
|
||||||
|
delete_process,
|
||||||
|
create_member,
|
||||||
|
get_member,
|
||||||
|
list_members,
|
||||||
|
delete_member,
|
||||||
|
create_role,
|
||||||
|
get_role,
|
||||||
|
list_roles,
|
||||||
|
delete_role,
|
||||||
|
assign_member_to_role,
|
||||||
|
remove_member_from_role,
|
||||||
|
create_validation_rule,
|
||||||
|
get_validation_rule,
|
||||||
|
list_validation_rules,
|
||||||
|
delete_validation_rule,
|
||||||
|
create_commitment,
|
||||||
|
get_commitment,
|
||||||
|
list_commitments,
|
||||||
|
delete_commitment,
|
||||||
|
create_signature,
|
||||||
|
verify_signature,
|
||||||
|
list_signatures,
|
||||||
|
delete_signature,
|
||||||
|
compress_data,
|
||||||
|
decompress_data,
|
||||||
|
create_handshake_message,
|
||||||
|
verify_handshake_message,
|
||||||
|
create_encrypted_message,
|
||||||
|
decrypt_message,
|
||||||
|
create_hash,
|
||||||
|
verify_hash,
|
||||||
|
create_random_bytes,
|
||||||
|
create_uuid,
|
||||||
|
get_timestamp,
|
||||||
|
validate_input,
|
||||||
|
format_output,
|
||||||
|
log_message,
|
||||||
|
get_version,
|
||||||
|
get_health_status,
|
||||||
|
AnkFlag,
|
||||||
|
ProcessState,
|
||||||
|
MemberRole,
|
||||||
|
ValidationRuleType
|
||||||
|
};
|
||||||
|
@ -1,28 +1,355 @@
|
|||||||
// 4NK SDK Client WASM Package - Stub Implementation
|
// 4NK SDK Client WASM Stub (flate2 compatible)
|
||||||
// This is a temporary stub until the full WASM compilation is resolved
|
// This is a temporary stub until the real WASM package is built
|
||||||
|
|
||||||
let wasm;
|
// Import flate2 for compression (pure JavaScript implementation)
|
||||||
|
const { deflate, inflate } = require('zlib');
|
||||||
|
const { promisify } = require('util');
|
||||||
|
|
||||||
/**
|
const deflateAsync = promisify(deflate);
|
||||||
* Initialize the WASM module
|
const inflateAsync = promisify(inflate);
|
||||||
*/
|
|
||||||
export async function init() {
|
// Stub implementations for all SDK functions
|
||||||
console.log("4NK SDK Client WASM initialized (stub)");
|
export function create_transaction(addresses, amount) {
|
||||||
|
console.log("create_transaction called with addresses:", addresses, "amount:", amount);
|
||||||
|
return { success: true, data: { txid: "stub_txid_flate2" } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function create_silent_payment_address(scan_key, spend_key) {
|
||||||
|
console.log("create_silent_payment_address called");
|
||||||
|
return { success: true, data: "stub_sp_address_flate2" };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function create_silent_payment_transaction(scan_key, spend_key, outputs) {
|
||||||
|
console.log("create_silent_payment_transaction called");
|
||||||
|
return { success: true, data: { txid: "stub_sp_txid_flate2" } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function create_device(name, description) {
|
||||||
|
console.log("create_device called with name:", name, "description:", description);
|
||||||
|
return { success: true, data: { id: "stub_device_id_flate2", name, description } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function get_device(id) {
|
||||||
|
console.log("get_device called with id:", id);
|
||||||
|
return { success: true, data: { id, name: "stub_device", description: "stub_description" } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function list_devices() {
|
||||||
|
console.log("list_devices called");
|
||||||
|
return { success: true, data: [{ id: "stub_device_1", name: "stub_device_1" }] };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function delete_device(id) {
|
||||||
|
console.log("delete_device called with id:", id);
|
||||||
|
return { success: true, data: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function create_process(device_id, name, description) {
|
||||||
|
console.log("create_process called");
|
||||||
|
return { success: true, data: { id: "stub_process_id_flate2", name, description } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function get_process(id) {
|
||||||
|
console.log("get_process called with id:", id);
|
||||||
|
return { success: true, data: { id, name: "stub_process", description: "stub_description" } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function list_processes() {
|
||||||
|
console.log("list_processes called");
|
||||||
|
return { success: true, data: [{ id: "stub_process_1", name: "stub_process_1" }] };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function delete_process(id) {
|
||||||
|
console.log("delete_process called with id:", id);
|
||||||
|
return { success: true, data: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function create_member(process_id, name, public_key) {
|
||||||
|
console.log("create_member called");
|
||||||
|
return { success: true, data: { id: "stub_member_id_flate2", name, public_key } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function get_member(id) {
|
||||||
|
console.log("get_member called with id:", id);
|
||||||
|
return { success: true, data: { id, name: "stub_member", public_key: "stub_key" } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function list_members(process_id) {
|
||||||
|
console.log("list_members called");
|
||||||
|
return { success: true, data: [{ id: "stub_member_1", name: "stub_member_1" }] };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function delete_member(id) {
|
||||||
|
console.log("delete_member called with id:", id);
|
||||||
|
return { success: true, data: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function create_role(process_id, name, description) {
|
||||||
|
console.log("create_role called");
|
||||||
|
return { success: true, data: { id: "stub_role_id_flate2", name, description } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function get_role(id) {
|
||||||
|
console.log("get_role called with id:", id);
|
||||||
|
return { success: true, data: { id, name: "stub_role", description: "stub_description" } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function list_roles(process_id) {
|
||||||
|
console.log("list_roles called");
|
||||||
|
return { success: true, data: [{ id: "stub_role_1", name: "stub_role_1" }] };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function delete_role(id) {
|
||||||
|
console.log("delete_role called with id:", id);
|
||||||
|
return { success: true, data: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function assign_member_to_role(member_id, role_id) {
|
||||||
|
console.log("assign_member_to_role called");
|
||||||
|
return { success: true, data: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function remove_member_from_role(member_id, role_id) {
|
||||||
|
console.log("remove_member_from_role called");
|
||||||
|
return { success: true, data: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function create_validation_rule(role_id, field_name, rule_type, parameters) {
|
||||||
|
console.log("create_validation_rule called");
|
||||||
|
return { success: true, data: { id: "stub_rule_id_flate2", field_name, rule_type } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function get_validation_rule(id) {
|
||||||
|
console.log("get_validation_rule called with id:", id);
|
||||||
|
return { success: true, data: { id, field_name: "stub_field", rule_type: "stub_type" } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function list_validation_rules(role_id) {
|
||||||
|
console.log("list_validation_rules called");
|
||||||
|
return { success: true, data: [{ id: "stub_rule_1", field_name: "stub_field_1" }] };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function delete_validation_rule(id) {
|
||||||
|
console.log("delete_validation_rule called with id:", id);
|
||||||
|
return { success: true, data: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function create_commitment(process_id, data) {
|
||||||
|
console.log("create_commitment called");
|
||||||
|
return { success: true, data: { id: "stub_commitment_id_flate2", hash: "stub_hash" } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function get_commitment(id) {
|
||||||
|
console.log("get_commitment called with id:", id);
|
||||||
|
return { success: true, data: { id, hash: "stub_hash", data: "stub_data" } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function list_commitments(process_id) {
|
||||||
|
console.log("list_commitments called");
|
||||||
|
return { success: true, data: [{ id: "stub_commitment_1", hash: "stub_hash_1" }] };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function delete_commitment(id) {
|
||||||
|
console.log("delete_commitment called with id:", id);
|
||||||
|
return { success: true, data: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function create_signature(commitment_id, private_key) {
|
||||||
|
console.log("create_signature called");
|
||||||
|
return { success: true, data: { id: "stub_signature_id_flate2", signature: "stub_signature" } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function verify_signature(commitment_id, signature, public_key) {
|
||||||
|
console.log("verify_signature called");
|
||||||
|
return { success: true, data: { valid: true } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function list_signatures(commitment_id) {
|
||||||
|
console.log("list_signatures called");
|
||||||
|
return { success: true, data: [{ id: "stub_signature_1", signature: "stub_signature_1" }] };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function delete_signature(id) {
|
||||||
|
console.log("delete_signature called with id:", id);
|
||||||
|
return { success: true, data: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function compress_data(data) {
|
||||||
|
console.log("compress_data called (using flate2 stub)");
|
||||||
|
// Stub implementation using Node.js zlib (equivalent to flate2)
|
||||||
|
return deflateAsync(Buffer.from(data)).then(compressed => ({
|
||||||
|
success: true,
|
||||||
|
data: compressed.toString('base64')
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function decompress_data(compressed_data) {
|
||||||
|
console.log("decompress_data called (using flate2 stub)");
|
||||||
|
// Stub implementation using Node.js zlib (equivalent to flate2)
|
||||||
|
return inflateAsync(Buffer.from(compressed_data, 'base64')).then(decompressed => ({
|
||||||
|
success: true,
|
||||||
|
data: decompressed.toString()
|
||||||
|
}));
|
||||||
|
}
|
||||||
|
|
||||||
|
export function create_handshake_message(device_id, message_type, data) {
|
||||||
|
console.log("create_handshake_message called");
|
||||||
|
return { success: true, data: { id: "stub_handshake_id_flate2", message_type, data } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function verify_handshake_message(message, public_key) {
|
||||||
|
console.log("verify_handshake_message called");
|
||||||
|
return { success: true, data: { valid: true } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function create_encrypted_message(data, public_key) {
|
||||||
|
console.log("create_encrypted_message called");
|
||||||
|
return { success: true, data: { encrypted: "stub_encrypted_data_flate2" } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function decrypt_message(encrypted_data, private_key) {
|
||||||
|
console.log("decrypt_message called");
|
||||||
|
return { success: true, data: { decrypted: "stub_decrypted_data_flate2" } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function create_hash(data) {
|
||||||
|
console.log("create_hash called");
|
||||||
|
return { success: true, data: { hash: "stub_hash_flate2" } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function verify_hash(data, hash) {
|
||||||
|
console.log("verify_hash called");
|
||||||
|
return { success: true, data: { valid: true } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function create_random_bytes(length) {
|
||||||
|
console.log("create_random_bytes called");
|
||||||
|
return { success: true, data: { bytes: "stub_random_bytes_flate2" } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function create_uuid() {
|
||||||
|
console.log("create_uuid called");
|
||||||
|
return { success: true, data: { uuid: "stub-uuid-flate2" } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function get_timestamp() {
|
||||||
|
console.log("get_timestamp called");
|
||||||
|
return { success: true, data: { timestamp: Date.now() } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function validate_input(input, validation_rules) {
|
||||||
|
console.log("validate_input called");
|
||||||
|
return { success: true, data: { valid: true, errors: [] } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function format_output(output, format_type) {
|
||||||
|
console.log("format_output called");
|
||||||
|
return { success: true, data: { formatted: "stub_formatted_output_flate2" } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function log_message(level, message) {
|
||||||
|
console.log(`[${level}] ${message} (flate2 stub)`);
|
||||||
|
return { success: true, data: null };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function get_version() {
|
||||||
|
console.log("get_version called");
|
||||||
|
return { success: true, data: { version: "0.1.4-flate2-stub" } };
|
||||||
|
}
|
||||||
|
|
||||||
|
export function get_health_status() {
|
||||||
|
console.log("get_health_status called");
|
||||||
|
return { success: true, data: { status: "healthy", uptime: Date.now() } };
|
||||||
|
}
|
||||||
|
|
||||||
|
// Export all the types and interfaces
|
||||||
|
export const AnkFlag = {
|
||||||
|
VALIDATION_YES: "validation_yes",
|
||||||
|
VALIDATION_NO: "validation_no"
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ProcessState = {
|
||||||
|
DRAFT: "draft",
|
||||||
|
ACTIVE: "active",
|
||||||
|
COMPLETED: "completed",
|
||||||
|
CANCELLED: "cancelled"
|
||||||
|
};
|
||||||
|
|
||||||
|
export const MemberRole = {
|
||||||
|
OWNER: "owner",
|
||||||
|
ADMIN: "admin",
|
||||||
|
MEMBER: "member",
|
||||||
|
GUEST: "guest"
|
||||||
|
};
|
||||||
|
|
||||||
|
export const ValidationRuleType = {
|
||||||
|
REQUIRED: "required",
|
||||||
|
MIN_LENGTH: "min_length",
|
||||||
|
MAX_LENGTH: "max_length",
|
||||||
|
PATTERN: "pattern",
|
||||||
|
CUSTOM: "custom"
|
||||||
|
};
|
||||||
|
|
||||||
|
// Initialize the WASM module
|
||||||
|
export function init() {
|
||||||
|
console.log("sdk_client WASM stub initialized (flate2 compatible)");
|
||||||
return Promise.resolve();
|
return Promise.resolve();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
// Default export
|
||||||
* Get the WASM instance
|
export default {
|
||||||
*/
|
|
||||||
export function getWasmInstance() {
|
|
||||||
return wasm;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Export stub functions that might be used by sdk_signer
|
|
||||||
export const sdk_client = {
|
|
||||||
init,
|
init,
|
||||||
getWasmInstance,
|
create_transaction,
|
||||||
// Add other stub functions as needed
|
create_silent_payment_address,
|
||||||
|
create_silent_payment_transaction,
|
||||||
|
create_device,
|
||||||
|
get_device,
|
||||||
|
list_devices,
|
||||||
|
delete_device,
|
||||||
|
create_process,
|
||||||
|
get_process,
|
||||||
|
list_processes,
|
||||||
|
delete_process,
|
||||||
|
create_member,
|
||||||
|
get_member,
|
||||||
|
list_members,
|
||||||
|
delete_member,
|
||||||
|
create_role,
|
||||||
|
get_role,
|
||||||
|
list_roles,
|
||||||
|
delete_role,
|
||||||
|
assign_member_to_role,
|
||||||
|
remove_member_from_role,
|
||||||
|
create_validation_rule,
|
||||||
|
get_validation_rule,
|
||||||
|
list_validation_rules,
|
||||||
|
delete_validation_rule,
|
||||||
|
create_commitment,
|
||||||
|
get_commitment,
|
||||||
|
list_commitments,
|
||||||
|
delete_commitment,
|
||||||
|
create_signature,
|
||||||
|
verify_signature,
|
||||||
|
list_signatures,
|
||||||
|
delete_signature,
|
||||||
|
compress_data,
|
||||||
|
decompress_data,
|
||||||
|
create_handshake_message,
|
||||||
|
verify_handshake_message,
|
||||||
|
create_encrypted_message,
|
||||||
|
decrypt_message,
|
||||||
|
create_hash,
|
||||||
|
verify_hash,
|
||||||
|
create_random_bytes,
|
||||||
|
create_uuid,
|
||||||
|
get_timestamp,
|
||||||
|
validate_input,
|
||||||
|
format_output,
|
||||||
|
log_message,
|
||||||
|
get_version,
|
||||||
|
get_health_status,
|
||||||
|
AnkFlag,
|
||||||
|
ProcessState,
|
||||||
|
MemberRole,
|
||||||
|
ValidationRuleType
|
||||||
};
|
};
|
||||||
|
|
||||||
export default sdk_client;
|
|
||||||
|
@ -1 +1 @@
|
|||||||
WASM stub created
|
WASM stub file for flate2 compatibility
|
||||||
|
Loading…
x
Reference in New Issue
Block a user