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

More advanced control for encoders, parsers and url builders #30

Merged
merged 2 commits into from
Jun 30, 2021
Merged
Show file tree
Hide file tree
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
270 changes: 270 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,273 @@
## v8.0.0 (2021-??-??)

- Allow more advanced control for tweaking parsers, decoders and url builders. This is particularly useful for applications integrating with systems which are either not strictly following the OAuth2.0 specifications, or, systems who introduce custom fields of some importance for the underlying application. (see #29, #23, #21)

- Update dependencies for base64 encoding

### Diff

#### `OAuth` - MINOR

- Added:

```elm
type GrantType
= AuthorizationCode
| Password
| ClientCredentials
| RefreshToken
| CustomGrant String

grantTypeToString : GrantType -> String
```

```elm
type ResponseType
= Code
| Token
| CustomResponse String

responseTypeToString : ResponseType -> String
```

#### `OAuth.Implicit` - MAJOR

- Added:

```elm
makeAuthorizationUrlWith :
ResponseType
-> Dict String String
-> Authorization
-> Url
```

- Changed:

```elm
-- type alias Parsers =
-- { tokenParser :
-- Query.Parser (Maybe Token)
-- , errorParser :
-- Query.Parser (Maybe ErrorCode)
-- , authorizationSuccessParser :
-- String -> Query.Parser AuthorizationSuccess
-- , authorizationErrorParser :
-- ErrorCode -> Query.Parser AuthorizationError
-- }

type alias Parsers error success =
{ tokenParser :
Query.Parser (Maybe Token)
, errorParser :
Query.Parser (Maybe ErrorCode)
, authorizationSuccessParser :
String -> Query.Parser success
, authorizationErrorParser :
ErrorCode -> Query.Parser error
}
```

```elm
-- defaultParsers : Parsers
defaultParsers : Parsers AuthorizationError AuthorizationSuccess
```

```elm
-- parseTokenWith : Parsers -> Url -> AuthorizationResult
parseTokenWith : Parsers error success -> Url -> AuthorizationResultWith error success
```

#### `OAuth.AuthorizationCode` - MAJOR

- Added:

```elm
makeAuthorizationUrlWith :
ResponseType
-> Dict String String
-> Authorization
-> Url
```

```elm
makeTokenRequestWith :
OAuth.GrantType
-> Json.Decoder success
-> Dict String String
-> (Result Http.Error success -> msg)
-> Authentication
-> RequestParts msg
```

- Changed:

```elm
-- type AuthorizationResult
-- = Empty
-- | Error AuthorizationError
-- | Success AuthorizationSuccess

type alias AuthorizationResult =
AuthorizationResultWith AuthorizationError AuthorizationSuccess

type AuthorizationResultWith error success
= Empty
| Error error
| Success success
```

```elm
-- type alias Parsers =
-- { codeParser :
-- Query.Parser (Maybe String)
-- , errorParser :
-- Query.Parser (Maybe ErrorCode)
-- , authorizationSuccessParser :
-- String -> Query.Parser AuthorizationSuccess
-- , authorizationErrorParser :
-- ErrorCode -> Query.Parser AuthorizationError
-- }

type alias Parsers error success =
{ codeParser :
Query.Parser (Maybe String)
, errorParser :
Query.Parser (Maybe ErrorCode)
, authorizationSuccessParser :
String -> Query.Parser success
, authorizationErrorParser :
ErrorCode -> Query.Parser error
}
```

```elm
-- defaultParsers : Parsers
defaultParsers : Parsers AuthorizationError AuthorizationSuccess
```

```elm
-- parseCodeWith : Parsers -> Url -> AuthorizationResult
parseCodeWith : Parsers error success -> Url -> AuthorizationResultWith error success
```

#### `OAuth.AuthorizationCode.PKCE` - MAJOR

- Added:

```elm
makeAuthorizationUrlWith :
ResponseType
-> Dict String String
-> Authorization
-> Url
```

```elm
makeTokenRequestWith :
OAuth.GrantType
-> Json.Decoder success
-> Dict String String
-> (Result Http.Error success -> msg)
-> Authentication
-> RequestParts msg
```

- Changed:

```elm
-- type AuthorizationResult
-- = Empty
-- | Error AuthorizationError
-- | Success AuthorizationSuccess

type alias AuthorizationResult =
AuthorizationResultWith AuthorizationError AuthorizationSuccess

type AuthorizationResultWith error success
= Empty
| Error error
| Success success
```

```elm
-- type alias Parsers =
-- { codeParser :
-- Query.Parser (Maybe String)
-- , errorParser :
-- Query.Parser (Maybe ErrorCode)
-- , authorizationSuccessParser :
-- String -> Query.Parser AuthorizationSuccess
-- , authorizationErrorParser :
-- ErrorCode -> Query.Parser AuthorizationError
-- }

type alias Parsers error success =
{ codeParser :
Query.Parser (Maybe String)
, errorParser :
Query.Parser (Maybe ErrorCode)
, authorizationSuccessParser :
String -> Query.Parser success
, authorizationErrorParser :
ErrorCode -> Query.Parser error
}
```

```elm
-- defaultParsers : Parsers
defaultParsers : Parsers AuthorizationError AuthorizationSuccess
```

```elm
-- parseCodeWith : Parsers -> Url -> AuthorizationResult
parseCodeWith : Parsers error success -> Url -> AuthorizationResultWith error success
```


#### `OAuth.ClientCredentials` - MINOR

- Added:

```elm
makeTokenRequestWith :
GrantType
-> Json.Decoder success
-> Dict String String
-> (Result Http.Error success -> msg)
-> Authentication
-> RequestParts msg
```

#### `OAuth.Password` - MINOR

- Added:

```elm
makeTokenRequestWith :
GrantType
-> Json.Decoder success
-> Dict String String
-> (Result Http.Error success -> msg)
-> Authentication
-> RequestParts msg
```


#### `OAuth.Refresh` - MINOR

- Added:

```elm
makeTokenRequestWith :
GrantType
-> Json.Decoder success
-> Dict String String
-> (Result Http.Error success -> msg)
-> Authentication
-> RequestParts msg
```

## v7.0.1 (2020-12-05)

- Updated dependency `ivadzy/bbase64@1.1.1` renamed as `chelovek0v/bbase64@1.0.1`
Expand Down
2 changes: 1 addition & 1 deletion elm.json
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
"name": "truqu/elm-oauth2",
"summary": "OAuth 2.0 client-side utils",
"license": "MIT",
"version": "7.0.1",
"version": "8.0.0",
"exposed-modules": [
"OAuth",
"OAuth.AuthorizationCode",
Expand Down
2 changes: 1 addition & 1 deletion examples/providers/facebook/implicit/Main.elm
Original file line number Diff line number Diff line change
Expand Up @@ -497,7 +497,7 @@ errorParser =

{-| Put everything together and rely on `OAuth.parseTokenWith` instead of the default parser
-}
parsers : OAuth.Parsers
parsers : OAuth.Parsers OAuth.AuthorizationError OAuth.AuthorizationSuccess
parsers =
{ tokenParser = tokenParser
, errorParser = errorParser
Expand Down
Loading