@vardario/cognito-client 0.1.8 → 0.2.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +3 -0
- package/lib/cognito-client.d.ts +30 -45
- package/lib/cognito-client.js +106 -149
- package/lib/error.d.ts +93 -31
- package/lib/error.js +96 -46
- package/lib/index.d.ts +0 -1
- package/lib/index.js +0 -1
- package/lib/utils.d.ts +3 -3
- package/lib/utils.js +60 -54
- package/package.json +37 -19
- package/lib/cognito-client.test.d.ts +0 -1
- package/lib/cognito-client.test.js +0 -99
- package/lib/session-storage/cookie-session-storage/cookie-session-storage.d.ts +0 -21
- package/lib/session-storage/cookie-session-storage/cookie-session-storage.js +0 -42
- package/lib/session-storage/cookie-session-storage/index.d.ts +0 -1
- package/lib/session-storage/cookie-session-storage/index.js +0 -1
- package/lib/session-storage/index.d.ts +0 -4
- package/lib/session-storage/index.js +0 -4
- package/lib/session-storage/local-storage-session-storage.d.ts +0 -20
- package/lib/session-storage/local-storage-session-storage.js +0 -38
- package/lib/session-storage/memory-session-storage.d.ts +0 -13
- package/lib/session-storage/memory-session-storage.js +0 -18
- package/lib/session-storage/session-storage.d.ts +0 -14
- package/lib/session-storage/session-storage.js +0 -5
- package/lib/session-storage/session-storage.test.d.ts +0 -1
- package/lib/session-storage/session-storage.test.js +0 -33
- package/lib/test-utils.d.ts +0 -17
- package/lib/test-utils.js +0 -81
|
@@ -1,99 +0,0 @@
|
|
|
1
|
-
import "isomorphic-fetch";
|
|
2
|
-
import { GenericContainer } from "testcontainers";
|
|
3
|
-
import { CognitoClient, CognitoIdentityProvider, } from "./cognito-client.js";
|
|
4
|
-
import { MemorySessionStorage } from "./session-storage/index.js";
|
|
5
|
-
import { newUser, setupCognito, user } from "./test-utils.js";
|
|
6
|
-
import { expect, test, describe, beforeAll, beforeEach, afterAll, } from "vitest";
|
|
7
|
-
describe("Cognito Client", () => {
|
|
8
|
-
let cognitoClient;
|
|
9
|
-
let container;
|
|
10
|
-
let sessionStorage = new MemorySessionStorage();
|
|
11
|
-
const oAuth2 = {
|
|
12
|
-
cognitoDomain: "http://localhost",
|
|
13
|
-
redirectUrl: "http://localhost",
|
|
14
|
-
responseType: "code",
|
|
15
|
-
scopes: ["email openid"],
|
|
16
|
-
};
|
|
17
|
-
let userPoolConfig = {
|
|
18
|
-
userPoolClientId: "",
|
|
19
|
-
userPoolId: "",
|
|
20
|
-
};
|
|
21
|
-
beforeAll(async () => {
|
|
22
|
-
const cognitoPort = 9229;
|
|
23
|
-
container = await new GenericContainer("jagregory/cognito-local")
|
|
24
|
-
.withExposedPorts(cognitoPort)
|
|
25
|
-
.start();
|
|
26
|
-
const cognitoEndpoint = `http://localhost:${container.getMappedPort(cognitoPort)}`;
|
|
27
|
-
userPoolConfig = await setupCognito(cognitoEndpoint);
|
|
28
|
-
cognitoClient = new CognitoClient({
|
|
29
|
-
userPoolId: userPoolConfig.userPoolId,
|
|
30
|
-
userPoolClientId: userPoolConfig.userPoolClientId,
|
|
31
|
-
sessionStorage: sessionStorage,
|
|
32
|
-
endpoint: cognitoEndpoint,
|
|
33
|
-
oAuth2: oAuth2,
|
|
34
|
-
});
|
|
35
|
-
});
|
|
36
|
-
beforeEach(async () => {
|
|
37
|
-
try {
|
|
38
|
-
await cognitoClient.signOut();
|
|
39
|
-
}
|
|
40
|
-
catch (error) { }
|
|
41
|
-
});
|
|
42
|
-
afterAll(async () => {
|
|
43
|
-
await container.stop();
|
|
44
|
-
});
|
|
45
|
-
test("authenticateUser", async () => {
|
|
46
|
-
const session = await cognitoClient.authenticateUser(user.email, user.password);
|
|
47
|
-
expect(session).toEqual(await cognitoClient.getSession());
|
|
48
|
-
//Simulate session expiring
|
|
49
|
-
sessionStorage.setSession({
|
|
50
|
-
...session,
|
|
51
|
-
expiresIn: 0,
|
|
52
|
-
});
|
|
53
|
-
const newSession = await cognitoClient.getSession();
|
|
54
|
-
expect(newSession).not.toEqual(session);
|
|
55
|
-
});
|
|
56
|
-
test("authenticateUserSrp: TODO", async () => {
|
|
57
|
-
// TODO: Currently SRP auth is not supported through cognito-local
|
|
58
|
-
// const session = await cognitoClient.authenticateUserSrp(user.name, user.password);
|
|
59
|
-
// expect(session).toEqual(await cognitoClient.getSession());
|
|
60
|
-
expect(true).toBe(true);
|
|
61
|
-
});
|
|
62
|
-
test("signUp", async () => {
|
|
63
|
-
const { id, confirmed } = await cognitoClient.signUp(newUser.email, newUser.password, [
|
|
64
|
-
{ Name: "givenName", Value: newUser.givenName },
|
|
65
|
-
{ Name: "familyName", Value: newUser.familyName },
|
|
66
|
-
]);
|
|
67
|
-
expect(id).toBeDefined();
|
|
68
|
-
expect(confirmed).toBe(false);
|
|
69
|
-
});
|
|
70
|
-
test("changePassword", async () => {
|
|
71
|
-
const newPassword = "newPassword";
|
|
72
|
-
expect(cognitoClient.changePassword(user.password, newPassword)).rejects.toThrow();
|
|
73
|
-
await cognitoClient.authenticateUser(user.email, user.password);
|
|
74
|
-
await cognitoClient.changePassword(user.password, newPassword);
|
|
75
|
-
await cognitoClient.signOut();
|
|
76
|
-
expect(cognitoClient.authenticateUser(user.email, user.password)).rejects.toThrow();
|
|
77
|
-
await cognitoClient.authenticateUser(user.email, "newPassword");
|
|
78
|
-
});
|
|
79
|
-
test("generateOAuthSignInUrl", async () => {
|
|
80
|
-
const _test = async (cb, identityProvider) => {
|
|
81
|
-
const hostedUIUrl = await cognitoClient.generateOAuthSignInUrl(identityProvider);
|
|
82
|
-
const { searchParams } = new URL(hostedUIUrl);
|
|
83
|
-
expect(searchParams.get("redirect_uri")).toBe(oAuth2.redirectUrl);
|
|
84
|
-
expect(searchParams.get("response_type")).toBe(oAuth2.responseType);
|
|
85
|
-
expect(searchParams.get("client_id")).toBe(userPoolConfig.userPoolClientId);
|
|
86
|
-
expect(searchParams.get("scope")).toBe(oAuth2.scopes.join(" "));
|
|
87
|
-
expect(searchParams.get("state")).toBeDefined();
|
|
88
|
-
expect(searchParams.get("code_challenge")).toBeDefined();
|
|
89
|
-
expect(searchParams.get("code_challenge_method")).toBe("S256");
|
|
90
|
-
cb(searchParams);
|
|
91
|
-
};
|
|
92
|
-
await _test((searchParams) => {
|
|
93
|
-
expect(searchParams.get("identity_provider")).toBeNull();
|
|
94
|
-
});
|
|
95
|
-
await _test((searchParams) => {
|
|
96
|
-
expect(searchParams.get("identity_provider")).toBe(CognitoIdentityProvider.Apple);
|
|
97
|
-
}, CognitoIdentityProvider.Apple);
|
|
98
|
-
});
|
|
99
|
-
});
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
import { CookieProps } from '@vardario/cookies';
|
|
2
|
-
import { Session } from '../../cognito-client.js';
|
|
3
|
-
import { OAuthVerificationParams, SessionStorage } from '../session-storage.js';
|
|
4
|
-
export interface CookieSessionStorageProps extends CookieProps {
|
|
5
|
-
cookieName: string;
|
|
6
|
-
}
|
|
7
|
-
/**
|
|
8
|
-
* Cookies based session storage.
|
|
9
|
-
* This session storage works also across sub domains.
|
|
10
|
-
*/
|
|
11
|
-
export declare class CookieSessionStorage extends SessionStorage {
|
|
12
|
-
private readonly props;
|
|
13
|
-
private readonly oAuthParamCookieName;
|
|
14
|
-
private readonly sessionCookieName;
|
|
15
|
-
private readonly cookies;
|
|
16
|
-
constructor(props: CookieSessionStorageProps);
|
|
17
|
-
getSession(): Session | undefined;
|
|
18
|
-
setSession(session: Session | undefined): void;
|
|
19
|
-
getOauthVerificationParams(): OAuthVerificationParams | undefined;
|
|
20
|
-
setOauthVerificationParams(oAuthParams: OAuthVerificationParams): void;
|
|
21
|
-
}
|
|
@@ -1,42 +0,0 @@
|
|
|
1
|
-
import { Cookies } from '@vardario/cookies';
|
|
2
|
-
import { SessionStorage } from '../session-storage.js';
|
|
3
|
-
/**
|
|
4
|
-
* Cookies based session storage.
|
|
5
|
-
* This session storage works also across sub domains.
|
|
6
|
-
*/
|
|
7
|
-
export class CookieSessionStorage extends SessionStorage {
|
|
8
|
-
constructor(props) {
|
|
9
|
-
super();
|
|
10
|
-
this.props = {
|
|
11
|
-
domain: props.domain,
|
|
12
|
-
path: props.path ?? '/',
|
|
13
|
-
expires: props.expires ?? 365,
|
|
14
|
-
secure: props.secure ?? true,
|
|
15
|
-
sameSite: props.sameSite ?? 'None',
|
|
16
|
-
cookieName: props.cookieName,
|
|
17
|
-
};
|
|
18
|
-
this.cookies = new Cookies(this.props);
|
|
19
|
-
this.sessionCookieName = `${props.cookieName}`;
|
|
20
|
-
this.oAuthParamCookieName = `${props.cookieName}_oauth`;
|
|
21
|
-
}
|
|
22
|
-
getSession() {
|
|
23
|
-
const session = this.cookies.getCookie(this.sessionCookieName);
|
|
24
|
-
if (session === undefined) {
|
|
25
|
-
return undefined;
|
|
26
|
-
}
|
|
27
|
-
return JSON.parse(session);
|
|
28
|
-
}
|
|
29
|
-
setSession(session) {
|
|
30
|
-
this.cookies.setCookie(this.sessionCookieName, JSON.stringify(session));
|
|
31
|
-
}
|
|
32
|
-
getOauthVerificationParams() {
|
|
33
|
-
const oAuthParams = this.cookies.getCookie(this.oAuthParamCookieName);
|
|
34
|
-
if (oAuthParams === undefined) {
|
|
35
|
-
return undefined;
|
|
36
|
-
}
|
|
37
|
-
return JSON.parse(oAuthParams);
|
|
38
|
-
}
|
|
39
|
-
setOauthVerificationParams(oAuthParams) {
|
|
40
|
-
this.cookies.setCookie(this.oAuthParamCookieName, JSON.stringify(oAuthParams));
|
|
41
|
-
}
|
|
42
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './cookie-session-storage.js';
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export * from './cookie-session-storage.js';
|
|
@@ -1,20 +0,0 @@
|
|
|
1
|
-
import { Session } from '../cognito-client.js';
|
|
2
|
-
import { OAuthVerificationParams, SessionStorage } from './session-storage.js';
|
|
3
|
-
export interface LocalStorageSessionStorageProps {
|
|
4
|
-
storageName: string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* LocalStorage based session storage.
|
|
8
|
-
* This session storage works only one domain at a time.
|
|
9
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
|
|
10
|
-
* Use @see CookieSessionStorage for a session storage, which
|
|
11
|
-
* can span across sub domains as well.
|
|
12
|
-
*/
|
|
13
|
-
export declare class LocalStorageSessionStorage extends SessionStorage {
|
|
14
|
-
private readonly props;
|
|
15
|
-
constructor(props: LocalStorageSessionStorageProps);
|
|
16
|
-
getSession(): Session | undefined;
|
|
17
|
-
setSession(session: Session | undefined): void;
|
|
18
|
-
setOauthVerificationParams(oAuthParams: OAuthVerificationParams): void;
|
|
19
|
-
getOauthVerificationParams(): OAuthVerificationParams | undefined;
|
|
20
|
-
}
|
|
@@ -1,38 +0,0 @@
|
|
|
1
|
-
import { SessionStorage } from './session-storage.js';
|
|
2
|
-
/**
|
|
3
|
-
* LocalStorage based session storage.
|
|
4
|
-
* This session storage works only one domain at a time.
|
|
5
|
-
* @see https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage
|
|
6
|
-
* Use @see CookieSessionStorage for a session storage, which
|
|
7
|
-
* can span across sub domains as well.
|
|
8
|
-
*/
|
|
9
|
-
export class LocalStorageSessionStorage extends SessionStorage {
|
|
10
|
-
constructor(props) {
|
|
11
|
-
super();
|
|
12
|
-
this.props = props;
|
|
13
|
-
}
|
|
14
|
-
getSession() {
|
|
15
|
-
const payload = window.localStorage.getItem(this.props.storageName);
|
|
16
|
-
if (payload === null) {
|
|
17
|
-
return undefined;
|
|
18
|
-
}
|
|
19
|
-
return JSON.parse(payload);
|
|
20
|
-
}
|
|
21
|
-
setSession(session) {
|
|
22
|
-
if (session === undefined) {
|
|
23
|
-
window.localStorage.removeItem(this.props.storageName);
|
|
24
|
-
return;
|
|
25
|
-
}
|
|
26
|
-
window.localStorage.setItem(this.props.storageName, JSON.stringify(session));
|
|
27
|
-
}
|
|
28
|
-
setOauthVerificationParams(oAuthParams) {
|
|
29
|
-
window.localStorage.setItem(`${this.props.storageName}_oauth`, JSON.stringify(oAuthParams));
|
|
30
|
-
}
|
|
31
|
-
getOauthVerificationParams() {
|
|
32
|
-
const payload = window.localStorage.getItem(`${this.props.storageName}_oauth`);
|
|
33
|
-
if (payload === null) {
|
|
34
|
-
return undefined;
|
|
35
|
-
}
|
|
36
|
-
return JSON.parse(payload);
|
|
37
|
-
}
|
|
38
|
-
}
|
|
@@ -1,13 +0,0 @@
|
|
|
1
|
-
import { Session } from '../cognito-client.js';
|
|
2
|
-
import { OAuthVerificationParams, SessionStorage } from './session-storage.js';
|
|
3
|
-
/**
|
|
4
|
-
* In-memory based session storage. Useful for testing.
|
|
5
|
-
*/
|
|
6
|
-
export declare class MemorySessionStorage extends SessionStorage {
|
|
7
|
-
private session?;
|
|
8
|
-
private oAuthVerificationParams?;
|
|
9
|
-
getSession(): Session | undefined;
|
|
10
|
-
setSession(session: Session | undefined): void;
|
|
11
|
-
getOauthVerificationParams(): OAuthVerificationParams | undefined;
|
|
12
|
-
setOauthVerificationParams(oAuthParams: OAuthVerificationParams): void;
|
|
13
|
-
}
|
|
@@ -1,18 +0,0 @@
|
|
|
1
|
-
import { SessionStorage } from './session-storage.js';
|
|
2
|
-
/**
|
|
3
|
-
* In-memory based session storage. Useful for testing.
|
|
4
|
-
*/
|
|
5
|
-
export class MemorySessionStorage extends SessionStorage {
|
|
6
|
-
getSession() {
|
|
7
|
-
return this.session;
|
|
8
|
-
}
|
|
9
|
-
setSession(session) {
|
|
10
|
-
this.session = session;
|
|
11
|
-
}
|
|
12
|
-
getOauthVerificationParams() {
|
|
13
|
-
return this.oAuthVerificationParams;
|
|
14
|
-
}
|
|
15
|
-
setOauthVerificationParams(oAuthParams) {
|
|
16
|
-
this.oAuthVerificationParams = oAuthParams;
|
|
17
|
-
}
|
|
18
|
-
}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import { Session } from '../cognito-client.js';
|
|
2
|
-
export interface OAuthVerificationParams {
|
|
3
|
-
pkce: string;
|
|
4
|
-
state: string;
|
|
5
|
-
}
|
|
6
|
-
/**
|
|
7
|
-
* Session storage interface class.
|
|
8
|
-
*/
|
|
9
|
-
export declare abstract class SessionStorage {
|
|
10
|
-
abstract getSession(): Session | undefined;
|
|
11
|
-
abstract setSession(session: Session | undefined): void;
|
|
12
|
-
abstract setOauthVerificationParams(oAuthParams: OAuthVerificationParams): void;
|
|
13
|
-
abstract getOauthVerificationParams(): OAuthVerificationParams | undefined;
|
|
14
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
export {};
|
|
@@ -1,33 +0,0 @@
|
|
|
1
|
-
import { randomBytes } from "crypto";
|
|
2
|
-
import { setupJsDom } from "../test-utils.js";
|
|
3
|
-
import { CookieSessionStorage } from "./cookie-session-storage/index.js";
|
|
4
|
-
import { LocalStorageSessionStorage } from "./local-storage-session-storage.js";
|
|
5
|
-
import { MemorySessionStorage } from "./memory-session-storage.js";
|
|
6
|
-
import { expect, test } from "vitest";
|
|
7
|
-
setupJsDom();
|
|
8
|
-
const sessionStorages = [
|
|
9
|
-
new MemorySessionStorage(),
|
|
10
|
-
new LocalStorageSessionStorage({ storageName: "session" }),
|
|
11
|
-
new CookieSessionStorage({
|
|
12
|
-
domain: "localhost",
|
|
13
|
-
cookieName: "session",
|
|
14
|
-
}),
|
|
15
|
-
];
|
|
16
|
-
const session = {
|
|
17
|
-
accessToken: randomBytes(128).toString("base64"),
|
|
18
|
-
expiresIn: 600,
|
|
19
|
-
idToken: randomBytes(128).toString("base64"),
|
|
20
|
-
refreshToken: randomBytes(128).toString("base64"),
|
|
21
|
-
};
|
|
22
|
-
const oAuthVerificationParams = {
|
|
23
|
-
pkce: randomBytes(128).toString("base64"),
|
|
24
|
-
state: randomBytes(128).toString("base64"),
|
|
25
|
-
};
|
|
26
|
-
test("SessionStorage", () => {
|
|
27
|
-
sessionStorages.forEach((sessionStorage) => {
|
|
28
|
-
sessionStorage.setSession(session);
|
|
29
|
-
expect(sessionStorage.getSession()).toStrictEqual(session);
|
|
30
|
-
sessionStorage.setOauthVerificationParams(oAuthVerificationParams);
|
|
31
|
-
expect(sessionStorage.getOauthVerificationParams()).toStrictEqual(oAuthVerificationParams);
|
|
32
|
-
});
|
|
33
|
-
});
|
package/lib/test-utils.d.ts
DELETED
|
@@ -1,17 +0,0 @@
|
|
|
1
|
-
export declare const user: {
|
|
2
|
-
email: string;
|
|
3
|
-
password: string;
|
|
4
|
-
givenName: string;
|
|
5
|
-
familyName: string;
|
|
6
|
-
};
|
|
7
|
-
export declare const newUser: {
|
|
8
|
-
email: string;
|
|
9
|
-
password: string;
|
|
10
|
-
givenName: string;
|
|
11
|
-
familyName: string;
|
|
12
|
-
};
|
|
13
|
-
export declare function setupCognito(endpoint: string): Promise<{
|
|
14
|
-
userPoolId: string;
|
|
15
|
-
userPoolClientId: string;
|
|
16
|
-
}>;
|
|
17
|
-
export declare function setupJsDom(): void;
|
package/lib/test-utils.js
DELETED
|
@@ -1,81 +0,0 @@
|
|
|
1
|
-
const { AdminCreateUserCommand, AdminSetUserPasswordCommand, AttributeDataType, CognitoIdentityProviderClient, CreateUserPoolClientCommand, CreateUserPoolCommand, } = await import("@aws-sdk/client-cognito-identity-provider");
|
|
2
|
-
import { JSDOM } from "jsdom";
|
|
3
|
-
export const user = {
|
|
4
|
-
email: "sahin@test.com",
|
|
5
|
-
password: "password",
|
|
6
|
-
givenName: "Sahin",
|
|
7
|
-
familyName: "Sahin",
|
|
8
|
-
};
|
|
9
|
-
export const newUser = {
|
|
10
|
-
email: "john@test.com",
|
|
11
|
-
password: "password",
|
|
12
|
-
givenName: "John",
|
|
13
|
-
familyName: "John",
|
|
14
|
-
};
|
|
15
|
-
export async function setupCognito(endpoint) {
|
|
16
|
-
const awsCognitoClient = new CognitoIdentityProviderClient({
|
|
17
|
-
endpoint: endpoint,
|
|
18
|
-
credentials: {
|
|
19
|
-
accessKeyId: "test",
|
|
20
|
-
secretAccessKey: "test",
|
|
21
|
-
},
|
|
22
|
-
region: "eu-central-1",
|
|
23
|
-
});
|
|
24
|
-
const createPoolResult = await awsCognitoClient.send(new CreateUserPoolCommand({
|
|
25
|
-
PoolName: "TestPool",
|
|
26
|
-
Schema: [
|
|
27
|
-
{
|
|
28
|
-
Name: "email",
|
|
29
|
-
AttributeDataType: AttributeDataType.STRING,
|
|
30
|
-
Required: true,
|
|
31
|
-
},
|
|
32
|
-
{
|
|
33
|
-
Name: "givenName",
|
|
34
|
-
AttributeDataType: AttributeDataType.STRING,
|
|
35
|
-
Required: true,
|
|
36
|
-
},
|
|
37
|
-
{
|
|
38
|
-
Name: "familyName",
|
|
39
|
-
AttributeDataType: AttributeDataType.STRING,
|
|
40
|
-
Required: true,
|
|
41
|
-
},
|
|
42
|
-
],
|
|
43
|
-
}));
|
|
44
|
-
const createUserPoolClientResult = await awsCognitoClient.send(new CreateUserPoolClientCommand({
|
|
45
|
-
ClientName: "TestClient",
|
|
46
|
-
UserPoolId: createPoolResult.UserPool?.Id,
|
|
47
|
-
}));
|
|
48
|
-
const createUserResult = await awsCognitoClient.send(new AdminCreateUserCommand({
|
|
49
|
-
UserPoolId: createPoolResult.UserPool?.Id,
|
|
50
|
-
Username: user.email,
|
|
51
|
-
MessageAction: "SUPPRESS",
|
|
52
|
-
UserAttributes: [
|
|
53
|
-
{
|
|
54
|
-
Name: "givenName",
|
|
55
|
-
Value: user.givenName,
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
Name: "familyName",
|
|
59
|
-
Value: user.familyName,
|
|
60
|
-
},
|
|
61
|
-
],
|
|
62
|
-
}));
|
|
63
|
-
const setUserPasswordResult = await awsCognitoClient.send(new AdminSetUserPasswordCommand({
|
|
64
|
-
UserPoolId: createPoolResult.UserPool?.Id,
|
|
65
|
-
Username: user.email,
|
|
66
|
-
Password: user.password,
|
|
67
|
-
Permanent: true,
|
|
68
|
-
}));
|
|
69
|
-
return {
|
|
70
|
-
userPoolId: createPoolResult.UserPool?.Id,
|
|
71
|
-
userPoolClientId: createUserPoolClientResult.UserPoolClient
|
|
72
|
-
?.ClientId,
|
|
73
|
-
};
|
|
74
|
-
}
|
|
75
|
-
export function setupJsDom() {
|
|
76
|
-
const dom = new JSDOM("", {
|
|
77
|
-
url: "http://localhost",
|
|
78
|
-
});
|
|
79
|
-
global.document = dom.window.document;
|
|
80
|
-
global.window = dom.window;
|
|
81
|
-
}
|