@@ -484,10 +484,10 @@ export class TurnkeyClient {
484484 * - Stores the resulting session token and manages cleanup of unused key pairs.
485485 *
486486 * @param params.passkeyDisplayName - display name for the passkey (defaults to a generated name based on the current timestamp).
487+ * @param params.challenge - challenge string to use for passkey registration. If not provided, a new challenge will be generated.
488+ * @param params.expirationSeconds - session expiration time in seconds (defaults to the configured default).
487489 * @param params.createSubOrgParams - parameters for creating a sub-organization (e.g., authenticators, user metadata).
488490 * @param params.sessionKey - session key to use for storing the session (defaults to the default session key).
489- * @param params.expirationSeconds - session expiration time in seconds (defaults to the configured default).
490- * @param params.challenge - challenge string to use for passkey registration. If not provided, a new challenge will be generated.
491491 * @param params.organizationId - organization ID to target (defaults to the session's organization ID or the parent organization ID).
492492 * @returns A promise that resolves to a {@link PasskeyAuthResult}, which includes:
493493 * - `sessionToken`: the signed JWT session token.
@@ -498,10 +498,11 @@ export class TurnkeyClient {
498498 params ?: SignUpWithPasskeyParams ,
499499 ) : Promise < PasskeyAuthResult > => {
500500 const {
501- createSubOrgParams,
502501 passkeyDisplayName,
503- sessionKey = SessionKey . DefaultSessionkey ,
502+ challenge ,
504503 expirationSeconds = DEFAULT_SESSION_EXPIRATION_IN_SECONDS ,
504+ createSubOrgParams,
505+ sessionKey = SessionKey . DefaultSessionkey ,
505506 organizationId,
506507 } = params || { } ;
507508
@@ -514,7 +515,7 @@ export class TurnkeyClient {
514515 // A passkey will be created automatically when you call this function. The name is passed in
515516 const passkey = await this . createPasskey ( {
516517 name : passkeyName ,
517- ...( params ?. challenge && { challenge : params . challenge } ) ,
518+ ...( challenge && { challenge } ) ,
518519 } ) ;
519520
520521 if ( ! passkey ) {
@@ -1653,9 +1654,10 @@ export class TurnkeyClient {
16531654 * @param params.oidcToken - OIDC token received after successful authentication with the OAuth provider.
16541655 * @param params.publicKey - public key to use for authentication. Must be generated prior to calling this function, this is because the OIDC nonce has to be set to `sha256(publicKey)`.
16551656 * @param params.providerName - name of the OAuth provider (defaults to a generated name with a timestamp).
1656- * @param params.sessionKey - session key to use for session creation (defaults to the default session key).
1657- * @param params.invalidateExisting - flag to invalidate existing sessions for the user.
16581657 * @param params.createSubOrgParams - parameters for sub-organization creation (e.g., authenticators, user metadata).
1658+ * @param params.invalidateExisting - flag to invalidate existing sessions for the user.
1659+ * @param params.sessionKey - session key to use for session creation (defaults to the default session key).
1660+ *
16591661 * @returns A promise that resolves to an object containing:
16601662 * - `sessionToken`: the signed JWT session token.
16611663 * - `action`: whether the flow resulted in a login or signup ({@link AuthAction}).
@@ -1667,10 +1669,10 @@ export class TurnkeyClient {
16671669 const {
16681670 oidcToken,
16691671 publicKey,
1672+ providerName,
16701673 createSubOrgParams,
1671- providerName = "OpenID Connect Provider" + " " + Date . now ( ) ,
1672- sessionKey = SessionKey . DefaultSessionkey ,
1673- invalidateExisting = false ,
1674+ invalidateExisting,
1675+ sessionKey,
16741676 } = params ;
16751677
16761678 return withTurnkeyErrorHandling (
@@ -1692,8 +1694,8 @@ export class TurnkeyClient {
16921694 const loginRes = await this . loginWithOauth ( {
16931695 oidcToken,
16941696 publicKey,
1695- invalidateExisting,
1696- sessionKey,
1697+ ... ( invalidateExisting && { invalidateExisting } ) ,
1698+ ... ( sessionKey && { sessionKey } ) ,
16971699 } ) ;
16981700
16991701 return {
@@ -1704,11 +1706,14 @@ export class TurnkeyClient {
17041706 const signUpRes = await this . signUpWithOauth ( {
17051707 oidcToken,
17061708 publicKey,
1707- providerName,
1708- sessionKey,
1709+ ...( providerName && {
1710+ providerName,
1711+ } ) ,
17091712 ...( createSubOrgParams && {
17101713 createSubOrgParams,
17111714 } ) ,
1715+ ...( invalidateExisting && { invalidateExisting } ) ,
1716+ ...( sessionKey && { sessionKey } ) ,
17121717 } ) ;
17131718
17141719 return {
@@ -1733,7 +1738,10 @@ export class TurnkeyClient {
17331738 * - Handles cleanup of unused key pairs if login fails.
17341739 *
17351740 * @param params.oidcToken - OIDC token received after successful authentication with the OAuth provider.
1736- * @param params.publicKey - public key to use for authentication. Must be generated prior to calling this function.
1741+ * @param params.publicKey - The public key bound to the login session. This key is required because it is directly
1742+ * tied to the nonce used during OIDC token generation and must match the value
1743+ * encoded in the token.
1744+ * @param params.organizationId - ID of the organization to target when creating the session.
17371745 * @param params.invalidateExisting - flag to invalidate existing sessions for the user.
17381746 * @param params.sessionKey - session key to use for session creation (defaults to the default session key).
17391747 * @returns A promise that resolves to a {@link BaseAuthResult}, which includes:
@@ -1745,8 +1753,9 @@ export class TurnkeyClient {
17451753 ) : Promise < BaseAuthResult > => {
17461754 const {
17471755 oidcToken,
1748- invalidateExisting = false ,
17491756 publicKey,
1757+ organizationId,
1758+ invalidateExisting = false ,
17501759 sessionKey = SessionKey . DefaultSessionkey ,
17511760 } = params ;
17521761
@@ -1763,6 +1772,7 @@ export class TurnkeyClient {
17631772 oidcToken,
17641773 publicKey,
17651774 invalidateExisting,
1775+ ...( organizationId && { organizationId } ) ,
17661776 } ) ;
17671777
17681778 if ( ! loginRes ) {
@@ -1837,7 +1847,7 @@ export class TurnkeyClient {
18371847 const {
18381848 oidcToken,
18391849 publicKey,
1840- providerName,
1850+ providerName = "OpenID Connect Provider" + " " + Date . now ( ) ,
18411851 createSubOrgParams,
18421852 sessionKey,
18431853 } = params ;
0 commit comments