Skip to content

Commit dbbbd10

Browse files
authored
fix(pamv3): fix token in subscription session (#94)
fix(pamv3): fix token in subscription session Fix issue because of which access token not updated in subscription session.
1 parent 5e6ae3c commit dbbbd10

File tree

9 files changed

+27
-7
lines changed

9 files changed

+27
-7
lines changed

.pubnub.yml

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,14 @@
11
---
22
name: swift
33
scm: github.com/pubnub/swift
4-
version: "5.0.0"
4+
version: "5.0.1"
55
schema: 1
66
changelog:
7+
- date: 2022-01-19
8+
version: 5.0.1
9+
changes:
10+
- type: bug
11+
text: "Fix issue because of which access token not updated in subscription session."
712
- date: 2022-01-12
813
version: 5.0.0
914
changes:
@@ -434,7 +439,7 @@ sdks:
434439
- distribution-type: source
435440
distribution-repository: GitHub release
436441
package-name: PubNub
437-
location: https://github.com/pubnub/swift/archive/refs/tags/5.0.0.zip
442+
location: https://github.com/pubnub/swift/archive/refs/tags/5.0.1.zip
438443
supported-platforms:
439444
supported-operating-systems:
440445
macOS:

Examples/Example-iOS/Info.plist

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
<string>demo</string>
77
<key>PubNubSubscribeKey</key>
88
<string>demo</string>
9+
<key>PubNubUuid</key>
10+
<string>demo-user</string>
911
<key>CFBundleDevelopmentRegion</key>
1012
<string>$(DEVELOPMENT_LANGUAGE)</string>
1113
<key>CFBundleExecutable</key>

PubNub.xcodeproj/project.pbxproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2506,7 +2506,7 @@
25062506
"$(inherited)",
25072507
"$(TOOLCHAIN_DIR)/usr/lib/swift/macosx",
25082508
);
2509-
MARKETING_VERSION = 5.0.0;
2509+
MARKETING_VERSION = 5.0.1;
25102510
OTHER_CFLAGS = "$(inherited)";
25112511
OTHER_LDFLAGS = "$(inherited)";
25122512
OTHER_SWIFT_FLAGS = "$(inherited)";
@@ -2539,7 +2539,7 @@
25392539
"$(inherited)",
25402540
"$(TOOLCHAIN_DIR)/usr/lib/swift/macosx",
25412541
);
2542-
MARKETING_VERSION = 5.0.0;
2542+
MARKETING_VERSION = 5.0.1;
25432543
OTHER_CFLAGS = "$(inherited)";
25442544
OTHER_LDFLAGS = "$(inherited)";
25452545
OTHER_SWIFT_FLAGS = "$(inherited)";

PubNubSwift.podspec

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
Pod::Spec.new do |s|
22
s.name = 'PubNubSwift'
3-
s.version = '5.0.0'
3+
s.version = '5.0.1'
44
s.homepage = 'https://github.com/pubnub/swift'
55
s.documentation_url = 'https://www.pubnub.com/docs/swift-native/pubnub-swift-sdk'
66
s.authors = { 'PubNub, Inc.' => '[email protected]' }

Sources/PubNub/Helpers/Constants.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,7 +62,7 @@ public struct Constant {
6262
}()
6363

6464
static let pubnubSwiftSDKVersion: String = {
65-
"5.0.0"
65+
"5.0.1"
6666
}()
6767

6868
static let appBundleId: String = {

Sources/PubNub/PubNub.swift

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2041,6 +2041,7 @@ extension PubNub {
20412041
/// - Parameter token: The token to add to the Token Management System.
20422042
public mutating func set(token: String) {
20432043
configuration.authToken = token
2044+
subscription.configuration.authToken = token
20442045
}
20452046
}
20462047

Sources/PubNub/Subscription/SubscribeSessionFactory.swift

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -113,6 +113,8 @@ public protocol SubscriptionConfiguration: RouterConfiguration {
113113
var requestMessageCountThreshold: UInt { get }
114114
/// PSV2 feature to subscribe with a custom filter expression.
115115
var filterExpression: String? { get }
116+
/// If Access Manager (PAM) is enabled, client will use `authToken` instead of `authKey` on all requests
117+
override var authToken: String? { get set }
116118
}
117119

118120
extension SubscriptionConfiguration {

Sources/PubNub/Subscription/SubscriptionSession.swift

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ public class SubscriptionSession {
3333

3434
public let uuid = UUID()
3535
let longPollingSession: SessionReplaceable
36-
let configuration: SubscriptionConfiguration
36+
internal(set) var configuration: SubscriptionConfiguration
3737
let sessionStream: SessionListener
3838

3939
/// PSV2 feature to subscribe with a custom filter expression.

Tests/PubNubTests/Helpers/PAMTokenTests.swift

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -69,6 +69,16 @@ extension PAMTokenTests {
6969
pubnub.set(token: "access-token")
7070

7171
XCTAssertEqual(pubnub.configuration.authToken, "access-token")
72+
XCTAssertEqual(pubnub.subscription.configuration.authToken, "access-token")
73+
}
74+
75+
func testChangeToken() {
76+
var pubnub = PubNub(configuration: config)
77+
pubnub.set(token: "access-token")
78+
pubnub.set(token: "access-token-updated")
79+
80+
XCTAssertEqual(pubnub.configuration.authToken, "access-token-updated")
81+
XCTAssertEqual(pubnub.subscription.configuration.authToken, "access-token-updated")
7282
}
7383

7484
// swiftlint:enable line_length

0 commit comments

Comments
 (0)