Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

v0.11.1 #79

Merged
merged 8 commits into from
Nov 3, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 10 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
@@ -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
Expand Down Expand Up @@ -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;
Expand Down
2 changes: 1 addition & 1 deletion lerna.json
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
{
"packages": ["packages/*"],
"useNx": true,
"version": "0.11.0"
"version": "1.0.0"
}
6 changes: 3 additions & 3 deletions packages/core/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down Expand Up @@ -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",
Expand Down
3 changes: 3 additions & 0 deletions packages/core/src/QubicConnect.ts
Original file line number Diff line number Diff line change
Expand Up @@ -398,6 +398,7 @@ export class QubicConnect {
walletType: options?.walletType,
qubicSignInProvider: options?.qubicSignInProvider,
redirectUrl,
apiKey: this.config.key,
dataString,
action: 'login',
});
Expand All @@ -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',
Expand Down Expand Up @@ -676,6 +678,7 @@ export class QubicConnect {
url: `${walletUrl}/verify-user-address`,
query: {
nextPath,
provider: this.user.qubicUser?.provider,
userAddress: this.user.address,
},
});
Expand Down
2 changes: 1 addition & 1 deletion packages/detect-iab/package.json
Original file line number Diff line number Diff line change
@@ -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 <[email protected]>",
"homepage": "https://github.com/getamis/qubic-creator-sdk/tree/main/packages/detect-iab#readme",
Expand Down
4 changes: 2 additions & 2 deletions packages/redirect/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand All @@ -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
Expand Down
2 changes: 1 addition & 1 deletion packages/redirect/package.json
Original file line number Diff line number Diff line change
@@ -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",
Expand Down
5 changes: 5 additions & 0 deletions packages/redirect/src/utils.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand All @@ -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',
Expand Down Expand Up @@ -197,6 +199,7 @@ describe('real world', () => {
walletType: 'qubic',
qubicSignInProvider: 'google',
redirectUrl: url,
apiKey: 'apiKey123',
dataString: JSON.stringify({ foo: 1, bar: 2 }),
});

Expand Down Expand Up @@ -277,6 +280,7 @@ describe('real world', () => {
walletType: 'qubic',
qubicSignInProvider: 'google',
redirectUrl: url,
apiKey: 'apiKey123',
dataString: JSON.stringify({ foo: 1, bar: 2 }),
});

Expand Down Expand Up @@ -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',
Expand Down
6 changes: 6 additions & 0 deletions packages/redirect/src/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ export interface RequestConnectToPassLogin {
walletType?: LoginRedirectWalletType;
qubicSignInProvider?: QubicSignInProvider;
redirectUrl: string;
apiKey: string;
dataString: string;
action: 'login';
}
Expand All @@ -23,6 +24,7 @@ export interface RequestConnectToPassBind {
walletType?: LoginRedirectWalletType;
qubicSignInProvider?: QubicSignInProvider;
redirectUrl: string;
apiKey: string;
dataString: string;
clientTicket: string;
action: 'bind';
Expand Down Expand Up @@ -77,13 +79,15 @@ 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,
}
: {
walletType: options.walletType,
qubicSignInProvider: options?.qubicSignInProvider,
redirectUrl: encodeURIComponent(options.redirectUrl),
apiKey: options.apiKey,
dataString: encodeURIComponent(options.dataString),
clientTicket: options.clientTicket,
action: 'bind',
Expand Down Expand Up @@ -164,13 +168,15 @@ 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',
}
: {
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',
Expand Down
Loading