-
Notifications
You must be signed in to change notification settings - Fork 0
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
1 parent
5c8cb2d
commit abc27e6
Showing
9 changed files
with
42 additions
and
2 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 |
---|---|---|
@@ -1,3 +1,7 @@ | ||
## 0.0.3 | ||
|
||
- Refactor | ||
|
||
## 0.0.2 | ||
|
||
- Bug fix | ||
|
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { default as encrypt } from "./lib/encrypt.js"; | ||
export { default as decrypt } from "./lib/decrypt.js"; | ||
export { default as access } from "./lib/access.js"; | ||
export { default as Uint8ArrayFromObject } from "./lib/Uint8ArrayFromObject.js"; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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,3 @@ | ||
/// <reference types="@cloudflare/workers-types" /> | ||
declare const _default: (Key: JsonWebKey["k"], UUID: ReturnType<Crypto["randomUUID"]>, From: KVNamespace, View?: "access_token") => Promise<any>; | ||
export default _default; |
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export { default as encrypt } from "./lib/encrypt.js"; | ||
export { default as decrypt } from "./lib/decrypt.js"; | ||
export { default as access } from "./lib/access.js"; | ||
export { default as Uint8ArrayFromObject } from "./lib/Uint8ArrayFromObject.js"; |
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,29 @@ | ||
import { Buffer } from "node:buffer"; | ||
import type { DataObject } from "./Uint8ArrayFromObject"; | ||
import decrypt from "./decrypt.js"; | ||
import Uint8ArrayFromObject from "./Uint8ArrayFromObject.js"; | ||
|
||
export default async ( | ||
Key: JsonWebKey["k"], | ||
UUID: ReturnType<Crypto["randomUUID"]>, | ||
From: KVNamespace, | ||
View: "access_token" = "access_token" | ||
) => { | ||
try { | ||
const { iv, data } = (await From.get(UUID, { | ||
type: "json", | ||
})) as DataObject; | ||
|
||
return JSON.parse( | ||
Buffer.from( | ||
await decrypt( | ||
await Uint8ArrayFromObject(data), | ||
Key ?? "", | ||
await Uint8ArrayFromObject(iv) | ||
) | ||
).toString() | ||
)[View]; | ||
} catch (error) { | ||
return {}; | ||
} | ||
}; |