@eetr/eetr-auth-client 0.2.0 → 0.3.1
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.d.ts +2 -0
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/dist/passkeys.d.ts +43 -0
- package/dist/passkeys.d.ts.map +1 -0
- package/dist/passkeys.js +57 -0
- package/dist/passkeys.js.map +1 -0
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -7,4 +7,6 @@ export { validateJwt, decodeJwtPayload } from "./jwt.js";
|
|
|
7
7
|
export type { ValidateJwtOptions } from "./jwt.js";
|
|
8
8
|
export { getAdminUser, createAdminUser, updateAdminUser, deleteAdminUser, } from "./admin.js";
|
|
9
9
|
export type { AdminUserRecord, AdminClientConfig, CreateUserParams, UpdateUserParams, } from "./admin.js";
|
|
10
|
+
export { listPasskeys, renamePasskey, removePasskey } from "./passkeys.js";
|
|
11
|
+
export type { PasskeySummary, UserClientConfig } from "./passkeys.js";
|
|
10
12
|
//# sourceMappingURL=index.d.ts.map
|
package/dist/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,uBAAuB,GACxB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAExE,OAAO,EACL,UAAU,EACV,aAAa,EACb,eAAe,EACf,WAAW,GACZ,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACzD,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEnD,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EACf,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAAA,YAAY,EACV,aAAa,EACb,gBAAgB,EAChB,aAAa,EACb,mBAAmB,EACnB,gBAAgB,EAChB,UAAU,EACV,uBAAuB,GACxB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAExE,OAAO,EACL,UAAU,EACV,aAAa,EACb,eAAe,EACf,WAAW,GACZ,MAAM,UAAU,CAAC;AAClB,YAAY,EACV,SAAS,EACT,mBAAmB,EACnB,mBAAmB,EACnB,qBAAqB,EACrB,qBAAqB,GACtB,MAAM,UAAU,CAAC;AAElB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AACzD,YAAY,EAAE,kBAAkB,EAAE,MAAM,UAAU,CAAC;AAEnD,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EACf,eAAe,GAChB,MAAM,YAAY,CAAC;AACpB,YAAY,EACV,eAAe,EACf,iBAAiB,EACjB,gBAAgB,EAChB,gBAAgB,GACjB,MAAM,YAAY,CAAC;AAEpB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC;AAC3E,YAAY,EAAE,cAAc,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAC"}
|
package/dist/index.js
CHANGED
|
@@ -3,4 +3,5 @@ export { OAuthError, exchangeToken, introspectToken, getUserInfo, } from "./api.
|
|
|
3
3
|
export { TokenManager } from "./tokens.js";
|
|
4
4
|
export { validateJwt, decodeJwtPayload } from "./jwt.js";
|
|
5
5
|
export { getAdminUser, createAdminUser, updateAdminUser, deleteAdminUser, } from "./admin.js";
|
|
6
|
+
export { listPasskeys, renamePasskey, removePasskey } from "./passkeys.js";
|
|
6
7
|
//# sourceMappingURL=index.js.map
|
package/dist/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAExE,OAAO,EACL,UAAU,EACV,aAAa,EACb,eAAe,EACf,WAAW,GACZ,MAAM,UAAU,CAAC;AASlB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGzD,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EACf,eAAe,GAChB,MAAM,YAAY,CAAC"}
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../src/index.ts"],"names":[],"mappings":"AAUA,OAAO,EAAE,kBAAkB,EAAE,kBAAkB,EAAE,MAAM,gBAAgB,CAAC;AAExE,OAAO,EACL,UAAU,EACV,aAAa,EACb,eAAe,EACf,WAAW,GACZ,MAAM,UAAU,CAAC;AASlB,OAAO,EAAE,YAAY,EAAE,MAAM,aAAa,CAAC;AAE3C,OAAO,EAAE,WAAW,EAAE,gBAAgB,EAAE,MAAM,UAAU,CAAC;AAGzD,OAAO,EACL,YAAY,EACZ,eAAe,EACf,eAAe,EACf,eAAe,GAChB,MAAM,YAAY,CAAC;AAQpB,OAAO,EAAE,YAAY,EAAE,aAAa,EAAE,aAAa,EAAE,MAAM,eAAe,CAAC"}
|
|
@@ -0,0 +1,43 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* Safe, display-only view of a passkey returned by the auth server. Mirrors the
|
|
3
|
+
* server-side `PasskeySummary` — never includes the public key, counter, or raw
|
|
4
|
+
* credential id.
|
|
5
|
+
*/
|
|
6
|
+
export interface PasskeySummary {
|
|
7
|
+
id: string;
|
|
8
|
+
name: string | null;
|
|
9
|
+
/** Backed up / synced across devices (e.g. iCloud Keychain, Google Password Manager). */
|
|
10
|
+
synced: boolean;
|
|
11
|
+
/** Single-device credential. */
|
|
12
|
+
deviceBound: boolean;
|
|
13
|
+
createdAt: string;
|
|
14
|
+
lastUsedAt: string | null;
|
|
15
|
+
}
|
|
16
|
+
/**
|
|
17
|
+
* Config for the passkey management endpoints. These are user-scoped: the access
|
|
18
|
+
* token must belong to the user whose passkeys are being managed.
|
|
19
|
+
*
|
|
20
|
+
* Note: only passkey *management* (list/rename/remove) is available here. Creating
|
|
21
|
+
* or authenticating with a passkey is a WebAuthn ceremony that requires a browser
|
|
22
|
+
* and cannot be driven by a server-side client.
|
|
23
|
+
*/
|
|
24
|
+
export interface UserClientConfig {
|
|
25
|
+
baseUrl: string;
|
|
26
|
+
accessToken: string;
|
|
27
|
+
}
|
|
28
|
+
/**
|
|
29
|
+
* List the authenticated user's passkeys.
|
|
30
|
+
*/
|
|
31
|
+
export declare function listPasskeys(config: UserClientConfig): Promise<PasskeySummary[]>;
|
|
32
|
+
/**
|
|
33
|
+
* Rename one of the authenticated user's passkeys. Throws `OAuthError` with code
|
|
34
|
+
* `not_found` if the passkey does not exist or is not owned by the user.
|
|
35
|
+
*/
|
|
36
|
+
export declare function renamePasskey(id: string, name: string, config: UserClientConfig): Promise<void>;
|
|
37
|
+
/**
|
|
38
|
+
* Remove one of the authenticated user's passkeys (server-side record only — this
|
|
39
|
+
* does not delete the credential from the device/authenticator). Throws `OAuthError`
|
|
40
|
+
* with code `not_found` if the passkey does not exist or is not owned by the user.
|
|
41
|
+
*/
|
|
42
|
+
export declare function removePasskey(id: string, config: UserClientConfig): Promise<void>;
|
|
43
|
+
//# sourceMappingURL=passkeys.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passkeys.d.ts","sourceRoot":"","sources":["../src/passkeys.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,MAAM,WAAW,cAAc;IAC7B,EAAE,EAAE,MAAM,CAAC;IACX,IAAI,EAAE,MAAM,GAAG,IAAI,CAAC;IACpB,yFAAyF;IACzF,MAAM,EAAE,OAAO,CAAC;IAChB,gCAAgC;IAChC,WAAW,EAAE,OAAO,CAAC;IACrB,SAAS,EAAE,MAAM,CAAC;IAClB,UAAU,EAAE,MAAM,GAAG,IAAI,CAAC;CAC3B;AAED;;;;;;;GAOG;AACH,MAAM,WAAW,gBAAgB;IAC/B,OAAO,EAAE,MAAM,CAAC;IAChB,WAAW,EAAE,MAAM,CAAC;CACrB;AAqBD;;GAEG;AACH,wBAAsB,YAAY,CAAC,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,cAAc,EAAE,CAAC,CAStF;AAED;;;GAGG;AACH,wBAAsB,aAAa,CACjC,EAAE,EAAE,MAAM,EACV,IAAI,EAAE,MAAM,EACZ,MAAM,EAAE,gBAAgB,GACvB,OAAO,CAAC,IAAI,CAAC,CAYf;AAED;;;;GAIG;AACH,wBAAsB,aAAa,CAAC,EAAE,EAAE,MAAM,EAAE,MAAM,EAAE,gBAAgB,GAAG,OAAO,CAAC,IAAI,CAAC,CAQvF"}
|
package/dist/passkeys.js
ADDED
|
@@ -0,0 +1,57 @@
|
|
|
1
|
+
import { OAuthError } from "./api.js";
|
|
2
|
+
function passkeysUrl(baseUrl, id) {
|
|
3
|
+
const trimmed = baseUrl.replace(/\/+$/, "");
|
|
4
|
+
if (id === undefined) {
|
|
5
|
+
return `${trimmed}/api/users/passkey`;
|
|
6
|
+
}
|
|
7
|
+
return `${trimmed}/api/users/passkey/${encodeURIComponent(id)}`;
|
|
8
|
+
}
|
|
9
|
+
async function parseError(res) {
|
|
10
|
+
const data = (await res.json().catch(() => ({})));
|
|
11
|
+
return new OAuthError(data.error ?? "server_error", data.error_description ?? `Passkey API request failed: ${res.status}`);
|
|
12
|
+
}
|
|
13
|
+
/**
|
|
14
|
+
* List the authenticated user's passkeys.
|
|
15
|
+
*/
|
|
16
|
+
export async function listPasskeys(config) {
|
|
17
|
+
const res = await fetch(passkeysUrl(config.baseUrl), {
|
|
18
|
+
headers: { Authorization: `Bearer ${config.accessToken}` },
|
|
19
|
+
});
|
|
20
|
+
if (!res.ok) {
|
|
21
|
+
throw await parseError(res);
|
|
22
|
+
}
|
|
23
|
+
const data = (await res.json());
|
|
24
|
+
return data.passkeys;
|
|
25
|
+
}
|
|
26
|
+
/**
|
|
27
|
+
* Rename one of the authenticated user's passkeys. Throws `OAuthError` with code
|
|
28
|
+
* `not_found` if the passkey does not exist or is not owned by the user.
|
|
29
|
+
*/
|
|
30
|
+
export async function renamePasskey(id, name, config) {
|
|
31
|
+
const res = await fetch(passkeysUrl(config.baseUrl, id), {
|
|
32
|
+
method: "PATCH",
|
|
33
|
+
headers: {
|
|
34
|
+
Authorization: `Bearer ${config.accessToken}`,
|
|
35
|
+
"Content-Type": "application/json",
|
|
36
|
+
},
|
|
37
|
+
body: JSON.stringify({ name }),
|
|
38
|
+
});
|
|
39
|
+
if (!res.ok) {
|
|
40
|
+
throw await parseError(res);
|
|
41
|
+
}
|
|
42
|
+
}
|
|
43
|
+
/**
|
|
44
|
+
* Remove one of the authenticated user's passkeys (server-side record only — this
|
|
45
|
+
* does not delete the credential from the device/authenticator). Throws `OAuthError`
|
|
46
|
+
* with code `not_found` if the passkey does not exist or is not owned by the user.
|
|
47
|
+
*/
|
|
48
|
+
export async function removePasskey(id, config) {
|
|
49
|
+
const res = await fetch(passkeysUrl(config.baseUrl, id), {
|
|
50
|
+
method: "DELETE",
|
|
51
|
+
headers: { Authorization: `Bearer ${config.accessToken}` },
|
|
52
|
+
});
|
|
53
|
+
if (!res.ok) {
|
|
54
|
+
throw await parseError(res);
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
//# sourceMappingURL=passkeys.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"passkeys.js","sourceRoot":"","sources":["../src/passkeys.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,UAAU,EAAE,MAAM,UAAU,CAAC;AA+BtC,SAAS,WAAW,CAAC,OAAe,EAAE,EAAW;IAC/C,MAAM,OAAO,GAAG,OAAO,CAAC,OAAO,CAAC,MAAM,EAAE,EAAE,CAAC,CAAC;IAC5C,IAAI,EAAE,KAAK,SAAS,EAAE,CAAC;QACrB,OAAO,GAAG,OAAO,oBAAoB,CAAC;IACxC,CAAC;IACD,OAAO,GAAG,OAAO,sBAAsB,kBAAkB,CAAC,EAAE,CAAC,EAAE,CAAC;AAClE,CAAC;AAED,KAAK,UAAU,UAAU,CAAC,GAAa;IACrC,MAAM,IAAI,GAAG,CAAC,MAAM,GAAG,CAAC,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,EAAE,CAAC,CAAC,EAAE,CAAC,CAAC,CAG/C,CAAC;IACF,OAAO,IAAI,UAAU,CACnB,IAAI,CAAC,KAAK,IAAI,cAAc,EAC5B,IAAI,CAAC,iBAAiB,IAAI,+BAA+B,GAAG,CAAC,MAAM,EAAE,CACtE,CAAC;AACJ,CAAC;AAED;;GAEG;AACH,MAAM,CAAC,KAAK,UAAU,YAAY,CAAC,MAAwB;IACzD,MAAM,GAAG,GAAG,MAAM,KAAK,CAAC,WAAW,CAAC,MAAM,CAAC,OAAO,CAAC,EAAE;QACnD,OAAO,EAAE,EAAE,aAAa,EAAE,UAAU,MAAM,CAAC,WAAW,EAAE,EAAE;KAC3D,CAAC,CAAC;IACH,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE,CAAC;QACZ,MAAM,MAAM,UAAU,CAAC,GAAG,CAAC,CAAC;IAC9B,CAAC;IAC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