Skip to content

Commit

Permalink
Add displayName param to passkey signUp (#11)
Browse files Browse the repository at this point in the history
* Add displayName param to passkey signUp

* wip
  • Loading branch information
chrisfisher authored Dec 22, 2023
1 parent 681bf25 commit a4dd6df
Show file tree
Hide file tree
Showing 7 changed files with 17 additions and 8 deletions.
4 changes: 2 additions & 2 deletions android/build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,8 @@ dependencies {

implementation "androidx.browser:browser:1.2.0"

implementation("com.authsignal:authsignal-push-android:0.2.3")
implementation("com.authsignal:authsignal-passkey-android:0.1.3")
implementation("com.authsignal:authsignal-push-android:0.2.6")
implementation("com.authsignal:authsignal-passkey-android:0.1.6")
}

if (isNewArchitectureEnabled()) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -57,10 +57,10 @@ public void initialize(String tenantID, String baseURL, Promise promise) {
}

@ReactMethod
public void signUp(String token, String userName, Promise promise) {
public void signUp(String token, String userName, String displayName, Promise promise) {
if (authsignalPasskey != null) {
authsignalPasskey
.signUpAsync(token, userName)
.signUpAsync(token, userName, displayName)
.thenAcceptAsync(response -> {
if (response.getError() != null) {
promise.reject("signUp error", response.getError());
Expand Down
1 change: 1 addition & 0 deletions ios/AuthsignalPasskeyModule.m
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@ @interface RCT_EXTERN_MODULE(AuthsignalPasskeyModule, NSObject)

RCT_EXTERN_METHOD(signUp:(NSString)token
withUserName:(NSString)userName
withDisplayName:(NSString)displayName
resolver:(RCTPromiseResolveBlock)resolve
rejecter:(RCTPromiseRejectBlock)reject)

Expand Down
4 changes: 3 additions & 1 deletion ios/AuthsignalPasskeyModule.swift
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ class AuthsignalPasskeyModule: NSObject {
@objc func signUp(
_ token: NSString,
withUserName userName: NSString,
withDisplayName displayName: NSString,
resolver resolve: @escaping RCTPromiseResolveBlock,
rejecter reject: @escaping RCTPromiseRejectBlock
) -> Void {
Expand All @@ -34,9 +35,10 @@ class AuthsignalPasskeyModule: NSObject {

let tokenStr = token as String
let userNameStr = userName as String?
let displayNameStr = displayName as String?

Task.init {
let response = await authsignal!.signUp(token: tokenStr, userName: userNameStr)
let response = await authsignal!.signUp(token: tokenStr, userName: userNameStr, displayName: displayNameStr)

if (response.error != nil) {
reject("signUp error", response.error, nil)
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "react-native-authsignal",
"version": "0.3.3",
"version": "0.3.4",
"description": "The official Authsignal React Native library.",
"main": "lib/commonjs/index",
"module": "lib/module/index",
Expand Down
2 changes: 1 addition & 1 deletion react-native-authsignal.podspec
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ Pod::Spec.new do |s|
s.source_files = "ios/**/*.{h,m,mm,swift}"

s.dependency "React-Core"
s.dependency 'Authsignal', '0.2.0'
s.dependency 'Authsignal', '0.2.1'

# Don't install the dependencies when we run `pod install` in the old architecture.
if ENV['RCT_NEW_ARCH_ENABLED'] == '1' then
Expand Down
8 changes: 7 additions & 1 deletion src/passkey.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@ interface ConstructorArgs {
interface PasskeySignUpInput {
token: string;
userName?: string;
displayName?: string;
}

interface PasskeySignInInput {
Expand Down Expand Up @@ -46,11 +47,16 @@ export class AuthsignalPasskey {
async signUp({
token,
userName,
displayName,
}: PasskeySignUpInput): Promise<AuthsignalResponse<string>> {
await this.ensureModuleIsInitialized();

try {
const data = await AuthsignalPasskeyModule.signUp(token, userName);
const data = await AuthsignalPasskeyModule.signUp(
token,
userName,
displayName
);

return { data };
} catch (ex) {
Expand Down

0 comments on commit a4dd6df

Please sign in to comment.