-
Notifications
You must be signed in to change notification settings - Fork 3
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
38 changed files
with
3,473 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,31 @@ | ||
# | ||
# Be sure to run `pod lib lint Categories.podspec' to ensure this is a | ||
# valid spec before submitting. | ||
# | ||
# Any lines starting with a # are optional, but their use is encouraged | ||
# To learn more about a Podspec see http://guides.cocoapods.org/syntax/podspec.html | ||
# | ||
|
||
Pod::Spec.new do |s| | ||
s.name = "AppGroupKit" | ||
s.version = "1.0.0" | ||
s.summary = "AppGroupKit." | ||
s.homepage = "https://www.passlockapp.com/" | ||
s.license = { :type => "MIT", :file => "LICENSE" } | ||
s.author = "MeloDreek@gmail.com" | ||
s.source = { :git => "https://www.passlockapp.com/AppGroupKit.git", :tag => s.version } | ||
s.platform = :ios, '14.0' | ||
s.requires_arc = true | ||
|
||
#指定Pod为静态库模式 | ||
s.static_framework = true | ||
s.source_files = "Classes/**/*.swift" | ||
s.resources = 'Classes/*.{png,bundle}' | ||
s.frameworks = "CloudKit" | ||
|
||
# s.dependency 'KakaFoundation' | ||
s.dependency 'KakaUIKit' | ||
s.dependency 'KakaObjcKit' | ||
s.dependency 'KakaSwiftyRSA' | ||
|
||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,70 @@ | ||
// | ||
// AppRecordTypeModel.swift | ||
// PassLock | ||
// | ||
// Created by Melo Dreek on 2023/2/19. | ||
// Copyright © 2023 PassLock. All rights reserved. | ||
// | ||
|
||
import KakaFoundation | ||
import CloudKit | ||
import HandyJSON | ||
|
||
|
||
public enum StorageItemType: String, HandyJSONEnum { | ||
|
||
case allItem = "allItem" | ||
case password = "password" | ||
case photoVault = "photoVault" | ||
case secretNotes = "secretNotes" | ||
|
||
case bankCard = "bankCard" | ||
case secretContacts = "secretContacts" | ||
case database = "database" | ||
case service = "service" | ||
case customerInfo = "customerInfo" | ||
case APICredentials = "APICredentials" | ||
case SSHKey = "SSHKey" | ||
|
||
public func systemIconImage() -> UIImage? { | ||
switch self { | ||
case .allItem: | ||
return UIImage(systemName: "square.grid.2x2") | ||
case .password: | ||
return UIImage(systemName: "lock.rectangle.stack") | ||
case .photoVault: | ||
return UIImage(systemName: "lock.doc") | ||
case .secretNotes: | ||
return UIImage(systemName: "note.text")?.flippedImage() | ||
|
||
case .bankCard: | ||
return UIImage(systemName: "building.columns") | ||
case .secretContacts: | ||
if #available(iOS 15.0, *) { | ||
return UIImage(systemName: "person.text.rectangle") | ||
}else{ | ||
return UIImage(systemName: "person.crop.rectangle") | ||
} | ||
case .database: | ||
return UIImage(systemName: "externaldrive.badge.icloud") | ||
case .service: | ||
return nil | ||
case .customerInfo: | ||
return nil | ||
case .APICredentials: | ||
return nil | ||
case .SSHKey: | ||
return nil | ||
} | ||
} | ||
|
||
public func typeImage() -> UIImage? { | ||
switch self { | ||
case .photoVault: | ||
return UIImage(systemName: "paperclip.badge.ellipsis") | ||
default: | ||
return nil | ||
} | ||
} | ||
|
||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,66 @@ | ||
// | ||
// AppRecordTypeModel.swift | ||
// AppGroupKit | ||
// | ||
// Created by Melo on 2023/11/30. | ||
// | ||
|
||
import HandyJSON | ||
|
||
public struct AppRecordTypeModel: HandyJSON { | ||
|
||
public init() {} | ||
|
||
public var recordId: String = "" | ||
|
||
public var recordType = AppRecordType.defaultBook | ||
|
||
public var isSelected: Bool = false | ||
|
||
public var customName: String? | ||
|
||
public var customDesc: String? | ||
|
||
} | ||
|
||
extension AppRecordTypeModel { | ||
public func model1() -> AppRecordTypeModel { | ||
let recordType = AppRecordType.defaultBook | ||
|
||
var model = AppRecordTypeModel() | ||
model.recordType = recordType | ||
model.isSelected = true | ||
|
||
return model | ||
} | ||
|
||
public func model2() -> AppRecordTypeModel { | ||
let recordType = AppRecordType.familyBook | ||
|
||
var model = AppRecordTypeModel() | ||
model.recordType = recordType | ||
model.isSelected = false | ||
|
||
return model | ||
} | ||
|
||
public func model3() -> AppRecordTypeModel { | ||
let recordType = AppRecordType.companyBook | ||
|
||
var model = AppRecordTypeModel() | ||
model.recordType = recordType | ||
model.isSelected = false | ||
|
||
return model | ||
} | ||
|
||
public func model4() -> AppRecordTypeModel { | ||
let recordType = AppRecordType.otherBook | ||
|
||
var model = AppRecordTypeModel() | ||
model.recordType = recordType | ||
model.isSelected = false | ||
|
||
return model | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,81 @@ | ||
// | ||
// PrivateAccountModel.swift | ||
// AppGroupKit | ||
// | ||
// Created by Melo on 2023/12/1. | ||
// | ||
|
||
import KakaFoundation | ||
import CloudKit | ||
import HandyJSON | ||
import KakaObjcKit | ||
|
||
|
||
public struct PrivateAccountModel: HandyJSON { | ||
|
||
public init() { } | ||
|
||
public var accountName: String? | ||
|
||
public var passwords: [PasswordListModel]? | ||
|
||
public var websiteModel: WebsiteInfoModel? | ||
|
||
} | ||
|
||
|
||
public struct PasswordListModel: HandyJSON { | ||
|
||
public init() { } | ||
|
||
public init(passwordID: String, password: String, createTime: TimeInterval, deviceType: DeviceOSType) { | ||
self.passwordID = passwordID | ||
self.password = password | ||
self.createTime = createTime | ||
self.deviceType = deviceType | ||
} | ||
|
||
public var passwordID: String = "" | ||
|
||
public var password: String = "" | ||
|
||
public var createTime: TimeInterval = 0 | ||
|
||
public var deviceType = DeviceOSType.iOS | ||
|
||
public func formatCreateDate() -> Date { | ||
|
||
let newTime = createTime.rounded() | ||
|
||
let date = Date(timeIntervalSince1970: newTime) | ||
|
||
return date | ||
} | ||
|
||
public func convertToPassRecord() -> CKRecord { | ||
|
||
var record = CKRecord(recordType: CloudRecordType_CopiedPasswords, recordID: CKRecord.ID(recordName: self.passwordID)) | ||
|
||
var tempRecord = self | ||
tempRecord.passwordID = record.recordID.recordName | ||
|
||
// JSON | ||
var jsonStr = tempRecord.toJSONString() ?? "" | ||
jsonStr = CryptoHelper.encryptAES(string: jsonStr, key: ...) ?? "" | ||
record.setObject(jsonStr.ocString, forKey: ...) | ||
|
||
return record | ||
} | ||
} | ||
|
||
extension CKRecord { | ||
|
||
public func convertToPassModel() -> PasswordListModel { | ||
var jsonStr = (self.object(forKey: ...) as? String) ?? "" | ||
jsonStr = CryptoHelper.decryptAES(string: jsonStr, key: ...) ?? "" | ||
|
||
var model = PasswordListModel.deserialize(from: jsonStr) ?? PasswordListModel() | ||
model.passwordID = self.recordID.recordName | ||
return model | ||
} | ||
} |
Oops, something went wrong.