Skip to content

Commit

Permalink
fmt
Browse files Browse the repository at this point in the history
  • Loading branch information
piloking committed Oct 13, 2024
1 parent 71cd242 commit 77df760
Show file tree
Hide file tree
Showing 17 changed files with 146 additions and 119 deletions.
6 changes: 3 additions & 3 deletions .github/workflows/docs_site_build.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,8 @@ on:
push:
branches: [main]
paths:
- 'docs/**'
- '.github/workflows/docs_site_build.yml'
- "docs/**"
- ".github/workflows/docs_site_build.yml"

workflow_dispatch:

Expand Down Expand Up @@ -58,4 +58,4 @@ jobs:
steps:
- name: Deploy to GitHub Pages
id: deployment
uses: actions/deploy-pages@v2
uses: actions/deploy-pages@v2
16 changes: 8 additions & 8 deletions .github/workflows/pull_request.yml
Original file line number Diff line number Diff line change
@@ -1,13 +1,13 @@
name: pull_request
on:
pull_request:
branches: ['*']
branches: ["*"]
paths-ignore:
- 'docs/**'
- '.vscode/**'
- 'README.md'
- '.gitignore'
- 'LICENSE'
- "docs/**"
- ".vscode/**"
- "README.md"
- ".gitignore"
- "LICENSE"

jobs:
jsr-dry-run:
Expand All @@ -24,7 +24,7 @@ jobs:
working-directory: ./packages/types

deno:
name: 'Testing'
name: "Testing"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand All @@ -34,7 +34,7 @@ jobs:
- run: deno test

format:
name: 'Format Check'
name: "Format Check"
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v4
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: release
on:
push:
tags:
- '*'
- "*"

jobs:
jsr:
Expand Down
5 changes: 2 additions & 3 deletions .gitpod.yml
Original file line number Diff line number Diff line change
@@ -1,8 +1,7 @@
tasks:
- name: Setup
init: echo "LINEJS GITPOD"
- name: Setup
init: echo "LINEJS GITPOD"

vscode:
extensions:
- denoland.vscode-deno

109 changes: 63 additions & 46 deletions archive/_server/latesta_device.ts
Original file line number Diff line number Diff line change
@@ -1,52 +1,69 @@
import { JSDOM } from 'npm:[email protected]';
import { JSDOM } from "npm:[email protected]";

