Skip to content

Commit ab9d2a7

Browse files
committed
feat: Resolve the circular dependency error
1 parent 7b210a7 commit ab9d2a7

File tree

7 files changed

+23
-24
lines changed

7 files changed

+23
-24
lines changed

examples/websocket/socket_io_holder.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ export async function receiveConnectionInitiatedByVerifier(): Promise<void> {
7777
const socketId = await agent.socketId;
7878

7979
if (socketId) {
80-
const verifierSocketId = "x0rvaCKqZbbcYFWFACcj";
80+
const verifierSocketId = "ggy2HVSRGNS2hYflACc5";
8181
const minimalCompactJson = {
8282
from: did,
8383
body: {

src/crypto/jwe.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import base64url from "base64url";
22

3-
import { jose, joseOriginal } from "../index";
3+
import { jose, joseOriginal } from "../jose-config";
44

55
/**
66
* Encrypts the given plaintext using the provided key and optional ephemeral public key.

src/crypto/jws.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import base64url from "base64url";
22
import { KeyObject } from "crypto";
33

4-
import { jose, joseOriginal } from "../index";
4+
import { jose, joseOriginal } from "../jose-config";
55

66
/**
77
* Signs the provided payload using the given private key and protected header,

src/index.ts

Lines changed: 1 addition & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,6 @@
1-
import * as joseOriginal from "jose";
2-
import { extendJose } from "jose-browser";
3-
41
import * as crypto from "./crypto";
52
import * as messages from "./messages";
63
import * as utils from "./utils";
74
import * as websocket from "./websocket";
85

9-
const isBrowser = typeof window !== "undefined";
10-
const isServer = typeof global !== "undefined";
11-
12-
let jose: any;
13-
14-
if (isBrowser) {
15-
jose = extendJose(joseOriginal);
16-
} else if (isServer) {
17-
jose = joseOriginal;
18-
} else {
19-
throw new Error("Environment is unknown: jose is not initialized.");
20-
}
21-
22-
console.log(`Environment is set: ${isBrowser ? "browser" : "server"}`);
23-
24-
export { crypto, jose, joseOriginal, messages, utils, websocket };
6+
export { crypto, messages, utils, websocket };

src/jose-config.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
import * as joseOriginal from "jose";
2+
import { extendJose } from "jose-browser";
3+
4+
const isBrowser = typeof window !== "undefined";
5+
const isServer = typeof global !== "undefined";
6+
7+
let jose: any;
8+
9+
if (isBrowser) {
10+
jose = extendJose(joseOriginal);
11+
} else if (isServer) {
12+
jose = joseOriginal;
13+
} else {
14+
throw new Error("Environment is unknown: jose is not initialized.");
15+
}
16+
17+
export { jose, joseOriginal };

src/utils/key.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ import { generateKeyPair, sharedKey } from "@stablelib/x25519";
22
import base64url from "base64url";
33
import { CryptoHelper, PrivateJwk_ED, PublicJwk_ED } from "infra-did-js";
44

5-
import { joseOriginal } from "../index";
5+
import { joseOriginal } from "../jose-config";
66
import { escape } from "./coding";
77
import { privateKeyFromMnemonic, publicKeyFromMnemonic } from "./key_convert";
88
/**

src/websocket/message-handler.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ import {
99
extractJWEHeader,
1010
verifyJWS,
1111
} from "../crypto";
12-
import { jose } from "../index";
12+
import { jose } from "../jose-config";
1313
import {
1414
DIDAuthFailedMessage,
1515
DIDAuthInitMessage,

0 commit comments

Comments
 (0)