@@ -3,6 +3,11 @@ import { isError } from '@socketsecurity/lib/errors'
33import { httpRequest } from '@socketsecurity/lib/http-request'
44import { jsonParse } from '@socketsecurity/lib/json/parse'
55import { perfTimer } from '@socketsecurity/lib/performance'
6+ import {
7+ DateNow ,
8+ SetCtor ,
9+ StringPrototypeTrim ,
10+ } from '@socketsecurity/lib/primordials'
611
712import {
813 MAX_RESPONSE_SIZE ,
@@ -44,7 +49,7 @@ export async function createDeleteRequest(
4449 urlPath : string ,
4550 options ?: RequestOptionsWithHooks | undefined ,
4651) : Promise < HttpResponse > {
47- const startTime = Date . now ( )
52+ const startTime = DateNow ( )
4853 const url = `${ baseUrl } ${ urlPath } `
4954 const method = 'DELETE'
5055 const { hooks, ...rawOpts } = {
@@ -74,7 +79,7 @@ export async function createDeleteRequest(
7479 hooks . onResponse ( {
7580 method,
7681 url,
77- duration : Date . now ( ) - startTime ,
82+ duration : DateNow ( ) - startTime ,
7883 status : response . status ,
7984 statusText : response . statusText ,
8085 headers : sanitizeHeaders ( response . headers ) ,
@@ -87,7 +92,7 @@ export async function createDeleteRequest(
8792 hooks . onResponse ( {
8893 method,
8994 url,
90- duration : Date . now ( ) - startTime ,
95+ duration : DateNow ( ) - startTime ,
9196 error : e as Error ,
9297 } )
9398 }
@@ -101,7 +106,7 @@ export async function createGetRequest(
101106 urlPath : string ,
102107 options ?: RequestOptionsWithHooks | undefined ,
103108) : Promise < HttpResponse > {
104- const startTime = Date . now ( )
109+ const startTime = DateNow ( )
105110 const url = `${ baseUrl } ${ urlPath } `
106111 const method = 'GET'
107112 const stopTimer = perfTimer ( 'http:get' , { urlPath } )
@@ -133,7 +138,7 @@ export async function createGetRequest(
133138 hooks . onResponse ( {
134139 method,
135140 url,
136- duration : Date . now ( ) - startTime ,
141+ duration : DateNow ( ) - startTime ,
137142 status : response . status ,
138143 statusText : response . statusText ,
139144 headers : sanitizeHeaders ( response . headers ) ,
@@ -148,7 +153,7 @@ export async function createGetRequest(
148153 hooks . onResponse ( {
149154 method,
150155 url,
151- duration : Date . now ( ) - startTime ,
156+ duration : DateNow ( ) - startTime ,
152157 error : e as Error ,
153158 } )
154159 }
@@ -164,7 +169,7 @@ export async function createRequestWithJson(
164169 json : unknown ,
165170 options ?: RequestOptionsWithHooks | undefined ,
166171) : Promise < HttpResponse > {
167- const startTime = Date . now ( )
172+ const startTime = DateNow ( )
168173 const url = `${ baseUrl } ${ urlPath } `
169174 const stopTimer = perfTimer ( `http:${ method . toLowerCase ( ) } ` , {
170175 urlPath,
@@ -203,7 +208,7 @@ export async function createRequestWithJson(
203208 hooks . onResponse ( {
204209 method,
205210 url,
206- duration : Date . now ( ) - startTime ,
211+ duration : DateNow ( ) - startTime ,
207212 status : response . status ,
208213 statusText : response . statusText ,
209214 headers : sanitizeHeaders ( response . headers ) ,
@@ -218,7 +223,7 @@ export async function createRequestWithJson(
218223 hooks . onResponse ( {
219224 method,
220225 url,
221- duration : Date . now ( ) - startTime ,
226+ duration : DateNow ( ) - startTime ,
222227 error : e as Error ,
223228 } )
224229 }
@@ -335,9 +340,10 @@ export function reshapeArtifactForPublicPolicy<
335340 policy ?: Map < string , string > | undefined ,
336341) : T {
337342 if ( ! isAuthenticated ) {
338- const allowedActions = actions ?. trim ( )
339- ? new Set ( actions . split ( ',' ) )
340- : undefined
343+ const allowedActions =
344+ actions && StringPrototypeTrim ( actions )
345+ ? new SetCtor ( actions . split ( ',' ) )
346+ : undefined
341347 const resolvedPolicy = policy ?? defaultPublicPolicy
342348
343349 const reshapeArtifact = ( artifact : SocketArtifactWithExtras ) => ( {
0 commit comments