@sudobility/types 1.9.55 → 1.9.57
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.d.ts +50 -50
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +28 -201
- package/dist/index.js.map +1 -1
- package/dist/types/blockchain/common.d.ts +3 -3
- package/dist/types/blockchain/common.d.ts.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.d.ts +4 -4
- package/dist/types/blockchain/index.d.ts.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.d.ts +1 -1
- package/dist/types/blockchain/validation.d.ts.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.d.ts +2 -2
- package/dist/types/business/wallet-status.d.ts.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.d.ts +1 -1
- package/dist/types/common.d.ts.map +1 -1
- package/dist/types/common.js +1 -2
- package/dist/types/common.js.map +1 -1
- package/dist/types/config/app-config.d.ts +1 -1
- package/dist/types/config/app-config.d.ts.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.d.ts +1 -1
- package/dist/types/config/environment.d.ts.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.d.ts +1 -1
- package/dist/types/entity/permissions.d.ts.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.d.ts +1 -1
- package/dist/types/entity/requests.d.ts.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.d.ts +2 -2
- package/dist/types/entity/responses.d.ts.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.d.ts +1 -1
- package/dist/types/infrastructure/analytics.d.ts.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.d.ts +2 -2
- package/dist/types/infrastructure/api.d.ts.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.d.ts +1 -1
- package/dist/types/infrastructure/navigation.d.ts.map +1 -1
- package/dist/types/infrastructure/navigation.js +1 -2
- package/dist/types/infrastructure/network.d.ts +1 -1
- package/dist/types/infrastructure/network.d.ts.map +1 -1
- 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.d.ts +1 -1
- package/dist/utils/async-helpers.d.ts.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.d.ts +2 -2
- package/dist/utils/auth/auth.d.ts.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.d.ts +2 -2
- package/dist/utils/blockchain/address.d.ts.map +1 -1
- package/dist/utils/blockchain/address.js +21 -32
- 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.d.ts +1 -1
- package/dist/utils/formatting/date.d.ts.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.d.ts +1 -1
- package/dist/utils/formatting/string.d.ts.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.d.ts +1 -1
- package/dist/utils/logging/logger.d.ts.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.d.ts +1 -1
- package/dist/utils/url/url-params.d.ts.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.d.ts +1 -1
- package/dist/utils/validation/type-validation.d.ts.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.d.ts +2 -2
- package/dist/utils/validation/web3-username-validator.d.ts.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 +4 -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
|
@@ -1,79 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Admin email whitelist utilities
|
|
4
|
-
*
|
|
5
|
-
* Pure utility functions for parsing and checking admin email whitelists.
|
|
6
|
-
* Used by both frontend (auth_lib) and backend (auth_service) packages.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.parseAdminEmails = parseAdminEmails;
|
|
10
|
-
exports.isAdminEmail = isAdminEmail;
|
|
11
|
-
exports.createAdminChecker = createAdminChecker;
|
|
12
|
-
/**
|
|
13
|
-
* Parse admin emails from environment variable or string
|
|
14
|
-
*
|
|
15
|
-
* @param input - Comma-separated string of admin emails (e.g., "admin@example.com, other@example.com")
|
|
16
|
-
* @returns Array of normalized (lowercase, trimmed) email addresses
|
|
17
|
-
*
|
|
18
|
-
* @example
|
|
19
|
-
* ```typescript
|
|
20
|
-
* const adminEmails = parseAdminEmails(process.env.ADMIN_EMAILS || "");
|
|
21
|
-
* // Returns: ["admin@example.com", "other@example.com"]
|
|
22
|
-
* ```
|
|
23
|
-
*/
|
|
24
|
-
function parseAdminEmails(input) {
|
|
25
|
-
if (!input) {
|
|
26
|
-
return [];
|
|
27
|
-
}
|
|
28
|
-
return input
|
|
29
|
-
.split(',')
|
|
30
|
-
.map((email) => email.trim().toLowerCase())
|
|
31
|
-
.filter((email) => email.length > 0 && email.includes('@'));
|
|
32
|
-
}
|
|
33
|
-
/**
|
|
34
|
-
* Check if an email is in the admin whitelist
|
|
35
|
-
*
|
|
36
|
-
* @param email - Email address to check
|
|
37
|
-
* @param adminEmails - Array of admin emails (from parseAdminEmails)
|
|
38
|
-
* @returns True if the email is an admin
|
|
39
|
-
*
|
|
40
|
-
* @example
|
|
41
|
-
* ```typescript
|
|
42
|
-
* const adminEmails = parseAdminEmails(process.env.ADMIN_EMAILS || "");
|
|
43
|
-
* if (isAdminEmail(user.email, adminEmails)) {
|
|
44
|
-
* // Skip rate limiting, subscription checks, etc.
|
|
45
|
-
* }
|
|
46
|
-
* ```
|
|
47
|
-
*/
|
|
48
|
-
function isAdminEmail(email, adminEmails) {
|
|
49
|
-
if (!email) {
|
|
50
|
-
return false;
|
|
51
|
-
}
|
|
52
|
-
return adminEmails.includes(email.toLowerCase());
|
|
53
|
-
}
|
|
54
|
-
/**
|
|
55
|
-
* Create a cached admin email checker
|
|
56
|
-
*
|
|
57
|
-
* Parses the admin emails once and returns a checker function.
|
|
58
|
-
* Useful for middleware where you don't want to re-parse on every request.
|
|
59
|
-
*
|
|
60
|
-
* @param input - Comma-separated string of admin emails
|
|
61
|
-
* @returns Function that checks if an email is an admin
|
|
62
|
-
*
|
|
63
|
-
* @example
|
|
64
|
-
* ```typescript
|
|
65
|
-
* const isAdmin = createAdminChecker(process.env.ADMIN_EMAILS);
|
|
66
|
-
*
|
|
67
|
-
* // In middleware:
|
|
68
|
-
* if (isAdmin(user.email)) {
|
|
69
|
-
* // Bypass checks
|
|
70
|
-
* }
|
|
71
|
-
* ```
|
|
72
|
-
*/
|
|
73
|
-
function createAdminChecker(input) {
|
|
74
|
-
const adminEmails = parseAdminEmails(input);
|
|
75
|
-
return (email) => {
|
|
76
|
-
return isAdminEmail(email, adminEmails);
|
|
77
|
-
};
|
|
78
|
-
}
|
|
79
|
-
//# sourceMappingURL=admin-emails.js.map
|
package/dist/utils/auth/auth.cjs
DELETED
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Authentication utilities for wallet-based authentication
|
|
4
|
-
*/
|
|
5
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
6
|
-
exports.generateAuthMessage = generateAuthMessage;
|
|
7
|
-
exports.isAuthExpired = isAuthExpired;
|
|
8
|
-
exports.getAuthStatusText = getAuthStatusText;
|
|
9
|
-
exports.canAccessProtectedFeatures = canAccessProtectedFeatures;
|
|
10
|
-
exports.isAuthStatusConnected = isAuthStatusConnected;
|
|
11
|
-
exports.generateNonce = generateNonce;
|
|
12
|
-
exports.extractNonceFromMessage = extractNonceFromMessage;
|
|
13
|
-
exports.isValidNonce = isValidNonce;
|
|
14
|
-
const enums_1 = require("../../types/business/enums");
|
|
15
|
-
/**
|
|
16
|
-
* Generate an authentication message with a nonce
|
|
17
|
-
* @param emailDomain - The email domain/service name to display in the auth message
|
|
18
|
-
* @param nonce - Optional nonce value. If not provided, a random one will be generated
|
|
19
|
-
* @returns Authentication message string
|
|
20
|
-
*/
|
|
21
|
-
function generateAuthMessage(emailDomain, nonce) {
|
|
22
|
-
const actualNonce = nonce || `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
23
|
-
return `Authenticate with ${emailDomain}\nNonce: ${actualNonce}`;
|
|
24
|
-
}
|
|
25
|
-
/**
|
|
26
|
-
* Check if authentication is expired
|
|
27
|
-
* @param createdAt - The date when authentication was created
|
|
28
|
-
* @param expirationHours - Number of hours until expiration (default: 24)
|
|
29
|
-
*/
|
|
30
|
-
function isAuthExpired(createdAt, expirationHours = 24) {
|
|
31
|
-
const expirationTime = new Date(createdAt.getTime() + expirationHours * 60 * 60 * 1000);
|
|
32
|
-
return new Date() > expirationTime;
|
|
33
|
-
}
|
|
34
|
-
/**
|
|
35
|
-
* Get human-readable text for authentication status
|
|
36
|
-
*/
|
|
37
|
-
function getAuthStatusText(status) {
|
|
38
|
-
switch (status) {
|
|
39
|
-
case enums_1.AuthStatus.DISCONNECTED:
|
|
40
|
-
return 'Not connected';
|
|
41
|
-
case enums_1.AuthStatus.CONNECTED:
|
|
42
|
-
return 'Connected - Please verify';
|
|
43
|
-
case enums_1.AuthStatus.VERIFIED:
|
|
44
|
-
return 'Authenticated';
|
|
45
|
-
default:
|
|
46
|
-
return 'Unknown status';
|
|
47
|
-
}
|
|
48
|
-
}
|
|
49
|
-
/**
|
|
50
|
-
* Check if user can access protected features
|
|
51
|
-
*/
|
|
52
|
-
function canAccessProtectedFeatures(status) {
|
|
53
|
-
return status === enums_1.AuthStatus.VERIFIED;
|
|
54
|
-
}
|
|
55
|
-
/**
|
|
56
|
-
* Check if auth status indicates wallet is connected (either connected or verified)
|
|
57
|
-
*/
|
|
58
|
-
function isAuthStatusConnected(status) {
|
|
59
|
-
return status === enums_1.AuthStatus.CONNECTED || status === enums_1.AuthStatus.VERIFIED;
|
|
60
|
-
}
|
|
61
|
-
/**
|
|
62
|
-
* Generate a random nonce for authentication
|
|
63
|
-
*/
|
|
64
|
-
function generateNonce() {
|
|
65
|
-
return `${Date.now()}-${Math.random().toString(36).substr(2, 9)}`;
|
|
66
|
-
}
|
|
67
|
-
/**
|
|
68
|
-
* Extract nonce from an authentication message
|
|
69
|
-
*/
|
|
70
|
-
function extractNonceFromMessage(message) {
|
|
71
|
-
const match = message.match(/Nonce:\s*(.+)$/m);
|
|
72
|
-
return match ? match[1].trim() : undefined;
|
|
73
|
-
}
|
|
74
|
-
/**
|
|
75
|
-
* Validate that a nonce meets basic requirements
|
|
76
|
-
*/
|
|
77
|
-
function isValidNonce(nonce) {
|
|
78
|
-
if (!nonce || typeof nonce !== 'string') {
|
|
79
|
-
return false;
|
|
80
|
-
}
|
|
81
|
-
// Nonce should be at least 10 characters
|
|
82
|
-
if (nonce.length < 10) {
|
|
83
|
-
return false;
|
|
84
|
-
}
|
|
85
|
-
// Nonce should not be too old (check if it starts with a timestamp)
|
|
86
|
-
const parts = nonce.split('-');
|
|
87
|
-
if (parts.length >= 2) {
|
|
88
|
-
const timestamp = parseInt(parts[0], 10);
|
|
89
|
-
if (!isNaN(timestamp)) {
|
|
90
|
-
// Check if timestamp is within last 24 hours
|
|
91
|
-
const oneDayAgo = Date.now() - 24 * 60 * 60 * 1000;
|
|
92
|
-
if (timestamp < oneDayAgo) {
|
|
93
|
-
return false;
|
|
94
|
-
}
|
|
95
|
-
}
|
|
96
|
-
}
|
|
97
|
-
return true;
|
|
98
|
-
}
|
|
99
|
-
//# sourceMappingURL=auth.js.map
|
|
@@ -1,225 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* Blockchain address utilities for multi-chain support
|
|
4
|
-
*
|
|
5
|
-
* Provides validation and detection for various blockchain address formats
|
|
6
|
-
* including EVM addresses, Solana addresses, ENS names, and SNS names.
|
|
7
|
-
*/
|
|
8
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
9
|
-
exports.AddressType = void 0;
|
|
10
|
-
exports.isENSName = isENSName;
|
|
11
|
-
exports.isSNSName = isSNSName;
|
|
12
|
-
exports.getAddressType = getAddressType;
|
|
13
|
-
exports.isValidWalletAddress = isValidWalletAddress;
|
|
14
|
-
exports.isValidSignature = isValidSignature;
|
|
15
|
-
exports.parseEmailAddress = parseEmailAddress;
|
|
16
|
-
exports.formatWalletAddress = formatWalletAddress;
|
|
17
|
-
exports.getChainDisplayName = getChainDisplayName;
|
|
18
|
-
const enums_1 = require("../../types/business/enums");
|
|
19
|
-
// Import base validation functions from common types
|
|
20
|
-
const common_1 = require("../../types/blockchain/common");
|
|
21
|
-
/**
|
|
22
|
-
* Address type enumeration
|
|
23
|
-
*/
|
|
24
|
-
var AddressType;
|
|
25
|
-
(function (AddressType) {
|
|
26
|
-
AddressType["EVMAddress"] = "EVMAddress";
|
|
27
|
-
AddressType["SolanaAddress"] = "SolanaAddress";
|
|
28
|
-
AddressType["ENSName"] = "ENSName";
|
|
29
|
-
AddressType["SNSName"] = "SNSName";
|
|
30
|
-
})(AddressType || (exports.AddressType = AddressType = {}));
|
|
31
|
-
// Address validation functions are now imported directly from common.ts
|
|
32
|
-
// Use isEvmAddress and isSolanaAddress from '../../types/blockchain/common'
|
|
33
|
-
/**
|
|
34
|
-
* Check if address is an ENS name (.eth or .box)
|
|
35
|
-
*/
|
|
36
|
-
function isENSName(address) {
|
|
37
|
-
const lowerAddress = address.toLowerCase();
|
|
38
|
-
// ENS names end with .eth or .box
|
|
39
|
-
if (!lowerAddress.endsWith('.eth') && !lowerAddress.endsWith('.box')) {
|
|
40
|
-
return false;
|
|
41
|
-
}
|
|
42
|
-
// Extract the name part (without .eth or .box)
|
|
43
|
-
const nameWithoutTLD = lowerAddress.endsWith('.eth')
|
|
44
|
-
? lowerAddress.slice(0, -4)
|
|
45
|
-
: lowerAddress.slice(0, -4);
|
|
46
|
-
if (nameWithoutTLD.length === 0) {
|
|
47
|
-
return false;
|
|
48
|
-
}
|
|
49
|
-
// ENS names can have multiple labels separated by dots
|
|
50
|
-
const labels = nameWithoutTLD.split('.');
|
|
51
|
-
// Each label must be valid
|
|
52
|
-
const validLabelRegex = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;
|
|
53
|
-
for (const label of labels) {
|
|
54
|
-
if (label.length === 0 || !validLabelRegex.test(label)) {
|
|
55
|
-
return false;
|
|
56
|
-
}
|
|
57
|
-
// No consecutive hyphens allowed
|
|
58
|
-
if (label.includes('--')) {
|
|
59
|
-
return false;
|
|
60
|
-
}
|
|
61
|
-
}
|
|
62
|
-
return true;
|
|
63
|
-
}
|
|
64
|
-
/**
|
|
65
|
-
* Check if address is an SNS name (Solana name service)
|
|
66
|
-
* Supports: .sol, .abc, .bonk, .poor, .gm, .dao, .defi, .web3
|
|
67
|
-
*/
|
|
68
|
-
function isSNSName(address) {
|
|
69
|
-
const lowerAddress = address.toLowerCase();
|
|
70
|
-
// List of supported Solana name extensions
|
|
71
|
-
const snsExtensions = [
|
|
72
|
-
'.sol',
|
|
73
|
-
'.abc',
|
|
74
|
-
'.bonk',
|
|
75
|
-
'.poor',
|
|
76
|
-
'.gm',
|
|
77
|
-
'.dao',
|
|
78
|
-
'.defi',
|
|
79
|
-
'.web3',
|
|
80
|
-
];
|
|
81
|
-
// Check if address ends with any supported extension
|
|
82
|
-
const matchingExtension = snsExtensions.find((ext) => lowerAddress.endsWith(ext));
|
|
83
|
-
if (!matchingExtension) {
|
|
84
|
-
return false;
|
|
85
|
-
}
|
|
86
|
-
// Extract the name part (without the extension)
|
|
87
|
-
const nameWithoutTLD = lowerAddress.slice(0, -matchingExtension.length);
|
|
88
|
-
if (nameWithoutTLD.length === 0) {
|
|
89
|
-
return false;
|
|
90
|
-
}
|
|
91
|
-
// SNS names can have multiple labels separated by dots
|
|
92
|
-
const labels = nameWithoutTLD.split('.');
|
|
93
|
-
// Each label must be valid
|
|
94
|
-
const validLabelRegex = /^[a-z0-9]([a-z0-9-]*[a-z0-9])?$/;
|
|
95
|
-
for (const label of labels) {
|
|
96
|
-
if (label.length === 0 || !validLabelRegex.test(label)) {
|
|
97
|
-
return false;
|
|
98
|
-
}
|
|
99
|
-
// No consecutive hyphens allowed
|
|
100
|
-
if (label.includes('--')) {
|
|
101
|
-
return false;
|
|
102
|
-
}
|
|
103
|
-
}
|
|
104
|
-
return true;
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Determine the address type from a string
|
|
108
|
-
* Case insensitive as addresses/names are often case insensitive
|
|
109
|
-
*/
|
|
110
|
-
function getAddressType(address, parentAddressType = undefined) {
|
|
111
|
-
// Check for EVM address (0x followed by 40 hex characters)
|
|
112
|
-
if ((0, common_1.isEvmAddress)(address)) {
|
|
113
|
-
return AddressType.EVMAddress;
|
|
114
|
-
}
|
|
115
|
-
// Check for Solana address (base58 encoded, 32-44 characters)
|
|
116
|
-
if ((0, common_1.isSolanaAddress)(address)) {
|
|
117
|
-
return AddressType.SolanaAddress;
|
|
118
|
-
}
|
|
119
|
-
// If parent address type is provided and address contains ".", it's a domain name
|
|
120
|
-
if (parentAddressType && address.includes('.')) {
|
|
121
|
-
if (parentAddressType === AddressType.EVMAddress) {
|
|
122
|
-
return AddressType.ENSName;
|
|
123
|
-
}
|
|
124
|
-
if (parentAddressType === AddressType.SolanaAddress) {
|
|
125
|
-
return AddressType.SNSName;
|
|
126
|
-
}
|
|
127
|
-
}
|
|
128
|
-
return undefined;
|
|
129
|
-
}
|
|
130
|
-
/**
|
|
131
|
-
* Validate a wallet address for a specific chain type
|
|
132
|
-
*/
|
|
133
|
-
function isValidWalletAddress(address, chainType) {
|
|
134
|
-
if (!address || typeof address !== 'string') {
|
|
135
|
-
return false;
|
|
136
|
-
}
|
|
137
|
-
const addressType = getAddressType(address);
|
|
138
|
-
switch (chainType) {
|
|
139
|
-
case enums_1.ChainType.EVM:
|
|
140
|
-
return (addressType === AddressType.EVMAddress ||
|
|
141
|
-
addressType === AddressType.ENSName);
|
|
142
|
-
case enums_1.ChainType.SOLANA:
|
|
143
|
-
return (addressType === AddressType.SolanaAddress ||
|
|
144
|
-
addressType === AddressType.SNSName);
|
|
145
|
-
default:
|
|
146
|
-
// Unknown chain type, accept any known address format
|
|
147
|
-
return !!addressType;
|
|
148
|
-
}
|
|
149
|
-
}
|
|
150
|
-
/**
|
|
151
|
-
* Check if a signature is valid for a specific chain type
|
|
152
|
-
*/
|
|
153
|
-
function isValidSignature(signature, chainType) {
|
|
154
|
-
if (!signature || typeof signature !== 'string') {
|
|
155
|
-
return false;
|
|
156
|
-
}
|
|
157
|
-
switch (chainType) {
|
|
158
|
-
case enums_1.ChainType.EVM:
|
|
159
|
-
// EVM signature validation (0x followed by 130 hex characters)
|
|
160
|
-
return /^0x[a-fA-F0-9]{130}$/.test(signature);
|
|
161
|
-
case enums_1.ChainType.SOLANA:
|
|
162
|
-
// Solana signature validation (base58 encoded, typically 87-88 characters)
|
|
163
|
-
return /^[1-9A-HJ-NP-Za-km-z]{87,88}$/.test(signature);
|
|
164
|
-
default:
|
|
165
|
-
// Basic validation for unknown chain types
|
|
166
|
-
return signature.length > 50;
|
|
167
|
-
}
|
|
168
|
-
}
|
|
169
|
-
/**
|
|
170
|
-
* Parse an email address into its components
|
|
171
|
-
*/
|
|
172
|
-
function parseEmailAddress(email) {
|
|
173
|
-
if (!email || typeof email !== 'string') {
|
|
174
|
-
return undefined;
|
|
175
|
-
}
|
|
176
|
-
const parts = email.split('@');
|
|
177
|
-
if (parts.length !== 2) {
|
|
178
|
-
return undefined;
|
|
179
|
-
}
|
|
180
|
-
const [address, domain] = parts;
|
|
181
|
-
if (!address || !domain) {
|
|
182
|
-
return undefined;
|
|
183
|
-
}
|
|
184
|
-
const type = getAddressType(address);
|
|
185
|
-
return {
|
|
186
|
-
address,
|
|
187
|
-
domain,
|
|
188
|
-
type,
|
|
189
|
-
};
|
|
190
|
-
}
|
|
191
|
-
/**
|
|
192
|
-
* Format a wallet address for display
|
|
193
|
-
* Shows first 6 and last 4 characters with ellipsis
|
|
194
|
-
*/
|
|
195
|
-
function formatWalletAddress(address) {
|
|
196
|
-
if (!address || address.length < 10) {
|
|
197
|
-
return address;
|
|
198
|
-
}
|
|
199
|
-
// For ENS/SNS names, show them in full if they're short enough
|
|
200
|
-
const addressType = getAddressType(address);
|
|
201
|
-
if ((addressType === AddressType.ENSName ||
|
|
202
|
-
addressType === AddressType.SNSName) &&
|
|
203
|
-
address.length <= 20) {
|
|
204
|
-
return address;
|
|
205
|
-
}
|
|
206
|
-
// Show first 6 and last 4 characters with ellipsis
|
|
207
|
-
return `${address.slice(0, 6)}...${address.slice(-4)}`;
|
|
208
|
-
}
|
|
209
|
-
/**
|
|
210
|
-
* Get display name for a chain type
|
|
211
|
-
*/
|
|
212
|
-
function getChainDisplayName(chainType) {
|
|
213
|
-
if (!chainType) {
|
|
214
|
-
return 'Unknown Chain';
|
|
215
|
-
}
|
|
216
|
-
switch (chainType) {
|
|
217
|
-
case enums_1.ChainType.EVM:
|
|
218
|
-
return 'EVM Chain';
|
|
219
|
-
case enums_1.ChainType.SOLANA:
|
|
220
|
-
return 'Solana';
|
|
221
|
-
default:
|
|
222
|
-
return 'Blockchain';
|
|
223
|
-
}
|
|
224
|
-
}
|
|
225
|
-
//# sourceMappingURL=address.js.map
|
|
@@ -1,143 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
/**
|
|
3
|
-
* @fileoverview Pure Event Helper Functions
|
|
4
|
-
* @description Pure utility functions for multi-chain event processing
|
|
5
|
-
* @version 2.0.0
|
|
6
|
-
*
|
|
7
|
-
* This file provides clean, type-safe utility functions with no external dependencies:
|
|
8
|
-
* - Multi-chain ID generation
|
|
9
|
-
* - Address normalization
|
|
10
|
-
* - BigInt formatting
|
|
11
|
-
* - Address validation
|
|
12
|
-
* - Testnet detection
|
|
13
|
-
*/
|
|
14
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.createMultiChainId = createMultiChainId;
|
|
16
|
-
exports.createUserMultiChainId = createUserMultiChainId;
|
|
17
|
-
exports.createChainStatsId = createChainStatsId;
|
|
18
|
-
exports.createDelegationId = createDelegationId;
|
|
19
|
-
exports.normalizeAddress = normalizeAddress;
|
|
20
|
-
exports.formatBigInt = formatBigInt;
|
|
21
|
-
exports.isZeroAddress = isZeroAddress;
|
|
22
|
-
exports.isTestNet = isTestNet;
|
|
23
|
-
exports.validateEventArgs = validateEventArgs;
|
|
24
|
-
// ========================================
|
|
25
|
-
// ID GENERATION UTILITIES
|
|
26
|
-
// ========================================
|
|
27
|
-
/**
|
|
28
|
-
* Generate unique multi-chain entity ID
|
|
29
|
-
*
|
|
30
|
-
* @param chainId - Network chain ID (e.g., 1 for Ethereum)
|
|
31
|
-
* @param txHash - Transaction hash
|
|
32
|
-
* @param logIndex - Event log index within transaction
|
|
33
|
-
* @returns Formatted ID: "chainId-txHash-logIndex"
|
|
34
|
-
*
|
|
35
|
-
* @example
|
|
36
|
-
* ```typescript
|
|
37
|
-
* const id = createMultiChainId(1, "0x123...", 0);
|
|
38
|
-
* // Result: "1-0x123...-0"
|
|
39
|
-
* ```
|
|
40
|
-
*/
|
|
41
|
-
function createMultiChainId(chainId, txHash, logIndex) {
|
|
42
|
-
return `${chainId}-${txHash}-${logIndex}`;
|
|
43
|
-
}
|
|
44
|
-
/**
|
|
45
|
-
* Generate user-specific multi-chain ID
|
|
46
|
-
*
|
|
47
|
-
* @param chainId - Network chain ID
|
|
48
|
-
* @param address - User wallet address (will be normalized to lowercase)
|
|
49
|
-
* @returns Formatted ID: "chainId-address"
|
|
50
|
-
*
|
|
51
|
-
* @example
|
|
52
|
-
* ```typescript
|
|
53
|
-
* const userId = createUserMultiChainId(137, "0xABC...");
|
|
54
|
-
* // Result: "137-0xabc..."
|
|
55
|
-
* ```
|
|
56
|
-
*/
|
|
57
|
-
function createUserMultiChainId(chainId, address) {
|
|
58
|
-
return `${chainId}-${address.toLowerCase()}`;
|
|
59
|
-
}
|
|
60
|
-
/**
|
|
61
|
-
* Generate chain-specific statistics ID
|
|
62
|
-
*
|
|
63
|
-
* @param chainId - Network chain ID
|
|
64
|
-
* @returns Formatted ID: "chainId-global"
|
|
65
|
-
*/
|
|
66
|
-
function createChainStatsId(chainId) {
|
|
67
|
-
return `${chainId}-global`;
|
|
68
|
-
}
|
|
69
|
-
/**
|
|
70
|
-
* Generate delegation ID based on delegator address and testnet status
|
|
71
|
-
*
|
|
72
|
-
* @param delegatorAddress - The wallet address that is delegating
|
|
73
|
-
* @param isTestNet - Whether the chain is a testnet
|
|
74
|
-
* @returns Formatted ID: "delegatorAddress-testNet"
|
|
75
|
-
*/
|
|
76
|
-
function createDelegationId(delegatorAddress, isTestNet) {
|
|
77
|
-
return `${delegatorAddress.toLowerCase()}-${isTestNet}`;
|
|
78
|
-
}
|
|
79
|
-
// ========================================
|
|
80
|
-
// UTILITY FUNCTIONS
|
|
81
|
-
// ========================================
|
|
82
|
-
/**
|
|
83
|
-
* Normalize address to lowercase
|
|
84
|
-
*/
|
|
85
|
-
function normalizeAddress(address) {
|
|
86
|
-
return address.toLowerCase();
|
|
87
|
-
}
|
|
88
|
-
/**
|
|
89
|
-
* Format bigint for display
|
|
90
|
-
*/
|
|
91
|
-
function formatBigInt(value, decimals = 18) {
|
|
92
|
-
const divisor = BigInt(10 ** decimals);
|
|
93
|
-
const whole = value / divisor;
|
|
94
|
-
const fraction = value % divisor;
|
|
95
|
-
if (fraction === 0n) {
|
|
96
|
-
return whole.toString();
|
|
97
|
-
}
|
|
98
|
-
return `${whole}.${fraction.toString().padStart(decimals, '0').replace(/0+$/, '')}`;
|
|
99
|
-
}
|
|
100
|
-
/**
|
|
101
|
-
* Check if address is zero address (delegation clearing)
|
|
102
|
-
*/
|
|
103
|
-
function isZeroAddress(address) {
|
|
104
|
-
return address.toLowerCase() === '0x0000000000000000000000000000000000000000';
|
|
105
|
-
}
|
|
106
|
-
/**
|
|
107
|
-
* Determine if a chain ID represents a testnet
|
|
108
|
-
* @param chainId The blockchain chain ID
|
|
109
|
-
* @returns true if the chain is a testnet, false if mainnet
|
|
110
|
-
*/
|
|
111
|
-
function isTestNet(chainId) {
|
|
112
|
-
// EVM Testnets (positive chain IDs)
|
|
113
|
-
const evmTestnets = new Set([
|
|
114
|
-
31337, // Hardhat (local development)
|
|
115
|
-
11155111, // Ethereum Sepolia
|
|
116
|
-
80001, // Polygon Mumbai (if configured)
|
|
117
|
-
80002, // Polygon Amoy (if configured)
|
|
118
|
-
421614, // Arbitrum Sepolia (if configured)
|
|
119
|
-
11155420, // OP Sepolia (if configured)
|
|
120
|
-
84532, // Base Sepolia (if configured)
|
|
121
|
-
43113, // Avalanche Fuji (if configured)
|
|
122
|
-
]);
|
|
123
|
-
// Solana Testnets (negative chain IDs)
|
|
124
|
-
const solanaTestnets = new Set([
|
|
125
|
-
-102, // Solana Devnet
|
|
126
|
-
-103, // Solana Testnet
|
|
127
|
-
-104, // Solana Localnet
|
|
128
|
-
]);
|
|
129
|
-
return evmTestnets.has(chainId) || solanaTestnets.has(chainId);
|
|
130
|
-
}
|
|
131
|
-
/**
|
|
132
|
-
* Validate event arguments
|
|
133
|
-
*/
|
|
134
|
-
function validateEventArgs(args, requiredFields) {
|
|
135
|
-
for (const field of requiredFields) {
|
|
136
|
-
if (args[field] === undefined || args[field] === null) {
|
|
137
|
-
console.error(`❌ Missing required field: ${String(field)}`);
|
|
138
|
-
return false;
|
|
139
|
-
}
|
|
140
|
-
}
|
|
141
|
-
return true;
|
|
142
|
-
}
|
|
143
|
-
//# sourceMappingURL=event-helpers.js.map
|
|
@@ -1,152 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
// Application constants
|
|
3
|
-
// For UI-related constants (gradients, spacing, etc.), see:
|
|
4
|
-
// - ./gradients.ts - Gradient utilities and color schemes
|
|
5
|
-
// - ./ui-constants.ts - Layout, typography, and component patterns
|
|
6
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
7
|
-
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 = void 0;
|
|
8
|
-
// API Configuration
|
|
9
|
-
const API_TIMEOUT = 30000; // 30 seconds
|
|
10
|
-
exports.API_TIMEOUT = API_TIMEOUT;
|
|
11
|
-
const API_RETRY_ATTEMPTS = 3;
|
|
12
|
-
exports.API_RETRY_ATTEMPTS = API_RETRY_ATTEMPTS;
|
|
13
|
-
const API_RETRY_DELAY = 1000; // 1 second
|
|
14
|
-
exports.API_RETRY_DELAY = API_RETRY_DELAY;
|
|
15
|
-
// Authentication
|
|
16
|
-
const AUTH_STATUS = {
|
|
17
|
-
DISCONNECTED: 'disconnected',
|
|
18
|
-
CONNECTED: 'connected',
|
|
19
|
-
VERIFIED: 'verified',
|
|
20
|
-
};
|
|
21
|
-
exports.AUTH_STATUS = AUTH_STATUS;
|
|
22
|
-
// Chain Types
|
|
23
|
-
const CHAIN_TYPE = {
|
|
24
|
-
EVM: 'evm',
|
|
25
|
-
SOLANA: 'solana',
|
|
26
|
-
UNKNOWN: 'unknown',
|
|
27
|
-
};
|
|
28
|
-
exports.CHAIN_TYPE = CHAIN_TYPE;
|
|
29
|
-
// Storage Keys
|
|
30
|
-
const STORAGE_KEYS = {
|
|
31
|
-
AUTH_TOKEN: 'authToken',
|
|
32
|
-
USER_DATA: 'userData',
|
|
33
|
-
THEME: 'theme',
|
|
34
|
-
EMAIL_CACHE: 'emailCache',
|
|
35
|
-
WALLET_ADDRESS: 'walletAddress',
|
|
36
|
-
CHAIN_TYPE: 'chainType',
|
|
37
|
-
};
|
|
38
|
-
exports.STORAGE_KEYS = STORAGE_KEYS;
|
|
39
|
-
// Email Configuration
|
|
40
|
-
const EMAIL_CONFIG = {
|
|
41
|
-
MAX_ATTACHMENT_SIZE: 25 * 1024 * 1024, // 25MB
|
|
42
|
-
MAX_RECIPIENTS: 100,
|
|
43
|
-
ITEMS_PER_PAGE: 50,
|
|
44
|
-
REFRESH_INTERVAL: 60000, // 1 minute
|
|
45
|
-
NOTIFICATION_COOLDOWN: 300000, // 5 minutes
|
|
46
|
-
};
|
|
47
|
-
exports.EMAIL_CONFIG = EMAIL_CONFIG;
|
|
48
|
-
// Subscription Tiers
|
|
49
|
-
const SUBSCRIPTION_TIERS = {
|
|
50
|
-
FREE: 'free',
|
|
51
|
-
BASIC: 'basic',
|
|
52
|
-
PRO: 'pro',
|
|
53
|
-
ENTERPRISE: 'enterprise',
|
|
54
|
-
};
|
|
55
|
-
exports.SUBSCRIPTION_TIERS = SUBSCRIPTION_TIERS;
|
|
56
|
-
// Time Formats
|
|
57
|
-
const TIME_FORMAT = {
|
|
58
|
-
SHORT_DATE: 'MMM d',
|
|
59
|
-
FULL_DATE: 'MMM d, yyyy',
|
|
60
|
-
DATE_TIME: 'MMM d, yyyy h:mm a',
|
|
61
|
-
RELATIVE: 'relative',
|
|
62
|
-
};
|
|
63
|
-
exports.TIME_FORMAT = TIME_FORMAT;
|
|
64
|
-
// Error Messages
|
|
65
|
-
const ERROR_MESSAGES = {
|
|
66
|
-
WALLET_NOT_CONNECTED: 'Please connect your wallet first',
|
|
67
|
-
INVALID_ADDRESS: 'Please enter a valid address',
|
|
68
|
-
NETWORK_ERROR: 'Network error. Please try again.',
|
|
69
|
-
AUTHENTICATION_FAILED: 'Authentication failed. Please sign in again.',
|
|
70
|
-
TRANSACTION_FAILED: 'Transaction failed. Please try again.',
|
|
71
|
-
INSUFFICIENT_FUNDS: 'Insufficient funds for this operation',
|
|
72
|
-
RATE_LIMITED: 'Too many requests. Please wait a moment.',
|
|
73
|
-
SESSION_EXPIRED: 'Your session has expired. Please sign in again.',
|
|
74
|
-
PERMISSION_DENIED: 'You do not have permission to perform this action',
|
|
75
|
-
};
|
|
76
|
-
exports.ERROR_MESSAGES = ERROR_MESSAGES;
|
|
77
|
-
// Success Messages
|
|
78
|
-
const SUCCESS_MESSAGES = {
|
|
79
|
-
EMAIL_SENT: 'Email sent successfully',
|
|
80
|
-
EMAIL_DELETED: 'Email deleted successfully',
|
|
81
|
-
PREFERENCES_SAVED: 'Preferences saved successfully',
|
|
82
|
-
WALLET_CONNECTED: 'Wallet connected successfully',
|
|
83
|
-
AUTHENTICATION_SUCCESS: 'Authentication successful',
|
|
84
|
-
DELEGATION_SUCCESS: 'Delegation successful',
|
|
85
|
-
SUBSCRIPTION_ACTIVATED: 'Subscription activated successfully',
|
|
86
|
-
};
|
|
87
|
-
exports.SUCCESS_MESSAGES = SUCCESS_MESSAGES;
|
|
88
|
-
// Routes
|
|
89
|
-
const ROUTES = {
|
|
90
|
-
HOME: '/',
|
|
91
|
-
ABOUT: '/about',
|
|
92
|
-
CONNECT: '/connect',
|
|
93
|
-
MAIL: '/mail',
|
|
94
|
-
COMPOSE: '/mail/compose',
|
|
95
|
-
PREFERENCES: '/preferences',
|
|
96
|
-
TERMS: '/terms',
|
|
97
|
-
PRIVACY: '/privacy',
|
|
98
|
-
DOCUMENTATION: '/document',
|
|
99
|
-
WEB3_USERS: '/web3-users',
|
|
100
|
-
WEB3_PROJECTS: '/web3-projects',
|
|
101
|
-
};
|
|
102
|
-
exports.ROUTES = ROUTES;
|
|
103
|
-
// Contact Information
|
|
104
|
-
const CONTACT_INFO = {
|
|
105
|
-
SUPPORT_EMAIL: 'support@sudobility.com',
|
|
106
|
-
CONTACT_EMAIL: 'info@sudobility.com',
|
|
107
|
-
};
|
|
108
|
-
exports.CONTACT_INFO = CONTACT_INFO;
|
|
109
|
-
// Wallet Names
|
|
110
|
-
const WALLET_NAMES = {
|
|
111
|
-
METAMASK: 'MetaMask',
|
|
112
|
-
WALLETCONNECT: 'WalletConnect',
|
|
113
|
-
COINBASE: 'Coinbase Wallet',
|
|
114
|
-
PHANTOM: 'Phantom',
|
|
115
|
-
SAFE: 'Safe',
|
|
116
|
-
ARGENT: 'Argent',
|
|
117
|
-
RAINBOW: 'Rainbow',
|
|
118
|
-
TRUST: 'Trust Wallet',
|
|
119
|
-
LEDGER: 'Ledger',
|
|
120
|
-
TREZOR: 'Trezor',
|
|
121
|
-
};
|
|
122
|
-
exports.WALLET_NAMES = WALLET_NAMES;
|
|
123
|
-
// Network IDs
|
|
124
|
-
const NETWORK_IDS = {
|
|
125
|
-
ETHEREUM_MAINNET: 1,
|
|
126
|
-
POLYGON: 137,
|
|
127
|
-
ARBITRUM: 42161,
|
|
128
|
-
OPTIMISM: 10,
|
|
129
|
-
BASE: 8453,
|
|
130
|
-
SOLANA_MAINNET: 'mainnet-beta',
|
|
131
|
-
SOLANA_DEVNET: 'devnet',
|
|
132
|
-
};
|
|
133
|
-
exports.NETWORK_IDS = NETWORK_IDS;
|
|
134
|
-
// Animation Durations
|
|
135
|
-
const ANIMATION = {
|
|
136
|
-
FAST: 150,
|
|
137
|
-
NORMAL: 300,
|
|
138
|
-
SLOW: 500,
|
|
139
|
-
VERY_SLOW: 1000,
|
|
140
|
-
};
|
|
141
|
-
exports.ANIMATION = ANIMATION;
|
|
142
|
-
// Z-Index Layers
|
|
143
|
-
const Z_INDEX = {
|
|
144
|
-
DROPDOWN: 10,
|
|
145
|
-
OVERLAY: 20,
|
|
146
|
-
MODAL: 30,
|
|
147
|
-
POPOVER: 40,
|
|
148
|
-
TOOLTIP: 50,
|
|
149
|
-
TOAST: 60,
|
|
150
|
-
};
|
|
151
|
-
exports.Z_INDEX = Z_INDEX;
|
|
152
|
-
//# sourceMappingURL=application.js.map
|