diff --git a/Sources/Auth/AuthAdmin.swift b/Sources/Auth/AuthAdmin.swift index 5b6564dce..e3dd0da46 100644 --- a/Sources/Auth/AuthAdmin.swift +++ b/Sources/Auth/AuthAdmin.swift @@ -33,4 +33,52 @@ public struct AuthAdmin: Sendable { ) ) } + + /// Get a list of users. + /// + /// This function should only be called on a server. + /// + /// - Warning: Never expose your `service_role` key in the client. + public func listUsers(params: PageParams? = nil) async throws -> ListUsersPaginatedResponse { + struct Response: Decodable { + let users: [User] + let aud: String + } + + let httpResponse = try await api.execute( + HTTPRequest( + url: configuration.url.appendingPathComponent("admin/users"), + method: .get, + query: [ + URLQueryItem(name: "page", value: params?.page?.description ?? ""), + URLQueryItem(name: "per_page", value: params?.perPage?.description ?? ""), + ] + ) + ) + + let response = try httpResponse.decoded(as: Response.self, decoder: configuration.decoder) + + var pagination = ListUsersPaginatedResponse( + users: response.users, + aud: response.aud, + lastPage: 0, + total: httpResponse.headers["x-total-count"].flatMap(Int.init) ?? 0 + ) + + let links = httpResponse.headers["link"]?.components(separatedBy: ",") ?? [] + if !links.isEmpty { + for link in links { + let page = link.components(separatedBy: ";")[0].components(separatedBy: "=")[1].prefix(while: \.isNumber) + let rel = link.components(separatedBy: ";")[1].components(separatedBy: "=")[1] + + if rel == "\"last\"", let lastPage = Int(page) { + pagination.lastPage = lastPage + } else if rel == "\"next\"", let nextPage = Int(page) { + pagination.nextPage = nextPage + } + } + } + + return pagination + } } diff --git a/Sources/Auth/Types.swift b/Sources/Auth/Types.swift index 8fac62acf..d850b5424 100644 --- a/Sources/Auth/Types.swift +++ b/Sources/Auth/Types.swift @@ -193,8 +193,8 @@ public struct User: Codable, Hashable, Identifiable, Sendable { public init(from decoder: any Decoder) throws { let container = try decoder.container(keyedBy: CodingKeys.self) id = try container.decode(UUID.self, forKey: .id) - appMetadata = try container.decode([String: AnyJSON].self, forKey: .appMetadata) - userMetadata = try container.decode([String: AnyJSON].self, forKey: .userMetadata) + appMetadata = try container.decodeIfPresent([String: AnyJSON].self, forKey: .appMetadata) ?? [:] + userMetadata = try container.decodeIfPresent([String: AnyJSON].self, forKey: .userMetadata) ?? [:] aud = try container.decode(String.self, forKey: .aud) confirmationSentAt = try container.decodeIfPresent(Date.self, forKey: .confirmationSentAt) recoverySentAt = try container.decodeIfPresent(Date.self, forKey: .recoverySentAt) @@ -816,3 +816,23 @@ public struct OAuthResponse: Codable, Hashable, Sendable { public let provider: Provider public let url: URL } + +public struct PageParams { + /// The page number. + public let page: Int? + /// Number of items returned per page. + public let perPage: Int? + + public init(page: Int? = nil, perPage: Int? = nil) { + self.page = page + self.perPage = perPage + } +} + +public struct ListUsersPaginatedResponse: Hashable, Sendable { + public let users: [User] + public let aud: String + public var nextPage: Int? + public var lastPage: Int + public var total: Int +} diff --git a/Tests/AuthTests/AuthClientTests.swift b/Tests/AuthTests/AuthClientTests.swift index b2e8a446a..bd5f2ef8e 100644 --- a/Tests/AuthTests/AuthClientTests.swift +++ b/Tests/AuthTests/AuthClientTests.swift @@ -306,6 +306,40 @@ final class AuthClientTests: XCTestCase { XCTAssertEqual(receivedURL.value?.absoluteString, url) } + func testAdminListUsers() async throws { + let sut = makeSUT { _ in + .stub( + fromFileName: "list-users-response", + headers: [ + "X-Total-Count": "669", + "Link": "; rel=\"next\", ; rel=\"last\"", + ] + ) + } + + let response = try await sut.admin.listUsers() + XCTAssertEqual(response.total, 669) + XCTAssertEqual(response.nextPage, 2) + XCTAssertEqual(response.lastPage, 14) + } + + func testAdminListUsers_noNextPage() async throws { + let sut = makeSUT { _ in + .stub( + fromFileName: "list-users-response", + headers: [ + "X-Total-Count": "669", + "Link": "; rel=\"last\"", + ] + ) + } + + let response = try await sut.admin.listUsers() + XCTAssertEqual(response.total, 669) + XCTAssertNil(response.nextPage) + XCTAssertEqual(response.lastPage, 14) + } + private func makeSUT( fetch: ((URLRequest) async throws -> HTTPResponse)? = nil ) -> AuthClient { @@ -331,38 +365,50 @@ final class AuthClientTests: XCTestCase { } extension HTTPResponse { - static func stub(_ body: String = "", code: Int = 200) -> HTTPResponse { + static func stub( + _ body: String = "", + code: Int = 200, + headers: [String: String]? = nil + ) -> HTTPResponse { HTTPResponse( data: body.data(using: .utf8)!, response: HTTPURLResponse( url: clientURL, statusCode: code, httpVersion: nil, - headerFields: nil + headerFields: headers )! ) } - static func stub(fromFileName fileName: String, code: Int = 200) -> HTTPResponse { + static func stub( + fromFileName fileName: String, + code: Int = 200, + headers: [String: String]? = nil + ) -> HTTPResponse { HTTPResponse( data: json(named: fileName), response: HTTPURLResponse( url: clientURL, statusCode: code, httpVersion: nil, - headerFields: nil + headerFields: headers )! ) } - static func stub(_ value: some Encodable, code: Int = 200) -> HTTPResponse { + static func stub( + _ value: some Encodable, + code: Int = 200, + headers: [String: String]? = nil + ) -> HTTPResponse { HTTPResponse( data: try! AuthClient.Configuration.jsonEncoder.encode(value), response: HTTPURLResponse( url: clientURL, statusCode: code, httpVersion: nil, - headerFields: nil + headerFields: headers )! ) } diff --git a/Tests/AuthTests/Resources/list-users-response.json b/Tests/AuthTests/Resources/list-users-response.json new file mode 100644 index 000000000..0912372b7 --- /dev/null +++ b/Tests/AuthTests/Resources/list-users-response.json @@ -0,0 +1,1250 @@ +{ + "users": [ + { + "id": "314055a4-f68b-4809-b32c-ae64bc45b283", + "aud": "authenticated", + "role": "authenticated", + "email": "nhoysdbdt@supabase.com", + "email_confirmed_at": "2024-09-23T10:55:18.380613Z", + "phone": "", + "confirmed_at": "2024-09-23T10:55:18.380613Z", + "last_sign_in_at": "2024-09-23T10:55:18.382997Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "nhoysdbdt@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "314055a4-f68b-4809-b32c-ae64bc45b283" + }, + "identities": null, + "created_at": "2024-09-23T10:55:18.375179Z", + "updated_at": "2024-09-23T10:55:18.385003Z", + "is_anonymous": false + }, + { + "id": "e407724b-5f87-43c0-9e96-e38daddd88bc", + "aud": "authenticated", + "role": "authenticated", + "email": "dpmgoou@supabase.com", + "email_confirmed_at": "2024-09-23T10:55:17.729918Z", + "phone": "", + "confirmed_at": "2024-09-23T10:55:17.729918Z", + "last_sign_in_at": "2024-09-23T10:55:17.734064Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "dpmgoou@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "e407724b-5f87-43c0-9e96-e38daddd88bc" + }, + "identities": null, + "created_at": "2024-09-23T10:55:17.724191Z", + "updated_at": "2024-09-23T10:55:17.735433Z", + "is_anonymous": false + }, + { + "id": "0ead5d21-936b-4b7c-8758-4d9d5150874b", + "aud": "authenticated", + "role": "authenticated", + "email": "ynzlbcuxnn@supabase.com", + "email_confirmed_at": "2024-09-23T10:55:16.907977Z", + "phone": "", + "confirmed_at": "2024-09-23T10:55:16.907977Z", + "last_sign_in_at": "2024-09-23T10:55:16.910737Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "ynzlbcuxnn@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "0ead5d21-936b-4b7c-8758-4d9d5150874b" + }, + "identities": null, + "created_at": "2024-09-23T10:55:16.902684Z", + "updated_at": "2024-09-23T10:55:16.913745Z", + "is_anonymous": false + }, + { + "id": "931bc93e-d503-412f-8aa2-f020dfc4b1b6", + "aud": "authenticated", + "role": "authenticated", + "email": "sowgrakgpq@supabase.com", + "email_confirmed_at": "2024-09-23T10:55:16.063209Z", + "phone": "", + "confirmed_at": "2024-09-23T10:55:16.063209Z", + "last_sign_in_at": "2024-09-23T10:55:16.06622Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "sowgrakgpq@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "931bc93e-d503-412f-8aa2-f020dfc4b1b6" + }, + "identities": null, + "created_at": "2024-09-23T10:55:16.05547Z", + "updated_at": "2024-09-23T10:55:16.06772Z", + "is_anonymous": false + }, + { + "id": "351bc251-cbec-45ec-8b4c-a25bbba735e9", + "aud": "authenticated", + "role": "authenticated", + "email": "iosvm@supabase.com", + "email_confirmed_at": "2024-09-23T10:55:15.082449Z", + "phone": "", + "confirmed_at": "2024-09-23T10:55:15.082449Z", + "last_sign_in_at": "2024-09-23T10:55:15.086376Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "iosvm@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "351bc251-cbec-45ec-8b4c-a25bbba735e9", + "test": 42 + }, + "identities": null, + "created_at": "2024-09-23T10:55:15.077746Z", + "updated_at": "2024-09-23T10:55:15.257156Z", + "is_anonymous": false + }, + { + "id": "55e485c2-61b7-4591-b980-05ee85ae8638", + "aud": "authenticated", + "role": "authenticated", + "email": "wjaxylgcuu@supabase.com", + "email_confirmed_at": "2024-09-23T10:55:13.907617Z", + "phone": "", + "confirmed_at": "2024-09-23T10:55:13.907617Z", + "last_sign_in_at": "2024-09-23T10:55:13.911262Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "wjaxylgcuu@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "55e485c2-61b7-4591-b980-05ee85ae8638" + }, + "identities": null, + "created_at": "2024-09-23T10:55:13.897589Z", + "updated_at": "2024-09-23T10:55:13.912676Z", + "is_anonymous": false + }, + { + "id": "b3f77e03-d27e-4d96-955f-42993f55423c", + "aud": "authenticated", + "role": "authenticated", + "email": "ayjbz@supabase.com", + "email_confirmed_at": "2024-09-23T10:55:12.583477Z", + "phone": "", + "confirmed_at": "2024-09-23T10:55:12.583477Z", + "last_sign_in_at": "2024-09-23T10:55:13.254674Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "ayjbz@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "b3f77e03-d27e-4d96-955f-42993f55423c", + "test": 42 + }, + "identities": null, + "created_at": "2024-09-23T10:55:12.578064Z", + "updated_at": "2024-09-23T10:55:13.257898Z", + "is_anonymous": false + }, + { + "id": "2c426860-5fd5-49b5-b765-a8828c7e1582", + "aud": "authenticated", + "role": "authenticated", + "email": "gytfwnikjj@supabase.com", + "email_confirmed_at": "2024-09-23T10:55:11.668283Z", + "phone": "", + "confirmed_at": "2024-09-23T10:55:11.668283Z", + "last_sign_in_at": "2024-09-23T10:55:11.671139Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "gytfwnikjj@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "2c426860-5fd5-49b5-b765-a8828c7e1582" + }, + "identities": null, + "created_at": "2024-09-23T10:55:11.659375Z", + "updated_at": "2024-09-23T10:55:11.673833Z", + "is_anonymous": false + }, + { + "id": "3cf3a564-805d-4f1c-a4ef-d6110b1fbce8", + "aud": "authenticated", + "role": "authenticated", + "email": "", + "phone": "", + "last_sign_in_at": "2024-09-23T10:55:10.820202Z", + "app_metadata": {}, + "user_metadata": {}, + "identities": null, + "created_at": "2024-09-23T10:55:10.818397Z", + "updated_at": "2024-09-23T10:55:10.829256Z", + "is_anonymous": true + }, + { + "id": "6641e9ef-44a9-428c-83b4-ca84f5756dbb", + "aud": "authenticated", + "role": "authenticated", + "email": "prntt@supabase.com", + "email_confirmed_at": "2024-09-23T10:55:10.398251Z", + "phone": "", + "confirmed_at": "2024-09-23T10:55:10.398251Z", + "last_sign_in_at": "2024-09-23T10:55:10.219561Z", + "app_metadata": {}, + "user_metadata": {}, + "identities": null, + "created_at": "2024-09-23T10:55:10.216156Z", + "updated_at": "2024-09-23T10:55:10.398449Z", + "is_anonymous": false + }, + { + "id": "b509b42e-23b5-4fb9-b7b3-ddf50b48b82e", + "aud": "authenticated", + "role": "authenticated", + "email": "jvasbtw@supabase.com", + "email_confirmed_at": "2024-09-23T10:55:09.412701Z", + "phone": "", + "confirmed_at": "2024-09-23T10:55:09.412701Z", + "last_sign_in_at": "2024-09-23T10:55:09.417505Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "jvasbtw@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "b509b42e-23b5-4fb9-b7b3-ddf50b48b82e" + }, + "identities": null, + "created_at": "2024-09-23T10:55:09.407852Z", + "updated_at": "2024-09-23T10:55:09.606293Z", + "is_anonymous": false + }, + { + "id": "38a1f11e-840c-4b21-b248-d53fbb34de9c", + "aud": "authenticated", + "role": "authenticated", + "email": "fcrvjrro@supabase.com", + "email_confirmed_at": "2024-09-23T10:55:06.18255Z", + "phone": "", + "confirmed_at": "2024-09-23T10:55:06.18255Z", + "reauthentication_sent_at": "2024-09-23T10:55:06.617442Z", + "last_sign_in_at": "2024-09-23T10:55:06.185267Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "fcrvjrro@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "38a1f11e-840c-4b21-b248-d53fbb34de9c" + }, + "identities": null, + "created_at": "2024-09-23T10:55:06.164469Z", + "updated_at": "2024-09-23T10:55:08.503786Z", + "is_anonymous": false + }, + { + "id": "aa0da7fd-2272-425b-80a5-3cc38f66a1e5", + "aud": "authenticated", + "role": "authenticated", + "email": "itmyeami@supabase.com", + "email_confirmed_at": "2024-09-23T10:55:05.334493Z", + "phone": "", + "confirmed_at": "2024-09-23T10:55:05.334493Z", + "last_sign_in_at": "2024-09-23T10:55:05.336952Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "itmyeami@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "aa0da7fd-2272-425b-80a5-3cc38f66a1e5" + }, + "identities": null, + "created_at": "2024-09-23T10:55:05.314776Z", + "updated_at": "2024-09-23T10:55:05.344063Z", + "is_anonymous": false + }, + { + "id": "ec0c5411-0b47-463b-9ebb-225afc985f41", + "aud": "authenticated", + "role": "authenticated", + "email": "qitlhhxymy@supabase.com", + "email_confirmed_at": "2024-09-23T10:55:03.921824Z", + "phone": "", + "confirmed_at": "2024-09-23T10:55:03.921824Z", + "last_sign_in_at": "2024-09-23T10:55:03.926885Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "qitlhhxymy@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "ec0c5411-0b47-463b-9ebb-225afc985f41" + }, + "identities": null, + "created_at": "2024-09-23T10:55:03.902661Z", + "updated_at": "2024-09-23T10:55:03.938296Z", + "is_anonymous": false + }, + { + "id": "fbe912b5-aeb7-439a-92d4-4a1039294f2a", + "aud": "authenticated", + "role": "authenticated", + "email": "cielc@supabase.com", + "email_confirmed_at": "2024-09-09T15:28:35.786509Z", + "phone": "", + "confirmed_at": "2024-09-09T15:28:35.786509Z", + "last_sign_in_at": "2024-09-09T15:28:35.78928Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "cielc@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "fbe912b5-aeb7-439a-92d4-4a1039294f2a" + }, + "identities": null, + "created_at": "2024-09-09T15:28:35.777862Z", + "updated_at": "2024-09-09T15:28:35.793939Z", + "is_anonymous": false + }, + { + "id": "e4d954fc-0d9c-4ab0-86b0-94ef66f1fbd2", + "aud": "authenticated", + "role": "authenticated", + "email": "ujvbwmpqv@supabase.com", + "email_confirmed_at": "2024-09-09T15:28:35.226372Z", + "phone": "", + "confirmed_at": "2024-09-09T15:28:35.226372Z", + "last_sign_in_at": "2024-09-09T15:28:35.228767Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "ujvbwmpqv@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "e4d954fc-0d9c-4ab0-86b0-94ef66f1fbd2" + }, + "identities": null, + "created_at": "2024-09-09T15:28:35.222069Z", + "updated_at": "2024-09-09T15:28:35.230181Z", + "is_anonymous": false + }, + { + "id": "187e7013-e98f-47bb-95dd-a2061af380f4", + "aud": "authenticated", + "role": "authenticated", + "email": "rnfengxz@supabase.com", + "email_confirmed_at": "2024-09-09T15:28:34.520968Z", + "phone": "", + "confirmed_at": "2024-09-09T15:28:34.520968Z", + "last_sign_in_at": "2024-09-09T15:28:34.524123Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "rnfengxz@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "187e7013-e98f-47bb-95dd-a2061af380f4" + }, + "identities": null, + "created_at": "2024-09-09T15:28:34.511402Z", + "updated_at": "2024-09-09T15:28:34.527773Z", + "is_anonymous": false + }, + { + "id": "58f00e9f-f7b6-40ea-84b8-e80860264ff0", + "aud": "authenticated", + "role": "authenticated", + "email": "nmvsffkbsd@supabase.com", + "email_confirmed_at": "2024-09-09T15:28:33.185199Z", + "phone": "", + "confirmed_at": "2024-09-09T15:28:33.185199Z", + "last_sign_in_at": "2024-09-09T15:28:33.189373Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "nmvsffkbsd@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "58f00e9f-f7b6-40ea-84b8-e80860264ff0" + }, + "identities": null, + "created_at": "2024-09-09T15:28:33.177211Z", + "updated_at": "2024-09-09T15:28:33.191964Z", + "is_anonymous": false + }, + { + "id": "20fa5416-5902-4971-8591-2214b3707262", + "aud": "authenticated", + "role": "authenticated", + "email": "vzwcttdr@supabase.com", + "email_confirmed_at": "2024-09-09T15:28:32.25538Z", + "phone": "", + "confirmed_at": "2024-09-09T15:28:32.25538Z", + "last_sign_in_at": "2024-09-09T15:28:32.257891Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "vzwcttdr@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "20fa5416-5902-4971-8591-2214b3707262", + "test": 42 + }, + "identities": null, + "created_at": "2024-09-09T15:28:32.248595Z", + "updated_at": "2024-09-09T15:28:32.486621Z", + "is_anonymous": false + }, + { + "id": "37894439-8fa3-407d-a22a-133254783c3c", + "aud": "authenticated", + "role": "authenticated", + "email": "xigdzfdpvh@supabase.com", + "email_confirmed_at": "2024-09-09T15:28:31.451531Z", + "phone": "", + "confirmed_at": "2024-09-09T15:28:31.451531Z", + "last_sign_in_at": "2024-09-09T15:28:31.453793Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "xigdzfdpvh@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "37894439-8fa3-407d-a22a-133254783c3c" + }, + "identities": null, + "created_at": "2024-09-09T15:28:31.440187Z", + "updated_at": "2024-09-09T15:28:31.456527Z", + "is_anonymous": false + }, + { + "id": "e2f9f1f8-fd1d-4252-97dc-a159447f143d", + "aud": "authenticated", + "role": "authenticated", + "email": "nhvooij@supabase.com", + "email_confirmed_at": "2024-09-09T15:28:30.021647Z", + "phone": "", + "confirmed_at": "2024-09-09T15:28:30.021647Z", + "last_sign_in_at": "2024-09-09T15:28:30.928927Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "nhvooij@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "e2f9f1f8-fd1d-4252-97dc-a159447f143d", + "test": 42 + }, + "identities": null, + "created_at": "2024-09-09T15:28:30.01628Z", + "updated_at": "2024-09-09T15:28:30.93108Z", + "is_anonymous": false + }, + { + "id": "7f406129-673b-4bc7-afaf-bf6f582c6fe4", + "aud": "authenticated", + "role": "authenticated", + "email": "clljbxe@supabase.com", + "email_confirmed_at": "2024-09-09T15:28:29.066806Z", + "phone": "", + "confirmed_at": "2024-09-09T15:28:29.066806Z", + "last_sign_in_at": "2024-09-09T15:28:29.070929Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "clljbxe@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "7f406129-673b-4bc7-afaf-bf6f582c6fe4" + }, + "identities": null, + "created_at": "2024-09-09T15:28:29.059371Z", + "updated_at": "2024-09-09T15:28:29.077693Z", + "is_anonymous": false + }, + { + "id": "b9707c3c-cc57-492c-9966-02b549924cf2", + "aud": "authenticated", + "role": "authenticated", + "email": "", + "phone": "", + "last_sign_in_at": "2024-09-09T15:28:28.345564Z", + "app_metadata": {}, + "user_metadata": {}, + "identities": null, + "created_at": "2024-09-09T15:28:28.343333Z", + "updated_at": "2024-09-09T15:28:28.346965Z", + "is_anonymous": true + }, + { + "id": "c55731a8-0120-41c7-a778-53209a245b2c", + "aud": "authenticated", + "role": "authenticated", + "email": "eacbjhob@supabase.com", + "email_confirmed_at": "2024-09-09T15:28:28.119949Z", + "phone": "", + "confirmed_at": "2024-09-09T15:28:28.119949Z", + "last_sign_in_at": "2024-09-09T15:28:27.863585Z", + "app_metadata": {}, + "user_metadata": {}, + "identities": null, + "created_at": "2024-09-09T15:28:27.859394Z", + "updated_at": "2024-09-09T15:28:28.120155Z", + "is_anonymous": false + }, + { + "id": "c16287f9-8383-4298-8154-7de52264058d", + "aud": "authenticated", + "role": "authenticated", + "email": "ubjucekjxr@supabase.com", + "email_confirmed_at": "2024-09-09T15:28:27.134578Z", + "phone": "", + "confirmed_at": "2024-09-09T15:28:27.134578Z", + "last_sign_in_at": "2024-09-09T15:28:27.138826Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "ubjucekjxr@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "c16287f9-8383-4298-8154-7de52264058d" + }, + "identities": null, + "created_at": "2024-09-09T15:28:27.122439Z", + "updated_at": "2024-09-09T15:28:27.388386Z", + "is_anonymous": false + }, + { + "id": "d82b987f-d6ee-46e2-909f-f26a0d56e978", + "aud": "authenticated", + "role": "authenticated", + "email": "gcpngjhcck@supabase.com", + "email_confirmed_at": "2024-09-09T15:28:22.541847Z", + "phone": "", + "confirmed_at": "2024-09-09T15:28:22.541847Z", + "reauthentication_sent_at": "2024-09-09T15:28:22.768384Z", + "last_sign_in_at": "2024-09-09T15:28:22.548884Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "gcpngjhcck@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "d82b987f-d6ee-46e2-909f-f26a0d56e978" + }, + "identities": null, + "created_at": "2024-09-09T15:28:22.527049Z", + "updated_at": "2024-09-09T15:28:26.301478Z", + "is_anonymous": false + }, + { + "id": "b75a2c76-325b-402e-a8b8-2ecd2aefa39d", + "aud": "authenticated", + "role": "authenticated", + "email": "ofrzcsp@supabase.com", + "email_confirmed_at": "2024-09-09T15:28:21.206302Z", + "phone": "", + "confirmed_at": "2024-09-09T15:28:21.206302Z", + "last_sign_in_at": "2024-09-09T15:28:21.211625Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "ofrzcsp@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "b75a2c76-325b-402e-a8b8-2ecd2aefa39d" + }, + "identities": null, + "created_at": "2024-09-09T15:28:21.189215Z", + "updated_at": "2024-09-09T15:28:21.223035Z", + "is_anonymous": false + }, + { + "id": "441d2164-475e-4df2-a343-4a6bb162574b", + "aud": "authenticated", + "role": "authenticated", + "email": "hhwrxose@supabase.com", + "email_confirmed_at": "2024-09-09T15:28:19.851736Z", + "phone": "", + "confirmed_at": "2024-09-09T15:28:19.851736Z", + "last_sign_in_at": "2024-09-09T15:28:19.856306Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "hhwrxose@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "441d2164-475e-4df2-a343-4a6bb162574b" + }, + "identities": null, + "created_at": "2024-09-09T15:28:19.837859Z", + "updated_at": "2024-09-09T15:28:19.865618Z", + "is_anonymous": false + }, + { + "id": "3fac14e3-2787-493a-995f-816140c4683a", + "aud": "authenticated", + "role": "authenticated", + "email": "svxkqpt@supabase.com", + "email_confirmed_at": "2024-09-07T11:35:56.426639Z", + "phone": "", + "confirmed_at": "2024-09-07T11:35:56.426639Z", + "last_sign_in_at": "2024-09-07T11:35:56.42885Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "svxkqpt@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "3fac14e3-2787-493a-995f-816140c4683a" + }, + "identities": null, + "created_at": "2024-09-07T11:35:56.422288Z", + "updated_at": "2024-09-07T11:35:56.432801Z", + "is_anonymous": false + }, + { + "id": "81498f37-adcf-421e-b14c-2931dfc99469", + "aud": "authenticated", + "role": "authenticated", + "email": "yrzxbwk@supabase.com", + "email_confirmed_at": "2024-09-07T11:35:55.954078Z", + "phone": "", + "confirmed_at": "2024-09-07T11:35:55.954078Z", + "last_sign_in_at": "2024-09-07T11:35:55.956927Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "yrzxbwk@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "81498f37-adcf-421e-b14c-2931dfc99469" + }, + "identities": null, + "created_at": "2024-09-07T11:35:55.949145Z", + "updated_at": "2024-09-07T11:35:55.958847Z", + "is_anonymous": false + }, + { + "id": "9467dc47-4462-46ba-92d4-d7b3f5bf7594", + "aud": "authenticated", + "role": "authenticated", + "email": "ztffqzfrp@supabase.com", + "email_confirmed_at": "2024-09-07T11:35:55.279873Z", + "phone": "", + "confirmed_at": "2024-09-07T11:35:55.279873Z", + "last_sign_in_at": "2024-09-07T11:35:55.282201Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "ztffqzfrp@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "9467dc47-4462-46ba-92d4-d7b3f5bf7594" + }, + "identities": null, + "created_at": "2024-09-07T11:35:55.274476Z", + "updated_at": "2024-09-07T11:35:55.28366Z", + "is_anonymous": false + }, + { + "id": "26265243-d143-46a8-8fd4-dd4377eca023", + "aud": "authenticated", + "role": "authenticated", + "email": "hxeqg@supabase.com", + "email_confirmed_at": "2024-09-07T11:35:54.59134Z", + "phone": "", + "confirmed_at": "2024-09-07T11:35:54.59134Z", + "last_sign_in_at": "2024-09-07T11:35:54.595789Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "hxeqg@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "26265243-d143-46a8-8fd4-dd4377eca023" + }, + "identities": null, + "created_at": "2024-09-07T11:35:54.586923Z", + "updated_at": "2024-09-07T11:35:54.597163Z", + "is_anonymous": false + }, + { + "id": "b71663c5-43d4-4b7d-a5c1-d83553d7e6d1", + "aud": "authenticated", + "role": "authenticated", + "email": "xjtvdb@supabase.com", + "email_confirmed_at": "2024-09-07T11:35:52.201856Z", + "phone": "", + "confirmed_at": "2024-09-07T11:35:52.201856Z", + "last_sign_in_at": "2024-09-07T11:35:52.204207Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "xjtvdb@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "b71663c5-43d4-4b7d-a5c1-d83553d7e6d1", + "test": 42 + }, + "identities": null, + "created_at": "2024-09-07T11:35:52.194904Z", + "updated_at": "2024-09-07T11:35:53.078194Z", + "is_anonymous": false + }, + { + "id": "4672ae63-7295-4c95-9dc0-8c3c1392583f", + "aud": "authenticated", + "role": "authenticated", + "email": "fncuxmoqt@supabase.com", + "email_confirmed_at": "2024-09-07T11:35:50.093656Z", + "phone": "", + "confirmed_at": "2024-09-07T11:35:50.093656Z", + "last_sign_in_at": "2024-09-07T11:35:50.098026Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "fncuxmoqt@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "4672ae63-7295-4c95-9dc0-8c3c1392583f" + }, + "identities": null, + "created_at": "2024-09-07T11:35:50.087054Z", + "updated_at": "2024-09-07T11:35:50.100528Z", + "is_anonymous": false + }, + { + "id": "ae1fe144-f301-4f59-b321-19033246a2f6", + "aud": "authenticated", + "role": "authenticated", + "email": "ysycswlbj@supabase.com", + "email_confirmed_at": "2024-09-07T11:35:48.641515Z", + "phone": "", + "confirmed_at": "2024-09-07T11:35:48.641515Z", + "last_sign_in_at": "2024-09-07T11:35:49.597642Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "ysycswlbj@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "ae1fe144-f301-4f59-b321-19033246a2f6", + "test": 42 + }, + "identities": null, + "created_at": "2024-09-07T11:35:48.633616Z", + "updated_at": "2024-09-07T11:35:49.599208Z", + "is_anonymous": false + }, + { + "id": "19c8d618-c96a-4c67-90fc-be7252b16829", + "aud": "authenticated", + "role": "authenticated", + "email": "xfzsqdjp@supabase.com", + "email_confirmed_at": "2024-09-07T11:35:48.093397Z", + "phone": "", + "confirmed_at": "2024-09-07T11:35:48.093397Z", + "last_sign_in_at": "2024-09-07T11:35:48.096806Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "xfzsqdjp@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "19c8d618-c96a-4c67-90fc-be7252b16829" + }, + "identities": null, + "created_at": "2024-09-07T11:35:48.084887Z", + "updated_at": "2024-09-07T11:35:48.100718Z", + "is_anonymous": false + }, + { + "id": "6dcf6b38-8061-488d-89e2-a5f41d97d728", + "aud": "authenticated", + "role": "authenticated", + "email": "", + "phone": "", + "last_sign_in_at": "2024-09-07T11:35:46.463395Z", + "app_metadata": {}, + "user_metadata": {}, + "identities": null, + "created_at": "2024-09-07T11:35:46.457073Z", + "updated_at": "2024-09-07T11:35:46.467873Z", + "is_anonymous": true + }, + { + "id": "3bf69baf-b80f-42ad-b6d0-e0ea1a8ce821", + "aud": "authenticated", + "role": "authenticated", + "email": "hlzzvhgns@supabase.com", + "email_confirmed_at": "2024-09-07T11:35:46.26319Z", + "phone": "", + "confirmed_at": "2024-09-07T11:35:46.26319Z", + "last_sign_in_at": "2024-09-07T11:35:46.044953Z", + "app_metadata": {}, + "user_metadata": {}, + "identities": null, + "created_at": "2024-09-07T11:35:46.041846Z", + "updated_at": "2024-09-07T11:35:46.263388Z", + "is_anonymous": false + }, + { + "id": "971599e6-bf99-4599-ba1b-aa00df87667d", + "aud": "authenticated", + "role": "authenticated", + "email": "ylgvxlitb@supabase.com", + "email_confirmed_at": "2024-09-07T11:35:45.400287Z", + "phone": "", + "confirmed_at": "2024-09-07T11:35:45.400287Z", + "last_sign_in_at": "2024-09-07T11:35:45.402618Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "ylgvxlitb@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "971599e6-bf99-4599-ba1b-aa00df87667d" + }, + "identities": null, + "created_at": "2024-09-07T11:35:45.390751Z", + "updated_at": "2024-09-07T11:35:45.653903Z", + "is_anonymous": false + }, + { + "id": "5e50888d-b91a-4b1d-b3ea-c43ea879e7a3", + "aud": "authenticated", + "role": "authenticated", + "email": "nmbjixxr@supabase.com", + "email_confirmed_at": "2024-09-07T11:35:42.643321Z", + "phone": "", + "confirmed_at": "2024-09-07T11:35:42.643321Z", + "reauthentication_sent_at": "2024-09-07T11:35:42.85002Z", + "last_sign_in_at": "2024-09-07T11:35:42.647972Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "nmbjixxr@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "5e50888d-b91a-4b1d-b3ea-c43ea879e7a3" + }, + "identities": null, + "created_at": "2024-09-07T11:35:42.629054Z", + "updated_at": "2024-09-07T11:35:44.906045Z", + "is_anonymous": false + }, + { + "id": "1e33efc9-a2a7-4099-8dc3-345d9e834090", + "aud": "authenticated", + "role": "authenticated", + "email": "hmitn@supabase.com", + "email_confirmed_at": "2024-09-07T11:35:41.052655Z", + "phone": "", + "confirmed_at": "2024-09-07T11:35:41.052655Z", + "last_sign_in_at": "2024-09-07T11:35:41.056898Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "hmitn@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "1e33efc9-a2a7-4099-8dc3-345d9e834090" + }, + "identities": null, + "created_at": "2024-09-07T11:35:41.033754Z", + "updated_at": "2024-09-07T11:35:41.069898Z", + "is_anonymous": false + }, + { + "id": "c0300426-8fc0-4e17-ad70-640e3a33b3df", + "aud": "authenticated", + "role": "authenticated", + "email": "vkgmxqomr@supabase.com", + "email_confirmed_at": "2024-09-07T11:35:39.640304Z", + "phone": "", + "confirmed_at": "2024-09-07T11:35:39.640304Z", + "last_sign_in_at": "2024-09-07T11:35:39.645729Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "vkgmxqomr@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "c0300426-8fc0-4e17-ad70-640e3a33b3df" + }, + "identities": null, + "created_at": "2024-09-07T11:35:39.62358Z", + "updated_at": "2024-09-07T11:35:39.65511Z", + "is_anonymous": false + }, + { + "id": "bd7787d9-b0bb-40a0-b464-e55bd20bdbd3", + "aud": "authenticated", + "role": "authenticated", + "email": "llrens@supabase.com", + "email_confirmed_at": "2024-09-07T03:16:52.726109Z", + "phone": "", + "confirmed_at": "2024-09-07T03:16:52.726109Z", + "last_sign_in_at": "2024-09-07T03:16:52.729755Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "llrens@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "bd7787d9-b0bb-40a0-b464-e55bd20bdbd3" + }, + "identities": null, + "created_at": "2024-09-07T03:16:52.719166Z", + "updated_at": "2024-09-07T03:16:52.73133Z", + "is_anonymous": false + }, + { + "id": "c3172e8e-7853-497a-b027-1eb21feef572", + "aud": "authenticated", + "role": "authenticated", + "email": "tjiut@supabase.com", + "email_confirmed_at": "2024-09-07T03:16:52.201953Z", + "phone": "", + "confirmed_at": "2024-09-07T03:16:52.201953Z", + "last_sign_in_at": "2024-09-07T03:16:52.205573Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "tjiut@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "c3172e8e-7853-497a-b027-1eb21feef572" + }, + "identities": null, + "created_at": "2024-09-07T03:16:52.196751Z", + "updated_at": "2024-09-07T03:16:52.207118Z", + "is_anonymous": false + }, + { + "id": "2eeca7ea-a017-4c7e-a3b7-2bb26db5e20a", + "aud": "authenticated", + "role": "authenticated", + "email": "wvhibguq@supabase.com", + "email_confirmed_at": "2024-09-07T03:16:51.470052Z", + "phone": "", + "confirmed_at": "2024-09-07T03:16:51.470052Z", + "last_sign_in_at": "2024-09-07T03:16:51.472287Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "wvhibguq@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "2eeca7ea-a017-4c7e-a3b7-2bb26db5e20a" + }, + "identities": null, + "created_at": "2024-09-07T03:16:51.463239Z", + "updated_at": "2024-09-07T03:16:51.475894Z", + "is_anonymous": false + }, + { + "id": "67c84288-1a6c-4f96-b938-fb90bf7692cd", + "aud": "authenticated", + "role": "authenticated", + "email": "nvzwjmpm@supabase.com", + "email_confirmed_at": "2024-09-07T03:16:50.698242Z", + "phone": "", + "confirmed_at": "2024-09-07T03:16:50.698242Z", + "last_sign_in_at": "2024-09-07T03:16:50.700466Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "nvzwjmpm@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "67c84288-1a6c-4f96-b938-fb90bf7692cd" + }, + "identities": null, + "created_at": "2024-09-07T03:16:50.692031Z", + "updated_at": "2024-09-07T03:16:50.702529Z", + "is_anonymous": false + }, + { + "id": "7a1b56d4-2a58-4485-bcfc-9997b029ac75", + "aud": "authenticated", + "role": "authenticated", + "email": "pazprmk@supabase.com", + "email_confirmed_at": "2024-09-07T03:16:49.93797Z", + "phone": "", + "confirmed_at": "2024-09-07T03:16:49.93797Z", + "last_sign_in_at": "2024-09-07T03:16:49.94022Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "pazprmk@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "7a1b56d4-2a58-4485-bcfc-9997b029ac75", + "test": 42 + }, + "identities": null, + "created_at": "2024-09-07T03:16:49.931332Z", + "updated_at": "2024-09-07T03:16:50.147887Z", + "is_anonymous": false + }, + { + "id": "56e74398-c801-43f0-bb3c-96f38332802a", + "aud": "authenticated", + "role": "authenticated", + "email": "apebt@supabase.com", + "email_confirmed_at": "2024-09-07T03:16:49.179173Z", + "phone": "", + "confirmed_at": "2024-09-07T03:16:49.179173Z", + "last_sign_in_at": "2024-09-07T03:16:49.183825Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "apebt@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "56e74398-c801-43f0-bb3c-96f38332802a" + }, + "identities": null, + "created_at": "2024-09-07T03:16:49.174209Z", + "updated_at": "2024-09-07T03:16:49.185316Z", + "is_anonymous": false + }, + { + "id": "fb6e2939-44e3-4463-be19-ffb26f1d05f5", + "aud": "authenticated", + "role": "authenticated", + "email": "chcigkhyrj@supabase.com", + "email_confirmed_at": "2024-09-07T03:16:48.171025Z", + "phone": "", + "confirmed_at": "2024-09-07T03:16:48.171025Z", + "last_sign_in_at": "2024-09-07T03:16:48.673115Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "chcigkhyrj@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "fb6e2939-44e3-4463-be19-ffb26f1d05f5", + "test": 42 + }, + "identities": null, + "created_at": "2024-09-07T03:16:48.164747Z", + "updated_at": "2024-09-07T03:16:48.675668Z", + "is_anonymous": false + }, + { + "id": "7e8ff617-baa4-4a6a-acf3-6bcbe91c1100", + "aud": "authenticated", + "role": "authenticated", + "email": "xaqyl@supabase.com", + "email_confirmed_at": "2024-09-07T03:16:47.482428Z", + "phone": "", + "confirmed_at": "2024-09-07T03:16:47.482428Z", + "last_sign_in_at": "2024-09-07T03:16:47.485381Z", + "app_metadata": { + "provider": "email", + "providers": [ + "email" + ] + }, + "user_metadata": { + "email": "xaqyl@supabase.com", + "email_verified": false, + "phone_verified": false, + "sub": "7e8ff617-baa4-4a6a-acf3-6bcbe91c1100" + }, + "identities": null, + "created_at": "2024-09-07T03:16:47.473931Z", + "updated_at": "2024-09-07T03:16:47.487384Z", + "is_anonymous": false + } + ], + "aud": "authenticated" +} diff --git a/Tests/IntegrationTests/AuthClientIntegrationTests.swift b/Tests/IntegrationTests/AuthClientIntegrationTests.swift index dd950c479..f40b39e08 100644 --- a/Tests/IntegrationTests/AuthClientIntegrationTests.swift +++ b/Tests/IntegrationTests/AuthClientIntegrationTests.swift @@ -18,12 +18,14 @@ import XCTest final class AuthClientIntegrationTests: XCTestCase { let authClient = makeClient() - static func makeClient() -> AuthClient { - AuthClient( + static func makeClient(serviceRole: Bool = false) -> AuthClient { + let key = serviceRole ? DotEnv.SUPABASE_SERVICE_ROLE_KEY : DotEnv.SUPABASE_ANON_KEY + return AuthClient( configuration: AuthClient.Configuration( url: URL(string: "\(DotEnv.SUPABASE_URL)/auth/v1")!, headers: [ - "apikey": DotEnv.SUPABASE_ANON_KEY, + "apikey": key, + "Authorization": "Bearer \(key)", ], localStorage: InMemoryLocalStorage(), logger: nil @@ -249,6 +251,14 @@ final class AuthClientIntegrationTests: XCTestCase { } } + func testListUsers() async throws { + let client = Self.makeClient(serviceRole: true) + let pagination = try await client.admin.listUsers(params: PageParams(perPage: 10)) + XCTAssertEqual(pagination.users.count, 10) + XCTAssertEqual(pagination.aud, "authenticated") + XCTAssertEqual(pagination.nextPage, 2) + } + @discardableResult private func signUpIfNeededOrSignIn( email: String,