Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add replacement_for_certificate to Create Certificate api #10

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from 3 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions dist/lib/types.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export type CreateCertificateOptions = {
domains: string[];
validityDays: 90 | 365;
strictDomains: boolean;
replacementForCertificate?: string;
};
export type KeyPair = {
publicKey: string;
Expand Down
2 changes: 2 additions & 0 deletions dist/lib/zerossl.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,8 @@ var ZeroSSL = (function () {
.field('certificate_csr', options.csr)
.field('certificate_validity_days', options.validityDays)
.field('strict_domains', options.strictDomains);
if (options.replacementForCertificate)
postFn = postFn.field('replacement_for_certificate', options.replacementForCertificate);
return [4, this.performRequest(postFn)];
case 1:
result = _a.sent();
Expand Down
1 change: 1 addition & 0 deletions lib/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,7 @@ export type CreateCertificateOptions = {
domains: string[]
validityDays: 90 | 365
strictDomains: boolean
replacementForCertificate?: string
}

export type KeyPair = {
Expand Down
4 changes: 3 additions & 1 deletion lib/zerossl.ts
Original file line number Diff line number Diff line change
Expand Up @@ -51,12 +51,14 @@ export class ZeroSSL {
const qs = this.queryString({ access_key: this.options.accessKey })
const url = `${this.options.apiUrl}/certificates?${qs}`

const postFn = superagent.post(url)
let postFn = superagent.post(url)
.type('form')
.field('certificate_domains', options.domains.join(','))
.field('certificate_csr', options.csr)
.field('certificate_validity_days', options.validityDays)
.field('strict_domains', options.strictDomains)

if (options.replacementForCertificate) postFn = postFn.field('replacement_for_certificate', options.replacementForCertificate as string)
dantheman2865 marked this conversation as resolved.
Show resolved Hide resolved

const result = await this.performRequest(postFn)
return result.body as CertificateRecord
Expand Down