Rename NostrSignerType to NostrSignerCommand and introduce NostrSignerRequestType

This commit is contained in:
2025-01-30 22:37:41 -05:00
parent e8b7d56ffc
commit 5a13fb4f64
4 changed files with 22 additions and 9 deletions

View File

@@ -10,7 +10,8 @@ import SwiftData
@Model @Model
final class SignerRequestModel { final class SignerRequestModel {
var type: NostrSignerType var command: NostrSignerCommand
var requestType: NostrSignerRequestType
var returnType: NostrSignerReturnType var returnType: NostrSignerReturnType
var compressionType: NostrSignerCompressionType var compressionType: NostrSignerCompressionType
var createdAt: Date var createdAt: Date
@@ -22,7 +23,8 @@ final class SignerRequestModel {
var decidedAt: Date? var decidedAt: Date?
init( init(
type: NostrSignerType, command: NostrSignerCommand,
requestType: NostrSignerRequestType,
returnType: NostrSignerReturnType, returnType: NostrSignerReturnType,
compressionType: NostrSignerCompressionType, compressionType: NostrSignerCompressionType,
createdAt: Date, createdAt: Date,
@@ -33,7 +35,8 @@ final class SignerRequestModel {
approved: Bool? = nil, approved: Bool? = nil,
decidedAt: Date? = nil decidedAt: Date? = nil
) { ) {
self.type = type self.command = command
self.requestType = requestType
self.returnType = returnType self.returnType = returnType
self.compressionType = compressionType self.compressionType = compressionType
self.createdAt = createdAt self.createdAt = createdAt
@@ -46,7 +49,7 @@ final class SignerRequestModel {
} }
} }
enum NostrSignerType: String, Codable, CaseIterable { enum NostrSignerCommand: String, Codable, CaseIterable {
case getPublicKey = "get_public_key" case getPublicKey = "get_public_key"
case signEvent = "sign_event" case signEvent = "sign_event"
case nip04Encrypt = "nip04_encrypt" case nip04Encrypt = "nip04_encrypt"
@@ -57,6 +60,13 @@ enum NostrSignerType: String, Codable, CaseIterable {
case decryptZapEvent = "decrypt_zap_event" case decryptZapEvent = "decrypt_zap_event"
} }
enum NostrSignerRequestType: String, Codable {
case actionExtension
case nostrSignerUrlScheme
case nip07
case nip46
}
enum NostrSignerReturnType: String, Codable { enum NostrSignerReturnType: String, Codable {
case signature case signature
case event case event

View File

@@ -67,8 +67,8 @@ class SceneDelegate: NSObject, UIWindowSceneDelegate, ObservableObject {
compressionType = .none compressionType = .none
} }
guard let rawType = params[NostrSignerURLQueryItemName.type.rawValue], guard let rawCommand = params[NostrSignerURLQueryItemName.type.rawValue],
let type = NostrSignerType(rawValue: rawType), let command = NostrSignerCommand(rawValue: rawCommand),
let rawReturnType = params[NostrSignerURLQueryItemName.returnType.rawValue], let rawReturnType = params[NostrSignerURLQueryItemName.returnType.rawValue],
let returnType = NostrSignerReturnType(rawValue: rawReturnType) let returnType = NostrSignerReturnType(rawValue: rawReturnType)
else { else {
@@ -81,7 +81,8 @@ class SceneDelegate: NSObject, UIWindowSceneDelegate, ObservableObject {
let pubkey = params[NostrSignerURLQueryItemName.pubkey.rawValue] let pubkey = params[NostrSignerURLQueryItemName.pubkey.rawValue]
let signerRequestModel = SignerRequestModel( let signerRequestModel = SignerRequestModel(
type: type, command: command,
requestType: .nostrSignerUrlScheme,
returnType: returnType, returnType: returnType,
compressionType: compressionType, compressionType: compressionType,
createdAt: Date.now, createdAt: Date.now,

View File

@@ -16,7 +16,8 @@ struct HistoryView: View {
ForEach(signerRequestModels, id: \.self) { signerRequestModel in ForEach(signerRequestModels, id: \.self) { signerRequestModel in
Section { Section {
VStack { VStack {
Text(signerRequestModel.type.rawValue) Text(signerRequestModel.command.rawValue)
Text(signerRequestModel.requestType.rawValue)
Text(signerRequestModel.returnType.rawValue) Text(signerRequestModel.returnType.rawValue)
Text(signerRequestModel.compressionType.rawValue) Text(signerRequestModel.compressionType.rawValue)
Text(signerRequestModel.createdAt.description) Text(signerRequestModel.createdAt.description)

View File

@@ -21,7 +21,8 @@ struct HomeView: View {
if let signerRequestModel = signerRequestModels.first { if let signerRequestModel = signerRequestModels.first {
Section { Section {
VStack { VStack {
Text(signerRequestModel.type.rawValue) Text(signerRequestModel.command.rawValue)
Text(signerRequestModel.requestType.rawValue)
Text(signerRequestModel.returnType.rawValue) Text(signerRequestModel.returnType.rawValue)
Text(signerRequestModel.compressionType.rawValue) Text(signerRequestModel.compressionType.rawValue)
Text(signerRequestModel.createdAt.description) Text(signerRequestModel.createdAt.description)