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

supabase / supabase-js / 10130650437

28 Jul 2024 09:31AM UTC coverage: 66.038% (+1.1%) from 64.948%
10130650437

Pull #1004

github

web-flow
Merge 7b4c23f85 into 51cd9863a
Pull Request #1004: feat: add third-party auth support

41 of 83 branches covered (49.4%)

Branch coverage included in aggregate %.

12 of 15 new or added lines in 2 files covered. (80.0%)

1 existing line in 1 file now uncovered.

99 of 129 relevant lines covered (76.74%)

4.59 hits per line

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

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

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

12
export function stripTrailingSlash(url: string): string {
4✔
13
  return url.replace(/\/$/, '')
10✔
14
}
15

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

18
export function applySettingDefaults<
4✔
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
9✔
33
  const {
34
    db: DEFAULT_DB_OPTIONS,
35
    auth: DEFAULT_AUTH_OPTIONS,
36
    realtime: DEFAULT_REALTIME_OPTIONS,
37
    global: DEFAULT_GLOBAL_OPTIONS,
38
  } = defaults
9✔
39

40
  const result: Required<SupabaseClientOptions<SchemaName>> = {
9✔
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
    },
NEW
57
    accessToken: async () => '',
×
58
  }
59

60
  if (options.accessToken) {
9✔
61
    result.accessToken = options.accessToken
1✔
62
  } else {
63
    // hack around Required<>
64
    delete (result as any).accessToken
8✔
65
  }
66

67
  return result
9✔
68
}
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