Skip to content

Commit

Permalink
Merge pull request #1076 from WalletConnect/feature/notify-ksu-remove…
Browse files Browse the repository at this point in the history
…-for-server

[Notify] ksu removed for server requests
  • Loading branch information
flypaper0 authored Sep 7, 2023
2 parents e4556ef + 814dc1c commit 5238e8b
Show file tree
Hide file tree
Showing 4 changed files with 0 additions and 48 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ struct NotifyDeleteResponsePayload: JWTClaimsCodable {
let iat: UInt64
/// Timestamp when JWT must expire
let exp: UInt64
/// Key server URL
let ksu: String
/// Description of action intent. Must be equal to `notify_delete_response`
let act: String?

Expand Down Expand Up @@ -38,25 +36,11 @@ struct NotifyDeleteResponsePayload: JWTClaimsCodable {
}
}

let keyserver: URL
let selfPubKey: DIDKey
let subscriptionHash: String
let app: String

init(
keyserver: URL,
selfPubKey: DIDKey,
subscriptionHash: String,
app: String
) {
self.keyserver = keyserver
self.selfPubKey = selfPubKey
self.subscriptionHash = subscriptionHash
self.app = app
}

init(claims: Claims) throws {
self.keyserver = try claims.ksu.asURL()
self.selfPubKey = try DIDKey(did: claims.aud)
self.subscriptionHash = claims.sub
self.app = claims.app
Expand All @@ -66,7 +50,6 @@ struct NotifyDeleteResponsePayload: JWTClaimsCodable {
return Claims(
iat: defaultIat(),
exp: expiry(days: 1),
ksu: keyserver.absoluteString,
act: Claims.action,
iss: iss,
aud: selfPubKey.did(variant: .ED25519),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ struct NotifyMessagePayload: JWTClaimsCodable {
let iat: UInt64
/// Timestamp when JWT must expire
let exp: UInt64
/// Key server URL
let ksu: String
/// Action intent (must be `notify_message`)
let act: String?

Expand Down Expand Up @@ -41,31 +39,13 @@ struct NotifyMessagePayload: JWTClaimsCodable {
}

let castServerPubKey: DIDKey
let keyserver: URL
let account: Account
let subscriptionId: String
let app: String
let message: NotifyMessage

init(
castServerPubKey: DIDKey,
keyserver: URL,
account: Account,
subscriptionId: String,
app: String,
message: NotifyMessage
) {
self.castServerPubKey = castServerPubKey
self.keyserver = keyserver
self.account = account
self.subscriptionId = subscriptionId
self.app = app
self.message = message
}

init(claims: Claims) throws {
self.castServerPubKey = try DIDKey(did: claims.iss)
self.keyserver = try claims.ksu.asURL()
self.account = try DIDPKH(did: claims.aud).account
self.subscriptionId = claims.sub
self.app = claims.app
Expand All @@ -76,7 +56,6 @@ struct NotifyMessagePayload: JWTClaimsCodable {
return Claims(
iat: defaultIat(),
exp: expiry(days: 1),
ksu: keyserver.absoluteString,
act: Claims.action,
iss: castServerPubKey.multibase(variant: .ED25519),
aud: account.did,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ struct NotifySubscriptionResponsePayload: JWTClaimsCodable {
let iat: UInt64
/// timestamp when jwt must expire
let exp: UInt64
/// Key server URL
let ksu: String
/// Description of action intent. Must be equal to "notify_subscription_response"
let act: String?

Expand Down Expand Up @@ -38,13 +36,11 @@ struct NotifySubscriptionResponsePayload: JWTClaimsCodable {
}
}

let keyserver: URL
let selfPubKey: DIDKey
let publicKey: DIDKey
let app: String

init(claims: Claims) throws {
self.keyserver = try claims.ksu.asURL()
self.selfPubKey = try DIDKey(did: claims.aud)
self.publicKey = try DIDKey(did: claims.sub)
self.app = claims.app
Expand All @@ -54,7 +50,6 @@ struct NotifySubscriptionResponsePayload: JWTClaimsCodable {
return Claims(
iat: defaultIat(),
exp: expiry(days: 1),
ksu: keyserver.absoluteString,
act: Claims.action,
iss: iss,
aud: selfPubKey.did(variant: .ED25519),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,6 @@ struct NotifyUpdateResponsePayload: JWTClaimsCodable {
let iat: UInt64
/// timestamp when jwt must expire
let exp: UInt64
/// Key server URL
let ksu: String
/// Description of action intent. Must be equal to "notify_update_response"
let act: String?

Expand Down Expand Up @@ -38,13 +36,11 @@ struct NotifyUpdateResponsePayload: JWTClaimsCodable {
}
}

let keyserver: URL
let selfPubKey: DIDKey
let subscriptionHash: String
let app: String

init(claims: Claims) throws {
self.keyserver = try claims.ksu.asURL()
self.selfPubKey = try DIDKey(did: claims.aud)
self.subscriptionHash = claims.sub
self.app = claims.app
Expand All @@ -54,7 +50,6 @@ struct NotifyUpdateResponsePayload: JWTClaimsCodable {
return Claims(
iat: defaultIat(),
exp: expiry(days: 1),
ksu: keyserver.absoluteString,
act: Claims.action,
iss: iss,
aud: selfPubKey.did(variant: .ED25519),
Expand Down

0 comments on commit 5238e8b

Please sign in to comment.