Skip to content

Commit

Permalink
Version 0.0.8 (#18)
Browse files Browse the repository at this point in the history
* Version 0.0.8
  • Loading branch information
skhamis authored Oct 26, 2021
1 parent 0fde703 commit e8d9b43
Show file tree
Hide file tree
Showing 5 changed files with 133 additions and 85 deletions.
4 changes: 2 additions & 2 deletions Package.swift
Original file line number Diff line number Diff line change
Expand Up @@ -41,8 +41,8 @@ let package = Package(
// For release artifacts, reference the MozillaRustComponents as a URL with checksum.
// IMPORTANT: The checksum has to be on the line directly after the `url`
// this is important for our release script so that all values are updated correctly
url: "https://118551-129966583-gh.circle-artifacts.com/0/dist/MozillaRustComponents.xcframework.zip",
checksum: "2195ff4b9f942cf8dc66461514af57be56e7c663f37e3e5d5b7f9a3adc5cf71f"
url: "https://119127-129966583-gh.circle-artifacts.com/0/dist/MozillaRustComponents.xcframework.zip",
checksum: "2cf6f6e5db8e995773560ad3074722b7ec3ed05a6c2d33c6f90bbffce866ed03"

// For local testing, you can point at an (unzipped) XCFramework that's part of the repo.
// Note that you have to actually check it in and make a tag for it to work correctly.
Expand Down
4 changes: 4 additions & 0 deletions generate.sh
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,10 @@ cp -r "$APP_SERVICES_DIR/components/fxa-client/ios/FxAClient" "$FXA_CLIENT_DIR/F

LOGINS_DIR="$THIS_DIR/generated/logins"
rm -rf "$LOGINS_DIR" && mkdir -p "$LOGINS_DIR"
# Glean metrics.
# Run this first, because it appears to delete any other .swift files in the output directory.
# Also, it wants to be run from inside Xcode, so we set some env vars to fake it out.
SOURCE_ROOT="$THIS_DIR" PROJECT="logins" "$GLEAN_GENERATOR" -o "$LOGINS_DIR/Generated" "$APP_SERVICES_DIR/components/logins/ios/metrics.yaml"
# UniFFI bindings.
"${UNIFFI_BINDGEN[@]}" generate -l swift -o "$LOGINS_DIR/Generated" "$APP_SERVICES_DIR/components/logins/src/logins.udl"
# Copy the hand-written Swift, since it all needs to be together in one directory.
Expand Down
69 changes: 69 additions & 0 deletions generated/logins/Generated/Metrics.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
// -*- mode: Swift -*-

// AUTOGENERATED BY glean_parser. DO NOT EDIT. DO NOT COMMIT.

/* This Source Code Form is subject to the terms of the Mozilla Public
* License, v. 2.0. If a copy of the MPL was not distributed with this
* file, You can obtain one at http://mozilla.org/MPL/2.0/. */



import Glean

// swiftlint:disable superfluous_disable_command
// swiftlint:disable nesting
// swiftlint:disable line_length
// swiftlint:disable identifier_name
// swiftlint:disable force_try

extension GleanMetrics {
enum LoginsStoreMigration {
/// The total number of login records processed by the migration
static let numProcessed = CounterMetricType( // generated from logins_store_migration.num_processed
category: "logins_store_migration",
name: "num_processed",
sendInPings: ["metrics"],
lifetime: .ping,
disabled: false
)

/// The total number of login records successfully migrated
static let numSucceeded = CounterMetricType( // generated from logins_store_migration.num_succeeded
category: "logins_store_migration",
name: "num_succeeded",
sendInPings: ["metrics"],
lifetime: .ping,
disabled: false
)

/// The total number of login records which failed to migrate
static let numFailed = CounterMetricType( // generated from logins_store_migration.num_failed
category: "logins_store_migration",
name: "num_failed",
sendInPings: ["metrics"],
lifetime: .ping,
disabled: false
)

/// How long the migration tool
static let totalDuration = TimespanMetricType( // generated from logins_store_migration.total_duration
category: "logins_store_migration",
name: "total_duration",
sendInPings: ["metrics"],
lifetime: .ping,
disabled: false,
timeUnit: .millisecond
)

/// Errors discovered in the migration.
static let errors = StringListMetricType( // generated from logins_store_migration.errors
category: "logins_store_migration",
name: "errors",
sendInPings: ["metrics"],
lifetime: .ping,
disabled: false
)

}

}
75 changes: 29 additions & 46 deletions generated/logins/Generated/logins.swift
Original file line number Diff line number Diff line change
Expand Up @@ -14,15 +14,15 @@ private extension RustBuffer {
// Allocate a new buffer, copying the contents of a `UInt8` array.
init(bytes: [UInt8]) {
let rbuf = bytes.withUnsafeBufferPointer { ptr in
try! rustCall { ffi_logins_5236_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) }
try! rustCall { ffi_logins_42e6_rustbuffer_from_bytes(ForeignBytes(bufferPointer: ptr), $0) }
}
self.init(capacity: rbuf.capacity, len: rbuf.len, data: rbuf.data)
}

// Frees the buffer in place.
// The buffer must not be used after this is called.
func deallocate() {
try! rustCall { ffi_logins_5236_rustbuffer_free(self, $0) }
try! rustCall { ffi_logins_42e6_rustbuffer_free(self, $0) }
}
}

Expand Down Expand Up @@ -273,7 +273,7 @@ extension String: ViaFfi {

fileprivate static func lift(_ v: FfiType) throws -> Self {
defer {
try! rustCall { ffi_logins_5236_rustbuffer_free(v, $0) }
try! rustCall { ffi_logins_42e6_rustbuffer_free(v, $0) }
}
if v.data == nil {
return String()
Expand All @@ -289,7 +289,7 @@ extension String: ViaFfi {
// The swift string gives us a trailing null byte, we don't want it.
let buf = UnsafeBufferPointer(rebasing: ptr.prefix(upTo: ptr.count - 1))
let bytes = ForeignBytes(bufferPointer: buf)
return try! rustCall { ffi_logins_5236_rustbuffer_from_bytes(bytes, $0) }
return try! rustCall { ffi_logins_42e6_rustbuffer_from_bytes(bytes, $0) }
}
}
}
Expand Down Expand Up @@ -836,7 +836,7 @@ public func createKey() throws -> String {
let _retval = try

rustCallWithError(LoginsStorageError.self) {
logins_5236_create_key($0)
logins_42e6_create_key($0)
}
return try String.lift(_retval)
}
Expand All @@ -845,7 +845,7 @@ public func decryptLogin(login: EncryptedLogin, encryptionKey: String) throws ->
let _retval = try

rustCallWithError(LoginsStorageError.self) {
logins_5236_decrypt_login(login.lower(), encryptionKey.lower(), $0)
logins_42e6_decrypt_login(login.lower(), encryptionKey.lower(), $0)
}
return try Login.lift(_retval)
}
Expand All @@ -854,7 +854,7 @@ public func encryptLogin(login: Login, encryptionKey: String) throws -> Encrypte
let _retval = try

rustCallWithError(LoginsStorageError.self) {
logins_5236_encrypt_login(login.lower(), encryptionKey.lower(), $0)
logins_42e6_encrypt_login(login.lower(), encryptionKey.lower(), $0)
}
return try EncryptedLogin.lift(_retval)
}
Expand All @@ -863,7 +863,7 @@ public func decryptFields(secFields: String, encryptionKey: String) throws -> Se
let _retval = try

