@insaeng/auth 0.1.0 → 0.4.0

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.
Files changed (39) hide show
  1. package/dist/data/auth/auth-repo.d.ts +7 -0
  2. package/dist/data/auth/auth-repo.d.ts.map +1 -0
  3. package/dist/data/auth/auth-repo.js +43 -0
  4. package/dist/{verify.d.ts → data/sources/jwks/jwks-source.d.ts} +7 -4
  5. package/dist/data/sources/jwks/jwks-source.d.ts.map +1 -0
  6. package/dist/{verify.js → data/sources/jwks/jwks-source.js} +16 -20
  7. package/dist/{testing.d.ts → data/sources/jwks/test-issuer-source.d.ts} +3 -3
  8. package/dist/data/sources/jwks/test-issuer-source.d.ts.map +1 -0
  9. package/dist/{testing.js → data/sources/jwks/test-issuer-source.js} +1 -1
  10. package/dist/data/sources/oauth/oauth-source.d.ts +18 -0
  11. package/dist/data/sources/oauth/oauth-source.d.ts.map +1 -0
  12. package/dist/data/sources/oauth/oauth-source.js +104 -0
  13. package/dist/dependencies.d.ts +12 -0
  14. package/dist/dependencies.d.ts.map +1 -0
  15. package/dist/dependencies.js +13 -0
  16. package/dist/domain/auth/auth-entity.d.ts +20 -0
  17. package/dist/domain/auth/auth-entity.d.ts.map +1 -0
  18. package/dist/domain/auth/auth-entity.js +14 -0
  19. package/dist/domain/auth/auth-repo.d.ts +6 -0
  20. package/dist/domain/auth/auth-repo.d.ts.map +1 -0
  21. package/dist/domain/auth/auth-repo.js +1 -0
  22. package/dist/domain/auth/use-cases/assert-can-use-case.d.ts +8 -0
  23. package/dist/domain/auth/use-cases/assert-can-use-case.d.ts.map +1 -0
  24. package/dist/domain/auth/use-cases/assert-can-use-case.js +8 -0
  25. package/dist/domain/auth/use-cases/verify-access-token-use-case.d.ts +8 -0
  26. package/dist/domain/auth/use-cases/verify-access-token-use-case.d.ts.map +1 -0
  27. package/dist/domain/auth/use-cases/verify-access-token-use-case.js +13 -0
  28. package/package.json +13 -5
  29. package/src/data/auth/auth-repo.ts +58 -0
  30. package/src/{verify.ts → data/sources/jwks/jwks-source.ts} +21 -26
  31. package/src/{testing.ts → data/sources/jwks/test-issuer-source.ts} +2 -2
  32. package/src/data/sources/oauth/oauth-source.ts +140 -0
  33. package/src/dependencies.ts +28 -0
  34. package/src/domain/auth/auth-entity.ts +29 -0
  35. package/src/domain/auth/auth-repo.ts +10 -0
  36. package/src/domain/auth/use-cases/assert-can-use-case.ts +22 -0
  37. package/src/domain/auth/use-cases/verify-access-token-use-case.ts +23 -0
  38. package/dist/testing.d.ts.map +0 -1
  39. package/dist/verify.d.ts.map +0 -1
@@ -0,0 +1,7 @@
1
+ import type { AuthRepo } from "../../domain/auth/auth-repo.js";
2
+ import type { JwksSource } from "../sources/jwks/jwks-source.js";
3
+ export interface AuthRepoDeps {
4
+ jwks: JwksSource;
5
+ }
6
+ export declare function createAuthRepo({ jwks, }: AuthRepoDeps): Pick<AuthRepo, "findPrincipal">;
7
+ //# sourceMappingURL=auth-repo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-repo.d.ts","sourceRoot":"","sources":["../../../src/data/auth/auth-repo.ts"],"names":[],"mappings":"AAEA,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,gCAAgC,CAAC;AAC/D,OAAO,KAAK,EAEV,UAAU,EACX,MAAM,gCAAgC,CAAC;AAExC,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,UAAU,CAAC;CAClB;AAgCD,wBAAgB,cAAc,CAAC,EAC7B,IAAI,GACL,EAAE,YAAY,GAAG,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAahD"}
@@ -0,0 +1,43 @@
1
+ import { errors } from "jose";
2
+ const rejectedTokenErrors = [
3
+ errors.JWTClaimValidationFailed,
4
+ errors.JWTExpired,
5
+ errors.JWTInvalid,
6
+ errors.JWSInvalid,
7
+ errors.JWSSignatureVerificationFailed,
8
+ errors.JWKSNoMatchingKey,
9
+ errors.JOSEAlgNotAllowed,
10
+ errors.JOSENotSupported,
11
+ ];
12
+ function isRejectedToken(error) {
13
+ return rejectedTokenErrors.some((rejected) => error instanceof rejected);
14
+ }
15
+ function toPrincipal(claims) {
16
+ const principal = {
17
+ kind: claims.client_id === claims.sub ? "client" : "user",
18
+ id: claims.sub,
19
+ roles: claims.roles,
20
+ };
21
+ if (claims.email !== undefined) {
22
+ principal.email = claims.email;
23
+ }
24
+ if (claims.name !== undefined) {
25
+ principal.name = claims.name;
26
+ }
27
+ return principal;
28
+ }
29
+ export function createAuthRepo({ jwks, }) {
30
+ return {
31
+ async findPrincipal(accessToken) {
32
+ try {
33
+ return toPrincipal(await jwks.verify(accessToken));
34
+ }
35
+ catch (error) {
36
+ if (isRejectedToken(error)) {
37
+ return undefined;
38
+ }
39
+ throw error;
40
+ }
41
+ },
42
+ };
43
+ }
@@ -6,14 +6,17 @@ export interface AccessTokenClaims {
6
6
  email?: string;
7
7
  name?: string;
8
8
  }
