-
Notifications
You must be signed in to change notification settings - Fork 488
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
133 additions
and
201 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
31 changes: 31 additions & 0 deletions
31
apps/extension/src/pages/setting/general/link-keplr-mobile/upload-to-s3.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,31 @@ | ||
import { simpleFetch, SimpleFetchResponse } from "@keplr-wallet/simple-fetch"; | ||
|
||
type Response = { | ||
otp: string; | ||
} | null; | ||
|
||
export async function uploadToS3( | ||
encryptedData: string | ||
): Promise<SimpleFetchResponse<Response>["data"]> { | ||
const postEndpoint = | ||
process.env["KEPLR_EXT_LINK_MOBILE_POST_ENDPOINT"] ?? | ||
"https://p56p7lfgkbcssbsroxjb6amexu0ybdxt.lambda-url.us-west-2.on.aws"; | ||
|
||
if (!postEndpoint) { | ||
throw new Error("KEPLR_EXT_LINK_MOBILE_POST_ENDPOINT is not set"); | ||
} | ||
|
||
const response = await simpleFetch<Response>(postEndpoint, { | ||
method: "POST", | ||
headers: { | ||
"Content-Type": "application/json", | ||
}, | ||
body: JSON.stringify({ data: encryptedData }), | ||
}); | ||
|
||
if (response.status !== 200) { | ||
throw new Error("Failed to upload to S3"); | ||
} | ||
|
||
return response.data; | ||
} |