@plyaz/types 1.12.0 → 1.12.2
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 +7 -1
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +6 -1
- package/dist/index.js.map +1 -1
- package/dist/payments/events/emitter/types.d.ts +1 -0
- package/dist/payments/gateways/provider/types.d.ts +2 -2
- package/dist/payments/provider/adapter/types.d.ts +5 -4
- package/dist/payments/provider/core/types.d.ts +0 -81
- package/dist/payments/provider/payment-provider/types.d.ts +3 -2
- package/package.json +1 -1
- package/dist/auth/config/index.d.ts +0 -1
- package/dist/auth/config/types.d.ts +0 -67
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ProviderHealthStatus } from '../../../features';
|
|
2
2
|
import type { CURRENCY } from '../../currency';
|
|
3
|
-
import type {
|
|
3
|
+
import type { BaseProviderConfig } from '../../gateways';
|
|
4
|
+
import type { PaymentResult, ProcessPaymentRequest } from '../../request';
|
|
4
5
|
import type { FeeBreakdown, Money } from '../../transaction';
|
|
5
|
-
import type { AdapterConfiguration, CreateCustomerParams,
|
|
6
|
+
import type { AdapterConfiguration, CreateCustomerParams, CreateSubscriptionParams, CustomerResult, FeeCalculationOptions, FeeStructure, PaymentStatusResult, PayoutParams, PayoutResult, RefundParams, RefundResult, SavedPaymentMethod, SavedPaymentMethodResult, SavePaymentMethodParams, SubscriptionResult, TransactionDetails, TransactionHistory, TransactionHistoryParams, WebhookPayload, WebhookResult } from '../core';
|
|
6
7
|
import type { ProviderCapabilities, ProviderConfiguration } from '../payment-provider';
|
|
7
8
|
import type { PAYMENTMETHOD, PAYMENTPROVIDERTYPE } from '../provider-capability';
|
|
8
9
|
/**
|
|
@@ -41,7 +42,7 @@ export interface PaymentAdapter {
|
|
|
41
42
|
* @throws ProviderConfigurationError if configuration is invalid
|
|
42
43
|
* @throws ProviderConnectionError if unable to connect to provider
|
|
43
44
|
*/
|
|
44
|
-
initialize(config:
|
|
45
|
+
initialize(config: BaseProviderConfig): Promise<void>;
|
|
45
46
|
/**
|
|
46
47
|
* Shutdown the provider and clean up resources.
|
|
47
48
|
* This method should:
|
|
@@ -67,7 +68,7 @@ export interface PaymentAdapter {
|
|
|
67
68
|
* @throws PaymentValidationError for invalid parameters
|
|
68
69
|
* @throws PaymentProcessingError for provider errors
|
|
69
70
|
*/
|
|
70
|
-
createPayment(params:
|
|
71
|
+
createPayment(params: ProcessPaymentRequest): Promise<PaymentResult>;
|
|
71
72
|
/**
|
|
72
73
|
* Capture a previously authorized payment (if supported)
|
|
73
74
|
* Used in two-step payment flows
|
|
@@ -1,87 +1,6 @@
|
|
|
1
1
|
import type { CURRENCY } from '../../currency';
|
|
2
2
|
import type { FeeBreakdown, Money } from '../../transaction';
|
|
3
3
|
import type { PAYMENTMETHOD, PAYMENTPROVIDERTYPE, PAYMENTSTATUS } from '../provider-capability';
|
|
4
|
-
/**
|
|
5
|
-
* High-level configuration for initializing a payment provider.
|
|
6
|
-
*
|
|
7
|
-
* This configuration is passed to the provider adapter during initialization.
|
|
8
|
-
* It must contain everything required to:
|
|
9
|
-
* - Authenticate with the provider
|
|
10
|
-
* - Configure operational behavior
|
|
11
|
-
* - Enable webhook verification
|
|
12
|
-
* - Support different environments (sandbox, production, etc.)
|
|
13
|
-
*/
|
|
14
|
-
export interface PaymentProviderConfig<TExtra extends object = object, TCustomHeaders extends Record<string, string> = Record<string, string>> {
|
|
15
|
-
/** Provider type identifier (e.g., stripe, paypal) */
|
|
16
|
-
provider: PAYMENTPROVIDERTYPE;
|
|
17
|
-
/** Primary authentication */
|
|
18
|
-
apiKey?: string;
|
|
19
|
-
secretKey?: string;
|
|
20
|
-
/** For Stripe client-side integrations */
|
|
21
|
-
publishableKey?: string;
|
|
22
|
-
/** Optional merchant/account identifiers */
|
|
23
|
-
merchantId?: string;
|
|
24
|
-
accountId?: string;
|
|
25
|
-
/** Optional API version pinning */
|
|
26
|
-
apiVersion?: string;
|
|
27
|
-
/** Environment */
|
|
28
|
-
environment: 'sandbox' | 'staging' | 'production';
|
|
29
|
-
apiBaseUrl?: string;
|
|
30
|
-
/** Currency and region support */
|
|
31
|
-
supportedCurrencies?: CURRENCY[];
|
|
32
|
-
supportedRegions?: string[];
|
|
33
|
-
/** Webhook configuration */
|
|
34
|
-
webhook?: {
|
|
35
|
-
url: string;
|
|
36
|
-
secret?: string;
|
|
37
|
-
/** Support multiple webhook endpoints if needed */
|
|
38
|
-
secrets?: Record<string, string>;
|
|
39
|
-
events?: string[];
|
|
40
|
-
tolerance?: number;
|
|
41
|
-
};
|
|
42
|
-
/** Request config */
|
|
43
|
-
requestTimeout?: number;
|
|
44
|
-
retryPolicy?: {
|
|
45
|
-
maxRetries: number;
|
|
46
|
-
backoffMs: number;
|
|
47
|
-
};
|
|
48
|
-
/** Debug and advanced options */
|
|
49
|
-
debug?: boolean;
|
|
50
|
-
customHeaders?: TCustomHeaders;
|
|
51
|
-
extra?: TExtra;
|
|
52
|
-
/** Optional secondary credentials (e.g., key rotation) */
|
|
53
|
-
secondaryCredentials?: {
|
|
54
|
-
apiKey?: string;
|
|
55
|
-
secretKey?: string;
|
|
56
|
-
};
|
|
57
|
-
}
|
|
58
|
-
/**
|
|
59
|
-
* Core parameters for initiating a payment transaction with any provider.
|
|
60
|
-
* This type is **provider-agnostic** and later normalized/translated
|
|
61
|
-
* inside the provider adapter.
|
|
62
|
-
*/
|
|
63
|
-
export interface CreatePaymentParams<TMetadata extends object = object> {
|
|
64
|
-
/** Amount to be charged, always in smallest currency unit */
|
|
65
|
-
amount: Money;
|
|
66
|
-
/** Payment method selected for this transaction */
|
|
67
|
-
method: PAYMENTMETHOD;
|
|
68
|
-
/** Currency of the transaction */
|
|
69
|
-
currency: CURRENCY;
|
|
70
|
-
/** Unique identifier for the user initiating the transaction */
|
|
71
|
-
userId: string;
|
|
72
|
-
/** Product or service being paid for */
|
|
73
|
-
productId: string;
|
|
74
|
-
/** Description for statement or receipt */
|
|
75
|
-
description?: string;
|
|
76
|
-
/** URL to redirect user after successful payment */
|
|
77
|
-
returnUrl?: string;
|
|
78
|
-
/** URL to redirect user after failed/cancelled payment */
|
|
79
|
-
cancelUrl?: string;
|
|
80
|
-
/** Optional idempotency key to prevent duplicate charges */
|
|
81
|
-
idempotencyKey?: string;
|
|
82
|
-
/** Additional metadata (campaign, subscription, geo info, etc.) */
|
|
83
|
-
metadata?: TMetadata;
|
|
84
|
-
}
|
|
85
4
|
/**
|
|
86
5
|
* Parameters required to initiate a refund.
|
|
87
6
|
* Refunds can be full or partial.
|
|
@@ -1,8 +1,9 @@
|
|
|
1
1
|
import type { ProviderHealthStatus } from '../../../features';
|
|
2
2
|
import type { CURRENCY } from '../../currency';
|
|
3
|
+
import type { BaseProviderConfig } from '../../gateways';
|
|
3
4
|
import type { PaymentResult, ProcessPaymentRequest } from '../../request';
|
|
4
5
|
import type { FeeBreakdown, Money } from '../../transaction';
|
|
5
|
-
import type { CreateCustomerParams, CustomerResult, FeeCalculationOptions,
|
|
6
|
+
import type { CreateCustomerParams, CustomerResult, FeeCalculationOptions, PaymentStatusResult, RefundParams, RefundResult, SavedPaymentMethodResult, SavePaymentMethodParams, TransactionHistory, TransactionHistoryParams, WebhookPayload, WebhookResult } from '../core';
|
|
6
7
|
import type { PAYMENTMETHOD, PAYMENTPROVIDERTYPE } from '../provider-capability';
|
|
7
8
|
/**
|
|
8
9
|
* Core interface that all payment providers must implement.
|
|
@@ -38,7 +39,7 @@ export interface PaymentProvider {
|
|
|
38
39
|
* @throws ProviderConfigurationError if configuration is invalid
|
|
39
40
|
* @throws ProviderConnectionError if unable to connect to provider
|
|
40
41
|
*/
|
|
41
|
-
initialize(config:
|
|
42
|
+
initialize(config: BaseProviderConfig): Promise<void>;
|
|
42
43
|
/**
|
|
43
44
|
* Shutdown the provider and clean up resources.
|
|
44
45
|
* This method should:
|
package/package.json
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export type * from './types';
|
|
@@ -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
|
-
}
|