1.0.12 • Published 1 year ago

@antaja/edge-iron v1.0.12

Weekly downloads
-
License
MIT
Repository
github
Last release
1 year ago

@antaja/edge-iron

A fork from @wunderwerk/edge-iron with merge code to reduce dependencies.

Edge-Runtime compatible port of @hapi/iron. Run well on Cloudflare Pages/Workers, Vercel and browser.

License

MIT license

  • Credits to hapi.dev for the initial implementation and
  • Credits to @wunderwerk/edge-iron for porting to Edge-runtime.
  • Credit to Timkieu for fixing bugs by nodejs runtime.

Install

pnpm i @antaja/edge-iron

npm i @antaja/edge-iron

yarn add @antaja/edge-iron

Example

import {Iron} from '@antaja/edge-iron';

// ironPassword must only live on the server-side: Sveltkit/Remix/Nextjs or Backend API
// ironPassword should be changed after a period to reduce leakage.
export async function session2cookie(session: SessionSandbox, ironPassword: string): Promise<string | undefined> {
  const sealed = await Iron.seal(session, ironPassword, Iron.defaults);
  return sealed;
}

export async function cookie2session(cookie: string, ironPassword: string): Promise<SessionSandbox | undefined> {
  const unsealed = await Iron.unseal(cookie, ironPassword, Iron.defaults);
  return unsealed;
}
1.0.12

1 year ago

1.0.11

1 year ago

1.0.10

1 year ago

1.0.9

1 year ago

1.0.7

1 year ago

1.0.5

1 year ago

1.0.4

1 year ago

1.0.2

1 year ago

1.0.0

1 year ago