Commit f7b7c5fa authored by Drew's avatar Drew

Modernize (kit)

parent 73957439
......@@ -13,6 +13,7 @@ xcs:
- "$CJ forceGitLabBranch --branchName CaveJohnsonAuto --hostname code.sealedabstract.com --projectID $GITLAB_PROJECT_ID"
- "sleep 1"
- "XCSBUILDNO=`/Applications/CaveJohnson.app/Contents/MacOS/CaveJohnsonCLI xcsIntegrateNow --botID $XCSBOT --hostname localhost --sslPolicy localhost`"
- "echo XCS BUILDNO $XCSBUILDNO"
- "$CJ waitForIntegration --hostname localhost --botID $XCSBOT --sslPolicy localhost --buildNumber $XCSBUILDNO"
- "$CJ xcsStatusToShell --hostname localhost --botID $XCSBOT --sslPolicy localhost --buildNumber $XCSBUILDNO"
- "ZIPFILE=$($CJ getNameVersionString --infoPlistPath ${APP_NAME}/Info.plist --productName ${APP_NAME})-dev-${CI_BUILD_ID}.zip"
......
This diff is collapsed.
<?xml version="1.0" encoding="UTF-8"?>
<Workspace
version = "1.0">
<FileRef
location = "self:FISA.xcodeproj">
</FileRef>
</Workspace>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3A526FFF1B80FC0D0092BA60"
BuildableName = "FISA.app"
BlueprintName = "FISA"
ReferencedContainer = "container:FISA.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
codeCoverageEnabled = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3A5270101B80FC0D0092BA60"
BuildableName = "FISATests.xctest"
BlueprintName = "FISATests"
ReferencedContainer = "container:FISA.xcodeproj">
</BuildableReference>
</TestableReference>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3A52702D1B80FC220092BA60"
BuildableName = "FISAKitTests.xctest"
BlueprintName = "FISAKitTests"
ReferencedContainer = "container:FISA.xcodeproj">
</BuildableReference>
</TestableReference>
</Testables>
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3A1922671B8163FF0092C6B1"
BuildableName = "FISAcli"
BlueprintName = "FISAcli"
ReferencedContainer = "container:FISA.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3A1922671B8163FF0092C6B1"
BuildableName = "FISAcli"
BlueprintName = "FISAcli"
ReferencedContainer = "container:FISA.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
<CommandLineArguments>
<CommandLineArgument
argument = "setSecret --secretKey &quot;MyTestKey&quot;"
isEnabled = "YES">
</CommandLineArgument>
</CommandLineArguments>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3A526FFF1B80FC0D0092BA60"
BuildableName = "FISA.app"
BlueprintName = "FISA"
ReferencedContainer = "container:FISA.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "0700"
version = "1.3">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
buildForRunning = "YES"
buildForProfiling = "YES"
buildForArchiving = "YES"
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3A5270241B80FC220092BA60"
BuildableName = "FISAKit.framework"
BlueprintName = "FISAKit"
ReferencedContainer = "container:FISA.xcodeproj">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES">
<Testables>
</Testables>
<AdditionalOptions>
</AdditionalOptions>
</TestAction>
<LaunchAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
launchStyle = "0"
useCustomWorkingDirectory = "NO"
ignoresPersistentStateOnLaunch = "NO"
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3A5270241B80FC220092BA60"
BuildableName = "FISAKit.framework"
BlueprintName = "FISAKit"
ReferencedContainer = "container:FISA.xcodeproj">
</BuildableReference>
</MacroExpansion>
<AdditionalOptions>
</AdditionalOptions>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "3A5270241B80FC220092BA60"
BuildableName = "FISAKit.framework"
BlueprintName = "FISAKit"
ReferencedContainer = "container:FISA.xcodeproj">
</BuildableReference>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
......@@ -25,11 +25,11 @@ class AppDelegate: NSObject, NSApplicationDelegate {
func applicationDidFinishLaunching(aNotification: NSNotification) {
func applicationDidFinishLaunching(_ aNotification: Notification) {
// Insert code here to initialize your application
}
func applicationWillTerminate(aNotification: NSNotification) {
func applicationWillTerminate(_ aNotification: Notification) {
// Insert code here to tear down your application
}
......
......@@ -30,29 +30,25 @@ enum StringlyTyped : String {
case secretValue = "secretValue"
}
internal let defaultFISAPath = NSFileManager.defaultManager().currentDirectoryPath + "/secrets.fisa"
internal let defaultIdentityPath = NSHomeDirectory() + "/.identity.fisa"
private let identityOption = CLIKit.DefaultOption(longName: StringlyTyped.identityFile.rawValue, help: "Path to the identity file. For security reasons, it must have permissions 0600 (only user-readable)", defaultValue: OptionType.StringOption(defaultIdentityPath))
private let fisaFileOption = CLIKit.DefaultOption(longName: StringlyTyped.fisaFile.rawValue, help: "Path to the FISA file to be operated on.", defaultValue: OptionType.StringOption(defaultFISAPath))
private final class IdentityCreationCommand : CLIKit.EasyCommand {
private func command(parseResult: ParseResult) {
fileprivate func command(_ parseResult: ParseResult) {
try! createIdentity(parseResult[StringlyTyped.identityFile.rawValue].stringValue)
}
private let options : [Option] = [identityOption]
private let shortHelp = "Create a new identity and save it to the specified file."
fileprivate let options : [Option] = [identityOption]
fileprivate let shortHelp = "Create a new identity and save it to the specified file."
let name = "createIdentity"
}
private final class CreateFISACommand : CLIKit.EasyCommand {
private let options : [Option] = [identityOption, fisaFileOption, DefaultOption(longName: "identityDescription", help: "The description to use for your identity in the new FISA file.")]
private let shortHelp = "Create a new FISA secrets file and save it to the specified location."
fileprivate let options : [Option] = [identityOption, fisaFileOption, DefaultOption(longName: "identityDescription", help: "The description to use for your identity in the new FISA file.")]
fileprivate let shortHelp = "Create a new FISA secrets file and save it to the specified location."
let name = "createFISA"
private func command(parseResult: ParseResult) {
fileprivate func command(_ parseResult: ParseResult) {
var file = FISAFile()
let key = try! PublicKey(readFromFile: (parseResult[StringlyTyped.identityFile.rawValue].stringValue))
file.identities.append(Identity(description: parseResult[StringlyTyped.identityDescription.rawValue].stringValue, key: key))
......@@ -61,10 +57,10 @@ private final class CreateFISACommand : CLIKit.EasyCommand {
}
private final class PrintFISACommand : CLIKit.EasyCommand {
private let options : [Option] = [identityOption, fisaFileOption]
private let shortHelp = "Print the FISA file."
fileprivate let options : [Option] = [identityOption, fisaFileOption]
fileprivate let shortHelp = "Print the FISA file."
let name = "printFISA"
private func command(parseResult: ParseResult) {
fileprivate func command(_ parseResult: ParseResult) {
let key = try! PublicKey(readFromFile: (parseResult[StringlyTyped.identityFile.rawValue].stringValue))
let file = try! FISAFile(contentsOfFile: parseResult[StringlyTyped.fisaFile.rawValue].stringValue, identity: key)
print("\(file)")
......@@ -72,20 +68,20 @@ private final class PrintFISACommand : CLIKit.EasyCommand {
}
private final class GetPublicIdentity : CLIKit.EasyCommand {
private let options : [Option] = [identityOption]
private let shortHelp = "Get the public portion of your identity"
fileprivate let options : [Option] = [identityOption]
fileprivate let shortHelp = "Get the public portion of your identity"
let name = "getPublicIdentity"
private func command(parseResult: ParseResult) {
fileprivate func command(_ parseResult: ParseResult) {
let key = try! PublicKey(readFromFile: (parseResult[StringlyTyped.identityFile.rawValue].stringValue))
print("\(key.bytes.base64)")
}
}
private final class AddPublicIdentity : CLIKit.EasyCommand {
private let options : [Option] = [identityOption, fisaFileOption, DefaultOption(longName: StringlyTyped.publicIdentity.rawValue, help: "Public identity string to add"), DefaultOption(longName: StringlyTyped.identityDescription.rawValue, help: "The description to use for the new identity in the FISA file.")]
private let shortHelp = "Add the public portion of an identity to the specified FISA file"
fileprivate let options : [Option] = [identityOption, fisaFileOption, DefaultOption(longName: StringlyTyped.publicIdentity.rawValue, help: "Public identity string to add"), DefaultOption(longName: StringlyTyped.identityDescription.rawValue, help: "The description to use for the new identity in the FISA file.")]
fileprivate let shortHelp = "Add the public portion of an identity to the specified FISA file"
let name = "addPublicIdentity"
private func command(parseResult: ParseResult) {
fileprivate func command(_ parseResult: ParseResult) {
let key = try! PublicKey(readFromFile: (parseResult[StringlyTyped.identityFile.rawValue].stringValue))
var file = try! FISAFile(contentsOfFile: parseResult[StringlyTyped.fisaFile.rawValue].stringValue, identity: key)
file.addIdentity(parseResult[StringlyTyped.publicIdentity.rawValue].stringValue, description: parseResult[StringlyTyped.identityDescription.rawValue].stringValue)
......@@ -94,10 +90,10 @@ private final class AddPublicIdentity : CLIKit.EasyCommand {
}
private final class RemovePublicIdentity : CLIKit.EasyCommand {
private let options : [Option] = [identityOption, fisaFileOption, DefaultOption(longName: StringlyTyped.identityDescription.rawValue, help: "Description of the identity to remove.")]
private let shortHelp = "Remove the public portion of an identity from the specified FISA file"
fileprivate let options : [Option] = [identityOption, fisaFileOption, DefaultOption(longName: StringlyTyped.identityDescription.rawValue, help: "Description of the identity to remove.")]
fileprivate let shortHelp = "Remove the public portion of an identity from the specified FISA file"
let name = "removePublicIdentity"
private func command(parseResult: ParseResult) {
fileprivate func command(_ parseResult: ParseResult) {
let key = try! PublicKey(readFromFile: (parseResult[StringlyTyped.identityFile.rawValue].stringValue))
var file = try! FISAFile(contentsOfFile: parseResult[StringlyTyped.fisaFile.rawValue].stringValue, identity: key)
try! file.removeIdentity(parseResult[StringlyTyped.identityDescription.rawValue].stringValue)
......@@ -106,10 +102,10 @@ private final class RemovePublicIdentity : CLIKit.EasyCommand {
}
private final class SetSecret : CLIKit.EasyCommand {
private let options : [Option] = [identityOption, fisaFileOption, DefaultOption(longName: "secretKey", help: "Key of the secret"),SecureOption(longName: "secretValue", help: "Value of the secret")]
private let shortHelp = "Creates a secret or sets an existing one to a new value"
fileprivate let options : [Option] = [identityOption, fisaFileOption, DefaultOption(longName: "secretKey", help: "Key of the secret"),SecureOption(longName: "secretValue", help: "Value of the secret")]
fileprivate let shortHelp = "Creates a secret or sets an existing one to a new value"
let name = "setSecret"
private func command(parseResult: ParseResult) {
fileprivate func command(_ parseResult: ParseResult) {
let key = try! PublicKey(readFromFile: (parseResult[StringlyTyped.identityFile.rawValue].stringValue))
var file = try! FISAFile(contentsOfFile: parseResult[StringlyTyped.fisaFile.rawValue].stringValue, identity: key)
file.secrets[parseResult[StringlyTyped.secretKey.rawValue].stringValue] = parseResult[StringlyTyped.secretValue.rawValue].stringValue
......@@ -118,10 +114,10 @@ private final class SetSecret : CLIKit.EasyCommand {
}
private final class RemoveSecret : CLIKit.EasyCommand {
private let options : [Option] = [identityOption, fisaFileOption, DefaultOption(longName: "secretKey", help: "Key of the secret")]
private let shortHelp = "Removes a secret from the FISA file"
fileprivate let options : [Option] = [identityOption, fisaFileOption, DefaultOption(longName: "secretKey", help: "Key of the secret")]
fileprivate let shortHelp = "Removes a secret from the FISA file"
let name = "removeSecret"
private func command(parseResult: ParseResult) {
fileprivate func command(_ parseResult: ParseResult) {
let key = try! PublicKey(readFromFile: (parseResult[StringlyTyped.identityFile.rawValue].stringValue))
var file = try! FISAFile(contentsOfFile: parseResult[StringlyTyped.fisaFile.rawValue].stringValue, identity: key)
file.secrets.removeValueForKey(parseResult[StringlyTyped.secretKey.rawValue].stringValue)
......@@ -130,10 +126,10 @@ private final class RemoveSecret : CLIKit.EasyCommand {
}
private final class GetSecret : CLIKit.EasyCommand {
private let options : [Option] = [identityOption, fisaFileOption, DefaultOption(longName: "secretKey", help: "Key of the secret")]
private let shortHelp = "Retrieves the secret from the FISA file"
fileprivate let options : [Option] = [identityOption, fisaFileOption, DefaultOption(longName: "secretKey", help: "Key of the secret")]
fileprivate let shortHelp = "Retrieves the secret from the FISA file"
let name = "getSecret"
private func command(parseResult: ParseResult) {
fileprivate func command(_ parseResult: ParseResult) {
let key = try! PublicKey(readFromFile: (parseResult[StringlyTyped.identityFile.rawValue].stringValue))
var file = try! FISAFile(contentsOfFile: parseResult[StringlyTyped.fisaFile.rawValue].stringValue, identity: key)
let secretKey = parseResult[StringlyTyped.secretKey.rawValue].stringValue
......@@ -157,4 +153,4 @@ public final class EntryPoint: NSObject {
metaCommand.command(parseResult)
}
}
}
\ No newline at end of file
}
......@@ -24,16 +24,16 @@ extension Array {
get {
assert(Element.self == UInt8.self)
return self.withUnsafeBufferPointer { (ptr) -> String in
let data = NSData(bytes: ptr.baseAddress, length: ptr.count)
return data.base64EncodedStringWithOptions(NSDataBase64EncodingOptions())
let data = Data(bytes: ptr.baseAddress!, count: ptr.count)
return data.base64EncodedString(options: NSData.Base64EncodingOptions())
}
}
}
//📡21473461 📡17821143 (origbug)
static func byteArrayWithBase64(base64String: String) -> [UInt8] {
let data = NSData(base64EncodedString: base64String, options: NSDataBase64DecodingOptions())!
static func byteArrayWithBase64(_ base64String: String) -> [UInt8] {
let data = Data(base64Encoded: base64String, options: NSData.Base64DecodingOptions())!
return data.byteArray
}
}
\ No newline at end of file
}
This diff is collapsed.
......@@ -22,20 +22,20 @@ import Foundation
import NaOH
/**Creates a new identity and writes it to the specified file. */
public func createIdentity(file: String) throws {
let identity = PublicKey()
public func createIdentity(_ file: String) throws {
let identity = CryptoBoxSecretKey()
try identity.saveToFile(file)
}
/**Gets the public portion of the identity, as base64 */
public func getPublicIdentity(file: String) throws -> String {
let identity = try PublicKey(readFromFile: file)
public func getPublicIdentity(_ file: String) throws -> String {
let identity = try CryptoBoxPublicKey(readFromFile: file)
return identity.bytes.base64
}
enum FISAKitError : ErrorType {
case InvalidFISAFile(Int)
case IdentityCantOpenFile
case IdentityNotInFile
enum FISAKitError : Error {
case invalidFISAFile(Int)
case identityCantOpenFile
case identityNotInFile
}
......@@ -18,19 +18,19 @@
// language governing rights and limitations under the RPL.
import Foundation
extension NSData {
extension Data {
var byteArray : [UInt8] {
get {
let uint8ptr = unsafeBitCast(bytes, UnsafePointer<UInt8>.self)
let bufferPtr = UnsafeBufferPointer<UInt8>(start: uint8ptr, count: self.length)
return [UInt8](bufferPtr)
return self.withUnsafeBytes {
Array(UnsafeBufferPointer<UInt8>(start: $0, count: self.count/MemoryLayout<UInt8>.size))
}
}
}
/**This silly API is to work around 📡22302010 */
static func dataWithArray(array: [UInt8]) -> NSData {
return array.withUnsafeBufferPointer { (ptr) -> NSData in
return NSData(bytes: ptr.baseAddress, length: ptr.count)
static func dataWithArray(_ array: [UInt8]) -> Data {
return array.withUnsafeBufferPointer { (ptr) -> Data in
return Data(bytes: UnsafePointer<UInt8>(ptr.baseAddress!), count: ptr.count)
}
}
......
......@@ -40,7 +40,7 @@ class FISATests: XCTestCase {
func testPerformanceExample() {
// This is an example of a performance test case.
self.measureBlock {
self.measure {
// Put the code you want to measure the time of here.
}
}
......
;; Anarchy Tools Package Manager lock file
;;
;; If you want to pin a package to a git commit add a ':pin'
;; line to that package definition. This will override all version
;; information the build files specify.
;;
;; You may override the repository URL for a package by specifying
;; it in an ':override-url' line. This is very handy if you develop
;; the dependency in parallel to the package that uses it
(lock-file
:packages [
{
:url "https://code.sealedabstract.com/drewcrawford/Caroline.git"
:payloads [
{
:key "git"
:used-commit "f1797525eeb2999d664dbc4a7ade2c1703219e55"
:pin false
}
]
}
{
:url "https://code.sealedabstract.com/drewcrawford/StandBack.git"
:payloads [
{
:key "git"
:used-commit "91eb559427a92a7eeeb3ecf84aa6060e0f58d170"
:pin false
}
]
}
{
:url "https://code.sealedabstract.com/drewcrawford/pianissimo.git"
:payloads [
{
:key "git"
:used-commit "dbf270709dbb7956e41a12cca7b65d170af57649"
:pin false
}
]
}
{
:url "https://code.sealedabstract.com/drewcrawford/NaOH.git"
:payloads [
{
:key "git"
:used-commit "08ac076e8578a2b0d7f204de72d954e99048f92b"
:pin false
}
]
}
{
:url "https://code.sealedabstract.com/drewcrawford/Caroline.git"
:payloads [
{
:key "git"
:used-commit "f1797525eeb2999d664dbc4a7ade2c1703219e55"
:pin false
}
]
}
{
:url "https://code.sealedabstract.com/drewcrawford/StandBack.git"
:payloads [
{
:key "git"
:used-commit "91eb559427a92a7eeeb3ecf84aa6060e0f58d170"
:pin false
}
]
}
]
)
(package
:name "FISA"
:external-packages [
{
:url "https://code.sealedabstract.com/drewcrawford/Caroline.git"
:version [">= 1.1"]
}
{
:url "https://code.sealedabstract.com/drewcrawford/pianissimo.git"
:version [">= 0.1"]
}
{
:url "https://code.sealedabstract.com/drewcrawford/NaOH.git"
:branch "master"
}
]
:tasks {
:kit {
:tool "atllbuild"
:sources ["FISAKit/**.swift"]
:name "FISAKit"
:output-type "static-library"
:publish-product true
:dependencies ["pianissimo.default" "NaOH.default"]
:link-with-product ["pianissimo.a" "NaOH.a"]
:overlays {
:at.xcode-emit {
:include-with-user ["libsodium/libsodium/src/libsodium/include/"]
}
}
}
}
)
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment