@explorins/pers-signer 1.0.5

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 ADDED
@@ -0,0 +1,124 @@
1
+ # @explorins/pers-signer SDK
2
+
3
+ A lightweight SDK for blockchain transaction signing with PERS integration. Uses existing services and environment-based configuration.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install @explorins/pers-signer
9
+ ```
10
+
11
+ ## Quick Start
12
+
13
+ The SDK uses environment variables for configuration, so no complex setup is needed:
14
+
15
+ ```typescript
16
+ import { PersSignerSDK } from '@explorins/pers-signer';
17
+
18
+ // Simple initialization - uses environment config
19
+ const sdk = new PersSignerSDK();
20
+
21
+ // Authenticate user
22
+ const user = await sdk.authenticateUser('user@example.com');
23
+
24
+ // Sign PERS transaction
25
+ const result = await sdk.signPersTransaction(user, 'transaction-123');
26
+
27
+ if (result.success) {
28
+ console.log('Transaction hash:', result.transactionHash);
29
+ }
30
+ ```
31
+
32
+ ## Environment Variables
33
+
34
+ The SDK automatically uses these environment variables from your `.env` file:
35
+
36
+ - `VITE_EXPRESS_API_URL` - Signer backend API URL
37
+ - `VITE_PERS_API_URL` - PERS API URL
38
+ - `VITE_PASSKEY_RELYING_PARTY_*` - WebAuthn configuration
39
+ - `VITE_ETHERS_PROVIDER` - Blockchain provider URL
40
+
41
+ ## Configuration
42
+
43
+ Optional configuration can be provided:
44
+
45
+ ```typescript
46
+ import { PersSignerSDK, PersSignerConfig } from '@explorins/pers-signer';
47
+
48
+ const config: PersSignerConfig = {
49
+ tenantId: 'my-tenant', // Multi-tenant identifier
50
+ ethersProviderUrl: 'https://my-rpc.com' // Custom blockchain provider
51
+ };
52
+
53
+ const sdk = new PersSignerSDK(config);
54
+ ```
55
+
56
+ ## API Reference
57
+
58
+ ### High-Level Methods
59
+
60
+ #### `authenticateUser(identifier: string): Promise<SignerUser>`
61
+
62
+ Complete user onboarding flow - handles registration or login automatically.
63
+
64
+ #### `signPersTransaction(user: SignerUser, transactionId: string): Promise<SigningResult>`
65
+
66
+ Complete PERS transaction signing flow - same as the web project.
67
+
68
+ ### Granular Methods (For Custom Integrations)
69
+
70
+ #### `registerUser(identifier: string): Promise<{authToken: string}>`
71
+ #### `loginUser(identifier: string): Promise<string>`
72
+ #### `addWalletToPersUser(signerAuthToken: string): Promise<string>`
73
+ #### `retrieveTransactionData(transactionId: string, persAccessToken: string): Promise<any>`
74
+ #### `signTransactionData(signerAuthToken: string, transactionData: any): Promise<string>`
75
+ #### `submitTransaction(transactionId: string, signature: string, persAccessToken: string): Promise<{transactionHash?: string; success: boolean}>`
76
+
77
+ ### Utility Methods
78
+
79
+ #### `checkUserExists(identifier: string): Promise<boolean>`
80
+ #### `getUserWallets(signerAuthToken: string): Promise<any>`
81
+ #### `getTransactionStatus(transactionId: string, persAccessToken: string): Promise<{status: string; transactionHash?: string}>`
82
+
83
+ ## Examples
84
+
85
+ See `/examples/basic-usage.ts` for comprehensive examples including:
86
+
87
+ - Gaming platform integration
88
+ - E-commerce loyalty transactions
89
+ - Batch operations
90
+ - Custom blockchain providers
91
+ - Environment-based configuration
92
+
93
+ ## Types
94
+
95
+ ```typescript
96
+ interface PersSignerConfig {
97
+ tenantId?: string;
98
+ ethersProviderUrl?: string;
99
+ }
100
+
101
+ interface SignerUser {
102
+ identifier: string;
103
+ signerAuthToken?: string;
104
+ persAccessToken?: string;
105
+ }
106
+
107
+ interface SigningResult {
108
+ success: boolean;
109
+ transactionHash?: string;
110
+ error?: string;
111
+ }
112
+ ```
113
+
114
+ ## Architecture
115
+
116
+ This SDK is a simple orchestrator that uses existing services:
117
+
118
+ - **AuthenticationService** - WebAuthn authentication
119
+ - **WalletService** - Wallet management
120
+ - **SigningService** - Transaction signing
121
+ - **PersService** - PERS integration
122
+ - **TransactionSigningService** - High-level transaction flow
123
+
124
+ No complex initialization or platform providers needed - everything is pre-configured.