• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

supabase / supabase-js / 16261028777

14 Jul 2025 07:44AM UTC coverage: 72.889%. Remained the same
16261028777

Pull #1497

github

web-flow
Merge 7b175c40d into d78ce0eab
Pull Request #1497: feat: bump auth-js to 2.71.0

55 of 93 branches covered (59.14%)

Branch coverage included in aggregate %.

109 of 132 relevant lines covered (82.58%)

26.43 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

92.31
/src/lib/helpers.ts
1
// helpers.ts
2
import { SupabaseClientOptions } from './types'
3

4
export function uuid() {
12✔
5
  return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
3✔
6
    var r = (Math.random() * 16) | 0,
93✔
7
      v = c == 'x' ? r : (r & 0x3) | 0x8
93✔
8
    return v.toString(16)
93✔
9
  })
10
}
11

12
export function ensureTrailingSlash(url: string): string {
12✔
13
  return url.endsWith('/') ? url : url + '/'
69✔
14
}
15

16
export const isBrowser = () => typeof window !== 'undefined'
12✔
17

18
export function applySettingDefaults<
12✔
19
  Database = any,
20
  SchemaName extends string & keyof Database = 'public' extends keyof Database
21
    ? 'public'
22
    : string & keyof Database
23
>(
24
  options: SupabaseClientOptions<SchemaName>,
25
  defaults: SupabaseClientOptions<any>
26
): Required<SupabaseClientOptions<SchemaName>> {
27
  const {
28
    db: dbOptions,
29
    auth: authOptions,
30
    realtime: realtimeOptions,
31
    global: globalOptions,
32
  } = options
60✔
33
  const {
34
    db: DEFAULT_DB_OPTIONS,
35
    auth: DEFAULT_AUTH_OPTIONS,
36
    realtime: DEFAULT_REALTIME_OPTIONS,
37
    global: DEFAULT_GLOBAL_OPTIONS,
38
  } = defaults
60✔
39

40
  const result: Required<SupabaseClientOptions<SchemaName>> = {
60✔
41
    db: {
42
      ...DEFAULT_DB_OPTIONS,
43
      ...dbOptions,
44
    },
45
    auth: {
46
      ...DEFAULT_AUTH_OPTIONS,
47
      ...authOptions,
48
    },
49
    realtime: {
50
      ...DEFAULT_REALTIME_OPTIONS,
51
      ...realtimeOptions,
52
    },
53
    global: {
54
      ...DEFAULT_GLOBAL_OPTIONS,
55
      ...globalOptions,
56
      headers: {
57
        ...(DEFAULT_GLOBAL_OPTIONS?.headers ?? {}),
360!
58
        ...(globalOptions?.headers ?? {}),
360✔
59
      },
60
    },
61
    accessToken: async () => '',
×
62
  }
63

64
  if (options.accessToken) {
60✔
65
    result.accessToken = options.accessToken
3✔
66
  } else {
67
    // hack around Required<>
68
    delete (result as any).accessToken
57✔
69
  }
70

71
  return result
60✔
72
}
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc