Skip to content

Commit

Permalink
chore: Update JSDoc and print warning message if deprecated mode para…
Browse files Browse the repository at this point in the history
…meter is used to initialize FormSG SDK
  • Loading branch information
frankchn committed Jan 31, 2021
1 parent a3ce917 commit e132d0a
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,13 @@ import Crypto from './crypto'
/**
* Entrypoint into the FormSG SDK
* @param {PackageInitParams} config Package initialization config parameters
* @param {string} [config.publicKey] This public key is used to authenticate or verify signed objects passed into this package.
* @param {string?} [config.webhookSecretKey] Optional base64 secret key for signing webhooks
*//**
* Deprecated entrypoint into the FormSG SDK
*
* @deprecated since January 2021
* @param {PackageInitParams} config Package initialization config parameters
* @param {string?} [config.publicKey] Optional. If provided, this public key will be used instead to authenticate or verify signed objects passed into this package.
* @param {string?} [config.mode] Optional. Initializes public key used for verifying and decrypting in this package. If `config.signingPublicKey` is given, this param will be ignored.
* @param {string?} [config.webhookSecretKey] Optional base64 secret key for signing webhooks
Expand All @@ -20,6 +27,10 @@ export = function (config: PackageInitParams = {}) {
const verificationPublicKey =
publicKey || getVerificationPublicKey(mode || 'production')

if (typeof mode !== 'undefined') {
console.warn('Initializing the FormSG SDK is now deprecated. Please switch to the publicKey parameter instead.')
}

return {
webhooks: new Webhooks({
publicKey: encryptionPublicKey,
Expand Down

0 comments on commit e132d0a

Please sign in to comment.