rustCallWithError(LoginsStorageError.self) {
logins_5236_decrypt_fields(secFields.lower(), encryptionKey.lower(), $0)
logins_42e6_decrypt_fields(secFields.lower(), encryptionKey.lower(), $0)
}
return try SecureLoginFields.lift(_retval)
}
Expand All @@ -872,7 +872,7 @@ public func encryptFields(secFields: SecureLoginFields, encryptionKey: String) t
let _retval = try

rustCallWithError(LoginsStorageError.self) {
logins_5236_encrypt_fields(secFields.lower(), encryptionKey.lower(), $0)
logins_42e6_encrypt_fields(secFields.lower(), encryptionKey.lower(), $0)
}
return try String.lift(_retval)
}
Expand All @@ -881,7 +881,7 @@ public func createCanary(text: String, encryptionKey: String) throws -> String {
let _retval = try

rustCallWithError(LoginsStorageError.self) {
logins_5236_create_canary(text.lower(), encryptionKey.lower(), $0)
logins_42e6_create_canary(text.lower(), encryptionKey.lower(), $0)
}
return try String.lift(_retval)
}
Expand All @@ -890,7 +890,7 @@ public func checkCanary(canary: String, text: String, encryptionKey: String) thr
let _retval = try

rustCallWithError(LoginsStorageError.self) {
logins_5236_check_canary(canary.lower(), text.lower(), encryptionKey.lower(), $0)
logins_42e6_check_canary(canary.lower(), text.lower(), encryptionKey.lower(), $0)
}
return try Bool.lift(_retval)
}
Expand All @@ -899,13 +899,12 @@ public func migrateLogins(path: String, newEncryptionKey: String, sqlcipherPath:
let _retval = try

rustCallWithError(LoginsStorageError.self) {
logins_5236_migrate_logins(path.lower(), newEncryptionKey.lower(), sqlcipherPath.lower(), sqlcipherKey.lower(), salt.lower(), $0)
logins_42e6_migrate_logins(path.lower(), newEncryptionKey.lower(), sqlcipherPath.lower(), sqlcipherKey.lower(), salt.lower(), $0)
}
return try String.lift(_retval)
}

