Skip to content

Commit

Permalink
Change out variable name for back end consumption
Browse files Browse the repository at this point in the history
  • Loading branch information
chrisdakin-magic committed Oct 10, 2023
1 parent 490119f commit 089c4df
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 14 deletions.
8 changes: 4 additions & 4 deletions packages/@magic-sdk/provider/src/modules/auth.ts
Original file line number Diff line number Diff line change
Expand Up @@ -49,11 +49,11 @@ export class AuthModule extends BaseModule {
}).log();
}

const { email, showUI = true, redirectURI, customTemplateName } = configuration;
const { email, showUI = true, redirectURI, variation } = configuration;

const requestPayload = createJsonRpcRequestPayload(
this.sdk.testMode ? MagicPayloadMethod.LoginWithMagicLinkTestMode : MagicPayloadMethod.LoginWithMagicLink,
[{ email, showUI, redirectURI, customTemplateName }],
[{ email, showUI, redirectURI, variation }],
);
return this.request<string | null, LoginWithMagicLinkEventHandlers>(requestPayload);
}
Expand All @@ -78,10 +78,10 @@ export class AuthModule extends BaseModule {
* of 15 minutes)
*/
public loginWithEmailOTP(configuration: LoginWithEmailOTPConfiguration) {
const { email, showUI, deviceCheckUI, customTemplateName } = configuration;
const { email, showUI, deviceCheckUI, variation } = configuration;
const requestPayload = createJsonRpcRequestPayload(
this.sdk.testMode ? MagicPayloadMethod.LoginWithEmailOTPTestMode : MagicPayloadMethod.LoginWithEmailOTP,
[{ email, showUI, deviceCheckUI, customTemplateName }],
[{ email, showUI, deviceCheckUI, variation }],
);
const handle = this.request<string | null, LoginWithEmailOTPEventHandlers>(requestPayload);
if (!deviceCheckUI && handle) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,16 +37,16 @@ test('Generates JSON RPC request payload with `showUI: false` parameter', async
expect(requestPayload.params).toEqual([{ email: expectedEmail, showUI: false }]);
});

test('Generates JSON RPC request payload with `customTemplateName` parameter', async () => {
test('Generates JSON RPC request payload with `variation` parameter', async () => {
const magic = createMagicSDK();
magic.auth.request = jest.fn();

await magic.auth.loginWithEmailOTP({ email: expectedEmail, customTemplateName: 'my custom template' });
await magic.auth.loginWithEmailOTP({ email: expectedEmail, variation: 'my custom template' });

const requestPayload = magic.auth.request.mock.calls[0][0];
expect(requestPayload.jsonrpc).toBe('2.0');
expect(requestPayload.method).toBe(MagicPayloadMethod.LoginWithEmailOTP);
expect(requestPayload.params).toEqual([{ email: expectedEmail, customTemplateName: 'my custom template' }]);
expect(requestPayload.params).toEqual([{ email: expectedEmail, variation: 'my custom template' }]);
});

test('If `testMode` is enabled, testing-specific RPC method is used', async () => {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,16 @@ test('Generates JSON RPC request payload with `redirectURI` parameter', async ()
expect(requestPayload.params).toEqual([{ email: 'test', showUI: true, redirectURI: 'helloworld' }]);
});

test('Generates JSON RPC request payload with `customTemplateName` parameter', async () => {
test('Generates JSON RPC request payload with `variation` parameter', async () => {
const magic = createMagicSDK();
magic.auth.request = jest.fn();

await magic.auth.loginWithMagicLink({ email: 'test', showUI: true, customTemplateName: 'my custom template' });
await magic.auth.loginWithMagicLink({ email: 'test', showUI: true, variation: 'my custom template' });

const requestPayload = magic.auth.request.mock.calls[0][0];
expect(requestPayload.jsonrpc).toBe('2.0');
expect(requestPayload.method).toBe(MagicPayloadMethod.LoginWithMagicLink);
expect(requestPayload.params).toEqual([{ email: 'test', showUI: true, customTemplateName: 'my custom template' }]);
expect(requestPayload.params).toEqual([{ email: 'test', showUI: true, variation: 'my custom template' }]);
});

test('If `testMode` is enabled, testing-specific RPC method is used', async () => {
Expand Down
8 changes: 4 additions & 4 deletions packages/@magic-sdk/types/src/modules/auth-types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,9 @@ export interface LoginWithMagicLinkConfiguration {
/**
* Enterprise users with a custom SMTP can create custom email templates
* from their dashboard. The default Magic loginWithMagicLink email will be
* overriden when a customTemplateName is passed here.
* overriden when a variation is passed here.
*/
customTemplateName?: string;
variation?: string;
}

export interface LoginWithSmsConfiguration {
Expand Down Expand Up @@ -65,9 +65,9 @@ export interface LoginWithEmailOTPConfiguration {
/**
* Enterprise users with a custom SMTP can create custom email templates
* from their dashboard. The default Magic loginWithOTP email will be
* overriden when a customTemplateName is passed here.
* overriden when a variation is passed here.
*/
customTemplateName?: string;
variation?: string;
}

/**
Expand Down

0 comments on commit 089c4df

Please sign in to comment.