Skip to content

Commit f7898a9

Browse files
committedMar 11, 2025
refactor: always assume structuredClone is present
1 parent e8d366a commit f7898a9

File tree

1 file changed

+2
-10
lines changed

1 file changed

+2
-10
lines changed
 

‎src/jwks/local.ts

+2-10
Original file line numberDiff line numberDiff line change
@@ -47,14 +47,6 @@ function isJWKLike(key: unknown) {
4747
return isObject<types.JWK>(key)
4848
}
4949

50-
function clone<T>(obj: T): T {
51-
if (typeof structuredClone === 'function') {
52-
return structuredClone(obj)
53-
}
54-
55-
return JSON.parse(JSON.stringify(obj))
56-
}
57-
5850
class LocalJWKSet {
5951
#jwks: types.JSONWebKeySet
6052

@@ -65,7 +57,7 @@ class LocalJWKSet {
6557
throw new JWKSInvalid('JSON Web Key Set malformed')
6658
}
6759

68-
this.#jwks = clone<types.JSONWebKeySet>(jwks)
60+
this.#jwks = structuredClone<types.JSONWebKeySet>(jwks)
6961
}
7062

7163
jwks(): types.JSONWebKeySet {
@@ -261,7 +253,7 @@ export function createLocalJWKSet(
261253

262254
Object.defineProperties(localJWKSet, {
263255
jwks: {
264-
value: () => clone(set.jwks()),
256+
value: () => structuredClone(set.jwks()),
265257
enumerable: false,
266258
configurable: false,
267259
writable: false,

0 commit comments

Comments
 (0)
Please sign in to comment.