@plyaz/types 1.11.4 → 1.12.1
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/dist/api/index.cjs +1 -1
- package/dist/api/index.cjs.map +1 -1
- package/dist/auth/enums.d.ts +4 -0
- package/dist/auth/index.cjs +6 -0
- package/dist/auth/index.cjs.map +1 -1
- package/dist/auth/index.d.ts +0 -1
- package/dist/auth/index.js +6 -1
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/types.d.ts +34 -0
- package/dist/index.cjs +352 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +333 -1
- package/dist/index.js.map +1 -1
- package/dist/payments/currency/index.d.ts +37 -0
- package/dist/payments/events/emitter/types.d.ts +333 -0
- package/dist/payments/events/enums.d.ts +110 -0
- package/dist/payments/events/index.d.ts +4 -0
- package/dist/payments/events/types.d.ts +151 -0
- package/dist/payments/events/unified-event/enums.d.ts +14 -0
- package/dist/payments/events/unified-event/index.d.ts +2 -0
- package/dist/payments/events/unified-event/types.d.ts +346 -0
- package/dist/payments/gateways/index.d.ts +2 -0
- package/dist/payments/gateways/provider/index.d.ts +1 -0
- package/dist/payments/gateways/provider/types.d.ts +435 -0
- package/dist/payments/gateways/routings/enums.d.ts +87 -0
- package/dist/payments/gateways/routings/index.d.ts +2 -0
- package/dist/payments/gateways/routings/types.d.ts +512 -0
- package/dist/payments/index.cjs +351 -0
- package/dist/payments/index.cjs.map +1 -0
- package/dist/payments/index.d.ts +7 -0
- package/dist/payments/index.js +332 -0
- package/dist/payments/index.js.map +1 -0
- package/dist/payments/provider/adapter/index.d.ts +1 -0
- package/dist/payments/provider/adapter/types.d.ts +208 -0
- package/dist/payments/provider/core/index.d.ts +1 -0
- package/dist/payments/provider/core/types.d.ts +508 -0
- package/dist/payments/provider/index.d.ts +4 -0
- package/dist/payments/provider/payment-provider/index.d.ts +1 -0
- package/dist/payments/provider/payment-provider/types.d.ts +269 -0
- package/dist/payments/provider/provider-capability/enums.d.ts +116 -0
- package/dist/payments/provider/provider-capability/index.d.ts +1 -0
- package/dist/payments/request/enums.d.ts +19 -0
- package/dist/payments/request/index.d.ts +2 -0
- package/dist/payments/request/types.d.ts +221 -0
- package/dist/payments/service/index.d.ts +1 -0
- package/dist/payments/service/types.d.ts +48 -0
- package/dist/payments/transaction/index.d.ts +1 -0
- package/dist/payments/transaction/types.d.ts +120 -0
- package/package.json +6 -1
- package/dist/auth/config/types.d.ts +0 -67
- /package/dist/{auth/config → payments/events/emitter}/index.d.ts +0 -0
|
@@ -0,0 +1,120 @@
|
|
|
1
|
+
import type { CURRENCY } from '../currency';
|
|
2
|
+
/**
|
|
3
|
+
* Core money interface for handling monetary values throughout the system.
|
|
4
|
+
* All monetary amounts are stored in the smallest currency unit to avoid
|
|
5
|
+
* floating-point precision issues.
|
|
6
|
+
*
|
|
7
|
+
* Design Principles:
|
|
8
|
+
* - Always store amounts in smallest currency unit (cents, satoshis, wei)
|
|
9
|
+
* - Include currency information with every amount
|
|
10
|
+
* - Support display formatting for user interfaces
|
|
11
|
+
* - Track exchange rates for converted amounts
|
|
12
|
+
*/
|
|
13
|
+
export interface Money {
|
|
14
|
+
/**
|
|
15
|
+
* Amount in smallest currency unit (e.g., cents for USD, satoshis for BTC)
|
|
16
|
+
* Using integer values prevents floating-point precision issues
|
|
17
|
+
*/
|
|
18
|
+
amount: number;
|
|
19
|
+
/**
|
|
20
|
+
* Currency code following ISO 4217 standard for fiat currencies
|
|
21
|
+
* and custom codes for cryptocurrencies (BTC, ETH, etc.)
|
|
22
|
+
*/
|
|
23
|
+
currency: CURRENCY;
|
|
24
|
+
/**
|
|
25
|
+
* Human-readable formatted amount for display purposes
|
|
26
|
+
* Example: "$50.00", "€45.50", "0.001 BTC"
|
|
27
|
+
*/
|
|
28
|
+
displayAmount?: string;
|
|
29
|
+
/**
|
|
30
|
+
* Exchange rate used if this amount was converted from another currency
|
|
31
|
+
* Useful for tracking conversions and fees
|
|
32
|
+
*/
|
|
33
|
+
exchangeRate?: number;
|
|
34
|
+
/**
|
|
35
|
+
* Original currency if this amount was converted
|
|
36
|
+
* Helps with audit trails and reconciliation
|
|
37
|
+
*/
|
|
38
|
+
originalCurrency?: CURRENCY;
|
|
39
|
+
/**
|
|
40
|
+
* Timestamp when exchange rate was calculated
|
|
41
|
+
* Important for cryptocurrency and volatile currency exchanges
|
|
42
|
+
*/
|
|
43
|
+
exchangeRateTimestamp?: Date;
|
|
44
|
+
}
|
|
45
|
+
/**
|
|
46
|
+
* Comprehensive fee breakdown interface providing transparency
|
|
47
|
+
* into all costs associated with a payment transaction.
|
|
48
|
+
*
|
|
49
|
+
* Business Requirements:
|
|
50
|
+
* - Full transparency of all fees charged
|
|
51
|
+
* - Support for various fee types across providers
|
|
52
|
+
* - Regulatory compliance for fee disclosure
|
|
53
|
+
*/
|
|
54
|
+
export interface FeeBreakdown {
|
|
55
|
+
/** Payment processor fee (Stripe, PayPal, etc.) */
|
|
56
|
+
processingFee: Money;
|
|
57
|
+
/** Platform fee taken by Plyaz */
|
|
58
|
+
platformFee: Money;
|
|
59
|
+
/** Additional fee for international/cross-border transactions */
|
|
60
|
+
crossBorderFee?: Money;
|
|
61
|
+
/** Fee for currency conversion if applicable */
|
|
62
|
+
currencyConversionFee?: Money;
|
|
63
|
+
/** Network fee for blockchain transactions */
|
|
64
|
+
networkFee?: Money;
|
|
65
|
+
/** Gas fee for smart contract interactions */
|
|
66
|
+
gasFee?: Money;
|
|
67
|
+
/** Fee for instant/expedited processing */
|
|
68
|
+
expediteFee?: Money;
|
|
69
|
+
/** Risk assessment fee for high-risk transactions */
|
|
70
|
+
riskFee?: Money;
|
|
71
|
+
/** Regulatory compliance fee (where applicable) */
|
|
72
|
+
complianceFee?: Money;
|
|
73
|
+
/** Total of all fees combined */
|
|
74
|
+
total: Money;
|
|
75
|
+
/**
|
|
76
|
+
* Fee calculation metadata for audit and debugging
|
|
77
|
+
* Includes rate information and calculation details
|
|
78
|
+
*/
|
|
79
|
+
calculationMetadata?: {
|
|
80
|
+
processingRate?: number;
|
|
81
|
+
platformRate?: number;
|
|
82
|
+
crossBorderRate?: number;
|
|
83
|
+
conversionRate?: number;
|
|
84
|
+
calculatedAt: Date;
|
|
85
|
+
ruleVersion?: string;
|
|
86
|
+
};
|
|
87
|
+
}
|
|
88
|
+
/**
|
|
89
|
+
* Payment limits interface defining constraints on transaction amounts
|
|
90
|
+
* and frequencies to support compliance and risk management.
|
|
91
|
+
*/
|
|
92
|
+
export interface PaymentLimits {
|
|
93
|
+
/** Minimum transaction amount per payment method */
|
|
94
|
+
minimumAmount: Money;
|
|
95
|
+
/** Maximum transaction amount per payment method */
|
|
96
|
+
maximumAmount: Money;
|
|
97
|
+
/** Maximum daily transaction volume per user */
|
|
98
|
+
dailyLimit?: Money;
|
|
99
|
+
/** Maximum weekly transaction volume per user */
|
|
100
|
+
weeklyLimit?: Money;
|
|
101
|
+
/** Maximum monthly transaction volume per user */
|
|
102
|
+
monthlyLimit?: Money;
|
|
103
|
+
/** Maximum annual transaction volume per user */
|
|
104
|
+
annualLimit?: Money;
|
|
105
|
+
/** Maximum number of transactions per day */
|
|
106
|
+
dailyTransactionLimit?: number;
|
|
107
|
+
/** Maximum number of transactions per hour */
|
|
108
|
+
hourlyTransactionLimit?: number;
|
|
109
|
+
/** Cooling-off period between large transactions (minutes) */
|
|
110
|
+
coolingOffPeriod?: number;
|
|
111
|
+
/** Velocity check configuration */
|
|
112
|
+
velocityLimits?: {
|
|
113
|
+
/** Maximum amount in specified time window */
|
|
114
|
+
maxAmount: Money;
|
|
115
|
+
/** Time window in minutes */
|
|
116
|
+
timeWindowMinutes: number;
|
|
117
|
+
/** Number of transactions allowed in window */
|
|
118
|
+
maxTransactions: number;
|
|
119
|
+
};
|
|
120
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@plyaz/types",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.12.1",
|
|
4
4
|
"author": "Redeemer Pace",
|
|
5
5
|
"license": "ISC",
|
|
6
6
|
"description": "Provides shared TypeScript types and schema utilities for validation and parsing in the @playz ecosystem.",
|
|
@@ -165,6 +165,11 @@
|
|
|
165
165
|
"import": "./dist/web3/index.js",
|
|
166
166
|
"require": "./dist/web3/index.cjs"
|
|
167
167
|
},
|
|
168
|
+
"./payments": {
|
|
169
|
+
"types": "./dist/payments/index.d.ts",
|
|
170
|
+
"import": "./dist/payments/index.js",
|
|
171
|
+
"require": "./dist/payments/index.cjs"
|
|
172
|
+
},
|
|
168
173
|
"./package.json": "./package.json"
|
|
169
174
|
},
|
|
170
175
|
"files": [
|
|
@@ -1,67 +0,0 @@
|
|
|
1
|
-
import type { UserContext, AuthCredentials } from '../types';
|
|
2
|
-
/**
|
|
3
|
-
* @plyaz/auth/providers/base/auth-service-provider.interface
|
|
4
|
-
* The contract for all external authentication service adapters (Supabase, Internal DB, etc.).
|
|
5
|
-
* This ensures our strategies remain vendor-agnostic.
|
|
6
|
-
*/
|
|
7
|
-
export interface AuthServiceProvider {
|
|
8
|
-
/**
|
|
9
|
-
* Synchronizes an external user ID (e.g., from Clerk or Web3) with the internal RLS database.
|
|
10
|
-
* This method ensures the user exists internally and issues an RLS token.
|
|
11
|
-
* * @param externalId The unique ID from the external provider (e.g., Clerk's 'sub').
|
|
12
|
-
* @param email The user's primary email address.
|
|
13
|
-
* @returns An object containing the internal UserContext and the RLS JWT.
|
|
14
|
-
*/
|
|
15
|
-
syncUserFromExternalToken(externalId: string, email: string): Promise<{
|
|
16
|
-
user: UserContext;
|
|
17
|
-
supabaseRlsToken: string;
|
|
18
|
-
}>;
|
|
19
|
-
/** Handles traditional login via email/password (used as a fallback or if Clerk is bypassed). */
|
|
20
|
-
authenticate(credentials: AuthCredentials): Promise<UserContext>;
|
|
21
|
-
/** Registers a new user with the provider. */
|
|
22
|
-
register(credentials: AuthCredentials): Promise<UserContext>;
|
|
23
|
-
/** Retrieves basic user profile information by internal ID. */
|
|
24
|
-
getUserById(userId: string): Promise<UserContext | null>;
|
|
25
|
-
/** Requests a password reset (only relevant for traditional auth flows). */
|
|
26
|
-
requestPasswordReset(email: string): Promise<void>;
|
|
27
|
-
}
|
|
28
|
-
/**
|
|
29
|
-
* The contract for all external OAuth authentication providers (Google, GitHub, etc.).
|
|
30
|
-
* This interface ensures our strategies remain vendor-agnostic and defines
|
|
31
|
-
* the core functionality required to authenticate with an OAuth service.
|
|
32
|
-
*/
|
|
33
|
-
export interface OAuthProvider {
|
|
34
|
-
/**
|
|
35
|
-
* Generates the URL to redirect the user to for authentication.
|
|
36
|
-
* This URL will typically include a client ID, redirect URI, and scopes.
|
|
37
|
-
* @param redirectUrl The URL to which the user will be redirected after authentication.
|
|
38
|
-
* @returns The full URL for the OAuth login page.
|
|
39
|
-
*/
|
|
40
|
-
getRedirectUrl(redirectUrl: string): string;
|
|
41
|
-
/**
|
|
42
|
-
* Exchanges an authorization code for an access token and user information.
|
|
43
|
-
* This method is called after the user has successfully authenticated with the provider.
|
|
44
|
-
* @param code The authorization code received from the OAuth provider.
|
|
45
|
-
* @returns A promise that resolves to the user's details and a refresh token.
|
|
46
|
-
*/
|
|
47
|
-
exchangeCodeForToken(code: string): Promise<{
|
|
48
|
-
accessToken: string;
|
|
49
|
-
refreshToken: string;
|
|
50
|
-
expiresIn: number;
|
|
51
|
-
user: {
|
|
52
|
-
providerId: string;
|
|
53
|
-
email: string;
|
|
54
|
-
name?: string;
|
|
55
|
-
profileImageUrl?: string;
|
|
56
|
-
};
|
|
57
|
-
}>;
|
|
58
|
-
/**
|
|
59
|
-
* (Optional) Refreshes an access token using a refresh token.
|
|
60
|
-
* @param refreshToken The refresh token provided by the provider.
|
|
61
|
-
* @returns A new access token and its expiration time.
|
|
62
|
-
*/
|
|
63
|
-
refreshToken?(refreshToken: string): Promise<{
|
|
64
|
-
accessToken: string;
|
|
65
|
-
expiresIn: number;
|
|
66
|
-
}>;
|
|
67
|
-
}
|
|
File without changes
|