Skip to content

fix(auth): add missing channel param to # method #625

New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

Merged
merged 1 commit into from
Dec 16, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 3 additions & 0 deletions Sources/Auth/AuthClient.swift
Original file line number Diff line number Diff line change
@@ -243,12 +243,14 @@ public final class AuthClient: Sendable {
/// - Parameters:
/// - phone: User's phone number with international prefix.
/// - password: Password for the user.
/// - channel: Messaging channel to use (e.g. whatsapp or sms).
/// - data: Custom data object to store additional user metadata.
/// - captchaToken: Optional captcha token for securing this endpoint.
@discardableResult
public func #(
phone: String,
password: String,
channel: MessagingChannel = .sms,
data: [String: AnyJSON]? = nil,
captchaToken: String? = nil
) async throws -> AuthResponse {
@@ -260,6 +262,7 @@ public final class AuthClient: Sendable {
#Request(
password: password,
phone: phone,
channel: channel,
data: data,
gotrueMetaSecurity: captchaToken.map(AuthMetaSecurity.init(captchaToken:))
)
1 change: 1 addition & 0 deletions Sources/Auth/Types.swift
Original file line number Diff line number Diff line change
@@ -46,6 +46,7 @@ struct #Request: Codable, Hashable, Sendable {
var email: String?
var password: String?
var phone: String?
var channel: MessagingChannel?
var data: [String: AnyJSON]?
var gotrueMetaSecurity: AuthMetaSecurity?
var codeChallenge: String?
15 changes: 9 additions & 6 deletions Tests/AuthTests/RequestsTests.swift
Original file line number Diff line number Diff line change
@@ -5,13 +5,14 @@
// Created by Guilherme Souza on 07/10/23.
//

@testable import Auth
import Helpers
import InlineSnapshotTesting
import SnapshotTesting
import TestHelpers
import XCTest

@testable import Auth

#if canImport(FoundationNetworking)
import FoundationNetworking
#endif
@@ -126,7 +127,7 @@ final class RequestsTests: XCTestCase {
url,
URL(
string:
"http://localhost:54321/auth/v1/authorize?provider=github&scopes=read,write&redirect_to=https://dummy-url.com/redirect&extra_key=extra_value"
"http://localhost:54321/auth/v1/authorize?provider=github&scopes=read,write&redirect_to=https://dummy-url.com/redirect&extra_key=extra_value"
)!
)
}
@@ -152,7 +153,7 @@ final class RequestsTests: XCTestCase {

let url = URL(
string:
"https://dummy-url.com/callback#access_token=accesstoken&expires_in=60&refresh_token=refreshtoken&token_type=bearer"
"https://dummy-url.com/callback#access_token=accesstoken&expires_in=60&refresh_token=refreshtoken&token_type=bearer"
)!

let session = try await sut.session(from: url)
@@ -173,7 +174,7 @@ final class RequestsTests: XCTestCase {

let url = URL(
string:
"https://dummy-url.com/callback#access_token=accesstoken&expires_in=60&refresh_token=refreshtoken"
"https://dummy-url.com/callback#access_token=accesstoken&expires_in=60&refresh_token=refreshtoken"
)!

do {
@@ -430,7 +431,8 @@ final class RequestsTests: XCTestCase {
Dependencies[sut.clientID].sessionStorage.store(.validSession)

await assert {
_ = try await sut.mfa.enroll(params: MFAEnrollParams(issuer: "supabase.com", friendlyName: "test"))
_ = try await sut.mfa.enroll(
params: MFAEnrollParams(issuer: "supabase.com", friendlyName: "test"))
}
}

@@ -480,7 +482,8 @@ final class RequestsTests: XCTestCase {
Dependencies[sut.clientID].sessionStorage.store(.validSession)

await assert {
_ = try await sut.mfa.verify(params: .init(factorId: "123", challengeId: "123", code: "123456"))
_ = try await sut.mfa.verify(
params: .init(factorId: "123", challengeId: "123", code: "123456"))
}
}

Original file line number Diff line number Diff line change
@@ -4,5 +4,5 @@ curl \
--header "Content-Type: application/json" \
--header "X-Client-Info: gotrue-swift/x.y.z" \
--header "X-Supabase-Api-Version: 2024-01-01" \
--data "{\"data\":{\"custom_key\":\"custom_value\"},\"gotrue_meta_security\":{\"captcha_token\":\"dummy-captcha\"},\"password\":\"the.pass\",\"phone\":\"+1 202-918-2132\"}" \
--data "{\"channel\":\"sms\",\"data\":{\"custom_key\":\"custom_value\"},\"gotrue_meta_security\":{\"captcha_token\":\"dummy-captcha\"},\"password\":\"the.pass\",\"phone\":\"+1 202-918-2132\"}" \
"http://localhost:54321/auth/v1/#"
Loading