9
- export type AccessTokenKeys = {
9
+ export type JwksKeys = {
10
10
  jwksUrl: string | URL;
11
11
  } | {
12
12
  keys: JWTVerifyGetKey;
13
13
  };
14
- export type VerifyAccessTokenOptions = AccessTokenKeys & {
14
+ export type JwksSourceOptions = JwksKeys & {
15
15
  issuer: string;
16
16
  audience: string;
17
17
  };
18
- export declare function verifyAccessToken(token: string, options: VerifyAccessTokenOptions): Promise<AccessTokenClaims>;
19
- //# sourceMappingURL=verify.d.ts.map
18
+ export interface JwksSource {
19
+ verify(accessToken: string): Promise<AccessTokenClaims>;
20
+ }
21
+ export declare function createJwksSource(options: JwksSourceOptions): JwksSource;
22
+ //# sourceMappingURL=jwks-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"jwks-source.d.ts","sourceRoot":"","sources":["../../../../src/data/sources/jwks/jwks-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,MAAM,CAAC;AAEd,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,QAAQ,GAAG;IAAE,OAAO,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,CAAC;AAE7E,MAAM,MAAM,iBAAiB,GAAG,QAAQ,GAAG;IACzC,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAEF,MAAM,WAAW,UAAU;IACzB,MAAM,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,iBAAiB,CAAC,CAAC;CACzD;AA0CD,wBAAgB,gBAAgB,CAAC,OAAO,EAAE,iBAAiB,GAAG,UAAU,CAiBvE"}
@@ -1,14 +1,4 @@
1
1
  import { createRemoteJWKSet, errors, jwtVerify, } from "jose";
2
- const remoteKeySets = new Map();
3
- function remoteKeySet(jwksUrl) {
4
- const href = new URL(jwksUrl).href;
5
- let keySet = remoteKeySets.get(href);
6
- if (keySet === undefined) {
7
- keySet = createRemoteJWKSet(new URL(href));
8
- remoteKeySets.set(href, keySet);
9
- }
10
- return keySet;
11
- }
12
2
  function invalidClaim(payload, claim, message) {
13
3
  throw new errors.JWTClaimValidationFailed(message, payload, claim, "invalid");
14
4
  }
@@ -37,14 +27,20 @@ function toClaims(payload) {
37
27
  }
38
28
  return claims;
39
29
  }
40
- export async function verifyAccessToken(token, options) {
41
- const keys = "keys" in options ? options.keys : remoteKeySet(options.jwksUrl);
42
- const { payload } = await jwtVerify(token, keys, {
43
- typ: "at+jwt",
44
- issuer: options.issuer,
45
- audience: options.audience,
46
- algorithms: ["EdDSA"],
47
- requiredClaims: ["exp", "sub"],
48
- });
49
- return toClaims(payload);
30
+ export function createJwksSource(options) {
31
+ const keys = "keys" in options
32
+ ? options.keys
33
+ : createRemoteJWKSet(new URL(options.jwksUrl));
34
+ return {
35
+ async verify(accessToken) {
36
+ const { payload } = await jwtVerify(accessToken, keys, {
37
+ typ: "at+jwt",
38
+ issuer: options.issuer,
39
+ audience: options.audience,
40
+ algorithms: ["EdDSA"],
41
+ requiredClaims: ["exp", "sub"],
42
+ });
43
+ return toClaims(payload);
44
+ },
45
+ };
50
46
  }
@@ -1,5 +1,5 @@
1
1
  import { type JSONWebKeySet, type JWTVerifyGetKey } from "jose";
2
- import type { AccessTokenClaims } from "./verify.js";
2
+ import type { AccessTokenClaims } from "./jwks-source.js";
3
3
  export interface TestIssuerOptions {
4
4
  issuer?: string;
5
5
  audience?: string;
@@ -17,5 +17,5 @@ export interface TestIssuer {
17
17
  keys: JWTVerifyGetKey;
18
18
  signAccessToken(claims: Partial<AccessTokenClaims>, options?: SignTestTokenOptions): Promise<string>;
19
19
  }
20
- export declare function createTestIssuer({ issuer, audience, }?: TestIssuerOptions): Promise<TestIssuer>;
21
- //# sourceMappingURL=testing.d.ts.map
20
+ export declare function createTestIssuerSource({ issuer, audience, }?: TestIssuerOptions): Promise<TestIssuer>;
21
+ //# sourceMappingURL=test-issuer-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"test-issuer-source.d.ts","sourceRoot":"","sources":["../../../../src/data/sources/jwks/test-issuer-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,kBAAkB,CAAC;AAE1D,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CACzC;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,eAAe,CAAC;IACtB,eAAe,CACb,MAAM,EAAE,OAAO,CAAC,iBAAiB,CAAC,EAClC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,MAAM,CAAC,CAAC;CACpB;AAED,wBAAsB,sBAAsB,CAAC,EAC3C,MAAoC,EACpC,QAAiC,GAClC,GAAE,iBAAsB,GAAG,OAAO,CAAC,UAAU,CAAC,CA2B9C"}
@@ -1,5 +1,5 @@
1
1
  import { calculateJwkThumbprint, createLocalJWKSet, exportJWK, generateKeyPair, SignJWT, } from "jose";
2
- export async function createTestIssuer({ issuer = "https://auth.insaeng.test", audience = "insaeng-test-service", } = {}) {
2
+ export async function createTestIssuerSource({ issuer = "https://auth.insaeng.test", audience = "insaeng-test-service", } = {}) {
3
3
  const { privateKey, publicKey } = await generateKeyPair("EdDSA", {
4
4
  crv: "Ed25519",
5
5
  });
@@ -0,0 +1,18 @@
1
+ import { type JWK } from "jose";
2
+ export interface OauthSourceOptions {
3
+ tokenEndpoint: string | URL;
4
+ clientId: string;
5
+ privateKey: JWK;
6
+ resource: string;
7
+ fetch?: typeof fetch;
8
+ }
9
+ export interface OauthSource {
10
+ getToken(): Promise<string>;
11
+ }
12
+ export declare class TokenRequestError extends Error {
13
+ readonly status: number;
14
+ readonly error: string | undefined;
15
+ constructor(status: number, error: string | undefined);
16
+ }
17
+ export declare function createOauthSource(options: OauthSourceOptions): OauthSource;
18
+ //# sourceMappingURL=oauth-source.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"oauth-source.d.ts","sourceRoot":"","sources":["../../../../src/data/sources/oauth/oauth-source.ts"],"names":[],"mappings":"AAAA,OAAO,EAAsB,KAAK,GAAG,EAAE,MAAM,MAAM,CAAC;AAEpD,MAAM,WAAW,kBAAkB;IACjC,aAAa,EAAE,MAAM,GAAG,GAAG,CAAC;IAC5B,QAAQ,EAAE,MAAM,CAAC;IACjB,UAAU,EAAE,GAAG,CAAC;IAChB,QAAQ,EAAE,MAAM,CAAC;IACjB,KAAK,CAAC,EAAE,OAAO,KAAK,CAAC;CACtB;AAED,MAAM,WAAW,WAAW;IAC1B,QAAQ,IAAI,OAAO,CAAC,MAAM,CAAC,CAAC;CAC7B;AAED,qBAAa,iBAAkB,SAAQ,KAAK;IAC1C,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;IACxB,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,SAAS,CAAC;gBAEvB,MAAM,EAAE,MAAM,EAAE,KAAK,EAAE,MAAM,GAAG,SAAS;CAStD;AA8CD,wBAAgB,iBAAiB,CAAC,OAAO,EAAE,kBAAkB,GAAG,WAAW,CAkE1E"}
@@ -0,0 +1,104 @@
1
+ import { importJWK, SignJWT } from "jose";
2
+ export class TokenRequestError extends Error {
3
+ status;
4
+ error;
5
+ constructor(status, error) {
6
+ super(`Token request failed with status ${String(status)}` +
7
+ (error === undefined ? "" : `: ${error}`));
8
+ this.name = "TokenRequestError";
9
+ this.status = status;
10
+ this.error = error;
11
+ }
12
+ }
13
+ const ASSERTION_TYPE = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer";
14
+ const ASSERTION_LIFETIME_SECONDS = 60;
15
+ const REFRESH_MARGIN_MS = 30_000;
16
+ function isRecord(value) {
17
+ return typeof value === "object" && value !== null;
18
+ }
19
+ async function readJson(response) {
20
+ try {
21
+ return await response.json();
22
+ }
23
+ catch {
24
+ return undefined;
25
+ }
26
+ }
27
+ function toCachedToken(body) {
28
+ if (!isRecord(body)) {
29
+ throw new TypeError("Token response must be a JSON object");
30
+ }
31
+ const { access_token, expires_in } = body;
32
+ if (typeof access_token !== "string" || access_token === "") {
33
+ throw new TypeError('Token response "access_token" must be a string');
34
+ }
35
+ if (typeof expires_in !== "number" ||
36
+ !Number.isFinite(expires_in) ||
37
+ expires_in <= 0) {
38
+ throw new TypeError('Token response "expires_in" must be a positive number');
39
+ }
40
+ return {
41
+ accessToken: access_token,
42
+ expiresAt: Date.now() + expires_in * 1000,
43
+ };
44
+ }
45
+ export function createOauthSource(options) {
46
+ const { clientId, privateKey, resource } = options;
47
+ const tokenEndpoint = String(options.tokenEndpoint);
48
+ const fetchToken = options.fetch ?? globalThis.fetch;
49
+ const kid = privateKey.kid ?? "";
50
+ if (kid === "") {
51
+ throw new TypeError('Client private key must have a "kid"');
52
+ }
53
+ let key;
54
+ let cached;
55
+ let pending;
56
+ async function signAssertion() {
57
+ key ??= importJWK(privateKey, "EdDSA");
58
+ return new SignJWT()
59
+ .setProtectedHeader({ alg: "EdDSA", kid })
60
+ .setIssuer(clientId)
61
+ .setSubject(clientId)
62
+ .setAudience(tokenEndpoint)
63
+ .setJti(crypto.randomUUID())
64
+ .setIssuedAt()
65
+ .setExpirationTime(`${String(ASSERTION_LIFETIME_SECONDS)}s`)
66
+ .sign(await key);
67
+ }
68
+ async function requestToken() {
69
+ const response = await fetchToken(tokenEndpoint, {
70
+ method: "POST",
71
+ headers: {
72
+ accept: "application/json",
73
+ "content-type": "application/x-www-form-urlencoded",
74
+ },
75
+ body: new URLSearchParams({
76
+ grant_type: "client_credentials",
77
+ client_assertion_type: ASSERTION_TYPE,
78
+ client_assertion: await signAssertion(),
79
+ resource,
80
+ }),
81
+ });
82
+ const body = await readJson(response);
83
+ if (!response.ok) {
84
+ const error = isRecord(body) && typeof body.error === "string"
85
+ ? body.error
86
+ : undefined;
87
+ throw new TokenRequestError(response.status, error);
88
+ }
89
+ cached = toCachedToken(body);
90
+ return cached.accessToken;
91
+ }
92
+ return {
93
+ getToken() {
94
+ if (cached !== undefined &&
95
+ cached.expiresAt - Date.now() > REFRESH_MARGIN_MS) {
96
+ return Promise.resolve(cached.accessToken);
97
+ }
98
+ pending ??= requestToken().finally(() => {
99
+ pending = undefined;
100
+ });
101
+ return pending;
102
+ },
103
+ };
104
+ }
@@ -0,0 +1,12 @@
1
+ import { type JwksSourceOptions } from "./data/sources/jwks/jwks-source.js";
2
+ import type { AuthRepo } from "./domain/auth/auth-repo.js";
3
+ import { verifyAccessTokenUseCase, type VerifyAccessToken } from "./domain/auth/use-cases/verify-access-token-use-case.js";
4
+ export type { JwksSourceOptions };
5
+ export { assertCanUseCase } from "./domain/auth/use-cases/assert-can-use-case.js";
6
+ export { verifyAccessTokenUseCase };
7
+ export interface Auth {
8
+ authRepo: Pick<AuthRepo, "findPrincipal">;
9
+ verifyAccessToken: VerifyAccessToken;
10
+ }
11
+ export declare function createAuth(options: JwksSourceOptions): Auth;
12
+ //# sourceMappingURL=dependencies.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"dependencies.d.ts","sourceRoot":"","sources":["../src/dependencies.ts"],"names":[],"mappings":"AACA,OAAO,EAEL,KAAK,iBAAiB,EACvB,MAAM,oCAAoC,CAAC;AAC5C,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,4BAA4B,CAAC;AAC3D,OAAO,EACL,wBAAwB,EACxB,KAAK,iBAAiB,EACvB,MAAM,yDAAyD,CAAC;AAEjE,YAAY,EAAE,iBAAiB,EAAE,CAAC;AAClC,OAAO,EAAE,gBAAgB,EAAE,MAAM,gDAAgD,CAAC;AAClF,OAAO,EAAE,wBAAwB,EAAE,CAAC;AAEpC,MAAM,WAAW,IAAI;IACnB,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;IAC1C,iBAAiB,EAAE,iBAAiB,CAAC;CACtC;AAED,wBAAgB,UAAU,CAAC,OAAO,EAAE,iBAAiB,GAAG,IAAI,CAO3D"}
@@ -0,0 +1,13 @@
1
+ import { createAuthRepo } from "./data/auth/auth-repo.js";
2
+ import { createJwksSource, } from "./data/sources/jwks/jwks-source.js";
3
+ import { verifyAccessTokenUseCase, } from "./domain/auth/use-cases/verify-access-token-use-case.js";
4
+ export { assertCanUseCase } from "./domain/auth/use-cases/assert-can-use-case.js";
5
+ export { verifyAccessTokenUseCase };
6
+ export function createAuth(options) {
7
+ const jwks = createJwksSource(options);
8
+ const authRepo = createAuthRepo({ jwks });
9
+ return {
10
+ authRepo,
11
+ verifyAccessToken: verifyAccessTokenUseCase({ authRepo }),
12
+ };
13
+ }
@@ -0,0 +1,20 @@
1
+ export type { AuthRepo } from "./auth-repo.js";
2
+ export type { AssertCan } from "./use-cases/assert-can-use-case.js";
3
+ export type { VerifyAccessToken } from "./use-cases/verify-access-token-use-case.js";
4
+ export interface Principal {
5
+ kind: "user" | "client";
6
+ id: string;
7
+ roles: readonly string[];
8
+ email?: string;
9
+ name?: string;
10
+ }
11
+ export declare class Unauthenticated extends Error {
12
+ readonly name = "Unauthenticated";
13
+ constructor();
14
+ }
15
+ export declare class Forbidden<Action extends string = string> extends Error {
16
+ readonly name = "Forbidden";
17
+ readonly action: Action;
18
+ constructor(action: Action);
19
+ }
20
+ //# sourceMappingURL=auth-entity.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-entity.d.ts","sourceRoot":"","sources":["../../../src/domain/auth/auth-entity.ts"],"names":[],"mappings":"AAAA,YAAY,EAAE,QAAQ,EAAE,MAAM,gBAAgB,CAAC;AAC/C,YAAY,EAAE,SAAS,EAAE,MAAM,oCAAoC,CAAC;AACpE,YAAY,EAAE,iBAAiB,EAAE,MAAM,6CAA6C,CAAC;AAErF,MAAM,WAAW,SAAS;IACxB,IAAI,EAAE,MAAM,GAAG,QAAQ,CAAC;IACxB,EAAE,EAAE,MAAM,CAAC;IACX,KAAK,EAAE,SAAS,MAAM,EAAE,CAAC;IACzB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,qBAAa,eAAgB,SAAQ,KAAK;IACxC,SAAkB,IAAI,qBAAqB;;CAK5C;AAED,qBAAa,SAAS,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,CAAE,SAAQ,KAAK;IAClE,SAAkB,IAAI,eAAe;IACrC,QAAQ,CAAC,MAAM,EAAE,MAAM,CAAC;gBAEZ,MAAM,EAAE,MAAM;CAI3B"}
@@ -0,0 +1,14 @@
1
+ export class Unauthenticated extends Error {
2
+ name = "Unauthenticated";
3
+ constructor() {
4
+ super("Unauthenticated");
5
+ }
6
+ }
7
+ export class Forbidden extends Error {
8
+ name = "Forbidden";
9
+ action;
10
+ constructor(action) {
11
+ super(`Forbidden: ${action}`);
12
+ this.action = action;
13
+ }
14
+ }
@@ -0,0 +1,6 @@
1
+ import type { Principal } from "./auth-entity.js";
2
+ export interface AuthRepo<Action extends string = string, Resource = unknown> {
3
+ findPrincipal(accessToken: string): Promise<Principal | undefined>;
4
+ can(principal: Principal, action: Action, resource: Resource): Promise<boolean>;
5
+ }
6
+ //# sourceMappingURL=auth-repo.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"auth-repo.d.ts","sourceRoot":"","sources":["../../../src/domain/auth/auth-repo.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,kBAAkB,CAAC;AAElD,MAAM,WAAW,QAAQ,CAAC,MAAM,SAAS,MAAM,GAAG,MAAM,EAAE,QAAQ,GAAG,OAAO;IAC1E,aAAa,CAAC,WAAW,EAAE,MAAM,GAAG,OAAO,CAAC,SAAS,GAAG,SAAS,CAAC,CAAC;IACnE,GAAG,CACD,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,GACjB,OAAO,CAAC,OAAO,CAAC,CAAC;CACrB"}
@@ -0,0 +1 @@
1
+ export {};
@@ -0,0 +1,8 @@
1
+ import { type Principal } from "../auth-entity.js";
2
+ import type { AuthRepo } from "../auth-repo.js";
3
+ export type AssertCan<Action extends string, Resource> = (principal: Principal, action: Action, resource: Resource) => Promise<void>;
4
+ export interface AssertCanDeps<Action extends string, Resource> {
5
+ authRepo: Pick<AuthRepo<Action, Resource>, "can">;
6
+ }
7
+ export declare function assertCanUseCase<Action extends string, Resource>({ authRepo, }: AssertCanDeps<Action, Resource>): AssertCan<Action, Resource>;
8
+ //# sourceMappingURL=assert-can-use-case.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"assert-can-use-case.d.ts","sourceRoot":"","sources":["../../../../src/domain/auth/use-cases/assert-can-use-case.ts"],"names":[],"mappings":"AAAA,OAAO,EAAa,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AAC9D,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,MAAM,SAAS,CAAC,MAAM,SAAS,MAAM,EAAE,QAAQ,IAAI,CACvD,SAAS,EAAE,SAAS,EACpB,MAAM,EAAE,MAAM,EACd,QAAQ,EAAE,QAAQ,KACf,OAAO,CAAC,IAAI,CAAC,CAAC;AAEnB,MAAM,WAAW,aAAa,CAAC,MAAM,SAAS,MAAM,EAAE,QAAQ;IAC5D,QAAQ,EAAE,IAAI,CAAC,QAAQ,CAAC,MAAM,EAAE,QAAQ,CAAC,EAAE,KAAK,CAAC,CAAC;CACnD;AAED,wBAAgB,gBAAgB,CAAC,MAAM,SAAS,MAAM,EAAE,QAAQ,EAAE,EAChE,QAAQ,GACT,EAAE,aAAa,CAAC,MAAM,EAAE,QAAQ,CAAC,GAAG,SAAS,CAAC,MAAM,EAAE,QAAQ,CAAC,CAM/D"}
@@ -0,0 +1,8 @@
1
+ import { Forbidden } from "../auth-entity.js";
2
+ export function assertCanUseCase({ authRepo, }) {
3
+ return async (principal, action, resource) => {
4
+ if (!(await authRepo.can(principal, action, resource))) {
5
+ throw new Forbidden(action);
6
+ }
7
+ };
8
+ }
@@ -0,0 +1,8 @@
1
+ import { type Principal } from "../auth-entity.js";
2
+ import type { AuthRepo } from "../auth-repo.js";
3
+ export type VerifyAccessToken = (accessToken: string) => Promise<Principal>;
4
+ export interface VerifyAccessTokenDeps {
5
+ authRepo: Pick<AuthRepo, "findPrincipal">;
6
+ }
7
+ export declare function verifyAccessTokenUseCase({ authRepo, }: VerifyAccessTokenDeps): VerifyAccessToken;
8
+ //# sourceMappingURL=verify-access-token-use-case.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"verify-access-token-use-case.d.ts","sourceRoot":"","sources":["../../../../src/domain/auth/use-cases/verify-access-token-use-case.ts"],"names":[],"mappings":"AAAA,OAAO,EAAmB,KAAK,SAAS,EAAE,MAAM,mBAAmB,CAAC;AACpE,OAAO,KAAK,EAAE,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAEhD,MAAM,MAAM,iBAAiB,GAAG,CAAC,WAAW,EAAE,MAAM,KAAK,OAAO,CAAC,SAAS,CAAC,CAAC;AAE5E,MAAM,WAAW,qBAAqB;IACpC,QAAQ,EAAE,IAAI,CAAC,QAAQ,EAAE,eAAe,CAAC,CAAC;CAC3C;AAED,wBAAgB,wBAAwB,CAAC,EACvC,QAAQ,GACT,EAAE,qBAAqB,GAAG,iBAAiB,CAW3C"}
@@ -0,0 +1,13 @@
1
+ import { Unauthenticated } from "../auth-entity.js";
2
+ export function verifyAccessTokenUseCase({ authRepo, }) {
3
+ return async (accessToken) => {
4
+ if (accessToken.trim() === "") {
5
+ throw new Unauthenticated();
6
+ }
7
+ const principal = await authRepo.findPrincipal(accessToken);
8
+ if (principal === undefined) {
9
+ throw new Unauthenticated();
10
+ }
11
+ return principal;
12
+ };
13
+ }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@insaeng/auth",
3
- "version": "0.1.0",
3
+ "version": "0.4.0",
4
4
  "description": "Access-token verification for insaeng services",
5
5
  "repository": {
6
6
  "type": "git",
@@ -10,12 +10,20 @@
10
10
  "type": "module",
11
11
  "exports": {
12
12
  ".": {
13
- "types": "./dist/verify.d.ts",
14
- "default": "./dist/verify.js"
13
+ "types": "./dist/dependencies.d.ts",
14
+ "default": "./dist/dependencies.js"
15
+ },
16
+ "./client": {
17
+ "types": "./dist/data/sources/oauth/oauth-source.d.ts",
18
+ "default": "./dist/data/sources/oauth/oauth-source.js"
15
19
  },
16
20
  "./testing": {
17
- "types": "./dist/testing.d.ts",
18
- "default": "./dist/testing.js"
21
+ "types": "./dist/data/sources/jwks/test-issuer-source.d.ts",
22
+ "default": "./dist/data/sources/jwks/test-issuer-source.js"
23
+ },
24
+ "./domain": {
25
+ "types": "./dist/domain/auth/auth-entity.d.ts",
26
+ "default": "./dist/domain/auth/auth-entity.js"
19
27
  }
20
28
  },
21
29
  "publishConfig": {
@@ -0,0 +1,58 @@
1
+ import { errors } from "jose";
2
+ import type { Principal } from "../../domain/auth/auth-entity.js";
3
+ import type { AuthRepo } from "../../domain/auth/auth-repo.js";
4
+ import type {
5
+ AccessTokenClaims,
6
+ JwksSource,
7
+ } from "../sources/jwks/jwks-source.js";
8
+
9
+ export interface AuthRepoDeps {
10
+ jwks: JwksSource;
11
+ }
12
+
13
+ const rejectedTokenErrors = [
14
+ errors.JWTClaimValidationFailed,
15
+ errors.JWTExpired,
16
+ errors.JWTInvalid,
17
+ errors.JWSInvalid,
18
+ errors.JWSSignatureVerificationFailed,
19
+ errors.JWKSNoMatchingKey,
20
+ errors.JOSEAlgNotAllowed,
21
+ errors.JOSENotSupported,
22
+ ];
23
+
24
+ function isRejectedToken(error: unknown): boolean {
25
+ return rejectedTokenErrors.some((rejected) => error instanceof rejected);
26
+ }
27
+
28
+ function toPrincipal(claims: AccessTokenClaims): Principal {
29
+ const principal: Principal = {
30
+ kind: claims.client_id === claims.sub ? "client" : "user",
31
+ id: claims.sub,
32
+ roles: claims.roles,
33
+ };
34
+ if (claims.email !== undefined) {
35
+ principal.email = claims.email;
36
+ }
37
+ if (claims.name !== undefined) {
38
+ principal.name = claims.name;
39
+ }
40
+ return principal;
41
+ }
42
+
43
+ export function createAuthRepo({
44
+ jwks,
45
+ }: AuthRepoDeps): Pick<AuthRepo, "findPrincipal"> {
46
+ return {
47
+ async findPrincipal(accessToken) {
48
+ try {
49
+ return toPrincipal(await jwks.verify(accessToken));
50
+ } catch (error) {
51
+ if (isRejectedToken(error)) {
52
+ return undefined;
53
+ }
54
+ throw error;
55
+ }
56
+ },
57
+ };
58
+ }
@@ -14,24 +14,15 @@ export interface AccessTokenClaims {
14
14
  name?: string;
15
15
  }
16
16
 
17
- export type AccessTokenKeys =
18
- { jwksUrl: string | URL } | { keys: JWTVerifyGetKey };
17
+ export type JwksKeys = { jwksUrl: string | URL } | { keys: JWTVerifyGetKey };
19
18
 
20
- export type VerifyAccessTokenOptions = AccessTokenKeys & {
19
+ export type JwksSourceOptions = JwksKeys & {
21
20
  issuer: string;
22
21
  audience: string;
23
22
  };
24
23
 
25
- const remoteKeySets = new Map<string, JWTVerifyGetKey>();
26
-
27
- function remoteKeySet(jwksUrl: string | URL): JWTVerifyGetKey {
28
- const href = new URL(jwksUrl).href;
29
- let keySet = remoteKeySets.get(href);
30
- if (keySet === undefined) {
31
- keySet = createRemoteJWKSet(new URL(href));
32
- remoteKeySets.set(href, keySet);
33
- }
34
- return keySet;
24
+ export interface JwksSource {
25
+ verify(accessToken: string): Promise<AccessTokenClaims>;
35
26
  }
36
27
 
37
28
  function invalidClaim(
@@ -74,17 +65,21 @@ function toClaims(payload: JWTPayload): AccessTokenClaims {
74
65
  return claims;
75
66
  }
76
67
 
77
- export async function verifyAccessToken(
78
- token: string,
79
- options: VerifyAccessTokenOptions,
80
- ): Promise<AccessTokenClaims> {
81
- const keys = "keys" in options ? options.keys : remoteKeySet(options.jwksUrl);
82
- const { payload } = await jwtVerify(token, keys, {
83
- typ: "at+jwt",
84
- issuer: options.issuer,
85
- audience: options.audience,
86
- algorithms: ["EdDSA"],
87
- requiredClaims: ["exp", "sub"],
88
- });
89
- return toClaims(payload);
68
+ export function createJwksSource(options: JwksSourceOptions): JwksSource {
69
+ const keys =
70
+ "keys" in options
71
+ ? options.keys
72
+ : createRemoteJWKSet(new URL(options.jwksUrl));
73
+ return {
74
+ async verify(accessToken) {
75
+ const { payload } = await jwtVerify(accessToken, keys, {
76
+ typ: "at+jwt",
77
+ issuer: options.issuer,
78
+ audience: options.audience,
79
+ algorithms: ["EdDSA"],
80
+ requiredClaims: ["exp", "sub"],
81
+ });
82
+ return toClaims(payload);
83
+ },
84
+ };
90
85
  }
@@ -7,7 +7,7 @@ import {
7
7
  type JSONWebKeySet,
8
8
  type JWTVerifyGetKey,
9
9
  } from "jose";
10
- import type { AccessTokenClaims } from "./verify.js";
10
+ import type { AccessTokenClaims } from "./jwks-source.js";
11
11
 
12
12
  export interface TestIssuerOptions {
13
13
  issuer?: string;
@@ -32,7 +32,7 @@ export interface TestIssuer {
32
32
  ): Promise<string>;
33
33
  }
34
34
 
35
- export async function createTestIssuer({
35
+ export async function createTestIssuerSource({
36
36
  issuer = "https://auth.insaeng.test",
37
37
  audience = "insaeng-test-service",
38
38
  }: TestIssuerOptions = {}): Promise<TestIssuer> {
@@ -0,0 +1,140 @@
1
+ import { importJWK, SignJWT, type JWK } from "jose";
2
+
3
+ export interface OauthSourceOptions {
4
+ tokenEndpoint: string | URL;
5
+ clientId: string;
6
+ privateKey: JWK;
7
+ resource: string;
8
+ fetch?: typeof fetch;
9
+ }
10
+
11
+ export interface OauthSource {
12
+ getToken(): Promise<string>;
13
+ }
14
+
15
+ export class TokenRequestError extends Error {
16
+ readonly status: number;
17
+ readonly error: string | undefined;
18
+
19
+ constructor(status: number, error: string | undefined) {
20
+ super(
21
+ `Token request failed with status ${String(status)}` +
22
+ (error === undefined ? "" : `: ${error}`),
23
+ );
24
+ this.name = "TokenRequestError";
25
+ this.status = status;
26
+ this.error = error;
27
+ }
28
+ }
29
+
30
+ const ASSERTION_TYPE = "urn:ietf:params:oauth:client-assertion-type:jwt-bearer";
31
+ const ASSERTION_LIFETIME_SECONDS = 60;
32
+ const REFRESH_MARGIN_MS = 30_000;
33
+
34
+ interface CachedToken {
35
+ accessToken: string;
36
+ expiresAt: number;
37
+ }
38
+
39
+ function isRecord(value: unknown): value is Record<string, unknown> {
40
+ return typeof value === "object" && value !== null;
41
+ }
42
+
43
+ async function readJson(response: Response): Promise<unknown> {
44
+ try {
45
+ return await response.json();
46
+ } catch {
47
+ return undefined;
48
+ }
49
+ }
50
+
51
+ function toCachedToken(body: unknown): CachedToken {
52
+ if (!isRecord(body)) {
53
+ throw new TypeError("Token response must be a JSON object");
54
+ }
55
+ const { access_token, expires_in } = body;
56
+ if (typeof access_token !== "string" || access_token === "") {
57
+ throw new TypeError('Token response "access_token" must be a string');
58
+ }
59
+ if (
60
+ typeof expires_in !== "number" ||
61
+ !Number.isFinite(expires_in) ||
62
+ expires_in <= 0
63
+ ) {
64
+ throw new TypeError(
65
+ 'Token response "expires_in" must be a positive number',
66
+ );
67
+ }
68
+ return {
69
+ accessToken: access_token,
70
+ expiresAt: Date.now() + expires_in * 1000,
71
+ };
72
+ }
73
+
74
+ export function createOauthSource(options: OauthSourceOptions): OauthSource {
75
+ const { clientId, privateKey, resource } = options;
76
+ const tokenEndpoint = String(options.tokenEndpoint);
77
+ const fetchToken = options.fetch ?? globalThis.fetch;
78
+ const kid = privateKey.kid ?? "";
79
+ if (kid === "") {
80
+ throw new TypeError('Client private key must have a "kid"');
81
+ }
82
+
83
+ let key: ReturnType<typeof importJWK> | undefined;
84
+ let cached: CachedToken | undefined;
85
+ let pending: Promise<string> | undefined;
86
+
87
+ async function signAssertion(): Promise<string> {
88
+ key ??= importJWK(privateKey, "EdDSA");
89
+ return new SignJWT()
90
+ .setProtectedHeader({ alg: "EdDSA", kid })
91
+ .setIssuer(clientId)
92
+ .setSubject(clientId)
93
+ .setAudience(tokenEndpoint)
94
+ .setJti(crypto.randomUUID())
95
+ .setIssuedAt()
96
+ .setExpirationTime(`${String(ASSERTION_LIFETIME_SECONDS)}s`)
97
+ .sign(await key);
98
+ }
99
+
100
+ async function requestToken(): Promise<string> {
101
+ const response = await fetchToken(tokenEndpoint, {
102
+ method: "POST",
103
+ headers: {
104
+ accept: "application/json",
105
+ "content-type": "application/x-www-form-urlencoded",
106
+ },
107
+ body: new URLSearchParams({
108
+ grant_type: "client_credentials",
109
+ client_assertion_type: ASSERTION_TYPE,
110
+ client_assertion: await signAssertion(),
111
+ resource,
112
+ }),
113
+ });
114
+ const body = await readJson(response);
115
+ if (!response.ok) {
116
+ const error =
117
+ isRecord(body) && typeof body.error === "string"
118
+ ? body.error
119
+ : undefined;
120
+ throw new TokenRequestError(response.status, error);
121
+ }
122
+ cached = toCachedToken(body);
123
+ return cached.accessToken;
124
+ }
125
+
126
+ return {
127
+ getToken() {
128
+ if (
129
+ cached !== undefined &&
130
+ cached.expiresAt - Date.now() > REFRESH_MARGIN_MS
131
+ ) {
132
+ return Promise.resolve(cached.accessToken);
133
+ }
134
+ pending ??= requestToken().finally(() => {
135
+ pending = undefined;
136
+ });
137
+ return pending;
138
+ },
139
+ };
140
+ }
@@ -0,0 +1,28 @@
1
+ import { createAuthRepo } from "./data/auth/auth-repo.js";
2
+ import {
3
+ createJwksSource,
4
+ type JwksSourceOptions,
5
+ } from "./data/sources/jwks/jwks-source.js";
6
+ import type { AuthRepo } from "./domain/auth/auth-repo.js";
7
+ import {
8
+ verifyAccessTokenUseCase,
9
+ type VerifyAccessToken,
10
+ } from "./domain/auth/use-cases/verify-access-token-use-case.js";
11
+
12
+ export type { JwksSourceOptions };
13
+ export { assertCanUseCase } from "./domain/auth/use-cases/assert-can-use-case.js";
14
+ export { verifyAccessTokenUseCase };
15
+
16
+ export interface Auth {
17
+ authRepo: Pick<AuthRepo, "findPrincipal">;
18
+ verifyAccessToken: VerifyAccessToken;
19
+ }
20
+
21
+ export function createAuth(options: JwksSourceOptions): Auth {
22
+ const jwks = createJwksSource(options);
23
+ const authRepo = createAuthRepo({ jwks });
24
+ return {
25
+ authRepo,
26
+ verifyAccessToken: verifyAccessTokenUseCase({ authRepo }),
27
+ };
28
+ }
@@ -0,0 +1,29 @@
1
+ export type { AuthRepo } from "./auth-repo.js";
2
+ export type { AssertCan } from "./use-cases/assert-can-use-case.js";
3
+ export type { VerifyAccessToken } from "./use-cases/verify-access-token-use-case.js";
4
+
5
+ export interface Principal {
6
+ kind: "user" | "client";
7
+ id: string;
8
+ roles: readonly string[];
9
+ email?: string;
10
+ name?: string;
11
+ }
12
+
13
+ export class Unauthenticated extends Error {
14
+ override readonly name = "Unauthenticated";
15
+
16
+ constructor() {
17
+ super("Unauthenticated");
18
+ }
19
+ }
20
+
21
+ export class Forbidden<Action extends string = string> extends Error {
22
+ override readonly name = "Forbidden";
23
+ readonly action: Action;
24
+
25
+ constructor(action: Action) {
26
+ super(`Forbidden: ${action}`);
27
+ this.action = action;
28
+ }
29
+ }
@@ -0,0 +1,10 @@
1
+ import type { Principal } from "./auth-entity.js";
2
+
3
+ export interface AuthRepo<Action extends string = string, Resource = unknown> {
4
+ findPrincipal(accessToken: string): Promise<Principal | undefined>;
5
+ can(
6
+ principal: Principal,
7
+ action: Action,
8
+ resource: Resource,
9
+ ): Promise<boolean>;
10
+ }
@@ -0,0 +1,22 @@
1
+ import { Forbidden, type Principal } from "../auth-entity.js";
2
+ import type { AuthRepo } from "../auth-repo.js";
3
+
4
+ export type AssertCan<Action extends string, Resource> = (
5
+ principal: Principal,
6
+ action: Action,
7
+ resource: Resource,
8
+ ) => Promise<void>;
9
+
10
+ export interface AssertCanDeps<Action extends string, Resource> {
11
+ authRepo: Pick<AuthRepo<Action, Resource>, "can">;
12
+ }
13
+
14
+ export function assertCanUseCase<Action extends string, Resource>({
15
+ authRepo,
16
+ }: AssertCanDeps<Action, Resource>): AssertCan<Action, Resource> {
17
+ return async (principal, action, resource) => {
18
+ if (!(await authRepo.can(principal, action, resource))) {
19
+ throw new Forbidden(action);
20
+ }
21
+ };
22
+ }
@@ -0,0 +1,23 @@
1
+ import { Unauthenticated, type Principal } from "../auth-entity.js";
2
+ import type { AuthRepo } from "../auth-repo.js";
3
+
4
+ export type VerifyAccessToken = (accessToken: string) => Promise<Principal>;
5
+
6
+ export interface VerifyAccessTokenDeps {
7
+ authRepo: Pick<AuthRepo, "findPrincipal">;
8
+ }
9
+
10
+ export function verifyAccessTokenUseCase({
11
+ authRepo,
12
+ }: VerifyAccessTokenDeps): VerifyAccessToken {
13
+ return async (accessToken) => {
14
+ if (accessToken.trim() === "") {
15
+ throw new Unauthenticated();
16
+ }
17
+ const principal = await authRepo.findPrincipal(accessToken);
18
+ if (principal === undefined) {
19
+ throw new Unauthenticated();
20
+ }
21
+ return principal;
22
+ };
23
+ }
@@ -1 +0,0 @@
1
- {"version":3,"file":"testing.d.ts","sourceRoot":"","sources":["../src/testing.ts"],"names":[],"mappings":"AAAA,OAAO,EAML,KAAK,aAAa,EAClB,KAAK,eAAe,EACrB,MAAM,MAAM,CAAC;AACd,OAAO,KAAK,EAAE,iBAAiB,EAAE,MAAM,aAAa,CAAC;AAErD,MAAM,WAAW,iBAAiB;IAChC,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;CACnB;AAED,MAAM,WAAW,oBAAoB;IACnC,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,MAAM,CAAC,EAAE,MAAM,CAAC;IAChB,QAAQ,CAAC,EAAE,MAAM,CAAC;IAClB,cAAc,CAAC,EAAE,MAAM,GAAG,MAAM,GAAG,IAAI,CAAC;CACzC;AAED,MAAM,WAAW,UAAU;IACzB,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;IACjB,IAAI,EAAE,aAAa,CAAC;IACpB,IAAI,EAAE,eAAe,CAAC;IACtB,eAAe,CACb,MAAM,EAAE,OAAO,CAAC,iBAAiB,CAAC,EAClC,OAAO,CAAC,EAAE,oBAAoB,GAC7B,OAAO,CAAC,MAAM,CAAC,CAAC;CACpB;AAED,wBAAsB,gBAAgB,CAAC,EACrC,MAAoC,EACpC,QAAiC,GAClC,GAAE,iBAAsB,GAAG,OAAO,CAAC,UAAU,CAAC,CA2B9C"}
@@ -1 +0,0 @@
1
- {"version":3,"file":"verify.d.ts","sourceRoot":"","sources":["../src/verify.ts"],"names":[],"mappings":"AAAA,OAAO,EAKL,KAAK,eAAe,EACrB,MAAM,MAAM,CAAC;AAEd,MAAM,WAAW,iBAAiB;IAChC,GAAG,EAAE,MAAM,CAAC;IACZ,KAAK,EAAE,MAAM,EAAE,CAAC;IAChB,SAAS,CAAC,EAAE,MAAM,CAAC;IACnB,KAAK,CAAC,EAAE,MAAM,CAAC;IACf,IAAI,CAAC,EAAE,MAAM,CAAC;CACf;AAED,MAAM,MAAM,eAAe,GACzB;IAAE,OAAO,EAAE,MAAM,GAAG,GAAG,CAAA;CAAE,GAAG;IAAE,IAAI,EAAE,eAAe,CAAA;CAAE,CAAC;AAExD,MAAM,MAAM,wBAAwB,GAAG,eAAe,GAAG;IACvD,MAAM,EAAE,MAAM,CAAC;IACf,QAAQ,EAAE,MAAM,CAAC;CAClB,CAAC;AAsDF,wBAAsB,iBAAiB,CACrC,KAAK,EAAE,MAAM,EACb,OAAO,EAAE,wBAAwB,GAChC,OAAO,CAAC,iBAAiB,CAAC,CAU5B"}