@ha_tecno/react-native-sdk
Version:
React Native SDK for biometric authentication, liveness detection, and fingerprint recognition
36 lines (34 loc) • 939 B
JavaScript
;
let sdkToken = null;
export const setToken = token => {
sdkToken = token;
};
export const getToken = () => {
return sdkToken;
};
export const assertTokenIsValid = () => {
if (!sdkToken) {
throw new Error('[HA-TECNO-SDK] Token não configurado. Use configureLibrary(token).');
}
};
export const validateTokenRemote = async () => {
if (!sdkToken) {
throw new Error('[HA-TECNO-SDK] Token não configurado. Use configureLibrary(token).');
}
// url será mudada no futuro, pois o endpoint ainda não existe.
const res = await fetch('https://sua-api.com/validar-token', {
method: 'POST',
headers: {
'Content-Type': 'application/json'
},
body: JSON.stringify({
token: sdkToken
})
});
const data = await res.json();
if (data?.valid !== true) {
throw new Error('[HA-TECNO-SDK] Token recusado pela API');
}
return true;
};
//# sourceMappingURL=tokenManager.js.map