Skip to content

Commit 9ed9e6f

Browse files
authored
Change to 5 sec delay when re-launching app clip (#61)
* Change to 5 sec delay when re-launching app clip * Add option to use deffered deep links on android from triggerReclaimFlow, and getRequestUrl * Bump patch version * Update docs
1 parent 83f622c commit 9ed9e6f

File tree

4 files changed

+40
-202
lines changed

4 files changed

+40
-202
lines changed

package.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "@reclaimprotocol/js-sdk",
3-
"version": "4.6.0",
3+
"version": "4.6.1",
44
"description": "Designed to request proofs from the Reclaim protocol and manage the flow of claims and witness interactions.",
55
"main": "dist/index.js",
66
"types": "dist/index.d.ts",

src/Reclaim.ts

Lines changed: 21 additions & 19 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ import {
99
InitSessionResponse,
1010
ClaimCreationType,
1111
ModalOptions,
12+
ReclaimFlowLaunchOptions,
1213
} from './utils/types'
1314
import { SessionStatus, DeviceType } from './utils/types'
1415
import { ethers } from 'ethers'
@@ -39,7 +40,6 @@ import { assertValidSignedClaim, createLinkWithTemplateData, getWitnessesForClai
3940
import { QRCodeModal } from './utils/modalUtils'
4041
import loggerModule from './utils/logger';
4142
import { getDeviceType, getMobileDeviceType, isMobileDevice } from './utils/device'
42-
import { Features } from './utils/apis/feature'
4343
import { canonicalStringify } from './utils/strings'
4444
const logger = loggerModule.logger
4545

@@ -196,7 +196,6 @@ export class ReclaimProofRequest {
196196
private modalOptions?: ModalOptions;
197197
private modal?: QRCodeModal;
198198
private readonly FAILURE_TIMEOUT = 30 * 1000; // 30 seconds timeout, can be adjusted
199-
private isNewLinkingEnabledAsync: Promise<boolean>
200199

201200
private constructor(applicationId: string, providerId: string, options?: ProofRequestOptions) {
202201
this.providerId = providerId;
@@ -243,12 +242,6 @@ export class ReclaimProofRequest {
243242
// Fetch sdk version from package.json
244243
this.sdkVersion = 'js-' + sdkVersion;
245244
logger.info(`Initializing client with applicationId: ${this.applicationId}`);
246-
247-
this.isNewLinkingEnabledAsync = Features.isNewLinkingEnabled({
248-
applicationId: applicationId,
249-
providerId: providerId,
250-
sessionId: this.sessionId,
251-
});
252245
}
253246

254247
/**
@@ -839,6 +832,7 @@ export class ReclaimProofRequest {
839832
* - Mobile Android: Returns Instant App URL (if useAppClip is enabled)
840833
* - Desktop/Other: Returns standard verification URL
841834
*
835+
* @param launchOptions - Optional launch configuration to override default behavior
842836
* @returns Promise<string> - The generated request URL
843837
* @throws {SignatureNotFoundError} When signature is not set
844838
*
@@ -848,7 +842,9 @@ export class ReclaimProofRequest {
848842
* // Share this URL with users or display as QR code
849843
* ```
850844
*/
851-
async getRequestUrl(): Promise<string> {
845+
async getRequestUrl(launchOptions?: ReclaimFlowLaunchOptions): Promise<string> {
846+
const options = launchOptions || this.options?.launchOptions || {};
847+
852848
logger.info('Creating Request Url')
853849
if (!this.signature) {
854850
throw new SignatureNotFoundError('Signature is not set.')
@@ -867,7 +863,9 @@ export class ReclaimProofRequest {
867863
const isIos = getMobileDeviceType() === DeviceType.IOS;
868864
if (!isIos) {
869865
let instantAppUrl = this.buildSharePageUrl(template);
870-
if (await this.isNewLinkingEnabledAsync) {
866+
const isDeferredDeeplinksFlowEnabled = options.canUseDeferredDeepLinksFlow ?? false;
867+
868+
if (isDeferredDeeplinksFlowEnabled) {
871869
instantAppUrl = instantAppUrl.replace("/verifier", "/link");
872870
}
873871
logger.info('Instant App Url created successfully: ' + instantAppUrl);
@@ -897,6 +895,7 @@ export class ReclaimProofRequest {
897895
* - Mobile Android: Redirects to Instant App
898896
* - Mobile iOS: Redirects to App Clip
899897
*
898+
* @param launchOptions - Optional launch configuration to override default behavior
900899
* @returns Promise<void>
901900
* @throws {SignatureNotFoundError} When signature is not set
902901
*
@@ -906,7 +905,9 @@ export class ReclaimProofRequest {
906905
* // The appropriate verification method will be triggered automatically
907906
* ```
908907
*/
909-
async triggerReclaimFlow(): Promise<void> {
908+
async triggerReclaimFlow(launchOptions?: ReclaimFlowLaunchOptions): Promise<void> {
909+
const options = launchOptions || this.options?.launchOptions || {};
910+
910911
if (!this.signature) {
911912
throw new SignatureNotFoundError('Signature is not set.')
912913
}
@@ -941,7 +942,7 @@ export class ReclaimProofRequest {
941942
if (mobileDeviceType === DeviceType.ANDROID) {
942943
// Redirect to instant app URL
943944
logger.info('Redirecting to Android instant app');
944-
await this.redirectToInstantApp();
945+
await this.redirectToInstantApp(options);
945946
} else if (mobileDeviceType === DeviceType.IOS) {
946947
// Redirect to app clip URL
947948
logger.info('Redirecting to iOS app clip');
@@ -1027,7 +1028,7 @@ export class ReclaimProofRequest {
10271028
}
10281029
}
10291030

1030-
private async redirectToInstantApp(): Promise<void> {
1031+
private async redirectToInstantApp(options: ReclaimFlowLaunchOptions): Promise<void> {
10311032
try {
10321033
let template = encodeURIComponent(JSON.stringify(this.templateData));
10331034
template = replaceAll(template, '(', '%28');
@@ -1036,7 +1037,9 @@ export class ReclaimProofRequest {
10361037
let instantAppUrl = this.buildSharePageUrl(template);
10371038
logger.info('Redirecting to Android instant app: ' + instantAppUrl);
10381039

1039-
if (await this.isNewLinkingEnabledAsync) {
1040+
const isDeferredDeeplinksFlowEnabled = options.canUseDeferredDeepLinksFlow ?? false;
1041+
1042+
if (isDeferredDeeplinksFlowEnabled) {
10401043
instantAppUrl = instantAppUrl.replace("/verifier", "/link");
10411044

10421045
// Construct Android intent deep link
@@ -1123,11 +1126,10 @@ export class ReclaimProofRequest {
11231126
// Redirect to app clip
11241127
window.location.href = appClipUrl;
11251128

1126-
if (Features.isFirstAttemptToLaunchAppClip()) {
1127-
setTimeout(() => {
1128-
window.location.href = appClipUrl;
1129-
}, 2000);
1130-
}
1129+
setTimeout(() => {
1130+
window.location.href = appClipUrl;
1131+
// 5 second delay to allow app clip to launch
1132+
}, 5 * 1000);
11311133
} catch (error) {
11321134
logger.info('Error redirecting to app clip:', error);
11331135
throw error;

src/utils/apis/feature.ts

Lines changed: 0 additions & 181 deletions
This file was deleted.

src/utils/types.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,26 @@ export type ProofRequestOptions = {
3838
extensionID?: string;
3939
providerVersion?: string;
4040
customSharePageUrl?: string;
41-
customAppClipUrl?: string
41+
customAppClipUrl?: string;
42+
launchOptions?: ReclaimFlowLaunchOptions;
4243
};
4344

45+
export type ReclaimFlowLaunchOptions = {
46+
/**
47+
* Enables deferred deep links for the Reclaim verification flow.
48+
*
49+
* When enabled, users without the verifier app installed will receive a deferred deep link
50+
* that automatically launches the verification flow after they install the app, ensuring
51+
* a seamless continuation of the verification process.
52+
*
53+
* **Platform Support:** Currently Android only
54+
*
55+
* **Default Behavior:** Opt-in during rollout phase. Will default to `true` for all apps
56+
* once fully released. See: https://blog.reclaimprotocol.org/posts/moving-beyond-google-play-instant
57+
*/
58+
canUseDeferredDeepLinksFlow?: boolean;
59+
}
60+
4461
// Modal customization options
4562
export type ModalOptions = {
4663
title?: string;

0 commit comments

Comments
 (0)