UNPKG

@criipto/verify-expo

Version:

Accept MitID, NemID, Swedish BankID, Norwegian BankID and more logins in your Expo (React-Native) app

52 lines 1.44 kB
import { Platform } from "react-native"; export class SwedishBankIDTransaction { redirectUri; onComplete; onCancel; constructor(redirectUri, onComplete, onCancel) { this.redirectUri = redirectUri; this.onComplete = onComplete; this.onCancel = onCancel; } onForeground() { if (Platform.OS === "android") { this.onComplete(); } else { this.onCancel(); } } onUrl(url) { if (isRedirectURI(url, this.redirectUri)) { this.onComplete(); } } } export class DanishMitIDTransaction { redirectUri; resumeUrl; onComplete; constructor(redirectUri, resumeUrl, onComplete) { this.redirectUri = redirectUri; this.resumeUrl = resumeUrl; this.onComplete = onComplete; } onForeground() { } onUrl(url) { if (isRedirectURI(url, this.redirectUri)) { if (url.includes("code=") || url.includes("error=")) { this.onComplete(url); } } } } function isRedirectURI(url, redirectUri) { if (!(url instanceof URL)) url = new URL(url); if (!(redirectUri instanceof URL)) redirectUri = new URL(redirectUri); return (url.protocol === redirectUri.protocol && url.origin === redirectUri.origin && url.pathname === redirectUri.pathname); } //# sourceMappingURL=transaction.js.map