Skip to content

Commit

Permalink
Fixed import links
Browse files Browse the repository at this point in the history
  • Loading branch information
timonson committed Sep 26, 2019
1 parent 955cee8 commit 7ab84a8
Show file tree
Hide file tree
Showing 5 changed files with 18 additions and 22 deletions.
20 changes: 11 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -54,28 +54,30 @@ setExpiration(new Date().getTime() + 60 * 60 * 1000)

## Example

Try it out with this simple server example:

```javascript
import { serve } from "https://deno.land/std/http/server.ts"
import { encode, decode } from "https://deno.land/std/strings/mod.ts"
import { makeJwt } from "https://denopkg.com/timonson/djwt/create.ts"
import { validateJwt } from "https://denopkg.com/timonson/djwt/validate.ts"
import makeJwt, {
setExpiration,
} from "https://cdn.jsdelivr.net/gh/timonson/djwt@0.2.0/create.ts"
import validateJwt from "https://cdn.jsdelivr.net/gh/timonson/djwt@0.2.0/validate.ts"

const key = "abc"
const claims = {
iss: "joe",
exp: 1300819380,
exp: setExpiration(new Date().getTime() + 60_000),
}
const headerObject = {
alg: "HS512",
typ: "JWT",
}
const key = "abc"
const s = serve("0.0.0.0:8000")

;(async function main() {
for await (const req of s) {
;(async () => {
for await (const req of serve("0.0.0.0:8000")) {
if (req.method === "GET") {
const jwt = makeJwt(headerObject, claims, key)
req.respond({ body: encode(jwt) })
req.respond({ body: encode(jwt + "\n") })
} else {
const requestBody = decode(await req.body())
validateJwt(requestBody, key, false)
Expand Down
6 changes: 2 additions & 4 deletions examples/example.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import makeJwt, {
setExpiration,
} from "https://cdn.jsdelivr.net/gh/timonson/djwt/master@v0.2.0/create.ts"
import validateJwt from "https://cdn.jsdelivr.net/gh/timonson/djwt/master@v0.2.0/validate.ts"
// import makeJwt, { setExpiration } from "../create.ts"
// import validateJwt from "../validate.ts"
} from "https://cdn.jsdelivr.net/gh/timonson/djwt@0.2.0/create.ts"
import validateJwt from "https://cdn.jsdelivr.net/gh/timonson/djwt@0.2.0/validate.ts"

const claims = {
iss: "joe",
Expand Down
6 changes: 2 additions & 4 deletions examples/mini_example.ts
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
import { serve } from "https://deno.land/std/http/server.ts"
import { encode, decode } from "https://deno.land/std/strings/mod.ts"
import makeJwt from "https://cdn.jsdelivr.net/gh/timonson/djwt/master@v0.2.0/create.ts"
import validateJwt from "https://cdn.jsdelivr.net/gh/timonson/djwt/master@v0.2.0/validate.ts"
// import makeJwt from "../create.ts"
// import validateJwt from "../validate.ts"
import makeJwt from "https://cdn.jsdelivr.net/gh/timonson/djwt@0.2.0/create.ts"
import validateJwt from "https://cdn.jsdelivr.net/gh/timonson/djwt@0.2.0/validate.ts"
;(async () => {
for await (const req of serve("0.0.0.0:8000")) {
if (req.method === "GET")
Expand Down
6 changes: 2 additions & 4 deletions examples/readme_example.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,10 +2,8 @@ import { serve } from "https://deno.land/std/http/server.ts"
import { encode, decode } from "https://deno.land/std/strings/mod.ts"
import makeJwt, {
setExpiration,
} from "https://cdn.jsdelivr.net/gh/timonson/djwt/master@v0.2.0/create.ts"
import validateJwt from "https://cdn.jsdelivr.net/gh/timonson/djwt/master@v0.2.0/validate.ts"
// import makeJwt, { setExpiration } from "../create.ts"
// import validateJwt from "../validate.ts"
} from "https://cdn.jsdelivr.net/gh/timonson/djwt@0.2.0/create.ts"
import validateJwt from "https://cdn.jsdelivr.net/gh/timonson/djwt@0.2.0/validate.ts"

const key = "abc"
const claims = {
Expand Down
2 changes: 1 addition & 1 deletion validate.ts
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ import { addPaddingToBase64url } from "https://denopkg.com/timonson/base64url/ba
import makeJwt, {
Claims,
Jose,
} from "https://cdn.jsdelivr.net/gh/timonson/djwt/master@v0.2.0/create.ts"
} from "https://cdn.jsdelivr.net/gh/timonson/djwt@0.2.0/create.ts"

interface CritHandlers {
[key: string]: (header?: any) => any
Expand Down

0 comments on commit 7ab84a8

Please sign in to comment.