-
Notifications
You must be signed in to change notification settings - Fork 259
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #7167 from JayaShakthi97/feat-remote-userstore
[feat] introduce new remote user store impl - add file verification steps
- Loading branch information
Showing
7 changed files
with
291 additions
and
29 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,5 @@ | ||
--- | ||
"@wso2is/admin.remote-userstores.v1": minor | ||
--- | ||
|
||
[feat] introduce new remote user store impl - add file verification steps |
70 changes: 70 additions & 0 deletions
70
features/admin.remote-userstores.v1/api/use-get-sha-file.ts
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,70 @@ | ||
/** | ||
* Copyright (c) 2024, WSO2 LLC. (https://www.wso2.com). | ||
* | ||
* WSO2 LLC. licenses this file to you 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 | ||
* | ||
* http://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. | ||
*/ | ||
|
||
import useRequest, { | ||
RequestConfigInterface, | ||
RequestErrorInterface, | ||
RequestResultInterface | ||
} from "@wso2is/admin.core.v1/hooks/use-request"; | ||
import { HttpMethods } from "@wso2is/core/models"; | ||
import isEmpty from "lodash-es/isEmpty"; | ||
|
||
/** | ||
* Hook to get the checksum file content. | ||
* | ||
* @param filePath - File path to be fetched. | ||
* @param shouldFetch - If true, will fetch the data. | ||
* | ||
* @returns content of the file. | ||
*/ | ||
const useGetCheckSum = <Data = string, Error = RequestErrorInterface>( | ||
filePath: string, | ||
shouldFetch: boolean = true | ||
): RequestResultInterface<Data, Error> => { | ||
|
||
const requestConfig: RequestConfigInterface = { | ||
headers: { | ||
"Accept": "text/plain", | ||
"Content-Type": "text/plain" | ||
}, | ||
method: HttpMethods.GET, | ||
responseType: "text", | ||
url: filePath | ||
}; | ||
|
||
const { | ||
data, | ||
error, | ||
isLoading, | ||
isValidating, | ||
mutate | ||
} = useRequest<Data, Error>( | ||
(shouldFetch && !isEmpty(filePath)) ? requestConfig : null, | ||
{ attachToken: false } | ||
); | ||
|
||
return { | ||
data, | ||
error, | ||
isLoading, | ||
isValidating, | ||
mutate | ||
}; | ||
}; | ||
|
||
export default useGetCheckSum; |
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
Oops, something went wrong.