Skip to content

Commit 9ed938b

Browse files
authored
Add missing implementation for parsing PAM token in Kotlin Multiplatform sources (internal use) (#220)
1 parent 60e8f3c commit 9ed938b

File tree

6 files changed

+99
-12
lines changed

6 files changed

+99
-12
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: "9.3.1"
4+
version: "9.3.2"
55
schema: 1
66
changelog:
7+
- date: 2025-08-06
8+
version: 9.3.2
9+
changes:
10+
- type: bug
11+
text: "Implement missing token parsing logic in KMP layer (internal use)."
712
- date: 2025-07-31
813
version: 9.3.1
914
changes:
@@ -713,7 +718,7 @@ sdks:
713718
- distribution-type: source
714719
distribution-repository: GitHub release
715720
package-name: PubNub
716-
location: https://github.com/pubnub/swift/archive/refs/tags/9.3.1.zip
721+
location: https://github.com/pubnub/swift/archive/refs/tags/9.3.2.zip
717722
supported-platforms:
718723
supported-operating-systems:
719724
macOS:

PubNub.xcodeproj/project.pbxproj

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -438,6 +438,7 @@
438438
3D758DD52AB48A6A005D2B36 /* CryptorHeader.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D758DD32AB48A6A005D2B36 /* CryptorHeader.swift */; };
439439
3D758DD62AB48A6A005D2B36 /* CryptorHeaderWithinStreamFinder.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D758DD42AB48A6A005D2B36 /* CryptorHeaderWithinStreamFinder.swift */; };
440440
3D8102AA2C009AA5005E3607 /* KMPAppContextEventResult.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D8102A92C009AA5005E3607 /* KMPAppContextEventResult.swift */; };
441+
3D867D1D2E422E6E00B03EEE /* KMPPAMToken.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D867D1C2E422E6E00B03EEE /* KMPPAMToken.swift */; };
441442
3D8BAC102B8C96D70059A5C3 /* DependencyContainer.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D8BAC0F2B8C96D70059A5C3 /* DependencyContainer.swift */; };
442443
3D9134972A1216F7000A5124 /* PubNubPushTargetTests.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3D9134962A1216F7000A5124 /* PubNubPushTargetTests.swift */; };
443444
3DA0C7C92BFDF538000FFE6C /* KMPPubNub.swift in Sources */ = {isa = PBXBuildFile; fileRef = 3DA0C7C82BFDF538000FFE6C /* KMPPubNub.swift */; };
@@ -1064,6 +1065,7 @@
10641065
3D758DD32AB48A6A005D2B36 /* CryptorHeader.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CryptorHeader.swift; sourceTree = "<group>"; };
10651066
3D758DD42AB48A6A005D2B36 /* CryptorHeaderWithinStreamFinder.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = CryptorHeaderWithinStreamFinder.swift; sourceTree = "<group>"; };
10661067
3D8102A92C009AA5005E3607 /* KMPAppContextEventResult.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPAppContextEventResult.swift; sourceTree = "<group>"; };
1068+
3D867D1C2E422E6E00B03EEE /* KMPPAMToken.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = KMPPAMToken.swift; sourceTree = "<group>"; };
10671069
3D8BAC0F2B8C96D70059A5C3 /* DependencyContainer.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = DependencyContainer.swift; sourceTree = "<group>"; };
10681070
3D9134962A1216F7000A5124 /* PubNubPushTargetTests.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = PubNubPushTargetTests.swift; sourceTree = "<group>"; };
10691071
3DA0C7C82BFDF538000FFE6C /* KMPPubNub.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = KMPPubNub.swift; sourceTree = "<group>"; };
@@ -2092,6 +2094,7 @@
20922094
3DBFF2C22C2300F500142985 /* KMPSubscription.swift */,
20932095
3D3C38822C47D62700E782E7 /* KMPError.swift */,
20942096
3D7062C32D26AA20000729E1 /* KMPAppContextIncludeFields.swift */,
2097+
3D867D1C2E422E6E00B03EEE /* KMPPAMToken.swift */,
20952098
);
20962099
path = Wrappers;
20972100
sourceTree = "<group>";
@@ -3623,6 +3626,7 @@
36233626
3D758DCE2AB0A835005D2B36 /* LegacyCryptor.swift in Sources */,
36243627
3DB925812B7AA75F001B7E90 /* SubscribeMessagePayload+PubNubEvent.swift in Sources */,
36253628
35A66A7E22F861BA00AC67A9 /* SubscriptionSession.swift in Sources */,
3629+
3D867D1D2E422E6E00B03EEE /* KMPPAMToken.swift in Sources */,
36263630
3DB925872B7AA75F001B7E90 /* SessionStream.swift in Sources */,
36273631
3D7411A32C171F2B002267B8 /* Int+NSNumber.swift in Sources */,
36283632
3D339C7C2BFF828B00197342 /* KMPMessage.swift in Sources */,
@@ -4031,7 +4035,7 @@
40314035
"@loader_path/Frameworks",
40324036
);
40334037
MACOSX_DEPLOYMENT_TARGET = 10.15;
4034-
MARKETING_VERSION = 9.3.1;
4038+
MARKETING_VERSION = 9.3.2;
40354039
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
40364040
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
40374041
MTL_FAST_MATH = YES;
@@ -4082,7 +4086,7 @@
40824086
"@loader_path/Frameworks",
40834087
);
40844088
MACOSX_DEPLOYMENT_TARGET = 10.15;
4085-
MARKETING_VERSION = 9.3.1;
4089+
MARKETING_VERSION = 9.3.2;
40864090
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
40874091
MTL_ENABLE_DEBUG_INFO = NO;
40884092
MTL_FAST_MATH = YES;
@@ -4190,7 +4194,7 @@
41904194
"@loader_path/Frameworks",
41914195
);
41924196
MACOSX_DEPLOYMENT_TARGET = 10.15;
4193-
MARKETING_VERSION = 9.3.1;
4197+
MARKETING_VERSION = 9.3.2;
41944198
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
41954199
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
41964200
MTL_FAST_MATH = YES;
@@ -4243,7 +4247,7 @@
42434247
"@loader_path/Frameworks",
42444248
);
42454249
MACOSX_DEPLOYMENT_TARGET = 10.15;
4246-
MARKETING_VERSION = 9.3.1;
4250+
MARKETING_VERSION = 9.3.2;
42474251
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
42484252
MTL_ENABLE_DEBUG_INFO = NO;
42494253
MTL_FAST_MATH = YES;
@@ -4364,7 +4368,7 @@
43644368
"@loader_path/Frameworks",
43654369
);
43664370
MACOSX_DEPLOYMENT_TARGET = 10.15;
4367-
MARKETING_VERSION = 9.3.1;
4371+
MARKETING_VERSION = 9.3.2;
43684372
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
43694373
MTL_ENABLE_DEBUG_INFO = INCLUDE_SOURCE;
43704374
MTL_FAST_MATH = YES;
@@ -4416,7 +4420,7 @@
44164420
"@loader_path/Frameworks",
44174421
);
44184422
MACOSX_DEPLOYMENT_TARGET = 10.15;
4419-
MARKETING_VERSION = 9.3.1;
4423+
MARKETING_VERSION = 9.3.2;
44204424
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu11 gnu++17";
44214425
MTL_ENABLE_DEBUG_INFO = NO;
44224426
MTL_FAST_MATH = YES;
@@ -4896,7 +4900,7 @@
48964900
"$(TOOLCHAIN_DIR)/usr/lib/swift/macosx",
48974901
);
48984902
MACOSX_DEPLOYMENT_TARGET = 10.15;
4899-
MARKETING_VERSION = 9.3.1;
4903+
MARKETING_VERSION = 9.3.2;
49004904
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++14";
49014905
OTHER_CFLAGS = "$(inherited)";
49024906
OTHER_LDFLAGS = "$(inherited)";
@@ -4939,7 +4943,7 @@
49394943
"$(TOOLCHAIN_DIR)/usr/lib/swift/macosx",
49404944
);
49414945
MACOSX_DEPLOYMENT_TARGET = 10.15;
4942-
MARKETING_VERSION = 9.3.1;
4946+
MARKETING_VERSION = 9.3.2;
49434947
MODULE_VERIFIER_SUPPORTED_LANGUAGE_STANDARDS = "gnu17 gnu++14";
49444948
OTHER_CFLAGS = "$(inherited)";
49454949
OTHER_LDFLAGS = "$(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 = '9.3.1'
3+
s.version = '9.3.2'
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
@@ -57,7 +57,7 @@ public enum Constant {
5757

5858
static let pubnubSwiftSDKName: String = "PubNubSwift"
5959

60-
static let pubnubSwiftSDKVersion: String = "9.3.1"
60+
static let pubnubSwiftSDKVersion: String = "9.3.2"
6161

6262
static let appBundleId: String = {
6363
if let info = Bundle.main.infoDictionary,

Sources/PubNub/KMP/KMPPubNub.swift

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ public extension KMPPubNub {
5252
pubnub.set(token: token)
5353
}
5454

55+
func parse(token: String) -> KMPPAMToken? {
56+
if let token = pubnub.parse(token: token) {
57+
return KMPPAMToken(from: token)
58+
} else {
59+
return nil
60+
}
61+
}
62+
5563
func getToken() -> String? {
5664
pubnub.configuration.authToken
5765
}
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
//
2+
// KMPPAMToken.swift
3+
//
4+
// Copyright (c) PubNub Inc.
5+
// All rights reserved.
6+
//
7+
// This source code is licensed under the license found in the
8+
// LICENSE file in the root directory of this source tree.
9+
//
10+
// IMPORTANT NOTE FOR DEVELOPERS USING THIS SDK
11+
//
12+
// All public symbols in this file are intended to allow interoperation with Kotlin Multiplatform for other PubNub frameworks.
13+
// While these symbols are public, they are intended strictly for internal usage.
14+
//
15+
// External developers should refrain from directly using these symbols in their code, as their implementation details
16+
// may change in future versions of the framework, potentially leading to breaking changes.
17+
18+
import Foundation
19+
20+
@objc public class KMPPAMToken: NSObject {
21+
@objc public let version: NSNumber
22+
@objc public let timestamp: NSNumber
23+
@objc public let ttl: NSNumber
24+
@objc public let authorizedUUID: String
25+
@objc public let resources: KMPPAMTokenResource
26+
@objc public let patterns: KMPPAMTokenResource
27+
@objc public let meta: KMPAnyJSON
28+
29+
init(from token: PAMToken) {
30+
version = NSNumber(value: token.version)
31+
timestamp = NSNumber(value: token.timestamp)
32+
ttl = NSNumber(value: token.ttl)
33+
authorizedUUID = token.authorizedUUID ?? ""
34+
resources = KMPPAMTokenResource(from: token.resources)
35+
patterns = KMPPAMTokenResource(from: token.patterns)
36+
meta = KMPAnyJSON(token.meta)
37+
}
38+
}
39+
40+
@objc public class KMPPAMTokenResource: NSObject {
41+
@objc public let channels: [String: KMPPAMPermission]
42+
@objc public let channelGroups: [String: KMPPAMPermission]
43+
@objc public let uuids: [String: KMPPAMPermission]
44+
45+
init(from resource: PAMTokenResource) {
46+
channels = resource.channels.compactMapValues { KMPPAMPermission(from: $0) }
47+
channelGroups = resource.groups.compactMapValues { KMPPAMPermission(from: $0) }
48+
uuids = resource.uuids.compactMapValues { KMPPAMPermission(from: $0) }
49+
}
50+
}
51+
52+
@objc public class KMPPAMPermission: NSObject {
53+
@objc public let read: Bool
54+
@objc public let write: Bool
55+
@objc public let manage: Bool
56+
@objc public let delete: Bool
57+
@objc public let get: Bool
58+
@objc public let update: Bool
59+
@objc public let join: Bool
60+
61+
init(from permission: PAMPermission) {
62+
read = permission.contains(.read)
63+
write = permission.contains(.write)
64+
manage = permission.contains(.manage)
65+
delete = permission.contains(.delete)
66+
get = permission.contains(.get)
67+
update = permission.contains(.update)
68+
join = permission.contains(.join)
69+
}
70+
}

0 commit comments

Comments
 (0)