Skip to content

Commit 69be467

Browse files
Merge pull request #8382 from woocommerce/feat/8381-protocol-for-application-password
Create `ApplicationPasswordUseCase` protocol.
2 parents b2901bd + 9a3fc9e commit 69be467

File tree

2 files changed

+42
-0
lines changed

2 files changed

+42
-0
lines changed

Networking/Networking.xcodeproj/project.pbxproj

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -725,6 +725,7 @@
725725
E1BAB2C32913FA6400C3982B /* ResponseDataValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1BAB2C22913FA6400C3982B /* ResponseDataValidator.swift */; };
726726
E1BAB2C52913FB1800C3982B /* WordPressApiValidator.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1BAB2C42913FB1800C3982B /* WordPressApiValidator.swift */; };
727727
E1BAB2C72913FB5800C3982B /* WordPressApiError.swift in Sources */ = {isa = PBXBuildFile; fileRef = E1BAB2C62913FB5800C3982B /* WordPressApiError.swift */; };
728+
EE54C8942947229800A9BF61 /* ApplicationPasswordUseCase.swift in Sources */ = {isa = PBXBuildFile; fileRef = EE54C8932947229800A9BF61 /* ApplicationPasswordUseCase.swift */; };
728729
EE8A86F1286C5226003E8AA4 /* media-update-product-id-in-wordpress-site.json in Resources */ = {isa = PBXBuildFile; fileRef = EE8A86F0286C5226003E8AA4 /* media-update-product-id-in-wordpress-site.json */; };
729730
EECB7EE8286555180028C888 /* media-update-product-id.json in Resources */ = {isa = PBXBuildFile; fileRef = EECB7EE7286555180028C888 /* media-update-product-id.json */; };
730731
FE28F6E226840DED004465C7 /* User.swift in Sources */ = {isa = PBXBuildFile; fileRef = FE28F6E126840DED004465C7 /* User.swift */; };
@@ -1482,6 +1483,7 @@
14821483
E1BAB2C22913FA6400C3982B /* ResponseDataValidator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ResponseDataValidator.swift; sourceTree = "<group>"; };
14831484
E1BAB2C42913FB1800C3982B /* WordPressApiValidator.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressApiValidator.swift; sourceTree = "<group>"; };
14841485
E1BAB2C62913FB5800C3982B /* WordPressApiError.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = WordPressApiError.swift; sourceTree = "<group>"; };
1486+
EE54C8932947229800A9BF61 /* ApplicationPasswordUseCase.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = ApplicationPasswordUseCase.swift; sourceTree = "<group>"; };
14851487
EE8A86F0286C5226003E8AA4 /* media-update-product-id-in-wordpress-site.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "media-update-product-id-in-wordpress-site.json"; sourceTree = "<group>"; };
14861488
EECB7EE7286555180028C888 /* media-update-product-id.json */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.json; path = "media-update-product-id.json"; sourceTree = "<group>"; };
14871489
F3F25DC15EC1D7C631169CB5 /* Pods_Networking.framework */ = {isa = PBXFileReference; explicitFileType = wrapper.framework; includeInIndex = 0; path = Pods_Networking.framework; sourceTree = BUILT_PRODUCTS_DIR; };
@@ -1805,6 +1807,7 @@
18051807
B557D9E5209753AA005962F4 /* Networking */ = {
18061808
isa = PBXGroup;
18071809
children = (
1810+
EE54C8922947227900A9BF61 /* ApplicationPassword */,
18081811
B5A0369F214C0F4C00774E2C /* Internal */,
18091812
B5BB1D0A20A204F400112D92 /* Extensions */,
18101813
B567AF2720A0FA0A00AB6C62 /* Mapper */,
@@ -2563,6 +2566,14 @@
25632566
path = SystemStatusDetails;
25642567
sourceTree = "<group>";
25652568
};
2569+
EE54C8922947227900A9BF61 /* ApplicationPassword */ = {
2570+
isa = PBXGroup;
2571+
children = (
2572+
EE54C8932947229800A9BF61 /* ApplicationPasswordUseCase.swift */,
2573+
);
2574+
path = ApplicationPassword;
2575+
sourceTree = "<group>";
2576+
};
25662577
/* End PBXGroup section */
25672578

25682579
/* Begin PBXHeadersBuildPhase section */
@@ -3048,6 +3059,7 @@
30483059
743E84EE2217244C00FAC9D7 /* ShipmentTrackingListMapper.swift in Sources */,
30493060
451A97E5260B631E0059D135 /* ShippingLabelPredefinedPackage.swift in Sources */,
30503061
BAB373722795A1FB00837B4A /* OrderTaxLine.swift in Sources */,
3062+
EE54C8942947229800A9BF61 /* ApplicationPasswordUseCase.swift in Sources */,
30513063
B567AF2520A0CCA300AB6C62 /* AuthenticatedRequest.swift in Sources */,
30523064
453305E92459DF2100264E50 /* PostMapper.swift in Sources */,
30533065
E12552C526385B05001CEE70 /* ShippingLabelAddressValidationSuccess.swift in Sources */,
Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,30 @@
1+
import Foundation
2+
import WordPressShared
3+
4+
struct ApplicationPassword {
5+
/// WordPress org username that the application password belongs to
6+
///
7+
let wpOrgUsername: String
8+
9+
/// Application password
10+
///
11+
let password: Secret<String>
12+
}
13+
14+
protocol ApplicationPasswordUseCase {
15+
/// Returns the locally saved ApplicationPassword if available
16+
///
17+
var applicationPassword: ApplicationPassword? { get }
18+
19+
/// Generates new ApplicationPassword
20+
///
21+
/// - Returns: Generated `ApplicationPassword` instance
22+
///
23+
func generateNewPassword() async throws -> ApplicationPassword
24+
25+
/// Deletes the application password
26+
///
27+
/// Deletes locally and also sends an API request to delete it from the site
28+
///
29+
func deletePassword() async throws
30+
}

0 commit comments

Comments
 (0)