@stackframe/stack-shared 2.6.6 → 2.6.8
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/CHANGELOG.md +14 -0
- package/dist/utils/bytes.d.ts +3 -0
- package/dist/utils/bytes.js +18 -0
- package/dist/utils/jwt.js +4 -4
- package/package.json +2 -2
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,19 @@
|
|
|
1
1
|
# @stackframe/stack-shared
|
|
2
2
|
|
|
3
|
+
## 2.6.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Bugfixes
|
|
8
|
+
- @stackframe/stack-sc@2.6.8
|
|
9
|
+
|
|
10
|
+
## 2.6.7
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- @stackframe/stack-sc@2.6.7
|
|
16
|
+
|
|
3
17
|
## 2.6.6
|
|
4
18
|
|
|
5
19
|
### Patch Changes
|
package/dist/utils/bytes.d.ts
CHANGED
|
@@ -2,5 +2,8 @@ export declare function encodeBase32(input: Uint8Array): string;
|
|
|
2
2
|
export declare function decodeBase32(input: string): Uint8Array;
|
|
3
3
|
export declare function encodeBase64(input: Uint8Array): string;
|
|
4
4
|
export declare function decodeBase64(input: string): Uint8Array;
|
|
5
|
+
export declare function encodeBase64Url(input: Uint8Array): string;
|
|
6
|
+
export declare function decodeBase64Url(input: string): Uint8Array;
|
|
5
7
|
export declare function isBase32(input: string): boolean;
|
|
6
8
|
export declare function isBase64(input: string): boolean;
|
|
9
|
+
export declare function isBase64Url(input: string): boolean;
|
package/dist/utils/bytes.js
CHANGED
|
@@ -68,6 +68,20 @@ export function decodeBase64(input) {
|
|
|
68
68
|
}
|
|
69
69
|
return new Uint8Array(atob(input).split("").map((char) => char.charCodeAt(0)));
|
|
70
70
|
}
|
|
71
|
+
export function encodeBase64Url(input) {
|
|
72
|
+
const res = encodeBase64(input).replace(/=+$/, "").replace(/\+/g, "-").replace(/\//g, "_");
|
|
73
|
+
// sanity check
|
|
74
|
+
if (!isBase64Url(res)) {
|
|
75
|
+
throw new StackAssertionError("Invalid base64url output; this should never happen");
|
|
76
|
+
}
|
|
77
|
+
return res;
|
|
78
|
+
}
|
|
79
|
+
export function decodeBase64Url(input) {
|
|
80
|
+
if (!isBase64Url(input)) {
|
|
81
|
+
throw new StackAssertionError("Invalid base64url string");
|
|
82
|
+
}
|
|
83
|
+
return decodeBase64(input.replace(/-/g, "+").replace(/_/g, "/") + "====".slice((input.length - 1) % 4 + 1));
|
|
84
|
+
}
|
|
71
85
|
export function isBase32(input) {
|
|
72
86
|
for (const char of input) {
|
|
73
87
|
if (char === " ")
|
|
@@ -82,3 +96,7 @@ export function isBase64(input) {
|
|
|
82
96
|
const regex = /^([0-9a-zA-Z+/]{4})*(([0-9a-zA-Z+/]{2}==)|([0-9a-zA-Z+/]{3}=))?$/;
|
|
83
97
|
return regex.test(input);
|
|
84
98
|
}
|
|
99
|
+
export function isBase64Url(input) {
|
|
100
|
+
const regex = /^[0-9a-zA-Z_-]+$/;
|
|
101
|
+
return regex.test(input);
|
|
102
|
+
}
|
package/dist/utils/jwt.js
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import elliptic from "elliptic";
|
|
2
2
|
import * as jose from "jose";
|
|
3
|
-
import {
|
|
3
|
+
import { encodeBase64Url } from "./bytes";
|
|
4
4
|
import { getEnvVariable } from "./env";
|
|
5
5
|
import { globalVar } from "./globals";
|
|
6
6
|
import { pick } from "./objects";
|
|
@@ -60,9 +60,9 @@ export async function getPrivateJwk(secret) {
|
|
|
60
60
|
return {
|
|
61
61
|
kty: 'EC',
|
|
62
62
|
crv: 'P-256',
|
|
63
|
-
d:
|
|
64
|
-
x:
|
|
65
|
-
y:
|
|
63
|
+
d: encodeBase64Url(priv),
|
|
64
|
+
x: encodeBase64Url(publicKey.getX().toBuffer()),
|
|
65
|
+
y: encodeBase64Url(publicKey.getY().toBuffer()),
|
|
66
66
|
};
|
|
67
67
|
}
|
|
68
68
|
export async function getPublicJwkSet(secret) {
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@stackframe/stack-shared",
|
|
3
|
-
"version": "2.6.
|
|
3
|
+
"version": "2.6.8",
|
|
4
4
|
"main": "./dist/index.js",
|
|
5
5
|
"types": "./dist/index.d.ts",
|
|
6
6
|
"files": [
|
|
@@ -38,7 +38,7 @@
|
|
|
38
38
|
"oauth4webapi": "^2.10.3",
|
|
39
39
|
"semver": "^7.6.3",
|
|
40
40
|
"uuid": "^9.0.1",
|
|
41
|
-
"@stackframe/stack-sc": "2.6.
|
|
41
|
+
"@stackframe/stack-sc": "2.6.8"
|
|
42
42
|
},
|
|
43
43
|
"devDependencies": {
|
|
44
44
|
"@types/bcrypt": "^5.0.2",
|