diff --git a/packages/nativescript-auth0/index.android.ts b/packages/nativescript-auth0/index.android.ts index 2dc3b6b..942ccf3 100644 --- a/packages/nativescript-auth0/index.android.ts +++ b/packages/nativescript-auth0/index.android.ts @@ -111,7 +111,7 @@ export class CredentialsManager { resolve(Credentials.fromNative(credentials)); } }, - }) + }), ); }); } @@ -145,7 +145,7 @@ export class WebAuth { return this; } - start(options?: { scheme?: string; scope?: string; audience?: string; redirectUrl?: string }) { + start(options?: { scheme?: string; scope?: string; audience?: string; redirectUrl?: string; parameters?: Record }) { return new Promise((resolve, reject) => { this.webAuth.start( Utils.android.getCurrentActivity(), @@ -153,6 +153,7 @@ export class WebAuth { options.scope ?? null, options?.audience ?? null, options?.redirectUrl ?? null, + Utils.dataSerialize(options?.parameters ?? {}) as any, new kotlin.jvm.functions.Function2({ invoke: (credentials: com.auth0.android.result.Credentials, error: java.lang.Throwable) => { if (error) { @@ -161,7 +162,7 @@ export class WebAuth { resolve(Credentials.fromNative(credentials)); } }, - }) + }), ); }); } @@ -181,7 +182,7 @@ export class WebAuth { resolve(); } }, - }) + }), ); }); } @@ -397,7 +398,7 @@ export class Authentication { resolve(UserInfo.fromNative(userInfo)); } }, - }) + }), ); }); } @@ -417,7 +418,7 @@ export class Authentication { resolve(Credentials.fromNative(credentials)); } }, - }) + }), ); }); } @@ -435,7 +436,7 @@ export class Authentication { resolve(); } }, - }) + }), ); }); } diff --git a/packages/nativescript-auth0/index.d.ts b/packages/nativescript-auth0/index.d.ts index e19ecd0..6a6371b 100644 --- a/packages/nativescript-auth0/index.d.ts +++ b/packages/nativescript-auth0/index.d.ts @@ -37,7 +37,7 @@ export class WebAuth { useHTTPS(): this; - start(options?: { scheme?: string; scope?: string; audience?: string; redirectUrl?: string }): Promise; + start(options?: { scheme?: string; scope?: string; audience?: string; redirectUrl?: string; parameters?: Record }): Promise; clear(options?: { scheme?: string; federated?: boolean; returnToUrl?: string }): Promise; } diff --git a/packages/nativescript-auth0/index.ios.ts b/packages/nativescript-auth0/index.ios.ts index 4a05074..4c79dcb 100644 --- a/packages/nativescript-auth0/index.ios.ts +++ b/packages/nativescript-auth0/index.ios.ts @@ -127,9 +127,9 @@ export class WebAuth { return this; } - start(options?: { scheme?: string; scope?: string; audience?: string; redirectUrl?: string }) { + start(options?: { scheme?: string; scope?: string; audience?: string; redirectUrl?: string; parameters?: Record }) { return new Promise((resolve, reject) => { - this.webAuth.start(options?.scope, options?.audience, (credentials, error) => { + this.webAuth.start(options?.scope, options?.audience, Utils.dataSerialize(options?.parameters ?? {}) as any, (credentials, error) => { if (error) { reject(error); } else { diff --git a/packages/nativescript-auth0/platforms/android/java/io/nstudio/plugins/auth0/WebAuth.kt b/packages/nativescript-auth0/platforms/android/java/io/nstudio/plugins/auth0/WebAuth.kt index b3807e9..812de5d 100644 --- a/packages/nativescript-auth0/platforms/android/java/io/nstudio/plugins/auth0/WebAuth.kt +++ b/packages/nativescript-auth0/platforms/android/java/io/nstudio/plugins/auth0/WebAuth.kt @@ -14,6 +14,7 @@ class WebAuth(val auth0: com.auth0.android.Auth0) { scope: String?, audience: String?, redirectUrl: String?, + parameters: Map?, callback: (Credentials?, Exception?) -> Void ) { val login = @@ -35,6 +36,10 @@ class WebAuth(val auth0: com.auth0.android.Auth0) { login.withAudience(audience) } + parameters?.let { + login.withParameters(it) + } + login.start(context, object : Callback { override fun onFailure(error: AuthenticationException) { callback(null, error) diff --git a/packages/nativescript-auth0/platforms/android/nativescript_auth0.aar b/packages/nativescript-auth0/platforms/android/nativescript_auth0.aar index 7484ffe..13fed69 100644 Binary files a/packages/nativescript-auth0/platforms/android/nativescript_auth0.aar and b/packages/nativescript-auth0/platforms/android/nativescript_auth0.aar differ diff --git a/packages/nativescript-auth0/platforms/ios/src/NSCAuth0.swift b/packages/nativescript-auth0/platforms/ios/src/NSCAuth0.swift index 8fbae42..95424ff 100644 --- a/packages/nativescript-auth0/platforms/ios/src/NSCAuth0.swift +++ b/packages/nativescript-auth0/platforms/ios/src/NSCAuth0.swift @@ -63,7 +63,7 @@ public class NSCAuth0WebAuth: NSObject { return self } - public func start(_ scope: String? = nil, _ audience: String? = nil, _ callback: @escaping (NSCAuth0Credentials?, Error?)->Void){ + public func start(_ scope: String? = nil, _ audience: String? = nil, _ parameters: [String: String]? = nil, _ callback: @escaping (NSCAuth0Credentials?, Error?)->Void){ Task { do { if let scope = scope { @@ -72,6 +72,9 @@ public class NSCAuth0WebAuth: NSObject { if let audience = audience { webAuth = self.webAuth.audience(audience) } + if let parameters = parameters { + webAuth = self.webAuth.parameters(parameters) + } let result = try await webAuth.start() callback(NSCAuth0Credentials(credentials: result), nil) }catch { diff --git a/packages/nativescript-auth0/typings/android.d.ts b/packages/nativescript-auth0/typings/android.d.ts index 015d4af..a801747 100644 --- a/packages/nativescript-auth0/typings/android.d.ts +++ b/packages/nativescript-auth0/typings/android.d.ts @@ -158,8 +158,8 @@ declare module io { public static class: java.lang.Class; public getAuth0(): com.auth0.android.Auth0; public constructor(auth0: com.auth0.android.Auth0); - public clearSession(it: globalAndroid.content.Context, value: string, it: boolean, logout: string, this_: any): void; - public start(it: globalAndroid.content.Context, value: string, it: string, value: string, it: string, value: any): void; + public clearSession(context: globalAndroid.content.Context, scheme: string, federated: boolean, returnToUrl: string, callback: any): void; + public start(context: globalAndroid.content.Context, scheme: string, scope: string, audience: string, redirectUrl: string, parameters: java.util.Map, callback: any): void; } } } diff --git a/packages/nativescript-auth0/typings/ios.d.ts b/packages/nativescript-auth0/typings/ios.d.ts index 9eae1e7..1a03334 100644 --- a/packages/nativescript-auth0/typings/ios.d.ts +++ b/packages/nativescript-auth0/typings/ios.d.ts @@ -157,7 +157,7 @@ declare class NSCAuth0WebAuth extends NSObject { clearSessionWithFederated(federated: boolean, callback: (p1: NSError) => void): void; - start(scope: string, audience: string, callback: (p1: NSCAuth0Credentials, p2: NSError) => void): void; + start(scope: string, audience: string, parameters: NSDictionary, callback: (p1: NSCAuth0Credentials, p2: NSError) => void): void; useHTTPS(): NSCAuth0WebAuth; } diff --git a/tools/assets/App_Resources/Android/app.gradle b/tools/assets/App_Resources/Android/app.gradle index 07a7c50..31101f2 100644 --- a/tools/assets/App_Resources/Android/app.gradle +++ b/tools/assets/App_Resources/Android/app.gradle @@ -18,6 +18,7 @@ android { targetSdkVersion 35 generatedDensities = [] multiDexEnabled true + manifestPlaceholders = [auth0Domain: "nstudio.auth0.com", auth0Scheme: "io.nstudio.plugindemo.auth0"] } aaptOptions { additionalParameters "--no-version-vectors" diff --git a/tools/assets/App_Resources/Android/src/main/AndroidManifest.xml b/tools/assets/App_Resources/Android/src/main/AndroidManifest.xml index 54d1a64..7837aba 100644 --- a/tools/assets/App_Resources/Android/src/main/AndroidManifest.xml +++ b/tools/assets/App_Resources/Android/src/main/AndroidManifest.xml @@ -49,6 +49,20 @@ + + + + + + + + + + + + + +