React Docusign Clickwrap 凭证

IT技术 reactjs typescript amazon-s3 docusignapi
2021-05-22 11:09:28

在我的 React 应用程序中,当我呈现 Docusign clickwrap 时,我需要提供 accountId 和 clickwrapId。是否有一种安全的方式来引用 accountId/clickwrapId 而不实际放入这些值。我不想在我的react应用程序中公开这些凭据


function App() {
  React.useLayoutEffect(() => {
    docuSignClick.Clickwrap.render({
      environment: 'https://demo.docusign.net',
      accountId: '...',
      clickwrapId: '...',

      onMustAgree(agreement) {
        // Called when no users have previously agreed by the above client user ID for the most recent required Clickwrap version
      },

      onAgreed(agreement) {
        // Called when either 1) the clientUserId has previously agreed 2) the clientUserId has clicked agree and completed successfully
      },

      onDeclined(agreement) {
        // Called when the clientUserId has declined successfully
      }
    }, '#ds-clickwrap');
  }, []);

  return <div id="ds-clickwrap" />
}
1个回答

啊,如果需要,您可以使用服务器端 API 来生成协议 URL。

POST /clickapi/v1/accounts/.../clickwraps/.../agreements:仅clientUserId需要进行此 API 调用。您可以从服务器执行此操作,然后将响应中的 URL 传递给客户端。

{
   "clientUserId": "..."
}

这将返回一个协议 URL,然后在 JS 代码段中使用:

{
   ...
   "status": "created",
   "agreementUrl": "https://...."
}

agreementUrl可能会在随后的片段中使用:

docuSignClick.render({
   agreementUrl: '...agreementUrl from REST API response...',

   onAgreed...
}, '#ds-clickwrap');