-
Notifications
You must be signed in to change notification settings - Fork 3
feat: add Android support for captive signing with URL #3
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
Open
nikonhub
wants to merge
3
commits into
IronTony:main
Choose a base branch
from
nikonhub:main
base: main
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
+147
−30
Open
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,6 +1,7 @@ | ||
| // Stub the native module so tests never reach requireNativeModule. | ||
| // Individual test files override './api' directly via jest.mock. | ||
| jest.mock('./src/DocuSignModule', () => ({ | ||
| __esModule: true, | ||
| default: {}, | ||
| default: { | ||
| presentCaptiveSigningWithUrl: jest.fn(), | ||
| }, | ||
| })); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,22 @@ | ||
| import { expect, it, jest } from '@jest/globals'; | ||
| import DocuSignModule from './DocuSignModule'; | ||
| import { presentCaptiveSigningWithUrl } from './api'; | ||
|
|
||
| it('delegates presentCaptiveSigningWithUrl to the native module', () => { | ||
| const mockPresentCaptiveSigningWithUrl = jest.mocked( | ||
| DocuSignModule.presentCaptiveSigningWithUrl, | ||
| ); | ||
| const params = { | ||
| signingUrl: 'https://demo.docusign.net/signing/example', | ||
| envelopeId: 'envelope-id', | ||
| recipientId: 'recipient-id', | ||
| }; | ||
| const nativeResult = Promise.resolve({ | ||
| status: 'completed' as const, | ||
| envelopeId: params.envelopeId, | ||
| }); | ||
| mockPresentCaptiveSigningWithUrl.mockReturnValue(nativeResult); | ||
|
|
||
| expect(presentCaptiveSigningWithUrl(params)).toBe(nativeResult); | ||
| expect(mockPresentCaptiveSigningWithUrl).toHaveBeenCalledWith(params); | ||
| }); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -1,5 +1,3 @@ | ||
| import { Platform } from 'react-native'; | ||
|
|
||
| import { | ||
| CaptiveSigningParams, | ||
| CaptiveSigningUrlParams, | ||
|
|
@@ -41,21 +39,11 @@ export function presentCaptiveSigning( | |
| * encodes recipient identity via a short-lived token. {@link initialize} is | ||
| * still required. | ||
| * | ||
| * @platform iOS only. The Android DocuSign SDK (2.1.4) does not expose a | ||
| * public URL-based signing entry point; calling this on Android rejects with | ||
| * a clear JS error. For cross-platform parity, prefer {@link presentCaptiveSigning} | ||
| * with the session flow (accessToken + envelopeId + recipient). | ||
| * Supported on iOS and Android. | ||
| */ | ||
| export function presentCaptiveSigningWithUrl( | ||
| params: CaptiveSigningUrlParams, | ||
| ): Promise<SigningResult> { | ||
| if (Platform.OS !== 'ios') { | ||
| return Promise.reject( | ||
| new Error( | ||
| 'presentCaptiveSigningWithUrl is iOS-only. Use presentCaptiveSigning + loginWithAccessToken for Android parity.', | ||
| ), | ||
| ); | ||
| } | ||
| return DocuSignModule.presentCaptiveSigningWithUrl(params); | ||
| } | ||
|
Comment on lines
44
to
48
Owner
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A small The file's wider 0% coverage is pre-existing debt and not yours to fix here. |
||
|
|
||
|
|
||
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No validation on
signingUrl, and the SDK does none on this path.From the 2.1.4 bytecode: the 4-arg session overload checks for an empty envelope ID and an empty client user ID, and reports failures through the listener. The 5-arg URL overload has no checks at all and calls
startActivityunconditionally.CaptiveSigningUrlRecord.signingUrldefaults to""when JS omits it, so a blank or malformed URL launches an empty signing activity, and the promise settles only if that activity happens to call the listener back.Add a guard next to this
isInitializedcheck: reject a blanksigningUrl, and ideally a non-https scheme.(iOS has the same gap, but that is pre-existing and not yours to fix here. Tracking it separately.)