Fix license validation bug
This commit is contained in:
parent
ba239e6418
commit
9fb36eddea
@ -7,11 +7,11 @@
|
|||||||
objects = {
|
objects = {
|
||||||
|
|
||||||
/* Begin PBXBuildFile section */
|
/* Begin PBXBuildFile section */
|
||||||
|
E11CB51E2DB1F8AF00F9F3ED /* whisper.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E11CB51D2DB1F8AF00F9F3ED /* whisper.xcframework */; };
|
||||||
|
E11CB51F2DB1F8AF00F9F3ED /* whisper.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E11CB51D2DB1F8AF00F9F3ED /* whisper.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
||||||
E1A261122CC143AC00B233D1 /* KeyboardShortcuts in Frameworks */ = {isa = PBXBuildFile; productRef = E1A261112CC143AC00B233D1 /* KeyboardShortcuts */; };
|
E1A261122CC143AC00B233D1 /* KeyboardShortcuts in Frameworks */ = {isa = PBXBuildFile; productRef = E1A261112CC143AC00B233D1 /* KeyboardShortcuts */; };
|
||||||
E1ADD45A2CC5352A00303ECB /* LaunchAtLogin in Frameworks */ = {isa = PBXBuildFile; productRef = E1ADD4592CC5352A00303ECB /* LaunchAtLogin */; };
|
E1ADD45A2CC5352A00303ECB /* LaunchAtLogin in Frameworks */ = {isa = PBXBuildFile; productRef = E1ADD4592CC5352A00303ECB /* LaunchAtLogin */; };
|
||||||
E1ADD45F2CC544F100303ECB /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = E1ADD45E2CC544F100303ECB /* Sparkle */; };
|
E1ADD45F2CC544F100303ECB /* Sparkle in Frameworks */ = {isa = PBXBuildFile; productRef = E1ADD45E2CC544F100303ECB /* Sparkle */; };
|
||||||
E1F5FA752DA6CBD700B1FD8A /* whisper.xcframework in Frameworks */ = {isa = PBXBuildFile; fileRef = E136D0102DA3EE57000E1E8A /* whisper.xcframework */; };
|
|
||||||
E1F5FA762DA6CBD700B1FD8A /* whisper.xcframework in Embed Frameworks */ = {isa = PBXBuildFile; fileRef = E136D0102DA3EE57000E1E8A /* whisper.xcframework */; settings = {ATTRIBUTES = (CodeSignOnCopy, RemoveHeadersOnCopy, ); }; };
|
|
||||||
E1F5FA7A2DA6CBF900B1FD8A /* Zip in Frameworks */ = {isa = PBXBuildFile; productRef = E1F5FA792DA6CBF900B1FD8A /* Zip */; };
|
E1F5FA7A2DA6CBF900B1FD8A /* Zip in Frameworks */ = {isa = PBXBuildFile; productRef = E1F5FA792DA6CBF900B1FD8A /* Zip */; };
|
||||||
/* End PBXBuildFile section */
|
/* End PBXBuildFile section */
|
||||||
|
|
||||||
@ -33,13 +33,13 @@
|
|||||||
/* End PBXContainerItemProxy section */
|
/* End PBXContainerItemProxy section */
|
||||||
|
|
||||||
/* Begin PBXCopyFilesBuildPhase section */
|
/* Begin PBXCopyFilesBuildPhase section */
|
||||||
E1F5FA772DA6CBD700B1FD8A /* Embed Frameworks */ = {
|
E11CB5202DB1F8AF00F9F3ED /* Embed Frameworks */ = {
|
||||||
isa = PBXCopyFilesBuildPhase;
|
isa = PBXCopyFilesBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
dstPath = "";
|
dstPath = "";
|
||||||
dstSubfolderSpec = 10;
|
dstSubfolderSpec = 10;
|
||||||
files = (
|
files = (
|
||||||
E1F5FA762DA6CBD700B1FD8A /* whisper.xcframework in Embed Frameworks */,
|
E11CB51F2DB1F8AF00F9F3ED /* whisper.xcframework in Embed Frameworks */,
|
||||||
);
|
);
|
||||||
name = "Embed Frameworks";
|
name = "Embed Frameworks";
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@ -50,6 +50,7 @@
|
|||||||
E11473B02CBE0F0A00318EE4 /* VoiceInk.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VoiceInk.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
E11473B02CBE0F0A00318EE4 /* VoiceInk.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = VoiceInk.app; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
E11473C32CBE0F0B00318EE4 /* VoiceInkTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VoiceInkTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
E11473C32CBE0F0B00318EE4 /* VoiceInkTests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VoiceInkTests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
E11473CD2CBE0F0B00318EE4 /* VoiceInkUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VoiceInkUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
E11473CD2CBE0F0B00318EE4 /* VoiceInkUITests.xctest */ = {isa = PBXFileReference; explicitFileType = wrapper.cfbundle; includeInIndex = 0; path = VoiceInkUITests.xctest; sourceTree = BUILT_PRODUCTS_DIR; };
|
||||||
|
E11CB51D2DB1F8AF00F9F3ED /* whisper.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = whisper.xcframework; path = "../build-apple/whisper.xcframework"; sourceTree = "<group>"; };
|
||||||
E136D0102DA3EE57000E1E8A /* whisper.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = whisper.xcframework; path = "../Downloads/build-apple/whisper.xcframework"; sourceTree = "<group>"; };
|
E136D0102DA3EE57000E1E8A /* whisper.xcframework */ = {isa = PBXFileReference; lastKnownFileType = wrapper.xcframework; name = whisper.xcframework; path = "../Downloads/build-apple/whisper.xcframework"; sourceTree = "<group>"; };
|
||||||
/* End PBXFileReference section */
|
/* End PBXFileReference section */
|
||||||
|
|
||||||
@ -76,10 +77,10 @@
|
|||||||
isa = PBXFrameworksBuildPhase;
|
isa = PBXFrameworksBuildPhase;
|
||||||
buildActionMask = 2147483647;
|
buildActionMask = 2147483647;
|
||||||
files = (
|
files = (
|
||||||
E1F5FA752DA6CBD700B1FD8A /* whisper.xcframework in Frameworks */,
|
|
||||||
E1ADD45A2CC5352A00303ECB /* LaunchAtLogin in Frameworks */,
|
E1ADD45A2CC5352A00303ECB /* LaunchAtLogin in Frameworks */,
|
||||||
E1ADD45F2CC544F100303ECB /* Sparkle in Frameworks */,
|
E1ADD45F2CC544F100303ECB /* Sparkle in Frameworks */,
|
||||||
E1A261122CC143AC00B233D1 /* KeyboardShortcuts in Frameworks */,
|
E1A261122CC143AC00B233D1 /* KeyboardShortcuts in Frameworks */,
|
||||||
|
E11CB51E2DB1F8AF00F9F3ED /* whisper.xcframework in Frameworks */,
|
||||||
E1F5FA7A2DA6CBF900B1FD8A /* Zip in Frameworks */,
|
E1F5FA7A2DA6CBF900B1FD8A /* Zip in Frameworks */,
|
||||||
);
|
);
|
||||||
runOnlyForDeploymentPostprocessing = 0;
|
runOnlyForDeploymentPostprocessing = 0;
|
||||||
@ -125,6 +126,7 @@
|
|||||||
E114741C2CBE1DE200318EE4 /* Frameworks */ = {
|
E114741C2CBE1DE200318EE4 /* Frameworks */ = {
|
||||||
isa = PBXGroup;
|
isa = PBXGroup;
|
||||||
children = (
|
children = (
|
||||||
|
E11CB51D2DB1F8AF00F9F3ED /* whisper.xcframework */,
|
||||||
E136D0102DA3EE57000E1E8A /* whisper.xcframework */,
|
E136D0102DA3EE57000E1E8A /* whisper.xcframework */,
|
||||||
);
|
);
|
||||||
name = Frameworks;
|
name = Frameworks;
|
||||||
@ -140,7 +142,7 @@
|
|||||||
E11473AC2CBE0F0A00318EE4 /* Sources */,
|
E11473AC2CBE0F0A00318EE4 /* Sources */,
|
||||||
E11473AD2CBE0F0A00318EE4 /* Frameworks */,
|
E11473AD2CBE0F0A00318EE4 /* Frameworks */,
|
||||||
E11473AE2CBE0F0A00318EE4 /* Resources */,
|
E11473AE2CBE0F0A00318EE4 /* Resources */,
|
||||||
E1F5FA772DA6CBD700B1FD8A /* Embed Frameworks */,
|
E11CB5202DB1F8AF00F9F3ED /* Embed Frameworks */,
|
||||||
);
|
);
|
||||||
buildRules = (
|
buildRules = (
|
||||||
);
|
);
|
||||||
|
|||||||
@ -1,34 +1,42 @@
|
|||||||
{
|
{
|
||||||
"object": {
|
"originHash" : "0bc73a42c360669f47256cb279b2e4e433ec96b0626a6e14ea30fbb197203b4a",
|
||||||
"pins": [
|
"pins" : [
|
||||||
{
|
{
|
||||||
"package": "KeyboardShortcuts",
|
"identity" : "keyboardshortcuts",
|
||||||
"repositoryURL": "https://github.com/sindresorhus/KeyboardShortcuts",
|
"kind" : "remoteSourceControl",
|
||||||
"state": {
|
"location" : "https://github.com/sindresorhus/KeyboardShortcuts",
|
||||||
"branch": null,
|
"state" : {
|
||||||
"revision": "7ecc38bb6edf7d087d30e737057b8d8a9b7f51eb",
|
"revision" : "7ecc38bb6edf7d087d30e737057b8d8a9b7f51eb",
|
||||||
"version": "2.2.4"
|
"version" : "2.2.4"
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"package": "LaunchAtLogin",
|
|
||||||
"repositoryURL": "https://github.com/sindresorhus/LaunchAtLogin-Modern",
|
|
||||||
"state": {
|
|
||||||
"branch": "main",
|
|
||||||
"revision": "a04ec1c363be3627734f6dad757d82f5d4fa8fcc",
|
|
||||||
"version": null
|
|
||||||
}
|
|
||||||
},
|
|
||||||
{
|
|
||||||
"package": "Sparkle",
|
|
||||||
"repositoryURL": "https://github.com/sparkle-project/Sparkle",
|
|
||||||
"state": {
|
|
||||||
"branch": null,
|
|
||||||
"revision": "0ef1ee0220239b3776f433314515fd849025673f",
|
|
||||||
"version": "2.6.4"
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
]
|
},
|
||||||
},
|
{
|
||||||
"version": 1
|
"identity" : "launchatlogin-modern",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/sindresorhus/LaunchAtLogin-Modern",
|
||||||
|
"state" : {
|
||||||
|
"branch" : "main",
|
||||||
|
"revision" : "a04ec1c363be3627734f6dad757d82f5d4fa8fcc"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "sparkle",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/sparkle-project/Sparkle",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "0ef1ee0220239b3776f433314515fd849025673f",
|
||||||
|
"version" : "2.6.4"
|
||||||
|
}
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"identity" : "zip?tab=readme-ov-file",
|
||||||
|
"kind" : "remoteSourceControl",
|
||||||
|
"location" : "https://github.com/marmelroy/Zip?tab=readme-ov-file",
|
||||||
|
"state" : {
|
||||||
|
"revision" : "67fa55813b9e7b3b9acee9c0ae501def28746d76",
|
||||||
|
"version" : "2.1.2"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
],
|
||||||
|
"version" : 3
|
||||||
}
|
}
|
||||||
|
|||||||
@ -20,7 +20,7 @@ class LicenseViewModel: ObservableObject {
|
|||||||
private let userDefaults = UserDefaults.standard
|
private let userDefaults = UserDefaults.standard
|
||||||
|
|
||||||
init() {
|
init() {
|
||||||
checkLicenseState()
|
loadLicenseState()
|
||||||
}
|
}
|
||||||
|
|
||||||
func startTrial() {
|
func startTrial() {
|
||||||
@ -32,40 +32,17 @@ class LicenseViewModel: ObservableObject {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private func checkLicenseState() {
|
private func loadLicenseState() {
|
||||||
// Check for existing license key
|
// Check for existing license key
|
||||||
if let licenseKey = userDefaults.licenseKey {
|
if let licenseKey = userDefaults.licenseKey {
|
||||||
self.licenseKey = licenseKey
|
self.licenseKey = licenseKey
|
||||||
|
|
||||||
// Check if this license requires activation
|
// If we have a license key, trust that it's licensed
|
||||||
if userDefaults.bool(forKey: "VoiceInkLicenseRequiresActivation") {
|
// Skip server validation on startup
|
||||||
// If we have an activation ID, we need to validate it
|
if userDefaults.activationId != nil || !userDefaults.bool(forKey: "VoiceInkLicenseRequiresActivation") {
|
||||||
if let activationId = userDefaults.activationId {
|
|
||||||
Task {
|
|
||||||
do {
|
|
||||||
let isValid = try await polarService.validateLicenseKeyWithActivation(licenseKey, activationId: activationId)
|
|
||||||
if isValid {
|
|
||||||
licenseState = .licensed
|
|
||||||
} else {
|
|
||||||
// If validation fails, we'll need to reactivate
|
|
||||||
userDefaults.activationId = nil
|
|
||||||
licenseState = .trialExpired
|
|
||||||
}
|
|
||||||
} catch {
|
|
||||||
// If there's an error, we'll need to reactivate
|
|
||||||
userDefaults.activationId = nil
|
|
||||||
licenseState = .trialExpired
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// We have a license key but no activation ID, so we need to activate
|
|
||||||
licenseState = .licensed
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
// This license doesn't require activation (unlimited devices)
|
|
||||||
licenseState = .licensed
|
licenseState = .licensed
|
||||||
|
return
|
||||||
}
|
}
|
||||||
return
|
|
||||||
}
|
}
|
||||||
|
|
||||||
// Check if this is first launch
|
// Check if this is first launch
|
||||||
@ -194,7 +171,7 @@ class LicenseViewModel: ObservableObject {
|
|||||||
licenseKey = ""
|
licenseKey = ""
|
||||||
validationMessage = nil
|
validationMessage = nil
|
||||||
NotificationCenter.default.post(name: .licenseStatusChanged, object: nil)
|
NotificationCenter.default.post(name: .licenseStatusChanged, object: nil)
|
||||||
checkLicenseState()
|
loadLicenseState()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
Loading…
x
Reference in New Issue
Block a user