Socket
Socket
Sign inDemoInstall

@tramvai/module-cookie

Package Overview
Dependencies
Maintainers
3
Versions
636
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

@tramvai/module-cookie

Module for cookie parsing and setting. The module is provided with the `@tramvai/module-common`.


Version published
Weekly downloads
2.3K
increased by37.46%
Maintainers
3
Weekly downloads
 
Created
Source

CookieModule

Module for cookie parsing and setting. The module is provided with the @tramvai/module-common.

Installation

Module is already provided with the @tramvai/module-common so no additional actions are needed if you are already use common module. Otherwise install @tramvai/module-cookie manually.

Explanation

Implements interface CookieManager and adds provider COOKIE_MANAGER_TOKEN from the @tramvai/module-common

Features

  • Isomorphic code that works on server and client
  • Uses deduplication for the same cookie entries on server
  • Uses secure parameter by default

How to

import { Module, provide } from '@tramvai/core';
import { COOKIE_MANAGER_TOKEN } from '@tramvai/module-common';

@Module({
  providers: [
    provide({
      provide: 'my_module',
      useFactory: ({ cookie }) => {
        cookie.get('sid'); // > ads.api3
      },
      deps: {
        cookie: COOKIE_MANAGER_TOKEN,
      },
    }),
  ],
})
class MyModule {}

Exported tokens

Instance of cookie manager

interface CookieSetOptions {
  name: string;
  value: string;
  expires?: number | Date | string;
  domain?: string;
  path?: string;
  secure?: boolean;
  httpOnly?: boolean;
  sameSite?: boolean | 'lax' | 'strict' | 'none';
}

interface CookieManager {
  get(name: any): string;
  all(): Record<string, string>;
  set({ name, value, ...options }: CookieSetOptions): void;
  remove(name: string): void;
}

FAQs

Package last updated on 02 Oct 2024

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc