@tktchurch/auth 0.9.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.
@@ -0,0 +1,52 @@
1
+ "use strict";var o=Object.defineProperty;var c=Object.getOwnPropertyDescriptor;var s=Object.getOwnPropertyNames;var a=Object.prototype.hasOwnProperty;var h=(e,t)=>{for(var u in t)o(e,u,{get:t[u],enumerable:!0})},l=(e,t,u,n)=>{if(t&&typeof t=="object"||typeof t=="function")for(let i of s(t))!a.call(e,i)&&i!==u&&o(e,i,{get:()=>t[i],enumerable:!(n=c(t,i))||n.enumerable});return e};var f=e=>l(o({},"__esModule",{value:!0}),e);var k={};h(k,{default:()=>p});module.exports=f(k);var r=require("@nuxt/kit"),p=(0,r.defineNuxtModule)({meta:{name:"@tktchurch/auth/nuxt",configKey:"tktAuth",compatibility:{nuxt:">=3.10.0"}},defaults:{baseUrl:"https://prod-auth.tktchurch.com",clientId:"",clientSecret:"",autoRefresh:!0,refreshCookieName:"tkt_refresh_token"},setup(e,t){let u=t.options.runtimeConfig.tktAuth??{};t.options.runtimeConfig.tktAuth={...u,clientSecret:e.clientSecret??u.clientSecret??""};let n=t.options.runtimeConfig.public.tktAuth??{};t.options.runtimeConfig.public.tktAuth={...n,baseUrl:e.baseUrl??n.baseUrl??"https://prod-auth.tktchurch.com",clientId:e.clientId??n.clientId??"",autoRefresh:e.autoRefresh??n.autoRefresh??!0,refreshCookieName:e.refreshCookieName??n.refreshCookieName??"tkt_refresh_token"},(0,r.addPluginTemplate)({filename:"tkt-auth.plugin.mjs",getContents:()=>`
2
+ import { createAuthClient } from "@tktchurch/auth";
3
+
4
+ export default defineNuxtPlugin(() => {
5
+ const config = useRuntimeConfig();
6
+
7
+ const auth = createAuthClient({
8
+ baseUrl: config.public.tktAuth.baseUrl,
9
+ clientId: config.public.tktAuth.clientId,
10
+ clientSecret: process.server ? config.tktAuth.clientSecret : undefined,
11
+ autoRefresh: config.public.tktAuth.autoRefresh,
12
+ });
13
+
14
+ return {
15
+ provide: {
16
+ tktAuth: auth,
17
+ },
18
+ };
19
+ });
20
+ `});let i=(0,r.addTemplate)({filename:"composables/tkt-auth.ts",getContents:()=>`
21
+ import { createAuthClient } from "@tktchurch/auth";
22
+
23
+ export const useTktAuth = () => useNuxtApp().$tktAuth;
24
+
25
+ export const createTktServerAuthClient = () => {
26
+ const config = useRuntimeConfig();
27
+ return createAuthClient({
28
+ baseUrl: config.public.tktAuth.baseUrl,
29
+ clientId: config.public.tktAuth.clientId,
30
+ clientSecret: config.tktAuth.clientSecret,
31
+ autoRefresh: config.public.tktAuth.autoRefresh,
32
+ });
33
+ };
34
+
35
+ export const useTktRefreshCookieName = () => useRuntimeConfig().public.tktAuth.refreshCookieName;
36
+ `});(0,r.addImports)([{name:"useTktAuth",from:i.dst},{name:"createTktServerAuthClient",from:i.dst},{name:"useTktRefreshCookieName",from:i.dst}]),(0,r.addTypeTemplate)({filename:"types/tkt-auth.d.ts",getContents:()=>`
37
+ import type { AuthClient } from "@tktchurch/auth";
38
+
39
+ declare module "#app" {
40
+ interface NuxtApp {
41
+ $tktAuth: AuthClient;
42
+ }
43
+ }
44
+
45
+ declare module "vue" {
46
+ interface ComponentCustomProperties {
47
+ $tktAuth: AuthClient;
48
+ }
49
+ }
50
+
51
+ export {};
52
+ `})}});
@@ -0,0 +1,12 @@
1
+ /** Nuxt module options for `@tktchurch/auth/nuxt`. */
2
+ interface TktAuthNuxtModuleOptions {
3
+ baseUrl?: string;
4
+ clientId?: string;
5
+ clientSecret?: string;
6
+ autoRefresh?: boolean;
7
+ refreshCookieName?: string;
8
+ }
9
+ /** Nuxt module entry point that injects `$tktAuth` and auto-import helpers. */
10
+ declare const _default: NuxtModule<TOptions, TOptions, false>;
11
+
12
+ export { type TktAuthNuxtModuleOptions, _default as default };
@@ -0,0 +1,12 @@
1
+ /** Nuxt module options for `@tktchurch/auth/nuxt`. */
2
+ interface TktAuthNuxtModuleOptions {
3
+ baseUrl?: string;
4
+ clientId?: string;
5
+ clientSecret?: string;
6
+ autoRefresh?: boolean;
7
+ refreshCookieName?: string;
8
+ }
9
+ /** Nuxt module entry point that injects `$tktAuth` and auto-import helpers. */
10
+ declare const _default: NuxtModule<TOptions, TOptions, false>;
11
+
12
+ export { type TktAuthNuxtModuleOptions, _default as default };
@@ -0,0 +1,52 @@
1
+ import{addImports as u,addPluginTemplate as o,addTemplate as c,addTypeTemplate as s,defineNuxtModule as a}from"@nuxt/kit";var l=a({meta:{name:"@tktchurch/auth/nuxt",configKey:"tktAuth",compatibility:{nuxt:">=3.10.0"}},defaults:{baseUrl:"https://prod-auth.tktchurch.com",clientId:"",clientSecret:"",autoRefresh:!0,refreshCookieName:"tkt_refresh_token"},setup(t,r){let n=r.options.runtimeConfig.tktAuth??{};r.options.runtimeConfig.tktAuth={...n,clientSecret:t.clientSecret??n.clientSecret??""};let e=r.options.runtimeConfig.public.tktAuth??{};r.options.runtimeConfig.public.tktAuth={...e,baseUrl:t.baseUrl??e.baseUrl??"https://prod-auth.tktchurch.com",clientId:t.clientId??e.clientId??"",autoRefresh:t.autoRefresh??e.autoRefresh??!0,refreshCookieName:t.refreshCookieName??e.refreshCookieName??"tkt_refresh_token"},o({filename:"tkt-auth.plugin.mjs",getContents:()=>`
2
+ import { createAuthClient } from "@tktchurch/auth";
3
+
4
+ export default defineNuxtPlugin(() => {
5
+ const config = useRuntimeConfig();
6
+
7
+ const auth = createAuthClient({
8
+ baseUrl: config.public.tktAuth.baseUrl,
9
+ clientId: config.public.tktAuth.clientId,
10
+ clientSecret: process.server ? config.tktAuth.clientSecret : undefined,
11
+ autoRefresh: config.public.tktAuth.autoRefresh,
12
+ });
13
+
14
+ return {
15
+ provide: {
16
+ tktAuth: auth,
17
+ },
18
+ };
19
+ });
20
+ `});let i=c({filename:"composables/tkt-auth.ts",getContents:()=>`
21
+ import { createAuthClient } from "@tktchurch/auth";
22
+
23
+ export const useTktAuth = () => useNuxtApp().$tktAuth;
24
+
25
+ export const createTktServerAuthClient = () => {
26
+ const config = useRuntimeConfig();
27
+ return createAuthClient({
28
+ baseUrl: config.public.tktAuth.baseUrl,
29
+ clientId: config.public.tktAuth.clientId,
30
+ clientSecret: config.tktAuth.clientSecret,
31
+ autoRefresh: config.public.tktAuth.autoRefresh,
32
+ });
33
+ };
34
+
35
+ export const useTktRefreshCookieName = () => useRuntimeConfig().public.tktAuth.refreshCookieName;
36
+ `});u([{name:"useTktAuth",from:i.dst},{name:"createTktServerAuthClient",from:i.dst},{name:"useTktRefreshCookieName",from:i.dst}]),s({filename:"types/tkt-auth.d.ts",getContents:()=>`
37
+ import type { AuthClient } from "@tktchurch/auth";
38
+
39
+ declare module "#app" {
40
+ interface NuxtApp {
41
+ $tktAuth: AuthClient;
42
+ }
43
+ }
44
+
45
+ declare module "vue" {
46
+ interface ComponentCustomProperties {
47
+ $tktAuth: AuthClient;
48
+ }
49
+ }
50
+
51
+ export {};
52
+ `})}});export{l as default};
@@ -0,0 +1 @@
1
+ "use strict";var a=Object.defineProperty;var p=Object.getOwnPropertyDescriptor;var f=Object.getOwnPropertyNames;var _=Object.prototype.hasOwnProperty;var k=(e,r)=>{for(var t in r)a(e,t,{get:r[t],enumerable:!0})},y=(e,r,t,o)=>{if(r&&typeof r=="object"||typeof r=="function")for(let i of f(r))!_.call(e,i)&&i!==t&&a(e,i,{get:()=>r[i],enumerable:!(o=p(r,i))||o.enumerable});return e};var T=e=>y(a({},"__esModule",{value:!0}),e);var w={};k(w,{createMemoryTokenStorage:()=>g});module.exports=T(w);var n=class extends Error{code;status;details;constructor(r,t,o){super(t),this.name="AuthError",this.code=r,this.status=o?.status,this.details=o?.details}};var m=new Set(["accessToken","tokenType","expiresIn","refreshToken","scope","idToken","authorizationDetails"]);function d(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let r=Object.getPrototypeOf(e);return r===Object.prototype||r===null}function l(e){return typeof e=="string"&&e.length>0}function u(e){return typeof e=="string"&&e.length>0?e:void 0}function h(e){if(!d(e))throw new n("invalid_request","Token storage rejected a non-object token payload.");for(let s of Object.keys(e))if(!m.has(s))throw new n("invalid_request",`Token storage rejected unknown field "${s}".`);if(!l(e.accessToken))throw new n("invalid_request","Token storage requires a non-empty accessToken.");if(!l(e.tokenType))throw new n("invalid_request","Token storage requires a non-empty tokenType.");if(typeof e.expiresIn!="number"||!Number.isFinite(e.expiresIn)||e.expiresIn<0)throw new n("invalid_request","Token storage requires a non-negative numeric expiresIn.");let r={accessToken:e.accessToken,tokenType:e.tokenType,expiresIn:e.expiresIn},t=u(e.refreshToken);t&&(r.refreshToken=t);let o=u(e.scope);o&&(r.scope=o);let i=u(e.idToken);if(i&&(r.idToken=i),typeof e.authorizationDetails<"u"){if(!Array.isArray(e.authorizationDetails)||!e.authorizationDetails.every(s=>d(s)&&typeof s.type=="string"))throw new n("invalid_request","Token storage rejected malformed authorizationDetails.");r.authorizationDetails=e.authorizationDetails}return r}var c=class{state=null;get(){return this.state}set(r){if(!r){this.clear();return}this.state=h(r)}clear(){this.state=null}};function g(){return new c}0&&(module.exports={createMemoryTokenStorage});
@@ -0,0 +1 @@
1
+ export { a2 as createMemoryTokenStorage } from '../memory-CVWZvsJ0.cjs';
@@ -0,0 +1 @@
1
+ export { a2 as createMemoryTokenStorage } from '../memory-CVWZvsJ0.js';
@@ -0,0 +1 @@
1
+ var t=class extends Error{code;status;details;constructor(r,i,n){super(i),this.name="AuthError",this.code=r,this.status=n?.status,this.details=n?.details}};var h=new Set(["accessToken","tokenType","expiresIn","refreshToken","scope","idToken","authorizationDetails"]);function c(e){if(typeof e!="object"||e===null||Array.isArray(e))return!1;let r=Object.getPrototypeOf(e);return r===Object.prototype||r===null}function d(e){return typeof e=="string"&&e.length>0}function s(e){return typeof e=="string"&&e.length>0?e:void 0}function l(e){if(!c(e))throw new t("invalid_request","Token storage rejected a non-object token payload.");for(let o of Object.keys(e))if(!h.has(o))throw new t("invalid_request",`Token storage rejected unknown field "${o}".`);if(!d(e.accessToken))throw new t("invalid_request","Token storage requires a non-empty accessToken.");if(!d(e.tokenType))throw new t("invalid_request","Token storage requires a non-empty tokenType.");if(typeof e.expiresIn!="number"||!Number.isFinite(e.expiresIn)||e.expiresIn<0)throw new t("invalid_request","Token storage requires a non-negative numeric expiresIn.");let r={accessToken:e.accessToken,tokenType:e.tokenType,expiresIn:e.expiresIn},i=s(e.refreshToken);i&&(r.refreshToken=i);let n=s(e.scope);n&&(r.scope=n);let u=s(e.idToken);if(u&&(r.idToken=u),typeof e.authorizationDetails<"u"){if(!Array.isArray(e.authorizationDetails)||!e.authorizationDetails.every(o=>c(o)&&typeof o.type=="string"))throw new t("invalid_request","Token storage rejected malformed authorizationDetails.");r.authorizationDetails=e.authorizationDetails}return r}var a=class{state=null;get(){return this.state}set(r){if(!r){this.clear();return}this.state=l(r)}clear(){this.state=null}};function y(){return new a}export{y as createMemoryTokenStorage};
package/package.json ADDED
@@ -0,0 +1,90 @@
1
+ {
2
+ "name": "@tktchurch/auth",
3
+ "version": "0.9.1",
4
+ "description": "Framework-agnostic auth SDK for TKTChurch OAuth/AuthFlow services",
5
+ "license": "MIT",
6
+ "type": "module",
7
+ "packageManager": "bun@1.3.4",
8
+ "main": "./dist/index.cjs",
9
+ "module": "./dist/index.js",
10
+ "types": "./dist/index.d.ts",
11
+ "sideEffects": false,
12
+ "repository": {
13
+ "type": "git",
14
+ "url": "git+https://github.com/tktchurch/auth-sdk-js.git"
15
+ },
16
+ "bugs": {
17
+ "url": "https://github.com/tktchurch/auth-sdk-js/issues"
18
+ },
19
+ "homepage": "https://github.com/tktchurch/auth-sdk-js#readme",
20
+ "keywords": [
21
+ "auth",
22
+ "oauth2",
23
+ "oidc",
24
+ "nuxt",
25
+ "nextjs",
26
+ "sdk",
27
+ "typescript",
28
+ "tktchurch"
29
+ ],
30
+ "engines": {
31
+ "node": ">=18"
32
+ },
33
+ "exports": {
34
+ ".": {
35
+ "types": "./dist/index.d.ts",
36
+ "import": "./dist/index.js",
37
+ "require": "./dist/index.cjs"
38
+ },
39
+ "./storage/memory": {
40
+ "types": "./dist/storage/memory.d.ts",
41
+ "import": "./dist/storage/memory.js",
42
+ "require": "./dist/storage/memory.cjs"
43
+ },
44
+ "./nuxt": {
45
+ "types": "./dist/nuxt/module.d.ts",
46
+ "import": "./dist/nuxt/module.js",
47
+ "require": "./dist/nuxt/module.cjs"
48
+ }
49
+ },
50
+ "files": [
51
+ "dist",
52
+ "CHANGELOG.md",
53
+ "PUBLISHING.md",
54
+ "README.md",
55
+ "SECURITY.md"
56
+ ],
57
+ "scripts": {
58
+ "build": "BUILD_PROFILE=full ./node_modules/.bin/tsup",
59
+ "build:full": "BUILD_PROFILE=full ./node_modules/.bin/tsup",
60
+ "build:consumer": "BUILD_PROFILE=consumer ./node_modules/.bin/tsup",
61
+ "typecheck": "./node_modules/.bin/tsc --noEmit",
62
+ "test": "./node_modules/.bin/vitest run",
63
+ "test:watch": "./node_modules/.bin/vitest",
64
+ "test:local": "RUN_LOCAL_STACK_TESTS=true ./node_modules/.bin/vitest run tests/integration/local-stack.test.ts",
65
+ "test:local:env": "bash scripts/run-local-tests.sh",
66
+ "test:e2e": "playwright test",
67
+ "test:e2e:env": "bash scripts/run-e2e-tests.sh",
68
+ "release:check": "bun run typecheck && bun run test && bun run build:full",
69
+ "release:check:consumer": "bun run typecheck && bun run test && bun run build:consumer",
70
+ "prepublishOnly": "bun run release:check",
71
+ "publish:github": "bun run release:check && npm publish --registry=https://npm.pkg.github.com --access=restricted --ignore-scripts",
72
+ "publish:npmjs": "bun run release:check:consumer && npm publish --registry=https://registry.npmjs.org --access=public --ignore-scripts"
73
+ },
74
+ "peerDependencies": {
75
+ "nuxt": "^3.0.0 || ^4.0.0"
76
+ },
77
+ "peerDependenciesMeta": {
78
+ "nuxt": {
79
+ "optional": true
80
+ }
81
+ },
82
+ "devDependencies": {
83
+ "@nuxt/kit": "^4.3.1",
84
+ "@playwright/test": "^1.60.0",
85
+ "@types/node": "^25.3.1",
86
+ "tsup": "^8.5.1",
87
+ "typescript": "^5.9.3",
88
+ "vitest": "^4.0.18"
89
+ }
90
+ }