Skip to content

Commit

Permalink
wip
Browse files Browse the repository at this point in the history
  • Loading branch information
luckyrat committed Mar 6, 2024
1 parent b5c8738 commit 602098f
Show file tree
Hide file tree
Showing 2 changed files with 18 additions and 26 deletions.
34 changes: 18 additions & 16 deletions ios/KeeVaultAutofill/KeeVaultViewController.swift
Original file line number Diff line number Diff line change
Expand Up @@ -232,26 +232,28 @@ class KeeVaultViewController: UIViewController, AddOrEditEntryDelegate {

fileprivate func mashNewUrlIntoJSON(_ entryJson: String, _ propertyName: String, _ url: String) -> String {
let range = entryJson.range(of: #""\#(propertyName)"\:\[([^\]]*)\]"#, options: .regularExpression)
// print(range)

if (range != nil) {
var newJson = entryJson.replacingOccurrences(of: "[]", with: "[\"\(url)\"]", options: .init(), range: range)
if (newJson.count == entryJson.count) {
// may already have an altURL
newJson = entryJson.replacingOccurrences(of: "]", with: ",\"\(url)\"]", options: .init(), range: range)
}
return newJson
var newJson = entryJson.replacingOccurrences(of: "[]", with: "[\"\(url)\"]", options: .init(), range: range)
if (newJson.count == entryJson.count) {
// may already have an altURL
newJson = entryJson.replacingOccurrences(of: "]", with: ",\"\(url)\"]", options: .init(), range: range)
}
return newJson
}

// may be a null property
let rangeNull = entryJson.range(of: #""\#(propertyName)"\:null"#, options: .regularExpression)
let rangeNull = entryJson.range(of: #""\#(propertyName)"\:null"#, options: .regularExpression)
if (rangeNull != nil) {
var newJson = entryJson.replacingOccurrences(of: "null", with: "[\"\(url)\"]", options: .init(), range: rangeNull)
return newJson
var newJson = entryJson.replacingOccurrences(of: "null", with: "[\"\(url)\"]", options: .init(), range: rangeNull)
return newJson
}
// no altURLs at all
var newJson = entryJson
let idx = newJson.index(newJson.endIndex, offsetBy: -1)
newJson.insert(contentsOf: ",\"\(propertyName)\":[\"\(url)\"]", at: idx)


// no altURLs at all
var newJson = entryJson
let idx = newJson.index(newJson.endIndex, offsetBy: -1)
newJson.insert(contentsOf: ",\"\(propertyName)\":[\"\(url)\"]", at: idx)

return newJson
}

Expand All @@ -268,7 +270,7 @@ var newJson = entryJson.replacingOccurrences(of: "null", with: "[\"\
entry.setField(name: "KPRPC JSON", value: newJson, isProtected: true)
}

let entryJsonV2 = entry.customData["KPRPC JSON"]?.value ?? #"{"version":2,"authenticationMethods":["password"],"matcherConfigs":[{"matcherType":"Url"}],"fields":[{"page":1,"valuePath":"UserName","uuid":"\#(UUID())","type":"Text","matcherConfigs":[{"matcherType":"UsernameDefaultHeuristic"}]},{"page":1,"valuePath":"Password","uuid":"\#(UUID())","type":"Password","matcherConfigs":[{"matcherType":"PasswordDefaultHeuristic"}]}]}"#
let entryJsonV2 = entry.customData["KPRPC JSON"]?.value ?? #"{"version":2,"authenticationMethods":["password"],"matcherConfigs":[{"matcherType":"Url"}],"fields":[{"page":1,"valuePath":"UserName","uuid":"\#(UUID().base64EncodedString())","type":"Text","matcherConfigs":[{"matcherType":"UsernameDefaultHeuristic"}]},{"page":1,"valuePath":"Password","uuid":"\#(UUID().base64EncodedString())","type":"Password","matcherConfigs":[{"matcherType":"PasswordDefaultHeuristic"}]}]}"#

Check failure on line 273 in ios/KeeVaultAutofill/KeeVaultViewController.swift

View workflow job for this annotation

GitHub Actions / Build ios prod

'base64EncodedString' is inaccessible due to 'internal' protection level

Check failure on line 273 in ios/KeeVaultAutofill/KeeVaultViewController.swift

View workflow job for this annotation

GitHub Actions / Build ios prod

'base64EncodedString' is inaccessible due to 'internal' protection level

let newJson = mashNewUrlIntoJSON(entryJsonV2, "altUrls", url)
let dataItem = CustomData2.Item(value: String(describing: newJson), lastModificationTime: nil)
Expand Down
10 changes: 0 additions & 10 deletions pubspec.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -135,18 +135,8 @@ dev_dependencies:
#patrol: ^2.2.3

dependency_overrides:
# flutter_inapp_purchase declares incompatibility with this version and other deps declare
# incompatibility with earlier versions. Seems to work fine if we just use the latest version.
#http: 1.1.0
# collection: 1.18.0
# sensitive_clipboard:
# path: ../sensitive_clipboard/
# flutter_inapp_purchase:
# path: ../flutter_inapp_purchase/
# flutter_autofill_service:
# path: ../flutter_autofill_service/
# argon2_ffi:
# path: ../argon2_ffi/

# For information on the generic Dart part of this file, see the
# following page: https://dart.dev/tools/pub/pubspec
Expand Down

0 comments on commit 602098f

Please sign in to comment.