-
Notifications
You must be signed in to change notification settings - Fork 6
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 #30 from mimiMonads/0.1.40
0.1.40
- Loading branch information
Showing
61 changed files
with
828 additions
and
678 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,14 @@ | ||
name: Bun | ||
|
||
on: [push, pull_request] | ||
|
||
jobs: | ||
test: | ||
runs-on: ubuntu-latest | ||
steps: | ||
- uses: actions/checkout@v3 | ||
- uses: antongolub/action-setup-bun@v1.12.8 | ||
with: | ||
bun-version: v1.x # Uses latest bun 1 | ||
- run: bun x jsr add @cross/test @std/assert # Installs dependencies | ||
- run: find . -type f -name "*.test.ts" | while read -r file; do echo "Running tests in $file"; bun test "$file"; done # Runs the tests |
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,2 @@ | ||
[install.scopes] | ||
"@jsr" = "https://npm.jsr.io" |
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,9 @@ | ||
{ | ||
"name": "@vixeny/core", | ||
"version": "0.1.40", | ||
"exports": "./main.ts", | ||
"imports": { | ||
"@cross/test": "jsr:@cross/test@^0.0.9", | ||
"@std/assert": "jsr:@std/assert@^0.226.0" | ||
} | ||
} |
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 was deleted.
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,46 @@ | ||
import type { FunRouterOptions } from "../../options.ts"; | ||
import type { Petition, SupportedKeys } from "../../morphism.ts"; | ||
import cookieToTokenBodyParser from "./cookieToTokenBodyParser.ts"; | ||
import cookieToTokenGets from "./cookieToTokenGets.ts"; | ||
import plugins from "../../exportable/plugin.ts"; | ||
import composerTools from "../../composer/composerTools.ts"; | ||
|
||
export const f = | ||
(o?: FunRouterOptions<any>) => | ||
(p: Petition): (s: string) => Record<string, string | undefined> => | ||
p.crypto && "globalKey" in p.crypto | ||
? ( | ||
(getCookies) => | ||
"token" in p.crypto | ||
? ((s: SupportedKeys) => (arr: string[]) => | ||
arr.reduce( | ||
(acc, x) => | ||
acc(cookieToTokenGets(composerTools.parsingToHexa(s))(x)), | ||
cookieToTokenBodyParser(arr), | ||
))(p.crypto.globalKey)( | ||
//@ts-ignore | ||
Object.keys(p.crypto.token), | ||
) | ||
: getCookies && getCookies.length > 0 | ||
? ((s: SupportedKeys) => (arr: string[]) => | ||
arr.reduce( | ||
(acc, x) => | ||
acc(cookieToTokenGets(composerTools.parsingToHexa(s))(x)), | ||
cookieToTokenBodyParser(arr), | ||
))(p.crypto.globalKey)( | ||
getCookies, | ||
) | ||
: void console.error("No token found, please use 'token' ") ?? | ||
((_: string) => null) | ||
)( | ||
plugins.pluginIsUsing(p)("token"), | ||
) | ||
: () => null; | ||
|
||
export const isUsing = (o?: FunRouterOptions<any>) => (p: Petition): string => | ||
( | ||
(uses) => | ||
uses && uses.length > 0 ? `[` + uses.map((x) => x + "?") + "]" : "null" | ||
)( | ||
plugins.pluginIsUsing(p)("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 |
---|---|---|
@@ -0,0 +1,15 @@ | ||
export default (_o?: any) => | ||
((s: string) => | ||
s | ||
? Object.fromEntries( | ||
s | ||
.split("; ") | ||
.filter((x) => | ||
x | ||
.indexOf("=") !== -1 | ||
) | ||
.map((x) => x.split("=")), | ||
) | ||
: {}) as unknown as ( | ||
string: string | null, | ||
) => Record<string, string | undefined>; |
This file was deleted.
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,31 @@ | ||
import plugins from "../../exportable/plugin.ts"; | ||
import type { Petition } from "../../morphism.ts"; | ||
import type { FunRouterOptions } from "../../options.ts"; | ||
import { body } from "./cookieBodyParser.ts"; | ||
import cookieDefaultCase from "./cookieDefaultCase.ts"; | ||
|
||
type Cookie = (string: string | null) => Record<string, string | undefined>; | ||
|
||
const f = (o?: FunRouterOptions<any>) => (p: Petition): Cookie => | ||
( | ||
(cookies) => | ||
cookies | ||
? body(p.cookie?.only ?? cookies) as Cookie | ||
: cookieDefaultCase() as Cookie | ||
)( | ||
plugins.pluginIsUsing(p)("cookies"), | ||
); | ||
|
||
const isUsing = (o?: FunRouterOptions<any>) => (p: Petition): string => | ||
( | ||
(uses) => | ||
p.cookie?.only | ||
? p.cookie?.only.toString() | ||
: uses && uses.length > 0 | ||
? `[` + uses.map((x) => x + "?") + "]" | ||
: `Record<string, string|null> | null` | ||
)( | ||
plugins.pluginIsUsing(p)("cookies"), | ||
); | ||
|
||
export { f, isUsing }; |
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
10 changes: 7 additions & 3 deletions
10
src/components/jwt/signSha256.mjs → src/components/jwt/signSha256.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 |
---|---|---|
@@ -1,18 +1,22 @@ | ||
import signer from "./src/sign/sha256.mjs"; | ||
import signer from "./src/sign/sha256.ts"; | ||
import nodeCrypto from "node:crypto"; | ||
import BufferProto from "node:buffer"; | ||
import name from "../runtime/name.mjs"; | ||
import args from "../runtime/name.ts"; | ||
|
||
type HashFunction = (data: Uint8Array) => nodeCrypto.Hash; | ||
|
||
export default () => | ||
( | ||
(rt) => | ||
signer( | ||
//@ts-ignore | ||
rt === "Bun" ? Buffer : BufferProto.Buffer, | ||
)( | ||
rt === "Bun" | ||
//@ts-ignore | ||
? (d) => new Bun.CryptoHasher("sha256").update(d) | ||
: (d) => nodeCrypto.createHash("sha256").update(d), | ||
) | ||
)( | ||
name(), | ||
args(), | ||
)(); |
Oops, something went wrong.