rajt 0.0.45 → 0.0.47

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/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "rajt",
3
3
  "description": "A serverless bundler layer, fully typed for AWS Lambda (Node.js and LLRT) and Cloudflare Workers.",
4
- "version": "0.0.45",
4
+ "version": "0.0.47",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "exports": {
package/src/auth/token.ts CHANGED
@@ -16,14 +16,14 @@ export class Token {
16
16
  const header = c.cx.req.header(this.#name) || c.cx.req.header('HTTP_AUTHORIZATION') || c.cx.req.header('REDIRECT_HTTP_AUTHORIZATION') || null
17
17
 
18
18
  if (header) {
19
- const position = header.toLowerCase().indexOf(this.#prefix.toLowerCase())
20
- if (position !== -1) {
21
- let token = header.slice(position + this.#prefix.length).trim()
22
- const commaPos = token.indexOf(',')
23
- if (commaPos !== -1) token = token.slice(0, commaPos).trim()
24
-
25
- return token
26
- }
19
+ const pos = header.toLowerCase().indexOf(this.#prefix.toLowerCase())
20
+ if (pos < 0) return header
21
+
22
+ let token = header.slice(pos + this.#prefix.length).trim()
23
+ const commaPos = token.indexOf(',')
24
+ if (commaPos > -1) token = token.slice(0, commaPos).trim()
25
+
26
+ return token
27
27
  }
28
28
 
29
29
  return null
@@ -265,6 +265,9 @@ export default class AbstractModel<T extends object> {
265
265
  }
266
266
 
267
267
  #getItemWithoutKeys(item: Partial<T>): Partial<T> {
268
+ if (Array.isArray(item))
269
+ return item?.length ? item.map(i => this.#getItemWithoutKeys(i)) as T : [] as T
270
+
268
271
  if (!this.#meta.keys || !item) return { ...item }
269
272
 
270
273
  const { PK, SK } = this.#meta.keys
@@ -296,7 +299,7 @@ export default class AbstractModel<T extends object> {
296
299
 
297
300
  #withKey(model: T, keys: Record<string, string>): T {
298
301
  // @ts-ignore
299
- if (Array.isArray(model)) return model.map(m => this.#withKey(m))
302
+ if (Array.isArray(model)) return model.map(m => this.#withKey(m, keys))
300
303
  // @ts-ignore
301
304
  return model.withKey(keys[this.#meta.keys.PK], keys[this.#meta.keys.SK] || undefined)
302
305
  }