Skip to content
New issue

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

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

Already on GitHub? Sign in to your account

Created request and response objects for sdk 2.x #222

Merged
merged 8 commits into from
Mar 2, 2024
Merged
Show file tree
Hide file tree
Changes from 5 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
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (C) 2024. Uber Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.uber.sdk2.auth.api.exception

/** Represents the exception that occurred during the authentication request. */
sealed class AuthException(override val message: String) : Throwable(message) {
/** Represents the exception that occurred due to server error. */
data class ServerError(override val message: String) : AuthException(message)

/** Represents the exception that occurred due to client error. */
data class ClientError(override val message: String) : AuthException(message)

/** Represents the exception that occurred due to network error. */
data class NetworkError(override val message: String) : AuthException(message)
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (C) 2024. Uber Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.uber.sdk2.auth.api.request

/**
* Represents the context of the authentication request needed for Uber to authenticate the user.
*
* @param authDestination The destination app to authenticate the user.
* @param authType The type of authentication to perform.
* @param prefillInfo The prefill information to be used for the authentication.
* @param scopes The scopes to request for the authentication.
*/
data class AuthContext(
val authDestination: AuthDestination,
val authType: AuthType,
val prefillInfo: PrefillInfo?,
val scopes: String?,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* Copyright (C) 2024. Uber Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.uber.sdk2.auth.api.request

/** Represents the destination app to authenticate the user. */
sealed class AuthDestination {
/**
* Authenticating within the same app by using a system webview, a.k.a Custom Tabs. If custom tabs
* are unavailable the authentication flow will be launched in the system browser app.
*/
object InApp : AuthDestination()

/**
* Authenticating via one of the family of Uber apps using the Single Sign-On (SSO) flow in the
* order of priority mentioned.
*
* @param appPriority The order of the apps to use for the SSO flow.
*/
data class CrossAppSso(val appPriority: List<CrossApp>) : AuthDestination()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,29 @@
/*
* Copyright (C) 2024. Uber Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.uber.sdk2.auth.api.request

/**
* Represents the type of authentication to perform.
*
* @see AuthContext
*/
sealed class AuthType {
/** The authorization code flow. */
object AuthCode : AuthType()

/** The proof key for code exchange (PKCE) flow. This is the recommended flow for mobile apps. */
object PKCE : AuthType()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (C) 2024. Uber Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.uber.sdk2.auth.api.request

/** Provides different apps that could be used for authentication using SSO flow. */
sealed class CrossApp {
/** The Eats app. */
object Eats : CrossApp()

/** The Rider app. */
object Rider : CrossApp()

/** The Driver app. */
object Driver : CrossApp()
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (C) 2024. Uber Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.uber.sdk2.auth.api.request

/**
* Provides a way to prefill the user's information in the authentication flow.
*
* @param email The email to prefill.
* @param firstName The first name to prefill.
* @param lastName The last name to prefill.
* @param phoneNumber The phone number to prefill.
*/
data class PrefillInfo(
val email: String,
val firstName: String,
val lastName: String,
val phoneNumber: String,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (C) 2024. Uber Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.uber.sdk2.auth.api.response

/** Holds the access token that is returned after a successful authentication request. */
data class AccessToken(val token: String, val scope: String, val expiresIn: Long)
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
/*
* Copyright (C) 2024. Uber Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.uber.sdk2.auth.api.response

import com.uber.sdk2.auth.api.exception.AuthException

/**
* Represents the response from the authentication request.
*
* @param authCode The authorization code to be used for the token exchange.
* @param accessToken The access token to be used for the API requests.
* @param authException The exception that occurred during the authentication request.
*/
data class AuthResponse(
val authCode: String,
val accessToken: AccessToken,
val authException: AuthException,
)
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
/*
* Copyright (C) 2024. Uber Technologies
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.uber.sdk2.auth.api.response

/** Holds the OAuth token that is returned after a successful authentication request. */
data class OAuthToken(val accessToken: AccessToken, val refreshToken: String)
Loading