async function getLatestMobile() {
const dom = new JSDOM(await fetch("https://apps.apple.com/jp/app/line/id443904275", {
"headers": {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"accept-language": "ja-JP,ja;q=0.9,en-US;q=0.8,en;q=0.7",
"cache-control": "no-cache",
"pragma": "no-cache",
"priority": "u=0, i",
"sec-fetch-dest": "document",
"sec-fetch-mode": "navigate",
"sec-fetch-site": "same-origin",
"sec-fetch-user": "?1",
"upgrade-insecure-requests": "1",
"cookie": "geo=JP; dssf=1; geo=JP",
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
},
"referrerPolicy": "strict-origin-when-cross-origin",
"body": null,
"method": "GET"
}).then(r => r.text()));
const dom = new JSDOM(
await fetch("https://apps.apple.com/jp/app/line/id443904275", {
"headers": {
"accept":
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"accept-language": "ja-JP,ja;q=0.9,en-US;q=0.8,en;q=0.7",
"cache-control": "no-cache",
"pragma": "no-cache",
"priority": "u=0, i",
"sec-fetch-dest": "document",
"sec-fetch-mode": "navigate",
"sec-fetch-site": "same-origin",
"sec-fetch-user": "?1",
"upgrade-insecure-requests": "1",
"cookie": "geo=JP; dssf=1; geo=JP",
"user-agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
},
"referrerPolicy": "strict-origin-when-cross-origin",
"body": null,
"method": "GET",
}).then((r) => r.text()),
);
const document = dom.window.document;
const apple = JSON.parse(document.querySelector("#shoebox-media-api-cache-apps").textContent)
const line = JSON.parse(Object.values(apple)[0] as string)
return line.d[0].attributes.platformAttributes.ios.versionHistory[0].versionDisplay as string
const apple = JSON.parse(
document.querySelector("#shoebox-media-api-cache-apps").textContent,
);
const line = JSON.parse(Object.values(apple)[0] as string);
return line.d[0].attributes.platformAttributes.ios.versionHistory[0]
.versionDisplay as string;
}
async function getLatestDesktop() {
const dom = new JSDOM(await fetch("https://apps.apple.com/jp/app/line/id539883307?ign-mpt=uo%3D4&mt=12", {
"headers": {
"accept": "text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"accept-language": "ja-JP,ja;q=0.9,en-US;q=0.8,en;q=0.7",
"cache-control": "no-cache",
"pragma": "no-cache",
"priority": "u=0, i",
"sec-fetch-dest": "document",
"sec-fetch-mode": "navigate",
"sec-fetch-site": "same-origin",
"sec-fetch-user": "?1",
"upgrade-insecure-requests": "1",
"cookie": "geo=JP; dssf=1; geo=JP",
"user-agent": "Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36"
},
"referrerPolicy": "strict-origin-when-cross-origin",
"body": null,
"method": "GET"
}).then(r => r.text()));
const dom = new JSDOM(
await fetch(
"https://apps.apple.com/jp/app/line/id539883307?ign-mpt=uo%3D4&mt=12",
{
"headers": {
"accept":
"text/html,application/xhtml+xml,application/xml;q=0.9,image/avif,image/webp,image/apng,*/*;q=0.8,application/signed-exchange;v=b3;q=0.7",
"accept-language": "ja-JP,ja;q=0.9,en-US;q=0.8,en;q=0.7",
"cache-control": "no-cache",
"pragma": "no-cache",
"priority": "u=0, i",
"sec-fetch-dest": "document",
"sec-fetch-mode": "navigate",
"sec-fetch-site": "same-origin",
"sec-fetch-user": "?1",
"upgrade-insecure-requests": "1",
"cookie": "geo=JP; dssf=1; geo=JP",
"user-agent":
"Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/126.0.0.0 Safari/537.36",
},
"referrerPolicy": "strict-origin-when-cross-origin",
"body": null,
"method": "GET",
},
).then((r) => r.text()),
);
const document = dom.window.document;
const apple = JSON.parse(document.querySelector("#shoebox-media-api-cache-apps").textContent)
const line = JSON.parse(Object.values(apple)[0] as string)
return line.d[0].attributes.platformAttributes.osx.versionHistory[0].versionDisplay as string
}
const apple = JSON.parse(
document.querySelector("#shoebox-media-api-cache-apps").textContent,
);
const line = JSON.parse(Object.values(apple)[0] as string);
return line.d[0].attributes.platformAttributes.osx.versionHistory[0]
.versionDisplay as string;
}
2 changes: 1 addition & 1 deletion deno.json
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@
"tweetnacl": "npm:tweetnacl@^1.0.3",
"jsdom": "npm:[email protected]",
"node-types": "npm:@types/node@latest",
"node-int64":"npm:node-int64"
"node-int64": "npm:node-int64"
},
"tasks": {
"format": "deno run -A npm:@biomejs/biome format --write ./packages/**/*.ts",
Expand Down
2 changes: 2 additions & 0 deletions deno.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

6 changes: 3 additions & 3 deletions examples/simple-send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ await client.login({
});

await client.sendMessage({
to: "MID", // mid (group c~ ,user u~)
text: "Hello, world!"
})
to: "MID", // mid (group c~ ,user u~)
text: "Hello, world!",
});
6 changes: 3 additions & 3 deletions examples/square-simple-send.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,6 @@ await client.login({
});

await client.sendSquareMessage({
to: "MID", // mid (squareChat m~)
text: "Hello, world!"
})
to: "MID", // mid (squareChat m~)
text: "Hello, world!",
});
5 changes: 3 additions & 2 deletions packages/linejs/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -38,8 +38,9 @@ For now, please use "https://esm.sh/jsr/@evex/linejs".

## LINEJS Types

