@supabase/auth-js 2.116.0 → 2.117.0-canary.1
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/dist/main/GoTrueAdminApi.d.ts +0 -6
- package/dist/main/GoTrueAdminApi.d.ts.map +1 -1
- package/dist/main/GoTrueAdminApi.js +0 -6
- package/dist/main/GoTrueAdminApi.js.map +1 -1
- package/dist/main/GoTrueClient.d.ts +25 -4
- package/dist/main/GoTrueClient.d.ts.map +1 -1
- package/dist/main/GoTrueClient.js +27 -12
- package/dist/main/GoTrueClient.js.map +1 -1
- package/dist/main/lib/error-codes.d.ts +1 -1
- package/dist/main/lib/error-codes.d.ts.map +1 -1
- package/dist/main/lib/helpers.d.ts +0 -3
- package/dist/main/lib/helpers.d.ts.map +1 -1
- package/dist/main/lib/helpers.js +0 -6
- package/dist/main/lib/helpers.js.map +1 -1
- package/dist/main/lib/types.d.ts +35 -6
- package/dist/main/lib/types.d.ts.map +1 -1
- package/dist/main/lib/types.js.map +1 -1
- package/dist/main/lib/version.d.ts +1 -1
- package/dist/main/lib/version.d.ts.map +1 -1
- package/dist/main/lib/version.js +1 -1
- package/dist/main/lib/version.js.map +1 -1
- package/dist/module/GoTrueAdminApi.d.ts +0 -6
- package/dist/module/GoTrueAdminApi.d.ts.map +1 -1
- package/dist/module/GoTrueAdminApi.js +1 -7
- package/dist/module/GoTrueAdminApi.js.map +1 -1
- package/dist/module/GoTrueClient.d.ts +25 -4
- package/dist/module/GoTrueClient.d.ts.map +1 -1
- package/dist/module/GoTrueClient.js +28 -13
- package/dist/module/GoTrueClient.js.map +1 -1
- package/dist/module/lib/error-codes.d.ts +1 -1
- package/dist/module/lib/error-codes.d.ts.map +1 -1
- package/dist/module/lib/helpers.d.ts +0 -3
- package/dist/module/lib/helpers.d.ts.map +1 -1
- package/dist/module/lib/helpers.js +0 -5
- package/dist/module/lib/helpers.js.map +1 -1
- package/dist/module/lib/types.d.ts +35 -6
- package/dist/module/lib/types.d.ts.map +1 -1
- package/dist/module/lib/types.js.map +1 -1
- package/dist/module/lib/version.d.ts +1 -1
- package/dist/module/lib/version.d.ts.map +1 -1
- package/dist/module/lib/version.js +1 -1
- package/dist/module/lib/version.js.map +1 -1
- package/dist/tsconfig.module.tsbuildinfo +1 -1
- package/dist/tsconfig.tsbuildinfo +1 -1
- package/package.json +1 -1
- package/src/GoTrueAdminApi.ts +1 -9
- package/src/GoTrueClient.ts +26 -14
- package/src/lib/error-codes.ts +1 -0
- package/src/lib/helpers.ts +0 -8
- package/src/lib/types.ts +35 -6
- package/src/lib/version.ts +1 -1
package/package.json
CHANGED
package/src/GoTrueAdminApi.ts
CHANGED
|
@@ -5,7 +5,7 @@ import {
|
|
|
5
5
|
_request,
|
|
6
6
|
_userResponse,
|
|
7
7
|
} from './lib/fetch'
|
|
8
|
-
import {
|
|
8
|
+
import { resolveFetch, validateUUID } from './lib/helpers'
|
|
9
9
|
import {
|
|
10
10
|
AdminUserAttributes,
|
|
11
11
|
GenerateLinkParams,
|
|
@@ -56,8 +56,6 @@ export default class GoTrueAdminApi {
|
|
|
56
56
|
|
|
57
57
|
/**
|
|
58
58
|
* Contains all passkey administration methods.
|
|
59
|
-
*
|
|
60
|
-
* Requires `auth.experimental.passkey: true`; otherwise all methods throw.
|
|
61
59
|
*/
|
|
62
60
|
passkey: GoTrueAdminPasskeyApi
|
|
63
61
|
|
|
@@ -1208,13 +1206,10 @@ export default class GoTrueAdminApi {
|
|
|
1208
1206
|
* Lists all passkeys for a user.
|
|
1209
1207
|
*
|
|
1210
1208
|
* This function should only be called on a server. Never expose your secret key in the browser.
|
|
1211
|
-
*
|
|
1212
|
-
* Requires `auth.experimental.passkey: true`.
|
|
1213
1209
|
*/
|
|
1214
1210
|
private async _adminListPasskeys(
|
|
1215
1211
|
params: AuthPasskeyAdminListParams
|
|
1216
1212
|
): Promise<AuthPasskeyListResponse> {
|
|
1217
|
-
assertPasskeyExperimentalEnabled(this.experimental)
|
|
1218
1213
|
validateUUID(params.userId)
|
|
1219
1214
|
|
|
1220
1215
|
try {
|
|
@@ -1236,13 +1231,10 @@ export default class GoTrueAdminApi {
|
|
|
1236
1231
|
* Deletes a user's passkey.
|
|
1237
1232
|
*
|
|
1238
1233
|
* This function should only be called on a server. Never expose your secret key in the browser.
|
|
1239
|
-
*
|
|
1240
|
-
* Requires `auth.experimental.passkey: true`.
|
|
1241
1234
|
*/
|
|
1242
1235
|
private async _adminDeletePasskey(
|
|
1243
1236
|
params: AuthPasskeyAdminDeleteParams
|
|
1244
1237
|
): Promise<AuthPasskeyDeleteResponse> {
|
|
1245
|
-
assertPasskeyExperimentalEnabled(this.experimental)
|
|
1246
1238
|
validateUUID(params.userId)
|
|
1247
1239
|
validateUUID(params.passkeyId)
|
|
1248
1240
|
|
package/src/GoTrueClient.ts
CHANGED
|
@@ -38,7 +38,6 @@ import {
|
|
|
38
38
|
} from './lib/fetch'
|
|
39
39
|
import {
|
|
40
40
|
appendFlowIdToRedirectTo,
|
|
41
|
-
assertPasskeyExperimentalEnabled,
|
|
42
41
|
assertRecoveryCodesExperimentalEnabled,
|
|
43
42
|
decodeJWT,
|
|
44
43
|
deepClone,
|
|
@@ -263,8 +262,6 @@ export default class GoTrueClient {
|
|
|
263
262
|
/**
|
|
264
263
|
* Namespace for passkey methods.
|
|
265
264
|
* Includes lower-level two-step registration/authentication and passkey management.
|
|
266
|
-
*
|
|
267
|
-
* Requires `auth.experimental.passkey: true`; otherwise all methods throw.
|
|
268
265
|
*/
|
|
269
266
|
passkey: AuthPasskeyApi
|
|
270
267
|
/**
|
|
@@ -6803,14 +6800,36 @@ export default class GoTrueClient {
|
|
|
6803
6800
|
* 2. Prompts user via navigator.credentials.get()
|
|
6804
6801
|
* 3. Verifies credential with server and creates session
|
|
6805
6802
|
*
|
|
6806
|
-
*
|
|
6803
|
+
* Pass `options.mediation: 'conditional'` to use WebAuthn Conditional UI
|
|
6804
|
+
* (passkey autofill) instead of the modal picker; the value is forwarded to
|
|
6805
|
+
* `navigator.credentials.get()` unchanged.
|
|
6806
|
+
*
|
|
6807
|
+
* The challenge fetched in step 1 expires after the server's
|
|
6808
|
+
* GOTRUE_WEBAUTHN_CHALLENGE_EXPIRY_DURATION (5 minutes by default). With
|
|
6809
|
+
* `mediation: 'conditional'` the autofill prompt can stay pending for longer
|
|
6810
|
+
* than that: the browser ceremony then still succeeds, but verification fails
|
|
6811
|
+
* with `error_code: "webauthn_challenge_expired"`. Recover by calling
|
|
6812
|
+
* `signInWithPasskey()` again. It fetches a fresh challenge and, unless you
|
|
6813
|
+
* passed your own `options.signal`, cancels the pending ceremony first, so
|
|
6814
|
+
* the browser never sees two concurrent WebAuthn requests; the earlier call
|
|
6815
|
+
* resolves with a `WebAuthnError` whose code is `ERROR_CEREMONY_ABORTED`. If
|
|
6816
|
+
* you pass your own `signal`, abort it before retrying.
|
|
6807
6817
|
*
|
|
6808
6818
|
* @category Auth
|
|
6819
|
+
*
|
|
6820
|
+
* @example Sign in with Conditional UI (passkey autofill)
|
|
6821
|
+
* ```js
|
|
6822
|
+
* // <input autocomplete="username webauthn" /> somewhere on the page
|
|
6823
|
+
* const { data, error } = await supabase.auth.signInWithPasskey({
|
|
6824
|
+
* options: {
|
|
6825
|
+
* mediation: 'conditional'
|
|
6826
|
+
* }
|
|
6827
|
+
* });
|
|
6828
|
+
* ```
|
|
6809
6829
|
*/
|
|
6810
6830
|
async signInWithPasskey(
|
|
6811
6831
|
credentials?: SignInWithPasskeyCredentials
|
|
6812
6832
|
): Promise<AuthPasskeyAuthenticationVerifyResponse> {
|
|
6813
|
-
assertPasskeyExperimentalEnabled(this.experimental)
|
|
6814
6833
|
try {
|
|
6815
6834
|
if (!browserSupportsWebAuthn()) {
|
|
6816
6835
|
return this._returnResult({
|
|
@@ -6833,6 +6852,7 @@ export default class GoTrueClient {
|
|
|
6833
6852
|
const { data: credential, error: credentialError } = await getCredential({
|
|
6834
6853
|
publicKey: publicKeyOptions,
|
|
6835
6854
|
signal,
|
|
6855
|
+
mediation: credentials?.options?.mediation,
|
|
6836
6856
|
})
|
|
6837
6857
|
if (credentialError || !credential) {
|
|
6838
6858
|
return this._returnResult({
|
|
@@ -6861,14 +6881,13 @@ export default class GoTrueClient {
|
|
|
6861
6881
|
* 2. Prompts user via navigator.credentials.create()
|
|
6862
6882
|
* 3. Verifies credential with server
|
|
6863
6883
|
*
|
|
6864
|
-
* Requires an active session.
|
|
6884
|
+
* Requires an active session.
|
|
6865
6885
|
*
|
|
6866
6886
|
* @category Auth
|
|
6867
6887
|
*/
|
|
6868
6888
|
async registerPasskey(
|
|
6869
6889
|
credentials?: RegisterPasskeyCredentials
|
|
6870
6890
|
): Promise<AuthPasskeyRegistrationVerifyResponse> {
|
|
6871
|
-
assertPasskeyExperimentalEnabled(this.experimental)
|
|
6872
6891
|
try {
|
|
6873
6892
|
if (!browserSupportsWebAuthn()) {
|
|
6874
6893
|
return this._returnResult({
|
|
@@ -6916,7 +6935,6 @@ export default class GoTrueClient {
|
|
|
6916
6935
|
* Returns WebAuthn credential creation options to pass to navigator.credentials.create().
|
|
6917
6936
|
*/
|
|
6918
6937
|
private async _startPasskeyRegistration(): Promise<AuthPasskeyRegistrationOptionsResponse> {
|
|
6919
|
-
assertPasskeyExperimentalEnabled(this.experimental)
|
|
6920
6938
|
try {
|
|
6921
6939
|
return await this._useSession(async (result) => {
|
|
6922
6940
|
const {
|
|
@@ -6959,7 +6977,6 @@ export default class GoTrueClient {
|
|
|
6959
6977
|
private async _verifyPasskeyRegistration(
|
|
6960
6978
|
params: VerifyPasskeyRegistrationParams
|
|
6961
6979
|
): Promise<AuthPasskeyRegistrationVerifyResponse> {
|
|
6962
|
-
assertPasskeyExperimentalEnabled(this.experimental)
|
|
6963
6980
|
try {
|
|
6964
6981
|
return await this._useSession(async (result) => {
|
|
6965
6982
|
const {
|
|
@@ -7005,7 +7022,6 @@ export default class GoTrueClient {
|
|
|
7005
7022
|
private async _startPasskeyAuthentication(
|
|
7006
7023
|
params?: StartPasskeyAuthenticationParams
|
|
7007
7024
|
): Promise<AuthPasskeyAuthenticationOptionsResponse> {
|
|
7008
|
-
assertPasskeyExperimentalEnabled(this.experimental)
|
|
7009
7025
|
try {
|
|
7010
7026
|
const { data, error } = await _request(
|
|
7011
7027
|
this.fetch,
|
|
@@ -7037,7 +7053,6 @@ export default class GoTrueClient {
|
|
|
7037
7053
|
private async _verifyPasskeyAuthentication(
|
|
7038
7054
|
params: VerifyPasskeyAuthenticationParams
|
|
7039
7055
|
): Promise<AuthPasskeyAuthenticationVerifyResponse> {
|
|
7040
|
-
assertPasskeyExperimentalEnabled(this.experimental)
|
|
7041
7056
|
try {
|
|
7042
7057
|
const { data, error } = await _request(
|
|
7043
7058
|
this.fetch,
|
|
@@ -7072,7 +7087,6 @@ export default class GoTrueClient {
|
|
|
7072
7087
|
* List all passkeys for the current user.
|
|
7073
7088
|
*/
|
|
7074
7089
|
private async _listPasskeys(): Promise<AuthPasskeyListResponse> {
|
|
7075
|
-
assertPasskeyExperimentalEnabled(this.experimental)
|
|
7076
7090
|
try {
|
|
7077
7091
|
return await this._useSession(async (result) => {
|
|
7078
7092
|
const {
|
|
@@ -7107,7 +7121,6 @@ export default class GoTrueClient {
|
|
|
7107
7121
|
* Update a passkey.
|
|
7108
7122
|
*/
|
|
7109
7123
|
private async _updatePasskey(params: PasskeyUpdateParams): Promise<AuthPasskeyUpdateResponse> {
|
|
7110
|
-
assertPasskeyExperimentalEnabled(this.experimental)
|
|
7111
7124
|
try {
|
|
7112
7125
|
return await this._useSession(async (result) => {
|
|
7113
7126
|
const {
|
|
@@ -7147,7 +7160,6 @@ export default class GoTrueClient {
|
|
|
7147
7160
|
* Delete a passkey.
|
|
7148
7161
|
*/
|
|
7149
7162
|
private async _deletePasskey(params: PasskeyDeleteParams): Promise<AuthPasskeyDeleteResponse> {
|
|
7150
|
-
assertPasskeyExperimentalEnabled(this.experimental)
|
|
7151
7163
|
try {
|
|
7152
7164
|
return await this._useSession(async (result) => {
|
|
7153
7165
|
const {
|
package/src/lib/error-codes.ts
CHANGED
package/src/lib/helpers.ts
CHANGED
|
@@ -569,14 +569,6 @@ export function validateUUID(str: string) {
|
|
|
569
569
|
}
|
|
570
570
|
}
|
|
571
571
|
|
|
572
|
-
export function assertPasskeyExperimentalEnabled(experimental: { passkey?: boolean }): void {
|
|
573
|
-
if (!experimental.passkey) {
|
|
574
|
-
throw new Error(
|
|
575
|
-
'@supabase/auth-js: the passkey API is experimental and disabled by default. Enable it by passing `auth: { experimental: { passkey: true } }` to createClient (or to the GoTrueClient constructor).'
|
|
576
|
-
)
|
|
577
|
-
}
|
|
578
|
-
}
|
|
579
|
-
|
|
580
572
|
export function assertRecoveryCodesExperimentalEnabled(experimental: {
|
|
581
573
|
recoveryCodes?: boolean
|
|
582
574
|
}): void {
|
package/src/lib/types.ts
CHANGED
|
@@ -181,13 +181,14 @@ export type GoTrueClientOptions = {
|
|
|
181
181
|
|
|
182
182
|
export type ExperimentalFeatureFlags = {
|
|
183
183
|
/**
|
|
184
|
-
*
|
|
185
|
-
*
|
|
186
|
-
* - `auth.passkey.*`
|
|
187
|
-
* - `auth.admin.passkey.*`
|
|
184
|
+
* Previously required to enable the passkey API (`auth.signInWithPasskey()`,
|
|
185
|
+
* `auth.registerPasskey()`, `auth.passkey.*`, `auth.admin.passkey.*`).
|
|
188
186
|
*
|
|
189
|
-
*
|
|
190
|
-
*
|
|
187
|
+
* Passkeys are now enabled by default and this flag is ignored. It is kept
|
|
188
|
+
* only so existing code that sets it keeps compiling and will be removed in
|
|
189
|
+
* the next major version.
|
|
190
|
+
*
|
|
191
|
+
* @deprecated Passkeys are enabled by default; this flag has no effect.
|
|
191
192
|
*/
|
|
192
193
|
passkey?: boolean
|
|
193
194
|
/**
|
|
@@ -3141,6 +3142,7 @@ export type PasskeyMetadata = {
|
|
|
3141
3142
|
export type PasskeyAuthenticationOptionsResponse = {
|
|
3142
3143
|
challenge_id: string
|
|
3143
3144
|
options: ServerCredentialRequestOptions
|
|
3145
|
+
/** Timestamp in UNIX seconds when this challenge will no longer be usable. */
|
|
3144
3146
|
expires_at: number
|
|
3145
3147
|
}
|
|
3146
3148
|
|
|
@@ -3164,6 +3166,33 @@ export type SignInWithPasskeyCredentials = {
|
|
|
3164
3166
|
options?: {
|
|
3165
3167
|
captchaToken?: string
|
|
3166
3168
|
signal?: AbortSignal
|
|
3169
|
+
/**
|
|
3170
|
+
* Forwarded to `navigator.credentials.get()` as `mediation`.
|
|
3171
|
+
*
|
|
3172
|
+
* Use `'conditional'` to opt into WebAuthn Conditional UI, where the browser
|
|
3173
|
+
* offers passkeys through the autofill prompt instead of a modal picker. The
|
|
3174
|
+
* page also needs an input with `autocomplete="username webauthn"`.
|
|
3175
|
+
*
|
|
3176
|
+
* When omitted the browser's default (modal) behavior is used.
|
|
3177
|
+
*
|
|
3178
|
+
* Note that the server-side challenge expires (5 minutes by default) while
|
|
3179
|
+
* the autofill prompt can stay pending indefinitely; if the user picks a
|
|
3180
|
+
* passkey after that, verification fails with
|
|
3181
|
+
* `error_code: "webauthn_challenge_expired"` and the app should call
|
|
3182
|
+
* `signInWithPasskey()` again. See `signInWithPasskey` for details.
|
|
3183
|
+
*
|
|
3184
|
+
* @see {@link https://developer.mozilla.org/en-US/docs/Web/API/CredentialsContainer/get#mediation MDN - mediation}
|
|
3185
|
+
*
|
|
3186
|
+
* @example
|
|
3187
|
+
* ```ts
|
|
3188
|
+
* const credentials: SignInWithPasskeyCredentials = {
|
|
3189
|
+
* options: {
|
|
3190
|
+
* mediation: 'conditional'
|
|
3191
|
+
* }
|
|
3192
|
+
* }
|
|
3193
|
+
* ```
|
|
3194
|
+
*/
|
|
3195
|
+
mediation?: CredentialMediationRequirement
|
|
3167
3196
|
}
|
|
3168
3197
|
}
|
|
3169
3198
|
|
package/src/lib/version.ts
CHANGED
|
@@ -4,4 +4,4 @@
|
|
|
4
4
|
// - Debugging and support (identifying which version is running)
|
|
5
5
|
// - Telemetry and logging (version reporting in errors/analytics)
|
|
6
6
|
// - Ensuring build artifacts match the published package version
|
|
7
|
-
export const version = '2.
|
|
7
|
+
export const version = '2.117.0-canary.1'
|