@supabase/auth-js 2.79.1-canary.2 → 2.80.0
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/README.md +35 -17
- package/dist/main/AuthAdminApi.js +2 -4
- package/dist/main/AuthAdminApi.js.map +1 -1
- package/dist/main/AuthClient.js +2 -4
- package/dist/main/AuthClient.js.map +1 -1
- package/dist/main/GoTrueAdminApi.d.ts +7 -0
- package/dist/main/GoTrueAdminApi.d.ts.map +1 -1
- package/dist/main/GoTrueAdminApi.js +28 -15
- package/dist/main/GoTrueAdminApi.js.map +1 -1
- package/dist/main/GoTrueClient.d.ts +38 -1
- package/dist/main/GoTrueClient.d.ts.map +1 -1
- package/dist/main/GoTrueClient.js +293 -152
- package/dist/main/GoTrueClient.js.map +1 -1
- package/dist/main/index.js +7 -23
- package/dist/main/index.js.map +1 -1
- package/dist/main/lib/error-codes.d.ts +1 -1
- package/dist/main/lib/fetch.js +2 -12
- package/dist/main/lib/fetch.js.map +1 -1
- package/dist/main/lib/helpers.d.ts +11 -0
- package/dist/main/lib/helpers.d.ts.map +1 -1
- package/dist/main/lib/helpers.js +39 -42
- package/dist/main/lib/helpers.js.map +1 -1
- package/dist/main/lib/types.d.ts +145 -3
- 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/main/lib/webauthn.js +3 -13
- package/dist/main/lib/webauthn.js.map +1 -1
- package/dist/module/GoTrueAdminApi.d.ts +7 -0
- package/dist/module/GoTrueAdminApi.d.ts.map +1 -1
- package/dist/module/GoTrueAdminApi.js +27 -14
- package/dist/module/GoTrueAdminApi.js.map +1 -1
- package/dist/module/GoTrueClient.d.ts +38 -1
- package/dist/module/GoTrueClient.d.ts.map +1 -1
- package/dist/module/GoTrueClient.js +292 -149
- package/dist/module/GoTrueClient.js.map +1 -1
- package/dist/module/lib/error-codes.d.ts +1 -1
- package/dist/module/lib/fetch.js +1 -11
- package/dist/module/lib/fetch.js.map +1 -1
- package/dist/module/lib/helpers.d.ts +11 -0
- package/dist/module/lib/helpers.d.ts.map +1 -1
- package/dist/module/lib/helpers.js +38 -9
- package/dist/module/lib/helpers.js.map +1 -1
- package/dist/module/lib/types.d.ts +145 -3
- 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/module/lib/webauthn.js +1 -11
- package/dist/module/lib/webauthn.js.map +1 -1
- package/dist/tsconfig.module.tsbuildinfo +1 -0
- package/dist/tsconfig.tsbuildinfo +1 -0
- package/package.json +9 -10
- package/src/GoTrueAdminApi.ts +38 -15
- package/src/GoTrueClient.ts +356 -150
- package/src/lib/error-codes.ts +1 -1
- package/src/lib/helpers.ts +46 -8
- package/src/lib/types.ts +159 -2
- package/src/lib/version.ts +1 -1
package/src/lib/error-codes.ts
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
/**
|
|
2
2
|
* Known error codes. Note that the server may also return other error codes
|
|
3
|
-
* not included in this list (if the
|
|
3
|
+
* not included in this list (if the SDK is older than the version
|
|
4
4
|
* on the server).
|
|
5
5
|
*/
|
|
6
6
|
export type ErrorCode =
|
package/src/lib/helpers.ts
CHANGED
|
@@ -94,16 +94,10 @@ export function parseParametersFromURL(href: string) {
|
|
|
94
94
|
type Fetch = typeof fetch
|
|
95
95
|
|
|
96
96
|
export const resolveFetch = (customFetch?: Fetch): Fetch => {
|
|
97
|
-
let _fetch: Fetch
|
|
98
97
|
if (customFetch) {
|
|
99
|
-
|
|
100
|
-
} else if (typeof fetch === 'undefined') {
|
|
101
|
-
_fetch = (...args) =>
|
|
102
|
-
import('@supabase/node-fetch' as any).then(({ default: fetch }) => fetch(...args))
|
|
103
|
-
} else {
|
|
104
|
-
_fetch = fetch
|
|
98
|
+
return (...args) => customFetch(...args)
|
|
105
99
|
}
|
|
106
|
-
return (...args) =>
|
|
100
|
+
return (...args) => fetch(...args)
|
|
107
101
|
}
|
|
108
102
|
|
|
109
103
|
export const looksLikeFetchResponse = (maybeResponse: unknown): maybeResponse is Response => {
|
|
@@ -407,6 +401,50 @@ export function userNotAvailableProxy(): User {
|
|
|
407
401
|
})
|
|
408
402
|
}
|
|
409
403
|
|
|
404
|
+
/**
|
|
405
|
+
* Creates a proxy around a user object that warns when properties are accessed on the server.
|
|
406
|
+
* This is used to alert developers that using user data from getSession() on the server is insecure.
|
|
407
|
+
*
|
|
408
|
+
* @param user The actual user object to wrap
|
|
409
|
+
* @param suppressWarningRef An object with a 'value' property that controls warning suppression
|
|
410
|
+
* @returns A proxied user object that warns on property access
|
|
411
|
+
*/
|
|
412
|
+
export function insecureUserWarningProxy(user: User, suppressWarningRef: { value: boolean }): User {
|
|
413
|
+
return new Proxy(user, {
|
|
414
|
+
get: (target: any, prop: string | symbol, receiver: any) => {
|
|
415
|
+
// Allow internal checks without warning
|
|
416
|
+
if (prop === '__isInsecureUserWarningProxy') {
|
|
417
|
+
return true
|
|
418
|
+
}
|
|
419
|
+
|
|
420
|
+
// Preventative check for common problematic symbols during cloning/inspection
|
|
421
|
+
// These symbols might be accessed by structuredClone or other internal mechanisms
|
|
422
|
+
if (typeof prop === 'symbol') {
|
|
423
|
+
const sProp = prop.toString()
|
|
424
|
+
if (
|
|
425
|
+
sProp === 'Symbol(Symbol.toPrimitive)' ||
|
|
426
|
+
sProp === 'Symbol(Symbol.toStringTag)' ||
|
|
427
|
+
sProp === 'Symbol(util.inspect.custom)' ||
|
|
428
|
+
sProp === 'Symbol(nodejs.util.inspect.custom)'
|
|
429
|
+
) {
|
|
430
|
+
// Return the actual value for these symbols to allow proper inspection
|
|
431
|
+
return Reflect.get(target, prop, receiver)
|
|
432
|
+
}
|
|
433
|
+
}
|
|
434
|
+
|
|
435
|
+
// Emit warning on first property access
|
|
436
|
+
if (!suppressWarningRef.value && typeof prop === 'string') {
|
|
437
|
+
console.warn(
|
|
438
|
+
'Using the user object as returned from supabase.auth.getSession() or from some supabase.auth.onAuthStateChange() events could be insecure! This value comes directly from the storage medium (usually cookies on the server) and may not be authentic. Use supabase.auth.getUser() instead which authenticates the data by contacting the Supabase Auth server.'
|
|
439
|
+
)
|
|
440
|
+
suppressWarningRef.value = true
|
|
441
|
+
}
|
|
442
|
+
|
|
443
|
+
return Reflect.get(target, prop, receiver)
|
|
444
|
+
},
|
|
445
|
+
})
|
|
446
|
+
}
|
|
447
|
+
|
|
410
448
|
/**
|
|
411
449
|
* Deep clones a JSON-serializable object using JSON.parse(JSON.stringify(obj)).
|
|
412
450
|
* Note: Only works for JSON-safe data.
|
package/src/lib/types.ts
CHANGED
|
@@ -107,6 +107,11 @@ export type GoTrueClientOptions = {
|
|
|
107
107
|
* @experimental
|
|
108
108
|
*/
|
|
109
109
|
hasCustomAuthorizationHeader?: boolean
|
|
110
|
+
/**
|
|
111
|
+
* If there is an error with the query, throwOnError will reject the promise by
|
|
112
|
+
* throwing the error instead of returning it as part of a successful response.
|
|
113
|
+
*/
|
|
114
|
+
throwOnError?: boolean
|
|
110
115
|
}
|
|
111
116
|
|
|
112
117
|
const WeakPasswordReasons = ['length', 'characters', 'pwned'] as const
|
|
@@ -1434,7 +1439,31 @@ export type RequiredClaims = {
|
|
|
1434
1439
|
session_id: string
|
|
1435
1440
|
}
|
|
1436
1441
|
|
|
1437
|
-
|
|
1442
|
+
/**
|
|
1443
|
+
* JWT Payload containing claims for Supabase authentication tokens.
|
|
1444
|
+
*
|
|
1445
|
+
* Required claims (iss, aud, exp, iat, sub, role, aal, session_id) are inherited from RequiredClaims.
|
|
1446
|
+
* All other claims are optional as they can be customized via Custom Access Token Hooks.
|
|
1447
|
+
*
|
|
1448
|
+
* @see https://supabase.com/docs/guides/auth/jwt-fields
|
|
1449
|
+
*/
|
|
1450
|
+
export interface JwtPayload extends RequiredClaims {
|
|
1451
|
+
// Standard optional claims (can be customized via custom access token hooks)
|
|
1452
|
+
email?: string
|
|
1453
|
+
phone?: string
|
|
1454
|
+
is_anonymous?: boolean
|
|
1455
|
+
|
|
1456
|
+
// Optional claims
|
|
1457
|
+
jti?: string
|
|
1458
|
+
nbf?: number
|
|
1459
|
+
app_metadata?: UserAppMetadata
|
|
1460
|
+
user_metadata?: UserMetadata
|
|
1461
|
+
amr?: AMREntry[]
|
|
1462
|
+
|
|
1463
|
+
// Special claims (only in anon/service role tokens)
|
|
1464
|
+
ref?: string
|
|
1465
|
+
|
|
1466
|
+
// Allow custom claims via custom access token hooks
|
|
1438
1467
|
[key: string]: any
|
|
1439
1468
|
}
|
|
1440
1469
|
|
|
@@ -1492,6 +1521,8 @@ export type OAuthClient = {
|
|
|
1492
1521
|
registration_type: OAuthClientRegistrationType
|
|
1493
1522
|
/** URI of the OAuth client */
|
|
1494
1523
|
client_uri?: string
|
|
1524
|
+
/** URI of the OAuth client's logo */
|
|
1525
|
+
logo_uri?: string
|
|
1495
1526
|
/** Array of allowed redirect URIs */
|
|
1496
1527
|
redirect_uris: string[]
|
|
1497
1528
|
/** Array of allowed grant types */
|
|
@@ -1525,6 +1556,24 @@ export type CreateOAuthClientParams = {
|
|
|
1525
1556
|
scope?: string
|
|
1526
1557
|
}
|
|
1527
1558
|
|
|
1559
|
+
/**
|
|
1560
|
+
* Parameters for updating an existing OAuth client.
|
|
1561
|
+
* All fields are optional. Only provided fields will be updated.
|
|
1562
|
+
* Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
|
|
1563
|
+
*/
|
|
1564
|
+
export type UpdateOAuthClientParams = {
|
|
1565
|
+
/** Human-readable name of the OAuth client */
|
|
1566
|
+
client_name?: string
|
|
1567
|
+
/** URI of the OAuth client */
|
|
1568
|
+
client_uri?: string
|
|
1569
|
+
/** URI of the OAuth client's logo */
|
|
1570
|
+
logo_uri?: string
|
|
1571
|
+
/** Array of allowed redirect URIs */
|
|
1572
|
+
redirect_uris?: string[]
|
|
1573
|
+
/** Array of allowed grant types */
|
|
1574
|
+
grant_types?: OAuthClientGrantType[]
|
|
1575
|
+
}
|
|
1576
|
+
|
|
1528
1577
|
/**
|
|
1529
1578
|
* Response type for OAuth client operations.
|
|
1530
1579
|
* Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
|
|
@@ -1574,13 +1623,21 @@ export interface GoTrueAdminOAuthApi {
|
|
|
1574
1623
|
*/
|
|
1575
1624
|
getClient(clientId: string): Promise<OAuthClientResponse>
|
|
1576
1625
|
|
|
1626
|
+
/**
|
|
1627
|
+
* Updates an existing OAuth client.
|
|
1628
|
+
* Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
|
|
1629
|
+
*
|
|
1630
|
+
* This function should only be called on a server. Never expose your `service_role` key in the browser.
|
|
1631
|
+
*/
|
|
1632
|
+
updateClient(clientId: string, params: UpdateOAuthClientParams): Promise<OAuthClientResponse>
|
|
1633
|
+
|
|
1577
1634
|
/**
|
|
1578
1635
|
* Deletes an OAuth client.
|
|
1579
1636
|
* Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
|
|
1580
1637
|
*
|
|
1581
1638
|
* This function should only be called on a server. Never expose your `service_role` key in the browser.
|
|
1582
1639
|
*/
|
|
1583
|
-
deleteClient(clientId: string): Promise<
|
|
1640
|
+
deleteClient(clientId: string): Promise<{ data: null; error: AuthError | null }>
|
|
1584
1641
|
|
|
1585
1642
|
/**
|
|
1586
1643
|
* Regenerates the secret for an OAuth client.
|
|
@@ -1590,3 +1647,103 @@ export interface GoTrueAdminOAuthApi {
|
|
|
1590
1647
|
*/
|
|
1591
1648
|
regenerateClientSecret(clientId: string): Promise<OAuthClientResponse>
|
|
1592
1649
|
}
|
|
1650
|
+
|
|
1651
|
+
/**
|
|
1652
|
+
* OAuth client details in an authorization request.
|
|
1653
|
+
* Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
|
|
1654
|
+
*/
|
|
1655
|
+
export type OAuthAuthorizationClient = {
|
|
1656
|
+
/** Unique identifier for the OAuth client (UUID) */
|
|
1657
|
+
client_id: string
|
|
1658
|
+
/** Human-readable name of the OAuth client */
|
|
1659
|
+
client_name: string
|
|
1660
|
+
/** URI of the OAuth client's website */
|
|
1661
|
+
client_uri: string
|
|
1662
|
+
/** URI of the OAuth client's logo */
|
|
1663
|
+
logo_uri: string
|
|
1664
|
+
}
|
|
1665
|
+
|
|
1666
|
+
/**
|
|
1667
|
+
* OAuth authorization details for the consent flow.
|
|
1668
|
+
* Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
|
|
1669
|
+
*/
|
|
1670
|
+
export type OAuthAuthorizationDetails = {
|
|
1671
|
+
/** The authorization ID */
|
|
1672
|
+
authorization_id: string
|
|
1673
|
+
/** Redirect URI - present if user already consented (can be used to trigger immediate redirect) */
|
|
1674
|
+
redirect_uri?: string
|
|
1675
|
+
/** OAuth client requesting authorization */
|
|
1676
|
+
client: OAuthAuthorizationClient
|
|
1677
|
+
/** User object associated with the authorization */
|
|
1678
|
+
user: {
|
|
1679
|
+
/** User ID (UUID) */
|
|
1680
|
+
id: string
|
|
1681
|
+
/** User email */
|
|
1682
|
+
email: string
|
|
1683
|
+
}
|
|
1684
|
+
/** Space-separated list of requested scopes */
|
|
1685
|
+
scope: string
|
|
1686
|
+
}
|
|
1687
|
+
|
|
1688
|
+
/**
|
|
1689
|
+
* Response type for getting OAuth authorization details.
|
|
1690
|
+
* Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
|
|
1691
|
+
*/
|
|
1692
|
+
export type AuthOAuthAuthorizationDetailsResponse = RequestResult<OAuthAuthorizationDetails>
|
|
1693
|
+
|
|
1694
|
+
/**
|
|
1695
|
+
* Response type for OAuth consent decision (approve/deny).
|
|
1696
|
+
* Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
|
|
1697
|
+
*/
|
|
1698
|
+
export type AuthOAuthConsentResponse = RequestResult<{
|
|
1699
|
+
/** URL to redirect the user back to the OAuth client */
|
|
1700
|
+
redirect_url: string
|
|
1701
|
+
}>
|
|
1702
|
+
|
|
1703
|
+
/**
|
|
1704
|
+
* Contains all OAuth 2.1 authorization server user-facing methods.
|
|
1705
|
+
* Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
|
|
1706
|
+
*
|
|
1707
|
+
* These methods are used to implement the consent page.
|
|
1708
|
+
*/
|
|
1709
|
+
export interface AuthOAuthServerApi {
|
|
1710
|
+
/**
|
|
1711
|
+
* Retrieves details about an OAuth authorization request.
|
|
1712
|
+
* Used to display consent information to the user.
|
|
1713
|
+
* Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
|
|
1714
|
+
*
|
|
1715
|
+
* This method returns authorization details including client info, scopes, and user information.
|
|
1716
|
+
* If the response includes a redirect_uri, it means consent was already given - the caller
|
|
1717
|
+
* should handle the redirect manually if needed.
|
|
1718
|
+
*
|
|
1719
|
+
* @param authorizationId - The authorization ID from the authorization request
|
|
1720
|
+
* @returns Authorization details including client info and requested scopes
|
|
1721
|
+
*/
|
|
1722
|
+
getAuthorizationDetails(authorizationId: string): Promise<AuthOAuthAuthorizationDetailsResponse>
|
|
1723
|
+
|
|
1724
|
+
/**
|
|
1725
|
+
* Approves an OAuth authorization request.
|
|
1726
|
+
* Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
|
|
1727
|
+
*
|
|
1728
|
+
* @param authorizationId - The authorization ID to approve
|
|
1729
|
+
* @param options - Optional parameters including skipBrowserRedirect
|
|
1730
|
+
* @returns Redirect URL to send the user back to the OAuth client
|
|
1731
|
+
*/
|
|
1732
|
+
approveAuthorization(
|
|
1733
|
+
authorizationId: string,
|
|
1734
|
+
options?: { skipBrowserRedirect?: boolean }
|
|
1735
|
+
): Promise<AuthOAuthConsentResponse>
|
|
1736
|
+
|
|
1737
|
+
/**
|
|
1738
|
+
* Denies an OAuth authorization request.
|
|
1739
|
+
* Only relevant when the OAuth 2.1 server is enabled in Supabase Auth.
|
|
1740
|
+
*
|
|
1741
|
+
* @param authorizationId - The authorization ID to deny
|
|
1742
|
+
* @param options - Optional parameters including skipBrowserRedirect
|
|
1743
|
+
* @returns Redirect URL to send the user back to the OAuth client
|
|
1744
|
+
*/
|
|
1745
|
+
denyAuthorization(
|
|
1746
|
+
authorizationId: string,
|
|
1747
|
+
options?: { skipBrowserRedirect?: boolean }
|
|
1748
|
+
): Promise<AuthOAuthConsentResponse>
|
|
1749
|
+
}
|
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.80.0'
|