Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[JWT] App startup + other JWT PRs merged here #1473

Open
wants to merge 61 commits into
base: internal_dump_method
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
61 commits
Select commit Hold shift + click to select a range
3f83a50
[dev app] for testing, revert later
nan-li Aug 4, 2024
aa7f3e8
internal dump method helper filled out
nan-li May 28, 2024
408ef55
Add internal JWT Config management and listener
nan-li Aug 17, 2024
7af6373
mock remote params returning use JWT = true
nan-li Aug 17, 2024
ec84c2c
Add JWT constants to Common Defines
nan-li Aug 17, 2024
d3eb08d
public updateUserJwt method
nan-li Aug 17, 2024
ca6b132
Helper methods to add auth headers
nan-li Aug 20, 2024
f0cfe5f
Request objects - update to consider JWT
nan-li Aug 20, 2024
2d1b317
Update Event Producer to accept multiple subscribers
nan-li Aug 20, 2024
d81c460
Add JWT Token to Identity Model
nan-li Aug 20, 2024
2774c34
Identity Model Repo listens for JWT changes
nan-li Aug 20, 2024
e7059de
Update Executors to consider JWT
nan-li Aug 20, 2024
5c98665
Operation Repo - refactor and update for JWT
nan-li Aug 22, 2024
e019d3d
User Manger - updates to login
nan-li Aug 22, 2024
a0baad8
TODOs
nan-li Aug 23, 2024
ed888cd
[tests] fix tests to build and pass, after changes
nan-li Aug 26, 2024
8694a4d
consolidate all user-related requirement checks
nan-li Aug 29, 2024
c6989b2
[nit] remove extraneous logging already done by client
nan-li Aug 27, 2024
ac887b9
[nit] log when GET requests are sent in Client
nan-li Aug 28, 2024
d19cf0c
Expose JWT config to objective c
nan-li Aug 30, 2024
40e74ee
[nit] Rename jwt token parameter for clarity
nan-li Aug 30, 2024
90a08f7
Move shared user helpers to utility class
nan-li Aug 30, 2024
c9b0a94
Modify getting IAM to use alias and jwt
nan-li Aug 30, 2024
e7eeba5
create simple way to fire invalid Jwt callback
emawby Sep 3, 2024
c0ad6c3
Adding OSJwtInvalidatedEvent and updating the JWT callback
emawby Sep 3, 2024
f926109
refactor in UserExecutor to handle 401s
emawby Sep 4, 2024
02acc2a
Unit tests for UserExecutor with identity verification on
emawby Sep 4, 2024
2530e2f
Fire callback for 401 error in property executor
emawby Sep 4, 2024
c0156d7
fire Jwt callback from subscription executor
emawby Sep 4, 2024
d5514e4
fire Jwt callback for add and remove aliases 401
emawby Sep 4, 2024
5afab13
Remove message for invalid handler
emawby Sep 11, 2024
1d0b97f
Fire JWT callback from IAMs
emawby Sep 11, 2024
f3cb3d8
Store UserExecutor requests that need auth
emawby Sep 11, 2024
aca978e
store property update requests that need auth
emawby Sep 11, 2024
1ae0deb
store alias update requests that need auth
emawby Sep 11, 2024
3542d34
Adding work in progress Subscription executor auth pends
emawby Sep 11, 2024
d90f0d2
[nit] run swiftlint
nan-li Sep 23, 2024
01c2069
cache the pending auth requests in executors
nan-li Sep 24, 2024
d579f06
Add pending to fetch user requests
nan-li Sep 24, 2024
19df3db
Don't fire JWT invalid listeners multiple times
nan-li Sep 24, 2024
cccb58c
Subscription executor wrap up, add some more tests
nan-li Sep 24, 2024
c27842c
[nits] Move public protocols out of User Manager file
nan-li Sep 24, 2024
74e4ef7
Update tests
nan-li Sep 25, 2024
0156328
Update the remote params JWT key
nan-li Oct 1, 2024
a2420ee
Re-use existing identity models for new users
nan-li Oct 1, 2024
5433ebb
Remove duplicate Create User requests
nan-li Oct 1, 2024
01fde6f
Don't send push sub for previous users to avoid transfer
nan-li Oct 1, 2024
8d0d088
Extract out User Manager Loggable extension for file length
nan-li Oct 2, 2024
b5ae642
Update JWT invalidated listener and event API
nan-li Oct 3, 2024
7d5db5e
Update tests after JWT listener API change
nan-li Oct 3, 2024
0dc2cee
Disable push sub when logout called (JWT on)
nan-li Oct 2, 2024
5ad412f
Fire user observer on logout (JWT on)
nan-li Oct 2, 2024
0d9c62d
[nit] move a method to extension for swiftlint
nan-li Oct 3, 2024
1f60b08
[nit] Clean up logging, remove hardcoded prints
nan-li Oct 4, 2024
0a81b7a
Revert back to production servers
nan-li Oct 4, 2024
1e7bce1
Merge pull request #1488 from OneSignal/identity_verification_logout
nan-li Oct 4, 2024
d4588f5
Merge pull request #1487 from OneSignal/identity_verification_multipl…
nan-li Oct 4, 2024
0bc08eb
Merge pull request #1478 from OneSignal/identity_verification_callback
nan-li Oct 4, 2024
1fbddcf
Merge pull request #1476 from OneSignal/identity_verification_get_iams
nan-li Oct 4, 2024
57c6f08
Handle when jwt_required is not returned
nan-li Oct 5, 2024
facb589
Merge pull request #1491 from OneSignal/identity_verification_works_w…
nan-li Oct 5, 2024
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion iOS_SDK/OneSignalDevApp/OneSignalDevApp/AppDelegate.h
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@
#import <UIKit/UIKit.h>
#import <OneSignalFramework/OneSignalFramework.h>

