Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 3 additions & 20 deletions LICENSE
Original file line number Diff line number Diff line change
@@ -1,21 +1,4 @@
MIT License
This repository contains multiple packages, each with its own LICENSE file.
Refer to the LICENSE file in each package directory for the terms that govern
that package.

Copyright (c) 2023 Proof of Passport

Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:

The above copyright notice and this permission notice shall be included in all
copies or substantial portions of the Software.

THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
9 changes: 1 addition & 8 deletions app/App.tsx
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
// SPDX-License-Identifier: BUSL-1.1
// Copyright (c) 2025 Social Connect Labs, Inc.
//
// This file is licensed under the Business Source License 1.1 (BUSL-1.1).
//
// Use of this software is governed by the Business Source License included in the LICENSE file.
//
// As of 2029-06-11, this file will be governed by the Apache License, Version 2.0.
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

import 'react-native-get-random-values';

Expand Down
2 changes: 1 addition & 1 deletion app/LICENSE
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ Copyright (C) 2025 Social Connect Labs, Inc.

The contents of this repository are licensed under the Business Source License 1.1 (the "License"); you may not use this file except in compliance with the License. You may obtain a copy of the License at:

https://github.com/self-xyz/project-name/blob/main/LICENSES/BSL1.1.txt
https://spdx.org/licenses/BUSL-1.1.html

Unless required by applicable law or agreed to in writing, software distributed under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.

Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

package com.proofofpassportapp

import android.app.backup.BackupManager
Expand All @@ -22,4 +24,4 @@ class BackupModule(reactContext: ReactApplicationContext): ReactContextBaseJavaM
// https://developer.android.com/identity/data/keyvaluebackup#RequestingRestore
promise.resolve(null)
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

package com.proofofpassportapp

import com.facebook.react.ReactPackage
Expand All @@ -16,4 +18,4 @@ class BackupPackage : ReactPackage {
)
}

}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

package com.proofofpassportapp;

import static com.google.android.gms.common.util.CollectionUtils.listOf;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

package com.proofofpassportapp

import android.content.Intent
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

package com.proofofpassportapp

import android.app.Application
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

package com.proofofpassportapp;

import android.app.Activity;
Expand Down Expand Up @@ -90,4 +92,4 @@ public void onRequestPermissionsResult(int requestCode, String[] permissions, in
}
}
}
}
}
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

package com.proofofpassportapp;

import com.facebook.react.ReactPackage;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

