@stacksjs/actions 0.75.28 → 0.75.30
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/auth/client-options.d.ts +12 -0
- package/dist/auth/client-options.js +1 -0
- package/dist/auth/client.js +2 -2
- package/dist/auth/prune.js +1 -1
- package/package.json +41 -41
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
export declare function parseAuthClientArgs(args: readonly string[]): AuthClientArgs;
|
|
2
|
+
export declare interface AuthClientArgs {
|
|
3
|
+
name: string
|
|
4
|
+
redirects: string[]
|
|
5
|
+
personal: boolean
|
|
6
|
+
password: boolean
|
|
7
|
+
provider: boolean
|
|
8
|
+
ownerId: number | null
|
|
9
|
+
type: 'confidential' | 'public'
|
|
10
|
+
scopes: string[]
|
|
11
|
+
resources: string[]
|
|
12
|
+
}
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
function option(args,name,short){const names=[`--${name}`,...short?[`-${short}`]:[]];for(let index=0;index<args.length;index++){const argument=args[index];for(const candidate of names){if(argument.startsWith(`${candidate}=`))return argument.slice(candidate.length+1);if(argument===candidate){const value=args[index+1];return value&&!value.startsWith("-")?value:void 0}}}return}function flag(args,name){return args.includes(`--${name}`)}function list(value){return value?.split(",").map((item)=>item.trim()).filter(Boolean)??[]}export function parseAuthClientArgs(args){const owner=Number(option(args,"owner"));return{name:option(args,"name","n")||"OAuth Client",redirects:list(option(args,"redirect","r")??"http://localhost"),personal:flag(args,"personal"),password:flag(args,"password"),provider:flag(args,"provider"),ownerId:Number.isSafeInteger(owner)&&owner>0?owner:null,type:flag(args,"public")?"public":"confidential",scopes:list(option(args,"scopes")),resources:list(option(args,"resources"))}}
|
package/dist/auth/client.js
CHANGED
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
import process from"node:process";import{createClient}from"@stacksjs/auth";import{ensureDatabaseConfigLoaded}from"@stacksjs/database";import{log}from"@stacksjs/logging";const
|
|
2
|
-
`);log.info(` Redirect URI: ${
|
|
1
|
+
import process from"node:process";import{createClient,registerOAuthClient,resolveOAuthProviderConfig}from"@stacksjs/auth";import{config}from"@stacksjs/config";import{ensureDatabaseConfigLoaded}from"@stacksjs/database";import{log}from"@stacksjs/logging";import{parseAuthClientArgs}from"./client-options";const options=parseAuthClientArgs(process.argv.slice(2));log.info(`Creating OAuth client: ${options.name}`);await ensureDatabaseConfigLoaded();const result=options.provider?await createProviderClient():await createClient({name:options.name,redirect:options.redirects[0]||"http://localhost",personalAccessClient:options.personal,passwordClient:options.password});async function createProviderClient(){if(options.personal||options.password)throw Error("Provider clients cannot use --personal or --password.");if(!options.ownerId)throw Error("Provider clients require a positive --owner user id.");if(!options.scopes.length)throw Error("Provider clients require at least one --scopes value.");const provider=resolveOAuthProviderConfig(config.auth.oauthProvider);if(!provider)throw Error("The OAuth authorization server is not enabled in config/auth.ts.");return registerOAuthClient(provider,options.ownerId,{name:options.name,type:options.type,tokenEndpointAuthMethod:options.type==="public"?"none":"client_secret_basic",redirectUris:options.redirects,grantTypes:["authorization_code","refresh_token"],scopes:options.scopes,resources:options.resources})}const{client,plainTextSecret}=result;log.success("OAuth client created successfully");log.info("");log.info("Client Details:");log.info(` Client ID: ${client.id}`);if(plainTextSecret)process.stdout.write(`Client Secret (save now, shown once): ${plainTextSecret}
|
|
2
|
+
`);else log.info(" Client Secret: none (public client)");log.info(` Redirect URI: ${options.redirects.join(", ")}`);log.info("");if(plainTextSecret)log.warn("Make sure to save the client secret. You will not be able to retrieve it again.");await log.flush();process.exit(0);
|
package/dist/auth/prune.js
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
import process from"node:process";import{
|
|
1
|
+
import process from"node:process";import{deleteExpiredTokens,deleteRevokedTokens,pruneOAuthAuthorizationArtifacts}from"@stacksjs/auth";import{log}from"@stacksjs/logging";const args=process.argv.slice(2),hasFlag=(name)=>{return args.includes(`--${name}`)},getArg=(name)=>{const idx=args.findIndex((a)=>a.startsWith(`--${name}=`)||a.startsWith(`-${name.charAt(0)}=`));if(idx!==-1){const arg=args[idx];if(!arg)return;const eqIdx=arg.indexOf("=");return eqIdx>=0?arg.slice(eqIdx+1):void 0}const flagIdx=args.findIndex((a)=>a===`--${name}`||a===`-${name.charAt(0)}`),value=flagIdx!==-1?args[flagIdx+1]:void 0;if(value&&!value.startsWith("-"))return value;return},pruneExpired=!hasFlag("no-expired"),pruneRevoked=!hasFlag("no-revoked"),daysOld=Number(getArg("days"))||7;log.info("Pruning authentication tokens...");let expiredCount=0,revokedCount=0,oauthCount=0;if(pruneExpired){log.info("Removing expired tokens...");expiredCount=await deleteExpiredTokens();log.success(`Removed ${expiredCount} expired token(s)`);const oauth=await pruneOAuthAuthorizationArtifacts({consumedRetentionMs:daysOld*24*60*60*1000});oauthCount=oauth.authorizationRequests+oauth.authorizationCodes;log.success(`Removed ${oauth.authorizationRequests} OAuth authorization request(s)`);log.success(`Removed ${oauth.authorizationCodes} OAuth authorization code(s)`)}if(pruneRevoked){log.info(`Removing tokens revoked more than ${daysOld} day(s) ago...`);revokedCount=await deleteRevokedTokens(daysOld);log.success(`Removed ${revokedCount} revoked token(s)`)}log.success(`Token pruning complete. Total removed: ${expiredCount+revokedCount+oauthCount}`);await log.flush();process.exit(0);
|
package/package.json
CHANGED
|
@@ -2,7 +2,7 @@
|
|
|
2
2
|
"name": "@stacksjs/actions",
|
|
3
3
|
"type": "module",
|
|
4
4
|
"sideEffects": false,
|
|
5
|
-
"version": "0.75.
|
|
5
|
+
"version": "0.75.30",
|
|
6
6
|
"description": "The Stacks actions.",
|
|
7
7
|
"author": "Chris Breuer",
|
|
8
8
|
"contributors": [
|
|
@@ -60,53 +60,53 @@
|
|
|
60
60
|
"prepublishOnly": "bun run build"
|
|
61
61
|
},
|
|
62
62
|
"dependencies": {
|
|
63
|
-
"@stacksjs/action-runner": "0.75.
|
|
64
|
-
"@stacksjs/ai": "0.75.
|
|
65
|
-
"@stacksjs/analytics": "0.75.
|
|
66
|
-
"@stacksjs/api": "0.75.
|
|
67
|
-
"@stacksjs/auth": "0.75.
|
|
68
|
-
"@stacksjs/build": "0.75.
|
|
63
|
+
"@stacksjs/action-runner": "0.75.30",
|
|
64
|
+
"@stacksjs/ai": "0.75.30",
|
|
65
|
+
"@stacksjs/analytics": "0.75.30",
|
|
66
|
+
"@stacksjs/api": "0.75.30",
|
|
67
|
+
"@stacksjs/auth": "0.75.30",
|
|
68
|
+
"@stacksjs/build": "0.75.30",
|
|
69
69
|
"@stacksjs/bumpx": "^0.2.6",
|
|
70
70
|
"@stacksjs/bunpress": "^0.2.8",
|
|
71
|
-
"@stacksjs/cli": "0.75.
|
|
72
|
-
"@stacksjs/cloud": "0.75.
|
|
73
|
-
"@stacksjs/cms": "0.75.
|
|
74
|
-
"@stacksjs/components": "^0.2.
|
|
75
|
-
"@stacksjs/config": "0.75.
|
|
76
|
-
"@stacksjs/database": "0.75.
|
|
77
|
-
"@stacksjs/desktop-build": "0.75.
|
|
78
|
-
"@stacksjs/dns": "0.75.
|
|
79
|
-
"@stacksjs/enums": "0.75.
|
|
80
|
-
"@stacksjs/env": "0.75.
|
|
81
|
-
"@stacksjs/error-handling": "0.75.
|
|
71
|
+
"@stacksjs/cli": "0.75.30",
|
|
72
|
+
"@stacksjs/cloud": "0.75.30",
|
|
73
|
+
"@stacksjs/cms": "0.75.30",
|
|
74
|
+
"@stacksjs/components": "^0.2.337",
|
|
75
|
+
"@stacksjs/config": "0.75.30",
|
|
76
|
+
"@stacksjs/database": "0.75.30",
|
|
77
|
+
"@stacksjs/desktop-build": "0.75.30",
|
|
78
|
+
"@stacksjs/dns": "0.75.30",
|
|
79
|
+
"@stacksjs/enums": "0.75.30",
|
|
80
|
+
"@stacksjs/env": "0.75.30",
|
|
81
|
+
"@stacksjs/error-handling": "0.75.30",
|
|
82
82
|
"@stacksjs/gitit": "^0.2.5",
|
|
83
|
-
"@stacksjs/i18n": "0.75.
|
|
84
|
-
"@stacksjs/image": "0.75.
|
|
85
|
-
"@stacksjs/logging": "0.75.
|
|
83
|
+
"@stacksjs/i18n": "0.75.30",
|
|
84
|
+
"@stacksjs/image": "0.75.30",
|
|
85
|
+
"@stacksjs/logging": "0.75.30",
|
|
86
86
|
"@stacksjs/logsmith": "^0.2.3",
|
|
87
|
-
"@stacksjs/orm": "0.75.
|
|
88
|
-
"@stacksjs/path": "0.75.
|
|
89
|
-
"@stacksjs/payments": "0.75.
|
|
90
|
-
"@stacksjs/queue": "0.75.
|
|
91
|
-
"@stacksjs/registry": "0.75.
|
|
92
|
-
"@stacksjs/router": "0.75.
|
|
87
|
+
"@stacksjs/orm": "0.75.30",
|
|
88
|
+
"@stacksjs/path": "0.75.30",
|
|
89
|
+
"@stacksjs/payments": "0.75.30",
|
|
90
|
+
"@stacksjs/queue": "0.75.30",
|
|
91
|
+
"@stacksjs/registry": "0.75.30",
|
|
92
|
+
"@stacksjs/router": "0.75.30",
|
|
93
93
|
"@stacksjs/rpx": "^0.11.54",
|
|
94
|
-
"@stacksjs/scheduler": "0.75.
|
|
95
|
-
"@stacksjs/search-engine": "0.75.
|
|
96
|
-
"@stacksjs/security": "0.75.
|
|
97
|
-
"@stacksjs/server": "0.75.
|
|
98
|
-
"@stacksjs/sites": "0.75.
|
|
99
|
-
"@stacksjs/storage": "0.75.
|
|
100
|
-
"@stacksjs/strings": "0.75.
|
|
101
|
-
"@stacksjs/stx": "^0.2.
|
|
94
|
+
"@stacksjs/scheduler": "0.75.30",
|
|
95
|
+
"@stacksjs/search-engine": "0.75.30",
|
|
96
|
+
"@stacksjs/security": "0.75.30",
|
|
97
|
+
"@stacksjs/server": "0.75.30",
|
|
98
|
+
"@stacksjs/sites": "0.75.30",
|
|
99
|
+
"@stacksjs/storage": "0.75.30",
|
|
100
|
+
"@stacksjs/strings": "0.75.30",
|
|
101
|
+
"@stacksjs/stx": "^0.2.337",
|
|
102
102
|
"@stacksjs/tlsx": "^0.13.19",
|
|
103
103
|
"@stacksjs/ts-cloud": "^0.16.15",
|
|
104
104
|
"@stacksjs/ts-md": "^0.1.1",
|
|
105
|
-
"@stacksjs/tunnel": "0.75.
|
|
106
|
-
"@stacksjs/types": "0.75.
|
|
107
|
-
"@stacksjs/utils": "0.75.
|
|
108
|
-
"@stacksjs/whois": "0.75.
|
|
109
|
-
"bun-plugin-stx": "^0.2.
|
|
105
|
+
"@stacksjs/tunnel": "0.75.30",
|
|
106
|
+
"@stacksjs/types": "0.75.30",
|
|
107
|
+
"@stacksjs/utils": "0.75.30",
|
|
108
|
+
"@stacksjs/whois": "0.75.30",
|
|
109
|
+
"bun-plugin-stx": "^0.2.337"
|
|
110
110
|
},
|
|
111
111
|
"peerDependencies": {
|
|
112
112
|
"craft-native": ">=0.0.103",
|
|
@@ -121,7 +121,7 @@
|
|
|
121
121
|
}
|
|
122
122
|
},
|
|
123
123
|
"devDependencies": {
|
|
124
|
-
"@stacksjs/validation": "0.75.
|
|
124
|
+
"@stacksjs/validation": "0.75.30",
|
|
125
125
|
"better-dx": "^0.2.24"
|
|
126
126
|
}
|
|
127
127
|
}
|