@d-mok/quasar-app-extension-quasar-axe 2.1.1 → 2.1.2
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,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@d-mok/quasar-app-extension-quasar-axe",
|
|
3
|
-
"version": "2.1.
|
|
3
|
+
"version": "2.1.2",
|
|
4
4
|
"description": "A Quasar App Extension",
|
|
5
5
|
"author": "d-mok <49301824+d-mok@users.noreply.github.com>",
|
|
6
6
|
"license": "MIT",
|
|
@@ -15,7 +15,7 @@
|
|
|
15
15
|
},
|
|
16
16
|
"dependencies": {
|
|
17
17
|
"@handsontable/vue3": "^12.1.0",
|
|
18
|
-
"@supabase/supabase-js": "^
|
|
18
|
+
"@supabase/supabase-js": "^2.24.0",
|
|
19
19
|
"@types/lodash": "^4.14.182",
|
|
20
20
|
"@types/papaparse": "^5.3.2",
|
|
21
21
|
"@types/webpack-env": "^1.17.0",
|
|
@@ -2,6 +2,8 @@ import {
|
|
|
2
2
|
createClient,
|
|
3
3
|
PostgrestError,
|
|
4
4
|
SupabaseClient,
|
|
5
|
+
Session,
|
|
6
|
+
SupabaseClientOptions,
|
|
5
7
|
} from '@supabase/supabase-js'
|
|
6
8
|
import { qDialog } from './dialog'
|
|
7
9
|
|
|
@@ -10,78 +12,69 @@ export type {
|
|
|
10
12
|
PostgrestSingleResponse,
|
|
11
13
|
} from '@supabase/postgrest-js'
|
|
12
14
|
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
|
|
16
|
-
accessTokenLife: () => number
|
|
17
|
-
waitForSignin: () => Promise<void>
|
|
18
|
-
email: () => string
|
|
19
|
-
call: <T>(fn: string, params?: object | undefined) => Promise<T[]>
|
|
20
|
-
callSingle: <T>(fn: string, params?: object | undefined) => Promise<T>
|
|
21
|
-
}
|
|
22
|
-
}
|
|
15
|
+
class MySupabaseClient extends SupabaseClient {
|
|
16
|
+
email: string = 'unauthenticated'
|
|
17
|
+
session: Session | null = null
|
|
23
18
|
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
19
|
+
constructor(
|
|
20
|
+
supabaseUrl: string,
|
|
21
|
+
supabaseKey: string,
|
|
22
|
+
options?: SupabaseClientOptions<any>
|
|
23
|
+
) {
|
|
24
|
+
super(supabaseUrl, supabaseKey, options)
|
|
25
|
+
this.auth.onAuthStateChange((event, session) => {
|
|
26
|
+
console.log('[SUPABASE AUTH]', event, session?.user?.email)
|
|
27
|
+
this.session = session
|
|
28
|
+
this.email = session?.user?.email ?? 'unauthenticated'
|
|
29
|
+
})
|
|
30
|
+
}
|
|
32
31
|
|
|
33
|
-
|
|
34
|
-
await
|
|
35
|
-
await
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
32
|
+
async signIn() {
|
|
33
|
+
await this.auth.signOut()
|
|
34
|
+
await this.auth.signInWithOAuth({
|
|
35
|
+
provider: 'google',
|
|
36
|
+
options: {
|
|
37
|
+
redirectTo: window.location.href,
|
|
38
|
+
},
|
|
39
|
+
})
|
|
39
40
|
}
|
|
40
41
|
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
const ms = expireAt.getTime() - new Date().getTime() // ms
|
|
46
|
-
return Math.round(ms / 1000)
|
|
42
|
+
async call<T>(fn: string, params?: object | undefined): Promise<T[]> {
|
|
43
|
+
let { data, error } = await this.rpc<string, any>(fn, params)
|
|
44
|
+
HANDLE_ERROR(data, error)
|
|
45
|
+
return data
|
|
47
46
|
}
|
|
48
47
|
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
48
|
+
async callSingle<T>(fn: string, params?: object | undefined): Promise<T> {
|
|
49
|
+
let { data, error } = await this.rpc<string, any>(fn, params).single()
|
|
50
|
+
HANDLE_ERROR(data, error)
|
|
51
|
+
return data as T
|
|
52
|
+
}
|
|
52
53
|
|
|
53
|
-
|
|
54
|
+
async waitForSignin(): Promise<void> {
|
|
54
55
|
setInterval(() => {
|
|
55
|
-
if (
|
|
56
|
+
if (this.session === null) this.signIn()
|
|
56
57
|
}, 1000)
|
|
57
|
-
|
|
58
|
-
() =>
|
|
58
|
+
waitFor(
|
|
59
|
+
() => this.session !== null,
|
|
59
60
|
'[Wait for SignIn] waiting...',
|
|
60
61
|
'[Wait for SignIn] DONE!'
|
|
61
62
|
)
|
|
62
63
|
}
|
|
64
|
+
}
|
|
63
65
|
|
|
64
|
-
|
|
65
|
-
|
|
66
|
-
|
|
67
|
-
): Promise<T[]> {
|
|
68
|
-
let { data, error } = await supabase.rpc<T>(fn, params)
|
|
69
|
-
HANDLE_ERROR(data, error)
|
|
70
|
-
return data
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
supabase.callSingle = async function <T>(
|
|
74
|
-
fn: string,
|
|
75
|
-
params?: object | undefined
|
|
76
|
-
): Promise<T> {
|
|
77
|
-
let { data, error } = await supabase.rpc<T>(fn, params).single()
|
|
78
|
-
HANDLE_ERROR(data, error)
|
|
79
|
-
return data
|
|
80
|
-
}
|
|
66
|
+
export let supabase: MySupabaseClient
|
|
67
|
+
let SUPABASE_URL = process.env.SUPABASE_URL
|
|
68
|
+
let SUPABASE_KEY = process.env.SUPABASE_KEY
|
|
81
69
|
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
70
|
+
if (SUPABASE_URL && SUPABASE_KEY) {
|
|
71
|
+
supabase = new MySupabaseClient(SUPABASE_URL, SUPABASE_KEY, {
|
|
72
|
+
auth: {
|
|
73
|
+
autoRefreshToken: true,
|
|
74
|
+
persistSession: true,
|
|
75
|
+
detectSessionInUrl: true,
|
|
76
|
+
},
|
|
77
|
+
})
|
|
85
78
|
}
|
|
86
79
|
|
|
87
80
|
export function HANDLE_ERROR<T>(
|
|
@@ -116,13 +109,13 @@ async function waitFor(
|
|
|
116
109
|
doneMsg: string
|
|
117
110
|
) {
|
|
118
111
|
return new Promise(resolve => {
|
|
119
|
-
function checker() {
|
|
112
|
+
async function checker() {
|
|
120
113
|
if (predicate()) {
|
|
121
114
|
console.log(doneMsg)
|
|
122
115
|
resolve(true)
|
|
123
116
|
} else {
|
|
124
117
|
console.log(waitingMsg)
|
|
125
|
-
setTimeout(
|
|
118
|
+
setTimeout(checker, 50)
|
|
126
119
|
}
|
|
127
120
|
}
|
|
128
121
|
checker()
|