Skip to content

Commit

Permalink
[MINI-6324] Create interfaces to share Cookie info to MiniApp (#280)
Browse files Browse the repository at this point in the history
* Cookies from Host app

* Sample app changes

* Theme changed

* Update Helper class

* Updated Readme and Changelog
  • Loading branch information
rleojoseph authored Oct 19, 2023
1 parent df972c6 commit ec0a753
Show file tree
Hide file tree
Showing 13 changed files with 485 additions and 17 deletions.
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 @@ -813,6 +814,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",
"build": "react-scripts build && npm run zip",
"dockerBuild": "cd ci && make build",
"eject": "react-scripts eject",
Expand Down
Loading

0 comments on commit ec0a753

Please sign in to comment.