Skip to content

Commit f482133

Browse files
Merge pull request #127 from gridaco/staging
(1/2) Assistant 2021.8 Release
2 parents a91159c + 480a4b2 commit f482133

File tree

289 files changed

+8572
-2690
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

289 files changed

+8572
-2690
lines changed

.github/workflows/tests.yaml

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,9 @@ jobs:
55
runs-on: ubuntu-latest
66
steps:
77
- uses: actions/checkout@v2
8-
- uses: actions/setup-node@v1
8+
- uses: actions/setup-node@v2
9+
with:
10+
node-version: "12"
911
- run: git submodule update --init --recursive
1012
- run: yarn
1113
- run: yarn test

.gitignore

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,3 +4,7 @@ dist
44
.idea
55
package.lock
66
webdev/.eslintcache
7+
8+
9+
# we use yarn
10+
package-lock.json

app/README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
# Assistant shared ui library
1+
# Assistant shared app (ui) library

app/lib/about.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
// const _package = require("../package.jsonn");
2-
export const name = "Bridged Assistant";
3-
export const version = "2021.2.1f0"; /*_package.version*/
2+
export const name = "Grida Assistant";
3+
export const version = "2021.2.2f0"; /*_package.version*/
44
export const versionText = `v${version}`;

app/lib/analytics/index.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,9 @@ export function initialize() {
77
// const client_id = nanoid();
88
// with proxy
99
analytics.initWithProxy(
10-
process.env.BRIDGED_FIRST_PARTY_ANALYTICS_PROXY_SERVICE_TOTP_SECRET
10+
process.env.BRIDGED_FIRST_PARTY_ANALYTICS_PROXY_SERVICE_TOTP_SECRET ??
11+
process.env
12+
.NEXT_PUBLIC_BRIDGED_FIRST_PARTY_ANALYTICS_PROXY_SERVICE_TOTP_SECRET
1113
);
1214

1315
analytics.initWithCors();

app/lib/app.css

Lines changed: 12 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,11 @@
11
#create {
2-
box-shadow: none;
3-
background: #18a0fb;
4-
color: white;
2+
box-shadow: none;
3+
background: #18a0fb;
4+
color: white;
55
}
66

77
#create:focus {
8-
box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.3);
8+
box-shadow: inset 0 0 0 2px rgba(0, 0, 0, 0.3);
99
}
1010

1111
h1,
@@ -16,29 +16,27 @@ h5,
1616
h6,
1717
sub,
1818
p {
19-
font-family: "Roboto";
19+
font-family: "Helvetica Neue", "Helvetica", "Roboto", "Arial", sans-serif;
2020
}
2121

2222
.jss3 {
23-
background-color: #000 !important;
23+
background-color: #000 !important;
2424
}
2525

26-
2726
/* for selected tab under line color */
2827

2928
.PrivateTabIndicator-colorSecondary-3 {
30-
background-color: #000 !important;
29+
background-color: #000 !important;
3130
}
3231

33-
3432
/* for tabs font color switch select */
3533

3634
.MuiTab-textColorInherit.Mui-selected {
37-
opacity: 1 !important;
38-
font-weight: bold !important;
35+
opacity: 1 !important;
36+
font-weight: bold !important;
3937
}
4038

4139
.MuiTab-textColorInherit {
42-
opacity: 0.4 !important;
43-
font-weight: initial !important;
44-
}
40+
opacity: 0.4 !important;
41+
font-weight: initial !important;
42+
}

app/lib/auth/README.md

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
# First pary auth - do not modify under this directory unless you are a inside collaborator.
2+
3+
> Cases for general contributing, you won't have to modify files under this directory.

app/lib/auth/index.ts

Lines changed: 58 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,18 +1,67 @@
1+
import { __HOSTS } from "@base-sdk/core";
12
import {
23
__auth_proxy,
34
ProxyAuthenticationMode,
4-
} from "@base-sdk/auth-first-party";
5-
import { __HOSTS } from "@base-sdk/core";
5+
AuthProxySessionStartRequest,
6+
AuthProxySessionStartResult,
7+
} from "@base-sdk-fp/auth";
8+
import { client_id } from "plugin-app";
9+
import { AuthStorage } from "./storage";
610

