@microcosmmoney/auth-react 1.1.0 → 1.2.0
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/callback.js
CHANGED
|
@@ -5,6 +5,17 @@ const jsx_runtime_1 = require("react/jsx-runtime");
|
|
|
5
5
|
// AI-generated · AI-managed · AI-maintained
|
|
6
6
|
const react_1 = require("react");
|
|
7
7
|
const provider_1 = require("./provider");
|
|
8
|
+
function isSameOrigin(url) {
|
|
9
|
+
if (url.startsWith('/') && !url.startsWith('//'))
|
|
10
|
+
return true;
|
|
11
|
+
try {
|
|
12
|
+
const parsed = new URL(url, window.location.origin);
|
|
13
|
+
return parsed.origin === window.location.origin;
|
|
14
|
+
}
|
|
15
|
+
catch {
|
|
16
|
+
return false;
|
|
17
|
+
}
|
|
18
|
+
}
|
|
8
19
|
function AuthCallback({ redirectTo = '/dashboard', onSuccess, onError, loadingComponent, errorComponent, }) {
|
|
9
20
|
const { client } = (0, provider_1.useAuth)();
|
|
10
21
|
const [error, setError] = (0, react_1.useState)(null);
|
|
@@ -16,7 +27,8 @@ function AuthCallback({ redirectTo = '/dashboard', onSuccess, onError, loadingCo
|
|
|
16
27
|
if (cancelled)
|
|
17
28
|
return;
|
|
18
29
|
onSuccess?.(user);
|
|
19
|
-
|
|
30
|
+
const safeRedirect = isSameOrigin(redirectTo) ? redirectTo : '/dashboard';
|
|
31
|
+
window.location.href = safeRedirect;
|
|
20
32
|
}
|
|
21
33
|
catch (err) {
|
|
22
34
|
if (cancelled)
|
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.useRefundDeposit = useRefundDeposit;
|
|
4
|
+
// AI-generated · AI-managed · AI-maintained
|
|
5
|
+
const use_auction_refund_1 = require("./use-auction-refund");
|
|
6
|
+
function useRefundDeposit() {
|
|
7
|
+
const { prepareRefund, loading, error } = (0, use_auction_refund_1.useAuctionRefund)();
|
|
8
|
+
return { refundDeposit: prepareRefund, loading, error };
|
|
9
|
+
}
|
package/dist/index.d.ts
CHANGED
|
@@ -93,6 +93,7 @@ export { useAuctionEnd } from './hooks/use-auction-end';
|
|
|
93
93
|
export { useNotifications } from './hooks/use-notifications';
|
|
94
94
|
export { useNotificationAction } from './hooks/use-notification-action';
|
|
95
95
|
export { useTeamCustody } from './hooks/use-team-custody';
|
|
96
|
+
export { useRefundDeposit } from './hooks/use-refund-deposit';
|
|
96
97
|
export { useSolanaWallet } from './hooks/use-solana-wallet';
|
|
97
98
|
export { useMiningFlow } from './hooks/use-mining-flow';
|
|
98
99
|
export { useBuybackFlow } from './hooks/use-buyback-flow';
|
package/dist/index.js
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
3
|
exports.useVoteAction = exports.useAuctionHistory = exports.useAuctionBid = exports.useAuctionCancel = exports.useTerritoryUpdate = exports.useBuybackAction = exports.usePublicMining = exports.useMiningAction = exports.useUserStats = exports.useAuctionDetail = exports.useMyBids = exports.useVotePower = exports.useProposalDetail = exports.useProposals = exports.useTerritoryMembers = exports.useTerritoryStats = exports.useTerritoryDetail = exports.useTerritorySummary = exports.useTerritories = exports.useBuybackHistory = exports.useBuybackQuote = exports.useMCDRewards = exports.useMCDTransactions = exports.useMiningDistribution = exports.useMiningRatio = exports.useMCCLocks = exports.useTokenPortfolio = exports.useWallets = exports.useDashboardSummary = exports.usePriceHistory = exports.useTechTree = exports.useOrganizations = exports.useAuctions = exports.useTerritoryNFTs = exports.useReincarnationPool = exports.useUserLevel = exports.useMiningRecords = exports.useMiningStats = exports.useMCDStats = exports.useMCCStats = exports.useMCCPrice = exports.useApiQuery = exports.useProfile = exports.useMCC = exports.useMCD = exports.RequireRole = exports.withAuth = exports.AuthCallback = exports.useAuth = exports.MicrocosmAuthProvider = void 0;
|
|
4
|
-
exports.useTerritoryNFTAction = exports.useBuybackFlow = exports.useMiningFlow = exports.useSolanaWallet = exports.useTeamCustody = exports.useNotificationAction = exports.useNotifications = exports.useAuctionEnd = exports.useProposalSettle = exports.useManagerIncome = exports.useTerritoryNFTMint = exports.useTerritoryDetailedStats = exports.useDashboardTerritoryStats = exports.useDashboardUserStats = exports.useMCCMiningHistory = exports.useLendingStats = exports.useFragmentConfig = exports.useAuctionConfig = exports.useDashboardMiningHistory = exports.usePlatformStats = exports.useMCCHolders = exports.useLendingPosition = exports.useLendingPool = exports.useFragmentVaultDetail = exports.useFragmentVaults = exports.useTerritoryDistributionPlan = exports.useTerritoryNameStatus = exports.useTerritoryNFTCollection = exports.useTechTreeBonus = exports.useTechTreeConfig = exports.useTechTreeAction = exports.useStationQueue = exports.useStationLeave = exports.useStationJoin = exports.useAuctionBids = exports.useMultiWalletBalance = exports.useOrganizationSummary = exports.useOrganizationTree = exports.useMarketData = exports.useAuctionRefund = exports.useCreateAuction = exports.useTerritoryRanking = exports.useTerritoryKPI = exports.useTerritoryIncome = exports.useCycleHistory = exports.useReincarnationConfig = exports.useMiningHistory = exports.useMiningConfig = exports.useMCCHistory = void 0;
|
|
4
|
+
exports.useTerritoryNFTAction = exports.useBuybackFlow = exports.useMiningFlow = exports.useSolanaWallet = exports.useRefundDeposit = exports.useTeamCustody = exports.useNotificationAction = exports.useNotifications = exports.useAuctionEnd = exports.useProposalSettle = exports.useManagerIncome = exports.useTerritoryNFTMint = exports.useTerritoryDetailedStats = exports.useDashboardTerritoryStats = exports.useDashboardUserStats = exports.useMCCMiningHistory = exports.useLendingStats = exports.useFragmentConfig = exports.useAuctionConfig = exports.useDashboardMiningHistory = exports.usePlatformStats = exports.useMCCHolders = exports.useLendingPosition = exports.useLendingPool = exports.useFragmentVaultDetail = exports.useFragmentVaults = exports.useTerritoryDistributionPlan = exports.useTerritoryNameStatus = exports.useTerritoryNFTCollection = exports.useTechTreeBonus = exports.useTechTreeConfig = exports.useTechTreeAction = exports.useStationQueue = exports.useStationLeave = exports.useStationJoin = exports.useAuctionBids = exports.useMultiWalletBalance = exports.useOrganizationSummary = exports.useOrganizationTree = exports.useMarketData = exports.useAuctionRefund = exports.useCreateAuction = exports.useTerritoryRanking = exports.useTerritoryKPI = exports.useTerritoryIncome = exports.useCycleHistory = exports.useReincarnationConfig = exports.useMiningHistory = exports.useMiningConfig = exports.useMCCHistory = void 0;
|
|
5
5
|
// AI-generated · AI-managed · AI-maintained
|
|
6
6
|
var provider_1 = require("./provider");
|
|
7
7
|
Object.defineProperty(exports, "MicrocosmAuthProvider", { enumerable: true, get: function () { return provider_1.MicrocosmAuthProvider; } });
|
|
@@ -192,6 +192,8 @@ var use_notification_action_1 = require("./hooks/use-notification-action");
|
|
|
192
192
|
Object.defineProperty(exports, "useNotificationAction", { enumerable: true, get: function () { return use_notification_action_1.useNotificationAction; } });
|
|
193
193
|
var use_team_custody_1 = require("./hooks/use-team-custody");
|
|
194
194
|
Object.defineProperty(exports, "useTeamCustody", { enumerable: true, get: function () { return use_team_custody_1.useTeamCustody; } });
|
|
195
|
+
var use_refund_deposit_1 = require("./hooks/use-refund-deposit");
|
|
196
|
+
Object.defineProperty(exports, "useRefundDeposit", { enumerable: true, get: function () { return use_refund_deposit_1.useRefundDeposit; } });
|
|
195
197
|
var use_solana_wallet_1 = require("./hooks/use-solana-wallet");
|
|
196
198
|
Object.defineProperty(exports, "useSolanaWallet", { enumerable: true, get: function () { return use_solana_wallet_1.useSolanaWallet; } });
|
|
197
199
|
var use_mining_flow_1 = require("./hooks/use-mining-flow");
|
|
@@ -45,10 +45,7 @@ function createTokenExchangeHandler(config) {
|
|
|
45
45
|
if (!tokenResponse.ok) {
|
|
46
46
|
const errorData = await safeJson(tokenResponse);
|
|
47
47
|
console.error('[MicrocosmAuth] Token exchange failed:', errorData);
|
|
48
|
-
return jsonResponse({
|
|
49
|
-
error: errorData.error || 'token_error',
|
|
50
|
-
error_description: errorData.error_description || 'Token exchange failed',
|
|
51
|
-
}, tokenResponse.status);
|
|
48
|
+
return jsonResponse({ error: 'token_error', error_description: 'Token exchange failed' }, tokenResponse.status);
|
|
52
49
|
}
|
|
53
50
|
const tokenData = await tokenResponse.json();
|
|
54
51
|
return jsonResponse({
|
|
@@ -60,10 +57,7 @@ function createTokenExchangeHandler(config) {
|
|
|
60
57
|
}
|
|
61
58
|
catch (error) {
|
|
62
59
|
console.error('[MicrocosmAuth] Exchange error:', error);
|
|
63
|
-
return jsonResponse({
|
|
64
|
-
error: 'server_error',
|
|
65
|
-
error_description: error instanceof Error ? error.message : 'Internal server error',
|
|
66
|
-
}, 500);
|
|
60
|
+
return jsonResponse({ error: 'server_error', error_description: 'Internal server error' }, 500);
|
|
67
61
|
}
|
|
68
62
|
};
|
|
69
63
|
}
|
|
@@ -94,7 +88,7 @@ function createProfileHandler(config) {
|
|
|
94
88
|
}
|
|
95
89
|
catch (error) {
|
|
96
90
|
console.error('[MicrocosmAuth] Profile error:', error);
|
|
97
|
-
return jsonResponse({ error: 'server_error', message:
|
|
91
|
+
return jsonResponse({ error: 'server_error', message: 'Internal server error' }, 500);
|
|
98
92
|
}
|
|
99
93
|
};
|
|
100
94
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@microcosmmoney/auth-react",
|
|
3
|
-
"version": "1.
|
|
3
|
+
"version": "1.2.0",
|
|
4
4
|
"description": "Microcosm OAuth 2.0 React/Next.js adapter",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -24,7 +24,7 @@
|
|
|
24
24
|
"react-dom": ">=18.0.0"
|
|
25
25
|
},
|
|
26
26
|
"dependencies": {
|
|
27
|
-
"@microcosmmoney/auth-core": "^1.
|
|
27
|
+
"@microcosmmoney/auth-core": "^1.2.0"
|
|
28
28
|
},
|
|
29
29
|
"devDependencies": {
|
|
30
30
|
"@types/react": "^18.0.0",
|