@instantdb/core
Advanced tools
Comparing version 0.10.0 to 0.10.1
@@ -17,6 +17,14 @@ export function sendMagicCode({ apiURI, appId, email }: { | ||
}): Promise<any>; | ||
export function exchangeCodeForToken({ apiURI, appId, code }: { | ||
apiURI: any; | ||
appId: any; | ||
code: any; | ||
/** | ||
* @param {Object} params | ||
* @param {string} params.apiURI | ||
* @param {string} params.appId | ||
* @param {string} params.code | ||
* @param {string | null | undefined} [params.codeVerifier] | ||
*/ | ||
export function exchangeCodeForToken({ apiURI, appId, code, codeVerifier, }: { | ||
apiURI: string; | ||
appId: string; | ||
code: string; | ||
codeVerifier?: string | null | undefined; | ||
}): Promise<any>; | ||
@@ -29,3 +37,3 @@ /** | ||
* @param {string} params.idToken | ||
* @param {string | null | undefined} params.nonce | ||
* @param {string | null | undefined} [params.nonce] | ||
*/ | ||
@@ -37,4 +45,4 @@ export function signInWithIdToken({ apiURI, appId, nonce, idToken, clientName, }: { | ||
idToken: string; | ||
nonce: string | null | undefined; | ||
nonce?: string | null | undefined; | ||
}): Promise<any>; | ||
//# sourceMappingURL=authAPI.d.ts.map |
@@ -47,3 +47,10 @@ "use strict"; | ||
exports.verifyRefreshToken = verifyRefreshToken; | ||
function exchangeCodeForToken({ apiURI, appId, code }) { | ||
/** | ||
* @param {Object} params | ||
* @param {string} params.apiURI | ||
* @param {string} params.appId | ||
* @param {string} params.code | ||
* @param {string | null | undefined} [params.codeVerifier] | ||
*/ | ||
function exchangeCodeForToken({ apiURI, appId, code, codeVerifier, }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -56,2 +63,3 @@ const res = yield (0, fetch_1.jsonFetch)(`${apiURI}/runtime/oauth/token`, { | ||
code: code, | ||
code_verifier: codeVerifier, | ||
}), | ||
@@ -69,3 +77,3 @@ }); | ||
* @param {string} params.idToken | ||
* @param {string | null | undefined} params.nonce | ||
* @param {string | null | undefined} [params.nonce] | ||
*/ | ||
@@ -72,0 +80,0 @@ function signInWithIdToken({ apiURI, appId, nonce, idToken, clientName, }) { |
@@ -228,2 +228,34 @@ import Reactor from "./Reactor"; | ||
/** | ||
* Sign in with the id_token from an external provider like Google | ||
* | ||
* @see https://docs.instantdb.com/docs/auth | ||
* @example | ||
* db.auth | ||
* .exchangeOAuthCode({ | ||
* // code received in redirect from OAuth callback | ||
* code: code | ||
* // The PKCE code_verifier, if any, that you used when you | ||
* // initiated the auth flow | ||
* codeVerifier: your_code_verifier | ||
* }) | ||
* .catch((err) => console.error(err.body?.message)); | ||
* | ||
*/ | ||
exchangeOAuthCode: (params: { | ||
code: string; | ||
codeVerifier: string | undefined | null; | ||
}) => Promise<any>; | ||
/** | ||
* OpenID Discovery path for use with tools like | ||
* expo-auth-session that use auto-discovery of | ||
* OAuth parameters. | ||
* | ||
* @see https://docs.instantdb.com/docs/auth | ||
* @example | ||
* const discovery = useAutoDiscovery( | ||
* db.auth.issuerURI() | ||
* ); | ||
*/ | ||
issuerURI: () => string; | ||
/** | ||
* Sign out the current user | ||
@@ -230,0 +262,0 @@ */ |
@@ -256,2 +256,35 @@ "use strict"; | ||
/** | ||
* Sign in with the id_token from an external provider like Google | ||
* | ||
* @see https://docs.instantdb.com/docs/auth | ||
* @example | ||
* db.auth | ||
* .exchangeOAuthCode({ | ||
* // code received in redirect from OAuth callback | ||
* code: code | ||
* // The PKCE code_verifier, if any, that you used when you | ||
* // initiated the auth flow | ||
* codeVerifier: your_code_verifier | ||
* }) | ||
* .catch((err) => console.error(err.body?.message)); | ||
* | ||
*/ | ||
this.exchangeOAuthCode = (params) => { | ||
return this.db.exchangeCodeForToken(params); | ||
}; | ||
/** | ||
* OpenID Discovery path for use with tools like | ||
* expo-auth-session that use auto-discovery of | ||
* OAuth parameters. | ||
* | ||
* @see https://docs.instantdb.com/docs/auth | ||
* @example | ||
* const discovery = useAutoDiscovery( | ||
* db.auth.issuerURI() | ||
* ); | ||
*/ | ||
this.issuerURI = () => { | ||
return this.db.issuerURI(); | ||
}; | ||
/** | ||
* Sign out the current user | ||
@@ -258,0 +291,0 @@ */ |
@@ -17,6 +17,14 @@ export function sendMagicCode({ apiURI, appId, email }: { | ||
}): Promise<any>; | ||
export function exchangeCodeForToken({ apiURI, appId, code }: { | ||
apiURI: any; | ||
appId: any; | ||
code: any; | ||
/** | ||
* @param {Object} params | ||
* @param {string} params.apiURI | ||
* @param {string} params.appId | ||
* @param {string} params.code | ||
* @param {string | null | undefined} [params.codeVerifier] | ||
*/ | ||
export function exchangeCodeForToken({ apiURI, appId, code, codeVerifier, }: { | ||
apiURI: string; | ||
appId: string; | ||
code: string; | ||
codeVerifier?: string | null | undefined; | ||
}): Promise<any>; | ||
@@ -29,3 +37,3 @@ /** | ||
* @param {string} params.idToken | ||
* @param {string | null | undefined} params.nonce | ||
* @param {string | null | undefined} [params.nonce] | ||
*/ | ||
@@ -37,4 +45,4 @@ export function signInWithIdToken({ apiURI, appId, nonce, idToken, clientName, }: { | ||
idToken: string; | ||
nonce: string | null | undefined; | ||
nonce?: string | null | undefined; | ||
}): Promise<any>; | ||
//# sourceMappingURL=authAPI.d.ts.map |
@@ -41,3 +41,10 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
} | ||
export function exchangeCodeForToken({ apiURI, appId, code }) { | ||
/** | ||
* @param {Object} params | ||
* @param {string} params.apiURI | ||
* @param {string} params.appId | ||
* @param {string} params.code | ||
* @param {string | null | undefined} [params.codeVerifier] | ||
*/ | ||
export function exchangeCodeForToken({ apiURI, appId, code, codeVerifier, }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -50,2 +57,3 @@ const res = yield jsonFetch(`${apiURI}/runtime/oauth/token`, { | ||
code: code, | ||
code_verifier: codeVerifier, | ||
}), | ||
@@ -62,3 +70,3 @@ }); | ||
* @param {string} params.idToken | ||
* @param {string | null | undefined} params.nonce | ||
* @param {string | null | undefined} [params.nonce] | ||
*/ | ||
@@ -65,0 +73,0 @@ export function signInWithIdToken({ apiURI, appId, nonce, idToken, clientName, }) { |
@@ -228,2 +228,34 @@ import Reactor from "./Reactor"; | ||
/** | ||
* Sign in with the id_token from an external provider like Google | ||
* | ||
* @see https://docs.instantdb.com/docs/auth | ||
* @example | ||
* db.auth | ||
* .exchangeOAuthCode({ | ||
* // code received in redirect from OAuth callback | ||
* code: code | ||
* // The PKCE code_verifier, if any, that you used when you | ||
* // initiated the auth flow | ||
* codeVerifier: your_code_verifier | ||
* }) | ||
* .catch((err) => console.error(err.body?.message)); | ||
* | ||
*/ | ||
exchangeOAuthCode: (params: { | ||
code: string; | ||
codeVerifier: string | undefined | null; | ||
}) => Promise<any>; | ||
/** | ||
* OpenID Discovery path for use with tools like | ||
* expo-auth-session that use auto-discovery of | ||
* OAuth parameters. | ||
* | ||
* @see https://docs.instantdb.com/docs/auth | ||
* @example | ||
* const discovery = useAutoDiscovery( | ||
* db.auth.issuerURI() | ||
* ); | ||
*/ | ||
issuerURI: () => string; | ||
/** | ||
* Sign out the current user | ||
@@ -230,0 +262,0 @@ */ |
@@ -242,2 +242,35 @@ import Reactor from "./Reactor"; | ||
/** | ||
* Sign in with the id_token from an external provider like Google | ||
* | ||
* @see https://docs.instantdb.com/docs/auth | ||
* @example | ||
* db.auth | ||
* .exchangeOAuthCode({ | ||
* // code received in redirect from OAuth callback | ||
* code: code | ||
* // The PKCE code_verifier, if any, that you used when you | ||
* // initiated the auth flow | ||
* codeVerifier: your_code_verifier | ||
* }) | ||
* .catch((err) => console.error(err.body?.message)); | ||
* | ||
*/ | ||
this.exchangeOAuthCode = (params) => { | ||
return this.db.exchangeCodeForToken(params); | ||
}; | ||
/** | ||
* OpenID Discovery path for use with tools like | ||
* expo-auth-session that use auto-discovery of | ||
* OAuth parameters. | ||
* | ||
* @see https://docs.instantdb.com/docs/auth | ||
* @example | ||
* const discovery = useAutoDiscovery( | ||
* db.auth.issuerURI() | ||
* ); | ||
*/ | ||
this.issuerURI = () => { | ||
return this.db.issuerURI(); | ||
}; | ||
/** | ||
* Sign out the current user | ||
@@ -244,0 +277,0 @@ */ |
@@ -160,5 +160,7 @@ /** | ||
}): string; | ||
exchangeCodeForToken({ code }: { | ||
exchangeCodeForToken({ code, codeVerifier }: { | ||
code: any; | ||
codeVerifier: any; | ||
}): Promise<any>; | ||
issuerURI(): string; | ||
/** | ||
@@ -165,0 +167,0 @@ * @param {Object} params |
@@ -848,3 +848,3 @@ // @ts-check | ||
} | ||
exchangeCodeForToken({ code }) { | ||
exchangeCodeForToken({ code, codeVerifier }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -855,2 +855,3 @@ const res = yield authAPI.exchangeCodeForToken({ | ||
code: code, | ||
codeVerifier, | ||
}); | ||
@@ -861,2 +862,6 @@ this.changeCurrentUser(res.user); | ||
} | ||
issuerURI() { | ||
const { apiURI, appId } = this.config; | ||
return `${apiURI}/runtime/${appId}`; | ||
} | ||
/** | ||
@@ -863,0 +868,0 @@ * @param {Object} params |
@@ -160,5 +160,7 @@ /** | ||
}): string; | ||
exchangeCodeForToken({ code }: { | ||
exchangeCodeForToken({ code, codeVerifier }: { | ||
code: any; | ||
codeVerifier: any; | ||
}): Promise<any>; | ||
issuerURI(): string; | ||
/** | ||
@@ -165,0 +167,0 @@ * @param {Object} params |
@@ -876,3 +876,3 @@ "use strict"; | ||
} | ||
exchangeCodeForToken({ code }) { | ||
exchangeCodeForToken({ code, codeVerifier }) { | ||
return __awaiter(this, void 0, void 0, function* () { | ||
@@ -883,2 +883,3 @@ const res = yield authAPI.exchangeCodeForToken({ | ||
code: code, | ||
codeVerifier, | ||
}); | ||
@@ -889,2 +890,6 @@ this.changeCurrentUser(res.user); | ||
} | ||
issuerURI() { | ||
const { apiURI, appId } = this.config; | ||
return `${apiURI}/runtime/${appId}`; | ||
} | ||
/** | ||
@@ -891,0 +896,0 @@ * @param {Object} params |
{ | ||
"name": "@instantdb/core", | ||
"version": "0.10.0", | ||
"version": "0.10.1", | ||
"description": "Instant's core local abstraction", | ||
@@ -5,0 +5,0 @@ "main": "dist/index.js", |
@@ -32,3 +32,15 @@ import { jsonFetch } from "./utils/fetch"; | ||
export async function exchangeCodeForToken({ apiURI, appId, code }) { | ||
/** | ||
* @param {Object} params | ||
* @param {string} params.apiURI | ||
* @param {string} params.appId | ||
* @param {string} params.code | ||
* @param {string | null | undefined} [params.codeVerifier] | ||
*/ | ||
export async function exchangeCodeForToken({ | ||
apiURI, | ||
appId, | ||
code, | ||
codeVerifier, | ||
}) { | ||
const res = await jsonFetch(`${apiURI}/runtime/oauth/token`, { | ||
@@ -40,2 +52,3 @@ method: "POST", | ||
code: code, | ||
code_verifier: codeVerifier, | ||
}), | ||
@@ -52,3 +65,3 @@ }); | ||
* @param {string} params.idToken | ||
* @param {string | null | undefined} params.nonce | ||
* @param {string | null | undefined} [params.nonce] | ||
*/ | ||
@@ -55,0 +68,0 @@ export async function signInWithIdToken({ |
@@ -333,3 +333,3 @@ import Reactor from "./Reactor"; | ||
* db.auth | ||
* .signInWithIdToken({ | ||
* .signInWithIdToken({ | ||
* // Token from external service | ||
@@ -355,2 +355,40 @@ * idToken: id_token, | ||
/** | ||
* Sign in with the id_token from an external provider like Google | ||
* | ||
* @see https://docs.instantdb.com/docs/auth | ||
* @example | ||
* db.auth | ||
* .exchangeOAuthCode({ | ||
* // code received in redirect from OAuth callback | ||
* code: code | ||
* // The PKCE code_verifier, if any, that you used when you | ||
* // initiated the auth flow | ||
* codeVerifier: your_code_verifier | ||
* }) | ||
* .catch((err) => console.error(err.body?.message)); | ||
* | ||
*/ | ||
exchangeOAuthCode = (params: { | ||
code: string; | ||
codeVerifier: string | undefined | null; | ||
}) => { | ||
return this.db.exchangeCodeForToken(params); | ||
}; | ||
/** | ||
* OpenID Discovery path for use with tools like | ||
* expo-auth-session that use auto-discovery of | ||
* OAuth parameters. | ||
* | ||
* @see https://docs.instantdb.com/docs/auth | ||
* @example | ||
* const discovery = useAutoDiscovery( | ||
* db.auth.issuerURI() | ||
* ); | ||
*/ | ||
issuerURI = () => { | ||
return this.db.issuerURI(); | ||
}; | ||
/** | ||
* Sign out the current user | ||
@@ -357,0 +395,0 @@ */ |
@@ -964,3 +964,3 @@ // @ts-check | ||
async exchangeCodeForToken({ code }) { | ||
async exchangeCodeForToken({ code, codeVerifier }) { | ||
const res = await authAPI.exchangeCodeForToken({ | ||
@@ -970,2 +970,3 @@ apiURI: this.config.apiURI, | ||
code: code, | ||
codeVerifier, | ||
}); | ||
@@ -976,2 +977,7 @@ this.changeCurrentUser(res.user); | ||
issuerURI() { | ||
const { apiURI, appId } = this.config; | ||
return `${apiURI}/runtime/${appId}`; | ||
} | ||
/** | ||
@@ -978,0 +984,0 @@ * @param {Object} params |
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
Sorry, the diff of this file is not supported yet
1554071
34908