@interface AppDelegate : UIResponder <UIApplicationDelegate, OSNotificationPermissionObserver, OSInAppMessageLifecycleListener, OSPushSubscriptionObserver, OSNotificationLifecycleListener, OSInAppMessageClickListener, OSNotificationClickListener, OSUserStateObserver>
@interface AppDelegate : UIResponder <UIApplicationDelegate, OSNotificationPermissionObserver, OSInAppMessageLifecycleListener, OSPushSubscriptionObserver, OSNotificationLifecycleListener, OSInAppMessageClickListener, OSNotificationClickListener, OSUserStateObserver, OSUserJwtInvalidatedListener>

@property (strong, nonatomic) UIWindow *window;

Expand Down
11 changes: 10 additions & 1 deletion iOS_SDK/OneSignalDevApp/OneSignalDevApp/AppDelegate.m
Original file line number Diff line number Diff line change
Expand Up @@ -46,6 +46,10 @@ @implementation AppDelegate

OneSignalNotificationCenterDelegate *_notificationDelegate;

// ECM Should we ship these typedefs in OneSignalFramework.h to make them available to Objective C customers?
typedef void (^JwtCompletionBlock)(NSString*);
typedef void (^JwtExpiredBlock)(NSString *, JwtCompletionBlock);

- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {

// [FIRApp configure];
Expand All @@ -72,6 +76,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
[OneSignal.User addObserver:self];
[OneSignal.Notifications addPermissionObserver:self];
[OneSignal.InAppMessages addClickListener:self];
[OneSignal addUserJwtInvalidatedListener:self];

NSLog(@"UNUserNotificationCenter.delegate: %@", UNUserNotificationCenter.currentNotificationCenter.delegate);

Expand All @@ -87,7 +92,7 @@ - (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(
}

#define ONESIGNAL_APP_ID_DEFAULT @"77e32082-ea27-42e3-a898-c72e141824ef"
#define ONESIGNAL_APP_ID_KEY_FOR_TESTING @"YOUR_APP_ID_HERE"
#define ONESIGNAL_APP_ID_KEY_FOR_TESTING @"77e32082-ea27-42e3-a898-c72e141824ef"

+ (NSString*)getOneSignalAppId {
NSString* userDefinedAppId = [[NSUserDefaults standardUserDefaults] objectForKey:ONESIGNAL_APP_ID_KEY_FOR_TESTING];
Expand Down Expand Up @@ -121,6 +126,10 @@ - (void)onUserStateDidChangeWithState:(OSUserChangedState * _Nonnull)state {
NSLog(@"Dev App onUserStateDidChangeWithState: %@", [state jsonRepresentation]);
}

- (void)onUserJwtInvalidatedWithEvent:(OSUserJwtInvalidatedEvent * _Nonnull)event {
NSLog(@"Dev App onUserJwtInvalidatedWithEvent: %@", [event jsonRepresentation]);
}

#pragma mark OSInAppMessageDelegate

- (void)onClickInAppMessage:(OSInAppMessageClickEvent * _Nonnull)event {
Expand Down
53 changes: 40 additions & 13 deletions iOS_SDK/OneSignalDevApp/OneSignalDevApp/Base.lproj/Main.storyboard

Large diffs are not rendered by default.

Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
</array>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.onesignal.example.onesignal</string>
<string>group.com.onesignal.example.staging.onesignal</string>
</array>
</dict>
</plist>
11 changes: 10 additions & 1 deletion iOS_SDK/OneSignalDevApp/OneSignalDevApp/SwiftTest.swift
Original file line number Diff line number Diff line change
Expand Up @@ -28,10 +28,19 @@
import Foundation
import OneSignalFramework

class SwiftTest: NSObject {
class SwiftTest: NSObject, OSUserJwtInvalidatedListener {
func onUserJwtInvalidated(event: OSUserJwtInvalidatedEvent) {
print("event: \(event.jsonRepresentation())")
print("externalId: \(event.externalId)")
}

func testSwiftUserModel() {
let token1 = OneSignal.User.pushSubscription.token
let token = OneSignal.User.pushSubscription.token
OneSignal.Debug._dump()
OneSignal.login(externalId: "euid", token: "token")
OneSignal.updateUserJwt(externalId: "euid", token: "token")
OneSignal.addUserJwtInvalidatedListener(self)
OneSignal.removeUserJwtInvalidatedListener(self)
}
}
2 changes: 2 additions & 0 deletions iOS_SDK/OneSignalDevApp/OneSignalDevApp/ViewController.h
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,9 @@
@property (weak, nonatomic) IBOutlet UIButton *removeSmsButton;

@property (weak, nonatomic) IBOutlet UITextField *externalUserIdTextField;
@property (weak, nonatomic) IBOutlet UITextField *tokenTextField;
@property (weak, nonatomic) IBOutlet UIButton *loginExternalUserIdButton;
@property (weak, nonatomic) IBOutlet UIButton *updateJwtButton;
@property (weak, nonatomic) IBOutlet UIButton *logoutButton;

@property (weak, nonatomic) IBOutlet UITextField *addAliasLabelTextField;
Expand Down
12 changes: 10 additions & 2 deletions iOS_SDK/OneSignalDevApp/OneSignalDevApp/ViewController.m
Original file line number Diff line number Diff line change
Expand Up @@ -196,8 +196,16 @@ - (IBAction)inAppMessagingSegmentedControlValueChanged:(UISegmentedControl *)sen

- (IBAction)loginExternalUserId:(UIButton *)sender {
NSString* externalUserId = self.externalUserIdTextField.text;
NSLog(@"Dev App: Logging in to external user ID %@", externalUserId);
[OneSignal login:externalUserId];
NSString* token = self.tokenTextField.text;
NSLog(@"Dev App: Logging in to external user ID %@ and token %@", externalUserId, token);
[OneSignal login:externalUserId withToken:token];
}

- (IBAction)updateJwt:(id)sender {
NSString* externalUserId = self.externalUserIdTextField.text;
NSString* token = self.tokenTextField.text;
NSLog(@"Dev App: updating JWT for external user ID %@ and token %@", externalUserId, token);
[OneSignal updateUserJwt:externalUserId withToken:token];
}

- (IBAction)logout:(UIButton *)sender {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@
@property (weak, nonatomic) IBOutlet UITextField *addTriggerValue;
@property (weak, nonatomic) IBOutlet UIButton *addTriggerButton;
@property (weak, nonatomic) IBOutlet UITextField *removeTriggerKey;
- (IBAction)updateJwt:(id)sender;
@property (weak, nonatomic) IBOutlet UITextField *getTriggerKey;
@property (weak, nonatomic) IBOutlet UILabel *infoLabel;
@property (weak, nonatomic) IBOutlet UITextField *outcomeName;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
<dict>
<key>com.apple.security.application-groups</key>
<array>
<string>group.com.onesignal.example.onesignal</string>
<string>group.com.onesignal.example.staging.onesignal</string>
</array>
</dict>
</plist>
Loading
Loading