Skip to main content

Hello,

I'm developing an application using the eSignature REST API (via the Node.js SDK) and facing an issue with embedded signing. The `signing_complete` event is not being sent from the DocuSign iFrame to my parent application via `postMessage`.

Here is my current setup and what I've tried so far:

**Workflow:**

1.  **Server-Side (Node.js/SvelteKit):**
    *   I create an envelope successfully.
    *   I call `envelopesApi.createRecipientView()` to generate a `recipientViewUrl` for an embedded signer.
    *   Crucially, I am including `frameAncestors` and `messageOrigins` in the `recipientViewRequest` pointing to my local development origin (`http://localhost:5173`).

    ```javascript
    // Simplified server-side code
    const viewRequest = {
        returnUrl: `https://example.com/docusign/return`, // A simple fallback page
        authenticationMethod: 'none',
        email: user.email,
        userName: user.name,
        clientUserId: user.id,
        // @ts-ignore - Types are missing, but API should support these
        frameAncestors: ['http://localhost:5173'],
        messageOrigins: ['http://localhost:5173']
    };

    const recipientView = await envelopeApi.createRecipientView(accountId, envelopeId, { recipientViewRequest: viewRequest });
    // This successfully returns a URL.
    ```

2.  **Client-Side (Svelte):**
    *   My application receives the `recipientViewUrl`.
    *   I display this URL within an `<iframe>` inside a modal dialog.
    *   I have a global `message` event listener attached to the `window` to listen for events from the iFrame.

    ```javascript
    // Simplified client-side code
    onMount(() => {
        const handleMessage = (event) => {
            const DOCUSIGN_ORIGIN = 'https://demo.docusign.net';
            
            // For debugging, I log all messages
            console.log(`MESSAGE RECEIVED: Origin: ${event.origin}, Data:`, event.data);

            if (event.origin !== DOCUSIGN_ORIGIN) {
                return; // Ignore messages from other origins
            }

            if (event.data?.source === 'docusign' && event.data?.event === 'signing_complete') {
                console.log('Signing complete!');
                // This part is never reached.
            }
        };

        window.addEventListener('message', handleMessage);
        return () => window.removeEventListener('message', handleMessage);
    });
    ```

**The Problem:**

*   The signing ceremony inside the iFrame works perfectly.
*   After the user signs, the iFrame correctly redirects to the `returnUrl`.
*   However, **no `postMessage` with `{ source: 'docusign', event: 'signing_complete' }` is ever received** by the parent window. The only messages I capture are from browser extensions like MetaMask.

**What I Have Ruled Out:**

*   **Incorrect Origin Check:** My listener logs all messages before filtering by origin, and no message from `https://demo.docusign.net` is ever logged.
*   **DocuSign JS SDK:** I have tried various DocuSign JS libraries, but they all failed to load (404 Not Found), suggesting they might be for different products (like Web Forms) and not for eSignature Recipient View. I have reverted to a basic iFrame implementation as it seems to be the standard approach.
*   **Code Issues:** The workflow seems to follow the recommended pattern. The issue appears to be environmental.

**My Hypothesis:**

Based on my extensive troubleshooting, I believe my developer account (`demo.docusign.net`) is missing a security setting that allows cross-domain `postMessage` communication from the embedded signing iFrame, even when `frameAncestors` and `messageOrigins` are specified in the API call. I cannot find any such setting in the Admin UI under "Security Settings" or "Connect".

**Question:**

1.  Is there a specific account-level setting in the DocuSign Admin that needs to be enabled to allow the Recipient View iFrame to `postMessage` events like `signing_complete` to the parent window?
2.  If so, where can I find it, or does it require intervention from DocuSign Support to be enabled?

Any help would be greatly appreciated. Thank you!

Be the first to reply!