Skip to content

Commit

Permalink
Restructure Sample Code And Add Sample App
Browse files Browse the repository at this point in the history
  • Loading branch information
nidal-stytch committed Sep 5, 2024
1 parent 90c9170 commit 7e52816
Show file tree
Hide file tree
Showing 47 changed files with 760 additions and 310 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,8 @@
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES">
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
<BuildActionEntries>
<BuildActionEntry
buildForTesting = "YES"
Expand All @@ -14,10 +15,10 @@
buildForAnalyzing = "YES">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "229B82172809EA3F007BC3F1"
BuildableName = "Stytch.app"
BlueprintName = "Stytch (iOS)"
ReferencedContainer = "container:Stytch.xcodeproj">
BlueprintIdentifier = "StytchUI"
BuildableName = "StytchUI"
BlueprintName = "StytchUI"
ReferencedContainer = "container:">
</BuildableReference>
</BuildActionEntry>
</BuildActionEntries>
Expand All @@ -39,33 +40,22 @@
debugDocumentVersioning = "YES"
debugServiceExtension = "internal"
allowLocationSimulation = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "229B82172809EA3F007BC3F1"
BuildableName = "Stytch.app"
BlueprintName = "Stytch (iOS)"
ReferencedContainer = "container:Stytch.xcodeproj">
</BuildableReference>
</BuildableProductRunnable>
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
<BuildableProductRunnable
runnableDebuggingMode = "0">
<MacroExpansion>
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "229B82172809EA3F007BC3F1"
BuildableName = "Stytch.app"
BlueprintName = "Stytch (iOS)"
ReferencedContainer = "container:Stytch.xcodeproj">
BlueprintIdentifier = "StytchUI"
BuildableName = "StytchUI"
BlueprintName = "StytchUI"
ReferencedContainer = "container:">
</BuildableReference>
</BuildableProductRunnable>
</MacroExpansion>
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
Expand Down
54 changes: 54 additions & 0 deletions .swiftpm/xcode/xcshareddata/xcschemes/StytchUIUnitTests.xcscheme
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
<?xml version="1.0" encoding="UTF-8"?>
<Scheme
LastUpgradeVersion = "1540"
version = "1.7">
<BuildAction
parallelizeBuildables = "YES"
buildImplicitDependencies = "YES"
buildArchitectures = "Automatic">
</BuildAction>
<TestAction
buildConfiguration = "Debug"
selectedDebuggerIdentifier = "Xcode.DebuggerFoundation.Debugger.LLDB"
selectedLauncherIdentifier = "Xcode.DebuggerFoundation.Launcher.LLDB"
shouldUseLaunchSchemeArgsEnv = "YES"
shouldAutocreateTestPlan = "YES">
<Testables>
<TestableReference
skipped = "NO">
<BuildableReference
BuildableIdentifier = "primary"
BlueprintIdentifier = "StytchUIUnitTests"
BuildableName = "StytchUIUnitTests"
BlueprintName = "StytchUIUnitTests"
ReferencedContainer = "container:">
</BuildableReference>
</TestableReference>
</Testables>
</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">
</LaunchAction>
<ProfileAction
buildConfiguration = "Release"
shouldUseLaunchSchemeArgsEnv = "YES"
savedToolIdentifier = ""
useCustomWorkingDirectory = "NO"
debugDocumentVersioning = "YES">
</ProfileAction>
<AnalyzeAction
buildConfiguration = "Debug">
</AnalyzeAction>
<ArchiveAction
buildConfiguration = "Release"
revealArchiveInOrganizer = "YES">
</ArchiveAction>
</Scheme>
14 changes: 6 additions & 8 deletions Stytch/DemoApps/B2BWorkbench/Base.lproj/LaunchScreen.storyboard
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,10 @@
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="b2b-Wordmark-light-mode" translatesAutoresizingMaskIntoConstraints="NO" id="47Q-Qs-gXw">
<rect key="frame" x="76.666666666666686" y="159" width="240" height="128"/>
<constraints>
<constraint firstAttribute="height" constant="128" id="70u-s2-ora"/>
<constraint firstAttribute="width" constant="240" id="pSw-Fk-GZL"/>
</constraints>
<rect key="frame" x="0.0" y="346" width="393.00000000000006" height="160"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="B2B Workbench" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="XCe-DR-3EE">
<rect key="frame" x="16" y="287" width="361" height="50"/>
<rect key="frame" x="16" y="768" width="361" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="o0j-X9-TDm"/>
</constraints>
Expand All @@ -37,11 +33,13 @@
<viewLayoutGuide key="safeArea" id="6Tk-OE-BBY"/>
<color key="backgroundColor" systemColor="systemBackgroundColor"/>
<constraints>
<constraint firstItem="XCe-DR-3EE" firstAttribute="top" secondItem="47Q-Qs-gXw" secondAttribute="bottom" id="LJ8-Xq-MGL"/>
<constraint firstAttribute="trailing" secondItem="47Q-Qs-gXw" secondAttribute="trailing" id="BUv-2K-v1t"/>
<constraint firstItem="XCe-DR-3EE" firstAttribute="leading" secondItem="6Tk-OE-BBY" secondAttribute="leading" constant="16" id="RUe-Xg-hLK"/>
<constraint firstItem="47Q-Qs-gXw" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="UvN-vE-ccl"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="trailing" secondItem="XCe-DR-3EE" secondAttribute="trailing" constant="16" id="W4s-V4-YAJ"/>
<constraint firstItem="47Q-Qs-gXw" firstAttribute="top" secondItem="6Tk-OE-BBY" secondAttribute="top" constant="100" id="pLH-JB-H01"/>
<constraint firstItem="6Tk-OE-BBY" firstAttribute="bottom" secondItem="XCe-DR-3EE" secondAttribute="bottom" id="WnF-mx-ZTJ"/>
<constraint firstItem="47Q-Qs-gXw" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="XZd-zG-fZC"/>
<constraint firstItem="47Q-Qs-gXw" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="yBF-dN-JTO"/>
</constraints>
</view>
</viewController>
Expand Down
60 changes: 60 additions & 0 deletions Stytch/DemoApps/ConsumerWorkbench/Launch Screen.storyboard
Original file line number Diff line number Diff line change
@@ -0,0 +1,60 @@
<?xml version="1.0" encoding="UTF-8"?>
<document type="com.apple.InterfaceBuilder3.CocoaTouch.Storyboard.XIB" version="3.0" toolsVersion="32700.99.1234" targetRuntime="iOS.CocoaTouch" propertyAccessControl="none" useAutolayout="YES" launchScreen="YES" useTraitCollections="YES" useSafeAreas="YES" colorMatched="YES" initialViewController="01J-lp-oVM">
<device id="retina6_12" orientation="portrait" appearance="light"/>
<dependencies>
<deployment identifier="iOS"/>
<plugIn identifier="com.apple.InterfaceBuilder.IBCocoaTouchPlugin" version="22685"/>
<capability name="Safe area layout guides" minToolsVersion="9.0"/>
<capability name="documents saved in the Xcode 8 format" minToolsVersion="8.0"/>
</dependencies>
<scenes>
<!--View Controller-->
<scene sceneID="EHf-IW-A2E">
<objects>
<viewController id="01J-lp-oVM" sceneMemberID="viewController">
<view key="view" contentMode="scaleToFill" id="Ze5-6b-2t3">
<rect key="frame" x="0.0" y="0.0" width="393" height="852"/>
<autoresizingMask key="autoresizingMask" widthSizable="YES" heightSizable="YES"/>
<subviews>
<label opaque="NO" clipsSubviews="YES" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" fixedFrame="YES" text="" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" minimumFontSize="9" translatesAutoresizingMaskIntoConstraints="NO" id="obG-Y5-kRd">
<rect key="frame" x="0.0" y="832" width="393" height="0.0"/>
<autoresizingMask key="autoresizingMask" flexibleMaxX="YES" flexibleMaxY="YES"/>
<fontDescription key="fontDescription" type="system" pointSize="17"/>
<color key="textColor" red="0.0" green="0.0" blue="0.0" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<nil key="highlightedColor"/>
</label>
<imageView clipsSubviews="YES" userInteractionEnabled="NO" contentMode="scaleAspectFit" horizontalHuggingPriority="251" verticalHuggingPriority="251" image="client-wordmark-light-mode" translatesAutoresizingMaskIntoConstraints="NO" id="lRe-LF-bCU">
<rect key="frame" x="0.0" y="346" width="393" height="160"/>
</imageView>
<label opaque="NO" userInteractionEnabled="NO" contentMode="left" horizontalHuggingPriority="251" verticalHuggingPriority="251" text="Consumer Workbench" textAlignment="center" lineBreakMode="tailTruncation" baselineAdjustment="alignBaselines" adjustsFontSizeToFit="NO" translatesAutoresizingMaskIntoConstraints="NO" id="Gw0-a6-Ypu">
<rect key="frame" x="16" y="768" width="361" height="50"/>
<constraints>
<constraint firstAttribute="height" constant="50" id="HmP-Q1-XAP"/>
</constraints>
<fontDescription key="fontDescription" type="boldSystem" pointSize="25"/>
<nil key="textColor"/>
<nil key="highlightedColor"/>
</label>
</subviews>
<viewLayoutGuide key="safeArea" id="Bcu-3y-fUS"/>
<color key="backgroundColor" red="1" green="1" blue="1" alpha="1" colorSpace="custom" customColorSpace="sRGB"/>
<constraints>
<constraint firstAttribute="trailing" secondItem="lRe-LF-bCU" secondAttribute="trailing" id="0EU-aW-8TO"/>
<constraint firstItem="Bcu-3y-fUS" firstAttribute="trailing" secondItem="Gw0-a6-Ypu" secondAttribute="trailing" constant="16" id="DRH-Dg-9LN"/>
<constraint firstItem="Bcu-3y-fUS" firstAttribute="bottom" secondItem="Gw0-a6-Ypu" secondAttribute="bottom" id="T5c-pO-GVy"/>
<constraint firstItem="lRe-LF-bCU" firstAttribute="leading" secondItem="Ze5-6b-2t3" secondAttribute="leading" id="lrM-Qq-8zZ"/>
<constraint firstItem="Gw0-a6-Ypu" firstAttribute="leading" secondItem="Bcu-3y-fUS" secondAttribute="leading" constant="16" id="ncl-fd-aGr"/>
<constraint firstItem="lRe-LF-bCU" firstAttribute="centerX" secondItem="Ze5-6b-2t3" secondAttribute="centerX" id="sXY-on-Anp"/>
<constraint firstItem="lRe-LF-bCU" firstAttribute="centerY" secondItem="Ze5-6b-2t3" secondAttribute="centerY" id="uYX-pp-cKC"/>
</constraints>
</view>
</viewController>
<placeholder placeholderIdentifier="IBFirstResponder" id="iYj-Kq-Ea1" userLabel="First Responder" sceneMemberID="firstResponder"/>
</objects>
<point key="canvasLocation" x="53" y="375"/>
</scene>
</scenes>
<resources>
<image name="client-wordmark-light-mode" width="850" height="160"/>
</resources>
</document>
Original file line number Diff line number Diff line change
@@ -1,4 +1,9 @@
{
"colors" : [
{
"idiom" : "universal"
}
],
"info" : {
"author" : "xcode",
"version" : 1
Expand Down
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
{
"images" : [
{
"filename" : "App icon1024x1024.png",
"idiom" : "universal",
"platform" : "ios",
"size" : "1024x1024"
}
],
"info" : {
"author" : "xcode",
"version" : 1
}
}
56 changes: 56 additions & 0 deletions Stytch/DemoApps/StytchDemo/ContentView.swift
Original file line number Diff line number Diff line change
@@ -0,0 +1,56 @@
import Combine
import StytchCore
import SwiftUI

struct ContentView: View {
@State var isAuthenticated = false
@State var subscriptions: Set<AnyCancellable> = []

var body: some View {
VStack {
if isAuthenticated {
LoggedInView()
} else {
OTPView()
}
}
.onOpenURL { url in
handle(url: url)
}
.task {
StytchClient.configure(publicToken: "public-token-test-728f8b82-2a20-4926-b077-a8ca7d67e1b2")
setUpObservations()
}
}

func setUpObservations() {
StytchClient.sessions.onAuthChange.sink { token in
if token == nil {
isAuthenticated = false
} else {
isAuthenticated = true
}
}.store(in: &subscriptions)
}

func handle(url: URL) {
Task {
do {
switch try await StytchClient.handle(url: url, sessionDuration: 5) {
case let .handled(response):
print("handled: \(response.session) - \(response.user)")
case .notHandled:
print("not handled")
case let .manualHandlingRequired(tokenType, token):
print("manualHandlingRequired: tokenType: \(tokenType) - token: \(token)")
}
} catch {
print("handle url error: \(error)")
}
}
}
}

#Preview {
ContentView()
}
17 changes: 17 additions & 0 deletions Stytch/DemoApps/StytchDemo/Info.plist
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
<key>CFBundleURLTypes</key>
<array>
<dict>
<key>CFBundleTypeRole</key>
<string>Editor</string>
<key>CFBundleURLSchemes</key>
<array>
<string>stytch-demo</string>
</array>
</dict>
</array>
</dict>
</plist>
Loading

0 comments on commit 7e52816

Please sign in to comment.