@gatewayfm/ups-sdk 0.1.13

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.
Files changed (47) hide show
  1. package/dist/account/index.d.mts +18 -0
  2. package/dist/account/index.d.ts +18 -0
  3. package/dist/account/index.js +12 -0
  4. package/dist/account/index.js.map +1 -0
  5. package/dist/account/index.mjs +3 -0
  6. package/dist/account/index.mjs.map +1 -0
  7. package/dist/chunk-2S2KS5ZI.js +150 -0
  8. package/dist/chunk-2S2KS5ZI.js.map +1 -0
  9. package/dist/chunk-BH5YEAE6.mjs +47 -0
  10. package/dist/chunk-BH5YEAE6.mjs.map +1 -0
  11. package/dist/chunk-BUSFZFJS.mjs +55 -0
  12. package/dist/chunk-BUSFZFJS.mjs.map +1 -0
  13. package/dist/chunk-G525R6AV.js +54 -0
  14. package/dist/chunk-G525R6AV.js.map +1 -0
  15. package/dist/chunk-PMX24TXY.js +138 -0
  16. package/dist/chunk-PMX24TXY.js.map +1 -0
  17. package/dist/chunk-S65V52WZ.mjs +148 -0
  18. package/dist/chunk-S65V52WZ.mjs.map +1 -0
  19. package/dist/chunk-VORGSH76.mjs +136 -0
  20. package/dist/chunk-VORGSH76.mjs.map +1 -0
  21. package/dist/chunk-XKQI2VMJ.js +57 -0
  22. package/dist/chunk-XKQI2VMJ.js.map +1 -0
  23. package/dist/http-client-D9JtkvUx.d.mts +22 -0
  24. package/dist/http-client-D9JtkvUx.d.ts +22 -0
  25. package/dist/index-1p5DSytk.d.mts +35 -0
  26. package/dist/index-Csrh5-dl.d.mts +160 -0
  27. package/dist/index-Csrh5-dl.d.ts +160 -0
  28. package/dist/index-D_ytPgEV.d.ts +35 -0
  29. package/dist/index.d.mts +130 -0
  30. package/dist/index.d.ts +130 -0
  31. package/dist/index.js +485 -0
  32. package/dist/index.js.map +1 -0
  33. package/dist/index.mjs +445 -0
  34. package/dist/index.mjs.map +1 -0
  35. package/dist/payment/index.d.mts +25 -0
  36. package/dist/payment/index.d.ts +25 -0
  37. package/dist/payment/index.js +13 -0
  38. package/dist/payment/index.js.map +1 -0
  39. package/dist/payment/index.mjs +4 -0
  40. package/dist/payment/index.mjs.map +1 -0
  41. package/dist/wallet/index.d.mts +2 -0
  42. package/dist/wallet/index.d.ts +2 -0
  43. package/dist/wallet/index.js +13 -0
  44. package/dist/wallet/index.js.map +1 -0
  45. package/dist/wallet/index.mjs +4 -0
  46. package/dist/wallet/index.mjs.map +1 -0
  47. package/package.json +56 -0
