Skip to content

Commit

Permalink
Make legacy direct message related classes and functions to be deprec…
Browse files Browse the repository at this point in the history
…ated
  • Loading branch information
tyiu committed May 28, 2024
1 parent d3852f8 commit c773692
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 2 deletions.
3 changes: 2 additions & 1 deletion Sources/NostrSDK/EventKind.swift
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,8 @@ public enum EventKind: RawRepresentable, CaseIterable, Codable, Equatable, Hasha
/// This kind of event should have a recipient pubkey tag.
///
/// See [NIP-04 - Encrypted Direct Message](https://github.com/nostr-protocol/nips/blob/master/04.md)
/// > Warning: Deprecated in favor of [NIP-17 - Private Direct Messages](https://github.com/nostr-protocol/nips/blob/master/04.md).
/// > Warning: Deprecated in favor of [NIP-17 - Private Direct Messages](https://github.com/nostr-protocol/nips/blob/master/17.md).
@available(*, deprecated, message: "Deprecated in favor of NIP-17 - Private Direct Messages.")
case legacyEncryptedDirectMessage

/// This kind of event indicates that the author requests that the events in the included
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,8 @@ import Foundation
/// An event that contains an encrypted message.
///
/// > Note: [NIP-04 - Encrypted Direct Message](https://github.com/nostr-protocol/nips/blob/master/04.md)
/// > Warning: Deprecated in favor of [NIP-17 - Private Direct Messages](https://github.com/nostr-protocol/nips/blob/master/04.md).
/// > Warning: Deprecated in favor of [NIP-17 - Private Direct Messages](https://github.com/nostr-protocol/nips/blob/master/17.md).
@available(*, deprecated, message: "Deprecated in favor of NIP-17 - Private Direct Messages.")
public final class LegacyEncryptedDirectMessageEvent: NostrEvent, LegacyDirectMessageEncrypting {

public required init(from decoder: Decoder) throws {
Expand Down Expand Up @@ -50,6 +51,8 @@ public extension EventCreating {
/// - Returns: The signed ``LegacyEncryptedDirectMessageEvent``.
///
/// See [NIP-04 - Encrypted Direct Message](https://github.com/nostr-protocol/nips/blob/master/04.md)
/// > Warning: Deprecated in favor of [NIP-17 - Private Direct Messages](https://github.com/nostr-protocol/nips/blob/master/17.md).
@available(*, deprecated, message: "Deprecated in favor of NIP-17 - Private Direct Messages.")
func legacyEncryptedDirectMessage(withContent content: String, toRecipient pubkey: PublicKey, signedBy keypair: Keypair) throws -> LegacyEncryptedDirectMessageEvent {
guard let encryptedMessage = try? legacyEncrypt(content: content, privateKey: keypair.privateKey, publicKey: pubkey) else {
throw EventCreatingError.invalidInput
Expand Down
4 changes: 4 additions & 0 deletions Sources/NostrSDK/LegacyDirectMessageEncrypting.swift
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,8 @@ public extension LegacyDirectMessageEncrypting {
/// - privateKey: The private key of the sender.
/// - publicKey: The public key of the intended recipient.
/// - Returns: Encrypted content.
/// > Warning: Deprecated in favor of [NIP-44](https://github.com/nostr-protocol/nips/blob/master/44.md) encryption and [NIP-59](https://github.com/nostr-protocol/nips/blob/master/59.md) seals and gift wraps..
@available(*, deprecated, message: "Deprecated in favor of NIP-44 encryption and NIP-59 seals and gift wraps.")
func legacyEncrypt(content: String, privateKey: PrivateKey, publicKey: PublicKey) throws -> String {

let sharedSecret = try getSharedSecret(privateKey: privateKey, recipient: publicKey)
Expand All @@ -50,6 +52,8 @@ public extension LegacyDirectMessageEncrypting {
/// - privateKey: The private key of the receiver.
/// - publicKey: The public key of the sender.
/// - Returns: The un-encrypted message.
/// > Warning: Deprecated in favor of [NIP-44](https://github.com/nostr-protocol/nips/blob/master/44.md) encryption and [NIP-59](https://github.com/nostr-protocol/nips/blob/master/59.md) seals and gift wraps..
@available(*, deprecated, message: "Deprecated in favor of NIP-44 encryption and NIP-59 seals and gift wraps.")
func legacyDecrypt(encryptedContent message: String, privateKey: PrivateKey, publicKey: PublicKey) throws -> String {
guard let sharedSecret = try? getSharedSecret(privateKey: privateKey, recipient: publicKey) else {
throw EventCreatingError.invalidInput
Expand Down

0 comments on commit c773692

Please sign in to comment.