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

[MINI-6324] Create interfaces to share Cookie info to MiniApp #271

Merged
merged 5 commits into from
Oct 13, 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
27 changes: 27 additions & 0 deletions js-miniapp-bridge/src/common-bridge.ts
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,7 @@ import { ProductInfo, PurchasedProductInfo } from './types/in-app-purchase';
import { HostThemeColor } from './types/host-color-scheme';
import { MAAnalyticsInfo } from './types/analytics/analytics';
import { UniversalBridgeInfo } from './types/universal-bridge';
import { CookieInfo } from './types/cookie-info';

/** @internal */
const mabMessageQueue: Callback[] = [];
Expand Down Expand Up @@ -794,6 +795,32 @@ export class MiniAppBridge {
);
});
}

getAllCookies() {
return new Promise<[CookieInfo]>((resolve, reject) => {
return this.executor.exec(
'getAllCookies',
null,
response => {
resolve(JSON.parse(response) as [CookieInfo]);
},
error => reject(parseMiniAppError(error))
);
});
}

getCookies(cookieNameList: string[]) {
return new Promise<[CookieInfo]>((resolve, reject) => {
return this.executor.exec(
'getCookies',
{ cookieList: cookieNameList },
response => {
resolve(JSON.parse(response) as [CookieInfo]);
},
error => reject(parseMiniAppError(error))
);
});
}
}

/**
Expand Down
2 changes: 2 additions & 0 deletions js-miniapp-bridge/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,7 @@ import {
PurchasedProductInfo,
ProductPrice,
} from './types/in-app-purchase';
import { CookieInfo } from './types/cookie-info';

export {
MiniAppBridge,
Expand Down Expand Up @@ -111,4 +112,5 @@ export {
MAAnalyticsActionType,
MAAnalyticsEventType,
UniversalBridgeInfo,
CookieInfo,
};
5 changes: 5 additions & 0 deletions js-miniapp-bridge/src/types/cookie-info.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
/** CookieInfo type. */
export interface CookieInfo {
name?: string;
value?: string;
}
2 changes: 1 addition & 1 deletion js-miniapp-sample/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
"format": "prettier --config ./prettier.config.js --write 'src/**/*.js'",
"prettify": "prettier --config ./prettier.config.js --check src/**/*.js",
"lint": "eslint src/ --fix-dry-run",
"start": "react-scripts start",
"start": "react-scripts --openssl-legacy-provider start",
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

may be remove this one! @rleojoseph

"build": "react-scripts build && npm run zip",
"dockerBuild": "cd ci && make build",
"eject": "react-scripts eject",
Expand Down
Loading
Loading