Skip to content

Commit

Permalink
Merge branch 'main' into release
Browse files Browse the repository at this point in the history
  • Loading branch information
viktor44 committed Jul 12, 2024
2 parents 223b0ff + 8d377c1 commit 45db874
Show file tree
Hide file tree
Showing 18 changed files with 440 additions and 37 deletions.
82 changes: 82 additions & 0 deletions .github/workflows/release-candidate.yml
Original file line number Diff line number Diff line change
@@ -0,0 +1,82 @@
name: Release Candidate
on:
push:
tags:
- 'v*-b*'

jobs:
Linux:
runs-on: ubuntu-latest
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: "18"
cache: "yarn"
# See https://github.com/nodejs/node-gyp/blob/main/docs/Force-npm-to-use-global-node-gyp.md
# https://github.com/nodejs/node-gyp/blob/main/docs/Updating-npm-bundled-node-gyp.md
# - name: Update node-gyp
# run: |
# npm install --global [email protected]
# npm config set node_gyp $(npm prefix -g)/lib/node_modules/node-gyp/bin/node-gyp.js
- name: Install dependencies
run: yarn install --immutable
- name: Build and Release
run: yarn release

MacOs:
runs-on: macos-13
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
CSC_LINK: ${{ secrets.CSC_LINK }}
AC_USERNAME: ${{ secrets.AC_USERNAME }}
AC_PASSWORD: ${{ secrets.AC_PASSWORD }}
AC_TEAM_ID: ${{ secrets.AC_TEAM_ID }}
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: "18"
cache: "yarn"
- name: Configure Node
run: |
# npm v9 doesn't allow custom config parameters (i.e. node_gyp) anymode, so we have to downgrade it to v8
npm install -g npm@8
npm install -g node-gyp@latest
npm config set node_gyp $(npm prefix -g)/lib/node_modules/node-gyp/bin/node-gyp.js
- name: Install dependencies
run: yarn install --immutable
- name: Build and Release
run: yarn release

Windows:
runs-on: windows-2019
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
CSC_KEY_PASSWORD: ${{ secrets.CSC_KEY_PASSWORD }}
CSC_LINK: ${{ secrets.CSC_LINK }}
GOOGLE_CLIENT_ID: ${{ secrets.GOOGLE_CLIENT_ID }}
GOOGLE_CLIENT_SECRET: ${{ secrets.GOOGLE_CLIENT_SECRET }}
steps:
- uses: actions/checkout@master
- uses: actions/setup-node@master
with:
node-version: "18"
- name: Configure Node
shell: powershell
run: |
# npm v9 doesn't allow custom config parameters (i.e. node_gyp) anymode, so we have to downgrade it to v8
npm install -g npm@8
npm install -g node-gyp@latest
npm prefix -g | % {npm config set node_gyp "$_\node_modules\node-gyp\bin\node-gyp.js"}
- name: Install dependencies
run: yarn install --immutable
- name: Build and Release
run: yarn release
Binary file added .yarn/install-state.gz
Binary file not shown.
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
"name": "station-project",
"private": true,
"productName": "Station",
"version": "3.1.0-b2",
"version": "3.1.0-b3",
"description": "Station",
"homepage": "https://getstation.com",
"author": {
Expand Down
5 changes: 5 additions & 0 deletions packages/app/manifests/definitions/140.json
Original file line number Diff line number Diff line change
Expand Up @@ -11,5 +11,10 @@
"theme_color": "#0070C9",
"scope": "https://outlook.live.com",
"bx_legacy_service_id": "outlook",
"extended_scopes": [
"https://*.live.com",
"https://*.office.com",
"https://*.microsoft.com"
],
"recommendedPosition": "12"
}
2 changes: 1 addition & 1 deletion packages/app/package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "station-desktop-app",
"productName": "Station",
"version": "3.1.0-b2",
"version": "3.1.0-b3",
"description": "Station",
"homepage": "https://getstation.com",
"author": {
Expand Down
4 changes: 2 additions & 2 deletions packages/app/src/app-worker.ts
Original file line number Diff line number Diff line change
Expand Up @@ -332,9 +332,9 @@ export class BrowserXAppWorker {
this.mainWindowManager.on('leave-full-screen', () => this.dispatch(setFullScreenState(false)));
this.mainWindowManager.on('swipe-left', () => this.dispatch(executeWebviewMethodForCurrentTab('go-back')));
this.mainWindowManager.on('swipe-right', () => this.dispatch(executeWebviewMethodForCurrentTab('go-forward')));
this.mainWindowManager.on('new-notification', (notificationId: string, props: NotificationProps, options: NotificationOptions) =>
this.mainWindowManager.on('new-notification', (notificationId: string, props: NotificationProps, options: NotificationOptions) => {
this.dispatch(notificationCenter.newNotification(undefined, undefined, notificationId, props, options))
);
});
}

private initSDK() {
Expand Down
5 changes: 4 additions & 1 deletion packages/app/src/applications/Application.tsx
Original file line number Diff line number Diff line change
Expand Up @@ -346,8 +346,11 @@ class ApplicationImpl extends React.PureComponent {
}

async handleDomReady() {
const js = await injectJS(this.props.legacyServiceId);

const webviewInjectJS = require(`!!raw-loader!../static/preload/webview-inject.js`).default
this.webView.view.executeJavaScript(webviewInjectJS); //`(function(){\n${bxNotifJS}\n})()`);

const js = await injectJS(this.props.legacyServiceId);
if (js && this.webView && this.webView.view) {
this.webView.view.executeJavaScript(js);
// const webContents = remote.webContents.fromId(this.webView.view.getWebContentsId());
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -32,12 +32,14 @@ export const JAVASCRIPT_INJECTIONS = {
gmail: ['gmailInjectedScript'],
slack: ['slackInjectedScript'],
'station-support': ['slackInjectedScript'],
'gdrive-mu': ['removeGoogleAccountInjectedScript'],
'gdrive-mu': ['removeGoogleAccountInjectedScript'],
'gcalendar-mu': ['removeGoogleAccountInjectedScript'],
'google-cloud': ['removeGoogleAccountInjectedScript'], //vk: FIXME: doesn't work
'google-keep': ['removeGoogleAccountInjectedScript'],
'meet': ['removeGoogleAccountInjectedScript'],
outlook: ['office365InjectedScript'],
'office-365': ['office365InjectedScript'],
'outlook-pro': ['office365InjectedScript'],
'google-keep': ['removeGoogleAccountInjectedScript'],
'facebook-messenger': ['messengerInjectedScript'],
'whatsapp': ['whatsappInjectedScript'],
};
Expand Down
1 change: 1 addition & 0 deletions packages/app/src/notification-center/sagas.ts
Original file line number Diff line number Diff line change
Expand Up @@ -206,6 +206,7 @@ function* interceptNotificationEventsFromWebContents({ webcontentsId, tabId }: {
step: RequestForApplicationNotificationsStep.ASK,
}));
}

yield put(newNotification(applicationId, tabId, props.id, props));
});

