ci: docker_tag=ext - utiliser pkg WASM fourni (ESM) et supprimer build wasm
All checks were successful
Build and Push Docker image (ext) / docker (push) Successful in 50s
All checks were successful
Build and Push Docker image (ext) / docker (push) Successful in 50s
This commit is contained in:
parent
0cf587fa6e
commit
e76f2e1db9
36
Dockerfile
36
Dockerfile
@ -1,35 +1,5 @@
|
|||||||
# syntax=docker/dockerfile:1.4
|
# syntax=docker/dockerfile:1.4
|
||||||
|
|
||||||
# Stage 1: Build WASM for web target
|
|
||||||
FROM rust:1.82-alpine AS wasm-builder
|
|
||||||
WORKDIR /build
|
|
||||||
|
|
||||||
# Install dependencies for WASM compilation
|
|
||||||
RUN apk update && apk add --no-cache git openssh-client curl nodejs npm build-base pkgconfig clang llvm musl-dev
|
|
||||||
|
|
||||||
# Install wasm-bindgen-cli
|
|
||||||
RUN cargo install wasm-bindgen-cli --version 0.2.103 --locked && rustup target add wasm32-unknown-unknown
|
|
||||||
|
|
||||||
# Setup SSH for git clone
|
|
||||||
RUN mkdir -p /root/.ssh && ssh-keyscan git.4nkweb.com >> /root/.ssh/known_hosts
|
|
||||||
|
|
||||||
# Copy project files
|
|
||||||
COPY . ihm_client/
|
|
||||||
|
|
||||||
# Clone and build sdk_client for web target
|
|
||||||
RUN --mount=type=ssh git clone -b dev ssh://git@git.4nkweb.com/4nk/sdk_client.git
|
|
||||||
WORKDIR /build/sdk_client
|
|
||||||
|
|
||||||
# Build WASM for web target (ES modules)
|
|
||||||
RUN cargo build --target wasm32-unknown-unknown --profile dev && \
|
|
||||||
wasm-bindgen target/wasm32-unknown-unknown/debug/sdk_client.wasm \
|
|
||||||
--out-dir /build/ihm_client/pkg \
|
|
||||||
--typescript \
|
|
||||||
--target web \
|
|
||||||
--no-reference-types \
|
|
||||||
--debug
|
|
||||||
|
|
||||||
# Stage 2: Final application
|
|
||||||
FROM node:20-alpine
|
FROM node:20-alpine
|
||||||
WORKDIR /app
|
WORKDIR /app
|
||||||
|
|
||||||
@ -39,8 +9,10 @@ RUN apk update && apk add --no-cache git nginx
|
|||||||
# Copy project files
|
# Copy project files
|
||||||
COPY . .
|
COPY . .
|
||||||
|
|
||||||
# Copy the web-compiled WASM package
|
# Copy the provided prebuilt WASM package (ESM)
|
||||||
COPY --from=wasm-builder /build/ihm_client/pkg ./pkg
|
# The directory pkg is provided in the build context
|
||||||
|
# and already contains sdk_client.js (ES module) and wasm
|
||||||
|
# so no compilation is required here.
|
||||||
|
|
||||||
# Installation des dépendances Node.js
|
# Installation des dépendances Node.js
|
||||||
RUN npm install
|
RUN npm install
|
||||||
|
1
pkg/.gitignore
vendored
Normal file
1
pkg/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
|||||||
|
*
|
@ -1,34 +0,0 @@
|
|||||||
## sdk_client — bibliothèque cliente Silent Payments (WASM)
|
|
||||||
|
|
||||||
Ce dépôt fournit une bibliothèque cliente visant l’intégration WebAssembly pour gérer appareil, portefeuille, processus et échanges chiffrés associés aux Silent Payments. Cette documentation renvoie vers `docs/` pour les spécifications détaillées, sans exemples exécutables.
|
|
||||||
|
|
||||||
## 📋 Table des Matières
|
|
||||||
|
|
||||||
- [📚 Documentation](#-documentation)
|
|
||||||
- [🧪 Tests](#-tests)
|
|
||||||
- [🛠️ Développement](#️-développement)
|
|
||||||
- [🚨 Dépannage](#-dépannage)
|
|
||||||
|
|
||||||
## 📚 Documentation
|
|
||||||
|
|
||||||
- [Architecture](docs/ARCHITECTURE.md)
|
|
||||||
- [Référence API](docs/API.md)
|
|
||||||
- [Configuration](docs/CONFIGURATION.md)
|
|
||||||
- [Tests](docs/TESTING.md)
|
|
||||||
|
|
||||||
## 🧪 Tests
|
|
||||||
|
|
||||||
- Tests natifs: `cargo test`
|
|
||||||
- Tests WASM (Windows): utiliser le script PowerShell `scripts/run-wasm-tests.ps1` (prérequis LLVM/Clang, voir `docs/TESTING.md`).
|
|
||||||
|
|
||||||
## 🛠️ Développement
|
|
||||||
|
|
||||||
La surface de code est centrée sur `src/` (Rust) avec export WASM. Les invariants sont décrits dans `docs/ARCHITECTURE.md` et `docs/API.md`.
|
|
||||||
|
|
||||||
## 🚨 Dépannage
|
|
||||||
|
|
||||||
Consulter `docs/TESTING.md` (section WASM Windows) pour les variables d’environnement et le runner wasm-bindgen.
|
|
||||||
|
|
||||||
---
|
|
||||||
|
|
||||||
Documentation de référence: voir `docs/` pour la table des matières.
|
|
@ -1,11 +1,17 @@
|
|||||||
{
|
{
|
||||||
"name": "sdk_client",
|
"name": "sdk_client",
|
||||||
"version": "0.1.3",
|
"type": "module",
|
||||||
|
"version": "0.1.0",
|
||||||
"files": [
|
"files": [
|
||||||
"sdk_client_bg.wasm",
|
"sdk_client_bg.wasm",
|
||||||
"sdk_client.js",
|
"sdk_client.js",
|
||||||
|
"sdk_client_bg.js",
|
||||||
"sdk_client.d.ts"
|
"sdk_client.d.ts"
|
||||||
],
|
],
|
||||||
"main": "sdk_client.js",
|
"main": "sdk_client.js",
|
||||||
"types": "sdk_client.d.ts"
|
"types": "sdk_client.d.ts",
|
||||||
|
"sideEffects": [
|
||||||
|
"./sdk_client.js",
|
||||||
|
"./snippets/*"
|
||||||
|
]
|
||||||
}
|
}
|
40
pkg/sdk_client.d.ts
vendored
40
pkg/sdk_client.d.ts
vendored
@ -6,11 +6,14 @@ export function get_member(): Member;
|
|||||||
export function restore_device(device: any): void;
|
export function restore_device(device: any): void;
|
||||||
export function create_device_from_sp_wallet(sp_wallet: string): string;
|
export function create_device_from_sp_wallet(sp_wallet: string): string;
|
||||||
export function create_new_device(birthday: number, network_str: string): string;
|
export function create_new_device(birthday: number, network_str: string): string;
|
||||||
export function scan_blocks(tip_height: number, blindbit_url: string): Promise<void>;
|
|
||||||
export function is_paired(): boolean;
|
export function is_paired(): boolean;
|
||||||
export function pair_device(process_id: string, sp_addresses: string[]): void;
|
export function pair_device(process_id: string, sp_addresses: string[]): void;
|
||||||
export function unpair_device(): void;
|
export function unpair_device(): void;
|
||||||
export function dump_wallet(): string;
|
export function dump_wallet(): string;
|
||||||
|
export function reset_process_cache(): void;
|
||||||
|
export function dump_process_cache(): string;
|
||||||
|
export function set_process_cache(processes: any): void;
|
||||||
|
export function add_to_process_cache(process_id: string, process: string): void;
|
||||||
export function reset_shared_secrets(): void;
|
export function reset_shared_secrets(): void;
|
||||||
export function set_shared_secrets(secrets: string): void;
|
export function set_shared_secrets(secrets: string): void;
|
||||||
export function get_pairing_process_id(): string;
|
export function get_pairing_process_id(): string;
|
||||||
@ -18,11 +21,8 @@ export function dump_device(): Device;
|
|||||||
export function dump_neutered_device(): Device;
|
export function dump_neutered_device(): Device;
|
||||||
export function reset_device(): void;
|
export function reset_device(): void;
|
||||||
export function get_txid(transaction: string): string;
|
export function get_txid(transaction: string): string;
|
||||||
export function get_prevouts(transaction: string): string[];
|
|
||||||
export function get_opreturn(transaction: string): string;
|
|
||||||
export function process_commit_new_state(process: Process, state_id: string, new_tip: string): Process;
|
|
||||||
export function parse_new_tx(new_tx_msg: string, block_height: number, members_list: OutPointMemberMap): ApiReturn;
|
export function parse_new_tx(new_tx_msg: string, block_height: number, members_list: OutPointMemberMap): ApiReturn;
|
||||||
export function parse_cipher(cipher_msg: string, members_list: OutPointMemberMap, processes: OutPointProcessMap): ApiReturn;
|
export function parse_cipher(cipher_msg: string, members_list: OutPointMemberMap): ApiReturn;
|
||||||
export function get_outputs(): any;
|
export function get_outputs(): any;
|
||||||
export function get_available_amount(): bigint;
|
export function get_available_amount(): bigint;
|
||||||
/**
|
/**
|
||||||
@ -50,15 +50,15 @@ export function decode_value(value: Uint8Array): any;
|
|||||||
export function hash_value(value: any, commited_in: string, label: string): string;
|
export function hash_value(value: any, commited_in: string, label: string): string;
|
||||||
/**
|
/**
|
||||||
* Generate a merkle proof for a specific attribute in a process state.
|
* Generate a merkle proof for a specific attribute in a process state.
|
||||||
*
|
*
|
||||||
* This function creates a merkle proof that proves the existence of a specific attribute
|
* This function creates a merkle proof that proves the existence of a specific attribute
|
||||||
* in a given state of a process. The proof can be used to verify that the attribute
|
* in a given state of a process. The proof can be used to verify that the attribute
|
||||||
* was indeed part of the state without revealing the entire state.
|
* was indeed part of the state without revealing the entire state.
|
||||||
*
|
*
|
||||||
* # Arguments
|
* # Arguments
|
||||||
* * `process_state` - The process state object as a JavaScript value
|
* * `process_state` - The process state object as a JavaScript value
|
||||||
* * `attribute_name` - The name of the attribute to generate a proof for
|
* * `attribute_name` - The name of the attribute to generate a proof for
|
||||||
*
|
*
|
||||||
* # Returns
|
* # Returns
|
||||||
* A MerkleProofResult object containing:
|
* A MerkleProofResult object containing:
|
||||||
* * `proof` - The merkle proof as a hex string
|
* * `proof` - The merkle proof as a hex string
|
||||||
@ -66,7 +66,7 @@ export function hash_value(value: any, commited_in: string, label: string): stri
|
|||||||
* * `attribute` - The attribute name that was proven
|
* * `attribute` - The attribute name that was proven
|
||||||
* * `attribute_index` - The index of the attribute in the merkle tree
|
* * `attribute_index` - The index of the attribute in the merkle tree
|
||||||
* * `total_leaves_count` - The total number of leaves in the merkle tree
|
* * `total_leaves_count` - The total number of leaves in the merkle tree
|
||||||
*
|
*
|
||||||
* # Errors
|
* # Errors
|
||||||
* * "Failed to deserialize process state" - If the process state cannot be deserialized from JsValue
|
* * "Failed to deserialize process state" - If the process state cannot be deserialized from JsValue
|
||||||
* * "Attribute not found in state" - If the attribute doesn't exist in the state
|
* * "Attribute not found in state" - If the attribute doesn't exist in the state
|
||||||
@ -74,18 +74,18 @@ export function hash_value(value: any, commited_in: string, label: string): stri
|
|||||||
export function get_merkle_proof(process_state: any, attribute_name: string): MerkleProofResult;
|
export function get_merkle_proof(process_state: any, attribute_name: string): MerkleProofResult;
|
||||||
/**
|
/**
|
||||||
* Validate a merkle proof for a specific attribute.
|
* Validate a merkle proof for a specific attribute.
|
||||||
*
|
*
|
||||||
* This function verifies that a merkle proof is valid and proves the existence
|
* This function verifies that a merkle proof is valid and proves the existence
|
||||||
* of a specific attribute in a given state. It checks that the proof correctly
|
* of a specific attribute in a given state. It checks that the proof correctly
|
||||||
* leads to the claimed root when combined with the attribute hash.
|
* leads to the claimed root when combined with the attribute hash.
|
||||||
*
|
*
|
||||||
* # Arguments
|
* # Arguments
|
||||||
* * `proof_result` - a JsValue expected to contain a MerkleProofResult with the proof and metadata
|
* * `proof_result` - a JsValue expected to contain a MerkleProofResult with the proof and metadata
|
||||||
* * `hash` - The hash of the attribute data as a hex string (the leaf value)
|
* * `hash` - The hash of the attribute data as a hex string (the leaf value)
|
||||||
*
|
*
|
||||||
* # Returns
|
* # Returns
|
||||||
* A boolean indicating whether the proof is valid
|
* A boolean indicating whether the proof is valid
|
||||||
*
|
*
|
||||||
* # Errors
|
* # Errors
|
||||||
* * "serde_wasm_bindgen deserialization error" - If the proof is not a valid MerkleProofResult
|
* * "serde_wasm_bindgen deserialization error" - If the proof is not a valid MerkleProofResult
|
||||||
* * "Invalid proof format" - If the proof cannot be parsed
|
* * "Invalid proof format" - If the proof cannot be parsed
|
||||||
@ -144,10 +144,7 @@ export interface Device {
|
|||||||
paired_member: Member;
|
paired_member: Member;
|
||||||
}
|
}
|
||||||
|
|
||||||
export interface SecretsStore {
|
export type TsUnsignedTransaction = SilentPaymentUnsignedTransaction;
|
||||||
shared_secrets: Record<SilentPaymentAddress, AnkSharedSecretHash>;
|
|
||||||
unconfirmed_secrets: AnkSharedSecretHash[];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* A process is basically a succession of states
|
* A process is basically a succession of states
|
||||||
@ -190,16 +187,19 @@ export interface Member {
|
|||||||
sp_addresses: string[];
|
sp_addresses: string[];
|
||||||
}
|
}
|
||||||
|
|
||||||
export type TsUnsignedTransaction = SilentPaymentUnsignedTransaction;
|
|
||||||
|
|
||||||
export type OutPointProcessMap = Record<OutPoint, Process>;
|
export type OutPointProcessMap = Record<OutPoint, Process>;
|
||||||
|
|
||||||
export type OutPointMemberMap = Record<OutPoint, Member>;
|
export type OutPointMemberMap = Record<OutPoint, Member>;
|
||||||
|
|
||||||
|
export interface SecretsStore {
|
||||||
|
shared_secrets: Record<SilentPaymentAddress, AnkSharedSecretHash>;
|
||||||
|
unconfirmed_secrets: AnkSharedSecretHash[];
|
||||||
|
}
|
||||||
|
|
||||||
export interface Prd {
|
export interface Prd {
|
||||||
prd_type: PrdType;
|
prd_type: PrdType;
|
||||||
process_id: OutPoint;
|
process_id: OutPoint;
|
||||||
sender: OutPoint | null;
|
sender: Member;
|
||||||
keys: Record<string, number[]>;
|
keys: Record<string, number[]>;
|
||||||
pcd_commitments: PcdCommitments;
|
pcd_commitments: PcdCommitments;
|
||||||
validation_tokens: Proof[];
|
validation_tokens: Proof[];
|
||||||
|
1675
pkg/sdk_client.js
1675
pkg/sdk_client.js
File diff suppressed because it is too large
Load Diff
1402
pkg/sdk_client_bg.js
Normal file
1402
pkg/sdk_client_bg.js
Normal file
File diff suppressed because it is too large
Load Diff
Binary file not shown.
69
pkg/sdk_client_bg.wasm.d.ts
vendored
Normal file
69
pkg/sdk_client_bg.wasm.d.ts
vendored
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
/* tslint:disable */
|
||||||
|
/* eslint-disable */
|
||||||
|
export const memory: WebAssembly.Memory;
|
||||||
|
export const setup: () => void;
|
||||||
|
export const get_address: () => [number, number, number, number];
|
||||||
|
export const get_member: () => [number, number, number];
|
||||||
|
export const restore_device: (a: any) => [number, number];
|
||||||
|
export const create_device_from_sp_wallet: (a: number, b: number) => [number, number, number, number];
|
||||||
|
export const create_new_device: (a: number, b: number, c: number) => [number, number, number, number];
|
||||||
|
export const is_paired: () => [number, number, number];
|
||||||
|
export const pair_device: (a: number, b: number, c: number, d: number) => [number, number];
|
||||||
|
export const unpair_device: () => [number, number];
|
||||||
|
export const dump_wallet: () => [number, number, number, number];
|
||||||
|
export const reset_process_cache: () => [number, number];
|
||||||
|
export const dump_process_cache: () => [number, number, number, number];
|
||||||
|
export const set_process_cache: (a: any) => [number, number];
|
||||||
|
export const add_to_process_cache: (a: number, b: number, c: number, d: number) => [number, number];
|
||||||
|
export const reset_shared_secrets: () => [number, number];
|
||||||
|
export const set_shared_secrets: (a: number, b: number) => [number, number];
|
||||||
|
export const get_pairing_process_id: () => [number, number, number, number];
|
||||||
|
export const dump_device: () => [number, number, number];
|
||||||
|
export const dump_neutered_device: () => [number, number, number];
|
||||||
|
export const reset_device: () => [number, number];
|
||||||
|
export const get_txid: (a: number, b: number) => [number, number, number, number];
|
||||||
|
export const parse_new_tx: (a: number, b: number, c: number, d: any) => [number, number, number];
|
||||||
|
export const parse_cipher: (a: number, b: number, c: any) => [number, number, number];
|
||||||
|
export const get_outputs: () => [number, number, number];
|
||||||
|
export const get_available_amount: () => [bigint, number, number];
|
||||||
|
export const create_transaction: (a: number, b: number, c: number) => [number, number, number];
|
||||||
|
export const sign_transaction: (a: any) => [number, number, number];
|
||||||
|
export const create_new_process: (a: any, b: any, c: any, d: number, e: number, f: number, g: any) => [number, number, number];
|
||||||
|
export const update_process: (a: any, b: any, c: any, d: any, e: any) => [number, number, number];
|
||||||
|
export const request_data: (a: number, b: number, c: number, d: number, e: any, f: any) => [number, number, number];
|
||||||
|
export const create_update_message: (a: any, b: number, c: number, d: any) => [number, number, number];
|
||||||
|
export const validate_state: (a: any, b: number, c: number, d: any) => [number, number, number];
|
||||||
|
export const refuse_state: (a: any, b: number, c: number, d: any) => [number, number, number];
|
||||||
|
export const evaluate_state: (a: any, b: number, c: number, d: any) => [number, number, number];
|
||||||
|
export const create_response_prd: (a: any, b: number, c: number, d: any) => [number, number, number];
|
||||||
|
export const create_faucet_msg: () => [number, number, number, number];
|
||||||
|
export const get_storages: (a: number, b: number) => [number, number, number, number];
|
||||||
|
export const is_child_role: (a: number, b: number, c: number, d: number) => [number, number];
|
||||||
|
export const decrypt_data: (a: number, b: number, c: number, d: number) => [number, number, number, number];
|
||||||
|
export const encode_binary: (a: any) => [number, number, number];
|
||||||
|
export const encode_json: (a: any) => [number, number, number];
|
||||||
|
export const decode_value: (a: number, b: number) => [number, number, number];
|
||||||
|
export const hash_value: (a: any, b: number, c: number, d: number, e: number) => [number, number, number, number];
|
||||||
|
export const get_merkle_proof: (a: any, b: number, c: number) => [number, number, number];
|
||||||
|
export const validate_merkle_proof: (a: any, b: number, c: number) => [number, number, number];
|
||||||
|
export const rust_zstd_wasm_shim_qsort: (a: number, b: number, c: number, d: number) => void;
|
||||||
|
export const rust_zstd_wasm_shim_malloc: (a: number) => number;
|
||||||
|
export const rust_zstd_wasm_shim_memcmp: (a: number, b: number, c: number) => number;
|
||||||
|
export const rust_zstd_wasm_shim_calloc: (a: number, b: number) => number;
|
||||||
|
export const rust_zstd_wasm_shim_free: (a: number) => void;
|
||||||
|
export const rust_zstd_wasm_shim_memcpy: (a: number, b: number, c: number) => number;
|
||||||
|
export const rust_zstd_wasm_shim_memmove: (a: number, b: number, c: number) => number;
|
||||||
|
export const rust_zstd_wasm_shim_memset: (a: number, b: number, c: number) => number;
|
||||||
|
export const rustsecp256k1_v0_9_2_context_create: (a: number) => number;
|
||||||
|
export const rustsecp256k1_v0_9_2_context_destroy: (a: number) => void;
|
||||||
|
export const rustsecp256k1_v0_9_2_default_illegal_callback_fn: (a: number, b: number) => void;
|
||||||
|
export const rustsecp256k1_v0_9_2_default_error_callback_fn: (a: number, b: number) => void;
|
||||||
|
export const __wbindgen_malloc: (a: number, b: number) => number;
|
||||||
|
export const __wbindgen_realloc: (a: number, b: number, c: number, d: number) => number;
|
||||||
|
export const __wbindgen_exn_store: (a: number) => void;
|
||||||
|
export const __externref_table_alloc: () => number;
|
||||||
|
export const __wbindgen_export_4: WebAssembly.Table;
|
||||||
|
export const __externref_table_dealloc: (a: number) => void;
|
||||||
|
export const __wbindgen_free: (a: number, b: number, c: number) => void;
|
||||||
|
export const __externref_drop_slice: (a: number, b: number) => void;
|
||||||
|
export const __wbindgen_start: () => void;
|
Loading…
x
Reference in New Issue
Block a user