poad 2.1.1 → 2.5.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 +10 -72
- package/poad.js +52 -0
- package/LICENSE +0 -21
- package/README.md +0 -63
- package/dist/main/OmneediaClient.d.ts +0 -28
- package/dist/main/OmneediaClient.d.ts.map +0 -1
- package/dist/main/OmneediaClient.js +0 -58
- package/dist/main/OmneediaClient.js.map +0 -1
- package/dist/main/env/prefix-dev.d.ts +0 -7
- package/dist/main/env/prefix-dev.d.ts.map +0 -1
- package/dist/main/env/prefix-dev.js +0 -8
- package/dist/main/env/prefix-dev.js.map +0 -1
- package/dist/main/env/prefix-prod.d.ts +0 -7
- package/dist/main/env/prefix-prod.d.ts.map +0 -1
- package/dist/main/env/prefix-prod.js +0 -8
- package/dist/main/env/prefix-prod.js.map +0 -1
- package/dist/main/env/prefix.d.ts +0 -7
- package/dist/main/env/prefix.d.ts.map +0 -1
- package/dist/main/env/prefix.js +0 -8
- package/dist/main/env/prefix.js.map +0 -1
- package/dist/main/index.d.ts +0 -11
- package/dist/main/index.d.ts.map +0 -1
- package/dist/main/index.js +0 -19
- package/dist/main/index.js.map +0 -1
- package/dist/main/lib/auth.d.ts +0 -22
- package/dist/main/lib/auth.d.ts.map +0 -1
- package/dist/main/lib/auth.js +0 -352
- package/dist/main/lib/auth.js.map +0 -1
- package/dist/main/lib/constants.d.ts +0 -8
- package/dist/main/lib/constants.d.ts.map +0 -1
- package/dist/main/lib/constants.js +0 -11
- package/dist/main/lib/constants.js.map +0 -1
- package/dist/main/lib/db.d.ts +0 -45
- package/dist/main/lib/db.d.ts.map +0 -1
- package/dist/main/lib/db.js +0 -252
- package/dist/main/lib/db.js.map +0 -1
- package/dist/main/lib/error-codes.d.ts +0 -7
- package/dist/main/lib/error-codes.d.ts.map +0 -1
- package/dist/main/lib/error-codes.js +0 -3
- package/dist/main/lib/error-codes.js.map +0 -1
- package/dist/main/lib/errors.d.ts +0 -96
- package/dist/main/lib/errors.d.ts.map +0 -1
- package/dist/main/lib/errors.js +0 -127
- package/dist/main/lib/errors.js.map +0 -1
- package/dist/main/lib/realtime.d.ts +0 -9
- package/dist/main/lib/realtime.d.ts.map +0 -1
- package/dist/main/lib/realtime.js +0 -36
- package/dist/main/lib/realtime.js.map +0 -1
- package/dist/main/lib/request.d.ts +0 -40
- package/dist/main/lib/request.d.ts.map +0 -1
- package/dist/main/lib/request.js +0 -237
- package/dist/main/lib/request.js.map +0 -1
- package/dist/main/lib/types.d.ts +0 -408
- package/dist/main/lib/types.d.ts.map +0 -1
- package/dist/main/lib/types.js +0 -11
- package/dist/main/lib/types.js.map +0 -1
- package/dist/main/lib/util.d.ts +0 -7
- package/dist/main/lib/util.d.ts.map +0 -1
- package/dist/main/lib/util.js +0 -90
- package/dist/main/lib/util.js.map +0 -1
- package/dist/main/lib copy/auth.d.ts +0 -22
- package/dist/main/lib copy/auth.d.ts.map +0 -1
- package/dist/main/lib copy/auth.js +0 -283
- package/dist/main/lib copy/auth.js.map +0 -1
- package/dist/main/lib copy/auth_api.d.ts +0 -23
- package/dist/main/lib copy/auth_api.d.ts.map +0 -1
- package/dist/main/lib copy/auth_api.js +0 -90
- package/dist/main/lib copy/auth_api.js.map +0 -1
- package/dist/main/lib copy/constants.d.ts +0 -8
- package/dist/main/lib copy/constants.d.ts.map +0 -1
- package/dist/main/lib copy/constants.js +0 -11
- package/dist/main/lib copy/constants.js.map +0 -1
- package/dist/main/lib copy/cookies.d.ts +0 -20
- package/dist/main/lib copy/cookies.d.ts.map +0 -1
- package/dist/main/lib copy/cookies.js +0 -144
- package/dist/main/lib copy/cookies.js.map +0 -1
- package/dist/main/lib copy/db.d.ts +0 -45
- package/dist/main/lib copy/db.d.ts.map +0 -1
- package/dist/main/lib copy/db.js +0 -252
- package/dist/main/lib copy/db.js.map +0 -1
- package/dist/main/lib copy/realtime.d.ts +0 -9
- package/dist/main/lib copy/realtime.d.ts.map +0 -1
- package/dist/main/lib copy/realtime.js +0 -36
- package/dist/main/lib copy/realtime.js.map +0 -1
- package/dist/main/lib copy/request.d.ts +0 -40
- package/dist/main/lib copy/request.d.ts.map +0 -1
- package/dist/main/lib copy/request.js +0 -206
- package/dist/main/lib copy/request.js.map +0 -1
- package/dist/main/lib copy/types.d.ts +0 -124
- package/dist/main/lib copy/types.d.ts.map +0 -1
- package/dist/main/lib copy/types.js +0 -3
- package/dist/main/lib copy/types.js.map +0 -1
- package/dist/main/lib copy/util.d.ts +0 -7
- package/dist/main/lib copy/util.d.ts.map +0 -1
- package/dist/main/lib copy/util.js +0 -90
- package/dist/main/lib copy/util.js.map +0 -1
- package/dist/module/OmneediaClient.d.ts +0 -28
- package/dist/module/OmneediaClient.d.ts.map +0 -1
- package/dist/module/OmneediaClient.js +0 -52
- package/dist/module/OmneediaClient.js.map +0 -1
- package/dist/module/env/prefix-dev.d.ts +0 -7
- package/dist/module/env/prefix-dev.d.ts.map +0 -1
- package/dist/module/env/prefix-dev.js +0 -6
- package/dist/module/env/prefix-dev.js.map +0 -1
- package/dist/module/env/prefix-prod.d.ts +0 -7
- package/dist/module/env/prefix-prod.d.ts.map +0 -1
- package/dist/module/env/prefix-prod.js +0 -6
- package/dist/module/env/prefix-prod.js.map +0 -1
- package/dist/module/env/prefix.d.ts +0 -7
- package/dist/module/env/prefix.d.ts.map +0 -1
- package/dist/module/env/prefix.js +0 -6
- package/dist/module/env/prefix.js.map +0 -1
- package/dist/module/index.d.ts +0 -11
- package/dist/module/index.d.ts.map +0 -1
- package/dist/module/index.js +0 -12
- package/dist/module/index.js.map +0 -1
- package/dist/module/lib/auth.d.ts +0 -22
- package/dist/module/lib/auth.d.ts.map +0 -1
- package/dist/module/lib/auth.js +0 -349
- package/dist/module/lib/auth.js.map +0 -1
- package/dist/module/lib/constants.d.ts +0 -8
- package/dist/module/lib/constants.d.ts.map +0 -1
- package/dist/module/lib/constants.js +0 -8
- package/dist/module/lib/constants.js.map +0 -1
- package/dist/module/lib/db.d.ts +0 -45
- package/dist/module/lib/db.d.ts.map +0 -1
- package/dist/module/lib/db.js +0 -246
- package/dist/module/lib/db.js.map +0 -1
- package/dist/module/lib/error-codes.d.ts +0 -7
- package/dist/module/lib/error-codes.d.ts.map +0 -1
- package/dist/module/lib/error-codes.js +0 -2
- package/dist/module/lib/error-codes.js.map +0 -1
- package/dist/module/lib/errors.d.ts +0 -96
- package/dist/module/lib/errors.d.ts.map +0 -1
- package/dist/module/lib/errors.js +0 -108
- package/dist/module/lib/errors.js.map +0 -1
- package/dist/module/lib/realtime.d.ts +0 -9
- package/dist/module/lib/realtime.d.ts.map +0 -1
- package/dist/module/lib/realtime.js +0 -33
- package/dist/module/lib/realtime.js.map +0 -1
- package/dist/module/lib/request.d.ts +0 -40
- package/dist/module/lib/request.d.ts.map +0 -1
- package/dist/module/lib/request.js +0 -231
- package/dist/module/lib/request.js.map +0 -1
- package/dist/module/lib/types.d.ts +0 -408
- package/dist/module/lib/types.d.ts.map +0 -1
- package/dist/module/lib/types.js +0 -8
- package/dist/module/lib/types.js.map +0 -1
- package/dist/module/lib/util.d.ts +0 -7
- package/dist/module/lib/util.d.ts.map +0 -1
- package/dist/module/lib/util.js +0 -81
- package/dist/module/lib/util.js.map +0 -1
- package/dist/module/lib copy/auth.d.ts +0 -22
- package/dist/module/lib copy/auth.d.ts.map +0 -1
- package/dist/module/lib copy/auth.js +0 -277
- package/dist/module/lib copy/auth.js.map +0 -1
- package/dist/module/lib copy/auth_api.d.ts +0 -23
- package/dist/module/lib copy/auth_api.d.ts.map +0 -1
- package/dist/module/lib copy/auth_api.js +0 -87
- package/dist/module/lib copy/auth_api.js.map +0 -1
- package/dist/module/lib copy/constants.d.ts +0 -8
- package/dist/module/lib copy/constants.d.ts.map +0 -1
- package/dist/module/lib copy/constants.js +0 -8
- package/dist/module/lib copy/constants.js.map +0 -1
- package/dist/module/lib copy/cookies.d.ts +0 -20
- package/dist/module/lib copy/cookies.d.ts.map +0 -1
- package/dist/module/lib copy/cookies.js +0 -137
- package/dist/module/lib copy/cookies.js.map +0 -1
- package/dist/module/lib copy/db.d.ts +0 -45
- package/dist/module/lib copy/db.d.ts.map +0 -1
- package/dist/module/lib copy/db.js +0 -246
- package/dist/module/lib copy/db.js.map +0 -1
- package/dist/module/lib copy/realtime.d.ts +0 -9
- package/dist/module/lib copy/realtime.d.ts.map +0 -1
- package/dist/module/lib copy/realtime.js +0 -33
- package/dist/module/lib copy/realtime.js.map +0 -1
- package/dist/module/lib copy/request.d.ts +0 -40
- package/dist/module/lib copy/request.d.ts.map +0 -1
- package/dist/module/lib copy/request.js +0 -200
- package/dist/module/lib copy/request.js.map +0 -1
- package/dist/module/lib copy/types.d.ts +0 -124
- package/dist/module/lib copy/types.d.ts.map +0 -1
- package/dist/module/lib copy/types.js +0 -2
- package/dist/module/lib copy/types.js.map +0 -1
- package/dist/module/lib copy/util.d.ts +0 -7
- package/dist/module/lib copy/util.d.ts.map +0 -1
- package/dist/module/lib copy/util.js +0 -81
- package/dist/module/lib copy/util.js.map +0 -1
- package/dist/umd/941.omneedia.js +0 -1
- package/dist/umd/omneedia.js +0 -2
- package/dist/umd/omneedia.js.LICENSE.txt +0 -1
- package/src/OmneediaClient.ts +0 -65
- package/src/env/prefix-dev.ts +0 -5
- package/src/env/prefix-prod.ts +0 -5
- package/src/env/prefix.ts +0 -5
- package/src/index.ts +0 -26
- package/src/lib/auth.ts +0 -306
- package/src/lib/constants.ts +0 -7
- package/src/lib/db.ts +0 -216
- package/src/lib/error-codes.ts +0 -71
- package/src/lib/errors.ts +0 -153
- package/src/lib/realtime.ts +0 -21
- package/src/lib/request.ts +0 -198
- package/src/lib/types.ts +0 -512
- package/src/lib/util.ts +0 -83
package/src/lib/types.ts
DELETED
|
@@ -1,512 +0,0 @@
|
|
|
1
|
-
import { AuthError } from './errors'
|
|
2
|
-
export type Fetch = typeof fetch
|
|
3
|
-
|
|
4
|
-
export interface UserIdentity {
|
|
5
|
-
id: string
|
|
6
|
-
user_id: string
|
|
7
|
-
identity_data?: {
|
|
8
|
-
[key: string]: any
|
|
9
|
-
}
|
|
10
|
-
identity_id: string
|
|
11
|
-
provider: string
|
|
12
|
-
created_at?: string
|
|
13
|
-
last_sign_in_at?: string
|
|
14
|
-
updated_at?: string
|
|
15
|
-
}
|
|
16
|
-
export interface Factor {
|
|
17
|
-
/** ID of the factor. */
|
|
18
|
-
id: string
|
|
19
|
-
|
|
20
|
-
/** Friendly name of the factor, useful to disambiguate between multiple factors. */
|
|
21
|
-
friendly_name?: string
|
|
22
|
-
|
|
23
|
-
/**
|
|
24
|
-
* Type of factor. `totp` and `phone` supported with this version
|
|
25
|
-
*/
|
|
26
|
-
factor_type: 'totp' | 'phone' | string
|
|
27
|
-
|
|
28
|
-
/** Factor's status. */
|
|
29
|
-
status: 'verified' | 'unverified'
|
|
30
|
-
|
|
31
|
-
created_at: string
|
|
32
|
-
updated_at: string
|
|
33
|
-
}
|
|
34
|
-
|
|
35
|
-
export interface UserAppMetadata {
|
|
36
|
-
provider?: string
|
|
37
|
-
[key: string]: any
|
|
38
|
-
}
|
|
39
|
-
|
|
40
|
-
export interface UserMetadata {
|
|
41
|
-
[key: string]: any
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export interface User {
|
|
45
|
-
id: string
|
|
46
|
-
app_metadata: UserAppMetadata
|
|
47
|
-
user_metadata: UserMetadata
|
|
48
|
-
aud: string
|
|
49
|
-
confirmation_sent_at?: string
|
|
50
|
-
recovery_sent_at?: string
|
|
51
|
-
email_change_sent_at?: string
|
|
52
|
-
new_email?: string
|
|
53
|
-
new_phone?: string
|
|
54
|
-
invited_at?: string
|
|
55
|
-
action_link?: string
|
|
56
|
-
email?: string
|
|
57
|
-
phone?: string
|
|
58
|
-
created_at: string
|
|
59
|
-
confirmed_at?: string
|
|
60
|
-
email_confirmed_at?: string
|
|
61
|
-
phone_confirmed_at?: string
|
|
62
|
-
last_sign_in_at?: string
|
|
63
|
-
role?: string
|
|
64
|
-
updated_at?: string
|
|
65
|
-
identities?: UserIdentity[]
|
|
66
|
-
is_anonymous?: boolean
|
|
67
|
-
factors?: Factor[]
|
|
68
|
-
}
|
|
69
|
-
|
|
70
|
-
export interface UserAttributes {
|
|
71
|
-
/**
|
|
72
|
-
* The user's email.
|
|
73
|
-
*/
|
|
74
|
-
email?: string
|
|
75
|
-
|
|
76
|
-
/**
|
|
77
|
-
* The user's phone.
|
|
78
|
-
*/
|
|
79
|
-
phone?: string
|
|
80
|
-
|
|
81
|
-
/**
|
|
82
|
-
* The user's password.
|
|
83
|
-
*/
|
|
84
|
-
password?: string
|
|
85
|
-
|
|
86
|
-
/**
|
|
87
|
-
* The nonce sent for reauthentication if the user's password is to be updated.
|
|
88
|
-
*
|
|
89
|
-
* Call reauthenticate() to obtain the nonce first.
|
|
90
|
-
*/
|
|
91
|
-
nonce?: string
|
|
92
|
-
|
|
93
|
-
/**
|
|
94
|
-
* A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.
|
|
95
|
-
*
|
|
96
|
-
* The `data` should be a JSON object that includes user-specific info, such as their first and last name.
|
|
97
|
-
*
|
|
98
|
-
*/
|
|
99
|
-
data?: object
|
|
100
|
-
}
|
|
101
|
-
|
|
102
|
-
export interface AdminUserAttributes extends Omit<UserAttributes, 'data'> {
|
|
103
|
-
/**
|
|
104
|
-
* A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.
|
|
105
|
-
*
|
|
106
|
-
*
|
|
107
|
-
* The `user_metadata` should be a JSON object that includes user-specific info, such as their first and last name.
|
|
108
|
-
*
|
|
109
|
-
* Note: When using the GoTrueAdminApi and wanting to modify a user's metadata,
|
|
110
|
-
* this attribute is used instead of UserAttributes data.
|
|
111
|
-
*
|
|
112
|
-
*/
|
|
113
|
-
user_metadata?: object
|
|
114
|
-
|
|
115
|
-
/**
|
|
116
|
-
* A custom data object to store the user's application specific metadata. This maps to the `auth.users.app_metadata` column.
|
|
117
|
-
*
|
|
118
|
-
* Only a service role can modify.
|
|
119
|
-
*
|
|
120
|
-
* The `app_metadata` should be a JSON object that includes app-specific info, such as identity providers, roles, and other
|
|
121
|
-
* access control information.
|
|
122
|
-
*/
|
|
123
|
-
app_metadata?: object
|
|
124
|
-
|
|
125
|
-
/**
|
|
126
|
-
* Confirms the user's email address if set to true.
|
|
127
|
-
*
|
|
128
|
-
* Only a service role can modify.
|
|
129
|
-
*/
|
|
130
|
-
email_confirm?: boolean
|
|
131
|
-
|
|
132
|
-
/**
|
|
133
|
-
* Confirms the user's phone number if set to true.
|
|
134
|
-
*
|
|
135
|
-
* Only a service role can modify.
|
|
136
|
-
*/
|
|
137
|
-
phone_confirm?: boolean
|
|
138
|
-
|
|
139
|
-
/**
|
|
140
|
-
* Determines how long a user is banned for.
|
|
141
|
-
*
|
|
142
|
-
* The format for the ban duration follows a strict sequence of decimal numbers with a unit suffix.
|
|
143
|
-
* Valid time units are "ns", "us" (or "µs"), "ms", "s", "m", "h".
|
|
144
|
-
*
|
|
145
|
-
* For example, some possible durations include: '300ms', '2h45m'.
|
|
146
|
-
*
|
|
147
|
-
* Setting the ban duration to 'none' lifts the ban on the user.
|
|
148
|
-
*/
|
|
149
|
-
ban_duration?: string | 'none'
|
|
150
|
-
|
|
151
|
-
/**
|
|
152
|
-
* The `role` claim set in the user's access token JWT.
|
|
153
|
-
*
|
|
154
|
-
* When a user signs up, this role is set to `authenticated` by default. You should only modify the `role` if you need to provision several levels of admin access that have different permissions on individual columns in your database.
|
|
155
|
-
*
|
|
156
|
-
* Setting this role to `service_role` is not recommended as it grants the user admin privileges.
|
|
157
|
-
*/
|
|
158
|
-
role?: string
|
|
159
|
-
|
|
160
|
-
/**
|
|
161
|
-
* The `password_hash` for the user's password.
|
|
162
|
-
*
|
|
163
|
-
* Allows you to specify a password hash for the user. This is useful for migrating a user's password hash from another service.
|
|
164
|
-
*
|
|
165
|
-
* Supports bcrypt and argon2 password hashes.
|
|
166
|
-
*/
|
|
167
|
-
password_hash?: string
|
|
168
|
-
|
|
169
|
-
/**
|
|
170
|
-
* The `id` for the user.
|
|
171
|
-
*
|
|
172
|
-
* Allows you to overwrite the default `id` set for the user.
|
|
173
|
-
*/
|
|
174
|
-
id?: string
|
|
175
|
-
}
|
|
176
|
-
|
|
177
|
-
export interface Subscription {
|
|
178
|
-
/**
|
|
179
|
-
* The subscriber UUID. This will be set by the client.
|
|
180
|
-
*/
|
|
181
|
-
id: string
|
|
182
|
-
/**
|
|
183
|
-
* The function to call every time there is an event. eg: (eventName) => {}
|
|
184
|
-
*/
|
|
185
|
-
callback: (event: AuthChangeEvent, session: Session | null) => void
|
|
186
|
-
/**
|
|
187
|
-
* Call this to remove the listener.
|
|
188
|
-
*/
|
|
189
|
-
unsubscribe: () => void
|
|
190
|
-
}
|
|
191
|
-
|
|
192
|
-
export interface Session {
|
|
193
|
-
/**
|
|
194
|
-
* The oauth provider token. If present, this can be used to make external API requests to the oauth provider used.
|
|
195
|
-
*/
|
|
196
|
-
provider_token?: string | null
|
|
197
|
-
/**
|
|
198
|
-
* The oauth provider refresh token. If present, this can be used to refresh the provider_token via the oauth provider's API.
|
|
199
|
-
* Not all oauth providers return a provider refresh token. If the provider_refresh_token is missing, please refer to the oauth provider's documentation for information on how to obtain the provider refresh token.
|
|
200
|
-
*/
|
|
201
|
-
provider_refresh_token?: string | null
|
|
202
|
-
/**
|
|
203
|
-
* The access token jwt. It is recommended to set the JWT_EXPIRY to a shorter expiry value.
|
|
204
|
-
*/
|
|
205
|
-
access_token: string
|
|
206
|
-
/**
|
|
207
|
-
* A one-time used refresh token that never expires.
|
|
208
|
-
*/
|
|
209
|
-
refresh_token: string
|
|
210
|
-
/**
|
|
211
|
-
* The number of seconds until the token expires (since it was issued). Returned when a login is confirmed.
|
|
212
|
-
*/
|
|
213
|
-
expires_in: number
|
|
214
|
-
/**
|
|
215
|
-
* A timestamp of when the token will expire. Returned when a login is confirmed.
|
|
216
|
-
*/
|
|
217
|
-
expires_at?: number
|
|
218
|
-
token_type: string
|
|
219
|
-
user: User
|
|
220
|
-
}
|
|
221
|
-
|
|
222
|
-
export type SignInAnonymouslyCredentials = {
|
|
223
|
-
options?: {
|
|
224
|
-
/**
|
|
225
|
-
* A custom data object to store the user's metadata. This maps to the `auth.users.raw_user_meta_data` column.
|
|
226
|
-
*
|
|
227
|
-
* The `data` should be a JSON object that includes user-specific info, such as their first and last name.
|
|
228
|
-
*/
|
|
229
|
-
data?: object
|
|
230
|
-
/** Verification token received when the user completes the captcha on the site. */
|
|
231
|
-
captchaToken?: string
|
|
232
|
-
}
|
|
233
|
-
}
|
|
234
|
-
|
|
235
|
-
export type Provider =
|
|
236
|
-
| 'apple'
|
|
237
|
-
| 'azure'
|
|
238
|
-
| 'bitbucket'
|
|
239
|
-
| 'discord'
|
|
240
|
-
| 'facebook'
|
|
241
|
-
| 'figma'
|
|
242
|
-
| 'github'
|
|
243
|
-
| 'gitlab'
|
|
244
|
-
| 'google'
|
|
245
|
-
| 'kakao'
|
|
246
|
-
| 'keycloak'
|
|
247
|
-
| 'linkedin'
|
|
248
|
-
| 'linkedin_oidc'
|
|
249
|
-
| 'notion'
|
|
250
|
-
| 'slack'
|
|
251
|
-
| 'slack_oidc'
|
|
252
|
-
| 'spotify'
|
|
253
|
-
| 'twitch'
|
|
254
|
-
| 'twitter'
|
|
255
|
-
| 'workos'
|
|
256
|
-
| 'zoom'
|
|
257
|
-
| 'fly'
|
|
258
|
-
|
|
259
|
-
export type AuthChangeEventMFA = 'MFA_CHALLENGE_VERIFIED'
|
|
260
|
-
|
|
261
|
-
export type MailPhoneProps = {
|
|
262
|
-
email: string | null
|
|
263
|
-
phone: string | null
|
|
264
|
-
}
|
|
265
|
-
|
|
266
|
-
export const COOKIE_OPTIONS = {
|
|
267
|
-
name: 'omeedia:token',
|
|
268
|
-
lifetime: 60 * 3600 * 8,
|
|
269
|
-
domain: '',
|
|
270
|
-
path: '/',
|
|
271
|
-
sameSite: 'lax',
|
|
272
|
-
}
|
|
273
|
-
|
|
274
|
-
export type EmailResetProps = {
|
|
275
|
-
email: string
|
|
276
|
-
redirectTo: string
|
|
277
|
-
}
|
|
278
|
-
|
|
279
|
-
export type EmailAuthProps = {
|
|
280
|
-
username: string | null
|
|
281
|
-
password: string | null
|
|
282
|
-
}
|
|
283
|
-
|
|
284
|
-
export type OmneediaClientOptions<SchemaName> = {
|
|
285
|
-
/**
|
|
286
|
-
* The Postgres schema which your tables belong to. Must be on the list of exposed schemas in Supabase. Defaults to `public`.
|
|
287
|
-
*/
|
|
288
|
-
db?: {
|
|
289
|
-
schema?: SchemaName
|
|
290
|
-
}
|
|
291
|
-
|
|
292
|
-
auth?: {
|
|
293
|
-
/**
|
|
294
|
-
* Automatically refreshes the token for logged-in users. Defaults to true.
|
|
295
|
-
*/
|
|
296
|
-
autoRefreshToken?: boolean
|
|
297
|
-
/**
|
|
298
|
-
* Optional key name used for storing tokens in local storage.
|
|
299
|
-
*/
|
|
300
|
-
storageKey?: string
|
|
301
|
-
/**
|
|
302
|
-
* Whether to persist a logged-in session to storage. Defaults to true.
|
|
303
|
-
*/
|
|
304
|
-
persistSession?: boolean
|
|
305
|
-
/**
|
|
306
|
-
* Detect a session from the URL. Used for OAuth login callbacks. Defaults to true.
|
|
307
|
-
*/
|
|
308
|
-
detectSessionInUrl?: boolean
|
|
309
|
-
/**
|
|
310
|
-
* A storage provider. Used to store the logged-in session.
|
|
311
|
-
*/
|
|
312
|
-
//storage?: SupabaseAuthClientOptions['storage']
|
|
313
|
-
/**
|
|
314
|
-
* OAuth flow to use - defaults to implicit flow. PKCE is recommended for mobile and server-side applications.
|
|
315
|
-
*/
|
|
316
|
-
//flowType?: SupabaseAuthClientOptions['flowType']
|
|
317
|
-
/**
|
|
318
|
-
* If debug messages for authentication client are emitted. Can be used to inspect the behavior of the library.
|
|
319
|
-
*/
|
|
320
|
-
//debug?: SupabaseAuthClientOptions['debug']
|
|
321
|
-
/**
|
|
322
|
-
* Provide your own locking mechanism based on the environment. By default no locking is done at this time.
|
|
323
|
-
*
|
|
324
|
-
* @experimental
|
|
325
|
-
*/
|
|
326
|
-
//lock?: SupabaseAuthClientOptions['lock']
|
|
327
|
-
}
|
|
328
|
-
/**
|
|
329
|
-
* Options passed to the realtime-js instance
|
|
330
|
-
*/
|
|
331
|
-
//realtime?: RealtimeClientOptions
|
|
332
|
-
global?: {
|
|
333
|
-
/**
|
|
334
|
-
* A custom `fetch` implementation.
|
|
335
|
-
*/
|
|
336
|
-
fetch?: Fetch
|
|
337
|
-
/**
|
|
338
|
-
* Optional headers for initializing the client.
|
|
339
|
-
*/
|
|
340
|
-
headers?: Record<string, string>
|
|
341
|
-
}
|
|
342
|
-
/**
|
|
343
|
-
* Optional function for using a third-party authentication system with
|
|
344
|
-
* Supabase. The function should return an access token or ID token (JWT) by
|
|
345
|
-
* obtaining it from the third-party auth client library. Note that this
|
|
346
|
-
* function may be called concurrently and many times. Use memoization and
|
|
347
|
-
* locking techniques if this is not supported by the client libraries.
|
|
348
|
-
*
|
|
349
|
-
* When set, the `auth` namespace of the Supabase client cannot be used.
|
|
350
|
-
* Create another client if you wish to use Supabase Auth and third-party
|
|
351
|
-
* authentications concurrently in the same application.
|
|
352
|
-
*/
|
|
353
|
-
accessToken?: () => Promise<string>
|
|
354
|
-
}
|
|
355
|
-
|
|
356
|
-
export type ProviderPropsConfig = {
|
|
357
|
-
callback: string
|
|
358
|
-
}
|
|
359
|
-
|
|
360
|
-
export type ProviderProps = {
|
|
361
|
-
provider: string | null
|
|
362
|
-
config: ProviderPropsConfig | null
|
|
363
|
-
}
|
|
364
|
-
|
|
365
|
-
export type AuthChangeEvent =
|
|
366
|
-
| 'INITIAL_SESSION'
|
|
367
|
-
| 'PASSWORD_RECOVERY'
|
|
368
|
-
| 'SIGNED_IN'
|
|
369
|
-
| 'SIGNED_OUT'
|
|
370
|
-
| 'TOKEN_REFRESHED'
|
|
371
|
-
| 'USER_UPDATED'
|
|
372
|
-
| 'USER_DELETED'
|
|
373
|
-
| 'ERROR'
|
|
374
|
-
|
|
375
|
-
export type PasswordCredentials =
|
|
376
|
-
| {
|
|
377
|
-
/** The user's email address. */
|
|
378
|
-
email: string
|
|
379
|
-
/** The user's password. */
|
|
380
|
-
password: string
|
|
381
|
-
options?: {
|
|
382
|
-
/**
|
|
383
|
-
* A custom data object to store the user's metadata. This maps to the `auth.users.user_metadata` column.
|
|
384
|
-
*
|
|
385
|
-
* The `data` should be a JSON object that includes user-specific info, such as their first and last name.
|
|
386
|
-
*/
|
|
387
|
-
data?: object
|
|
388
|
-
/** Verification token received when the user completes the captcha on the site. */
|
|
389
|
-
captchaToken?: string
|
|
390
|
-
redirectTo?: string
|
|
391
|
-
}
|
|
392
|
-
}
|
|
393
|
-
| {
|
|
394
|
-
/** The user's phone number. */
|
|
395
|
-
phone: string
|
|
396
|
-
/** The user's password. */
|
|
397
|
-
password: string
|
|
398
|
-
options?: {
|
|
399
|
-
/**
|
|
400
|
-
* A custom data object to store the user's metadata. This maps to the `auth.users.user_metadata` column.
|
|
401
|
-
*
|
|
402
|
-
* The `data` should be a JSON object that includes user-specific info, such as their first and last name.
|
|
403
|
-
*/
|
|
404
|
-
data?: object
|
|
405
|
-
/** Verification token received when the user completes the captcha on the site. */
|
|
406
|
-
captchaToken?: string
|
|
407
|
-
}
|
|
408
|
-
}
|
|
409
|
-
|
|
410
|
-
export type GenericUpdatableView = GenericTable
|
|
411
|
-
|
|
412
|
-
export type GenericNonUpdatableView = {
|
|
413
|
-
Row: Record<string, unknown>
|
|
414
|
-
}
|
|
415
|
-
|
|
416
|
-
export type GenericView = GenericUpdatableView | GenericNonUpdatableView
|
|
417
|
-
|
|
418
|
-
export type GenericTable = {
|
|
419
|
-
Row: Record<string, unknown>
|
|
420
|
-
Insert: Record<string, unknown>
|
|
421
|
-
Update: Record<string, unknown>
|
|
422
|
-
}
|
|
423
|
-
|
|
424
|
-
export type GenericFunction = {
|
|
425
|
-
Args: Record<string, unknown>
|
|
426
|
-
Returns: unknown
|
|
427
|
-
}
|
|
428
|
-
|
|
429
|
-
export type GenericSchema = {
|
|
430
|
-
Tables: Record<string, GenericTable>
|
|
431
|
-
Views: Record<string, GenericView>
|
|
432
|
-
Functions: Record<string, GenericFunction>
|
|
433
|
-
}
|
|
434
|
-
|
|
435
|
-
export type WeakPasswordReasons = 'length' | 'characters' | 'pwned' | string
|
|
436
|
-
export type WeakPassword = {
|
|
437
|
-
reasons: WeakPasswordReasons[]
|
|
438
|
-
message: string
|
|
439
|
-
}
|
|
440
|
-
|
|
441
|
-
export type AuthResponse =
|
|
442
|
-
| {
|
|
443
|
-
data: {
|
|
444
|
-
user: User | null
|
|
445
|
-
session: Session | null
|
|
446
|
-
}
|
|
447
|
-
error: null
|
|
448
|
-
}
|
|
449
|
-
| {
|
|
450
|
-
data: {
|
|
451
|
-
user: null
|
|
452
|
-
session: null
|
|
453
|
-
}
|
|
454
|
-
error: AuthError
|
|
455
|
-
}
|
|
456
|
-
|
|
457
|
-
export type AuthResponsePassword =
|
|
458
|
-
| {
|
|
459
|
-
data: {
|
|
460
|
-
user: User | null
|
|
461
|
-
session: Session | null
|
|
462
|
-
weak_password?: WeakPassword | null
|
|
463
|
-
}
|
|
464
|
-
error: null
|
|
465
|
-
}
|
|
466
|
-
| {
|
|
467
|
-
data: {
|
|
468
|
-
user: null
|
|
469
|
-
session: null
|
|
470
|
-
}
|
|
471
|
-
error: AuthError
|
|
472
|
-
}
|
|
473
|
-
|
|
474
|
-
export type InitializeResult = { error: AuthError | null }
|
|
475
|
-
|
|
476
|
-
export type CallRefreshTokenResult =
|
|
477
|
-
| {
|
|
478
|
-
session: Session
|
|
479
|
-
error: null
|
|
480
|
-
}
|
|
481
|
-
| {
|
|
482
|
-
session: null
|
|
483
|
-
error: AuthError
|
|
484
|
-
}
|
|
485
|
-
|
|
486
|
-
export type Pagination = {
|
|
487
|
-
[key: string]: any
|
|
488
|
-
nextPage: number | null
|
|
489
|
-
lastPage: number
|
|
490
|
-
total: number
|
|
491
|
-
}
|
|
492
|
-
|
|
493
|
-
export type PageParams = {
|
|
494
|
-
/** The page number */
|
|
495
|
-
page?: number
|
|
496
|
-
/** Number of items returned per page */
|
|
497
|
-
perPage?: number
|
|
498
|
-
}
|
|
499
|
-
|
|
500
|
-
export type SignOut = {
|
|
501
|
-
/**
|
|
502
|
-
* Determines which sessions should be
|
|
503
|
-
* logged out. Global means all
|
|
504
|
-
* sessions by this account. Local
|
|
505
|
-
* means only this session. Others
|
|
506
|
-
* means all other sessions except the
|
|
507
|
-
* current one. When using others,
|
|
508
|
-
* there is no sign-out event fired on
|
|
509
|
-
* the current session!
|
|
510
|
-
*/
|
|
511
|
-
scope?: 'global' | 'local' | 'others'
|
|
512
|
-
}
|
package/src/lib/util.ts
DELETED
|
@@ -1,83 +0,0 @@
|
|
|
1
|
-
export function uuid() {
|
|
2
|
-
return 'xxxxxxxx-xxxx-4xxx-yxxx-xxxxxxxxxxxx'.replace(/[xy]/g, function (c) {
|
|
3
|
-
const r = (Math.random() * 16) | 0,
|
|
4
|
-
v = c == 'x' ? r : (r & 0x3) | 0x8
|
|
5
|
-
return v.toString(16)
|
|
6
|
-
})
|
|
7
|
-
}
|
|
8
|
-
|
|
9
|
-
export const isBrowser = () => typeof document !== 'undefined'
|
|
10
|
-
|
|
11
|
-
export function getHashParams() {
|
|
12
|
-
let p = location.href.substring(location.href.indexOf('#') + 1, location.href.length)
|
|
13
|
-
let params = p.split('&')
|
|
14
|
-
let response: any = {}
|
|
15
|
-
for (let el in params) {
|
|
16
|
-
response[params[el].split('=')[0]] = params[el].split('=')[1]
|
|
17
|
-
}
|
|
18
|
-
return response
|
|
19
|
-
}
|
|
20
|
-
|
|
21
|
-
export function parseJwt(token: string) {
|
|
22
|
-
if (isBrowser()) {
|
|
23
|
-
var base64Url = token.split('.')[1]
|
|
24
|
-
var base64 = base64Url.replace(/-/g, '+').replace(/_/g, '/')
|
|
25
|
-
var jsonPayload = decodeURIComponent(
|
|
26
|
-
window
|
|
27
|
-
.atob(base64)
|
|
28
|
-
.split('')
|
|
29
|
-
.map(function (c) {
|
|
30
|
-
return '%' + ('00' + c.charCodeAt(0).toString(16)).slice(-2)
|
|
31
|
-
})
|
|
32
|
-
.join('')
|
|
33
|
-
)
|
|
34
|
-
const now = Math.floor(Date.now() / 1000)
|
|
35
|
-
const exp = JSON.parse(jsonPayload).exp
|
|
36
|
-
if (exp < now) {
|
|
37
|
-
localStorage.removeItem('omneedia.auth.token')
|
|
38
|
-
localStorage.removeItem('omneedia.auth.refresh_token')
|
|
39
|
-
return false
|
|
40
|
-
} else return JSON.parse(jsonPayload)
|
|
41
|
-
} else return JSON.parse(Buffer.from(token.split('.')[1], 'base64').toString())
|
|
42
|
-
}
|
|
43
|
-
|
|
44
|
-
export function urlBase64Decode(str: string) {
|
|
45
|
-
// From https://jwt.io/js/jwt.js
|
|
46
|
-
|
|
47
|
-
let output = str.replace(/-/g, '+').replace(/_/g, '/')
|
|
48
|
-
switch (output.length % 4) {
|
|
49
|
-
case 0:
|
|
50
|
-
break
|
|
51
|
-
case 2:
|
|
52
|
-
output += '=='
|
|
53
|
-
break
|
|
54
|
-
case 3:
|
|
55
|
-
output += '='
|
|
56
|
-
break
|
|
57
|
-
default:
|
|
58
|
-
}
|
|
59
|
-
|
|
60
|
-
// polifyll https://github.com/davidchambers/Base64.js
|
|
61
|
-
if (isBrowser()) {
|
|
62
|
-
const result = window.atob(output)
|
|
63
|
-
try {
|
|
64
|
-
return JSON.parse(decodeURIComponent(escape(result)))
|
|
65
|
-
} catch {
|
|
66
|
-
return result
|
|
67
|
-
}
|
|
68
|
-
} else {
|
|
69
|
-
return JSON.parse(Buffer.from(output.split('.')[1], 'base64').toString())
|
|
70
|
-
}
|
|
71
|
-
}
|
|
72
|
-
|
|
73
|
-
export function getHash() {
|
|
74
|
-
if (location.hash == '') return {}
|
|
75
|
-
let newHash: string[] = location.hash.split('&')
|
|
76
|
-
let items: any
|
|
77
|
-
for (let i = 0; i < newHash.length; i++) {
|
|
78
|
-
var key = newHash[i].split('=')[0]
|
|
79
|
-
var value = newHash[i].split('=')[1]
|
|
80
|
-
items[key] = value
|
|
81
|
-
}
|
|
82
|
-
return items
|
|
83
|
-
}
|