diff --git a/lib/management/types.ts b/lib/management/types.ts index 9d7c0cee9..7b0315037 100644 --- a/lib/management/types.ts +++ b/lib/management/types.ts @@ -971,6 +971,9 @@ export interface UserOptions { familyName?: string; additionalLoginIds?: string[]; ssoAppIds?: string[]; + password?: string; + hashedPassword?: UserPasswordHashed; + seed?: string; } export type MgmtUserOptions = Omit< diff --git a/lib/management/user.test.ts b/lib/management/user.test.ts index c716272e4..7fdfa8dce 100644 --- a/lib/management/user.test.ts +++ b/lib/management/user.test.ts @@ -181,6 +181,61 @@ describe('Management User', () => { response: httpResponse, }); }); + + it('should send password and hashed password with options argument', async () => { + const httpResponse = { + ok: true, + json: () => mockMgmtUserResponse, + clone: () => ({ + json: () => Promise.resolve(mockMgmtUserResponse), + }), + status: 200, + }; + mockHttpClient.post.mockResolvedValue(httpResponse); + + const hashed: UserPasswordHashed = { + firebase: { + hash: 'h', + salt: 's', + saltSeparator: 'ss', + signerKey: 'sk', + memory: 14, + rounds: 8, + }, + }; + + const resp: SdkResponse = await management.user.create('loginId', { + email: 'a@b.c', + password: 'cleartext', + hashedPassword: hashed, + seed: 'totp-seed', + }); + + expect(mockHttpClient.post).toHaveBeenCalledWith(apiPaths.user.create, { + loginId: 'loginId', + email: 'a@b.c', + password: 'cleartext', + hashedPassword: { + firebase: { + hash: 'h', + salt: 's', + saltSeparator: 'ss', + signerKey: 'sk', + memory: 14, + rounds: 8, + }, + }, + seed: 'totp-seed', + roleNames: undefined, + }); + + expect(resp).toEqual({ + code: 200, + data: mockUserResponse, + ok: true, + response: httpResponse, + }); + }); }); describe('createTestUser', () => {