Skip to content

Commit

Permalink
Merge pull request #20 from reclaimprotocol/json-proof-response
Browse files Browse the repository at this point in the history
Added support to open app clip flow directly
  • Loading branch information
Kushal7788 authored Dec 26, 2024
2 parents d6c5374 + b49032d commit 6c26d97
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 4 deletions.
35 changes: 31 additions & 4 deletions src/Reclaim.ts
Original file line number Diff line number Diff line change
Expand Up @@ -165,6 +165,16 @@ export class ReclaimProofRequest {
{ paramName: 'log', input: options.log }
], 'the constructor')
}
if (options.useAppClip) {
validateFunctionParams([
{ paramName: 'useAppClip', input: options.useAppClip }
], 'the constructor')
}
if (options.device) {
validateFunctionParams([
{ paramName: 'device', input: options.device, isString: true }
], 'the constructor')
}

}

Expand Down Expand Up @@ -433,11 +443,28 @@ export class ReclaimProofRequest {
sdkVersion: this.sdkVersion,
jsonProofResponse: this.jsonProofResponse
}

const link = await createLinkWithTemplateData(templateData)
logger.info('Request Url created successfully: ' + link)
await updateSession(this.sessionId, SessionStatus.SESSION_STARTED)
return link
if (this.options?.useAppClip) {
let template = encodeURIComponent(JSON.stringify(templateData));
template = replaceAll(template, '(', '%28');
template = replaceAll(template, ')', '%29');

// check if the app is running on iOS or Android
const isIos = this.options?.device === 'ios';
if (!isIos) {
const instantAppUrl = `https://share.reclaimprotocol.org/verify/?template=${template}`;
logger.info('Instant App Url created successfully: ' + instantAppUrl);
return instantAppUrl;
} else {
const appClipUrl = `https://appclip.apple.com/id?p=org.reclaimprotocol.app.clip&template=${template}`;
logger.info('App Clip Url created successfully: ' + appClipUrl);
return appClipUrl;
}
} else {
const link = await createLinkWithTemplateData(templateData)
logger.info('Request Url created successfully: ' + link)
return link
}
} catch (error) {
logger.info('Error creating Request Url:', error)
throw error
Expand Down
2 changes: 2 additions & 0 deletions src/utils/types.ts
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,8 @@ export type OnError = (error: Error) => void;
export type ProofRequestOptions = {
log?: boolean;
acceptAiProviders?: boolean;
useAppClip?: boolean;
device?: string;
};

// Session and response types
Expand Down

0 comments on commit 6c26d97

Please sign in to comment.