-
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
Showing
12 changed files
with
145 additions
and
62 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
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 |
---|---|---|
|
@@ -10,14 +10,14 @@ export { | |
join, | ||
normalize, | ||
resolve, | ||
} from "https://deno.land/std@0.209.0/path/mod.ts"; | ||
export { ensureDir, ensureFile } from "https://deno.land/std@0.209.0/fs/mod.ts"; | ||
} from "https://deno.land/std@0.223.0/path/mod.ts"; | ||
export { ensureDir, ensureFile } from "https://deno.land/std@0.223.0/fs/mod.ts"; | ||
export { | ||
decode as decodeFromHex, | ||
encode as encodeToHex, | ||
} from "https://deno.land/std@0.209.0/encoding/hex.ts"; | ||
export * as base64 from "https://deno.land/std@0.209.0/encoding/base64.ts"; | ||
export * as semver from "https://deno.land/std@0.209.0/semver/mod.ts"; | ||
} from "https://deno.land/std@0.223.0/encoding/hex.ts"; | ||
export * as base64 from "https://deno.land/std@0.223.0/encoding/base64.ts"; | ||
export * as semver from "https://deno.land/std@0.223.0/semver/mod.ts"; | ||
|
||
/** | ||
* Zaubrik | ||
|
@@ -29,11 +29,12 @@ export { | |
type Payload, | ||
verify, | ||
type VerifyOptions, | ||
} from "https://deno.land/x/[email protected].1/mod.ts"; | ||
} from "https://deno.land/x/[email protected].2/mod.ts"; | ||
export { | ||
isNumber, | ||
isObject, | ||
isPresent, | ||
isString, | ||
isUndefined, | ||
isUrl, | ||
} from "https://dev.zaubrik.com/[email protected].4/type.js"; | ||
} from "https://dev.zaubrik.com/[email protected].5/type.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
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 |
---|---|---|
|
@@ -7,15 +7,15 @@ export { | |
isAbsolute, | ||
join, | ||
normalize, | ||
} from "https://deno.land/std@0.209.0/path/mod.ts"; | ||
} from "https://deno.land/std@0.223.0/path/mod.ts"; | ||
export { | ||
ensureFile, | ||
ensureFileSync, | ||
} from "https://deno.land/std@0.209.0/fs/mod.ts"; | ||
} from "https://deno.land/std@0.223.0/fs/mod.ts"; | ||
export * from "https://deno.land/[email protected]/http/http_errors.ts"; | ||
export * as semver from "https://deno.land/[email protected]/semver/mod.ts"; | ||
export * from "https://deno.land/[email protected]/http/http_status.ts"; | ||
export { serveFile } from "https://deno.land/[email protected]/http/file_server.ts"; | ||
export { serveFile } from "https://deno.land/[email protected]/http/file_server.ts"; | ||
export * as semver from "https://deno.land/[email protected]/semver/mod.ts"; | ||
|
||
/** | ||
* mixed | ||
|
@@ -27,7 +27,7 @@ export { | |
type Payload, | ||
verify, | ||
type VerifyOptions, | ||
} from "https://deno.land/x/[email protected].1/mod.ts"; | ||
} from "https://deno.land/x/[email protected].2/mod.ts"; | ||
export { | ||
type ClientOptions, | ||
type SendConfig, | ||
|
@@ -43,24 +43,32 @@ export { | |
Context, | ||
createHandler, | ||
type Middleware, | ||
type ServerHandlerOptions, | ||
} from "https://dev.zaubrik.com/[email protected]/mod.ts"; | ||
export { | ||
type AuthInput, | ||
type Methods, | ||
type Options, | ||
respond, | ||
} from "https://dev.zaubrik.com/[email protected]/server/response.ts"; | ||
|
||
export { | ||
mergeUrl, | ||
type UrlProperties, | ||
} from "https://dev.zaubrik.com/[email protected].4/path.js"; | ||
export { copyResponse } from "https://dev.zaubrik.com/[email protected].4/response.js"; | ||
} from "https://dev.zaubrik.com/[email protected].5/url.js"; | ||
export { copyResponse } from "https://dev.zaubrik.com/[email protected].5/response.js"; | ||
export { | ||
isEmpty, | ||
} from "https://dev.zaubrik.com/[email protected].4/collections/length.js"; | ||
} from "https://dev.zaubrik.com/[email protected].5/collections/length.js"; | ||
export { | ||
equals, | ||
isFalse, | ||
} from "https://dev.zaubrik.com/[email protected].4/booleans/equality.js"; | ||
} from "https://dev.zaubrik.com/[email protected].5/booleans/equality.js"; | ||
export { | ||
hasNotProperty, | ||
hasProperty, | ||
hasPropertyOf, | ||
} from "https://dev.zaubrik.com/[email protected].4/objects/membership.js"; | ||
} from "https://dev.zaubrik.com/[email protected].5/objects/membership.js"; | ||
export { | ||
isDefined, | ||
isError, | ||
|
@@ -72,4 +80,4 @@ export { | |
isString, | ||
isUndefined, | ||
isUrl, | ||
} from "https://dev.zaubrik.com/[email protected].4/type.js"; | ||
} from "https://dev.zaubrik.com/[email protected].5/type.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
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,36 @@ | ||
import { | ||
type AuthInput, | ||
type Context, | ||
isFunction, | ||
type Methods, | ||
type Options, | ||
respond, | ||
} from "./deps.ts"; | ||
import { isCryptoKeyOrUpdateInput, verifyJwt } from "../functions/jwt.ts"; | ||
|
||
export function rpcRespond( | ||
methods: Methods, | ||
options: Options & { methodsUrl?: URL } = {}, | ||
authInput?: AuthInput, | ||
) { | ||
const verificationInputOrUndefined = authInput?.verification; | ||
const verify = isFunction(verificationInputOrUndefined) | ||
? verificationInputOrUndefined | ||
: isCryptoKeyOrUpdateInput(verificationInputOrUndefined) | ||
? verifyJwt(verificationInputOrUndefined) | ||
: undefined; | ||
return async <C extends Context>(ctx: C) => { | ||
const rpcMethods = options.methodsUrl | ||
? { ...methods, ...await import(options.methodsUrl.pathname) } | ||
: methods; | ||
const newAuthInput = authInput | ||
? verify ? { ...authInput, verification: verify } : authInput | ||
: undefined; | ||
ctx.response = await respond( | ||
rpcMethods, | ||
options, | ||
newAuthInput, | ||
)(ctx.request); | ||
return ctx; | ||
}; | ||
} |
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