Skip to content

Commit

Permalink
Add CLI to SecureEnclaveToken app
Browse files Browse the repository at this point in the history
  • Loading branch information
mwielgoszewski authored and Marcin Wielgoszewski committed Nov 2, 2022
1 parent f475c11 commit c0ff940
Show file tree
Hide file tree
Showing 11 changed files with 778 additions and 250 deletions.
54 changes: 46 additions & 8 deletions SecureEnclaveToken.xcodeproj/project.pbxproj
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
archiveVersion = 1;
classes = {
};
objectVersion = 52;
objectVersion = 56;
objects = {

/* Begin PBXBuildFile section */
Expand All @@ -19,6 +19,9 @@
BD60D3BA25D58D9A0075CC34 /* SecureEnclaveTokenExtension.appex in Embed App Extensions */ = {isa = PBXBuildFile; fileRef = BD60D3AB25D58D9A0075CC34 /* SecureEnclaveTokenExtension.appex */; settings = {ATTRIBUTES = (RemoveHeadersOnCopy, ); }; };
BD60D3C225D58E5A0075CC34 /* SecureEnclaveTokenUtils.swift in Sources */ = {isa = PBXBuildFile; fileRef = BD60D3C125D58E5A0075CC34 /* SecureEnclaveTokenUtils.swift */; };
BDE0445E25E0228C00C984E3 /* CertificateSigningRequest in Frameworks */ = {isa = PBXBuildFile; productRef = BDE0445D25E0228C00C984E3 /* CertificateSigningRequest */; };
D98B035928DF8CFE00D6EB1C /* main.swift in Sources */ = {isa = PBXBuildFile; fileRef = D98B035828DF8CFE00D6EB1C /* main.swift */; };
D98B035C28DF955900D6EB1C /* ArgumentParser in Frameworks */ = {isa = PBXBuildFile; productRef = D98B035B28DF955900D6EB1C /* ArgumentParser */; };
D98B035E28E0915200D6EB1C /* SecureEnclaveTokenCLI.swift in Sources */ = {isa = PBXBuildFile; fileRef = D98B035D28E0915200D6EB1C /* SecureEnclaveTokenCLI.swift */; };
/* End PBXBuildFile section */

/* Begin PBXContainerItemProxy section */
Expand Down Expand Up @@ -53,6 +56,16 @@
name = "Embed Frameworks";
runOnlyForDeploymentPostprocessing = 0;
};
D99219A828DF7DAE0088BA56 /* Embed CLI */ = {
isa = PBXCopyFilesBuildPhase;
buildActionMask = 2147483647;
dstPath = "";
dstSubfolderSpec = 6;
files = (
);
name = "Embed CLI";
runOnlyForDeploymentPostprocessing = 0;
};
/* End PBXCopyFilesBuildPhase section */

/* Begin PBXFileReference section */
Expand All @@ -72,13 +85,16 @@
BD60D3B625D58D9A0075CC34 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = "<group>"; };
BD60D3B725D58D9A0075CC34 /* SecureEnclaveTokenExtension.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = SecureEnclaveTokenExtension.entitlements; sourceTree = "<group>"; };
BD60D3C125D58E5A0075CC34 /* SecureEnclaveTokenUtils.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureEnclaveTokenUtils.swift; sourceTree = "<group>"; };
D98B035828DF8CFE00D6EB1C /* main.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = main.swift; sourceTree = "<group>"; };
D98B035D28E0915200D6EB1C /* SecureEnclaveTokenCLI.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = SecureEnclaveTokenCLI.swift; sourceTree = "<group>"; };
/* End PBXFileReference section */

