@sudobility/types 1.9.54 → 1.9.56
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 +44 -280
- package/dist/index.js +28 -201
- package/dist/index.js.map +1 -1
- package/dist/types/blockchain/common.js +9 -16
- package/dist/types/blockchain/common.js.map +1 -1
- package/dist/types/blockchain/index.js +3 -17
- package/dist/types/blockchain/index.js.map +1 -1
- package/dist/types/blockchain/validation.js +6 -12
- package/dist/types/blockchain/validation.js.map +1 -1
- package/dist/types/business/enums.js +46 -49
- package/dist/types/business/enums.js.map +1 -1
- package/dist/types/business/wallet-status.js +10 -16
- package/dist/types/business/wallet-status.js.map +1 -1
- package/dist/types/common.js +1 -2
- package/dist/types/common.js.map +1 -1
- package/dist/types/config/app-config.js +1 -2
- package/dist/types/config/app-config.js.map +1 -1
- package/dist/types/config/environment.js +2 -5
- package/dist/types/config/environment.js.map +1 -1
- package/dist/types/consumables/index.js +1 -2
- package/dist/types/consumables/index.js.map +1 -1
- package/dist/types/entity/entity.js +6 -9
- package/dist/types/entity/entity.js.map +1 -1
- package/dist/types/entity/permissions.js +12 -17
- package/dist/types/entity/permissions.js.map +1 -1
- package/dist/types/entity/requests.js +1 -2
- package/dist/types/entity/requests.js.map +1 -1
- package/dist/types/entity/responses.js +1 -2
- package/dist/types/entity/responses.js.map +1 -1
- package/dist/types/infrastructure/analytics.js +3 -7
- package/dist/types/infrastructure/analytics.js.map +1 -1
- package/dist/types/infrastructure/api.js +5 -9
- package/dist/types/infrastructure/api.js.map +1 -1
- package/dist/types/infrastructure/firebase-user.js +1 -2
- package/dist/types/infrastructure/firebase-user.js.map +1 -1
- package/dist/types/infrastructure/navigation.js +1 -2
- package/dist/types/infrastructure/network.js +1 -4
- package/dist/types/infrastructure/network.js.map +1 -1
- package/dist/types/infrastructure/wallet.js +2 -5
- package/dist/types/infrastructure/wallet.js.map +1 -1
- package/dist/types/subscription/entitlements.js +1 -4
- package/dist/types/subscription/entitlements.js.map +1 -1
- package/dist/types/subscription/period.js +2 -5
- package/dist/types/subscription/period.js.map +1 -1
- package/dist/types/subscription/rate-limits.js +2 -5
- package/dist/types/subscription/rate-limits.js.map +1 -1
- package/dist/utils/async-helpers.js +7 -16
- package/dist/utils/async-helpers.js.map +1 -1
- package/dist/utils/auth/admin-emails.js +3 -8
- package/dist/utils/auth/admin-emails.js.map +1 -1
- package/dist/utils/auth/auth.js +14 -24
- package/dist/utils/auth/auth.js.map +1 -1
- package/dist/utils/blockchain/address.js +20 -31
- package/dist/utils/blockchain/address.js.map +1 -1
- package/dist/utils/blockchain/event-helpers.js +9 -20
- package/dist/utils/blockchain/event-helpers.js.map +1 -1
- package/dist/utils/constants/application.js +2 -20
- package/dist/utils/constants/application.js.map +1 -1
- package/dist/utils/constants/status-values.js +1 -4
- package/dist/utils/constants/status-values.js.map +1 -1
- package/dist/utils/formatting/currency.js +6 -11
- package/dist/utils/formatting/currency.js.map +1 -1
- package/dist/utils/formatting/date.js +7 -16
- package/dist/utils/formatting/date.js.map +1 -1
- package/dist/utils/formatting/string.js +16 -34
- package/dist/utils/formatting/string.js.map +1 -1
- package/dist/utils/logging/logger.js +2 -10
- package/dist/utils/logging/logger.js.map +1 -1
- package/dist/utils/url/url-params.js +1 -6
- package/dist/utils/url/url-params.js.map +1 -1
- package/dist/utils/validation/type-validation.js +27 -48
- package/dist/utils/validation/type-validation.js.map +1 -1
- package/dist/utils/validation/web3-username-validator.js +6 -10
- package/dist/utils/validation/web3-username-validator.js.map +1 -1
- package/package.json +3 -11
- package/dist/index.cjs +0 -243
- package/dist/types/blockchain/common.cjs +0 -127
- package/dist/types/blockchain/index.cjs +0 -30
- package/dist/types/blockchain/validation.cjs +0 -144
- package/dist/types/business/enums.cjs +0 -367
- package/dist/types/business/wallet-status.cjs +0 -38
- package/dist/types/common.cjs +0 -12
- package/dist/types/config/app-config.cjs +0 -6
- package/dist/types/config/environment.cjs +0 -24
- package/dist/types/consumables/index.cjs +0 -8
- package/dist/types/entity/entity.cjs +0 -51
- package/dist/types/entity/permissions.cjs +0 -93
- package/dist/types/entity/requests.cjs +0 -7
- package/dist/types/entity/responses.cjs +0 -7
- package/dist/types/infrastructure/analytics.cjs +0 -212
- package/dist/types/infrastructure/api.cjs +0 -43
- package/dist/types/infrastructure/firebase-user.cjs +0 -10
- package/dist/types/infrastructure/navigation.cjs +0 -3
- package/dist/types/infrastructure/network.cjs +0 -18
- package/dist/types/infrastructure/wallet.cjs +0 -37
- package/dist/types/subscription/entitlements.cjs +0 -14
- package/dist/types/subscription/period.cjs +0 -29
- package/dist/types/subscription/rate-limits.cjs +0 -20
- package/dist/utils/async-helpers.cjs +0 -244
- package/dist/utils/auth/admin-emails.cjs +0 -79
- package/dist/utils/auth/auth.cjs +0 -99
- package/dist/utils/blockchain/address.cjs +0 -225
- package/dist/utils/blockchain/event-helpers.cjs +0 -143
- package/dist/utils/constants/application.cjs +0 -152
- package/dist/utils/constants/status-values.cjs +0 -14
- package/dist/utils/formatting/currency.cjs +0 -39
- package/dist/utils/formatting/date.cjs +0 -197
- package/dist/utils/formatting/string.cjs +0 -326
- package/dist/utils/logging/logger.cjs +0 -92
- package/dist/utils/url/url-params.cjs +0 -128
- package/dist/utils/validation/type-validation.cjs +0 -250
- package/dist/utils/validation/web3-username-validator.cjs +0 -132
package/dist/index.cjs
DELETED
|
@@ -1,243 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @johnqh/types - Common TypeScript types for Web3 email projects
|
|
4
|
-
*
|
|
5
|
-
* This package contains all shared TypeScript definitions used across
|
|
6
|
-
* Web3 email applications including business logic types, blockchain
|
|
7
|
-
* types, configuration interfaces, infrastructure types, and utility functions.
|
|
8
|
-
*
|
|
9
|
-
* @version 1.0.0
|
|
10
|
-
* @license MIT
|
|
11
|
-
*/
|
|
12
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
13
|
-
exports.EntityRole = exports.EntityType = exports.NONE_ENTITLEMENT = exports.ALL_PERIODS = exports.PERIOD_RANKS = exports.RateLimitPeriodType = exports.WalletType = exports.NetworkError = exports.ProcessedEventName = exports.ContractType = exports.AnalyticsEventBuilder = exports.AnalyticsEvent = exports.StorageType = exports.validateMessage = exports.validateDomain = exports.validateAmount = exports.validateAddress = exports.isSolanaRecipient = exports.isSolanaAddress = exports.isEvmRecipient = exports.isEvmAddress = exports.TransactionStatus = exports.PROTOCOL_CONSTANTS = exports.MessageType = exports.isWalletVerified = exports.isWalletConnected = exports.getWalletConnectionState = exports.Theme = exports.SubscriptionAction = exports.SortOrder = exports.RequestStatus = exports.PlatformType = exports.NotificationType = exports.MobileView = exports.MediumView = exports.InfoType = exports.FontSize = exports.FeatureFlag = exports.ErrorType = exports.EmailValidationState = exports.EmailSortCriteria = exports.EmailComposeType = exports.EmailAddressType = exports.EmailAction = exports.Currency = exports.ConnectionType = exports.ConnectionState = exports.ChainType = exports.Chain = exports.AuthStatus = void 0;
|
|
14
|
-
exports.isAuthStatusConnected = exports.isAuthExpired = exports.getAuthStatusText = exports.generateNonce = exports.generateAuthMessage = exports.extractNonceFromMessage = exports.canAccessProtectedFeatures = exports.validateEventArgs = exports.normalizeAddress = exports.isZeroAddress = exports.isTestNet = exports.formatBigInt = exports.createUserMultiChainId = exports.createMultiChainId = exports.createDelegationId = exports.createChainStatsId = exports.parseEmailAddress = exports.isValidWalletAddress = exports.isValidSignature = exports.isSNSName = exports.isENSName = exports.getChainDisplayName = exports.getAddressType = exports.formatWalletAddress = exports.AddressType = exports.validateArray = exports.parseJson = exports.optional = exports.isValidDate = exports.isUrl = exports.isSuccessResponse = exports.isString = exports.isObject = exports.isNumber = exports.isNullish = exports.isErrorResponse = exports.isEmail = exports.isBoolean = exports.isArray = exports.isApiResponse = exports.hasRequiredProperties = exports.createValidator = exports.createAssertion = exports.Web3UsernameValidator = exports.hasPermission = exports.getPermissionsForRole = exports.MEMBER_PERMISSIONS = exports.MANAGER_PERMISSIONS = exports.OWNER_PERMISSIONS = exports.InvitationStatus = void 0;
|
|
15
|
-
exports.LogLevel = exports.STATUS_VALUES = exports.Z_INDEX = exports.ANIMATION = exports.NETWORK_IDS = exports.WALLET_NAMES = exports.CONTACT_INFO = exports.ROUTES = exports.SUCCESS_MESSAGES = exports.ERROR_MESSAGES = exports.TIME_FORMAT = exports.SUBSCRIPTION_TIERS = exports.EMAIL_CONFIG = exports.STORAGE_KEYS = exports.CHAIN_TYPE = exports.AUTH_STATUS = exports.API_RETRY_DELAY = exports.API_RETRY_ATTEMPTS = exports.API_TIMEOUT = exports.truncate = exports.toTitleCase = exports.toSnakeCase = exports.toKebabCase = exports.toCamelCase = exports.stripHtml = exports.randomString = exports.pluralize = exports.normalizeWhitespace = exports.isNotBlank = exports.isBlank = exports.getInitials = exports.formatNumber = exports.formatBytes = exports.escapeHtml = exports.capitalize = exports.parseDate = exports.isDateInRange = exports.formatTimestamp = exports.formatRelativeTime = exports.formatEmailDate = exports.addHours = exports.addDays = exports.parseUSDC = exports.formatUSDC = exports.USDC_DECIMALS = exports.CLAIM_PERIOD_DAYS = exports.createAdminChecker = exports.isAdminEmail = exports.parseAdminEmails = exports.isValidNonce = void 0;
|
|
16
|
-
exports.debounceAsync = exports.clearExpiredCache = exports.withCache = exports.withTimeout = exports.safeParallel = exports.withLoadingState = exports.safeAsync = exports.parseSearchParams = exports.searchParamsToString = exports.createSearchParams = exports.createURLSearchParams = exports.storageLogger = exports.ensLogger = exports.contractLogger = exports.apiLogger = exports.authLogger = exports.logger = void 0;
|
|
17
|
-
// ============================================================================
|
|
18
|
-
// TYPES - Business
|
|
19
|
-
// ============================================================================
|
|
20
|
-
// Enums
|
|
21
|
-
var enums_1 = require("./types/business/enums");
|
|
22
|
-
Object.defineProperty(exports, "AuthStatus", { enumerable: true, get: function () { return enums_1.AuthStatus; } });
|
|
23
|
-
Object.defineProperty(exports, "Chain", { enumerable: true, get: function () { return enums_1.Chain; } });
|
|
24
|
-
Object.defineProperty(exports, "ChainType", { enumerable: true, get: function () { return enums_1.ChainType; } });
|
|
25
|
-
Object.defineProperty(exports, "ConnectionState", { enumerable: true, get: function () { return enums_1.ConnectionState; } });
|
|
26
|
-
Object.defineProperty(exports, "ConnectionType", { enumerable: true, get: function () { return enums_1.ConnectionType; } });
|
|
27
|
-
Object.defineProperty(exports, "Currency", { enumerable: true, get: function () { return enums_1.Currency; } });
|
|
28
|
-
Object.defineProperty(exports, "EmailAction", { enumerable: true, get: function () { return enums_1.EmailAction; } });
|
|
29
|
-
Object.defineProperty(exports, "EmailAddressType", { enumerable: true, get: function () { return enums_1.EmailAddressType; } });
|
|
30
|
-
Object.defineProperty(exports, "EmailComposeType", { enumerable: true, get: function () { return enums_1.EmailComposeType; } });
|
|
31
|
-
Object.defineProperty(exports, "EmailSortCriteria", { enumerable: true, get: function () { return enums_1.EmailSortCriteria; } });
|
|
32
|
-
Object.defineProperty(exports, "EmailValidationState", { enumerable: true, get: function () { return enums_1.EmailValidationState; } });
|
|
33
|
-
Object.defineProperty(exports, "ErrorType", { enumerable: true, get: function () { return enums_1.ErrorType; } });
|
|
34
|
-
Object.defineProperty(exports, "FeatureFlag", { enumerable: true, get: function () { return enums_1.FeatureFlag; } });
|
|
35
|
-
Object.defineProperty(exports, "FontSize", { enumerable: true, get: function () { return enums_1.FontSize; } });
|
|
36
|
-
Object.defineProperty(exports, "InfoType", { enumerable: true, get: function () { return enums_1.InfoType; } });
|
|
37
|
-
Object.defineProperty(exports, "MediumView", { enumerable: true, get: function () { return enums_1.MediumView; } });
|
|
38
|
-
Object.defineProperty(exports, "MobileView", { enumerable: true, get: function () { return enums_1.MobileView; } });
|
|
39
|
-
Object.defineProperty(exports, "NotificationType", { enumerable: true, get: function () { return enums_1.NotificationType; } });
|
|
40
|
-
Object.defineProperty(exports, "PlatformType", { enumerable: true, get: function () { return enums_1.PlatformType; } });
|
|
41
|
-
Object.defineProperty(exports, "RequestStatus", { enumerable: true, get: function () { return enums_1.RequestStatus; } });
|
|
42
|
-
Object.defineProperty(exports, "SortOrder", { enumerable: true, get: function () { return enums_1.SortOrder; } });
|
|
43
|
-
Object.defineProperty(exports, "SubscriptionAction", { enumerable: true, get: function () { return enums_1.SubscriptionAction; } });
|
|
44
|
-
Object.defineProperty(exports, "Theme", { enumerable: true, get: function () { return enums_1.Theme; } });
|
|
45
|
-
var wallet_status_1 = require("./types/business/wallet-status");
|
|
46
|
-
Object.defineProperty(exports, "getWalletConnectionState", { enumerable: true, get: function () { return wallet_status_1.getWalletConnectionState; } });
|
|
47
|
-
Object.defineProperty(exports, "isWalletConnected", { enumerable: true, get: function () { return wallet_status_1.isWalletConnected; } });
|
|
48
|
-
Object.defineProperty(exports, "isWalletVerified", { enumerable: true, get: function () { return wallet_status_1.isWalletVerified; } });
|
|
49
|
-
var common_1 = require("./types/blockchain/common");
|
|
50
|
-
Object.defineProperty(exports, "MessageType", { enumerable: true, get: function () { return common_1.MessageType; } });
|
|
51
|
-
Object.defineProperty(exports, "PROTOCOL_CONSTANTS", { enumerable: true, get: function () { return common_1.PROTOCOL_CONSTANTS; } });
|
|
52
|
-
Object.defineProperty(exports, "TransactionStatus", { enumerable: true, get: function () { return common_1.TransactionStatus; } });
|
|
53
|
-
Object.defineProperty(exports, "isEvmAddress", { enumerable: true, get: function () { return common_1.isEvmAddress; } });
|
|
54
|
-
Object.defineProperty(exports, "isEvmRecipient", { enumerable: true, get: function () { return common_1.isEvmRecipient; } });
|
|
55
|
-
Object.defineProperty(exports, "isSolanaAddress", { enumerable: true, get: function () { return common_1.isSolanaAddress; } });
|
|
56
|
-
Object.defineProperty(exports, "isSolanaRecipient", { enumerable: true, get: function () { return common_1.isSolanaRecipient; } });
|
|
57
|
-
var validation_1 = require("./types/blockchain/validation");
|
|
58
|
-
Object.defineProperty(exports, "validateAddress", { enumerable: true, get: function () { return validation_1.validateAddress; } });
|
|
59
|
-
Object.defineProperty(exports, "validateAmount", { enumerable: true, get: function () { return validation_1.validateAmount; } });
|
|
60
|
-
Object.defineProperty(exports, "validateDomain", { enumerable: true, get: function () { return validation_1.validateDomain; } });
|
|
61
|
-
Object.defineProperty(exports, "validateMessage", { enumerable: true, get: function () { return validation_1.validateMessage; } });
|
|
62
|
-
var environment_1 = require("./types/config/environment");
|
|
63
|
-
Object.defineProperty(exports, "StorageType", { enumerable: true, get: function () { return environment_1.StorageType; } });
|
|
64
|
-
var analytics_1 = require("./types/infrastructure/analytics");
|
|
65
|
-
Object.defineProperty(exports, "AnalyticsEvent", { enumerable: true, get: function () { return analytics_1.AnalyticsEvent; } });
|
|
66
|
-
Object.defineProperty(exports, "AnalyticsEventBuilder", { enumerable: true, get: function () { return analytics_1.AnalyticsEventBuilder; } });
|
|
67
|
-
var api_1 = require("./types/infrastructure/api");
|
|
68
|
-
Object.defineProperty(exports, "ContractType", { enumerable: true, get: function () { return api_1.ContractType; } });
|
|
69
|
-
Object.defineProperty(exports, "ProcessedEventName", { enumerable: true, get: function () { return api_1.ProcessedEventName; } });
|
|
70
|
-
var network_1 = require("./types/infrastructure/network");
|
|
71
|
-
Object.defineProperty(exports, "NetworkError", { enumerable: true, get: function () { return network_1.NetworkError; } });
|
|
72
|
-
// Wallet
|
|
73
|
-
var wallet_1 = require("./types/infrastructure/wallet");
|
|
74
|
-
Object.defineProperty(exports, "WalletType", { enumerable: true, get: function () { return wallet_1.WalletType; } });
|
|
75
|
-
var rate_limits_1 = require("./types/subscription/rate-limits");
|
|
76
|
-
Object.defineProperty(exports, "RateLimitPeriodType", { enumerable: true, get: function () { return rate_limits_1.RateLimitPeriodType; } });
|
|
77
|
-
var period_1 = require("./types/subscription/period");
|
|
78
|
-
Object.defineProperty(exports, "PERIOD_RANKS", { enumerable: true, get: function () { return period_1.PERIOD_RANKS; } });
|
|
79
|
-
Object.defineProperty(exports, "ALL_PERIODS", { enumerable: true, get: function () { return period_1.ALL_PERIODS; } });
|
|
80
|
-
// Entitlements
|
|
81
|
-
var entitlements_1 = require("./types/subscription/entitlements");
|
|
82
|
-
Object.defineProperty(exports, "NONE_ENTITLEMENT", { enumerable: true, get: function () { return entitlements_1.NONE_ENTITLEMENT; } });
|
|
83
|
-
// ============================================================================
|
|
84
|
-
// TYPES - Entity
|
|
85
|
-
// ============================================================================
|
|
86
|
-
// Core entity types
|
|
87
|
-
var entity_1 = require("./types/entity/entity");
|
|
88
|
-
Object.defineProperty(exports, "EntityType", { enumerable: true, get: function () { return entity_1.EntityType; } });
|
|
89
|
-
Object.defineProperty(exports, "EntityRole", { enumerable: true, get: function () { return entity_1.EntityRole; } });
|
|
90
|
-
Object.defineProperty(exports, "InvitationStatus", { enumerable: true, get: function () { return entity_1.InvitationStatus; } });
|
|
91
|
-
var permissions_1 = require("./types/entity/permissions");
|
|
92
|
-
Object.defineProperty(exports, "OWNER_PERMISSIONS", { enumerable: true, get: function () { return permissions_1.OWNER_PERMISSIONS; } });
|
|
93
|
-
Object.defineProperty(exports, "MANAGER_PERMISSIONS", { enumerable: true, get: function () { return permissions_1.MANAGER_PERMISSIONS; } });
|
|
94
|
-
Object.defineProperty(exports, "MEMBER_PERMISSIONS", { enumerable: true, get: function () { return permissions_1.MEMBER_PERMISSIONS; } });
|
|
95
|
-
Object.defineProperty(exports, "getPermissionsForRole", { enumerable: true, get: function () { return permissions_1.getPermissionsForRole; } });
|
|
96
|
-
Object.defineProperty(exports, "hasPermission", { enumerable: true, get: function () { return permissions_1.hasPermission; } });
|
|
97
|
-
var web3_username_validator_1 = require("./utils/validation/web3-username-validator");
|
|
98
|
-
Object.defineProperty(exports, "Web3UsernameValidator", { enumerable: true, get: function () { return web3_username_validator_1.Web3UsernameValidator; } });
|
|
99
|
-
var type_validation_1 = require("./utils/validation/type-validation");
|
|
100
|
-
Object.defineProperty(exports, "createAssertion", { enumerable: true, get: function () { return type_validation_1.createAssertion; } });
|
|
101
|
-
Object.defineProperty(exports, "createValidator", { enumerable: true, get: function () { return type_validation_1.createValidator; } });
|
|
102
|
-
Object.defineProperty(exports, "hasRequiredProperties", { enumerable: true, get: function () { return type_validation_1.hasRequiredProperties; } });
|
|
103
|
-
Object.defineProperty(exports, "isApiResponse", { enumerable: true, get: function () { return type_validation_1.isApiResponse; } });
|
|
104
|
-
Object.defineProperty(exports, "isArray", { enumerable: true, get: function () { return type_validation_1.isArray; } });
|
|
105
|
-
Object.defineProperty(exports, "isBoolean", { enumerable: true, get: function () { return type_validation_1.isBoolean; } });
|
|
106
|
-
Object.defineProperty(exports, "isEmail", { enumerable: true, get: function () { return type_validation_1.isEmail; } });
|
|
107
|
-
Object.defineProperty(exports, "isErrorResponse", { enumerable: true, get: function () { return type_validation_1.isErrorResponse; } });
|
|
108
|
-
Object.defineProperty(exports, "isNullish", { enumerable: true, get: function () { return type_validation_1.isNullish; } });
|
|
109
|
-
Object.defineProperty(exports, "isNumber", { enumerable: true, get: function () { return type_validation_1.isNumber; } });
|
|
110
|
-
Object.defineProperty(exports, "isObject", { enumerable: true, get: function () { return type_validation_1.isObject; } });
|
|
111
|
-
Object.defineProperty(exports, "isString", { enumerable: true, get: function () { return type_validation_1.isString; } });
|
|
112
|
-
Object.defineProperty(exports, "isSuccessResponse", { enumerable: true, get: function () { return type_validation_1.isSuccessResponse; } });
|
|
113
|
-
Object.defineProperty(exports, "isUrl", { enumerable: true, get: function () { return type_validation_1.isUrl; } });
|
|
114
|
-
Object.defineProperty(exports, "isValidDate", { enumerable: true, get: function () { return type_validation_1.isValidDate; } });
|
|
115
|
-
Object.defineProperty(exports, "optional", { enumerable: true, get: function () { return type_validation_1.optional; } });
|
|
116
|
-
Object.defineProperty(exports, "parseJson", { enumerable: true, get: function () { return type_validation_1.parseJson; } });
|
|
117
|
-
Object.defineProperty(exports, "validateArray", { enumerable: true, get: function () { return type_validation_1.validateArray; } });
|
|
118
|
-
var address_1 = require("./utils/blockchain/address");
|
|
119
|
-
Object.defineProperty(exports, "AddressType", { enumerable: true, get: function () { return address_1.AddressType; } });
|
|
120
|
-
Object.defineProperty(exports, "formatWalletAddress", { enumerable: true, get: function () { return address_1.formatWalletAddress; } });
|
|
121
|
-
Object.defineProperty(exports, "getAddressType", { enumerable: true, get: function () { return address_1.getAddressType; } });
|
|
122
|
-
Object.defineProperty(exports, "getChainDisplayName", { enumerable: true, get: function () { return address_1.getChainDisplayName; } });
|
|
123
|
-
Object.defineProperty(exports, "isENSName", { enumerable: true, get: function () { return address_1.isENSName; } });
|
|
124
|
-
Object.defineProperty(exports, "isSNSName", { enumerable: true, get: function () { return address_1.isSNSName; } });
|
|
125
|
-
Object.defineProperty(exports, "isValidSignature", { enumerable: true, get: function () { return address_1.isValidSignature; } });
|
|
126
|
-
Object.defineProperty(exports, "isValidWalletAddress", { enumerable: true, get: function () { return address_1.isValidWalletAddress; } });
|
|
127
|
-
Object.defineProperty(exports, "parseEmailAddress", { enumerable: true, get: function () { return address_1.parseEmailAddress; } });
|
|
128
|
-
var event_helpers_1 = require("./utils/blockchain/event-helpers");
|
|
129
|
-
Object.defineProperty(exports, "createChainStatsId", { enumerable: true, get: function () { return event_helpers_1.createChainStatsId; } });
|
|
130
|
-
Object.defineProperty(exports, "createDelegationId", { enumerable: true, get: function () { return event_helpers_1.createDelegationId; } });
|
|
131
|
-
Object.defineProperty(exports, "createMultiChainId", { enumerable: true, get: function () { return event_helpers_1.createMultiChainId; } });
|
|
132
|
-
Object.defineProperty(exports, "createUserMultiChainId", { enumerable: true, get: function () { return event_helpers_1.createUserMultiChainId; } });
|
|
133
|
-
Object.defineProperty(exports, "formatBigInt", { enumerable: true, get: function () { return event_helpers_1.formatBigInt; } });
|
|
134
|
-
Object.defineProperty(exports, "isTestNet", { enumerable: true, get: function () { return event_helpers_1.isTestNet; } });
|
|
135
|
-
Object.defineProperty(exports, "isZeroAddress", { enumerable: true, get: function () { return event_helpers_1.isZeroAddress; } });
|
|
136
|
-
Object.defineProperty(exports, "normalizeAddress", { enumerable: true, get: function () { return event_helpers_1.normalizeAddress; } });
|
|
137
|
-
Object.defineProperty(exports, "validateEventArgs", { enumerable: true, get: function () { return event_helpers_1.validateEventArgs; } });
|
|
138
|
-
// ============================================================================
|
|
139
|
-
// UTILS - Auth
|
|
140
|
-
// ============================================================================
|
|
141
|
-
var auth_1 = require("./utils/auth/auth");
|
|
142
|
-
Object.defineProperty(exports, "canAccessProtectedFeatures", { enumerable: true, get: function () { return auth_1.canAccessProtectedFeatures; } });
|
|
143
|
-
Object.defineProperty(exports, "extractNonceFromMessage", { enumerable: true, get: function () { return auth_1.extractNonceFromMessage; } });
|
|
144
|
-
Object.defineProperty(exports, "generateAuthMessage", { enumerable: true, get: function () { return auth_1.generateAuthMessage; } });
|
|
145
|
-
Object.defineProperty(exports, "generateNonce", { enumerable: true, get: function () { return auth_1.generateNonce; } });
|
|
146
|
-
Object.defineProperty(exports, "getAuthStatusText", { enumerable: true, get: function () { return auth_1.getAuthStatusText; } });
|
|
147
|
-
Object.defineProperty(exports, "isAuthExpired", { enumerable: true, get: function () { return auth_1.isAuthExpired; } });
|
|
148
|
-
Object.defineProperty(exports, "isAuthStatusConnected", { enumerable: true, get: function () { return auth_1.isAuthStatusConnected; } });
|
|
149
|
-
Object.defineProperty(exports, "isValidNonce", { enumerable: true, get: function () { return auth_1.isValidNonce; } });
|
|
150
|
-
var admin_emails_1 = require("./utils/auth/admin-emails");
|
|
151
|
-
Object.defineProperty(exports, "parseAdminEmails", { enumerable: true, get: function () { return admin_emails_1.parseAdminEmails; } });
|
|
152
|
-
Object.defineProperty(exports, "isAdminEmail", { enumerable: true, get: function () { return admin_emails_1.isAdminEmail; } });
|
|
153
|
-
Object.defineProperty(exports, "createAdminChecker", { enumerable: true, get: function () { return admin_emails_1.createAdminChecker; } });
|
|
154
|
-
// ============================================================================
|
|
155
|
-
// UTILS - Formatting
|
|
156
|
-
// ============================================================================
|
|
157
|
-
// Currency
|
|
158
|
-
var currency_1 = require("./utils/formatting/currency");
|
|
159
|
-
Object.defineProperty(exports, "CLAIM_PERIOD_DAYS", { enumerable: true, get: function () { return currency_1.CLAIM_PERIOD_DAYS; } });
|
|
160
|
-
Object.defineProperty(exports, "USDC_DECIMALS", { enumerable: true, get: function () { return currency_1.USDC_DECIMALS; } });
|
|
161
|
-
Object.defineProperty(exports, "formatUSDC", { enumerable: true, get: function () { return currency_1.formatUSDC; } });
|
|
162
|
-
Object.defineProperty(exports, "parseUSDC", { enumerable: true, get: function () { return currency_1.parseUSDC; } });
|
|
163
|
-
// Date
|
|
164
|
-
var date_1 = require("./utils/formatting/date");
|
|
165
|
-
Object.defineProperty(exports, "addDays", { enumerable: true, get: function () { return date_1.addDays; } });
|
|
166
|
-
Object.defineProperty(exports, "addHours", { enumerable: true, get: function () { return date_1.addHours; } });
|
|
167
|
-
Object.defineProperty(exports, "formatEmailDate", { enumerable: true, get: function () { return date_1.formatEmailDate; } });
|
|
168
|
-
Object.defineProperty(exports, "formatRelativeTime", { enumerable: true, get: function () { return date_1.formatRelativeTime; } });
|
|
169
|
-
Object.defineProperty(exports, "formatTimestamp", { enumerable: true, get: function () { return date_1.formatTimestamp; } });
|
|
170
|
-
Object.defineProperty(exports, "isDateInRange", { enumerable: true, get: function () { return date_1.isDateInRange; } });
|
|
171
|
-
Object.defineProperty(exports, "parseDate", { enumerable: true, get: function () { return date_1.parseDate; } });
|
|
172
|
-
// String
|
|
173
|
-
var string_1 = require("./utils/formatting/string");
|
|
174
|
-
Object.defineProperty(exports, "capitalize", { enumerable: true, get: function () { return string_1.capitalize; } });
|
|
175
|
-
Object.defineProperty(exports, "escapeHtml", { enumerable: true, get: function () { return string_1.escapeHtml; } });
|
|
176
|
-
Object.defineProperty(exports, "formatBytes", { enumerable: true, get: function () { return string_1.formatBytes; } });
|
|
177
|
-
Object.defineProperty(exports, "formatNumber", { enumerable: true, get: function () { return string_1.formatNumber; } });
|
|
178
|
-
Object.defineProperty(exports, "getInitials", { enumerable: true, get: function () { return string_1.getInitials; } });
|
|
179
|
-
Object.defineProperty(exports, "isBlank", { enumerable: true, get: function () { return string_1.isBlank; } });
|
|
180
|
-
Object.defineProperty(exports, "isNotBlank", { enumerable: true, get: function () { return string_1.isNotBlank; } });
|
|
181
|
-
Object.defineProperty(exports, "normalizeWhitespace", { enumerable: true, get: function () { return string_1.normalizeWhitespace; } });
|
|
182
|
-
Object.defineProperty(exports, "pluralize", { enumerable: true, get: function () { return string_1.pluralize; } });
|
|
183
|
-
Object.defineProperty(exports, "randomString", { enumerable: true, get: function () { return string_1.randomString; } });
|
|
184
|
-
Object.defineProperty(exports, "stripHtml", { enumerable: true, get: function () { return string_1.stripHtml; } });
|
|
185
|
-
Object.defineProperty(exports, "toCamelCase", { enumerable: true, get: function () { return string_1.toCamelCase; } });
|
|
186
|
-
Object.defineProperty(exports, "toKebabCase", { enumerable: true, get: function () { return string_1.toKebabCase; } });
|
|
187
|
-
Object.defineProperty(exports, "toSnakeCase", { enumerable: true, get: function () { return string_1.toSnakeCase; } });
|
|
188
|
-
Object.defineProperty(exports, "toTitleCase", { enumerable: true, get: function () { return string_1.toTitleCase; } });
|
|
189
|
-
Object.defineProperty(exports, "truncate", { enumerable: true, get: function () { return string_1.truncate; } });
|
|
190
|
-
// ============================================================================
|
|
191
|
-
// UTILS - Constants
|
|
192
|
-
// ============================================================================
|
|
193
|
-
var application_1 = require("./utils/constants/application");
|
|
194
|
-
Object.defineProperty(exports, "API_TIMEOUT", { enumerable: true, get: function () { return application_1.API_TIMEOUT; } });
|
|
195
|
-
Object.defineProperty(exports, "API_RETRY_ATTEMPTS", { enumerable: true, get: function () { return application_1.API_RETRY_ATTEMPTS; } });
|
|
196
|
-
Object.defineProperty(exports, "API_RETRY_DELAY", { enumerable: true, get: function () { return application_1.API_RETRY_DELAY; } });
|
|
197
|
-
Object.defineProperty(exports, "AUTH_STATUS", { enumerable: true, get: function () { return application_1.AUTH_STATUS; } });
|
|
198
|
-
Object.defineProperty(exports, "CHAIN_TYPE", { enumerable: true, get: function () { return application_1.CHAIN_TYPE; } });
|
|
199
|
-
Object.defineProperty(exports, "STORAGE_KEYS", { enumerable: true, get: function () { return application_1.STORAGE_KEYS; } });
|
|
200
|
-
Object.defineProperty(exports, "EMAIL_CONFIG", { enumerable: true, get: function () { return application_1.EMAIL_CONFIG; } });
|
|
201
|
-
Object.defineProperty(exports, "SUBSCRIPTION_TIERS", { enumerable: true, get: function () { return application_1.SUBSCRIPTION_TIERS; } });
|
|
202
|
-
Object.defineProperty(exports, "TIME_FORMAT", { enumerable: true, get: function () { return application_1.TIME_FORMAT; } });
|
|
203
|
-
Object.defineProperty(exports, "ERROR_MESSAGES", { enumerable: true, get: function () { return application_1.ERROR_MESSAGES; } });
|
|
204
|
-
Object.defineProperty(exports, "SUCCESS_MESSAGES", { enumerable: true, get: function () { return application_1.SUCCESS_MESSAGES; } });
|
|
205
|
-
Object.defineProperty(exports, "ROUTES", { enumerable: true, get: function () { return application_1.ROUTES; } });
|
|
206
|
-
Object.defineProperty(exports, "CONTACT_INFO", { enumerable: true, get: function () { return application_1.CONTACT_INFO; } });
|
|
207
|
-
Object.defineProperty(exports, "WALLET_NAMES", { enumerable: true, get: function () { return application_1.WALLET_NAMES; } });
|
|
208
|
-
Object.defineProperty(exports, "NETWORK_IDS", { enumerable: true, get: function () { return application_1.NETWORK_IDS; } });
|
|
209
|
-
Object.defineProperty(exports, "ANIMATION", { enumerable: true, get: function () { return application_1.ANIMATION; } });
|
|
210
|
-
Object.defineProperty(exports, "Z_INDEX", { enumerable: true, get: function () { return application_1.Z_INDEX; } });
|
|
211
|
-
var status_values_1 = require("./utils/constants/status-values");
|
|
212
|
-
Object.defineProperty(exports, "STATUS_VALUES", { enumerable: true, get: function () { return status_values_1.STATUS_VALUES; } });
|
|
213
|
-
// ============================================================================
|
|
214
|
-
// UTILS - Logging
|
|
215
|
-
// ============================================================================
|
|
216
|
-
var logger_1 = require("./utils/logging/logger");
|
|
217
|
-
Object.defineProperty(exports, "LogLevel", { enumerable: true, get: function () { return logger_1.LogLevel; } });
|
|
218
|
-
Object.defineProperty(exports, "logger", { enumerable: true, get: function () { return logger_1.logger; } });
|
|
219
|
-
Object.defineProperty(exports, "authLogger", { enumerable: true, get: function () { return logger_1.authLogger; } });
|
|
220
|
-
Object.defineProperty(exports, "apiLogger", { enumerable: true, get: function () { return logger_1.apiLogger; } });
|
|
221
|
-
Object.defineProperty(exports, "contractLogger", { enumerable: true, get: function () { return logger_1.contractLogger; } });
|
|
222
|
-
Object.defineProperty(exports, "ensLogger", { enumerable: true, get: function () { return logger_1.ensLogger; } });
|
|
223
|
-
Object.defineProperty(exports, "storageLogger", { enumerable: true, get: function () { return logger_1.storageLogger; } });
|
|
224
|
-
// ============================================================================
|
|
225
|
-
// UTILS - URL
|
|
226
|
-
// ============================================================================
|
|
227
|
-
var url_params_1 = require("./utils/url/url-params");
|
|
228
|
-
Object.defineProperty(exports, "createURLSearchParams", { enumerable: true, get: function () { return url_params_1.createURLSearchParams; } });
|
|
229
|
-
Object.defineProperty(exports, "createSearchParams", { enumerable: true, get: function () { return url_params_1.createSearchParams; } });
|
|
230
|
-
Object.defineProperty(exports, "searchParamsToString", { enumerable: true, get: function () { return url_params_1.searchParamsToString; } });
|
|
231
|
-
Object.defineProperty(exports, "parseSearchParams", { enumerable: true, get: function () { return url_params_1.parseSearchParams; } });
|
|
232
|
-
// ============================================================================
|
|
233
|
-
// UTILS - Async Helpers
|
|
234
|
-
// ============================================================================
|
|
235
|
-
var async_helpers_1 = require("./utils/async-helpers");
|
|
236
|
-
Object.defineProperty(exports, "safeAsync", { enumerable: true, get: function () { return async_helpers_1.safeAsync; } });
|
|
237
|
-
Object.defineProperty(exports, "withLoadingState", { enumerable: true, get: function () { return async_helpers_1.withLoadingState; } });
|
|
238
|
-
Object.defineProperty(exports, "safeParallel", { enumerable: true, get: function () { return async_helpers_1.safeParallel; } });
|
|
239
|
-
Object.defineProperty(exports, "withTimeout", { enumerable: true, get: function () { return async_helpers_1.withTimeout; } });
|
|
240
|
-
Object.defineProperty(exports, "withCache", { enumerable: true, get: function () { return async_helpers_1.withCache; } });
|
|
241
|
-
Object.defineProperty(exports, "clearExpiredCache", { enumerable: true, get: function () { return async_helpers_1.clearExpiredCache; } });
|
|
242
|
-
Object.defineProperty(exports, "debounceAsync", { enumerable: true, get: function () { return async_helpers_1.debounceAsync; } });
|
|
243
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,127 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Common type definitions for multi-chain MailBox system
|
|
4
|
-
* @description Shared types and interfaces for EVM and Solana implementations
|
|
5
|
-
* @author MailBox Team
|
|
6
|
-
* @version 1.4.2
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.PROTOCOL_CONSTANTS = exports.TransactionStatus = exports.MessageType = void 0;
|
|
10
|
-
exports.isSolanaAddress = isSolanaAddress;
|
|
11
|
-
exports.isEvmAddress = isEvmAddress;
|
|
12
|
-
exports.isSolanaRecipient = isSolanaRecipient;
|
|
13
|
-
exports.isEvmRecipient = isEvmRecipient;
|
|
14
|
-
/**
|
|
15
|
-
* Message type enumeration
|
|
16
|
-
* @enum MessageType
|
|
17
|
-
*/
|
|
18
|
-
var MessageType;
|
|
19
|
-
(function (MessageType) {
|
|
20
|
-
/** Standard message with 10% fee */
|
|
21
|
-
MessageType["STANDARD"] = "standard";
|
|
22
|
-
/** Priority message with full fee and 90% revenue share */
|
|
23
|
-
MessageType["PRIORITY"] = "priority";
|
|
24
|
-
/** Pre-prepared standard message */
|
|
25
|
-
MessageType["PREPARED_STANDARD"] = "prepared_standard";
|
|
26
|
-
/** Pre-prepared priority message */
|
|
27
|
-
MessageType["PREPARED_PRIORITY"] = "prepared_priority";
|
|
28
|
-
})(MessageType || (exports.MessageType = MessageType = {}));
|
|
29
|
-
/**
|
|
30
|
-
* Transaction status enumeration
|
|
31
|
-
* @enum TransactionStatus
|
|
32
|
-
*/
|
|
33
|
-
var TransactionStatus;
|
|
34
|
-
(function (TransactionStatus) {
|
|
35
|
-
/** Transaction successful */
|
|
36
|
-
TransactionStatus["SUCCESS"] = "success";
|
|
37
|
-
/** Transaction failed */
|
|
38
|
-
TransactionStatus["FAILED"] = "failed";
|
|
39
|
-
/** Transaction pending confirmation */
|
|
40
|
-
TransactionStatus["PENDING"] = "pending";
|
|
41
|
-
})(TransactionStatus || (exports.TransactionStatus = TransactionStatus = {}));
|
|
42
|
-
// ============================================================================
|
|
43
|
-
// TYPE GUARDS
|
|
44
|
-
// ============================================================================
|
|
45
|
-
/**
|
|
46
|
-
* Type guard to check if a value is a Solana PublicKey string
|
|
47
|
-
* @param value - Value to check
|
|
48
|
-
* @returns True if value is a valid Solana address
|
|
49
|
-
*/
|
|
50
|
-
function isSolanaAddress(address) {
|
|
51
|
-
try {
|
|
52
|
-
// Solana addresses are base58 encoded and typically 32-44 characters
|
|
53
|
-
if (address.length < 32 || address.length > 44) {
|
|
54
|
-
return false;
|
|
55
|
-
}
|
|
56
|
-
// Base58 alphabet: 123456789ABCDEFGHJKLMNPQRSTUVWXYZabcdefghijkmnopqrstuvwxyz
|
|
57
|
-
// Note: excludes 0, O, I, l to avoid ambiguity
|
|
58
|
-
const base58Regex = /^[1-9A-HJ-NP-Za-km-z]+$/;
|
|
59
|
-
if (!base58Regex.test(address)) {
|
|
60
|
-
return false;
|
|
61
|
-
}
|
|
62
|
-
// Additional validation: try to decode with bs58 if available
|
|
63
|
-
try {
|
|
64
|
-
// eslint-disable-next-line @typescript-eslint/no-require-imports
|
|
65
|
-
const bs58 = require('bs58');
|
|
66
|
-
const decoded = bs58.decode(address);
|
|
67
|
-
return decoded.length === 32; // Solana addresses decode to 32 bytes
|
|
68
|
-
}
|
|
69
|
-
catch {
|
|
70
|
-
// If bs58 is not available, rely on regex validation
|
|
71
|
-
return true;
|
|
72
|
-
}
|
|
73
|
-
}
|
|
74
|
-
catch {
|
|
75
|
-
return false;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
/**
|
|
79
|
-
* Type guard to check if a value is an EVM address
|
|
80
|
-
* @param value - Value to check
|
|
81
|
-
* @returns True if value is EVM address string
|
|
82
|
-
*/
|
|
83
|
-
function isEvmAddress(address) {
|
|
84
|
-
return /^0x[a-fA-F0-9]{40}$/.test(address);
|
|
85
|
-
}
|
|
86
|
-
/**
|
|
87
|
-
* Type guard to check if recipient is for Solana
|
|
88
|
-
* @param recipient - Message recipient
|
|
89
|
-
* @returns True if recipient is Solana address
|
|
90
|
-
*/
|
|
91
|
-
function isSolanaRecipient(recipient) {
|
|
92
|
-
return isSolanaAddress(recipient);
|
|
93
|
-
}
|
|
94
|
-
/**
|
|
95
|
-
* Type guard to check if recipient is for EVM
|
|
96
|
-
* @param recipient - Message recipient
|
|
97
|
-
* @returns True if recipient is EVM address
|
|
98
|
-
*/
|
|
99
|
-
function isEvmRecipient(recipient) {
|
|
100
|
-
return isEvmAddress(recipient);
|
|
101
|
-
}
|
|
102
|
-
// ============================================================================
|
|
103
|
-
// CONSTANTS
|
|
104
|
-
// ============================================================================
|
|
105
|
-
/**
|
|
106
|
-
* Protocol constants used across implementations
|
|
107
|
-
*/
|
|
108
|
-
exports.PROTOCOL_CONSTANTS = {
|
|
109
|
-
/** Base send fee: 0.1 USDC (100,000 with 6 decimals) */
|
|
110
|
-
SEND_FEE: 100000n,
|
|
111
|
-
/** Claim period: 60 days in seconds */
|
|
112
|
-
CLAIM_PERIOD: 60 * 24 * 60 * 60,
|
|
113
|
-
/** Revenue share percentages */
|
|
114
|
-
REVENUE_SHARES: {
|
|
115
|
-
SENDER: 90,
|
|
116
|
-
OWNER: 10,
|
|
117
|
-
},
|
|
118
|
-
/** USDC token decimals */
|
|
119
|
-
USDC_DECIMALS: 6,
|
|
120
|
-
/** Maximum message lengths */
|
|
121
|
-
MAX_LENGTHS: {
|
|
122
|
-
SUBJECT: 200,
|
|
123
|
-
BODY: 2000,
|
|
124
|
-
MAIL_ID: 100,
|
|
125
|
-
},
|
|
126
|
-
};
|
|
127
|
-
//# sourceMappingURL=common.js.map
|
|
@@ -1,30 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Blockchain types entry point.
|
|
4
|
-
*
|
|
5
|
-
* Import from `@sudobility/types/blockchain` to load only blockchain-
|
|
6
|
-
* related types, interfaces, enums, and validators without pulling in
|
|
7
|
-
* the rest of the library.
|
|
8
|
-
*
|
|
9
|
-
* @since 1.9.54
|
|
10
|
-
*/
|
|
11
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
-
exports.validateMessage = exports.validateDomain = exports.validateAmount = exports.validateAddress = exports.isSolanaRecipient = exports.isSolanaAddress = exports.isEvmRecipient = exports.isEvmAddress = exports.TransactionStatus = exports.PROTOCOL_CONSTANTS = exports.MessageType = void 0;
|
|
13
|
-
// Enums and constants
|
|
14
|
-
var common_1 = require("./common");
|
|
15
|
-
Object.defineProperty(exports, "MessageType", { enumerable: true, get: function () { return common_1.MessageType; } });
|
|
16
|
-
Object.defineProperty(exports, "PROTOCOL_CONSTANTS", { enumerable: true, get: function () { return common_1.PROTOCOL_CONSTANTS; } });
|
|
17
|
-
Object.defineProperty(exports, "TransactionStatus", { enumerable: true, get: function () { return common_1.TransactionStatus; } });
|
|
18
|
-
// Type guards
|
|
19
|
-
var common_2 = require("./common");
|
|
20
|
-
Object.defineProperty(exports, "isEvmAddress", { enumerable: true, get: function () { return common_2.isEvmAddress; } });
|
|
21
|
-
Object.defineProperty(exports, "isEvmRecipient", { enumerable: true, get: function () { return common_2.isEvmRecipient; } });
|
|
22
|
-
Object.defineProperty(exports, "isSolanaAddress", { enumerable: true, get: function () { return common_2.isSolanaAddress; } });
|
|
23
|
-
Object.defineProperty(exports, "isSolanaRecipient", { enumerable: true, get: function () { return common_2.isSolanaRecipient; } });
|
|
24
|
-
// Validators
|
|
25
|
-
var validation_1 = require("./validation");
|
|
26
|
-
Object.defineProperty(exports, "validateAddress", { enumerable: true, get: function () { return validation_1.validateAddress; } });
|
|
27
|
-
Object.defineProperty(exports, "validateAmount", { enumerable: true, get: function () { return validation_1.validateAmount; } });
|
|
28
|
-
Object.defineProperty(exports, "validateDomain", { enumerable: true, get: function () { return validation_1.validateDomain; } });
|
|
29
|
-
Object.defineProperty(exports, "validateMessage", { enumerable: true, get: function () { return validation_1.validateMessage; } });
|
|
30
|
-
//# sourceMappingURL=index.js.map
|
|
@@ -1,144 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Validation utilities for multi-chain operations.
|
|
4
|
-
* All validators throw on invalid input.
|
|
5
|
-
*
|
|
6
|
-
* @since 1.0.0
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.validateDomain = validateDomain;
|
|
10
|
-
exports.validateMessage = validateMessage;
|
|
11
|
-
exports.validateAddress = validateAddress;
|
|
12
|
-
exports.validateAmount = validateAmount;
|
|
13
|
-
const address_1 = require("../../utils/blockchain/address");
|
|
14
|
-
/**
|
|
15
|
-
* Validate a domain name format.
|
|
16
|
-
*
|
|
17
|
-
* @param domain - Domain string to validate
|
|
18
|
-
* @returns True if valid
|
|
19
|
-
* @throws Error if domain is empty, too long, or has invalid format
|
|
20
|
-
* @since 1.0.0
|
|
21
|
-
*
|
|
22
|
-
* @example
|
|
23
|
-
* ```typescript
|
|
24
|
-
* validateDomain('example.com'); // true
|
|
25
|
-
* validateDomain(''); // throws "Domain cannot be empty"
|
|
26
|
-
* ```
|
|
27
|
-
*/
|
|
28
|
-
function validateDomain(domain) {
|
|
29
|
-
if (!domain || domain.length === 0) {
|
|
30
|
-
throw new Error('Domain cannot be empty');
|
|
31
|
-
}
|
|
32
|
-
if (domain.length > 100) {
|
|
33
|
-
throw new Error('Domain cannot exceed 100 characters');
|
|
34
|
-
}
|
|
35
|
-
// Basic domain validation - can be expanded
|
|
36
|
-
const domainRegex = /^[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?(\.[a-zA-Z0-9]([a-zA-Z0-9-]{0,61}[a-zA-Z0-9])?)*$/;
|
|
37
|
-
if (!domainRegex.test(domain)) {
|
|
38
|
-
throw new Error('Invalid domain format');
|
|
39
|
-
}
|
|
40
|
-
return true;
|
|
41
|
-
}
|
|
42
|
-
/**
|
|
43
|
-
* Validate a message subject and body against length constraints.
|
|
44
|
-
*
|
|
45
|
-
* @param subject - Message subject (max 200 chars)
|
|
46
|
-
* @param body - Message body (max 10000 chars)
|
|
47
|
-
* @returns True if valid
|
|
48
|
-
* @throws Error if subject or body is empty or exceeds limits
|
|
49
|
-
* @since 1.0.0
|
|
50
|
-
*/
|
|
51
|
-
function validateMessage(subject, body) {
|
|
52
|
-
if (!subject || subject.length === 0) {
|
|
53
|
-
throw new Error('Message subject cannot be empty');
|
|
54
|
-
}
|
|
55
|
-
if (subject.length > 200) {
|
|
56
|
-
throw new Error('Message subject cannot exceed 200 characters');
|
|
57
|
-
}
|
|
58
|
-
if (!body || body.length === 0) {
|
|
59
|
-
throw new Error('Message body cannot be empty');
|
|
60
|
-
}
|
|
61
|
-
if (body.length > 10000) {
|
|
62
|
-
throw new Error('Message body cannot exceed 10000 characters');
|
|
63
|
-
}
|
|
64
|
-
return true;
|
|
65
|
-
}
|
|
66
|
-
/**
|
|
67
|
-
* Validate a wallet address for a specific chain type.
|
|
68
|
-
*
|
|
69
|
-
* @param address - Wallet address to validate
|
|
70
|
-
* @param chainType - Target blockchain type (EVM or Solana)
|
|
71
|
-
* @returns True if valid
|
|
72
|
-
* @throws Error if address is empty or has invalid format
|
|
73
|
-
* @since 1.0.0
|
|
74
|
-
*
|
|
75
|
-
* @example
|
|
76
|
-
* ```typescript
|
|
77
|
-
* validateAddress('0x742d35Cc6634C0532925a3b844e2', ChainType.EVM);
|
|
78
|
-
* ```
|
|
79
|
-
*/
|
|
80
|
-
function validateAddress(address, chainType) {
|
|
81
|
-
if (!address || address.length === 0) {
|
|
82
|
-
throw new Error('Address cannot be empty');
|
|
83
|
-
}
|
|
84
|
-
if (!(0, address_1.isValidWalletAddress)(address, chainType)) {
|
|
85
|
-
throw new Error(`Invalid ${chainType} address format`);
|
|
86
|
-
}
|
|
87
|
-
return true;
|
|
88
|
-
}
|
|
89
|
-
/**
|
|
90
|
-
* Validate and convert an amount to a non-negative bigint.
|
|
91
|
-
* Accepts string, number, or bigint input.
|
|
92
|
-
*
|
|
93
|
-
* @param amount - Amount value to validate
|
|
94
|
-
* @returns The validated amount as bigint
|
|
95
|
-
* @throws Error if amount is invalid, non-numeric, or negative
|
|
96
|
-
* @since 1.0.0
|
|
97
|
-
*
|
|
98
|
-
* @example
|
|
99
|
-
* ```typescript
|
|
100
|
-
* validateAmount('1000'); // 1000n
|
|
101
|
-
* validateAmount(500); // 500n
|
|
102
|
-
* validateAmount(-1); // throws "Amount cannot be negative"
|
|
103
|
-
* ```
|
|
104
|
-
*/
|
|
105
|
-
function validateAmount(amount) {
|
|
106
|
-
// Check for null, undefined, or empty string
|
|
107
|
-
if (amount === null ||
|
|
108
|
-
amount === undefined ||
|
|
109
|
-
amount === '' ||
|
|
110
|
-
(typeof amount === 'string' && amount.trim() === '')) {
|
|
111
|
-
throw new Error('Invalid amount format');
|
|
112
|
-
}
|
|
113
|
-
let amountBigInt;
|
|
114
|
-
try {
|
|
115
|
-
if (typeof amount === 'string') {
|
|
116
|
-
// Check for non-numeric strings
|
|
117
|
-
if (!/^-?\d+$/.test(amount.trim())) {
|
|
118
|
-
throw new Error('Invalid amount format');
|
|
119
|
-
}
|
|
120
|
-
amountBigInt = BigInt(amount);
|
|
121
|
-
}
|
|
122
|
-
else if (typeof amount === 'number') {
|
|
123
|
-
// Check for NaN or Infinity
|
|
124
|
-
if (!Number.isFinite(amount)) {
|
|
125
|
-
throw new Error('Invalid amount format');
|
|
126
|
-
}
|
|
127
|
-
amountBigInt = BigInt(Math.floor(amount));
|
|
128
|
-
}
|
|
129
|
-
else if (typeof amount === 'bigint') {
|
|
130
|
-
amountBigInt = amount;
|
|
131
|
-
}
|
|
132
|
-
else {
|
|
133
|
-
throw new Error('Invalid amount format');
|
|
134
|
-
}
|
|
135
|
-
}
|
|
136
|
-
catch {
|
|
137
|
-
throw new Error('Invalid amount format');
|
|
138
|
-
}
|
|
139
|
-
if (amountBigInt < 0n) {
|
|
140
|
-
throw new Error('Amount cannot be negative');
|
|
141
|
-
}
|
|
142
|
-
return amountBigInt;
|
|
143
|
-
}
|
|
144
|
-
//# sourceMappingURL=validation.js.map
|