@@ -0,0 +1,160 @@
1
+ interface UPSConfig {
2
+ baseUrl: string;
3
+ network: string;
4
+ chainId?: number;
5
+ timeout?: number;
6
+ retryAttempts?: number;
7
+ refreshInterval?: number;
8
+ }
9
+ interface AuthState {
10
+ isAuthenticated: boolean;
11
+ token: string | null;
12
+ expiresAt: Date | null;
13
+ address: string | null;
14
+ }
15
+ interface AuthResult {
16
+ token: string;
17
+ expiresAt: string;
18
+ }
19
+ interface User {
20
+ id: string;
21
+ walletAddress: string;
22
+ status: string;
23
+ createdAt: string;
24
+ }
25
+ interface ConnectResult {
26
+ user: User;
27
+ token: string;
28
+ expiresAt: string;
29
+ isNewUser: boolean;
30
+ }
31
+ type EIP1193Provider = {
32
+ request: (args: {
33
+ method: string;
34
+ params?: unknown[];
35
+ }) => Promise<unknown>;
36
+ on?: (event: string, handler: (...args: any[]) => void) => void;
37
+ removeListener?: (event: string, handler: (...args: any[]) => void) => void;
38
+ };
39
+ interface WalletState {
40
+ isConnected: boolean;
41
+ address: string | null;
42
+ chainId: number | null;
43
+ provider: EIP1193Provider | null;
44
+ }
45
+ interface ConnectedWallet {
46
+ address: string;
47
+ chainId: number;
48
+ provider: EIP1193Provider;
49
+ }
50
+ type AccountStatus = 'pending' | 'kyc_in_progress' | 'active' | 'frozen' | 'closed';
51
+ interface Account {
52
+ id: string;
53
+ ownerAddress: string;
54
+ walletAddress: string;
55
+ status: AccountStatus;
56
+ kycLevel: number;
57
+ userId?: string;
58
+ createdAt: string;
59
+ updatedAt?: string;
60
+ }
61
+ interface CreateAccountParams {
62
+ ownerAddress: string;
63
+ salt: string;
64
+ }
65
+ interface CreateAccountResponse {
66
+ account: Account;
67
+ txHash: string;
68
+ }
69
+ interface PaymentRequirements {
70
+ scheme: string;
71
+ network: string;
72
+ maxAmountRequired: string;
73
+ asset: string;
74
+ payTo: string;
75
+ maxTimeoutSeconds: number;
76
+ resource?: string;
77
+ description?: string;
78
+ extra?: PaymentExtra;
79
+ from?: string;
80
+ }
81
+ declare enum PaymentType {
82
+ UNSPECIFIED = "UNSPECIFIED",
83
+ DIRECT = "DIRECT",
84
+ ESCROW = "ESCROW"
85
+ }
86
+ interface PaymentExtra {
87
+ name?: string;
88
+ version?: string;
89
+ payment_type?: PaymentType;
90
+ arbiter?: string;
91
+ release_time?: number;
92
+ payee?: string;
93
+ }
94
+ interface PaymentAuthorization {
95
+ from: string;
96
+ to: string;
97
+ value: string;
98
+ validAfter: number;
99
+ validBefore: number;
100
+ nonce: string;
101
+ }
102
+ interface SignedAuthorization extends PaymentAuthorization {
103
+ signature: string;
104
+ }
105
+ interface VerifyResponse {
106
+ isValid: boolean;
107
+ invalidReason?: string;
108
+ payer?: string;
109
+ }
110
+ interface SettleResponse {
111
+ success: boolean;
112
+ errorReason?: string;
113
+ transaction?: string;
114
+ network?: string;
115
+ payer?: string;
116
+ }
117
+ interface SupportedScheme {
118
+ x402Version: number;
119
+ scheme: string;
120
+ network: string;
121
+ }
122
+ interface SupportedSchemesResponse {
123
+ kinds: SupportedScheme[];
124
+ extensions?: string[];
125
+ signers?: Record<string, string[]>;
126
+ }
127
+ interface EIP712Domain {
128
+ name: string;
129
+ version: string;
130
+ chainId: number;
131
+ verifyingContract: string;
132
+ }
133
+ interface EIP712Type {
134
+ name: string;
135
+ type: string;
136
+ }
137
+ interface EIP712TypedData {
138
+ domain: EIP712Domain;
139
+ types: Record<string, EIP712Type[]>;
140
+ primaryType: string;
141
+ message: Record<string, unknown>;
142
+ }
143
+ interface Escrow {
144
+ escrowId: string;
145
+ payer: string;
146
+ payee: string;
147
+ amount: string;
148
+ arbiter: string;
149
+ releaseTime: number;
150
+ status: EscrowStatus;
151
+ }
152
+ type EscrowStatus = 'ACTIVE' | 'RELEASED' | 'REFUNDED';
153
+ interface EscrowActionResponse {
154
+ success: boolean;
155
+ errorReason?: string;
156
+ transaction?: string;
157
+ network?: string;
158
+ }
159
+
160
+ export { type AuthState as A, type ConnectResult as C, type Escrow as E, type PaymentAuthorization as P, type SettleResponse as S, type User as U, type VerifyResponse as V, type WalletState as W, type AuthResult as a, type EscrowActionResponse as b, type UPSConfig as c, type EIP1193Provider as d, type ConnectedWallet as e, type Account as f, type AccountStatus as g, type CreateAccountParams as h, type CreateAccountResponse as i, type EIP712Domain as j, type EIP712Type as k, type EIP712TypedData as l, type EscrowStatus as m, type PaymentExtra as n, type PaymentRequirements as o, PaymentType as p, type SignedAuthorization as q, type SupportedScheme as r, type SupportedSchemesResponse as s };
@@ -0,0 +1,35 @@
1
+ import { W as WalletState, d as EIP1193Provider, e as ConnectedWallet, l as EIP712TypedData } from './index-Csrh5-dl.js';
2
+
3
+ type Callback<T = any> = (payload: T) => void;
4
+ type Unsubscribe = () => void;
5
+ declare class EventBus {
6
+ private listeners;
7
+ emit<T>(event: string, payload: T): void;
8
+ on<T>(event: string, callback: Callback<T>): Unsubscribe;
9
+ once<T>(event: string, callback: Callback<T>): Unsubscribe;
10
+ off(event: string, callback: Callback): void;
11
+ clear(): void;
12
+ }
13
+
14
+ declare class WalletModule {
15
+ private eventBus;
16
+ private _state;
17
+ private client;
18
+ private chains;
19
+ constructor(eventBus: EventBus);
20
+ get state(): WalletState;
21
+ connect(provider: EIP1193Provider): Promise<ConnectedWallet>;
22
+ disconnect(): Promise<void>;
23
+ getAddress(): string | null;
24
+ getChainId(): number | null;
25
+ isConnected(): boolean;
26
+ signMessage(message: string): Promise<string>;
27
+ signTypedData(typedData: EIP712TypedData): Promise<string>;
28
+ switchChain(chainId: number): Promise<void>;
29
+ onStateChange(callback: (state: WalletState) => void): () => void;
30
+ private updateState;
31
+ private setupListeners;
32
+ private getChain;
33
+ }
34
+
35
+ export { EventBus as E, WalletModule as W };
@@ -0,0 +1,130 @@
1
+ import { A as AuthState, C as ConnectResult, a as AuthResult, E as Escrow, b as EscrowActionResponse, U as User, c as UPSConfig, d as EIP1193Provider, e as ConnectedWallet } from './index-Csrh5-dl.mjs';
2
+ export { f as Account, g as AccountStatus, h as CreateAccountParams, i as CreateAccountResponse, j as EIP712Domain, k as EIP712Type, l as EIP712TypedData, m as EscrowStatus, P as PaymentAuthorization, n as PaymentExtra, o as PaymentRequirements, p as PaymentType, S as SettleResponse, q as SignedAuthorization, r as SupportedScheme, s as SupportedSchemesResponse, V as VerifyResponse, W as WalletState } from './index-Csrh5-dl.mjs';
3
+ import { H as HttpClient } from './http-client-D9JtkvUx.mjs';
4
+ import { E as EventBus, W as WalletModule } from './index-1p5DSytk.mjs';
5
+ import { AccountModule } from './account/index.mjs';
6
+ import { PaymentModule } from './payment/index.mjs';
7
+
8
+ declare class UPSError extends Error {
9
+ code: string;
10
+ details?: unknown;
11
+ constructor(message: string, code: string, details?: unknown);
12
+ }
13
+ declare class NetworkError extends UPSError {
14
+ status?: number;
15
+ constructor(message: string, details?: unknown, status?: number);
16
+ }
17
+ declare class AuthError extends UPSError {
18
+ constructor(message: string, details?: unknown);
19
+ }
20
+ declare class WalletError extends UPSError {
21
+ constructor(message: string, details?: unknown);
22
+ }
23
+ declare class PaymentError extends UPSError {
24
+ constructor(message: string, details?: unknown);
25
+ }
26
+ declare class RateLimitError extends UPSError {
27
+ constructor(message: string, details?: unknown);
28
+ }
29
+
30
+ declare class AuthManager {
31
+ private http;
32
+ private eventBus;
33
+ private _state;
34
+ private refreshTimer;
35
+ private refreshInterval;
36
+ constructor(http: HttpClient, eventBus: EventBus, refreshInterval?: number);
37
+ get state(): AuthState;
38
+ /**
39
+ * Unified connect method - creates user if new, authenticates if existing
40
+ * This is the preferred authentication method.
41
+ */
42
+ connect(walletAddress: string, message: string, signature: string): Promise<ConnectResult>;
43
+ /**
44
+ * @deprecated Use connect() instead
45
+ */
46
+ login(walletAddress: string, message: string, signature: string): Promise<AuthResult>;
47
+ /**
48
+ * @deprecated Use connect() instead
49
+ */
50
+ register(walletAddress: string, message: string, signature: string): Promise<AuthResult>;
51
+ private handleAuthSuccess;
52
+ refresh(): Promise<void>;
53
+ private mapUser;
54
+ logout(): void;
55
+ getToken(): string | null;
56
+ isAuthenticated(): boolean;
57
+ onStateChange(callback: (state: AuthState) => void): () => void;
58
+ private updateState;
59
+ private scheduleRefresh;
60
+ }
61
+
62
+ declare class EscrowModule {
63
+ private http;
64
+ constructor(http: HttpClient);
65
+ /**
66
+ * Get escrow details by ID
67
+ * @param escrowId Escrow ID
68
+ */
69
+ get(escrowId: string): Promise<Escrow>;
70
+ /**
71
+ * Release escrow funds (Payer or Arbiter only)
72
+ * @param escrowId Escrow ID
73
+ */
74
+ release(escrowId: string, network: string): Promise<EscrowActionResponse>;
75
+ /**
76
+ * Refund escrow funds (Arbiter only)
77
+ * @param escrowId Escrow ID
78
+ */
79
+ refund(escrowId: string, network: string): Promise<EscrowActionResponse>;
80
+ }
81
+
82
+ /**
83
+ * UserModule provides access to user profile operations.
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * const user = await client.user.getCurrentUser();
88
+ * console.log(user.id, user.walletAddress);
89
+ * ```
90
+ */
91
+ declare class UserModule {
92
+ private http;
93
+ constructor(http: HttpClient);
94
+ /**
95
+ * Get the current authenticated user's profile.
96
+ * Requires authentication.
97
+ */
98
+ getCurrentUser(): Promise<User>;
99
+ private mapUser;
100
+ }
101
+
102
+ declare class UPSClient {
103
+ readonly config: UPSConfig;
104
+ readonly wallet: WalletModule;
105
+ readonly auth: AuthManager;
106
+ readonly account: AccountModule;
107
+ readonly payment: PaymentModule;
108
+ readonly escrow: EscrowModule;
109
+ readonly user: UserModule;
110
+ private http;
111
+ private eventBus;
112
+ constructor(config: UPSConfig);
113
+ connect(provider: EIP1193Provider): Promise<ConnectedWallet>;
114
+ /**
115
+ * Authenticate with the UPS backend using the unified /auth/connect endpoint.
116
+ * This will create a new user if one doesn't exist, or authenticate an existing user.
117
+ *
118
+ * @returns ConnectResult containing user info and whether this is a new user
119
+ */
120
+ authenticate(): Promise<ConnectResult>;
121
+ /**
122
+ * @deprecated Use authenticate() instead which uses the unified /auth/connect endpoint.
123
+ * This method uses the legacy login/register flow.
124
+ */
125
+ authenticateLegacy(): Promise<void>;
126
+ disconnect(): Promise<void>;
127
+ destroy(): void;
128
+ }
129
+
130
+ export { AccountModule, AuthError, AuthManager, AuthResult, AuthState, ConnectResult, ConnectedWallet, EIP1193Provider, Escrow, EscrowActionResponse, EscrowModule, EventBus, HttpClient, NetworkError, PaymentError, PaymentModule, RateLimitError, UPSClient, UPSConfig, UPSError, User, UserModule, WalletError, WalletModule };
@@ -0,0 +1,130 @@
1
+ import { A as AuthState, C as ConnectResult, a as AuthResult, E as Escrow, b as EscrowActionResponse, U as User, c as UPSConfig, d as EIP1193Provider, e as ConnectedWallet } from './index-Csrh5-dl.js';
2
+ export { f as Account, g as AccountStatus, h as CreateAccountParams, i as CreateAccountResponse, j as EIP712Domain, k as EIP712Type, l as EIP712TypedData, m as EscrowStatus, P as PaymentAuthorization, n as PaymentExtra, o as PaymentRequirements, p as PaymentType, S as SettleResponse, q as SignedAuthorization, r as SupportedScheme, s as SupportedSchemesResponse, V as VerifyResponse, W as WalletState } from './index-Csrh5-dl.js';
3
+ import { H as HttpClient } from './http-client-D9JtkvUx.js';
4
+ import { E as EventBus, W as WalletModule } from './index-D_ytPgEV.js';
5
+ import { AccountModule } from './account/index.js';
6
+ import { PaymentModule } from './payment/index.js';
7
+
8
+ declare class UPSError extends Error {
9
+ code: string;
10
+ details?: unknown;
11
+ constructor(message: string, code: string, details?: unknown);
12
+ }
13
+ declare class NetworkError extends UPSError {
14
+ status?: number;
15
+ constructor(message: string, details?: unknown, status?: number);
16
+ }
17
+ declare class AuthError extends UPSError {
18
+ constructor(message: string, details?: unknown);
19
+ }
20
+ declare class WalletError extends UPSError {
21
+ constructor(message: string, details?: unknown);
22
+ }
23
+ declare class PaymentError extends UPSError {
24
+ constructor(message: string, details?: unknown);
25
+ }
26
+ declare class RateLimitError extends UPSError {
27
+ constructor(message: string, details?: unknown);
28
+ }
29
+
30
+ declare class AuthManager {
31
+ private http;
32
+ private eventBus;
33
+ private _state;
34
+ private refreshTimer;
35
+ private refreshInterval;
36
+ constructor(http: HttpClient, eventBus: EventBus, refreshInterval?: number);
37
+ get state(): AuthState;
38
+ /**
39
+ * Unified connect method - creates user if new, authenticates if existing
40
+ * This is the preferred authentication method.
41
+ */
42
+ connect(walletAddress: string, message: string, signature: string): Promise<ConnectResult>;
43
+ /**
44
+ * @deprecated Use connect() instead
45
+ */
46
+ login(walletAddress: string, message: string, signature: string): Promise<AuthResult>;
47
+ /**
48
+ * @deprecated Use connect() instead
49
+ */
50
+ register(walletAddress: string, message: string, signature: string): Promise<AuthResult>;
51
+ private handleAuthSuccess;
52
+ refresh(): Promise<void>;
53
+ private mapUser;
54
+ logout(): void;
55
+ getToken(): string | null;
56
+ isAuthenticated(): boolean;
57
+ onStateChange(callback: (state: AuthState) => void): () => void;
58
+ private updateState;
59
+ private scheduleRefresh;
60
+ }
61
+
62
+ declare class EscrowModule {
63
+ private http;
64
+ constructor(http: HttpClient);
65
+ /**
66
+ * Get escrow details by ID
67
+ * @param escrowId Escrow ID
68
+ */
69
+ get(escrowId: string): Promise<Escrow>;
70
+ /**
71
+ * Release escrow funds (Payer or Arbiter only)
72
+ * @param escrowId Escrow ID
73
+ */
74
+ release(escrowId: string, network: string): Promise<EscrowActionResponse>;
75
+ /**
76
+ * Refund escrow funds (Arbiter only)
77
+ * @param escrowId Escrow ID
78
+ */
79
+ refund(escrowId: string, network: string): Promise<EscrowActionResponse>;
80
+ }
81
+
82
+ /**
83
+ * UserModule provides access to user profile operations.
84
+ *
85
+ * @example
86
+ * ```typescript
87
+ * const user = await client.user.getCurrentUser();
88
+ * console.log(user.id, user.walletAddress);
89
+ * ```
90
+ */
91
+ declare class UserModule {
92
+ private http;
93
+ constructor(http: HttpClient);
94
+ /**
95
+ * Get the current authenticated user's profile.
96
+ * Requires authentication.
97
+ */
98
+ getCurrentUser(): Promise<User>;
99
+ private mapUser;
100
+ }
101
+
102
+ declare class UPSClient {
103
+ readonly config: UPSConfig;
104
+ readonly wallet: WalletModule;
105
+ readonly auth: AuthManager;
106
+ readonly account: AccountModule;
107
+ readonly payment: PaymentModule;
108
+ readonly escrow: EscrowModule;
109
+ readonly user: UserModule;
110
+ private http;
111
+ private eventBus;
112
+ constructor(config: UPSConfig);
113
+ connect(provider: EIP1193Provider): Promise<ConnectedWallet>;
114
+ /**
115
+ * Authenticate with the UPS backend using the unified /auth/connect endpoint.
116
+ * This will create a new user if one doesn't exist, or authenticate an existing user.
117
+ *
118
+ * @returns ConnectResult containing user info and whether this is a new user
119
+ */
120
+ authenticate(): Promise<ConnectResult>;
121
+ /**
122
+ * @deprecated Use authenticate() instead which uses the unified /auth/connect endpoint.
123
+ * This method uses the legacy login/register flow.
124
+ */
125
+ authenticateLegacy(): Promise<void>;
126
+ disconnect(): Promise<void>;
127
+ destroy(): void;
128
+ }
129
+
130
+ export { AccountModule, AuthError, AuthManager, AuthResult, AuthState, ConnectResult, ConnectedWallet, EIP1193Provider, Escrow, EscrowActionResponse, EscrowModule, EventBus, HttpClient, NetworkError, PaymentError, PaymentModule, RateLimitError, UPSClient, UPSConfig, UPSError, User, UserModule, WalletError, WalletModule };