/*
* Copyright 2017 The Android Open Source Project
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

package com.proofofpassportapp.ui

import android.view.Choreographer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

package com.proofofpassportapp.ui

import android.view.Choreographer
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

/*
* Copyright 2017 The Android Open Source Project
*
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

// Copyright 2018 Google LLC
//
// Licensed under the Apache License, Version 2.0 (the "License");
Expand Down
9 changes: 1 addition & 8 deletions app/android/react-native-passport-reader/index.android.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
// SPDX-License-Identifier: BUSL-1.1
// Copyright (c) 2025 Social Connect Labs, Inc.
//
// This file is licensed under the Business Source License 1.1 (BUSL-1.1).
//
// Use of this software is governed by the Business Source License included in the LICENSE file.
//
// As of 2029-06-11, this file will be governed by the Apache License, Version 2.0.
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

import { NativeModules } from 'react-native'

Expand Down
9 changes: 1 addition & 8 deletions app/declarations.d.ts
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
// SPDX-License-Identifier: BUSL-1.1
// Copyright (c) 2025 Social Connect Labs, Inc.
//
// This file is licensed under the Business Source License 1.1 (BUSL-1.1).
//
// Use of this software is governed by the Business Source License included in the LICENSE file.
//
// As of 2029-06-11, this file will be governed by the Apache License, Version 2.0.
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

declare module '@env';
declare module '*.png' {
Expand Down
2 changes: 2 additions & 0 deletions app/fastlane/helpers.rb
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
# SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

require "bundler/setup"
require "fastlane"
require "tempfile"
Expand Down
9 changes: 1 addition & 8 deletions app/index.js
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
// SPDX-License-Identifier: BUSL-1.1
// Copyright (c) 2025 Social Connect Labs, Inc.
//
// This file is licensed under the Business Source License 1.1 (BUSL-1.1).
//
// Use of this software is governed by the Business Source License included in the LICENSE file.
//
// As of 2029-06-11, this file will be governed by the Apache License, Version 2.0.
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

/**
* @format
Expand Down
24 changes: 13 additions & 11 deletions app/ios/CameraView.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

// CameraView.swift
// SwiftUI camera preview with frame capture callback

Expand Down Expand Up @@ -69,51 +71,51 @@ class CameraViewController: UIViewController, AVCaptureVideoDataOutputSampleBuff
guard let previewLayer = previewLayer else { return .zero }
let videoRect = previewLayer.layerRectConverted(fromMetadataOutputRect: CGRect(x: 0, y: 0, width: 1, height: 1))
let visibleRect = videoRect.intersection(view.bounds)

//Lottie animation frame
let lottieWidth = visibleRect.width * 1.3 // 130% of width
let lottieHeight = visibleRect.height * 1.3 // 130% of height

//bottom 25% of the Lottie animation
let boxHeight = lottieHeight * 0.25

// Center the box horizontally and ensure it's within bounds
let boxX = max(0, (visibleRect.width - lottieWidth) / 2)
let boxWidth = min(lottieWidth, visibleRect.width)

//Vertical offset to move the ROI a bit up. 15% in this case
let verticalOffset = visibleRect.height * 0.15

//GreenBox should stay within the visible area
let maxY = visibleRect.maxY - verticalOffset
let minY = visibleRect.minY
let boxY = max(minY, min(maxY - boxHeight, maxY - boxHeight))
// let boxY = visibleRect.maxY - boxHeight

return CGRect(x: boxX, y: boxY, width: boxWidth, height: boxHeight)
}

var roiInImageCoordinates: CGRect {
guard let previewLayer = previewLayer else { return .zero }
let videoRect = previewLayer.layerRectConverted(fromMetadataOutputRect: CGRect(x: 0, y: 0, width: 1, height: 1))
let greenBox = calculateGreenBoxFrame()

// map greenBox to normalized coordinates within videoRect
let normX = (greenBox.minX - videoRect.minX) / videoRect.width
let normY = (greenBox.minY - videoRect.minY) / videoRect.height
let normWidth = greenBox.width / videoRect.width
let normHeight = greenBox.height / videoRect.height

// Ensure normalized coordinates are within [0,1] bounds as vision's max ROI is (0,0) to (1,1)
let clampedX = max(0, min(1, normX))
let clampedY = max(0, min(1, normY))
let clampedWidth = max(0, min(1 - clampedX, normWidth))
let clampedHeight = max(0, min(1 - clampedY, normHeight))

// Vision expects (0,0) at bottom-left, so flip Y
let roiYVision = 1.0 - clampedY - clampedHeight
let roi = CGRect(x: clampedX, y: roiYVision, width: clampedWidth, height: clampedHeight)

// print("[CameraViewController] FINAL ROI for Vision (flipped Y, visible only): \(roi)")
return roi
}
Expand Down Expand Up @@ -157,4 +159,4 @@ extension UIImage {
UIGraphicsEndImageContext()
return normalizedImage
}
}
}
8 changes: 5 additions & 3 deletions app/ios/LiveMRZScannerView.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

// LiveMRZScannerView.swift

import SwiftUI
Expand All @@ -13,9 +15,9 @@ struct LiveMRZScannerView: View {

func singleCorrectDocumentNumberInMRZ(result: String, docNumber: String, parser: QKMRZParser) -> QKMRZResult? {
let replacements: [Character: [Character]] = [
// "0": ["O", "D"],
// "1": ["I"],
"O": ["0"],
// "0": ["O", "D"],
// "1": ["I"],
"O": ["0"],
"D": ["0"],
"I": ["1"],
"L": ["1"],
Expand Down
14 changes: 8 additions & 6 deletions app/ios/LottieView.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

//
// LottieView.swift
// FreedomTools
Expand All @@ -9,25 +11,25 @@ import SwiftUI
struct LottieView: UIViewRepresentable {
var animationFileName: String
let loopMode: LottieLoopMode

func updateUIView(_ uiView: UIViewType, context: Context) {}

func makeUIView(context: Context) -> some UIView {
let view = UIView(frame: .zero)

let animationView = LottieAnimationView(name: animationFileName)
animationView.loopMode = loopMode
animationView.contentMode = .scaleAspectFit
animationView.play()

animationView.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(animationView)

NSLayoutConstraint.activate([
animationView.widthAnchor.constraint(equalTo: view.widthAnchor),
animationView.heightAnchor.constraint(equalTo: view.heightAnchor)
])

return view
}
}
Expand Down
20 changes: 11 additions & 9 deletions app/ios/MRZScanner.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

//
// MRZScanner.swift

Expand All @@ -15,37 +17,37 @@ struct MRZScanner {
if let error = error {
print("Vision error: \(error)")
}

guard let observations = request.results as? [VNRecognizedTextObservation] else {
print("No text observations found")
completion("No text found", [])
return
}

// print("Found \(observations.count) text observations")

var mrzLines: [String] = []
var boxes: [CGRect] = []

// Sort lines from top to bottom
let sortedObservations = observations.sorted { $0.boundingBox.minY > $1.boundingBox.minY }

for (index, obs) in sortedObservations.enumerated() {
if let candidate = obs.topCandidates(1).first {
let text = candidate.string
let confidence = candidate.confidence
// print("Line \(index): '\(text)' (confidence: \(confidence), position: \(obs.boundingBox))")

// Check if this looks like an MRZ line (either contains "<" or matches MRZ pattern)
// TD1 format (ID cards): 30 chars, TD3 format (passports): 44 chars
if text.contains("<") ||
if text.contains("<") ||
text.matches(pattern: "^[A-Z0-9<]{30}$") || //TD1 //case where there's no '<' in MRZ
text.matches(pattern: "^[A-Z0-9<]{44}$") //TD3
{
// print("Matched MRZ pattern: \(text)")
mrzLines.append(text)
boxes.append(obs.boundingBox)

// Check if we have a complete MRZ
if (mrzLines.count == 2 && mrzLines.allSatisfy { $0.count == 44 }) || // TD3 - passport
(mrzLines.count == 3 && mrzLines.allSatisfy { $0.count == 30 }) { // TD1 - ID card
Expand All @@ -68,7 +70,7 @@ struct MRZScanner {
request.recognitionLevel = .accurate
request.usesLanguageCorrection = false
request.recognitionLanguages = ["en"]

// Use provided ROI. If not use as bottom 20%
if let roi = roi {
// print("[MRZScanner] Using provided ROI: \(roi) (image size: \(cgImage.width)x\(cgImage.height))")
Expand All @@ -80,7 +82,7 @@ struct MRZScanner {
// print("[MRZScanner] Using default ROI: \(defaultRoi) (image size: \(cgImage.width)x\(cgImage.height), roi height: \(roiHeight))")
request.regionOfInterest = defaultRoi
}

let handler = VNImageRequestHandler(cgImage: cgImage, options: [:])
DispatchQueue.global(qos: .userInitiated).async {
do {
Expand Down
2 changes: 2 additions & 0 deletions app/ios/MRZScannerModule.m
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

//
// MRZScannerModule.m
// OpenPassport
Expand Down
2 changes: 2 additions & 0 deletions app/ios/MRZScannerModule.swift
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
// SPDX-License-Identifier: BUSL-1.1; Copyright (c) 2025 Social Connect Labs, Inc.; Licensed under BUSL-1.1 (see LICENSE); Apache-2.0 from 2029-06-11

//
// MRZScannerModule.swift
// ProofOfPassport
Expand Down
Loading