Please see [@evex/linejs-types](https://jsr.io/@evex/linejs-types).
In short, TypeScript types and enums (such as ReactionType (0, 1, 2, 3), MessageType, etc.) are provided.
Please see [@evex/linejs-types](https://jsr.io/@evex/linejs-types).\
In short, TypeScript types and enums (such as ReactionType (0, 1, 2, 3),
MessageType, etc.) are provided.

## Provided Packages

Expand Down
22 changes: 12 additions & 10 deletions packages/linejs/client/clients/base-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -437,7 +437,7 @@ export class BaseClient extends TypedEventEmitter<ClientEvents> {
}
try {
const myEvents = await this.sync({
revision: (revision as number),
revision: revision as number,
globalRev,
individualRev,
});
Expand Down Expand Up @@ -520,15 +520,15 @@ export class BaseClient extends TypedEventEmitter<ClientEvents> {
const chat =
message.toType === LINETypes.MIDType._USER
? async () => {
return await this.getContact({ mid: sendIn });
}
return await this.getContact({ mid: sendIn });
}
: undefined;

const group =
message.toType !== LINETypes.MIDType._USER
? async () => {
return (await this.getChats({ mids: [sendIn] })).chats[0];
}
return (await this.getChats({ mids: [sendIn] })).chats[0];
}
: (undefined as LooseType);

const getContact = async () => {
Expand Down Expand Up @@ -576,10 +576,11 @@ export class BaseClient extends TypedEventEmitter<ClientEvents> {
this.emit("event", operation);
}
globalRev =
myEvents.operationResponse?.globalEvents?.lastRevision as number || globalRev;
(myEvents.operationResponse?.globalEvents?.lastRevision as number) ||
globalRev;
individualRev =
myEvents.operationResponse?.individualEvents?.lastRevision as number ||
individualRev;
(myEvents.operationResponse?.individualEvents
?.lastRevision as number) || individualRev;
revision = myEvents.fullSyncResponse?.nextRevision || revision;
} catch {
/* Do Nothing */
Expand Down Expand Up @@ -1096,7 +1097,7 @@ export class BaseClient extends TypedEventEmitter<ClientEvents> {
/**
* @description Will override.
*/
public decodeE2EEKeyV1(_data: LooseType, _secret: Buffer): LooseType { }
public decodeE2EEKeyV1(_data: LooseType, _secret: Buffer): LooseType {}

/**
* @description Will override.
Expand Down Expand Up @@ -1716,7 +1717,8 @@ export class BaseClient extends TypedEventEmitter<ClientEvents> {
this.storage.set(
"expire",
(
(RATR.tokenIssueTimeEpochSec as number) + (RATR.durationUntilRefreshInSec as number)
(RATR.tokenIssueTimeEpochSec as number) +
(RATR.durationUntilRefreshInSec as number)
).toString(),
);
} else {
Expand Down
14 changes: 4 additions & 10 deletions packages/linejs/client/clients/e2ee/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,9 @@ import type { LooseType } from "../../entities/common.ts";
import { rawReadStruct as readStruct } from "../../libs/thrift/read.ts";
import {
ContentType,
MIDType,
type Location,
type Message,
MIDType,
} from "@evex/linejs-types";
import nacl from "tweetnacl";
import { InternalError } from "../../entities/errors.ts";
Expand Down Expand Up @@ -672,18 +672,12 @@ class E2EE extends TalkClient {
message,
});
const decipher = crypto.createDecipheriv("aes-256-cbc", aes_key, aes_iv);
let decrypted:Buffer|undefined;
let decrypted: Buffer | undefined;
try {
decrypted = Buffer.concat([
decipher.update(message),
decipher.final(),
]);
decrypted = Buffer.concat([decipher.update(message), decipher.final()]);
} catch {
decipher.setAutoPadding(false);
decrypted = Buffer.concat([
decipher.update(message),
decipher.final(),
]);
decrypted = Buffer.concat([decipher.update(message), decipher.final()]);
}
this.e2eeLog(
"decryptE2EEMessageV1DecryptedMessage",
Expand Down
6 changes: 4 additions & 2 deletions packages/linejs/client/clients/internal/square-client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -814,7 +814,7 @@ export class SquareClient extends LiffClient {
true,
this.SquareService_API_PATH,
)) as LINETypes.GetSquareChatMembersResponse;
if (useCache)
if (useCache) {
response.squareChatMembers.forEach((e) => {
if (
!(
Expand All @@ -830,6 +830,7 @@ export class SquareClient extends LiffClient {
);
}
});
}

if (continueRequest && response.continuationToken) {
return await this.continueRequest({
Expand Down Expand Up @@ -1171,7 +1172,7 @@ export class SquareClient extends LiffClient {
true,
this.SquareService_API_PATH,
)) as LINETypes.GetSquareMembersBySquareResponse;
if (useCache)
if (useCache) {
response.members.forEach((e) => {
if (
!(
Expand All @@ -1187,6 +1188,7 @@ export class SquareClient extends LiffClient {
);
}
});
}
return response;
}

Expand Down
Loading

0 comments on commit 77df760

Please sign in to comment.