711
const PROXY_AUTH_REQUEST_SECRET =
8-
process.env.BRIDGED_FIRST_PARTY_PROXY_AUTH_REQUEST_TOTP_SECRET;
12+
process.env.GRIDA_FIRST_PARTY_PROXY_AUTH_REQUEST_TOTP_SECRET ??
13+
process.env.NEXT_PUBLIC_GRIDA_FIRST_PARTY_PROXY_AUTH_REQUEST_TOTP_SECRET;
14+
15+
function _make_request(): AuthProxySessionStartRequest {
16+
return {
17+
appId: "co.grida.assistant",
18+
clientId: client_id,
19+
mode: ProxyAuthenticationMode.long_polling,
20+
redirect_uri: "figma://", // TODO: change this scheme based on target platform.
21+
};
22+
}
23+
24+
export async function startAuthenticationSession(): Promise<AuthProxySessionStartResult> {
25+
return __auth_proxy.openProxyAuthSession(
26+
PROXY_AUTH_REQUEST_SECRET,
27+
_make_request()
28+
);
29+
}
30+
31+
export async function startAuthenticationWithSession(
32+
session: AuthProxySessionStartResult
33+
) {
34+
const result = await __auth_proxy.requesetProxyAuthWithSession(
35+
PROXY_AUTH_REQUEST_SECRET,
36+
session,
37+
_make_request()
38+
);
39+
40+
AuthStorage.save(result.access_token);
41+
// save result
42+
43+
return result;
44+
}
945

1046
export async function startAuthentication() {
11-
const request = await __auth_proxy.requesetProxyAuth({
12-
mode: ProxyAuthenticationMode.ws,
13-
secret: PROXY_AUTH_REQUEST_SECRET,
14-
});
47+
const session = await startAuthenticationSession();
48+
return await startAuthenticationWithSession(session);
49+
}
50+
51+
export async function isAuthenticated() {
52+
return (await AuthStorage.get())?.length > 1; // using 1 (same as != undefined.)
53+
}
54+
55+
export async function checkAuthSession(session: string): Promise<boolean> {
56+
// TODO:
57+
const res = await __auth_proxy.checkProxyAuthResult(
58+
PROXY_AUTH_REQUEST_SECRET,
59+
session
60+
);
1561

16-
// todo - build full url using method in base sdk
17-
open(__HOSTS.INTERNAL_SECURE_ACCOUNTS_SERVICE_HOST);
62+
const success = res.success && res.access_token !== undefined;
63+
if (success) {
64+
AuthStorage.save(res.access_token);
65+
}
66+
return success;
1867
}
Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,27 @@
11
////
22
//// Manage the quota of app usage as on unauthenticated anonymous user.
33
////
4+
5+
import { PluginSdk } from "@plugin-sdk/app";
6+
7+
const _STATE_STORE_KEY = "trial-state-store-key";
8+
export class TrialManager {
9+
private static _instance: TrialManager;
10+
private state;
11+
public static get instance(): TrialManager {
12+
if (!TrialManager._instance) {
13+
TrialManager._instance = new TrialManager();
14+
}
15+
return TrialManager._instance;
16+
}
17+
18+
private constructor() {
19+
this._loadstate();
20+
}
21+
22+
async _loadstate() {
23+
if (!this.state) {
24+
this.state = await PluginSdk.getItem(_STATE_STORE_KEY);
25+
}
26+
}
27+
}

app/lib/auth/storage.ts

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
///
2+
///
3+
///
4+
import { PluginSdk } from "@plugin-sdk/app";
5+
6+
/** Preserve value: Do not change value */
7+
const _ASSISTANT_GRIDA_AUTHENTICATION_CREDENTIAL_KEY =
8+
"co.grida.assistant/user-auth";
9+
10+
type Credential = string;
11+
12+
function saveAuthCredential(credential: Credential) {
13+
PluginSdk.setItem(_ASSISTANT_GRIDA_AUTHENTICATION_CREDENTIAL_KEY, credential);
14+
}
15+
16+
async function getAuthCredential(): Promise<Credential> {
17+
return PluginSdk.getItem(_ASSISTANT_GRIDA_AUTHENTICATION_CREDENTIAL_KEY);
18+
}
19+
20+
export const AuthStorage = {
21+
save: saveAuthCredential,
22+
get: getAuthCredential,
23+
};

0 commit comments

Comments
 (0)