Expand Down
1 change: 1 addition & 0 deletions packages/app/src/notification-center/webview-preload.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
/* tslint:disable:function-name */
//import { ipcRenderer } from 'electron';
import * as shortid from 'shortid';
import { EventTarget } from 'event-target-shim';

Expand Down
Original file line number Diff line number Diff line change
@@ -1,15 +1,17 @@
import { Schema$Person } from 'googleapis/build/src/apis/plus/v1';
import { people_v1 } from 'googleapis/build/src/apis/people/v1';
import { ServiceBase } from '../../lib/class';
import { service, timeout } from '../../lib/decorator';
import { RPC } from '../../lib/types';
import { Credentials } from 'google-auth-library/build/src/auth/credentials';
import { Credentials } from 'google-auth-library';

export type ElectronGoogleSignInResponse = {
tokens: Credentials,
profile: people_v1.Schema$Person,
}

@service('electron-google-oauth')
export class ElectronGoogleOAuthService extends ServiceBase implements RPC.Interface<ElectronGoogleOAuthService> {
@timeout(0)
// @ts-ignore
signIn(scopes: string[], forceAddSession?: boolean): Promise<{
tokens: Credentials,
profile: Schema$Person,
}> {}
signIn(scopes: string[], forceAddSession?: boolean): Promise<ElectronGoogleSignInResponse> {}
}
86 changes: 75 additions & 11 deletions packages/app/src/services/services/electron-google-oauth/main.ts
Original file line number Diff line number Diff line change
@@ -1,31 +1,95 @@
import { google } from 'googleapis';
import { people_v1 } from 'googleapis/build/src/apis/people/v1';
import { Credentials } from 'google-auth-library';
import ElectronGoogleOAuth2 from '@getstation/electron-google-oauth2';
import log from 'electron-log';

import { RPC } from '../../lib/types';
import { ElectronGoogleOAuthService } from './interface';
import { ElectronGoogleOAuthService, ElectronGoogleSignInResponse } from './interface';

const CLIENT_ID = process.env.GOOGLE_CLIENT_ID!;
const CLIENT_SECRET = process.env.GOOGLE_CLIENT_SECRET!;

