Skip to content

Commit 7b74fd8

Browse files
authored
Update depreciated libraries (#16)
* chore: 🔧 Update action node version to 16 * chore: 🔧 Update Github Actions Core to 1.10.0 * fix: 🐛 Migrate from `tweetsodium` to `libsodium-wrappers` * chore: 🔧 update patch version to `1.1.4`
1 parent 487ef4f commit 7b74fd8

File tree

4 files changed

+48
-34
lines changed

4 files changed

+48
-34
lines changed

action.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ outputs:
3030
description: The token for the GitHub App on the current repository.
3131

3232
runs:
33-
using: node12
33+
using: node16
3434
main: dist/index.js
3535
post: dist/index.js
3636

package.json

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
{
22
"name": "use-app-token",
3-
"version": "1.1.3",
3+
"version": "1.1.4",
44
"description": "Run GitHub Actions as a GitHub App by using the app's authentication token",
55
"main": "dist/index.js",
66
"files": [
@@ -35,12 +35,12 @@
3535
"contributors": [],
3636
"repository": "https://github.com/wow-actions/use-app-token",
3737
"dependencies": {
38-
"@actions/core": "^1.2.6",
38+
"@actions/core": "^1.10.0",
3939
"@actions/github": "^5.0.0",
4040
"@octokit/auth-app": "^3.6.0",
4141
"@octokit/core": "^3.5.1",
4242
"is-base64": "^1.1.0",
43-
"tweetsodium": "^0.0.5"
43+
"libsodium-wrappers": "^0.7.10"
4444
},
4545
"devDependencies": {
4646
"@commitlint/cli": "^13.1.0",

src/util.ts

Lines changed: 12 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ import * as github from '@actions/github'
33
import { Octokit } from '@octokit/core'
44
import { createAppAuth } from '@octokit/auth-app'
55
import isBase64 from 'is-base64'
6-
import sodium from 'tweetsodium'
6+
import sodium from 'libsodium-wrappers'
77

88
export namespace Util {
99
export async function getAppToken() {
@@ -54,17 +54,22 @@ export namespace Util {
5454

5555
const { key } = res.data
5656

57-
// Convert the message and key to Uint8Array's
58-
const messageBytes = Buffer.from(value)
59-
const keyBytes = Buffer.from(key, 'base64')
57+
await sodium.ready
6058

61-
// Encrypt using LibSodium.
62-
const encryptedBytes = sodium.seal(messageBytes, keyBytes)
59+
// Convert Secret & Base64 key to Uint8Array.
60+
const binkey = sodium.from_base64(key, sodium.base64_variants.ORIGINAL)
61+
const binsec = sodium.from_string(value)
62+
63+
// Encrypt the secret using LibSodium
64+
const encryptedBytes = sodium.crypto_box_seal(binsec, binkey)
6365

6466
return {
6567
key_id: res.data.key_id,
6668
// Base64 the encrypted secret
67-
encrypted_value: Buffer.from(encryptedBytes).toString('base64'),
69+
encrypted_value: sodium.to_base64(
70+
encryptedBytes,
71+
sodium.base64_variants.ORIGINAL,
72+
),
6873
}
6974
}
7075

yarn.lock

Lines changed: 32 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,13 @@
22
# yarn lockfile v1
33

44

5-
"@actions/core@^1.2.6":
6-
version "1.5.0"
7-
resolved "https://registry.npmjs.org/@actions/core/-/core-1.5.0.tgz#885b864700001a1b9a6fba247833a036e75ad9d3"
8-
integrity sha512-eDOLH1Nq9zh+PJlYLqEMkS/jLQxhksPNmUGNBHfa4G+tQmnIhzpctxmchETtVGyBOvXgOVVpYuE40+eS4cUnwQ==
5+
"@actions/core@^1.10.0":
6+
version "1.10.0"
7+
resolved "https://registry.yarnpkg.com/@actions/core/-/core-1.10.0.tgz#44551c3c71163949a2f06e94d9ca2157a0cfac4f"
8+
integrity sha512-2aZDDa3zrrZbP5ZYg159sNoLRb61nQ7awl5pSvIq5Qpj81vwDzdMRKzkWJGJuwVvWpvZKx7vspJALyvaaIQyug==
9+
dependencies:
10+
"@actions/http-client" "^2.0.1"
11+
uuid "^8.3.2"
912

1013
"@actions/github@^5.0.0":
1114
version "5.0.0"
@@ -24,6 +27,13 @@
2427
dependencies:
2528
tunnel "0.0.6"
2629

30+
"@actions/http-client@^2.0.1":
31+
version "2.0.1"
32+
resolved "https://registry.yarnpkg.com/@actions/http-client/-/http-client-2.0.1.tgz#873f4ca98fe32f6839462a6f046332677322f99c"
33+
integrity sha512-PIXiMVtz6VvyaRsGY268qvj57hXQEpsYogYOu2nrQhlf+XCGmZstmuZBbAybUl1nQGnvS1k1eEsQ69ZoD7xlSw==
34+
dependencies:
35+
tunnel "^0.0.6"
36+
2737
2838
version "7.12.11"
2939
resolved "https://registry.npmjs.org/@babel/code-frame/-/code-frame-7.12.11.tgz#f4ad435aa263db935b8f10f2c552d23fb716a63f"
@@ -668,11 +678,6 @@ before-after-hook@^2.2.0:
668678
resolved "https://registry.npmjs.org/before-after-hook/-/before-after-hook-2.2.2.tgz#a6e8ca41028d90ee2c24222f201c90956091613e"
669679
integrity sha512-3pZEU3NT5BFUo/AD5ERPWOgQOCZITni6iavr5AUw5AUwQjMlI0kzu5btnyD39AF0gUEsDPwJT+oY1ORBJijPjQ==
670680

671-
blakejs@^1.1.0:
672-
version "1.1.1"
673-
resolved "https://registry.npmjs.org/blakejs/-/blakejs-1.1.1.tgz#bf313053978b2cd4c444a48795710be05c785702"
674-
integrity sha512-bLG6PHOCZJKNshTjGRBvET0vTciwQE6zFKOKKXPDJfwFBd4Ac0yBfPZqcGvGJap50l7ktvlpFqc2jGVaUgbJgg==
675-
676681
brace-expansion@^1.1.7:
677682
version "1.1.11"
678683
resolved "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz#3c7fcbf529d87226f3d2f52b966ff5271eb441dd"
@@ -1884,6 +1889,18 @@ levn@^0.4.1:
18841889
prelude-ls "^1.2.1"
18851890
type-check "~0.4.0"
18861891

1892+
libsodium-wrappers@^0.7.10:
1893+
version "0.7.10"
1894+
resolved "https://registry.yarnpkg.com/libsodium-wrappers/-/libsodium-wrappers-0.7.10.tgz#13ced44cacb0fc44d6ac9ce67d725956089ce733"
1895+
integrity sha512-pO3F1Q9NPLB/MWIhehim42b/Fwb30JNScCNh8TcQ/kIc+qGLQch8ag8wb0keK3EP5kbGakk1H8Wwo7v+36rNQg==
1896+
dependencies:
1897+
libsodium "^0.7.0"
1898+
1899+
libsodium@^0.7.0:
1900+
version "0.7.10"
1901+
resolved "https://registry.yarnpkg.com/libsodium/-/libsodium-0.7.10.tgz#c2429a7e4c0836f879d701fec2c8a208af024159"
1902+
integrity sha512-eY+z7hDrDKxkAK+QKZVNv92A5KYkxfvIshtBJkmg5TSiCnYqZP3i9OO9whE79Pwgm4jGaoHgkM4ao/b9Cyu4zQ==
1903+
18871904
lines-and-columns@^1.1.6:
18881905
version "1.1.6"
18891906
resolved "https://registry.npmjs.org/lines-and-columns/-/lines-and-columns-1.1.6.tgz#1c00c743b433cd0a4e80758f7b64a57440d9ff00"
@@ -2920,24 +2937,11 @@ tsutils@^3.21.0:
29202937
dependencies:
29212938
tslib "^1.8.1"
29222939

2923-
2940+
[email protected], tunnel@^0.0.6:
29242941
version "0.0.6"
29252942
resolved "https://registry.npmjs.org/tunnel/-/tunnel-0.0.6.tgz#72f1314b34a5b192db012324df2cc587ca47f92c"
29262943
integrity sha512-1h/Lnq9yajKY2PEbBadPXj3VxsDDu844OnaAo52UVmIzIvwwtBPIuNvkjuzBlTWpfJyUbG3ez0KSBibQkj4ojg==
29272944

2928-
tweetnacl@^1.0.1:
2929-
version "1.0.3"
2930-
resolved "https://registry.npmjs.org/tweetnacl/-/tweetnacl-1.0.3.tgz#ac0af71680458d8a6378d0d0d050ab1407d35596"
2931-
integrity sha512-6rt+RN7aOi1nGMyC4Xa5DdYiukl2UWCbcJft7YhxReBGQD7OAM8Pbxw6YMo4r2diNEA8FEmu32YOn9rhaiE5yw==
2932-
2933-
tweetsodium@^0.0.5:
2934-
version "0.0.5"
2935-
resolved "https://registry.npmjs.org/tweetsodium/-/tweetsodium-0.0.5.tgz#f63ab4b1d26d6355d82d512a2bbf03cae96eb3e8"
2936-
integrity sha512-T3aXZtx7KqQbutTtBfn+P5By3HdBuB1eCoGviIrRJV2sXeToxv2X2cv5RvYqgG26PSnN5m3fYixds22Gkfd11w==
2937-
dependencies:
2938-
blakejs "^1.1.0"
2939-
tweetnacl "^1.0.1"
2940-
29412945
type-check@^0.4.0, type-check@~0.4.0:
29422946
version "0.4.0"
29432947
resolved "https://registry.npmjs.org/type-check/-/type-check-0.4.0.tgz#07b8203bfa7056c0657050e3ccd2c37730bab8f1"
@@ -3015,6 +3019,11 @@ util-deprecate@^1.0.1:
30153019
resolved "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz#450d4dc9fa70de732762fbd2d4a28981419a0ccf"
30163020
integrity sha1-RQ1Nyfpw3nMnYvvS1KKJgUGaDM8=
30173021

3022+
uuid@^8.3.2:
3023+
version "8.3.2"
3024+
resolved "https://registry.yarnpkg.com/uuid/-/uuid-8.3.2.tgz#80d5b5ced271bb9af6c445f21a1a04c606cefbe2"
3025+
integrity sha512-+NYs2QeMWy+GWFOEm9xnn6HCDp0l7QBD7ml8zLUmJ+93Q5NF0NocErnwkTkXVFNiX3/fpC6afS8Dhb/gz7R7eg==
3026+
30183027
v8-compile-cache@^2.0.3:
30193028
version "2.3.0"
30203029
resolved "https://registry.npmjs.org/v8-compile-cache/-/v8-compile-cache-2.3.0.tgz#2de19618c66dc247dcfb6f99338035d8245a2cee"

0 commit comments

Comments
 (0)