How to use the koa-session/lib/util.hash function in koa-session

To help you get started, we’ve selected a few koa-session examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github DefinitelyTyped / DefinitelyTyped / types / koa-session / koa-session-tests.ts View on Github external
import Koa = require('koa');
import session = require('koa-session');
import * as ContextSession from "koa-session/lib/context";

import {
    encode,
    decode,
    hash,
} from "koa-session/lib/util";

encode({ a: "b" });

decode("123");

hash("abc");

const app = new Koa();

app.use(session({
    valid: (ctx, sess) => {
        const { session: s } = ctx;
        if (s) {
            s.sess = "validated";
            s.save();
            return true;
        }
        return false;
    },
    store: {
        get: async (key) => {
            return "abc";

koa-session

Koa cookie session middleware with external store support

MIT
Latest version published 2 years ago

Package Health Score

62 / 100
Full package analysis