Skip to content

Commit fb6e173

Browse files
authored
feat!: update auth.createRegisterTransaction and user.revokeDevice signatures to use two separate arguments (#83)
1 parent db0586b commit fb6e173

File tree

6 files changed

+14
-22
lines changed

6 files changed

+14
-22
lines changed

src/classes/Auth/Auth.spec.ts

+1-4
Original file line numberDiff line numberDiff line change
@@ -15,10 +15,7 @@ describe('Auth e2e', () => {
1515

1616
describe('createRegisterTransaction', () => {
1717
it('should return the transaction ID', async () => {
18-
const transactionId = await passage.auth.createRegisterTransaction({
19-
externalId: 'test',
20-
passkeyDisplayName: 'test',
21-
});
18+
const transactionId = await passage.auth.createRegisterTransaction('test', 'test');
2219
expect(transactionId).toEqual(expect.any(String));
2320
});
2421
});

src/classes/Auth/Auth.ts

+7-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
import { AuthenticateApi, TransactionsApi } from '../../generated';
22
import { PassageBase, PassageInstanceConfig } from '../PassageBase';
3-
import { RegisterTransactionArgs } from './types';
43

54
/**
65
* Auth class that provides methods for creating and validating passkey transactions.
@@ -22,14 +21,18 @@ export class Auth extends PassageBase {
2221
/**
2322
* Create a transaction to start a user's registration process
2423
*
25-
* @param {RegisterTransactionArgs} args The required values to create a transaction
24+
* @param {string} externalId The external ID of the user to register
25+
* @param {string} passkeyDisplayName The display name of the passkey to use
2626
* @return {Promise<string>} The transaction ID
2727
*/
28-
public async createRegisterTransaction(args: RegisterTransactionArgs): Promise<string> {
28+
public async createRegisterTransaction(externalId: string, passkeyDisplayName: string): Promise<string> {
2929
try {
3030
const response = await this.transactionClient.createRegisterTransaction({
3131
appId: this.config.appId,
32-
registerTransactionArgs: args,
32+
registerTransactionArgs: {
33+
externalId,
34+
passkeyDisplayName,
35+
},
3336
});
3437

3538
return response.transactionId;

src/classes/Auth/index.ts

-1
Original file line numberDiff line numberDiff line change
@@ -1,2 +1 @@
11
export * from './Auth';
2-
export * from './types';

src/classes/Auth/types.ts

-3
This file was deleted.

src/classes/User/User.ts

+6-5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { ResponseError, UserDevicesApi, UserInfo, UsersApi, WebAuthnDevices } from '../../generated';
22
import { PassageBase, PassageInstanceConfig } from '../PassageBase';
3-
import { PassageUser, RevokeDeviceArgs } from './types';
3+
import { PassageUser } from './types';
44

55
/**
66
* User class for handling operations to get and update user information.
@@ -77,16 +77,17 @@ export class User extends PassageBase {
7777
/**
7878
* Revoke a user's device by their external ID and the device ID
7979
*
80-
* @param {RevokeDeviceArgs} args The external ID used to associate the user with Passage and the device ID
80+
* @param {string} externalId The external ID of the user whose device to revoke
81+
* @param {string} deviceId The device ID to revoke
8182
* @return {Promise<void>}
8283
*/
83-
public async revokeDevice(args: RevokeDeviceArgs): Promise<void> {
84+
public async revokeDevice(externalId: string, deviceId: string): Promise<void> {
8485
try {
85-
const user = await this.get(args.externalId);
86+
const user = await this.get(externalId);
8687
await this.deviceClient.deleteUserDevices({
8788
appId: this.config.appId,
88-
deviceId: args.deviceId,
8989
userId: user.id,
90+
deviceId,
9091
});
9192
} catch (err) {
9293
throw await this.parseError(err);

src/classes/User/types.ts

-5
Original file line numberDiff line numberDiff line change
@@ -14,9 +14,4 @@ export interface PassageUser {
1414
webauthnTypes: WebAuthnType[];
1515
}
1616

17-
export interface RevokeDeviceArgs {
18-
externalId: string;
19-
deviceId: string;
20-
}
21-
2217
export { UserStatus, WebAuthnDevices, WebAuthnType, WebAuthnIcons };

0 commit comments

Comments
 (0)