public protocol LoginStoreProtocol {
func checkValidWithNoDupes(id: String, login: LoginEntry, encryptionKey: String) throws
func add(login: LoginEntry, encryptionKey: String) throws -> EncryptedLogin
func update(id: String, login: LoginEntry, encryptionKey: String) throws -> EncryptedLogin
func addOrUpdate(login: LoginEntry, encryptionKey: String) throws -> EncryptedLogin
Expand All @@ -917,7 +916,6 @@ public protocol LoginStoreProtocol {
func list() throws -> [EncryptedLogin]
func getByBaseDomain(baseDomain: String) throws -> [EncryptedLogin]
func findLoginToUpdate(look: LoginEntry, encryptionKey: String) throws -> Login?
func potentialDupesIgnoringUsername(id: String, login: LoginEntry) throws -> [EncryptedLogin]
func get(id: String) throws -> EncryptedLogin?
func importMultiple(login: [Login], encryptionKey: String) throws -> String
func registerWithSyncManager()
Expand All @@ -938,140 +936,125 @@ public class LoginStore: LoginStoreProtocol {
self.init(unsafeFromRawPointer: try

rustCallWithError(LoginsStorageError.self) {
logins_5236_LoginStore_new(path.lower(), $0)
logins_42e6_LoginStore_new(path.lower(), $0)
})
}

deinit {
try! rustCall { ffi_logins_5236_LoginStore_object_free(pointer, $0) }
}

public func checkValidWithNoDupes(id: String, login: LoginEntry, encryptionKey: String) throws {
try
rustCallWithError(LoginsStorageError.self) {
logins_5236_LoginStore_check_valid_with_no_dupes(self.pointer, id.lower(), login.lower(), encryptionKey.lower(), $0)
}
try! rustCall { ffi_logins_42e6_LoginStore_object_free(pointer, $0) }
}

public func add(login: LoginEntry, encryptionKey: String) throws -> EncryptedLogin {
let _retval = try
rustCallWithError(LoginsStorageError.self) {
logins_5236_LoginStore_add(self.pointer, login.lower(), encryptionKey.lower(), $0)
logins_42e6_LoginStore_add(self.pointer, login.lower(), encryptionKey.lower(), $0)
}
return try EncryptedLogin.lift(_retval)
}

public func update(id: String, login: LoginEntry, encryptionKey: String) throws -> EncryptedLogin {
let _retval = try
rustCallWithError(LoginsStorageError.self) {
logins_5236_LoginStore_update(self.pointer, id.lower(), login.lower(), encryptionKey.lower(), $0)
logins_42e6_LoginStore_update(self.pointer, id.lower(), login.lower(), encryptionKey.lower(), $0)
}
return try EncryptedLogin.lift(_retval)
}

public func addOrUpdate(login: LoginEntry, encryptionKey: String) throws -> EncryptedLogin {
let _retval = try
rustCallWithError(LoginsStorageError.self) {
logins_5236_LoginStore_add_or_update(self.pointer, login.lower(), encryptionKey.lower(), $0)
logins_42e6_LoginStore_add_or_update(self.pointer, login.lower(), encryptionKey.lower(), $0)
}
return try EncryptedLogin.lift(_retval)
}

public func delete(id: String) throws -> Bool {
let _retval = try
rustCallWithError(LoginsStorageError.self) {
logins_5236_LoginStore_delete(self.pointer, id.lower(), $0)
logins_42e6_LoginStore_delete(self.pointer, id.lower(), $0)
}
return try Bool.lift(_retval)
}

public func wipe() throws {
try
rustCallWithError(LoginsStorageError.self) {
logins_5236_LoginStore_wipe(self.pointer, $0)
logins_42e6_LoginStore_wipe(self.pointer, $0)
}
}

public func wipeLocal() throws {
try
rustCallWithError(LoginsStorageError.self) {
logins_5236_LoginStore_wipe_local(self.pointer, $0)
logins_42e6_LoginStore_wipe_local(self.pointer, $0)
}
}

public func reset() throws {
try
rustCallWithError(LoginsStorageError.self) {
logins_5236_LoginStore_reset(self.pointer, $0)
logins_42e6_LoginStore_reset(self.pointer, $0)
}
}

public func touch(id: String) throws {
try
rustCallWithError(LoginsStorageError.self) {
logins_5236_LoginStore_touch(self.pointer, id.lower(), $0)
logins_42e6_LoginStore_touch(self.pointer, id.lower(), $0)
}
}

public func list() throws -> [EncryptedLogin] {
let _retval = try
rustCallWithError(LoginsStorageError.self) {
logins_5236_LoginStore_list(self.pointer, $0)
logins_42e6_LoginStore_list(self.pointer, $0)
}
return try [EncryptedLogin].lift(_retval)
}

public func getByBaseDomain(baseDomain: String) throws -> [EncryptedLogin] {
let _retval = try
rustCallWithError(LoginsStorageError.self) {
logins_5236_LoginStore_get_by_base_domain(self.pointer, baseDomain.lower(), $0)
logins_42e6_LoginStore_get_by_base_domain(self.pointer, baseDomain.lower(), $0)
}
return try [EncryptedLogin].lift(_retval)
}

public func findLoginToUpdate(look: LoginEntry, encryptionKey: String) throws -> Login? {
let _retval = try
rustCallWithError(LoginsStorageError.self) {
logins_5236_LoginStore_find_login_to_update(self.pointer, look.lower(), encryptionKey.lower(), $0)
logins_42e6_LoginStore_find_login_to_update(self.pointer, look.lower(), encryptionKey.lower(), $0)
}
return try Login?.lift(_retval)
}

public func potentialDupesIgnoringUsername(id: String, login: LoginEntry) throws -> [EncryptedLogin] {
let _retval = try
rustCallWithError(LoginsStorageError.self) {
logins_5236_LoginStore_potential_dupes_ignoring_username(self.pointer, id.lower(), login.lower(), $0)
}
return try [EncryptedLogin].lift(_retval)
}

public func get(id: String) throws -> EncryptedLogin? {
let _retval = try
rustCallWithError(LoginsStorageError.self) {
logins_5236_LoginStore_get(self.pointer, id.lower(), $0)
logins_42e6_LoginStore_get(self.pointer, id.lower(), $0)
}
return try EncryptedLogin?.lift(_retval)
}

public func importMultiple(login: [Login], encryptionKey: String) throws -> String {
let _retval = try
rustCallWithError(LoginsStorageError.self) {
logins_5236_LoginStore_import_multiple(self.pointer, login.lower(), encryptionKey.lower(), $0)
logins_42e6_LoginStore_import_multiple(self.pointer, login.lower(), encryptionKey.lower(), $0)
}
return try String.lift(_retval)
}

public func registerWithSyncManager() {
try!
rustCall {
logins_5236_LoginStore_register_with_sync_manager(self.pointer, $0)
logins_42e6_LoginStore_register_with_sync_manager(self.pointer, $0)
}
}

public func sync(keyId: String, accessToken: String, syncKey: String, tokenserverUrl: String, localEncryptionKey: String) throws -> String {
let _retval = try
rustCallWithError(LoginsStorageError.self) {
logins_5236_LoginStore_sync(self.pointer, keyId.lower(), accessToken.lower(), syncKey.lower(), tokenserverUrl.lower(), localEncryptionKey.lower(), $0)
logins_42e6_LoginStore_sync(self.pointer, keyId.lower(), accessToken.lower(), syncKey.lower(), tokenserverUrl.lower(), localEncryptionKey.lower(), $0)
}
return try String.lift(_retval)
}
Expand Down
Loading

0 comments on commit e8d9b43

Please sign in to comment.