diff --git a/README.md b/README.md index cbbedc0..065bcc5 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,10 @@ # Qubic Connect SDK +## Prerequisites + +Before getting started, you need to setup a project for allow domain, api key/secret you need and other stuff. +https://admin.qubic.market/developer + ## Installation ### Install from NPM @@ -90,6 +95,11 @@ const qubicConnect = new QubicConnect({ Login with redirect +First of all, you need to add domain in https://admin.qubic.market/developer. +This setting is not only for api CORS domains, but also allow list for redirect domains. + +For example, you can add `localhost:3000` for developing purpose. + ```ts function loginWithRedirect(options?: { walletType: LoginRedirectWalletType; diff --git a/lerna.json b/lerna.json index 07e5603..202b540 100644 --- a/lerna.json +++ b/lerna.json @@ -1,5 +1,5 @@ { "packages": ["packages/*"], "useNx": true, - "version": "0.11.0" + "version": "1.0.0" } diff --git a/packages/core/package.json b/packages/core/package.json index f57d846..1805c76 100644 --- a/packages/core/package.json +++ b/packages/core/package.json @@ -1,6 +1,6 @@ { "name": "@qubic-connect/core", - "version": "0.11.0", + "version": "1.0.0", "source": "./src/index.ts", "main": "./dist/index.js", "browser": "./dist/bundle.js", @@ -41,8 +41,8 @@ }, "dependencies": { "@ethersproject/providers": "^5.6.8", - "@qubic-connect/detect-iab": "^0.11.0", - "@qubic-connect/redirect": "^0.11.0", + "@qubic-connect/detect-iab": "^1.0.0", + "@qubic-connect/redirect": "^1.0.0", "@qubic-js/detect-inapp": "^1.4.1", "bignumber.js": "^9.0.2", "cross-fetch": "^3.1.5", diff --git a/packages/core/src/QubicConnect.ts b/packages/core/src/QubicConnect.ts index 9a76fa9..18d3bec 100644 --- a/packages/core/src/QubicConnect.ts +++ b/packages/core/src/QubicConnect.ts @@ -398,6 +398,7 @@ export class QubicConnect { walletType: options?.walletType, qubicSignInProvider: options?.qubicSignInProvider, redirectUrl, + apiKey: this.config.key, dataString, action: 'login', }); @@ -423,6 +424,7 @@ export class QubicConnect { walletType: options?.walletType, qubicSignInProvider: options?.qubicSignInProvider, redirectUrl, + apiKey: this.config.key, dataString, clientTicket: response.clientTicketIssue.ticket, action: 'bind', @@ -676,6 +678,7 @@ export class QubicConnect { url: `${walletUrl}/verify-user-address`, query: { nextPath, + provider: this.user.qubicUser?.provider, userAddress: this.user.address, }, }); diff --git a/packages/detect-iab/package.json b/packages/detect-iab/package.json index a9f4848..40a5e64 100644 --- a/packages/detect-iab/package.json +++ b/packages/detect-iab/package.json @@ -1,6 +1,6 @@ { "name": "@qubic-connect/detect-iab", - "version": "0.11.0", + "version": "1.0.0", "description": "when detecting environment in iab, show blocking", "author": "Kevin.Wu ", "homepage": "https://github.com/getamis/qubic-creator-sdk/tree/main/packages/detect-iab#readme", diff --git a/packages/redirect/README.md b/packages/redirect/README.md index 4491a35..3de61ef 100644 --- a/packages/redirect/README.md +++ b/packages/redirect/README.md @@ -17,7 +17,7 @@ entryspacing 1.0 note over client, wallet: loginWithRedirect client->sdk:loginWithRedirect\n - sdk->auth:navigate to auth web\n{\n action: 'login' \n walletType\n qubicSignInProvider\n redirectUrl\n dataString\n\n} + sdk->auth:navigate to auth web\n{\n action: 'login' \n walletType\n qubicSignInProvider\n redirectUrl\n apiKey\n dataString\n\n} alt Qubic Wallet and has redirectUrl auth->wallet:navigate to wallet\n{\n ticketRedirectUrl,\n provider: 'facebook' | 'google' | 'apple' | 'yahoo'\n} @@ -43,7 +43,7 @@ note over client, adminApi: bindWithRedirect client->sdk:bindWithRedirect\n sdk->adminApi:clientTicketIssue\n sdk<-adminApi:response { ticket, expiredAt } - sdk->auth:navigate to auth web\n{\n action: 'bind'\n clientTicket\n walletType\n qubicSignInProvider\n redirectUrl\n dataString\n}\n\n + sdk->auth:navigate to auth web\n{\n action: 'bind'\n clientTicket\n walletType\n qubicSignInProvider\n redirectUrl\n apiKey\n dataString\n}\n\n else action:bind diff --git a/packages/redirect/package.json b/packages/redirect/package.json index 9ad1771..44cf022 100644 --- a/packages/redirect/package.json +++ b/packages/redirect/package.json @@ -1,6 +1,6 @@ { "name": "@qubic-connect/redirect", - "version": "0.11.0", + "version": "1.0.0", "homepage": "https://github.com/getamis/qubic-creator-sdk/tree/main/packages/redirect#readme", "license": "ISC", "main": "./dist/index.js", diff --git a/packages/redirect/src/utils.test.ts b/packages/redirect/src/utils.test.ts index 47fd227..223856b 100644 --- a/packages/redirect/src/utils.test.ts +++ b/packages/redirect/src/utils.test.ts @@ -27,6 +27,7 @@ describe('utils', () => { walletType: 'qubic', qubicSignInProvider: 'google', redirectUrl: 'https://www.mydapp.com', + apiKey: 'apiKey123', dataString: JSON.stringify({ foo: 1, bar: 2 }), }; const targetUrl = createUrlRequestConnectToPass('https://pass.qubic.app', RequestConnectToPass); @@ -41,6 +42,7 @@ describe('utils', () => { walletType: 'qubic', qubicSignInProvider: 'google', redirectUrl: 'https://www.mydapp.com', + apiKey: 'apiKey123', dataString: JSON.stringify({ foo: 1, bar: 2 }), clientTicket: 'mockClientTicket', action: 'bind', @@ -197,6 +199,7 @@ describe('real world', () => { walletType: 'qubic', qubicSignInProvider: 'google', redirectUrl: url, + apiKey: 'apiKey123', dataString: JSON.stringify({ foo: 1, bar: 2 }), }); @@ -277,6 +280,7 @@ describe('real world', () => { walletType: 'qubic', qubicSignInProvider: 'google', redirectUrl: url, + apiKey: 'apiKey123', dataString: JSON.stringify({ foo: 1, bar: 2 }), }); @@ -336,6 +340,7 @@ describe('real world', () => { walletType: 'qubic', qubicSignInProvider: 'google', redirectUrl: url, + apiKey: 'apiKey123', dataString: JSON.stringify({ foo: 1, bar: 2 }), clientTicket: 'mockClientTicket', action: 'bind', diff --git a/packages/redirect/src/utils.ts b/packages/redirect/src/utils.ts index a6a1183..9db5a20 100644 --- a/packages/redirect/src/utils.ts +++ b/packages/redirect/src/utils.ts @@ -15,6 +15,7 @@ export interface RequestConnectToPassLogin { walletType?: LoginRedirectWalletType; qubicSignInProvider?: QubicSignInProvider; redirectUrl: string; + apiKey: string; dataString: string; action: 'login'; } @@ -23,6 +24,7 @@ export interface RequestConnectToPassBind { walletType?: LoginRedirectWalletType; qubicSignInProvider?: QubicSignInProvider; redirectUrl: string; + apiKey: string; dataString: string; clientTicket: string; action: 'bind'; @@ -77,6 +79,7 @@ export function createUrlRequestConnectToPass(url: string, options: RequestConne walletType: options.walletType, qubicSignInProvider: options?.qubicSignInProvider, redirectUrl: encodeURIComponent(options.redirectUrl), + apiKey: options.apiKey, dataString: encodeURIComponent(options.dataString), action: options.action, } @@ -84,6 +87,7 @@ export function createUrlRequestConnectToPass(url: string, options: RequestConne walletType: options.walletType, qubicSignInProvider: options?.qubicSignInProvider, redirectUrl: encodeURIComponent(options.redirectUrl), + apiKey: options.apiKey, dataString: encodeURIComponent(options.dataString), clientTicket: options.clientTicket, action: 'bind', @@ -164,6 +168,7 @@ export function getRequestConnectToPass(url: string): RequestConnectToPass | und walletType: query.walletType as LoginRedirectWalletType, qubicSignInProvider: query.qubicSignInProvider as QubicSignInProvider, redirectUrl: decodeURIComponent(query.redirectUrl), + apiKey: query.apiKey, dataString: decodeURIComponent(query.dataString), action: 'login', } @@ -171,6 +176,7 @@ export function getRequestConnectToPass(url: string): RequestConnectToPass | und walletType: query.walletType as LoginRedirectWalletType, qubicSignInProvider: query.qubicSignInProvider as QubicSignInProvider, redirectUrl: decodeURIComponent(query.redirectUrl), + apiKey: query.apiKey, dataString: decodeURIComponent(query.dataString), clientTicket: query.clientTicket, action: 'bind',