1.1.10 → 1.1.12 migration guide

Added windowMode to make it possible to login using a popup, making signUsing deprecated.

constructor

Old

var arkaneConnect = ArkaneConnect('MY_CLIENT_ID', {environment: 'staging', signUsing: 'POPUP'});

New

var arkaneConnect = ArkaneConnect('MY_CLIENT_ID', {environment: 'staging', windowMode: 'POPUP'});
  • windowMode will affect the login procedure AND the signing/linking/…​ . Default windowMode is POPUP.

  • signUsing will not affect the login procedure. ⇒ signUsing is deprecated (but still available for backwards compatibility), use windowMode instead ('REDIRECT' or 'POPUP')

check authenticated (no changes here)

arkaneConnect.checkAuthenticated().then((authenticatonResult) => {
	return authenticatonResult.authenticated((authObject) => {
        // authenticated, do stuff
	    console.log('username', authObject.idTokenParsed.name);
	    console.log('bearertoken', authObject.token);
	    arkaneConnect.addOnTokenRefreshCallback((newToken) => {
	    	// do something when bearertoken is refreshed
	    });
	}).notAuthenticated(() => {
        // NOT authenticated
        console.log('not logged in');
	});
});

Authenticate (do authentication when not authenticated)

REDIRECT

Code below will return a promise, but since it’s a redirect, it’s not possible to resolve it. The flow will come back to this page after the login flow. So starting again from the top (constructor).

arkaneConnect.authenticate({windowMode: 'REDIRECT'});

POPUP (New)

With the popup, the state of the page will not be lost, this means that after a successful login, you should run your 'authenticated' logic when this promise resolves.

arkaneConnect.authenticate({windowMode: 'POPUP'}).then((result) => {
    return authenticatonResult.authenticated((authObject) => {
        // authenticated, do stuff
        console.log('username', authObject.idTokenParsed.name);
        console.log('bearertoken', authObject.token);
        arkaneConnect.addOnTokenRefreshCallback((newToken) => {
            // do something when bearertoken is refreshed
        });
    }).notAuthenticated(() => {
        // NOT authenticated
        console.log('not logged in');
    });
});
Passing windowMode is optional, it will default to the windowMode passed to the constructor.

This will use the windowMode passed to the contructor. But can be overriden by passing windowMode as a property in the options parameter. arkaneConnect.linkWallets() will return a Promise that can be resolved when using the POPUP flow.

REDIRECT

arkaneConnect.linkWallets({windowMode: 'REDIRECT', redirectUri: 'https://mysite.com'});

POPUP

arkaneConnect.linkWallets({windowMode: 'POPUP'}).then((result) => {
    console.log(result, 'link-wallets finished');
}).catch((result) => {
    console.error(result, 'link-wallets');
});

Manage Wallets

This will use the windowMode passed to the contructor. But can be overriden by passing windowMode as a property in the options parameter. arkaneConnect.manageWallets() will return a Promise that can be resolved when using the POPUP flow.

REDIRECT

arkaneConnect.manageWallets(chain, {windowMode: 'REDIRECT', redirectUri: app.redirectUri});

POPUP

arkaneConnect.manageWallets('ETHEREUM', {windowMode: 'POPUP'}).then((result) => {
    console.log(result, 'manage-wallets finished');
}).catch((result) => {
    console.error(result, 'manage-wallets');
});

Signer

If signUsing (deprecated) is passed to the ArkaneConnect constructor, the signer will use that above windowMode. This is for backwards compatibility. But it still can be overriden by passing windowMode as the only parameter when creating a Signer object.

REDIRECT

arkaneConnect.createSigner('REDIRECT').sign({...});

# arkaneConnect.createSigner('REDIRECT').executeNativeTransaction({...});
# arkaneConnect.createSigner('REDIRECT').executeTransaction({...})

POPUP

arkaneConnect.createSigner('POPUP').sign({...})
                                   .then((result) => { console.log('result', result); })
                                   .catch((err) => console.error(err));

# arkaneConnect.createSigner('POPUP').executeNativeTransaction({...})
#                                    .then((result) => { console.log('result', result); })
#                                    .catch((err) => console.error(err));
#
# arkaneConnect.createSigner('POPUP').executeTransaction({...})
#                                    .then((result) => { console.log('result', result); })
#                                    .catch((err) => console.error(err));
^