Skip to content

Commit

Permalink
feat: oauth with catching
Browse files Browse the repository at this point in the history
  • Loading branch information
alerdenisov committed Jan 12, 2024
1 parent 92f2c47 commit 6aaeb52
Show file tree
Hide file tree
Showing 8 changed files with 9 additions and 7 deletions.
2 changes: 1 addition & 1 deletion packages/pieces/cryptomus/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@tookey-io/piece-cryptomus",
"version": "0.0.3"
"version": "0.0.4"
}
2 changes: 1 addition & 1 deletion packages/pieces/instant-form/package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
{
"name": "@tookey-io/piece-instant-form",
"version": "0.0.1"
"version": "0.0.2"
}
2 changes: 1 addition & 1 deletion packages/pieces/instant-form/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@ const catchQuery = new URLSearchParams({

export const InstantFormAuth = PieceAuth.OAuth2({
required: true,
authUrl: `https://0329-64-226-96-123.ngrok-free.app/catch_code?${catchQuery.toString()}`,
authUrl: `{{window.location.origin}}/catch_code?${catchQuery.toString()}`,
tokenUrl: 'https://instantlyform.com/webBot/oauth/token',
scope: [
'all'
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export const environment ={
jwtTokenName: 'token',
redirectUrl: window.location.origin,
backendUrl: isProductionEnv() ? 'https://backend.production.tookey.cloud' : 'https://backend.develop.tookey.cloud',
frontendUrl: isProductionEnv() ? 'https://automation.production.tookey.cloud' : 'https://automation.develop.tookey.cloud',
userPropertyNameInLocalStorage: 'currentUser',
websiteTitle: 'Tookey Automation',
activateBeamer: true,
Expand Down
1 change: 1 addition & 0 deletions packages/ui/common/src/lib/environments/environment.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ export const environment = {
jwtTokenName: 'token',
redirectUrl: 'http://127.0.0.1:4200/redirect',
backendUrl: 'http://127.0.0.1:3001',
frontendUrl: 'https://0329-64-226-96-123.ngrok-free.app',
userPropertyNameInLocalStorage: 'currentUser',
activateBeamer: true,
showDocsButton: true,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ export class CatchCodeComponent implements OnInit {
ngOnInit(): void {
const fillTemplates = (value: string | undefined, params: Params) => {
if (typeof value !== 'string') return undefined;
let replaced = value;
let replaced = value.replaceAll('{{window.location.origin}}', window.location.origin);
Object.entries(params)
.filter((pair): pair is [string, string] => typeof pair[1] === 'string')
.map(([key, value]) => (replaced = replaced.replaceAll(`{{${key}}}`, value)));
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ export class ManagedOAuth2ConnectionDialogComponent implements OnInit {
//TODO: decide whether redirect URL should be decided like this or some other way
this.dialogData.connectionType === AppConnectionType.PLATFORM_OAUTH2
? this.dialogData.frontendUrl + '/redirect'
: environment.secretsUrl + '/redirect',
: environment.frontendUrl + '/redirect',
scope: this.dialogData.pieceAuthProperty.scope.join(' '),
pkce: this.dialogData.pieceAuthProperty.pkce,
extraParams: this.dialogData.pieceAuthProperty.extra || {},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ export class Oauth2Service {
const queryParams: Record<string, string> = {
response_type: 'code',
client_id: request.client_id,
redirect_uri: request.redirect_url || environment.redirectUrl,
redirect_uri: request.redirect_url?.replaceAll('{{window.location.origin}}', window.location.origin) || environment.redirectUrl,
access_type: 'offline',
state: nanoid(),
prompt: 'consent',
Expand All @@ -66,7 +66,7 @@ export class Oauth2Service {
queryParams['code_challenge'] = code_challenge;
}

const url = new URL(request.auth_url);
const url = new URL(request.auth_url.replaceAll('{{window.location.origin}}', window.location.origin));

Object.entries(queryParams).forEach(([key, value]) => {
url.searchParams.append(key, value);
Expand Down

0 comments on commit 6aaeb52

Please sign in to comment.