-
Notifications
You must be signed in to change notification settings - Fork 104
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'master' into IOPAE-1100-1282-1285
- Loading branch information
Showing
24 changed files
with
500 additions
and
145 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,128 @@ | ||
openapi: 3.0.0 | ||
info: | ||
title: IO (FIMS) | ||
version: 1.0.0 | ||
|
||
security: | ||
- Bearer: [] | ||
|
||
paths: | ||
/api/v1/fims/consents: | ||
get: | ||
operationId: getConsents | ||
parameters: | ||
- $ref: "#/components/parameters/continuationToken" | ||
responses: | ||
200: | ||
description: "OK" | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/ConsentsResponseDTO" | ||
401: | ||
description: Bearer token null or expired. | ||
502: | ||
description: Bad gateway. | ||
504: | ||
description: Gateway timeout. | ||
500: | ||
description: Service unavailable. | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/ProblemJson" | ||
|
||
/api/v1/fims/exports: | ||
post: | ||
operationId: exports | ||
requestBody: | ||
$ref: "#/components/requestBodies/Export" | ||
responses: | ||
202: | ||
description: Accepted | ||
409: | ||
description: Conflict | ||
401: | ||
description: Bearer token null or expired. | ||
502: | ||
description: Bad gateway. | ||
504: | ||
description: Gateway timeout. | ||
500: | ||
description: Service unavailable. | ||
content: | ||
application/json: | ||
schema: | ||
$ref: "#/components/schemas/ProblemJson" | ||
|
||
|
||
components: | ||
securitySchemes: | ||
Bearer: | ||
type: http | ||
scheme: bearer | ||
bearerFormat: JWT | ||
|
||
parameters: | ||
continuationToken: | ||
name: continuationToken | ||
in: query | ||
required: false | ||
schema: | ||
type: string | ||
|
||
requestBodies: | ||
Export: | ||
description: Require an export | ||
required: true | ||
content: | ||
application/json: | ||
schema: | ||
type: object | ||
properties: | ||
type: | ||
type: string | ||
enum: ["consent"] | ||
required: | ||
- type | ||
|
||
schemas: | ||
ConsentsResponseDTO: | ||
type: object | ||
properties: | ||
items: | ||
type: array | ||
items: | ||
$ref: "#/components/schemas/Consent" | ||
continuationToken: | ||
type: string | ||
required: | ||
- items | ||
- continuationToken | ||
|
||
ProblemJson: | ||
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v26.3.0/openapi/definitions.yaml#/ProblemJson" | ||
|
||
Consent: | ||
type: object | ||
properties: | ||
id: | ||
type: string | ||
format: ulid | ||
service_id: | ||
type: string | ||
format: ulid | ||
redirect: | ||
type: object | ||
properties: | ||
uri: | ||
type: string | ||
format: uri | ||
display_name: | ||
type: string | ||
timestamp: | ||
$ref: "https://raw.githubusercontent.com/pagopa/io-functions-commons/v26.3.0/openapi/definitions.yaml#/Timestamp" | ||
required: | ||
- id | ||
- service_id | ||
- timestamp |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
import { createStackNavigator } from "@react-navigation/stack"; | ||
import * as React from "react"; | ||
import { FimsHistoryScreen } from "../../history/screens/HistoryScreen"; | ||
import { | ||
FimsFlowHandlerScreen, | ||
FimsFlowHandlerScreenRouteParams | ||
} from "../../singleSignOn/screens/FimsFlowHandlerScreen"; | ||
|
||
export const FIMS_ROUTES = { | ||
MAIN: "FIMS_MAIN", | ||
CONSENTS: "FIMS_SSO_CONSENTS", | ||
HISTORY: "FIMS_HISTORY" | ||
} as const; | ||
|
||
export type FimsParamsList = { | ||
[FIMS_ROUTES.MAIN]: undefined; | ||
[FIMS_ROUTES.CONSENTS]: FimsFlowHandlerScreenRouteParams; | ||
[FIMS_ROUTES.HISTORY]: undefined; | ||
}; | ||
|
||
const Stack = createStackNavigator<FimsParamsList>(); | ||
|
||
export const FimsNavigator = () => ( | ||
<Stack.Navigator | ||
initialRouteName={FIMS_ROUTES.MAIN} | ||
// Make sure to disable gestures in order to prevent | ||
// the user from going back by swiping and thus not | ||
// calling the custom cancel logic | ||
screenOptions={{ gestureEnabled: false, headerShown: true }} | ||
> | ||
<Stack.Screen | ||
name={FIMS_ROUTES.CONSENTS} | ||
component={FimsFlowHandlerScreen} | ||
/> | ||
<Stack.Screen name={FIMS_ROUTES.HISTORY} component={FimsHistoryScreen} /> | ||
</Stack.Navigator> | ||
); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,7 +1,21 @@ | ||
import { SagaIterator } from "redux-saga"; | ||
import { fork } from "typed-redux-saga/macro"; | ||
import { fork, select } from "typed-redux-saga/macro"; | ||
import { apiUrlPrefix } from "../../../../config"; | ||
import { sessionTokenSelector } from "../../../../store/reducers/authentication"; | ||
import { createFimsClient } from "../../history/api/client"; | ||
import { watchFimsHistorySaga } from "../../history/saga"; | ||
import { watchFimsSSOSaga } from "../../singleSignOn/saga"; | ||
|
||
const FIMS_DEV_ENV_TOKEN = ""; | ||
|
||
export function* watchFimsSaga(): SagaIterator { | ||
const fimsClient = createFimsClient(apiUrlPrefix); | ||
|
||
const sessionToken = yield* select(sessionTokenSelector); | ||
yield* fork(watchFimsSSOSaga); | ||
yield* fork( | ||
watchFimsHistorySaga, | ||
fimsClient, | ||
sessionToken ?? FIMS_DEV_ENV_TOKEN | ||
); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
import { FimsHistoryActions } from "../../history/store/actions"; | ||
import { FimsSSOActions } from "../../singleSignOn/store/actions"; | ||
|
||
export type FimsActions = FimsSSOActions; | ||
export type FimsActions = FimsSSOActions | FimsHistoryActions; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
import { createClient } from "../../../../../definitions/fims/client"; | ||
import { defaultRetryingFetch } from "../../../../utils/fetch"; | ||
|
||
export const createFimsClient = (baseUrl: string) => | ||
createClient({ | ||
baseUrl, | ||
fetchApi: defaultRetryingFetch() | ||
}); | ||
|
||
export type FimsHistoryClient = ReturnType<typeof createFimsClient>; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,49 @@ | ||
import * as E from "fp-ts/lib/Either"; | ||
import { pipe } from "fp-ts/lib/function"; | ||
import { call, put } from "typed-redux-saga/macro"; | ||
import { ActionType } from "typesafe-actions"; | ||
import { SagaCallReturnType } from "../../../../types/utils"; | ||
import { withRefreshApiCall } from "../../../fastLogin/saga/utils"; | ||
import { FimsHistoryClient } from "../api/client"; | ||
import { fimsHistoryGet } from "../store/actions"; | ||
|
||
export function* handleGetFimsHistorySaga( | ||
getFimsHistory: FimsHistoryClient["getConsents"], | ||
bearerToken: string, | ||
action: ActionType<typeof fimsHistoryGet.request> | ||
) { | ||
const getHistoryRequest = getFimsHistory({ | ||
Bearer: bearerToken, | ||
continuationToken: action.payload.continuationToken | ||
}); | ||
|
||
try { | ||
const getHistoryResult = (yield* call( | ||
withRefreshApiCall, | ||
getHistoryRequest, | ||
action | ||
)) as SagaCallReturnType<typeof getFimsHistory>; | ||
|
||
const resultAction = yield* call( | ||
extractFimsHistoryResponseAction, | ||
getHistoryResult | ||
); | ||
yield* put(resultAction); | ||
} catch (e) { | ||
yield* put(fimsHistoryGet.failure((e as Error).toString())); | ||
} | ||
} | ||
|
||
const extractFimsHistoryResponseAction = ( | ||
historyResult: SagaCallReturnType<FimsHistoryClient["getConsents"]> | ||
) => | ||
pipe( | ||
historyResult, | ||
E.fold( | ||
error => fimsHistoryGet.failure(error.toString()), | ||
response => | ||
response.status === 200 | ||
? fimsHistoryGet.success(response.value) | ||
: fimsHistoryGet.failure("GENERIC_NON_200") | ||
) | ||
); |
Oops, something went wrong.