export class ElectronGoogleOAuthServiceImpl extends ElectronGoogleOAuthService implements RPC.Interface<ElectronGoogleOAuthService> {
async signIn(scopes: string[], forceAddSession?: boolean) {
async signIn(scopes: string[], forceAddSession?: boolean): Promise<ElectronGoogleSignInResponse> {

const client = new ElectronGoogleOAuth2(CLIENT_ID, CLIENT_SECRET, scopes, { successRedirectURL: 'https://getstation.com/' });
return client.openAuthWindowAndGetTokens(forceAddSession)
.then(async (tokens) => {

const service = google.people({
try {
const service = google.people({
version: 'v1',
auth: client.oauth2Client,
});
});

const response = await service.people.get({
resourceName: 'people/me',
personFields: 'names,emailAddresses,photos',
sources: ['READ_SOURCE_TYPE_PROFILE'],
});
const response = await service.people.get({
resourceName: 'people/me',
personFields: 'names,emailAddresses,photos',
sources: ['READ_SOURCE_TYPE_PROFILE'],
});

return { tokens, profile: response.data as people_v1.Schema$Person };
return { tokens, profile: response.data as people_v1.Schema$Person };
}
catch (err) {
log.error(`Google profile request error ${err}`);
return this.parseToken(tokens);
}
});
}

private parseToken(tokens: Credentials): ElectronGoogleSignInResponse {
try {
//vk: id_token format https://developers.google.com/identity/gsi/web/reference/js-reference#credential
const decodedStr = Buffer.from(tokens.id_token!.split('.')[1], 'base64').toString()
const tokenPayload = JSON.parse(decodedStr);

return {
tokens,
profile: {
names: [
{
metadata: {
source: {
id: tokenPayload.sub,
}
},
displayName: tokenPayload.name,
givenName: tokenPayload.given_name,
familyName: tokenPayload.family_name,
}
],
emailAddresses: [
{
type: '',
value: tokenPayload.email,
}
],
photos: [
{
url: tokenPayload.picture,
}
]
}
};
}
catch (err) {
log.error(`Parse token error ${err}`);
return {
tokens,
profile: {
names: [
{
displayName: 'unknown',
}
],
emailAddresses: [
{
type: '',
value: 'unknown',
}
]
}
};
};
}
}
6 changes: 5 additions & 1 deletion packages/app/src/services/services/os-notification/main.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
import { Notification, webContents } from 'electron';
import log from 'electron-log';

import { ServiceSubscription } from '../../lib/class';
import { RPC } from '../../lib/types';
Expand All @@ -8,6 +9,9 @@ import { getDoNotDisturb, asNativeImage } from './utils';
export class OSNotificationServiceImpl extends OSNotificationService implements RPC.Interface<OSNotificationService> {

async show(param: IOSNotificationServiceShowParam) {

log.info(`>>> OSNotificationServiceImpl.show ${JSON.stringify(param)}`);

const notificationOptions: Electron.NotificationConstructorOptions = {
title: param.title,
actions: [],
Expand All @@ -16,7 +20,6 @@ export class OSNotificationServiceImpl extends OSNotificationService implements
};

if (param.imageURL) {

notificationOptions.icon = await asNativeImage(param.imageURL);
}
if (param.body) {
Expand All @@ -25,6 +28,7 @@ export class OSNotificationServiceImpl extends OSNotificationService implements

const notification = new Notification(notificationOptions);
notification.show();

return new OSNotificationImpl(notification);
}

Expand Down
13 changes: 10 additions & 3 deletions packages/app/src/services/services/os-notification/utils.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ import * as memoize from 'memoizee';

export const asNativeImage = memoize((url: string): Promise<Electron.NativeImage> => {
return new Promise((resolve, reject) => {
if (url.indexOf('data:') === 0) {
if (url.startsWith('data:')) {
resolve(nativeImage.createFromDataURL(url));
return;
}

if (url.indexOf('http:') === 0 || url.indexOf('https:') === 0) {
if (url.startsWith('http:') || url.startsWith('https:')) {
fetch(url)
.then((res: any) => res.buffer())
.then((buffer: Buffer) => {
Expand All @@ -19,9 +19,16 @@ export const asNativeImage = memoize((url: string): Promise<Electron.NativeImage
return;
}

if (url.startsWith('blob:http')) {
//FIXME: implement blob:https:// ( Telegram notifications )
resolve(nativeImage.createEmpty());
return;
}

try {
resolve(nativeImage.createFromPath(url));
} catch (e) {
}
catch (e) {
reject(new Error(`Unknow schema for ${url}`));
}
});
Expand Down
Loading

0 comments on commit 45db874

Please sign in to comment.