kettanaito

kettanaito

Encouraging great developer experience through open source.

Member Since 6 years ago

Experience Points
957
follower
Lessons Completed
22
follow
Lessons Completed
339
stars
Best Reply Awards
50
repos

1860 contributions in the last year

Pinned
⚡ Comprehensive language-agnostic guidelines on variables naming. Home of the A/HC/LC pattern.
⚡ Build declarative, responsive layouts in React using CSS Grid.
⚡ Functional reactive forms. Multi-layer validation, custom styling, field grouping, reactive props, and much more.
⚡ The React Framework
⚡ A window.fetch JavaScript polyfill.
⚡ Visual primitives for the component age. Use the best bits of ES6 and CSS to style your apps without stress 💅
Activity
Jan
24
16 hours ago
pull request

kettanaito pull request mswjs/msw

kettanaito
kettanaito

Revert "0.36.6"

Reverts mswjs/msw#1074

push

kettanaito push mswjs/msw

kettanaito
kettanaito

fix: update node-fetch to 2.6.7 to fix a security vulnerability (#1072)

  • chore: fix a security vulnerability in node-fetch prior to 2.6.7

A security issue was found in node-fetch versions up to 2.6.6 A fix was patched in 2.6.7: https://github.com/node-fetch/node-fetch/issues/1467

More about the vulnerability: https://www.whitesourcesoftware.com/vulnerability-database/CVE-2022-0235

  • chore(security): update yarn.lock file
kettanaito
kettanaito

fix: update "@mswjs/cookies" for safe localStorage access (#1071)

commit sha: 99ae530b75b5f4ca416311ffd7658143e99575d1

push time in 5 hours ago
pull request

kettanaito pull request mswjs/msw

kettanaito
kettanaito

Revert "0.36.6"

Reverts mswjs/msw#1074

Activity icon
created branch

kettanaito in mswjs/msw create branch revert-1074-0-36-6

createdAt 5 hours ago
Activity icon
delete

kettanaito in mswjs/msw delete branch 0-36-6

deleted time in 5 hours ago
push

kettanaito push mswjs/msw

kettanaito
kettanaito

0.36.6 (#1074)

  • fix: update node-fetch to 2.6.7 to fix a security vulnerability (#1072)

  • chore: fix a security vulnerability in node-fetch prior to 2.6.7

A security issue was found in node-fetch versions up to 2.6.6 A fix was patched in 2.6.7: https://github.com/node-fetch/node-fetch/issues/1467

More about the vulnerability: https://www.whitesourcesoftware.com/vulnerability-database/CVE-2022-0235

  • chore(security): update yarn.lock file

  • fix: update "@mswjs/cookies" for safe localStorage access (#1071)

Co-authored-by: Matan Borenkraout [email protected] Co-authored-by: Akmurat Saktagan [email protected]

commit sha: fd4625dc260535929b0b23e2837210c540cd3304

push time in 5 hours ago
Activity icon
issue

kettanaito issue mswjs/msw

kettanaito
kettanaito

Vulnerability found with node-fetch

Describe the bug

A vulnerability has been found with node-fetch which is a dependency in msw. Updating it to 3.1.1 or higher should fix the issue. https://security.snyk.io/vuln/SNYK-JS-NODEFETCH-2342118

Environment

  • msw: 0.36.4
Activity icon
issue

kettanaito issue comment mswjs/msw

kettanaito
kettanaito

chore: update @mswjs/cookies package to fix bug with localStorage

fixes error with localStorage appearing in incognito

https://github.com/mswjs/cookies/pull/10

kettanaito
kettanaito

Welcome to contributors, @sAs59! 🎉

push

kettanaito push mswjs/msw

kettanaito
kettanaito

fix: update node-fetch to 2.6.7 to fix a security vulnerability (#1072)

  • chore: fix a security vulnerability in node-fetch prior to 2.6.7

A security issue was found in node-fetch versions up to 2.6.6 A fix was patched in 2.6.7: https://github.com/node-fetch/node-fetch/issues/1467

More about the vulnerability: https://www.whitesourcesoftware.com/vulnerability-database/CVE-2022-0235

  • chore(security): update yarn.lock file
kettanaito
kettanaito

fix: update "@mswjs/cookies" for safe localStorage access (#1071)

commit sha: 40affd7bd76988bad7d157adb0946253aa24dbfa

push time in 5 hours ago
push

kettanaito push mswjs/msw

kettanaito
kettanaito

fix: update "@mswjs/cookies" for safe localStorage access (#1071)

commit sha: 2aed6ba6343252aff7053685cb5350ffce0da392

push time in 5 hours ago
pull request

kettanaito pull request mswjs/msw

kettanaito
kettanaito

chore: update @mswjs/cookies package to fix bug with localStorage

fixes error with localStorage appearing in incognito

https://github.com/mswjs/cookies/pull/10

Activity icon
issue

kettanaito issue mswjs/interceptors

kettanaito
kettanaito

Error with require

Cannot read properties of undefined (reading 'content-encoding')

const { createInterceptor } = require('@mswjs/interceptors')
const nodeInterceptors = require('@mswjs/interceptors/lib/presets/node').default

const interceptor = createInterceptor({
    modules: nodeInterceptors,
    resolver(request, ref) {
        return {
            status: 200,
            statusText: 'OK',
            headers: {
                'content-type': 'application/json',
                'x-header': 'yes'
            },
            body: JSON.stringify({
                success: true,
            }),
        }
    },
})

interceptor.apply()

image

Activity icon
issue

kettanaito issue comment mswjs/interceptors

kettanaito
kettanaito

Error with require

Cannot read properties of undefined (reading 'content-encoding')

const { createInterceptor } = require('@mswjs/interceptors')
const nodeInterceptors = require('@mswjs/interceptors/lib/presets/node').default

const interceptor = createInterceptor({
    modules: nodeInterceptors,
    resolver(request, ref) {
        return {
            status: 200,
            statusText: 'OK',
            headers: {
                'content-type': 'application/json',
                'x-header': 'yes'
            },
            body: JSON.stringify({
                success: true,
            }),
        }
    },
})

interceptor.apply()

image

kettanaito
kettanaito

I'm closing this due to the lack of the reproduction scenario. If you still experience this, please create one and post it here, I'd be glad to look into it. Thanks.

Activity icon
issue

kettanaito issue comment mswjs/interceptors

kettanaito
kettanaito

ES Modules (node): named import of `request` doesn't get intercepted

Hey,

I'm using node version 16.6.2 along with ES Modules, which means I import node's native https lib like this:

import { request } from 'https';

request('https://example.com/test', (res) => {})

However, requests are not intercepted when request is imported this way. The same behavior can be observed when doing this:

import * as https from 'https';

https.request('https://example.com/test', (res) => {})

Here's a repo to show the complete code.

kettanaito
kettanaito

Thanks for reporting this, @lionralfs. This indeed looks off. It shouldn't matter how the request function is imported, it references the same function.

Are you sure you're not using node:https?

Activity icon
issue

kettanaito issue comment mswjs/mswjs.io

kettanaito
kettanaito

Examples of Permanent override for Playwright

Hi, @kettanaito. The documentation currently has only Cypress example, but we can do the same with Playwright. Below code works fine as far as I've tried.

const url = (path) => `http://localhost:3000${path}`;

test.beforeEach(async ({ page }, testInfo) => {
  await page.goto(url("/login"));
  await page.evaluate(() => {
    const { worker, rest } = window.msw;
    worker.use(
      rest.post(url("/login"), (req, res, ctx) => {
        return res(ctx.json({ success: true }));
      })
    );
  });
});

test("handles user authentication", async ({ page }) => {
  // Describe application interactions for this test.
});

Please consider whether it can be posted as a usage example.

kettanaito
kettanaito

Thanks, @takefumi-yoshii! 🎉 I will give it a look a little later this week. That will be a superb addition to our examples collection.

pull request

kettanaito pull request mswjs/msw

kettanaito
kettanaito

chore(deps): bump node-fetch from 2.6.1 to 3.1.1

Bumps node-fetch from 2.6.1 to 3.1.1.

Release notes

Sourced from node-fetch's releases.

v3.1.1

Security patch release

Recommended to upgrade, to not leak sensitive cookie and authentication header information to 3th party host while a redirect occurred

What's Changed

New Contributors

Full Changelog: https://github.com/node-fetch/node-fetch/compare/v3.1.0...v3.1.1

v3.1.0

What's Changed

... (truncated)

Changelog

Sourced from node-fetch's changelog.

Changelog

All notable changes will be recorded here.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

What's Changed

New Contributors

Full Changelog: https://github.com/node-fetch/node-fetch/compare/v3.1.0...v3.1.2

3.1.0

What's Changed

... (truncated)

Commits
Maintainer changes

This version was pushed to npm by endless, a new releaser for node-fetch since your current version.


Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
  • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
  • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
  • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the Security Alerts page.

Activity icon
issue

kettanaito issue comment mswjs/msw

kettanaito
kettanaito

chore(deps): bump node-fetch from 2.6.1 to 3.1.1

Bumps node-fetch from 2.6.1 to 3.1.1.

Release notes

Sourced from node-fetch's releases.

v3.1.1

Security patch release

Recommended to upgrade, to not leak sensitive cookie and authentication header information to 3th party host while a redirect occurred

What's Changed

New Contributors

Full Changelog: https://github.com/node-fetch/node-fetch/compare/v3.1.0...v3.1.1

v3.1.0

What's Changed

... (truncated)

Changelog

Sourced from node-fetch's changelog.

Changelog

All notable changes will be recorded here.

The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.

What's Changed

New Contributors

Full Changelog: https://github.com/node-fetch/node-fetch/compare/v3.1.0...v3.1.2

3.1.0

What's Changed

... (truncated)

Commits
Maintainer changes

This version was pushed to npm by endless, a new releaser for node-fetch since your current version.


Dependabot compatibility score

Dependabot will resolve any conflicts with this PR as long as you don't alter it yourself. You can also trigger a rebase manually by commenting @dependabot rebase.


Dependabot commands and options

You can trigger Dependabot actions by commenting on this PR:

  • @dependabot rebase will rebase this PR
  • @dependabot recreate will recreate this PR, overwriting any edits that have been made to it
  • @dependabot merge will merge this PR after your CI passes on it
  • @dependabot squash and merge will squash and merge this PR after your CI passes on it
  • @dependabot cancel merge will cancel a previously requested merge and block automerging
  • @dependabot reopen will reopen this PR if it is closed
  • @dependabot close will close this PR and stop Dependabot recreating it. You can achieve the same result by closing it manually
  • @dependabot ignore this major version will close this PR and stop Dependabot creating any more for this major version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this minor version will close this PR and stop Dependabot creating any more for this minor version (unless you reopen the PR or upgrade to it yourself)
  • @dependabot ignore this dependency will close this PR and stop Dependabot creating any more for this dependency (unless you reopen the PR or upgrade to it yourself)
  • @dependabot use these labels will set the current labels as the default for future PRs for this repo and language
  • @dependabot use these reviewers will set the current reviewers as the default for future PRs for this repo and language
  • @dependabot use these assignees will set the current assignees as the default for future PRs for this repo and language
  • @dependabot use this milestone will set the current milestone as the default for future PRs for this repo and language

You can disable automated security fix PRs for this repo from the Security Alerts page.

kettanaito
kettanaito

Closed in favor of #1072 to prevent breaking changes.

push

kettanaito push mswjs/msw

kettanaito
kettanaito

chore: fix a security vulnerability in node-fetch prior to 2.6.7 (#1072)

  • chore: fix a security vulnerability in node-fetch prior to 2.6.7

A security issue was found in node-fetch versions up to 2.6.6 A fix was patched in 2.6.7: https://github.com/node-fetch/node-fetch/issues/1467

More about the vulnerability: https://www.whitesourcesoftware.com/vulnerability-database/CVE-2022-0235

  • chore(security): update yarn.lock file

commit sha: 766cd8f669f51f12f1f2f773890b932519e0a3ee

push time in 5 hours ago
pull request

kettanaito pull request mswjs/msw

kettanaito
kettanaito

chore: fix a security vulnerability in `node-fetch` prior to 2.6.7

A security issue was found in node-fetch versions up to 2.6.6 A fix was patched in 2.6.7: https://github.com/node-fetch/node-fetch/issues/1467

More about the vulnerability: https://www.whitesourcesoftware.com/vulnerability-database/CVE-2022-0235

Activity icon
created branch

kettanaito in mswjs/msw create branch 0-36-6

createdAt 5 hours ago
Activity icon
issue

kettanaito issue comment mswjs/msw

kettanaito
kettanaito

chore: update @mswjs/cookies package to fix bug with localStorage

fixes error with localStorage appearing in incognito

https://github.com/mswjs/cookies/pull/10

kettanaito
kettanaito

Thanks for helping us with this, @sAs59. I've rebased your feature branch and updated your email address associated with the commit so it points to your GitHub user and registers your contribution appropriately.

push

kettanaito push sAs59/msw

kettanaito
kettanaito

fix: update "@mswjs/cookies" for safe localStorage access

commit sha: 9559d927c3e9a0130c8a84a13948b1fa54b0cf94

push time in 5 hours ago
push

kettanaito push sAs59/msw

kettanaito
kettanaito

fix: update "@mswjs/cookies" for safe localStorage access

commit sha: 0c3752cd725425d9fe2c3a9aa294cbae9b9e00b8

push time in 5 hours ago
Activity icon
issue

kettanaito issue comment mswjs/msw-storybook-addon

kettanaito
kettanaito

getWorker() TS issue

[email protected] 
[email protected]

This is odd, the following code generates a TS error even though on the face of it the types look OK:

import { getWorker } from "msw-storybook-addon";

afterAll(() => {
  // ts(2339) error
  getWorker().close();
});

It seems to think close is missing from SetupApi but that doesn't make sense.

I have created a sample repo here:

https://github.com/robcaldecott/msw-storybook-addon-type-errors

Current workarounds are either // @ts-ignore or this:

import { SetupServerApi } from "msw/lib/types/node";

afterAll(() => {
  (getWorker() as SetupServerApi).close();
});

Better ideas are welcome.

kettanaito
kettanaito

Hey, @robcaldecott. Thanks for reaching out.

We need to improve on our type annotations (and also rename getWorker, it made me believe you're referring to the Service Worker, when, in fact, the add-on properly assigns the api to the worker/server depending on the environment).

I wonder if one can do conditional types based on the environment. The least we can do right now is to make getWorker a generic function so that you could use it like this:

getWorker<SetupServerApi>().close()
Jan
23
1 day ago
Activity icon
issue

kettanaito issue comment mswjs/msw

kettanaito
kettanaito

chore: fix a security vulnerability in `node-fetch` prior to 2.6.7

A security issue was found in node-fetch versions up to 2.6.6 A fix was patched in 2.6.7: https://github.com/node-fetch/node-fetch/issues/1467

More about the vulnerability: https://www.whitesourcesoftware.com/vulnerability-database/CVE-2022-0235

kettanaito
kettanaito

No worries! Thanks for addressing this so quickly. The CI build should run without issues now, let's see.

Activity icon
issue

kettanaito issue comment mswjs/msw

kettanaito
kettanaito

chore: fix a security vulnerability in `node-fetch` prior to 2.6.7

A security issue was found in node-fetch versions up to 2.6.6 A fix was patched in 2.6.7: https://github.com/node-fetch/node-fetch/issues/1467

More about the vulnerability: https://www.whitesourcesoftware.com/vulnerability-database/CVE-2022-0235

kettanaito
kettanaito

Hey, @MatanBobi! Thanks for addressing this!

Please, it looks like you forgot to run yarn install, as the lockfile doesn't reflect this change. Could you please do that and add the yarn.lock to the commit? Thanks.

Activity icon
issue

kettanaito issue comment mswjs/msw-storybook-addon

kettanaito
kettanaito

Live demos not working?

Hi,

When accessing https://msw-sb.vercel.app/ none of the demos seem to work. The data displayed in the Mocked Success are the actual data, and no error is shown in the Mocked Error stories.

A screen capture:

image

You can see the API calls being done.

Am I missing something?

Thanks!

kettanaito
kettanaito

The demos are now properly using MSW.

Previous