/* Begin PBXFrameworksBuildPhase section */
BD60D38D25D58D6F0075CC34 /* Frameworks */ = {
isa = PBXFrameworksBuildPhase;
buildActionMask = 2147483647;
files = (
D98B035C28DF955900D6EB1C /* ArgumentParser in Frameworks */,
BDE0445E25E0228C00C984E3 /* CertificateSigningRequest in Frameworks */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -118,11 +134,12 @@
children = (
BD60D39325D58D6F0075CC34 /* AppDelegate.swift */,
BD60D39525D58D6F0075CC34 /* ContentView.swift */,
D98B035D28E0915200D6EB1C /* SecureEnclaveTokenCLI.swift */,
BD60D3C125D58E5A0075CC34 /* SecureEnclaveTokenUtils.swift */,
BD60D39725D58D6F0075CC34 /* Assets.xcassets */,
BD60D39C25D58D6F0075CC34 /* Main.storyboard */,
BD60D39F25D58D6F0075CC34 /* Info.plist */,
BD60D3A025D58D6F0075CC34 /* SecureEnclaveToken.entitlements */,
BD60D39F25D58D6F0075CC34 /* Info.plist */,
D98B035828DF8CFE00D6EB1C /* main.swift */,
BD60D39725D58D6F0075CC34 /* Assets.xcassets */,
BD60D39925D58D6F0075CC34 /* Preview Content */,
);
path = SecureEnclaveToken;
Expand All @@ -131,6 +148,7 @@
BD60D39925D58D6F0075CC34 /* Preview Content */ = {
isa = PBXGroup;
children = (
BD60D39C25D58D6F0075CC34 /* Main.storyboard */,
BD60D39A25D58D6F0075CC34 /* Preview Assets.xcassets */,
);
path = "Preview Content";
Expand Down Expand Up @@ -168,6 +186,7 @@
BD60D38E25D58D6F0075CC34 /* Resources */,
BD60D3BE25D58D9A0075CC34 /* Embed App Extensions */,
BD6D6EE625DD910E00C507B4 /* Embed Frameworks */,
D99219A828DF7DAE0088BA56 /* Embed CLI */,
);
buildRules = (
);
Expand All @@ -177,6 +196,7 @@
name = SecureEnclaveToken;
packageProductDependencies = (
BDE0445D25E0228C00C984E3 /* CertificateSigningRequest */,
D98B035B28DF955900D6EB1C /* ArgumentParser */,
);
productName = SecureEnclaveToken;
productReference = BD60D39025D58D6F0075CC34 /* SecureEnclaveToken.app */;
Expand Down Expand Up @@ -205,7 +225,7 @@
BD60D38825D58D6F0075CC34 /* Project object */ = {
isa = PBXProject;
attributes = {
LastSwiftUpdateCheck = 1240;
LastSwiftUpdateCheck = 1400;
LastUpgradeCheck = 1320;
TargetAttributes = {
BD60D38F25D58D6F0075CC34 = {
Expand All @@ -217,7 +237,7 @@
};
};
buildConfigurationList = BD60D38B25D58D6F0075CC34 /* Build configuration list for PBXProject "SecureEnclaveToken" */;
compatibilityVersion = "Xcode 9.3";
compatibilityVersion = "Xcode 14.0";
developmentRegion = en;
hasScannedForEncodings = 0;
knownRegions = (
Expand All @@ -227,6 +247,7 @@
mainGroup = BD60D38725D58D6F0075CC34;
packageReferences = (
BDE0445C25E0228C00C984E3 /* XCRemoteSwiftPackageReference "CertificateSigningRequest" */,
D98B035A28DF955900D6EB1C /* XCRemoteSwiftPackageReference "swift-argument-parser" */,
);
productRefGroup = BD60D39125D58D6F0075CC34 /* Products */;
projectDirPath = "";
Expand Down Expand Up @@ -263,8 +284,10 @@
isa = PBXSourcesBuildPhase;
buildActionMask = 2147483647;
files = (
D98B035E28E0915200D6EB1C /* SecureEnclaveTokenCLI.swift in Sources */,
BD60D39625D58D6F0075CC34 /* ContentView.swift in Sources */,
BD60D39425D58D6F0075CC34 /* AppDelegate.swift in Sources */,
D98B035928DF8CFE00D6EB1C /* main.swift in Sources */,
BD60D3C225D58E5A0075CC34 /* SecureEnclaveTokenUtils.swift in Sources */,
);
runOnlyForDeploymentPostprocessing = 0;
Expand Down Expand Up @@ -435,11 +458,12 @@
"$(PROJECT_DIR)",
);
INFOPLIST_FILE = SecureEnclaveToken/Info.plist;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.0.2;
MARKETING_VERSION = 2.0;
PRODUCT_BUNDLE_IDENTIFIER = com.mwielgoszewski.SecureEnclaveToken;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand All @@ -465,11 +489,12 @@
"$(PROJECT_DIR)",
);
INFOPLIST_FILE = SecureEnclaveToken/Info.plist;
INFOPLIST_KEY_LSApplicationCategoryType = "public.app-category.utilities";
LD_RUNPATH_SEARCH_PATHS = (
"$(inherited)",
"@executable_path/../Frameworks",
);
MARKETING_VERSION = 1.0.2;
MARKETING_VERSION = 2.0;
PRODUCT_BUNDLE_IDENTIFIER = com.mwielgoszewski.SecureEnclaveToken;
PRODUCT_NAME = "$(TARGET_NAME)";
SWIFT_VERSION = 5.0;
Expand Down Expand Up @@ -563,6 +588,14 @@
kind = branch;
};
};
D98B035A28DF955900D6EB1C /* XCRemoteSwiftPackageReference "swift-argument-parser" */ = {
isa = XCRemoteSwiftPackageReference;
repositoryURL = "https://github.com/apple/swift-argument-parser.git";
requirement = {
kind = upToNextMajorVersion;
minimumVersion = 1.0.0;
};
};
/* End XCRemoteSwiftPackageReference section */

/* Begin XCSwiftPackageProductDependency section */
Expand All @@ -571,6 +604,11 @@
package = BDE0445C25E0228C00C984E3 /* XCRemoteSwiftPackageReference "CertificateSigningRequest" */;
productName = CertificateSigningRequest;
};
D98B035B28DF955900D6EB1C /* ArgumentParser */ = {
isa = XCSwiftPackageProductDependency;
package = D98B035A28DF955900D6EB1C /* XCRemoteSwiftPackageReference "swift-argument-parser" */;
productName = ArgumentParser;
};
/* End XCSwiftPackageProductDependency section */
};
rootObject = BD60D38825D58D6F0075CC34 /* Project object */;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,23 @@
{
"object": {
"pins": [
{
"package": "CertificateSigningRequest",
"repositoryURL": "https://github.com/mwielgoszewski/CertificateSigningRequest",
"state": {
"branch": "feature/extension-requests",
"revision": "0ee3a1a90c525b65a3f0079c4436ae4ce17944b0",
"version": null
}
"pins" : [
{
"identity" : "certificatesigningrequest",
"kind" : "remoteSourceControl",
"location" : "https://github.com/mwielgoszewski/CertificateSigningRequest",
"state" : {
"branch" : "feature/extension-requests",
"revision" : "f2cf3284bf2763772ea0e81f107df030ac7b9e23"
}
]
},
"version": 1
},
{
"identity" : "swift-argument-parser",
"kind" : "remoteSourceControl",
"location" : "https://github.com/apple/swift-argument-parser.git",
"state" : {
"revision" : "9f39744e025c7d377987f30b03770805dcb0bcd1",
"version" : "1.1.4"
}
}
],
"version" : 2
}
15 changes: 12 additions & 3 deletions SecureEnclaveToken/AppDelegate.swift
Original file line number Diff line number Diff line change
Expand Up @@ -7,20 +7,29 @@

import Cocoa
import SwiftUI
import ArgumentParser

@main
class AppDelegate: NSObject, NSApplicationDelegate {

var window: NSWindow!

func applicationDidFinishLaunching(_ aNotification: Notification) {
// arg.0 is the current executable
let args = Array(CommandLine.arguments.dropFirst())

// execute this as a cli app, then exit immediately
if args.first == "cli" {
SecureEnclaveTokenCLI.main(Array(args.dropFirst()))
exit(0)
}

// Create the SwiftUI view that provides the window contents.
let contentView = ContentView()

// Create the window and set the content view.
window = NSWindow(
contentRect: NSRect(x: 0, y: 0, width: 480, height: 300),
styleMask: [.titled, .closable, .miniaturizable, .resizable, .fullSizeContentView],
contentRect: NSRect(x: 0, y: 0, width: 480, height: 640),
styleMask: [.titled, .closable, .miniaturizable, .fullSizeContentView],
backing: .buffered, defer: false)
window.isReleasedWhenClosed = false
window.center()
Expand Down
Loading

0 comments on commit c0ff940

Please sign in to comment.