@aooth/login-client 0.2.0 → 0.2.2
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/dist/index.cjs +2 -3
- package/dist/index.d.cts +5 -8
- package/dist/index.d.mts +5 -8
- package/dist/index.mjs +2 -3
- package/package.json +2 -4
package/dist/index.cjs
CHANGED
|
@@ -2,7 +2,7 @@ Object.defineProperty(exports, Symbol.toStringTag, { value: "Module" });
|
|
|
2
2
|
let node_child_process = require("node:child_process");
|
|
3
3
|
let node_crypto = require("node:crypto");
|
|
4
4
|
let node_http = require("node:http");
|
|
5
|
-
|
|
5
|
+
// src/index.ts
|
|
6
6
|
/** A typed failure of the loopback login flow. */
|
|
7
7
|
var AuthorizeError = class extends Error {
|
|
8
8
|
code;
|
|
@@ -12,7 +12,7 @@ var AuthorizeError = class extends Error {
|
|
|
12
12
|
this.code = code;
|
|
13
13
|
}
|
|
14
14
|
};
|
|
15
|
-
const DEFAULT_TIMEOUT_MS =
|
|
15
|
+
const DEFAULT_TIMEOUT_MS = 3e5;
|
|
16
16
|
/** RFC 4648 §5 base64url (no padding) of raw bytes. */
|
|
17
17
|
function base64url(bytes) {
|
|
18
18
|
return bytes.toString("base64url");
|
|
@@ -198,6 +198,5 @@ async function authorize(opts) {
|
|
|
198
198
|
...userId !== void 0 && { userId }
|
|
199
199
|
};
|
|
200
200
|
}
|
|
201
|
-
//#endregion
|
|
202
201
|
exports.AuthorizeError = AuthorizeError;
|
|
203
202
|
exports.authorize = authorize;
|
package/dist/index.d.cts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/index.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* `@aooth/login-client` — a zero-dependency helper that obtains a token from an
|
|
4
3
|
* aoothjs authorization server by driving the user through a **browser login**
|
|
@@ -13,7 +12,7 @@
|
|
|
13
12
|
* is identical.
|
|
14
13
|
*/
|
|
15
14
|
/** Error codes surfaced by {@link authorize}. */
|
|
16
|
-
type AuthorizeErrorCode =
|
|
15
|
+
export type AuthorizeErrorCode =
|
|
17
16
|
/** The provider returned `?error=` on the callback (e.g. the user declined). */
|
|
18
17
|
"provider_denied" |
|
|
19
18
|
/** The callback `state` did not match the one we generated (CSRF / instance mismatch). */
|
|
@@ -25,11 +24,11 @@ type AuthorizeErrorCode =
|
|
|
25
24
|
/** The optional `statusUrl` confirmation did not return 200. */
|
|
26
25
|
"status_check_failed";
|
|
27
26
|
/** A typed failure of the loopback login flow. */
|
|
28
|
-
declare class AuthorizeError extends Error {
|
|
27
|
+
export declare class AuthorizeError extends Error {
|
|
29
28
|
readonly code: AuthorizeErrorCode;
|
|
30
29
|
constructor(code: AuthorizeErrorCode, message: string);
|
|
31
30
|
}
|
|
32
|
-
interface AuthorizeOptions {
|
|
31
|
+
export interface AuthorizeOptions {
|
|
33
32
|
/** The authorization server's `GET /auth/authorize` URL. */
|
|
34
33
|
authorizeUrl: string;
|
|
35
34
|
/** The authorization server's `POST /auth/token` URL. */
|
|
@@ -61,7 +60,7 @@ interface AuthorizeOptions {
|
|
|
61
60
|
/** Abort the wait early (e.g. on SIGINT). */
|
|
62
61
|
signal?: AbortSignal;
|
|
63
62
|
}
|
|
64
|
-
interface AuthorizeResult {
|
|
63
|
+
export interface AuthorizeResult {
|
|
65
64
|
/** The bearer access token to send as `Authorization: Bearer <accessToken>`. */
|
|
66
65
|
accessToken: string;
|
|
67
66
|
/** Access-token lifetime in seconds, as reported by the token endpoint. */
|
|
@@ -85,6 +84,4 @@ interface AuthorizeResult {
|
|
|
85
84
|
* the binding. (Tier-2 `id_token` signature verification is the relying
|
|
86
85
|
* service's job via an OIDC client, not a CLI's.)
|
|
87
86
|
*/
|
|
88
|
-
declare function authorize(opts: AuthorizeOptions): Promise<AuthorizeResult>;
|
|
89
|
-
//#endregion
|
|
90
|
-
export { AuthorizeError, AuthorizeErrorCode, AuthorizeOptions, AuthorizeResult, authorize };
|
|
87
|
+
export declare function authorize(opts: AuthorizeOptions): Promise<AuthorizeResult>;
|
package/dist/index.d.mts
CHANGED
|
@@ -1,4 +1,3 @@
|
|
|
1
|
-
//#region src/index.d.ts
|
|
2
1
|
/**
|
|
3
2
|
* `@aooth/login-client` — a zero-dependency helper that obtains a token from an
|
|
4
3
|
* aoothjs authorization server by driving the user through a **browser login**
|
|
@@ -13,7 +12,7 @@
|
|
|
13
12
|
* is identical.
|
|
14
13
|
*/
|
|
15
14
|
/** Error codes surfaced by {@link authorize}. */
|
|
16
|
-
type AuthorizeErrorCode =
|
|
15
|
+
export type AuthorizeErrorCode =
|
|
17
16
|
/** The provider returned `?error=` on the callback (e.g. the user declined). */
|
|
18
17
|
"provider_denied" |
|
|
19
18
|
/** The callback `state` did not match the one we generated (CSRF / instance mismatch). */
|
|
@@ -25,11 +24,11 @@ type AuthorizeErrorCode =
|
|
|
25
24
|
/** The optional `statusUrl` confirmation did not return 200. */
|
|
26
25
|
"status_check_failed";
|
|
27
26
|
/** A typed failure of the loopback login flow. */
|
|
28
|
-
declare class AuthorizeError extends Error {
|
|
27
|
+
export declare class AuthorizeError extends Error {
|
|
29
28
|
readonly code: AuthorizeErrorCode;
|
|
30
29
|
constructor(code: AuthorizeErrorCode, message: string);
|
|
31
30
|
}
|
|
32
|
-
interface AuthorizeOptions {
|
|
31
|
+
export interface AuthorizeOptions {
|
|
33
32
|
/** The authorization server's `GET /auth/authorize` URL. */
|
|
34
33
|
authorizeUrl: string;
|
|
35
34
|
/** The authorization server's `POST /auth/token` URL. */
|
|
@@ -61,7 +60,7 @@ interface AuthorizeOptions {
|
|
|
61
60
|
/** Abort the wait early (e.g. on SIGINT). */
|
|
62
61
|
signal?: AbortSignal;
|
|
63
62
|
}
|
|
64
|
-
interface AuthorizeResult {
|
|
63
|
+
export interface AuthorizeResult {
|
|
65
64
|
/** The bearer access token to send as `Authorization: Bearer <accessToken>`. */
|
|
66
65
|
accessToken: string;
|
|
67
66
|
/** Access-token lifetime in seconds, as reported by the token endpoint. */
|
|
@@ -85,6 +84,4 @@ interface AuthorizeResult {
|
|
|
85
84
|
* the binding. (Tier-2 `id_token` signature verification is the relying
|
|
86
85
|
* service's job via an OIDC client, not a CLI's.)
|
|
87
86
|
*/
|
|
88
|
-
declare function authorize(opts: AuthorizeOptions): Promise<AuthorizeResult>;
|
|
89
|
-
//#endregion
|
|
90
|
-
export { AuthorizeError, AuthorizeErrorCode, AuthorizeOptions, AuthorizeResult, authorize };
|
|
87
|
+
export declare function authorize(opts: AuthorizeOptions): Promise<AuthorizeResult>;
|
package/dist/index.mjs
CHANGED
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { spawn } from "node:child_process";
|
|
2
2
|
import { createHash, randomBytes } from "node:crypto";
|
|
3
3
|
import { createServer } from "node:http";
|
|
4
|
-
|
|
4
|
+
// src/index.ts
|
|
5
5
|
/** A typed failure of the loopback login flow. */
|
|
6
6
|
var AuthorizeError = class extends Error {
|
|
7
7
|
code;
|
|
@@ -11,7 +11,7 @@ var AuthorizeError = class extends Error {
|
|
|
11
11
|
this.code = code;
|
|
12
12
|
}
|
|
13
13
|
};
|
|
14
|
-
const DEFAULT_TIMEOUT_MS =
|
|
14
|
+
const DEFAULT_TIMEOUT_MS = 3e5;
|
|
15
15
|
/** RFC 4648 §5 base64url (no padding) of raw bytes. */
|
|
16
16
|
function base64url(bytes) {
|
|
17
17
|
return bytes.toString("base64url");
|
|
@@ -197,5 +197,4 @@ async function authorize(opts) {
|
|
|
197
197
|
...userId !== void 0 && { userId }
|
|
198
198
|
};
|
|
199
199
|
}
|
|
200
|
-
//#endregion
|
|
201
200
|
export { AuthorizeError, authorize };
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@aooth/login-client",
|
|
3
|
-
"version": "0.2.
|
|
3
|
+
"version": "0.2.2",
|
|
4
4
|
"description": "Zero-dependency CLI/loopback login helper for an aoothjs authorization server (browser round-trip + PKCE, returns a token)",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"aoothjs",
|
|
@@ -42,9 +42,7 @@
|
|
|
42
42
|
"access": "public"
|
|
43
43
|
},
|
|
44
44
|
"dependencies": {},
|
|
45
|
-
"devDependencies": {
|
|
46
|
-
"vitest": "npm:@voidzero-dev/vite-plus-test@latest"
|
|
47
|
-
},
|
|
45
|
+
"devDependencies": {},
|
|
48
46
|
"engines": {
|
|
49
47
|
"node": ">=18"
|
|
50
48
|
},
|