Skip to content

Commit

Permalink
feat: add asigna iframe connect (#400)
Browse files Browse the repository at this point in the history
* added integration with Asigna via iframe

* changed asigna provider data

* fixed check for asigna iframe

* chore: update lint errors

* chore: add changeset

---------

Co-authored-by: jeffrystone <[email protected]>
Co-authored-by: janniks <[email protected]>
  • Loading branch information
3 people authored Jan 8, 2025
1 parent a2939ca commit d6ea424
Show file tree
Hide file tree
Showing 4 changed files with 45 additions and 4 deletions.
6 changes: 6 additions & 0 deletions .changeset/smart-dingos-train.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
---
'@stacks/connect-ui': minor
'@stacks/connect': minor
---

Add iframe capable Asigna provider.
2 changes: 1 addition & 1 deletion packages/connect-ui/src/components/modal/modal.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -204,7 +204,7 @@ export class Modal {
rel="noopener noreferrer"
target="_blank"
>
Install &rarr;
{provider.id === 'AsignaProvider' ? 'Open' : 'Install'} &rarr;
</a>
)}
</li>
Expand Down
33 changes: 33 additions & 0 deletions packages/connect/src/asigna.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
const source = 'asigna-stx';

const generateCall = (payload: string, key: string) => {
return new Promise(res => {
function listener(message: MessageEvent<any>) {
if (message.data.source === source && message.data[key]) {
res(message.data[key]);
window.removeEventListener('message', listener);
}
}
window.addEventListener('message', listener);
window.top.postMessage(generateAsignaMessage(payload, key), '*');
});
};

const AsignaIframeProvider = {
authenticationRequest: async (payload: string) => {
return generateCall(payload, 'authenticationRequest');
},
transactionRequest: async (payload: string) => {
return generateCall(payload, 'transactionRequest');
},
};
const generateAsignaMessage = (payload: string, key: string) => {
return { source, [key]: payload };
};

export const initializeAsignaProvider = () => {
const isAsignaIframe = !!window.top && document.referrer.endsWith('.asigna.io/');
if (isAsignaIframe) {
window['AsignaProvider'] = AsignaIframeProvider;
}
};
8 changes: 5 additions & 3 deletions packages/connect/src/providers.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,7 @@
import { WebBTCProvider } from '@stacks/connect-ui';
import { initializeAsignaProvider } from './asigna';

initializeAsignaProvider();

export const DEFAULT_PROVIDERS: WebBTCProvider[] = [
{
Expand All @@ -25,10 +28,9 @@ export const DEFAULT_PROVIDERS: WebBTCProvider[] = [
},
{
id: 'AsignaProvider',
name: 'Asigna',
name: 'Asigna Multisig',
icon: 'data:image/svg+xml;base64,PHN2ZyB4bWxucz0iaHR0cDovL3d3dy53My5vcmcvMjAwMC9zdmciIHdpZHRoPSIzMiIgaGVpZ2h0PSIzMiIgZmlsbD0ibm9uZSI+PHBhdGggZmlsbD0iIzAwMDEwMCIgZD0iTTAgMGgzMnYzMkgweiIvPjxwYXRoIGZpbGw9InVybCgjYSkiIGQ9Ik0xNS4xMSA1LjU1YTMgMyAwIDAgMC0xLjgyIDEuM2wtLjA1LjA4LS40My43Mi0uMDcuMTEtLjUuODUtLjA1LjA5LTEuMjkgMi4xOC0uMDQuMDctLjQ3LjgtLjA2LjEtLjQ2Ljc4LS4wNy4xMS0xLjYzIDIuNzYtLjA3LjExLS4zOC42Ni0uMDUuMDgtLjczIDEuMjQtLjM1LjYtLjQuNjctLjA1LjA5TDUuMSAyMC43bC0uMTEuMTgtLjE0LjIzLS4wNy4xMy0uMzMuNTUtLjA0LjA3di4wMWExLjI2IDEuMjYgMCAwIDAtLjE0LjQ3IDEuMzEgMS4zMSAwIDAgMCAxLjI0IDEuNGgxLjVsLjA1LS4wNi4wNC0uMDYuODctMS4yMS4wNS0uMDguNzctMS4wNy4wNS0uMDcuNC0uNTcuMDUtLjA2LjI0LS4zNGExLjUyIDEuNTIgMCAwIDEgMS4zOS0uNjIgMS41IDEuNSAwIDAgMSAuNjQuMiAxLjQ3IDEuNDcgMCAwIDEgLjczIDEuMjcgMS40NCAxLjQ0IDAgMCAxLS4yNy44NGwtLjYzLjg4LS4wNS4wNy0uMzIuNDUtLjA2LjA4LS4wOC4xMi0uMTIuMTYtLjA1LjA4aDIuMTNhMi4zMiAyLjMyIDAgMCAwIDEuNzctL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com/detail/asigna-multisig/gopddoinbenlokghakiafackadkbnlid',
chromeWebStoreUrl: 'https://stx.asigna.io/',
},
];

0 comments on commit d6ea424

Please sign in to comment.