Skip to content

Commit fb9c74b

Browse files
committed
sender input validation
1 parent e0a677b commit fb9c74b

1 file changed

Lines changed: 8 additions & 3 deletions

File tree

‎src/lib/sdkUtils.ts‎

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,6 +13,7 @@ export type DnsRecord = {
1313
};
1414

1515
export type DomainRegistration = {
16+
domain: string;
1617
id: number;
1718
valid: boolean;
1819
records: {
@@ -49,8 +50,12 @@ function toDnsRecord(record?: Partial<DnsRecord>): DnsRecord {
4950
};
5051
}
5152

52-
function toDomainRegistration(res: RegisterDomainResponse): DomainRegistration {
53+
function toDomainRegistration(
54+
res: RegisterDomainResponse,
55+
domain: string,
56+
): DomainRegistration {
5357
return {
58+
domain,
5459
id: res.id,
5560
// The gateway returns `valid` as the string "true" / "false".
5661
valid: String(res.valid) === "true",
@@ -154,7 +159,7 @@ export async function registerJunoDomain(
154159
success: true,
155160
message:
156161
"Domain registered! Add the DNS records below at your DNS provider, then verify.",
157-
domain: toDomainRegistration(res),
162+
domain: toDomainRegistration(res, domain.trim()),
158163
};
159164
} catch (e) {
160165
console.error(e);
@@ -198,7 +203,7 @@ export async function verifyJunoDomain(
198203
},
199204
);
200205

201-
const registration = toDomainRegistration(res);
206+
const registration = toDomainRegistration(res, domain.trim());
202207
return {
203208
success: true,
204209
message: registration.valid

0 commit comments

Comments
 (0)