mirror of
https://gitea.tendokyu.moe/ppc/amnet.git
synced 2026-10-07 22:28:13 +03:00
Compare commits
1
Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
e77f401e0c |
@@ -77,8 +77,7 @@ const Tab = createBottomTabNavigator();
|
|||||||
const Stack = createNativeStackNavigator();
|
const Stack = createNativeStackNavigator();
|
||||||
|
|
||||||
function AppContent() {
|
function AppContent() {
|
||||||
return (
|
return (<Tab.Navigator tabBar={p => <AMUITabBar {...p}/>} screenOptions={{headerShown: false}}>
|
||||||
<Tab.Navigator tabBar={p => <AMUITabBar {...p}/>} screenOptions={{headerShown: false}}>
|
|
||||||
<Tab.Screen name="servers"
|
<Tab.Screen name="servers"
|
||||||
component={ServerManagerStack}
|
component={ServerManagerStack}
|
||||||
options={{tabBarIcon: ({color, size}) => (<Server color={color} size={size}/>)}}/>
|
options={{tabBarIcon: ({color, size}) => (<Server color={color} size={size}/>)}}/>
|
||||||
@@ -86,8 +85,7 @@ function AppContent() {
|
|||||||
<Tab.Screen name="cards"
|
<Tab.Screen name="cards"
|
||||||
component={CardManagerStack}
|
component={CardManagerStack}
|
||||||
options={{tabBarIcon: ({color, size}) => (<WalletCards color={color} size={size}/>)}}/>
|
options={{tabBarIcon: ({color, size}) => (<WalletCards color={color} size={size}/>)}}/>
|
||||||
</Tab.Navigator>
|
</Tab.Navigator>)
|
||||||
)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
export default function AppRoot() {
|
export default function AppRoot() {
|
||||||
|
|||||||
+15
-2
@@ -10,12 +10,25 @@
|
|||||||
"ios": {
|
"ios": {
|
||||||
"bundleIdentifier": "moe.ppc.amnet",
|
"bundleIdentifier": "moe.ppc.amnet",
|
||||||
"supportsTablet": true,
|
"supportsTablet": true,
|
||||||
|
"associatedDomains": [
|
||||||
|
"applinks:card.ppc.moe"
|
||||||
|
],
|
||||||
"infoPlist": {
|
"infoPlist": {
|
||||||
"NSAppTransportSecurity": {
|
"NSAppTransportSecurity": {
|
||||||
"NSAllowsArbitraryLoads": true
|
"NSAllowsArbitraryLoads": true
|
||||||
},
|
},
|
||||||
"UIDesignRequiresCompatibility": true,
|
"UIDesignRequiresCompatibility": true,
|
||||||
"UIViewControllerBasedStatusBarAppearance": false
|
"UIViewControllerBasedStatusBarAppearance": false,
|
||||||
|
"NFCReaderUsageDescription": "AMNet uses NFC to scan Physical IC Cards",
|
||||||
|
"com.apple.developer.nfc.readersession.felica.systemcodes": [
|
||||||
|
"0003",
|
||||||
|
"88b4"
|
||||||
|
]
|
||||||
|
},
|
||||||
|
"entitlements": {
|
||||||
|
"com.apple.developer.nfc.readersession.formats": [
|
||||||
|
"TAG"
|
||||||
|
]
|
||||||
},
|
},
|
||||||
"config": {
|
"config": {
|
||||||
"usesNonExemptEncryption": false
|
"usesNonExemptEncryption": false
|
||||||
@@ -23,7 +36,7 @@
|
|||||||
},
|
},
|
||||||
"android": {
|
"android": {
|
||||||
"package": "moe.ppc.amnet",
|
"package": "moe.ppc.amnet",
|
||||||
"versionCode": 9,
|
"versionCode": 8,
|
||||||
"adaptiveIcon": {
|
"adaptiveIcon": {
|
||||||
"foregroundImage": "./assets/icon-android.png",
|
"foregroundImage": "./assets/icon-android.png",
|
||||||
"backgroundColor": "#DED8FD"
|
"backgroundColor": "#DED8FD"
|
||||||
|
|||||||
@@ -74,7 +74,7 @@ export default function CardManager({navigation}) {
|
|||||||
|
|
||||||
return (
|
return (
|
||||||
<FlatList contentInsetAdjustmentBehavior="always"
|
<FlatList contentInsetAdjustmentBehavior="always"
|
||||||
style={{padding: 16}}
|
style={{padding: 16, paddingTop: 24}}
|
||||||
data={cards}
|
data={cards}
|
||||||
keyExtractor={i => i._id.toString()}
|
keyExtractor={i => i._id.toString()}
|
||||||
contentContainerStyle={{paddingBottom: 120}}
|
contentContainerStyle={{paddingBottom: 120}}
|
||||||
|
|||||||
@@ -1,8 +1,8 @@
|
|||||||
import {BSON} from "realm";
|
import {BSON} from "realm";
|
||||||
import {ActivityIndicator, Button, Text, useTheme} from "react-native-paper";
|
import NfcManager from "react-native-nfc-manager";
|
||||||
import React, {useCallback, useEffect, useLayoutEffect, useMemo, useState} from "react";
|
import React, {useCallback, useEffect, useLayoutEffect, useMemo, useState} from "react";
|
||||||
import {Alert, Platform, RefreshControl, ScrollView, Share, View} from "react-native";
|
import {ActivityIndicator, Button, IconButton, Text, useTheme} from "react-native-paper";
|
||||||
import {useSafeAreaInsets} from "react-native-safe-area-context";
|
import {Alert, Platform, RefreshControl, ScrollView, Share, StyleSheet, View} from "react-native";
|
||||||
import {
|
import {
|
||||||
CircleCheck,
|
CircleCheck,
|
||||||
CircleDot,
|
CircleDot,
|
||||||
@@ -13,6 +13,7 @@ import {
|
|||||||
WifiOff,
|
WifiOff,
|
||||||
TvMinimalPlay,
|
TvMinimalPlay,
|
||||||
Star,
|
Star,
|
||||||
|
SmartphoneNfc,
|
||||||
SquareArrowOutUpRight
|
SquareArrowOutUpRight
|
||||||
} from "lucide-react-native";
|
} from "lucide-react-native";
|
||||||
|
|
||||||
@@ -25,6 +26,7 @@ import RealmContext from "../models/RealmContext";
|
|||||||
import {AMServer} from "../models/AMServer";
|
import {AMServer} from "../models/AMServer";
|
||||||
import {AMCard} from "../models/AMCard";
|
import {AMCard} from "../models/AMCard";
|
||||||
|
|
||||||
|
import {felicaCardReadAsync, icCard0008Number, ICType} from "../lib/iccard";
|
||||||
import {
|
import {
|
||||||
AMCardInRequest,
|
AMCardInRequest,
|
||||||
AMServerConnectionInfo,
|
AMServerConnectionInfo,
|
||||||
@@ -42,8 +44,7 @@ const {useRealm, useQuery, useObject} = RealmContext;
|
|||||||
|
|
||||||
export default function ServerCardIn({route, navigation}) {
|
export default function ServerCardIn({route, navigation}) {
|
||||||
const realm = useRealm();
|
const realm = useRealm();
|
||||||
const theme = useTheme();
|
const theme = useTheme()
|
||||||
const insets = useSafeAreaInsets();
|
|
||||||
|
|
||||||
const {serverId} = route.params;
|
const {serverId} = route.params;
|
||||||
const server = useObject(AMServer, ObjectId.createFromHexString(serverId));
|
const server = useObject(AMServer, ObjectId.createFromHexString(serverId));
|
||||||
@@ -81,6 +82,16 @@ export default function ServerCardIn({route, navigation}) {
|
|||||||
}
|
}
|
||||||
}, [realm, server, navigation]);
|
}, [realm, server, navigation]);
|
||||||
|
|
||||||
|
// nfc support
|
||||||
|
const [nfcSupported, setNfcSupported] = useState<boolean | null>(Platform.select({android: false, default: null}));
|
||||||
|
useEffect(() => {
|
||||||
|
if (nfcSupported !== null) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
NfcManager.isSupported().then(setNfcSupported);
|
||||||
|
}, []);
|
||||||
|
|
||||||
// server state
|
// server state
|
||||||
const [serverRefreshing, setServerRefreshing] = useState<boolean>(false);
|
const [serverRefreshing, setServerRefreshing] = useState<boolean>(false);
|
||||||
const [serverReloadCounter, setServerReloadCounter] = useState<number>(0);
|
const [serverReloadCounter, setServerReloadCounter] = useState<number>(0);
|
||||||
@@ -90,6 +101,7 @@ export default function ServerCardIn({route, navigation}) {
|
|||||||
const [cardInCompleted, setCardInCompleted] = useState<boolean | null>(null);
|
const [cardInCompleted, setCardInCompleted] = useState<boolean | null>(null);
|
||||||
|
|
||||||
const disableCardIn = useMemo(() => cardInCompleted !== null || !serverConnectionSuccess, [cardInCompleted, serverConnectionSuccess]);
|
const disableCardIn = useMemo(() => cardInCompleted !== null || !serverConnectionSuccess, [cardInCompleted, serverConnectionSuccess]);
|
||||||
|
|
||||||
const serverDefaultCard = useMemo(() => {
|
const serverDefaultCard = useMemo(() => {
|
||||||
if (server?.isValid() !== true || !server.gameId) {
|
if (server?.isValid() !== true || !server.gameId) {
|
||||||
return null;
|
return null;
|
||||||
@@ -199,6 +211,38 @@ export default function ServerCardIn({route, navigation}) {
|
|||||||
return () => abortController.abort();
|
return () => abortController.abort();
|
||||||
}, [server]);
|
}, [server]);
|
||||||
|
|
||||||
|
const performPhysicalCardIn = useCallback(async () => {
|
||||||
|
const card = await felicaCardReadAsync();
|
||||||
|
|
||||||
|
if (!card) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
const savedCard = cards.find(x => x.physicalCardData?.cardIDm === card.idm);
|
||||||
|
|
||||||
|
if (savedCard) {
|
||||||
|
setUserSelectedCard(savedCard);
|
||||||
|
cardInCallback(savedCard);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
setCardInCompleted(false);
|
||||||
|
|
||||||
|
const cardId = card.type !== ICType.Amusement ? icCard0008Number(card.idm) : card.accessCode;
|
||||||
|
const abortController = new AbortController();
|
||||||
|
|
||||||
|
performCardIn(server, {cardId, physicalCardIDm: card.idm}, abortController.signal).then(r => {
|
||||||
|
setCardInCompleted(r);
|
||||||
|
}).catch(() => {
|
||||||
|
setCardInCompleted(false);
|
||||||
|
}).finally(() => {
|
||||||
|
setTimeout(() => setCardInCompleted(null), 3000);
|
||||||
|
});
|
||||||
|
|
||||||
|
setTimeout(() => abortController.abort(), 5000);
|
||||||
|
return () => abortController.abort();
|
||||||
|
}, [server]);
|
||||||
|
|
||||||
const performRefresh = () => {
|
const performRefresh = () => {
|
||||||
setServerRefreshing(true);
|
setServerRefreshing(true);
|
||||||
setServerReloadCounter(serverReloadCounter + 1);
|
setServerReloadCounter(serverReloadCounter + 1);
|
||||||
@@ -218,7 +262,7 @@ export default function ServerCardIn({route, navigation}) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<ScrollView contentInsetAdjustmentBehavior="always"
|
<ScrollView contentInsetAdjustmentBehavior="automatic"
|
||||||
refreshControl={<RefreshControl refreshing={serverRefreshing} onRefresh={performRefresh}/>}>
|
refreshControl={<RefreshControl refreshing={serverRefreshing} onRefresh={performRefresh}/>}>
|
||||||
<View style={styles.container}>
|
<View style={styles.container}>
|
||||||
<StatusAlert server={server} connectionEstablished={serverConnectionSuccess}/>
|
<StatusAlert server={server} connectionEstablished={serverConnectionSuccess}/>
|
||||||
@@ -230,6 +274,7 @@ export default function ServerCardIn({route, navigation}) {
|
|||||||
actionIcon={<CircleCheck color="green" size={24}/>}>
|
actionIcon={<CircleCheck color="green" size={24}/>}>
|
||||||
{serverDefaultCard?.code == selectedCard.code && <DefaultCardDetail/>}
|
{serverDefaultCard?.code == selectedCard.code && <DefaultCardDetail/>}
|
||||||
</ICCard>
|
</ICCard>
|
||||||
|
<View style={{display: "flex", flexDirection: "row", gap: 5}}>
|
||||||
<Button style={{flex: 1}}
|
<Button style={{flex: 1}}
|
||||||
textColor="white"
|
textColor="white"
|
||||||
disabled={disableCardIn}
|
disabled={disableCardIn}
|
||||||
@@ -237,9 +282,20 @@ export default function ServerCardIn({route, navigation}) {
|
|||||||
mode={serverConnectionSuccess ? "contained" : "outlined"}
|
mode={serverConnectionSuccess ? "contained" : "outlined"}
|
||||||
buttonColor={cardInCompleted === false ? "red" : "green"}
|
buttonColor={cardInCompleted === false ? "red" : "green"}
|
||||||
onPress={() => cardInCallback(selectedCard)}
|
onPress={() => cardInCallback(selectedCard)}
|
||||||
icon={() => <SquareArrowOutUpRight color={disableCardIn ? "gray" : "white"} size={18}/>}>
|
icon={() => <SquareArrowOutUpRight color={disableCardIn ? "gray" : "white"}
|
||||||
|
size={18}/>}>
|
||||||
{cardInCompleted === null ? "Card In" : cardInCompleted ? "Card In Success" : "Failed"}
|
{cardInCompleted === null ? "Card In" : cardInCompleted ? "Card In Success" : "Failed"}
|
||||||
</Button>
|
</Button>
|
||||||
|
{nfcSupported === true && (
|
||||||
|
<IconButton
|
||||||
|
mode="outlined"
|
||||||
|
disabled={disableCardIn}
|
||||||
|
onPress={performPhysicalCardIn}
|
||||||
|
style={{borderRadius: 10, margin: 0, height: "100%", flex: 0.2}}
|
||||||
|
icon={() => <SmartphoneNfc
|
||||||
|
color={disableCardIn ? "gray" : theme.colors.onBackground} size={18}/>}/>
|
||||||
|
)}
|
||||||
|
</View>
|
||||||
</>
|
</>
|
||||||
: <View style={styles.emptyPlaceholderView}>
|
: <View style={styles.emptyPlaceholderView}>
|
||||||
<EmptyStatePlaceholder message="No card selected" icon={<CreditCard color="gray"/>}/>
|
<EmptyStatePlaceholder message="No card selected" icon={<CreditCard color="gray"/>}/>
|
||||||
@@ -273,7 +329,8 @@ export default function ServerCardIn({route, navigation}) {
|
|||||||
{serverDefaultCard?.code == card.code && <DefaultCardDetail/>}
|
{serverDefaultCard?.code == card.code && <DefaultCardDetail/>}
|
||||||
</ICCard>))
|
</ICCard>))
|
||||||
: <View style={styles.emptyPlaceholderView}>
|
: <View style={styles.emptyPlaceholderView}>
|
||||||
<EmptyStatePlaceholder message="No additional cards" icon={<SmartphoneNfcIcon color="gray"/>}/>
|
<EmptyStatePlaceholder message="No additional cards"
|
||||||
|
icon={<SmartphoneNfcIcon color="gray"/>}/>
|
||||||
</View>}
|
</View>}
|
||||||
</View>)}
|
</View>)}
|
||||||
</View>
|
</View>
|
||||||
@@ -347,21 +404,21 @@ const menuActions: MenuAction[] = [
|
|||||||
}
|
}
|
||||||
];
|
];
|
||||||
|
|
||||||
const styles = {
|
const styles = StyleSheet.create({
|
||||||
section: {
|
section: {
|
||||||
gap: 10
|
gap: 10
|
||||||
},
|
},
|
||||||
sectionTitle: {
|
sectionTitle: {
|
||||||
fontWeight: "bold" as const
|
fontWeight: "bold"
|
||||||
},
|
},
|
||||||
emptyPlaceholderView: {
|
emptyPlaceholderView: {
|
||||||
marginVertical: 30,
|
marginVertical: 30,
|
||||||
gap: 15
|
gap: 15
|
||||||
},
|
},
|
||||||
container: {
|
container: {
|
||||||
paddingTop: Platform.select({android: 18, default: 0}),
|
paddingTop: Platform.select({android: 120, default: 0}),
|
||||||
paddingHorizontal: 16,
|
paddingHorizontal: 16,
|
||||||
paddingBottom: 80,
|
paddingBottom: 80,
|
||||||
gap: 20
|
gap: 20
|
||||||
}
|
}
|
||||||
};
|
});
|
||||||
|
|||||||
@@ -91,7 +91,7 @@ export default function ServerManager({navigation}) {
|
|||||||
<FlatList contentInsetAdjustmentBehavior="always"
|
<FlatList contentInsetAdjustmentBehavior="always"
|
||||||
data={servers}
|
data={servers}
|
||||||
keyExtractor={i => i._id.toString()}
|
keyExtractor={i => i._id.toString()}
|
||||||
style={{padding: 16}}
|
style={{padding: 16, paddingTop: 24}}
|
||||||
contentContainerStyle={{paddingBottom: 80}}
|
contentContainerStyle={{paddingBottom: 80}}
|
||||||
renderItem={i => <ServerCard navigation={navigation} server={i.item}/>}
|
renderItem={i => <ServerCard navigation={navigation} server={i.item}/>}
|
||||||
ItemSeparatorComponent={() => <View style={{height: 15}}/>}
|
ItemSeparatorComponent={() => <View style={{height: 15}}/>}
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ export default function ServerManagerStack({navigation}) {
|
|||||||
headerRight: () => Platform.OS === 'android' ? null : <TouchableOpacity onPress={() => navigation.navigate('add-server')}><Plus color={theme.colors.primary}/></TouchableOpacity>
|
headerRight: () => Platform.OS === 'android' ? null : <TouchableOpacity onPress={() => navigation.navigate('add-server')}><Plus color={theme.colors.primary}/></TouchableOpacity>
|
||||||
}}/>
|
}}/>
|
||||||
|
|
||||||
<Stack.Screen name="server" options={{title: "Server", headerTransparent: Platform.select({default: false, ios: true})}} component={ServerCardIn}/>
|
<Stack.Screen name="server" options={{title: "Server", headerTransparent: true}} component={ServerCardIn}/>
|
||||||
</Stack.Group>
|
</Stack.Group>
|
||||||
</Stack.Navigator>
|
</Stack.Navigator>
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -1,12 +1,15 @@
|
|||||||
import React from "react";
|
|
||||||
import {StatusBar} from "expo-status-bar";
|
import {StatusBar} from "expo-status-bar";
|
||||||
|
import NfcManager from "react-native-nfc-manager";
|
||||||
|
|
||||||
|
import React, {useEffect, useState} from "react";
|
||||||
import {Platform, TouchableOpacity, View} from "react-native";
|
import {Platform, TouchableOpacity, View} from "react-native";
|
||||||
import {createNativeStackNavigator} from "@react-navigation/native-stack";
|
import {createNativeStackNavigator} from "@react-navigation/native-stack";
|
||||||
|
|
||||||
import {Card, Text, useTheme} from "react-native-paper";
|
import {Card, Text, useTheme} from "react-native-paper";
|
||||||
import {SquareAsterisk, SquarePlus} from "lucide-react-native";
|
import {ShieldBan, SmartphoneNfc, SquareAsterisk, SquarePlus} from "lucide-react-native";
|
||||||
|
|
||||||
import ManualCardEntry from "./ManualCardEntry";
|
import ManualCardEntry from "./ManualCardEntry";
|
||||||
|
import PhysicalCardScan from "./PhyscialCardScan";
|
||||||
|
|
||||||
const Stack = createNativeStackNavigator();
|
const Stack = createNativeStackNavigator();
|
||||||
|
|
||||||
@@ -15,6 +18,7 @@ function CardAddModal() {
|
|||||||
<Stack.Navigator initialRouteName="Select" screenOptions={{headerTitleStyle: {fontWeight: "bold"}}}>
|
<Stack.Navigator initialRouteName="Select" screenOptions={{headerTitleStyle: {fontWeight: "bold"}}}>
|
||||||
<Stack.Screen name="Select" component={CardAddMethodSelector} options={{headerShown: false}}/>
|
<Stack.Screen name="Select" component={CardAddMethodSelector} options={{headerShown: false}}/>
|
||||||
|
|
||||||
|
<Stack.Screen name="Scan" component={PhysicalCardScan} options={{title: "Add Physical Card"}}/>
|
||||||
<Stack.Screen name="Manual" component={ManualCardEntry} options={{title: "Add Card Manually"}}/>
|
<Stack.Screen name="Manual" component={ManualCardEntry} options={{title: "Add Card Manually"}}/>
|
||||||
</Stack.Navigator>
|
</Stack.Navigator>
|
||||||
)
|
)
|
||||||
@@ -22,6 +26,11 @@ function CardAddModal() {
|
|||||||
|
|
||||||
function CardAddMethodSelector({navigation}) {
|
function CardAddMethodSelector({navigation}) {
|
||||||
const theme = useTheme();
|
const theme = useTheme();
|
||||||
|
const [nfcSupported, setNfcSupported] = useState<boolean | null>(null);
|
||||||
|
|
||||||
|
useEffect(() => {
|
||||||
|
NfcManager.isSupported().then(setNfcSupported);
|
||||||
|
}, []);
|
||||||
|
|
||||||
return (
|
return (
|
||||||
<>
|
<>
|
||||||
@@ -36,6 +45,19 @@ function CardAddMethodSelector({navigation}) {
|
|||||||
</Text>
|
</Text>
|
||||||
</View>
|
</View>
|
||||||
|
|
||||||
|
{nfcSupported !== null && (
|
||||||
|
<>
|
||||||
|
<MethodCard title="Scan Physical Card"
|
||||||
|
disabled={!nfcSupported}
|
||||||
|
color={nfcSupported ? "#03a9f4" : "gray"}
|
||||||
|
icon={nfcSupported ? <SmartphoneNfc/> : <ShieldBan/>}
|
||||||
|
description={nfcSupported ? "Amusement IC or Transport cards supported" : "NFC is not supported on this device"}
|
||||||
|
onPress={() => navigation.navigate('Scan')}/>
|
||||||
|
|
||||||
|
<View></View>
|
||||||
|
</>
|
||||||
|
)}
|
||||||
|
|
||||||
<MethodCard color={theme.colors.secondary}
|
<MethodCard color={theme.colors.secondary}
|
||||||
icon={<SquareAsterisk/>}
|
icon={<SquareAsterisk/>}
|
||||||
title="Enter Details Manually"
|
title="Enter Details Manually"
|
||||||
@@ -84,7 +106,8 @@ function MethodCard(props: {
|
|||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// the nfc library doesn't offer the same support for felica cards on android compared to ios...
|
||||||
export default Platform.select({
|
export default Platform.select({
|
||||||
default: ManualCardEntry,
|
ios: CardAddModal,
|
||||||
ios: CardAddModal
|
default: ManualCardEntry
|
||||||
});
|
});
|
||||||
@@ -0,0 +1,87 @@
|
|||||||
|
import {StatusBar} from "expo-status-bar";
|
||||||
|
import {useNavigation} from "@react-navigation/native";
|
||||||
|
import {Card, Text, useTheme} from "react-native-paper";
|
||||||
|
import {useCallback, useLayoutEffect, useState} from "react";
|
||||||
|
import {Platform, TextInput, TouchableOpacity, View} from "react-native";
|
||||||
|
|
||||||
|
import RealmContext from "../../models/RealmContext";
|
||||||
|
import {useModalStyles} from "../../utils/ModalStyles";
|
||||||
|
|
||||||
|
import {AMCard} from "../../models/AMCard";
|
||||||
|
import {AMPhysicalCardData} from "../../models/AMPhysicalCardData";
|
||||||
|
import {felicaCardReadAsync, icCard0008Number, ICType} from "../../lib/iccard";
|
||||||
|
|
||||||
|
const {useRealm} = RealmContext;
|
||||||
|
|
||||||
|
export default function PhysicalCardScan() {
|
||||||
|
const realm = useRealm();
|
||||||
|
const theme = useTheme();
|
||||||
|
const navigation = useNavigation();
|
||||||
|
const modalStyles = useModalStyles();
|
||||||
|
|
||||||
|
const [cardName, setCardName] = useState<string>('');
|
||||||
|
|
||||||
|
const handleScan = useCallback(async () => {
|
||||||
|
const cardInfo = await felicaCardReadAsync();
|
||||||
|
|
||||||
|
if (!cardInfo) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
realm.write(() => {
|
||||||
|
// check if the card has already been registered (convert a manually entered card to a physically scanned card)
|
||||||
|
const accessCode = cardInfo.type === ICType.Amusement ? cardInfo.accessCode : icCard0008Number(cardInfo.idm);
|
||||||
|
const cardEntity = realm.objects<AMCard>(AMCard.schema.name).find(x => x.code === accessCode) ?? realm.create<AMCard>(AMCard.schema.name, AMCard.generate(accessCode, cardName));
|
||||||
|
|
||||||
|
// set physical card props
|
||||||
|
cardEntity.name = cardName;
|
||||||
|
cardEntity.added = new Date();
|
||||||
|
cardEntity.physicalCardData ??= realm.objectForPrimaryKey<AMPhysicalCardData>(AMPhysicalCardData.schema.name, cardInfo.idm) ?? realm.create<AMPhysicalCardData>(AMPhysicalCardData.schema.name, {
|
||||||
|
cardIDm: cardInfo.idm,
|
||||||
|
cardType: cardInfo.type,
|
||||||
|
cardVendor: cardInfo.type === ICType.Amusement ? cardInfo.vendor : null
|
||||||
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
// dismiss the parent screen (this screen can only be accessed from modal -> stack)
|
||||||
|
navigation.getParent()?.goBack();
|
||||||
|
}, [realm, navigation, cardName]);
|
||||||
|
|
||||||
|
useLayoutEffect(() => {
|
||||||
|
const canSave = cardName.length;
|
||||||
|
const themeOptions = canSave ? modalStyles.headerText : {color: theme.colors.outline};
|
||||||
|
|
||||||
|
navigation.setOptions({
|
||||||
|
headerRight: () => <TouchableOpacity disabled={!canSave} onPress={() => handleScan()}>
|
||||||
|
<Text variant="bodyMedium" style={{...themeOptions}}>Scan</Text>
|
||||||
|
</TouchableOpacity>
|
||||||
|
})
|
||||||
|
}, [navigation, modalStyles, cardName]);
|
||||||
|
|
||||||
|
return (<>
|
||||||
|
{Platform.OS == 'ios' && <StatusBar style="light"/>}
|
||||||
|
<View style={modalStyles.rootLayout}>
|
||||||
|
<Card mode="contained">
|
||||||
|
<Card.Content>
|
||||||
|
<View style={modalStyles.formItemRow}>
|
||||||
|
<Text variant="bodyMedium" style={modalStyles.formItemName}>
|
||||||
|
Card Name
|
||||||
|
</Text>
|
||||||
|
<TextInput style={modalStyles.formItemInput}
|
||||||
|
autoFocus
|
||||||
|
numberOfLines={1}
|
||||||
|
value={cardName}
|
||||||
|
onChangeText={setCardName}
|
||||||
|
placeholder="Primary Card"
|
||||||
|
placeholderTextColor={theme.colors.outline}/>
|
||||||
|
</View>
|
||||||
|
</Card.Content>
|
||||||
|
</Card>
|
||||||
|
|
||||||
|
<Text variant="bodyMedium" style={modalStyles.formFootnote}>
|
||||||
|
Ensure you have either an Amusement IC or Transport card ready to scan.
|
||||||
|
After the scan has completed, the card will be saved to your device.
|
||||||
|
</Text>
|
||||||
|
</View>
|
||||||
|
</>)
|
||||||
|
}
|
||||||
@@ -0,0 +1,49 @@
|
|||||||
|
import {Buffer} from "buffer";
|
||||||
|
|
||||||
|
const s_box_inv = [
|
||||||
|
"243cba36e385a4d0934373b9706ec9f1100e9b2c97e70b636c2920fe86f3e1f5f69fb616047b8fabb1392a1beb5ca8ac3811125f893e7dcaec53db6d1ed281789646fff9541c287a4fd3c0dcc16af2bccb57fd4ae4f0b2c79540625241e2ad49a6b51f02c8da92e5b0c564764821de0f45584cdfa784cfd5154e27806b7ffc44714722dd300ca13be037a03523903274bf8dc2ead650bbd9c483b43168558b5df47218b7eff7982d010361cc0a8e1300e814af095175a52f1d0d658acd66073d05d84be99d997c91d1b819c32b426988c679173a4d5ba25afb253fbdf8edcee687a326a92ebe94087e67608c9c5e6fb39e06fa82aeee5977d71a9a34d456aa33",
|
||||||
|
"f9817c00b93037d590516ef0b206fbcd39145ff81bc74a82708c921deac34ec812e6b610d32f95842542a572e58f55ef86a253aeed262047de786828e445cc35bc3ebb8ec0be34afa60964017b44f5f3b13fa4b33280c94f6f40bf214c74e1115eeb3d712e9d6275d41648771367ad6b5d0787f7a89a59768b9b1ed8eeaae9992dc597f1a783fccadcbab84be88917050ba06523d1ce3603d7e0f291df0e9c2c0d66d673585cb40a4dc23bd2b7e2ac33db6027bd56432404028d7d7ff6b5f4fddd5bec79c4221fa18854e71998947e31a329e35acb6ab0cf6d936c7a08a93c1cd06350c68538c14149ab61522a9fd9181a57462b69dafaff0f15963a8afe9e0c",
|
||||||
|
"11a29ac394a051015bf7d130ee1f06d57767d3c16ee76a1aa48e9f6566d60c2dc6e469b7565a5760fc791ee11652f007d0cdca78c98bb38827f6e0c084cf2fa304008040a7fa759d4b89462228373413ff20b4da08266c8ff25d7b735c4c9071418a9ebb12e8556d2a254aafbd9519a531baadd9c5a66b83c4b6a9ccf9a1b17adcc7db2e7e7f8d4e620f0339fdb8d418c2ec6102531c3b7dbc1d59f58c98f16f9385f82c74d85e4d97ab87820a21425f0d5833443adde9fb5047c8d7819be51b1754862beff429320e7c2315ebe63c35e296683f0b43cede9cbe4f457276b510e3df92d2a84891b9acbf49b2996470eaf33e6314aeedaa24fe3dcbb009383605",
|
||||||
|
"c4f02849554af5fd75af2069c843866bc9a8c6544cdd025be89b597734d7c0515ff37ed4f19081ce198a7833cd978cd66a4b8fa480dc1a1714c5078766ad9d85b2f88d98df3e1f3f645840ac6c5c085d53baffd2a92c25abe432389af9cbc29167d0e322292d9248b40e9905a36f0a15efd5104fd8f600e6462b31578394ae03eb8e1324a11e5ed126d9a7ca366e7137eeb1fa7c7606b823be21bc9ec1da7a3b62277bb0e56318827f0feda02a9cbf11bde0880d3a795256f7b6d309161b70b342602f1ca29f72124547bbe10b018b1ddeec0c4ee9cfcc9574f4a593c7db4dfb3565fee739b5ea96c304414484fc6d30e2f268b7897d733db95a50a63c61aa2e",
|
||||||
|
"1a599cadc8e41154ed370f3ae65f3c4bb81589b1e8da697791568bdb0624cf18f8b087df8c35cb86539da4664a7a710a4838ffdc8320ce9832f6d7af705e738a14721ec129790708e94346d02fde2a4f3d2c50b375fc0b64ae317b61a530a093d2bec255ba6cf36268fdac3b95491f6bb485f7a603ec6e9a81090c6aee9e4ef0ab2d7ea1e1bbc9bc41f2fa2e1bdd2734d36004b501d640f9d50247d9d8e08f2bfbb7c5eb5716e5788df400cd8239c696bdbfe336450e261d63e7843eb69b22a3f58e236dc3997d9097102580d44ce274ccb25c33c7ea05123f51a8fef11c42cad176286f92a767a919a2445baaef587f21c08865b95d4d0d5ac413527c9f9417",
|
||||||
|
"c72b82615bd09684d34a70a19b59339fc02014532917c50bc97b97020d3a1e7c3f6b52e8753df6e40c8a4fc35f2665733123284874aaa73609b1e291045122fc08a605a4f1121c19eb4037c2a0411dd4dc07438f47afd12e98ab01baf06668acf9e769b6cb8d78871503d5dfa31a9d6aea2f944e9e42d7b83892d8bbdedd9abcb04c79f4583ee98381ffe355fd5db2ef9c6d549960da3becfa11d6c42aed4bae13bfb9068be01f7f5aad90390ff3bd466c2cf2f8fed9e6720e89be5ec6a8cff5577e8cb7e1887ac81b18db6f35d216326463a58ef7b47695867de5a95c8500c1934dfb30a2b5253410773c67712d4445560a50b3cd6280ce214924caee276ecc",
|
||||||
|
"a5b06db251551fbf3e8ddd1992ea1bbd326529a48967b1906800da0da65954f210142f45e03b23fad750ac93e643010a5c78709846a97bf395072ad374b33fa36082394e3448c01cf6c291644d3cf89d359a94e37af0f96eb912b8042d02281385728087db2bf14f26a2e1497e9ccca7b6a0d09b3677ad8b6b4a031d058a064bafe531b5d4c60c66ba83fd090fae71b76fdc41e8178e407f6230ffa88425fb16ce3744ab991eeb183a47f75f81cfed582c6cfe9e57539720ca791a5a88f5699fe7d90ebe42df56e44c22aa730b15c5eefcc7d6cbcd8ce27621e9d1ecc87dd88f617c2ebcdeb475d2c4633da15e5d6a0824c927bbef33865bd5385211f4c396c1",
|
||||||
|
"345adb2c5957122b30c2a092bfedbc45de279b96d3e6c5ebd8244ba421cca8d6ce3cbab109e0d732664a831d19ca89670f420771e9bb445e8517c4ae9c3f6b78e76d02a7fe33e3d90a7deaf118877b6203795223003e25b9dd16683b1f90a62ac629918a9def1e8476ee4f39fb111b0b93ad49b705e14dcbe838d055f2f70d8b65cdfad49ec9814e14c826b6f9aaf580f86a98ab58f3b88eb5974372a2da64c1405c13b0e5bd089f1c7e8f06be6e501a2f37a1fc102e705304206348e2fd6f7a7561b3353acf5b888251d247a5a9746c31947c9ac0ec150e28012dc3f0b4e48ddcac3d5f86c79522f4b2a35446d1778c0cffaf565d36697f994cd56073df41f6",
|
||||||
|
"04da79631ebdeae30b652501cda992ed187557308903096adcc798a450911fb10c778566ca121c67c2e01783599dd5228256a89fc66048b311fca328fb06dd5dba297a4fe8fee910cbf3937b6c6954e744a2841d8dcefffa1a879074a1f814aabcc0cf31b4d9bfd85e262dd0e43f19d68c2fab3958726edf3be63cb66288de40b28f9b7c9543d19eac9cd423e10e4b5333462013341b97f7f1c3614a6f5a217f702e554105c5d776e52715ec425c4d78358befd2eeb5beae023ad35fc424f0f9514eeb000ffdaf3ec19a528681807ef62bccb97d68f2ad99a7072c7338b06bb78e71a0f43da60d37db0a473616966d322a5be24594f5a54cc88a4964bb08c9b8"
|
||||||
|
];
|
||||||
|
|
||||||
|
function rotate_right(data: Uint8Array, nBytes: number, nBits: number) {
|
||||||
|
let prior = data[nBytes - 1];
|
||||||
|
|
||||||
|
for (let i = 0; i < nBytes; i++) {
|
||||||
|
let current = data[i];
|
||||||
|
|
||||||
|
data[i] = (current >> nBits) | ((prior & ((1 << nBits) - 1)) << (8 - nBits));
|
||||||
|
prior = current;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
const S_BOX_INV = s_box_inv.map(x => new Uint8Array(Buffer.from(x, 'hex')));
|
||||||
|
const N_TABLES = S_BOX_INV.length - 1;
|
||||||
|
const ITER_ADD = 5;
|
||||||
|
|
||||||
|
export function performDecrypt(data: Uint8Array) {
|
||||||
|
const spad = data.map(x => S_BOX_INV[N_TABLES][x]);
|
||||||
|
|
||||||
|
let count = (spad[15] >> 4) + 7;
|
||||||
|
let table = spad[15] + ITER_ADD * count;
|
||||||
|
|
||||||
|
for (let z = 0; z < count; z++) {
|
||||||
|
table -= ITER_ADD;
|
||||||
|
rotate_right(spad, 15, 5);
|
||||||
|
|
||||||
|
for (let i = 0; i < 15; i++) {
|
||||||
|
spad[i] = S_BOX_INV[table % N_TABLES][spad[i]];
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
version: spad[0],
|
||||||
|
accessCodeBytes: spad.slice(6) // access code is a binary-coded decimal
|
||||||
|
};
|
||||||
|
}
|
||||||
@@ -1,3 +1,8 @@
|
|||||||
|
import {Buffer} from "buffer";
|
||||||
|
import NfcManager, {NfcTech} from "react-native-nfc-manager";
|
||||||
|
|
||||||
|
import {performDecrypt} from "./iccard-crypto";
|
||||||
|
|
||||||
export enum ICType {
|
export enum ICType {
|
||||||
Amusement = 1,
|
Amusement = 1,
|
||||||
Transport = 2
|
Transport = 2
|
||||||
@@ -36,3 +41,92 @@ export function icCard0008Number(idm: string): string {
|
|||||||
// 0008 is the numerical representation of the idm padded with zeros until it is 20 digits
|
// 0008 is the numerical representation of the idm padded with zeros until it is 20 digits
|
||||||
return BigInt(`0x${idm}`).toString().padStart(20, '0');
|
return BigInt(`0x${idm}`).toString().padStart(20, '0');
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Reads a FeliCa card, returning access code information.
|
||||||
|
*/
|
||||||
|
export async function felicaCardReadAsync(): Promise<ICCard | null> {
|
||||||
|
try {
|
||||||
|
await NfcManager.requestTechnology(NfcTech.FelicaIOS, {
|
||||||
|
isReaderModeEnabled: true,
|
||||||
|
invalidateAfterFirstRead: false,
|
||||||
|
alertMessage: "Hold an Amusement IC or Transport card to the top of your phone to scan it."
|
||||||
|
});
|
||||||
|
|
||||||
|
const tag = await NfcManager.getTag();
|
||||||
|
const idm = tag['idm'] as string;
|
||||||
|
|
||||||
|
switch (tag['systemCode'] as string) {
|
||||||
|
case "0003":
|
||||||
|
return {
|
||||||
|
type: ICType.Transport,
|
||||||
|
idm
|
||||||
|
};
|
||||||
|
|
||||||
|
case "88B4":
|
||||||
|
return await readAmusementICCardContents(idm);
|
||||||
|
|
||||||
|
default:
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
} catch (ex) {
|
||||||
|
return null;
|
||||||
|
} finally {
|
||||||
|
await NfcManager.cancelTechnologyRequest();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
async function readAmusementICCardContents(idm: string): Promise<AmusementICCard | null> {
|
||||||
|
const idmBytes = Uint8Array.from(Buffer.from(idm, 'hex'));
|
||||||
|
const readCommand = [
|
||||||
|
0x06, // read
|
||||||
|
...idmBytes,
|
||||||
|
0x01, // service count (fixed)
|
||||||
|
0x0B, 0x00, // service code (000b, le)
|
||||||
|
0x02, // block count
|
||||||
|
0x80, 0x00, // S_PAD0 block
|
||||||
|
0x80, 0x82 // ID block
|
||||||
|
];
|
||||||
|
|
||||||
|
let response = await NfcManager.sendFelicaCommandIOS(readCommand);
|
||||||
|
const offset = response.indexOf(0x07); // look for 0x07 as for some reason the response may not start at response[0]
|
||||||
|
|
||||||
|
// response must have 44 bytes
|
||||||
|
if (offset === -1 || response.length - offset !== 44) {
|
||||||
|
return null;
|
||||||
|
} else if (offset !== 0) {
|
||||||
|
response = response.slice(offset);
|
||||||
|
}
|
||||||
|
|
||||||
|
// response format:
|
||||||
|
// 0 - read response (0x07)
|
||||||
|
// 1-8 - IDm
|
||||||
|
// 9 - status flag 1
|
||||||
|
// 10 - status flag 2
|
||||||
|
// 11 - number of blocks (0x02)
|
||||||
|
// 12-27 - S_PAD0 block
|
||||||
|
// 28-43 - ID block (DFC is 35-36)
|
||||||
|
|
||||||
|
if (response[9] !== 0x00 || response[11] !== 0x02) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
const dfcValue = response[37] | (response[36] << 8);
|
||||||
|
|
||||||
|
if (dfcValue in AmusementICVendor && dfcValue !== AmusementICVendor.Unknown) {
|
||||||
|
const accessCode = performDecrypt(new Uint8Array(response.slice(12, 28)));
|
||||||
|
return {
|
||||||
|
type: ICType.Amusement,
|
||||||
|
accessCode: [...accessCode.accessCodeBytes].map(x => x.toString(16).padStart(2, '0')).join(''),
|
||||||
|
vendor: dfcValue,
|
||||||
|
idm
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
return {
|
||||||
|
type: ICType.Amusement,
|
||||||
|
accessCode: icCard0008Number(idm),
|
||||||
|
vendor: AmusementICVendor.Unknown,
|
||||||
|
idm
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|||||||
Generated
+24
-8
@@ -1,12 +1,12 @@
|
|||||||
{
|
{
|
||||||
"name": "amnet-native",
|
"name": "amnet-native",
|
||||||
"version": "1.3.9",
|
"version": "1.3.2",
|
||||||
"lockfileVersion": 3,
|
"lockfileVersion": 3,
|
||||||
"requires": true,
|
"requires": true,
|
||||||
"packages": {
|
"packages": {
|
||||||
"": {
|
"": {
|
||||||
"name": "amnet-native",
|
"name": "amnet-native",
|
||||||
"version": "1.3.9",
|
"version": "1.3.2",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@babel/runtime": "^7.28.4",
|
"@babel/runtime": "^7.28.4",
|
||||||
"@expo-google-fonts/jetbrains-mono": "^0.4.1",
|
"@expo-google-fonts/jetbrains-mono": "^0.4.1",
|
||||||
@@ -32,6 +32,7 @@
|
|||||||
"react-native-context-menu-view": "^1.21.0",
|
"react-native-context-menu-view": "^1.21.0",
|
||||||
"react-native-gesture-handler": "^2.30.0",
|
"react-native-gesture-handler": "^2.30.0",
|
||||||
"react-native-get-random-values": "^2.0.0",
|
"react-native-get-random-values": "^2.0.0",
|
||||||
|
"react-native-nfc-manager": "^3.17.2",
|
||||||
"react-native-paper": "^5.14.5",
|
"react-native-paper": "^5.14.5",
|
||||||
"react-native-reanimated": "~4.2.1",
|
"react-native-reanimated": "~4.2.1",
|
||||||
"react-native-safe-area-context": "5.6.2",
|
"react-native-safe-area-context": "5.6.2",
|
||||||
@@ -1625,6 +1626,7 @@
|
|||||||
"resolved": "https://registry.npmjs.org/@expo/config-plugins/-/config-plugins-54.0.4.tgz",
|
"resolved": "https://registry.npmjs.org/@expo/config-plugins/-/config-plugins-54.0.4.tgz",
|
||||||
"integrity": "sha512-g2yXGICdoOw5i3LkQSDxl2Q5AlQCrG7oniu0pCPPO+UxGb7He4AFqSvPSy8HpRUj55io17hT62FTjYRD+d6j3Q==",
|
"integrity": "sha512-g2yXGICdoOw5i3LkQSDxl2Q5AlQCrG7oniu0pCPPO+UxGb7He4AFqSvPSy8HpRUj55io17hT62FTjYRD+d6j3Q==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
|
"peer": true,
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@expo/config-types": "^54.0.10",
|
"@expo/config-types": "^54.0.10",
|
||||||
"@expo/json-file": "~10.0.8",
|
"@expo/json-file": "~10.0.8",
|
||||||
@@ -7342,6 +7344,20 @@
|
|||||||
"react-native": "*"
|
"react-native": "*"
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
"node_modules/react-native-nfc-manager": {
|
||||||
|
"version": "3.17.2",
|
||||||
|
"resolved": "https://registry.npmjs.org/react-native-nfc-manager/-/react-native-nfc-manager-3.17.2.tgz",
|
||||||
|
"integrity": "sha512-0NryP/Iw2hzw4MVH5KCngoRerNUrnRok6VfLrlFcFZRKyTQ7KTgpsdDxCB6cR33qYNyEDrWGBayfAI+ym5gt8Q==",
|
||||||
|
"license": "MIT",
|
||||||
|
"peerDependencies": {
|
||||||
|
"@expo/config-plugins": "*"
|
||||||
|
},
|
||||||
|
"peerDependenciesMeta": {
|
||||||
|
"@expo/config-plugins": {
|
||||||
|
"optional": true
|
||||||
|
}
|
||||||
|
}
|
||||||
|
},
|
||||||
"node_modules/react-native-paper": {
|
"node_modules/react-native-paper": {
|
||||||
"version": "5.14.5",
|
"version": "5.14.5",
|
||||||
"resolved": "https://registry.npmjs.org/react-native-paper/-/react-native-paper-5.14.5.tgz",
|
"resolved": "https://registry.npmjs.org/react-native-paper/-/react-native-paper-5.14.5.tgz",
|
||||||
@@ -8503,9 +8519,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/tar": {
|
"node_modules/tar": {
|
||||||
"version": "7.5.7",
|
"version": "7.5.2",
|
||||||
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.7.tgz",
|
"resolved": "https://registry.npmjs.org/tar/-/tar-7.5.2.tgz",
|
||||||
"integrity": "sha512-fov56fJiRuThVFXD6o6/Q354S7pnWMJIVlDBYijsTNx6jKSE4pvrDTs6lUnmGvNyfJwFQQwWy3owKz1ucIhveQ==",
|
"integrity": "sha512-7NyxrTE4Anh8km8iEy7o0QYPs+0JKBTj5ZaqHg6B39erLg0qYXN3BijtShwbsNSvQ+LN75+KV+C4QR/f6Gwnpg==",
|
||||||
"license": "BlueOak-1.0.0",
|
"license": "BlueOak-1.0.0",
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"@isaacs/fs-minipass": "^4.0.0",
|
"@isaacs/fs-minipass": "^4.0.0",
|
||||||
@@ -8794,9 +8810,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/undici": {
|
"node_modules/undici": {
|
||||||
"version": "6.23.0",
|
"version": "6.22.0",
|
||||||
"resolved": "https://registry.npmjs.org/undici/-/undici-6.23.0.tgz",
|
"resolved": "https://registry.npmjs.org/undici/-/undici-6.22.0.tgz",
|
||||||
"integrity": "sha512-VfQPToRA5FZs/qJxLIinmU59u0r7LXqoJkCzinq3ckNJp3vKEh7jTWN589YQ5+aoAC/TGRLyJLCPKcLQbM8r9g==",
|
"integrity": "sha512-hU/10obOIu62MGYjdskASR3CUAiYaFTtC9Pa6vHyf//mAipSvSQg6od2CnJswq7fvzNS3zJhxoRkgNVaHurWKw==",
|
||||||
"license": "MIT",
|
"license": "MIT",
|
||||||
"engines": {
|
"engines": {
|
||||||
"node": ">=18.17"
|
"node": ">=18.17"
|
||||||
|
|||||||
@@ -1,6 +1,6 @@
|
|||||||
{
|
{
|
||||||
"name": "amnet-native",
|
"name": "amnet-native",
|
||||||
"version": "1.3.9",
|
"version": "1.3.2",
|
||||||
"private": true,
|
"private": true,
|
||||||
"scripts": {
|
"scripts": {
|
||||||
"android": "expo run:android",
|
"android": "expo run:android",
|
||||||
@@ -33,6 +33,7 @@
|
|||||||
"react-native-context-menu-view": "^1.21.0",
|
"react-native-context-menu-view": "^1.21.0",
|
||||||
"react-native-gesture-handler": "^2.30.0",
|
"react-native-gesture-handler": "^2.30.0",
|
||||||
"react-native-get-random-values": "^2.0.0",
|
"react-native-get-random-values": "^2.0.0",
|
||||||
|
"react-native-nfc-manager": "^3.17.2",
|
||||||
"react-native-paper": "^5.14.5",
|
"react-native-paper": "^5.14.5",
|
||||||
"react-native-reanimated": "~4.2.1",
|
"react-native-reanimated": "~4.2.1",
|
||||||
"react-native-safe-area-context": "5.6.2",
|
"react-native-safe-area-context": "5.6.2",
|
||||||
|
|||||||
Generated
+3
-3
@@ -1253,9 +1253,9 @@
|
|||||||
}
|
}
|
||||||
},
|
},
|
||||||
"node_modules/lodash": {
|
"node_modules/lodash": {
|
||||||
"version": "4.17.23",
|
"version": "4.17.21",
|
||||||
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.23.tgz",
|
"resolved": "https://registry.npmjs.org/lodash/-/lodash-4.17.21.tgz",
|
||||||
"integrity": "sha512-LgVTMpQtIopCi79SJeDiP0TfWi5CNEc/L/aRdTh3yIvmZXTnheWpKjSZhnvMl8iXbC1tFg9gdHHDMLoV7CnG+w==",
|
"integrity": "sha512-v2kDEe57lecTulaDIuNTPy3Ry4gLGJ6Z1O3vE1krgXZNrsQ+LFTGHVxVjcXPs17LhbZVGedAJv8XZ1tvj5FvSg==",
|
||||||
"license": "MIT"
|
"license": "MIT"
|
||||||
},
|
},
|
||||||
"node_modules/lru-cache": {
|
"node_modules/lru-cache": {
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
<div align="center">
|
<div align="center">
|
||||||
|
|
||||||
# AMNet
|
# AMNet
|
||||||
[Firebase](https://appdistribution.firebase.dev/i/6acc3151357deaa8) • [Website](http://card.ppc.moe) • [Server DLLs](https://gitea.tendokyu.moe/ppc/amnet/releases)
|
[TestFlight](https://testflight.apple.com/join/kHbeJTsQ) • [Firebase](https://appdistribution.firebase.dev/i/6acc3151357deaa8) • [Website](http://card.ppc.moe) • [Server DLLs](https://gitea.tendokyu.moe/ppc/amnet/releases)
|
||||||
|
|
||||||
An Amusement IC Card Switcher for segatools-based games.
|
An Amusement IC Card Switcher for segatools-based games.
|
||||||
|
|
||||||
@@ -11,10 +11,6 @@ An Amusement IC Card Switcher for segatools-based games.
|
|||||||
AMNet is designed to acts as dynamic version of the `DEVICE/aime.txt` file, allowing multiple users to log into a game using their own mobile devices.
|
AMNet is designed to acts as dynamic version of the `DEVICE/aime.txt` file, allowing multiple users to log into a game using their own mobile devices.
|
||||||
This was originally intended for use with maimai and CHUNITHM, but should be compatible with any segatools-based game with that uses Amusement IC for account management.
|
This was originally intended for use with maimai and CHUNITHM, but should be compatible with any segatools-based game with that uses Amusement IC for account management.
|
||||||
|
|
||||||
> [!WARNING]
|
|
||||||
> TestFlight is no longer available and must be sideloaded using AltStore or similar tooling for the forseeable future.
|
|
||||||
> See issue #1 for more details.
|
|
||||||
|
|
||||||
## Setup
|
## Setup
|
||||||
1. Download the latest `amnet.dll` from the releases page
|
1. Download the latest `amnet.dll` from the releases page
|
||||||
2. Move `amnet.dll` to the game directory
|
2. Move `amnet.dll` to the game directory
|
||||||
@@ -30,7 +26,7 @@ This was originally intended for use with maimai and CHUNITHM, but should be com
|
|||||||
; serverName - the name of the server to show to users (defaults to the computer name if not set)
|
; serverName - the name of the server to show to users (defaults to the computer name if not set)
|
||||||
; serverAddress - the address to listen on, including the protocol (don't set/change unless you know what you're doing)
|
; serverAddress - the address to listen on, including the protocol (don't set/change unless you know what you're doing)
|
||||||
; enableKeyboardMode - whether to enable hold-enter-to-login mode. Reads the file set at aimePath for card number (or DEVICE/aime.txt if not set).
|
; enableKeyboardMode - whether to enable hold-enter-to-login mode. Reads the file set at aimePath for card number (or DEVICE/aime.txt if not set).
|
||||||
; useAimeDBForPhysicalCards - Whether codes from real cards should use AiMeDB to retrieve access codes. If the game is using a hosted network, set this to 1 to load the same account data/profile as you would get on a physical cab.
|
; useAimeDBForPhysicalCards - Whether physical cards should use AiMeDB to retrieve access codes. If the game is using a hosted network, set this to 1 to load the same account data/profile as you would get on a physical cab.
|
||||||
gameId=SDEZ
|
gameId=SDEZ
|
||||||
;serverName=CHUNI-PENGUIN
|
;serverName=CHUNI-PENGUIN
|
||||||
;serverAddress=http://0.0.0.0:6070
|
;serverAddress=http://0.0.0.0:6070
|
||||||
@@ -40,6 +36,18 @@ This was originally intended for use with maimai and CHUNITHM, but should be com
|
|||||||
4. Launch the game, and check the amdaemon console for server startup messages
|
4. Launch the game, and check the amdaemon console for server startup messages
|
||||||
5. Access the using one of the interfaces (see below), add a new server `http://<your-ip-address>:6070`, import your existing card (or create a new one) and start playing!
|
5. Access the using one of the interfaces (see below), add a new server `http://<your-ip-address>:6070`, import your existing card (or create a new one) and start playing!
|
||||||
|
|
||||||
|
### Physical Cards
|
||||||
|
AMNet 1.3 adds support for scanning physical cards on iOS devices. If you own a physical Aime/Banapass/NESiCA/e-Amusement card, you can scan it using the app and use it in-game.
|
||||||
|
By changing the `useAimeDBForPhysicalCards` in segatools.ini, you can choose how the card is read on a per-game basis:
|
||||||
|
|
||||||
|
- `0` will only use the 20-digit access code (as shown in the app) to load the user profile directly (default option).
|
||||||
|
- `1` will present the card's hardware identifier (IDm) to the game and the AiMeDB server configures will be used to retrieve the 20-digit code assigned to the card.
|
||||||
|
|
||||||
|
Mode `1` makes the app function in the same way to a real card reader and should be used if you want the same access code to show when scanning the card on a cab.
|
||||||
|
You should also use this option if you're connecting to a hosted server (AquaNet/rinnet/etc).
|
||||||
|
|
||||||
|
Note: if `useAimeDBForPhysicalCards` is set to `1` and the game is failing to read the card, make sure an up-to-date version of segatools is being used.
|
||||||
|
|
||||||
## Interfaces
|
## Interfaces
|
||||||
AMNet can be used on most platforms, see below for options available for each platform:
|
AMNet can be used on most platforms, see below for options available for each platform:
|
||||||
|
|
||||||
@@ -52,8 +60,8 @@ AMNet can be used on most platforms, see below for options available for each pl
|
|||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td>iOS</td>
|
<td>iOS</td>
|
||||||
<td><a href="https://amnet-dist.ppc.moe/amnet-1.3.2.ipa" target="_blank">.ipa download</a></td>
|
<td><a href="https://testflight.apple.com/join/kHbeJTsQ" target="_blank">TestFlight</a></td>
|
||||||
<td>*TestFlight is no longer available, sideload using AltStore or similar tooling</td>
|
<td>Aime/Banapass/NESiCA/e-Amusement IC cards supported</td>
|
||||||
</tr>
|
</tr>
|
||||||
<tr>
|
<tr>
|
||||||
<td rowspan="2">Android</td>
|
<td rowspan="2">Android</td>
|
||||||
|
|||||||
Reference in New Issue
Block a user