Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions packages/nativescript-auth0/index.android.ts
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,7 @@ export class CredentialsManager {
resolve(Credentials.fromNative(credentials));
}
},
})
}),
);
});
}
Expand Down Expand Up @@ -145,14 +145,15 @@ 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<string, string> }) {
return new Promise<Credentials>((resolve, reject) => {
this.webAuth.start(
Utils.android.getCurrentActivity(),
options?.scheme ?? null,
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) {
Expand All @@ -161,7 +162,7 @@ export class WebAuth {
resolve(Credentials.fromNative(credentials));
}
},
})
}),
);
});
}
Expand All @@ -181,7 +182,7 @@ export class WebAuth {
resolve();
}
},
})
}),
);
});
}
Expand Down Expand Up @@ -397,7 +398,7 @@ export class Authentication {
resolve(UserInfo.fromNative(userInfo));
}
},
})
}),
);
});
}
Expand All @@ -417,7 +418,7 @@ export class Authentication {
resolve(Credentials.fromNative(credentials));
}
},
})
}),
);
});
}
Expand All @@ -435,7 +436,7 @@ export class Authentication {
resolve();
}
},
})
}),
);
});
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nativescript-auth0/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ export class WebAuth {

useHTTPS(): this;

start(options?: { scheme?: string; scope?: string; audience?: string; redirectUrl?: string }): Promise<Credentials>;
start(options?: { scheme?: string; scope?: string; audience?: string; redirectUrl?: string; parameters?: Record<string, string> }): Promise<Credentials>;

clear(options?: { scheme?: string; federated?: boolean; returnToUrl?: string }): Promise<void>;
}
Expand Down
4 changes: 2 additions & 2 deletions packages/nativescript-auth0/index.ios.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string> }) {
return new Promise<Credentials>((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 {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@ class WebAuth(val auth0: com.auth0.android.Auth0) {
scope: String?,
audience: String?,
redirectUrl: String?,
parameters: Map<String, String>?,
callback: (Credentials?, Exception?) -> Void
) {
val login =
Expand All @@ -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<Credentials, AuthenticationException> {
override fun onFailure(error: AuthenticationException) {
callback(null, error)
Expand Down
Binary file not shown.
5 changes: 4 additions & 1 deletion packages/nativescript-auth0/platforms/ios/src/NSCAuth0.swift
Original file line number Diff line number Diff line change
Expand Up @@ -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 {
Expand All @@ -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 {
Expand Down
4 changes: 2 additions & 2 deletions packages/nativescript-auth0/typings/android.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -158,8 +158,8 @@ declare module io {
public static class: java.lang.Class<io.nstudio.plugins.auth0.WebAuth>;
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<string, string>, callback: any): void;
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion packages/nativescript-auth0/typings/ios.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, string>, callback: (p1: NSCAuth0Credentials, p2: NSError) => void): void;

useHTTPS(): NSCAuth0WebAuth;
}
1 change: 1 addition & 0 deletions tools/assets/App_Resources/Android/app.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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"
Expand Down
14 changes: 14 additions & 0 deletions tools/assets/App_Resources/Android/src/main/AndroidManifest.xml
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,20 @@
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="io.nstudio.plugindemo.auth0" />
</intent-filter>
<intent-filter>
<action android:name="android.intent.action.VIEW" />
<category android:name="android.intent.category.DEFAULT" />
<category android:name="android.intent.category.BROWSABLE" />

<data android:scheme="io.nstudio.plugindemo" />
</intent-filter>
</activity>
<activity android:name="com.tns.ErrorReportActivity"/>
</application>
Expand Down