oidc-spa 8.1.10 → 8.1.12
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/backend.d.ts +27 -6
- package/backend.js +124 -139
- package/backend.js.map +1 -1
- package/core/Oidc.d.ts +28 -4
- package/core/createOidc.d.ts +12 -3
- package/core/createOidc.js +1 -1
- package/core/createOidc.js.map +1 -1
- package/core/earlyInit.d.ts +1 -0
- package/core/earlyInit.js +11 -4
- package/core/earlyInit.js.map +1 -1
- package/core/loginOrGoToAuthServer.js +8 -3
- package/core/loginOrGoToAuthServer.js.map +1 -1
- package/core/oidcClientTsUserToTokens.d.ts +1 -1
- package/core/oidcClientTsUserToTokens.js.map +1 -1
- package/core/requiredPostHydrationReplaceNavigationUrl.d.ts +6 -0
- package/core/requiredPostHydrationReplaceNavigationUrl.js +12 -0
- package/core/requiredPostHydrationReplaceNavigationUrl.js.map +1 -0
- package/entrypoint.d.ts +1 -0
- package/entrypoint.js +3 -1
- package/entrypoint.js.map +1 -1
- package/esm/angular.d.ts +14 -4
- package/esm/angular.js +155 -10
- package/esm/angular.js.map +1 -1
- package/esm/backend.d.ts +48 -0
- package/esm/backend.js +259 -0
- package/esm/backend.js.map +1 -0
- package/esm/core/Oidc.d.ts +28 -4
- package/esm/core/createOidc.d.ts +12 -3
- package/esm/core/createOidc.js +1 -1
- package/esm/core/createOidc.js.map +1 -1
- package/esm/core/earlyInit.d.ts +1 -0
- package/esm/core/earlyInit.js +11 -4
- package/esm/core/earlyInit.js.map +1 -1
- package/esm/core/loginOrGoToAuthServer.js +8 -3
- package/esm/core/loginOrGoToAuthServer.js.map +1 -1
- package/esm/core/oidcClientTsUserToTokens.d.ts +1 -1
- package/esm/core/oidcClientTsUserToTokens.js.map +1 -1
- package/esm/core/requiredPostHydrationReplaceNavigationUrl.d.ts +6 -0
- package/esm/core/requiredPostHydrationReplaceNavigationUrl.js +8 -0
- package/esm/core/requiredPostHydrationReplaceNavigationUrl.js.map +1 -0
- package/esm/entrypoint.d.ts +1 -0
- package/esm/entrypoint.js +1 -0
- package/esm/entrypoint.js.map +1 -1
- package/esm/mock/oidc.d.ts +1 -1
- package/esm/mock/oidc.js.map +1 -1
- package/esm/react/react.d.ts +1 -1
- package/esm/tanstack-start/react/accessTokenValidation_rfc9068.d.ts +12 -0
- package/esm/tanstack-start/react/accessTokenValidation_rfc9068.js +95 -0
- package/esm/tanstack-start/react/accessTokenValidation_rfc9068.js.map +1 -0
- package/esm/tanstack-start/react/apiBuilder.d.ts +27 -0
- package/esm/tanstack-start/react/apiBuilder.js +58 -0
- package/esm/tanstack-start/react/apiBuilder.js.map +1 -0
- package/esm/tanstack-start/react/createOidcSpaApi.d.ts +9 -0
- package/esm/tanstack-start/react/createOidcSpaApi.js +679 -0
- package/esm/tanstack-start/react/createOidcSpaApi.js.map +1 -0
- package/esm/tanstack-start/react/index.d.ts +3 -0
- package/esm/tanstack-start/react/index.js +4 -0
- package/esm/tanstack-start/react/index.js.map +1 -0
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/UnifiedClientRetryForSsrLoadersError.d.ts +4 -0
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/UnifiedClientRetryForSsrLoadersError.js +8 -0
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/UnifiedClientRetryForSsrLoadersError.js.map +1 -0
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/enableUnifiedClientRetryForSsrLoaders.d.ts +4 -0
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/enableUnifiedClientRetryForSsrLoaders.js +86 -0
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/enableUnifiedClientRetryForSsrLoaders.js.map +1 -0
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/entrypoint.d.ts +1 -0
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/entrypoint.js +13 -0
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/entrypoint.js.map +1 -0
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/index.d.ts +2 -0
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/index.js +3 -0
- package/esm/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/index.js.map +1 -0
- package/esm/tanstack-start/react/types.d.ts +355 -0
- package/esm/tanstack-start/react/types.js +2 -0
- package/esm/tanstack-start/react/types.js.map +1 -0
- package/esm/tanstack-start/react/withHandlingOidcPostLoginNavigation.d.ts +2 -0
- package/esm/tanstack-start/react/withHandlingOidcPostLoginNavigation.js +25 -0
- package/esm/tanstack-start/react/withHandlingOidcPostLoginNavigation.js.map +1 -0
- package/esm/tools/GetterOrDirectValue.d.ts +1 -0
- package/esm/tools/GetterOrDirectValue.js +2 -0
- package/esm/tools/GetterOrDirectValue.js.map +1 -0
- package/esm/tools/ZodSchemaLike.d.ts +3 -0
- package/esm/tools/ZodSchemaLike.js +2 -0
- package/esm/tools/ZodSchemaLike.js.map +1 -0
- package/esm/tools/inferIsViteDev.d.ts +1 -0
- package/esm/tools/inferIsViteDev.js +6 -0
- package/esm/tools/inferIsViteDev.js.map +1 -0
- package/esm/tools/infer_import_meta_env_BASE_URL.d.ts +1 -0
- package/esm/tools/infer_import_meta_env_BASE_URL.js +15 -0
- package/esm/tools/infer_import_meta_env_BASE_URL.js.map +1 -0
- package/esm/tools/tsafe/uncapitalize.d.ts +2 -0
- package/esm/tools/tsafe/uncapitalize.js +5 -0
- package/esm/tools/tsafe/uncapitalize.js.map +1 -0
- package/esm/vendor/backend/evt.d.ts +2 -0
- package/esm/vendor/backend/evt.js +3286 -0
- package/esm/vendor/backend/jose.d.ts +1 -0
- package/esm/vendor/backend/jose.js +3546 -0
- package/esm/vendor/backend/tsafe.d.ts +5 -0
- package/esm/vendor/backend/tsafe.js +68 -0
- package/esm/vendor/backend/zod.d.ts +1 -0
- package/esm/vendor/backend/zod.js +4023 -0
- package/esm/vendor/frontend/worker-timers.js +261 -1
- package/mock/oidc.d.ts +1 -1
- package/mock/oidc.js.map +1 -1
- package/package.json +40 -4
- package/react/react.d.ts +1 -1
- package/src/angular.ts +224 -9
- package/src/backend.ts +201 -166
- package/src/core/Oidc.ts +41 -11
- package/src/core/createOidc.ts +12 -3
- package/src/core/earlyInit.ts +19 -4
- package/src/core/loginOrGoToAuthServer.ts +11 -3
- package/src/core/oidcClientTsUserToTokens.ts +2 -2
- package/src/core/requiredPostHydrationReplaceNavigationUrl.ts +11 -0
- package/src/entrypoint.ts +1 -0
- package/src/mock/oidc.ts +2 -2
- package/src/react/react.tsx +1 -1
- package/src/tanstack-start/react/accessTokenValidation_rfc9068.ts +135 -0
- package/src/tanstack-start/react/apiBuilder.ts +151 -0
- package/src/tanstack-start/react/createOidcSpaApi.tsx +1011 -0
- package/src/tanstack-start/react/index.ts +5 -0
- package/src/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/UnifiedClientRetryForSsrLoadersError.ts +8 -0
- package/src/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/enableUnifiedClientRetryForSsrLoaders.tsx +127 -0
- package/src/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/entrypoint.ts +15 -0
- package/src/tanstack-start/react/rfcUnifiedClientRetryForSsrLoaders/index.ts +2 -0
- package/src/tanstack-start/react/types.tsx +415 -0
- package/src/tanstack-start/react/withHandlingOidcPostLoginNavigation.tsx +35 -0
- package/src/tools/GetterOrDirectValue.ts +1 -0
- package/src/tools/ZodSchemaLike.ts +3 -0
- package/src/tools/getThisCodebaseRootDirPath_cjs.ts +19 -0
- package/src/tools/inferIsViteDev.ts +6 -0
- package/src/tools/infer_import_meta_env_BASE_URL.ts +19 -0
- package/src/tools/tsafe/uncapitalize.ts +4 -0
- package/src/vendor/backend/jose.ts +1 -0
- package/src/vendor/build-runtime/babel.ts +6 -0
- package/src/vendor/build-runtime/magic-string.ts +3 -0
- package/src/vite-plugin/detectProjectType.ts +20 -0
- package/src/vite-plugin/excludeModuleExportFromOptimizedDeps.ts +20 -0
- package/src/vite-plugin/handleClientEntrypoint.ts +260 -0
- package/src/vite-plugin/index.ts +1 -0
- package/src/vite-plugin/transformCreateFileRoute.ts +240 -0
- package/src/vite-plugin/vite-plugin.ts +54 -0
- package/tools/GetterOrDirectValue.d.ts +1 -0
- package/tools/GetterOrDirectValue.js +3 -0
- package/tools/GetterOrDirectValue.js.map +1 -0
- package/tools/ZodSchemaLike.d.ts +3 -0
- package/tools/ZodSchemaLike.js +3 -0
- package/tools/ZodSchemaLike.js.map +1 -0
- package/tools/getThisCodebaseRootDirPath_cjs.d.ts +2 -0
- package/tools/getThisCodebaseRootDirPath_cjs.js +53 -0
- package/tools/getThisCodebaseRootDirPath_cjs.js.map +1 -0
- package/tools/tsafe/uncapitalize.d.ts +2 -0
- package/tools/tsafe/uncapitalize.js +8 -0
- package/tools/tsafe/uncapitalize.js.map +1 -0
- package/vendor/backend/jose.d.ts +1 -0
- package/vendor/backend/jose.js +3 -0
- package/vendor/build-runtime/babel.d.ts +6 -0
- package/vendor/build-runtime/babel.js +3 -0
- package/vendor/build-runtime/magic-string.d.ts +2 -0
- package/vendor/build-runtime/magic-string.js +2 -0
- package/vendor/frontend/oidc-client-ts.js +0 -2
- package/vite-plugin/detectProjectType.d.ts +10 -0
- package/vite-plugin/detectProjectType.js +15 -0
- package/vite-plugin/detectProjectType.js.map +1 -0
- package/vite-plugin/excludeModuleExportFromOptimizedDeps.d.ts +4 -0
- package/vite-plugin/excludeModuleExportFromOptimizedDeps.js +50 -0
- package/vite-plugin/excludeModuleExportFromOptimizedDeps.js.map +1 -0
- package/vite-plugin/handleClientEntrypoint.d.ts +10 -0
- package/vite-plugin/handleClientEntrypoint.js +211 -0
- package/vite-plugin/handleClientEntrypoint.js.map +1 -0
- package/vite-plugin/index.d.ts +1 -0
- package/vite-plugin/index.js +6 -0
- package/vite-plugin/index.js.map +1 -0
- package/vite-plugin/transformCreateFileRoute.d.ts +10 -0
- package/vite-plugin/transformCreateFileRoute.js +173 -0
- package/vite-plugin/transformCreateFileRoute.js.map +1 -0
- package/vite-plugin/vite-plugin.d.ts +5 -0
- package/vite-plugin/vite-plugin.js +46 -0
- package/vite-plugin/vite-plugin.js.map +1 -0
- package/src/vendor/backend/jsonwebtoken.ts +0 -1
- package/src/vendor/backend/node-fetch.ts +0 -2
- package/src/vendor/backend/node-jose.ts +0 -1
- package/vendor/backend/jsonwebtoken.d.ts +0 -1
- package/vendor/backend/jsonwebtoken.js +0 -3
- package/vendor/backend/node-fetch.d.ts +0 -2
- package/vendor/backend/node-fetch.js +0 -2
- package/vendor/backend/node-jose.d.ts +0 -1
- package/vendor/backend/node-jose.js +0 -3
|
@@ -0,0 +1,95 @@
|
|
|
1
|
+
import { createObjectThatThrowsIfAccessed } from "../../tools/createObjectThatThrowsIfAccessed";
|
|
2
|
+
import { assert, is } from "../../tools/tsafe/assert";
|
|
3
|
+
export function createCreateValidateAndGetAccessTokenClaims_rfc9068(params) {
|
|
4
|
+
const { accessTokenClaimsSchema, accessTokenClaims_mock, expectedAudience: expectedAudienceOrGetter } = params;
|
|
5
|
+
const createValidateAndGetAccessTokenClaims = ({ paramsOfBootstrap }) => {
|
|
6
|
+
if (paramsOfBootstrap.implementation === "mock") {
|
|
7
|
+
return {
|
|
8
|
+
validateAndGetAccessTokenClaims: async () => {
|
|
9
|
+
return {
|
|
10
|
+
isValid: true,
|
|
11
|
+
accessTokenClaims: (() => {
|
|
12
|
+
if (paramsOfBootstrap.accessTokenClaims_mock !== undefined) {
|
|
13
|
+
assert(is(paramsOfBootstrap.accessTokenClaims_mock));
|
|
14
|
+
return paramsOfBootstrap.accessTokenClaims_mock;
|
|
15
|
+
}
|
|
16
|
+
if (accessTokenClaims_mock !== undefined) {
|
|
17
|
+
return accessTokenClaims_mock;
|
|
18
|
+
}
|
|
19
|
+
return createObjectThatThrowsIfAccessed({
|
|
20
|
+
debugMessage: [
|
|
21
|
+
"oidc-spa: You didn't provide any mock for the accessTokenClaims",
|
|
22
|
+
"Either provide a default one by specifying accessTokenClaims_mock",
|
|
23
|
+
"as parameter of .withAccessTokenValidation() or",
|
|
24
|
+
"specify accessTokenClaims_mock when calling bootstrapOidc()"
|
|
25
|
+
].join(" ")
|
|
26
|
+
});
|
|
27
|
+
})()
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
};
|
|
31
|
+
}
|
|
32
|
+
assert;
|
|
33
|
+
const prVerifyAndDecodeAccessToken = (async () => {
|
|
34
|
+
const { createOidcBackend } = await import("../../backend");
|
|
35
|
+
const { verifyAndDecodeAccessToken } = await createOidcBackend({
|
|
36
|
+
issuerUri: paramsOfBootstrap.issuerUri,
|
|
37
|
+
decodedAccessTokenSchema: accessTokenClaimsSchema
|
|
38
|
+
});
|
|
39
|
+
return verifyAndDecodeAccessToken;
|
|
40
|
+
})();
|
|
41
|
+
const expectedAudience = (() => {
|
|
42
|
+
if (expectedAudienceOrGetter === undefined) {
|
|
43
|
+
return undefined;
|
|
44
|
+
}
|
|
45
|
+
if (typeof expectedAudienceOrGetter === "function") {
|
|
46
|
+
return expectedAudienceOrGetter({ paramsOfBootstrap });
|
|
47
|
+
}
|
|
48
|
+
return expectedAudienceOrGetter;
|
|
49
|
+
})();
|
|
50
|
+
return {
|
|
51
|
+
validateAndGetAccessTokenClaims: async ({ accessToken }) => {
|
|
52
|
+
const verifyAndDecodeAccessToken = await prVerifyAndDecodeAccessToken;
|
|
53
|
+
const { isValid, errorCase, errorMessage, decodedAccessToken, decodedAccessToken_original } = await verifyAndDecodeAccessToken({ accessToken });
|
|
54
|
+
if (!isValid) {
|
|
55
|
+
return {
|
|
56
|
+
isValid: false,
|
|
57
|
+
errorMessage: `${errorCase}: ${errorMessage}`,
|
|
58
|
+
wwwAuthenticateHeaderErrorDescription: (() => {
|
|
59
|
+
switch (errorCase) {
|
|
60
|
+
case "does not respect schema":
|
|
61
|
+
return "The access token is malformed or missing required claims";
|
|
62
|
+
case "expired":
|
|
63
|
+
return "The access token expired";
|
|
64
|
+
case "invalid signature":
|
|
65
|
+
return "The access token signature is invalid";
|
|
66
|
+
}
|
|
67
|
+
})()
|
|
68
|
+
};
|
|
69
|
+
}
|
|
70
|
+
if (expectedAudience !== undefined) {
|
|
71
|
+
const aud_array = typeof decodedAccessToken_original.aud === "string"
|
|
72
|
+
? [decodedAccessToken_original.aud]
|
|
73
|
+
: decodedAccessToken_original.aud;
|
|
74
|
+
if (!aud_array.includes(expectedAudience)) {
|
|
75
|
+
return {
|
|
76
|
+
isValid: false,
|
|
77
|
+
errorMessage: [
|
|
78
|
+
"Access token is not for the expected audience.",
|
|
79
|
+
`Got aud claim: ${JSON.stringify(decodedAccessToken_original.aud)}`,
|
|
80
|
+
`Expected: ${expectedAudience}`
|
|
81
|
+
].join(" "),
|
|
82
|
+
wwwAuthenticateHeaderErrorDescription: "The access token audience is invalid"
|
|
83
|
+
};
|
|
84
|
+
}
|
|
85
|
+
}
|
|
86
|
+
return {
|
|
87
|
+
isValid: true,
|
|
88
|
+
accessTokenClaims: decodedAccessToken
|
|
89
|
+
};
|
|
90
|
+
}
|
|
91
|
+
};
|
|
92
|
+
};
|
|
93
|
+
return { createValidateAndGetAccessTokenClaims };
|
|
94
|
+
}
|
|
95
|
+
//# sourceMappingURL=accessTokenValidation_rfc9068.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"accessTokenValidation_rfc9068.js","sourceRoot":"","sources":["../../../src/tanstack-start/react/accessTokenValidation_rfc9068.ts"],"names":[],"mappings":"AAGA,OAAO,EAAE,gCAAgC,EAAE,MAAM,8CAA8C,CAAC;AAChG,OAAO,EAAE,MAAM,EAAe,EAAE,EAAE,MAAM,0BAA0B,CAAC;AAEnE,MAAM,UAAU,mDAAmD,CAEjE,MAQD;IACG,MAAM,EACF,uBAAuB,EACvB,sBAAsB,EACtB,gBAAgB,EAAE,wBAAwB,EAC7C,GAAG,MAAM,CAAC;I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AC,2BAA2B,CAAC,GAAG,CAAC,EAAE;gCACnE,aAAa,gBAAgB,EAAE;6BAClC,CAAC,IAAI,CAAC,GAAG,CAAC;4BACX,qCAAqC,EAAE,sCAAsC;yBAChF,CAAC;oBACN,CAAC;gBACL,CAAC;gBAED,OAAO;oBACH,OAAO,EAAE,IAAI;oBACb,iBAAiB,EAAE,kBAAkB;iBACxC,CAAC;YACN,CAAC;SACJ,CAAC;IACN,CAAC,CAAC;IAEF,OAAO,EAAE,qCAAqC,EAAE,CAAC;AACrD,CAAC"}
|
|
@@ -0,0 +1,27 @@
|
|
|
1
|
+
import type { OidcSpaApi, CreateValidateAndGetAccessTokenClaims, ParamsOfBootstrap } from "./types";
|
|
2
|
+
import type { Oidc as Oidc_core } from "../../core";
|
|
3
|
+
import type { ZodSchemaLike } from "../../tools/ZodSchemaLike";
|
|
4
|
+
import type { DecodedAccessToken_RFC9068 as AccessTokenClaims_RFC9068 } from "../../backend";
|
|
5
|
+
export type OidcSpaApiBuilder<AutoLogin extends boolean = false, DecodedIdToken extends Record<string, unknown> = Oidc_core.Tokens.DecodedIdToken_OidcCoreSpec, AccessTokenClaims extends Record<string, unknown> | undefined = undefined, ExcludedMethod extends "withAutoLogin" | "withExpectedDecodedIdTokenShape" | "withAccessTokenValidation" | "finalize" = never> = Omit<{
|
|
6
|
+
withAutoLogin: () => OidcSpaApiBuilder<true, DecodedIdToken, AccessTokenClaims, ExcludedMethod | "withAutoLogin">;
|
|
7
|
+
withExpectedDecodedIdTokenShape: <DecodedIdToken extends Record<string, unknown>>(params: {
|
|
8
|
+
decodedIdTokenSchema: ZodSchemaLike<Oidc_core.Tokens.DecodedIdToken_OidcCoreSpec, DecodedIdToken>;
|
|
9
|
+
decodedIdToken_mock?: NoInfer<DecodedIdToken>;
|
|
10
|
+
}) => OidcSpaApiBuilder<AutoLogin, DecodedIdToken, AccessTokenClaims, ExcludedMethod | "withExpectedDecodedIdTokenShape">;
|
|
11
|
+
withAccessTokenValidation: {
|
|
12
|
+
<AccessTokenClaims extends Record<string, unknown> = AccessTokenClaims_RFC9068>(params: {
|
|
13
|
+
type: "RFC 9068: JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens";
|
|
14
|
+
accessTokenClaimsSchema?: ZodSchemaLike<AccessTokenClaims_RFC9068, AccessTokenClaims>;
|
|
15
|
+
accessTokenClaims_mock?: NoInfer<AccessTokenClaims>;
|
|
16
|
+
expectedAudience?: string | ((params: {
|
|
17
|
+
paramsOfBootstrap: ParamsOfBootstrap<boolean, Record<string, unknown>, AccessTokenClaims>;
|
|
18
|
+
}) => string);
|
|
19
|
+
}): OidcSpaApiBuilder<AutoLogin, DecodedIdToken, AccessTokenClaims, ExcludedMethod | "withAccessTokenValidation">;
|
|
20
|
+
<AccessTokenClaims extends Record<string, unknown>>(params: {
|
|
21
|
+
type: "custom";
|
|
22
|
+
createValidateAndGetAccessTokenClaims: CreateValidateAndGetAccessTokenClaims<AccessTokenClaims>;
|
|
23
|
+
}): OidcSpaApiBuilder<AutoLogin, DecodedIdToken, AccessTokenClaims, ExcludedMethod | "withAccessTokenValidation">;
|
|
24
|
+
};
|
|
25
|
+
finalize: () => OidcSpaApi<AutoLogin, DecodedIdToken, AccessTokenClaims>;
|
|
26
|
+
}, ExcludedMethod>;
|
|
27
|
+
export declare const oidcSpaApiBuilder: OidcSpaApiBuilder<false, Record<string, unknown>, undefined, never>;
|
|
@@ -0,0 +1,58 @@
|
|
|
1
|
+
import { assert } from "../../tools/tsafe/assert";
|
|
2
|
+
import { createCreateValidateAndGetAccessTokenClaims_rfc9068 } from "./accessTokenValidation_rfc9068";
|
|
3
|
+
import { createOidcSpaApi } from "./createOidcSpaApi";
|
|
4
|
+
function createOidcSpaApiBuilder(params) {
|
|
5
|
+
return {
|
|
6
|
+
withAutoLogin: () => createOidcSpaApiBuilder({
|
|
7
|
+
autoLogin: true,
|
|
8
|
+
decodedIdTokenSchema: params.decodedIdTokenSchema,
|
|
9
|
+
decodedIdToken_mock: params.decodedIdToken_mock,
|
|
10
|
+
createValidateAndGetAccessTokenClaims: params.createValidateAndGetAccessTokenClaims
|
|
11
|
+
}),
|
|
12
|
+
withExpectedDecodedIdTokenShape: ({ decodedIdTokenSchema, decodedIdToken_mock }) => createOidcSpaApiBuilder({
|
|
13
|
+
autoLogin: params.autoLogin,
|
|
14
|
+
decodedIdTokenSchema,
|
|
15
|
+
decodedIdToken_mock: decodedIdToken_mock,
|
|
16
|
+
createValidateAndGetAccessTokenClaims: params.createValidateAndGetAccessTokenClaims
|
|
17
|
+
}),
|
|
18
|
+
withAccessTokenValidation: params_scope => createOidcSpaApiBuilder({
|
|
19
|
+
autoLogin: params.autoLogin,
|
|
20
|
+
decodedIdTokenSchema: params.decodedIdTokenSchema,
|
|
21
|
+
decodedIdToken_mock: params.decodedIdToken_mock,
|
|
22
|
+
createValidateAndGetAccessTokenClaims: (() => {
|
|
23
|
+
switch (params_scope.type) {
|
|
24
|
+
case "RFC 9068: JSON Web Token (JWT) Profile for OAuth 2.0 Access Tokens": {
|
|
25
|
+
const { accessTokenClaimsSchema, accessTokenClaims_mock, expectedAudience } = params_scope;
|
|
26
|
+
const { createValidateAndGetAccessTokenClaims } = createCreateValidateAndGetAccessTokenClaims_rfc9068({
|
|
27
|
+
// @ts-expect-error
|
|
28
|
+
accessTokenClaims_mock,
|
|
29
|
+
// @ts-expect-error
|
|
30
|
+
accessTokenClaimsSchema,
|
|
31
|
+
expectedAudience
|
|
32
|
+
});
|
|
33
|
+
return createValidateAndGetAccessTokenClaims;
|
|
34
|
+
}
|
|
35
|
+
case "custom": {
|
|
36
|
+
const { createValidateAndGetAccessTokenClaims } = params_scope;
|
|
37
|
+
return createValidateAndGetAccessTokenClaims;
|
|
38
|
+
}
|
|
39
|
+
default:
|
|
40
|
+
assert(false);
|
|
41
|
+
}
|
|
42
|
+
})()
|
|
43
|
+
}),
|
|
44
|
+
finalize: () => createOidcSpaApi({
|
|
45
|
+
autoLogin: params.autoLogin,
|
|
46
|
+
decodedIdTokenSchema: params.decodedIdTokenSchema,
|
|
47
|
+
decodedIdToken_mock: params.decodedIdToken_mock,
|
|
48
|
+
createValidateAndGetAccessTokenClaims: params.createValidateAndGetAccessTokenClaims
|
|
49
|
+
})
|
|
50
|
+
};
|
|
51
|
+
}
|
|
52
|
+
export const oidcSpaApiBuilder = createOidcSpaApiBuilder({
|
|
53
|
+
autoLogin: false,
|
|
54
|
+
createValidateAndGetAccessTokenClaims: undefined,
|
|
55
|
+
decodedIdToken_mock: undefined,
|
|
56
|
+
decodedIdTokenSchema: undefined
|
|
57
|
+
});
|
|
58
|
+
//# sourceMappingURL=apiBuilder.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"apiBuilder.js","sourceRoot":"","sources":["../../../src/tanstack-start/react/apiBuilder.ts"],"names":[],"mappings":"AAEA,OAAO,EAAE,MAAM,EAAe,MAAM,0BAA0B,CAAC;AAG/D,OAAO,EAAE,mDAAmD,EAAE,MAAM,iCAAiC,CAAC;AACtG,OAAO,EAAE,gBAAgB,EAAE,MAAM,oBAAoB,CAAC;AAoEtD,SAAS,uBAAuB,CAI9B,MASD;IACG,OAAO;QACH,aAAa,EAAE,GAAG,EAAE,CAChB,uBAAuB,CAAC;YACpB,SAAS,EAAE,IAAI;YACf,oBAAoB,EAAE,MAAM,CAAC,oBAAoB;YACjD,mBAAmB,EAAE,MAAM,CAAC,mBAAmB;YAC/C,qCAAqC,EAAE,MAAM,CAAC,qCAAqC;SACtF,CAAC;QACN,+BAA+B,EAAE,CAAC,EAAE,oBAAoB,EAAE,mBAAmB,EAAE,EAAE,EAAE,CAC/E,uBAAuB,CAAC;YACpB,SAAS,EAAE,MAAM,CAAC,SAAS;YAC3B,oBAAoB;YACpB,mBAAmB,EAAE,mBAAmB;YACxC,qCAAqC,EAAE,MAAM,CAAC,qCAAqC;SACtF,CAAC;QACN,yBAAyB,EAAE,YAAY,CAAC,EAAE,CACtC,uBAAuB,CAAC;YACpB,SAAS,EAAE,M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
|
2
|
+
import type { ZodSchemaLike } from "../../tools/ZodSchemaLike";
|
|
3
|
+
import type { Oidc as Oidc_core } from "../../core";
|
|
4
|
+
export declare function createOidcSpaApi<AutoLogin extends boolean, DecodedIdToken extends Record<string, unknown>, AccessTokenClaims extends Record<string, unknown> | undefined>(params: {
|
|
5
|
+
autoLogin: AutoLogin;
|
|
6
|
+
decodedIdTokenSchema: ZodSchemaLike<Oidc_core.Tokens.DecodedIdToken_OidcCoreSpec, DecodedIdToken> | undefined;
|
|
7
|
+
decodedIdToken_mock: DecodedIdToken | undefined;
|
|
8
|
+
createValidateAndGetAccessTokenClaims: CreateValidateAndGetAccessTokenClaims<AccessTokenClaims> | undefined;
|
|
9
|
+
}): OidcSpaApi<AutoLogin, DecodedIdToken, AccessTokenClaims>;
|