@ctx-core/auth0-management 9.1.111 → 9.2.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.
- package/CHANGELOG.md +34 -0
- package/bin/auth0.mjs +2 -2
- package/package.json +5 -3
- package/src/AUTH0_MANAGEMENT_ID__/index.d.ts +5 -0
- package/src/AUTH0_MANAGEMENT_ID__/index.js +17 -0
- package/src/AUTH0_MANAGEMENT_SECRET__/index.d.ts +5 -0
- package/src/AUTH0_MANAGEMENT_SECRET__/index.js +17 -0
- package/src/auth0__v2_client__fetch_get/index.js +11 -5
- package/src/auth0__v2_client_grants__fetch_get/index.js +6 -3
- package/src/auth0__v2_user__fetch_get/index.d.ts +7 -5
- package/src/auth0__v2_user__fetch_get/index.js +8 -4
- package/src/auth0__v2_user__fetch_patch/index.d.ts +4 -1
- package/src/auth0__v2_user__fetch_patch/index.js +8 -6
- package/src/auth0__v2_users_by_email__fetch_get/index.js +6 -3
- package/src/auth0_management_/index.d.ts +5 -3
- package/src/auth0_management_/index.js +19 -5
- package/src/auth0_management__client_credentials__body_/index.js +5 -4
- package/src/auth0_management__init/index.d.ts +8 -0
- package/src/auth0_management__init/index.js +17 -0
- package/src/auth0_management__token_/index.js +16 -4
- package/src/index.d.ts +3 -0
- package/src/index.js +3 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,39 @@
|
|
|
1
1
|
# @ctx-core/auth0-management
|
|
2
2
|
|
|
3
|
+
## 9.2.0
|
|
4
|
+
|
|
5
|
+
### Minor Changes
|
|
6
|
+
|
|
7
|
+
- auth0**v2_user**fetch_patch: returns Promise<[UpdateUserData|auth0__error_T, Response]>
|
|
8
|
+
- - AUTH0*MANAGEMENT_ID\_\_,AUTH0_MANAGEMENT_ID*,AUTH0_MANAGEMENT_ID\_\_set
|
|
9
|
+
- - AUTH0*MANAGEMENT_SECRET\_\_,AUTH0_MANAGEMENT_SECRET*,AUTH0_MANAGEMENT_SECRET\_\_set
|
|
10
|
+
- - auth0**v2_user**fetch_get\_\_params_T: aliased by get_auth0_v2_user_params_T
|
|
11
|
+
|
|
12
|
+
AUTH0_DOMAIN?:string
|
|
13
|
+
|
|
14
|
+
### Patch Changes
|
|
15
|
+
|
|
16
|
+
- ∋ @ctx-core/error,@ctx-core/nanostores
|
|
17
|
+
- Updated dependencies
|
|
18
|
+
- Updated dependencies
|
|
19
|
+
- Updated dependencies
|
|
20
|
+
- Updated dependencies
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
- Updated dependencies
|
|
23
|
+
- Updated dependencies
|
|
24
|
+
- @ctx-core/error@11.6.11
|
|
25
|
+
- @ctx-core/auth0@37.5.0
|
|
26
|
+
|
|
27
|
+
## 9.1.112
|
|
28
|
+
|
|
29
|
+
### Patch Changes
|
|
30
|
+
|
|
31
|
+
- @ctx-core/fetch-undici: ^2.3.114 -> ^2.3.115
|
|
32
|
+
- Updated dependencies
|
|
33
|
+
- Updated dependencies
|
|
34
|
+
- @ctx-core/auth0@37.4.3
|
|
35
|
+
- @ctx-core/fetch-undici@2.3.116
|
|
36
|
+
|
|
3
37
|
## 9.1.111
|
|
4
38
|
|
|
5
39
|
### Patch Changes
|
package/bin/auth0.mjs
CHANGED
|
@@ -7,9 +7,9 @@ async function main() {
|
|
|
7
7
|
const [arg_manager, arg_cmd, ...arg_a] = rest_argv_a
|
|
8
8
|
const management_auth0 = auth0_management_()
|
|
9
9
|
const manager = management_auth0[arg_manager]
|
|
10
|
-
if (!manager) throw `Invalid manager ${arg_manager}`
|
|
10
|
+
if (!manager) throw new Error(`Invalid manager ${arg_manager}`)
|
|
11
11
|
const cmd = manager[arg_cmd]
|
|
12
|
-
if (!cmd) throw `Invalid manager ${arg_cmd}`
|
|
12
|
+
if (!cmd) throw new Error(`Invalid manager ${arg_cmd}`)
|
|
13
13
|
const rv = await cmd(...arg_a)
|
|
14
14
|
console.info(JSON.stringify(rv))
|
|
15
15
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ctx-core/auth0-management",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.2.0",
|
|
4
4
|
"description": "ctx-core auth0 management api",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ctx-core",
|
|
@@ -28,9 +28,11 @@
|
|
|
28
28
|
"getAll-client-grants-auth0": "./bin/getAll-client-grants-auth0.mjs"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@ctx-core/auth0": "^37.
|
|
31
|
+
"@ctx-core/auth0": "^37.5.0",
|
|
32
32
|
"@ctx-core/env": "^17.2.18",
|
|
33
|
-
"@ctx-core/
|
|
33
|
+
"@ctx-core/error": "^11.6.11",
|
|
34
|
+
"@ctx-core/fetch-undici": "^2.3.116",
|
|
35
|
+
"@ctx-core/nanostores": "^2.2.34",
|
|
34
36
|
"@ctx-core/object": "^26.0.0",
|
|
35
37
|
"@ctx-core/uri": "^12.4.0",
|
|
36
38
|
"auth0": "^3.2.0"
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { WritableAtom_ } from '@ctx-core/nanostores'
|
|
2
|
+
import type { Be, Ctx } from '@ctx-core/object'
|
|
3
|
+
export declare const AUTH0_MANAGEMENT_ID__:Be<WritableAtom_<string>>
|
|
4
|
+
export declare function AUTH0_MANAGEMENT_ID_(ctx:Ctx):string
|
|
5
|
+
export declare function AUTH0_MANAGEMENT_ID__set(ctx:Ctx, AUTH0_MANAGEMENT_ID:string):void
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { import_meta_env_ } from '@ctx-core/env'
|
|
2
|
+
import { atom_ } from '@ctx-core/nanostores'
|
|
3
|
+
import { be_ } from '@ctx-core/object'
|
|
4
|
+
/** @typedef {import('@ctx-core/object').Ctx}Ctx */
|
|
5
|
+
/** @type {typeof import('./index.d.ts').AUTH0_MANAGEMENT_ID__} */
|
|
6
|
+
export const AUTH0_MANAGEMENT_ID__ = be_('AUTH0_MANAGEMENT_ID__', ()=>
|
|
7
|
+
atom_(import_meta_env_().AUTH0_MANAGEMENT_ID))
|
|
8
|
+
export function AUTH0_MANAGEMENT_ID_(ctx) {
|
|
9
|
+
return AUTH0_MANAGEMENT_ID__(ctx).$
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @param {Ctx}ctx
|
|
13
|
+
* @param {string}AUTH0_MANAGEMENT_ID
|
|
14
|
+
*/
|
|
15
|
+
export function AUTH0_MANAGEMENT_ID__set(ctx, AUTH0_MANAGEMENT_ID) {
|
|
16
|
+
AUTH0_MANAGEMENT_ID__(ctx).$ = AUTH0_MANAGEMENT_ID
|
|
17
|
+
}
|
|
@@ -0,0 +1,5 @@
|
|
|
1
|
+
import type { WritableAtom_ } from '@ctx-core/nanostores'
|
|
2
|
+
import type { Be, Ctx } from '@ctx-core/object'
|
|
3
|
+
export declare const AUTH0_MANAGEMENT_SECRET__:Be<WritableAtom_<string>>
|
|
4
|
+
export declare function AUTH0_MANAGEMENT_SECRET_(ctx:Ctx):string
|
|
5
|
+
export declare function AUTH0_MANAGEMENT_SECRET__set(ctx:Ctx, AUTH0_MANAGEMENT_SECRET:string):void
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { import_meta_env_ } from '@ctx-core/env'
|
|
2
|
+
import { atom_ } from '@ctx-core/nanostores'
|
|
3
|
+
import { be_ } from '@ctx-core/object'
|
|
4
|
+
/** @typedef {import('@ctx-core/object').Ctx}Ctx */
|
|
5
|
+
/** @type {typeof import('./index.d.ts').AUTH0_MANAGEMENT_SECRET__} */
|
|
6
|
+
export const AUTH0_MANAGEMENT_SECRET__ = be_('AUTH0_MANAGEMENT_SECRET__', ()=>
|
|
7
|
+
atom_(import_meta_env_().AUTH0_MANAGEMENT_SECRET))
|
|
8
|
+
export function AUTH0_MANAGEMENT_SECRET_(ctx) {
|
|
9
|
+
return AUTH0_MANAGEMENT_SECRET__(ctx).$
|
|
10
|
+
}
|
|
11
|
+
/**
|
|
12
|
+
* @param {Ctx}ctx
|
|
13
|
+
* @param {string}AUTH0_MANAGEMENT_SECRET
|
|
14
|
+
*/
|
|
15
|
+
export function AUTH0_MANAGEMENT_SECRET__set(ctx, AUTH0_MANAGEMENT_SECRET) {
|
|
16
|
+
AUTH0_MANAGEMENT_SECRET__(ctx).$ = AUTH0_MANAGEMENT_SECRET
|
|
17
|
+
}
|
|
@@ -1,5 +1,4 @@
|
|
|
1
|
-
import {
|
|
2
|
-
import { import_meta_env_ } from '@ctx-core/env'
|
|
1
|
+
import { AUTH0_CLIENT_ID_, AUTH0_DOMAIN_, header__access_token__verify } from '@ctx-core/auth0'
|
|
3
2
|
import { fetch } from '@ctx-core/fetch-undici'
|
|
4
3
|
import { auth0_management__token_ } from '../auth0_management__token_/index.js'
|
|
5
4
|
/** @typedef {import('auth0').Client}Client */
|
|
@@ -8,11 +7,18 @@ import { auth0_management__token_ } from '../auth0_management__token_/index.js'
|
|
|
8
7
|
* @param {import('./auth0__v2_client__fetch_get.d.ts').auth0__v2_client__fetch__params_T}params
|
|
9
8
|
* @return {Promise<[Client, Response]>}
|
|
10
9
|
*/
|
|
11
|
-
export async function auth0__v2_client__fetch_get(
|
|
12
|
-
|
|
10
|
+
export async function auth0__v2_client__fetch_get(
|
|
11
|
+
ctx,
|
|
12
|
+
params
|
|
13
|
+
) {
|
|
14
|
+
const {
|
|
15
|
+
client_id = AUTH0_CLIENT_ID_(ctx),
|
|
16
|
+
body,
|
|
17
|
+
json,
|
|
18
|
+
} = params
|
|
13
19
|
const auth0_management__token = await auth0_management__token_(ctx)
|
|
14
20
|
const authorization = header__access_token__verify(auth0_management__token)
|
|
15
|
-
const url = `https://${
|
|
21
|
+
const url = `https://${AUTH0_DOMAIN_(ctx)}/api/v2/clients/${client_id}`
|
|
16
22
|
const res = await fetch(url, {
|
|
17
23
|
method: 'PATCH',
|
|
18
24
|
headers: {
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AUTH0_DOMAIN_, header__access_token__verify } from '@ctx-core/auth0'
|
|
2
2
|
import { fetch } from '@ctx-core/fetch-undici'
|
|
3
3
|
import { query_str_ } from '@ctx-core/uri'
|
|
4
4
|
import { auth0_management__token_ } from '../auth0_management__token_/index.js'
|
|
@@ -8,11 +8,14 @@ import { auth0_management__token_ } from '../auth0_management__token_/index.js'
|
|
|
8
8
|
* @param {import('./auth0__v2_client_grants__fetch_get.d.ts').auth0__v2_client_grants__fetch__params_T}params
|
|
9
9
|
* @return {Promise<[CreateClientGrant, Response]>}
|
|
10
10
|
*/
|
|
11
|
-
export async function auth0__v2_client_grants__fetch_get(
|
|
11
|
+
export async function auth0__v2_client_grants__fetch_get(
|
|
12
|
+
ctx,
|
|
13
|
+
params
|
|
14
|
+
) {
|
|
12
15
|
const { query, json } = params
|
|
13
16
|
const auth0__token = await auth0_management__token_(ctx)
|
|
14
17
|
const authorization = header__access_token__verify(auth0__token)
|
|
15
|
-
const url = `https://${
|
|
18
|
+
const url = `https://${AUTH0_DOMAIN_(ctx)}/api/v2/client-grants?${query || query_str_(json)}`
|
|
16
19
|
const res = await fetch(url, {
|
|
17
20
|
method: 'GET',
|
|
18
21
|
headers: {
|
|
@@ -1,12 +1,14 @@
|
|
|
1
1
|
import type { Ctx } from '@ctx-core/object'
|
|
2
2
|
import type { User } from 'auth0'
|
|
3
3
|
export declare function auth0__v2_user__fetch_get(
|
|
4
|
-
ctx:Ctx, params:
|
|
4
|
+
ctx:Ctx, params:auth0__v2_user__fetch_get__params_T
|
|
5
5
|
):Promise<[User, Response]>
|
|
6
|
-
export interface get_auth0_v2_user_params_T {
|
|
7
|
-
AUTH0_DOMAIN:string
|
|
8
|
-
user_id:string
|
|
9
|
-
}
|
|
10
6
|
export {
|
|
11
7
|
auth0__v2_user__fetch_get as get_auth0_v2_user,
|
|
12
8
|
}
|
|
9
|
+
export interface auth0__v2_user__fetch_get__params_T {
|
|
10
|
+
AUTH0_DOMAIN?:string
|
|
11
|
+
user_id:string
|
|
12
|
+
}
|
|
13
|
+
export declare type get_auth0_v2_user_params_T = auth0__v2_user__fetch_get__params_T
|
|
14
|
+
|
|
@@ -1,14 +1,18 @@
|
|
|
1
|
-
import { header__access_token__verify } from '@ctx-core/auth0'
|
|
1
|
+
import { AUTH0_DOMAIN_, header__access_token__verify } from '@ctx-core/auth0'
|
|
2
2
|
import { fetch } from '@ctx-core/fetch-undici'
|
|
3
3
|
import { auth0_management__token_ } from '../auth0_management__token_/index.js'
|
|
4
4
|
/** @typedef {import('auth0').User}User */
|
|
5
5
|
/**
|
|
6
6
|
* @param {import('@ctx-core/object').Ctx}ctx
|
|
7
|
-
* @param {import('./auth0__v2_user__fetch_get.d.ts').
|
|
7
|
+
* @param {import('./auth0__v2_user__fetch_get.d.ts').auth0__v2_user__fetch_get__params_T}params
|
|
8
8
|
* @return {Promise<[User, Response]>}
|
|
9
9
|
*/
|
|
10
|
-
export async function auth0__v2_user__fetch_get(
|
|
11
|
-
|
|
10
|
+
export async function auth0__v2_user__fetch_get(
|
|
11
|
+
ctx,
|
|
12
|
+
params
|
|
13
|
+
) {
|
|
14
|
+
const AUTH0_DOMAIN = params.AUTH0_DOMAIN || AUTH0_DOMAIN_(ctx)
|
|
15
|
+
const { user_id } = params
|
|
12
16
|
const auth0__token = await auth0_management__token_(ctx)
|
|
13
17
|
const authorization = header__access_token__verify(auth0__token)
|
|
14
18
|
const url = `https://${AUTH0_DOMAIN}/api/v2/users/${user_id}`
|
|
@@ -3,7 +3,7 @@ import type { UpdateUserData, UserData } from 'auth0'
|
|
|
3
3
|
import type { Auth0Error } from 'auth0-js'
|
|
4
4
|
export declare function auth0__v2_user__fetch_patch(
|
|
5
5
|
ctx:Ctx, user_id:string, data:auth0__v2_user__fetch_patch__data_T
|
|
6
|
-
):Promise<[UpdateUserData|
|
|
6
|
+
):Promise<[UpdateUserData|auth0__v2_user__fetch_patch__error_T, Response]>
|
|
7
7
|
export {
|
|
8
8
|
auth0__v2_user__fetch_patch as patch_auth0_v2_user,
|
|
9
9
|
}
|
|
@@ -11,3 +11,6 @@ export interface auth0__v2_user__fetch_patch__data_T extends Partial<UserData> {
|
|
|
11
11
|
password?:string
|
|
12
12
|
}
|
|
13
13
|
export declare type patch_auth0_v2_user_data_T = auth0__v2_user__fetch_patch__data_T
|
|
14
|
+
export interface auth0__v2_user__fetch_patch__error_T extends Auth0Error {
|
|
15
|
+
message:string
|
|
16
|
+
}
|
|
@@ -1,13 +1,13 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AUTH0_DOMAIN_, header__access_token__verify } from '@ctx-core/auth0'
|
|
2
2
|
import { fetch } from '@ctx-core/fetch-undici'
|
|
3
3
|
import { auth0_management__token_ } from '../auth0_management__token_/index.js'
|
|
4
4
|
/** @typedef {import('auth0').UpdateUserData}UpdateUserData */
|
|
5
|
-
/** @typedef {import('
|
|
5
|
+
/** @typedef {import('./index.d.ts').auth0__v2_user__fetch_patch__error_T}auth0__v2_user__fetch_patch__error_T */
|
|
6
6
|
/**
|
|
7
7
|
* @param {import('@ctx-core/object').Ctx}ctx
|
|
8
8
|
* @param {string}user_id
|
|
9
9
|
* @param {import('./auth0__v2_user__fetch_patch.d.ts').auth0__v2_user__fetch_patch__data_T}data
|
|
10
|
-
* @return {Promise<[UpdateUserData|
|
|
10
|
+
* @return {Promise<[UpdateUserData|auth0__v2_user__fetch_patch__error_T, Response]>}
|
|
11
11
|
* @see {@link https://auth0.com/docs/api-auth/tutorials/client-credentials}
|
|
12
12
|
* @see {@link https://auth0.com/docs/api-auth/which-oauth-flow-to-use}
|
|
13
13
|
* @see {@link https://auth0.com/docs/clients/client-grant-types}
|
|
@@ -15,11 +15,13 @@ import { auth0_management__token_ } from '../auth0_management__token_/index.js'
|
|
|
15
15
|
* @see {@link https://auth0.com/docs/protocols/oauth2}
|
|
16
16
|
*/
|
|
17
17
|
export async function auth0__v2_user__fetch_patch(
|
|
18
|
-
ctx,
|
|
18
|
+
ctx,
|
|
19
|
+
user_id,
|
|
20
|
+
data
|
|
19
21
|
) {
|
|
20
22
|
const auth0_management_token = await auth0_management__token_(ctx)
|
|
21
23
|
const authorization = header__access_token__verify(auth0_management_token)
|
|
22
|
-
const url = `https://${
|
|
24
|
+
const url = `https://${AUTH0_DOMAIN_(ctx)}/api/v2/users/${user_id}`
|
|
23
25
|
const res = await fetch(url, {
|
|
24
26
|
method: 'PATCH',
|
|
25
27
|
headers: {
|
|
@@ -28,7 +30,7 @@ export async function auth0__v2_user__fetch_patch(
|
|
|
28
30
|
},
|
|
29
31
|
body: JSON.stringify(data)
|
|
30
32
|
})
|
|
31
|
-
/** @type {UpdateUserData|
|
|
33
|
+
/** @type {UpdateUserData|auth0__v2_user__fetch_patch__error_T} */
|
|
32
34
|
const update_user_data_or_auth0_error = await res.json()
|
|
33
35
|
return [update_user_data_or_auth0_error, res]
|
|
34
36
|
}
|
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AUTH0_DOMAIN_, header__access_token__verify } from '@ctx-core/auth0'
|
|
2
2
|
import { fetch } from '@ctx-core/fetch-undici'
|
|
3
3
|
import { auth0_management__token_ } from '../auth0_management__token_/index.js'
|
|
4
4
|
/** @type {import('auth0-js').Auth0UserProfile}Auth0UserProfile */
|
|
@@ -7,9 +7,12 @@ import { auth0_management__token_ } from '../auth0_management__token_/index.js'
|
|
|
7
7
|
* @param {import('./auth0__v2_users_by_email__fetch_get.d.ts').auth0__v2_users_by_email__fetch__params_T}params
|
|
8
8
|
* @return {Promise<[Auth0UserProfile[], Response]>}
|
|
9
9
|
*/
|
|
10
|
-
export async function auth0__v2_users_by_email__fetch_get(
|
|
10
|
+
export async function auth0__v2_users_by_email__fetch_get(
|
|
11
|
+
ctx,
|
|
12
|
+
params
|
|
13
|
+
) {
|
|
11
14
|
const { email } = params
|
|
12
|
-
const AUTH0_DOMAIN = params.AUTH0_DOMAIN ||
|
|
15
|
+
const AUTH0_DOMAIN = params.AUTH0_DOMAIN || AUTH0_DOMAIN_(ctx)
|
|
13
16
|
const auth0__token = await auth0_management__token_(ctx)
|
|
14
17
|
const authorization = header__access_token__verify(auth0__token)
|
|
15
18
|
const url = `https://${AUTH0_DOMAIN}/api/v2/users-by-email?email=${encodeURIComponent(email)}`
|
|
@@ -1,10 +1,12 @@
|
|
|
1
|
+
import type { Ctx } from '@ctx-core/object'
|
|
1
2
|
import type { AppMetadata, ManagementClient, UserMetadata } from 'auth0'
|
|
2
3
|
export declare function auth0_management_(
|
|
4
|
+
ctx:Ctx,
|
|
3
5
|
params?:auth0_management__params_T
|
|
4
6
|
):ManagementClient<AppMetadata, UserMetadata>
|
|
5
7
|
export interface auth0_management__params_T {
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
8
|
+
AUTH0_DOMAIN?:string
|
|
9
|
+
AUTH0_MANAGEMENT_ID?:string
|
|
10
|
+
AUTH0_MANAGEMENT_SECRET?:string
|
|
9
11
|
}
|
|
10
12
|
export declare type auth0_management_params_I = auth0_management__params_T
|
|
@@ -1,13 +1,27 @@
|
|
|
1
|
-
import {
|
|
1
|
+
import { AUTH0_DOMAIN_ } from '@ctx-core/auth0'
|
|
2
2
|
import { ManagementClient } from 'auth0'
|
|
3
|
+
import { AUTH0_MANAGEMENT_ID_ } from '../AUTH0_MANAGEMENT_ID__/index.js'
|
|
4
|
+
import { AUTH0_MANAGEMENT_SECRET_ } from '../AUTH0_MANAGEMENT_SECRET__/index.js'
|
|
3
5
|
/**
|
|
4
6
|
* @param {import('./auth0_management_.d.ts').auth0_management__params_T} params
|
|
5
7
|
* @returns {import('auth0').ManagementClient}
|
|
6
8
|
*/
|
|
7
|
-
export function auth0_management_(
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
9
|
+
export function auth0_management_(
|
|
10
|
+
ctx,
|
|
11
|
+
params = {}
|
|
12
|
+
) {
|
|
13
|
+
const domain =
|
|
14
|
+
params.AUTH0_DOMAIN
|
|
15
|
+
|| AUTH0_DOMAIN_(ctx)
|
|
16
|
+
|| ''
|
|
17
|
+
const clientId =
|
|
18
|
+
params.AUTH0_MANAGEMENT_ID
|
|
19
|
+
|| AUTH0_MANAGEMENT_ID_(ctx)
|
|
20
|
+
|| ''
|
|
21
|
+
const clientSecret =
|
|
22
|
+
params.AUTH0_MANAGEMENT_SECRET
|
|
23
|
+
|| AUTH0_MANAGEMENT_SECRET_(ctx)
|
|
24
|
+
|| ''
|
|
11
25
|
const scope = ''
|
|
12
26
|
return new ManagementClient({
|
|
13
27
|
domain,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { auth0__v2__url_ } from '@ctx-core/auth0'
|
|
2
|
-
import {
|
|
2
|
+
import { AUTH0_MANAGEMENT_ID_ } from '../AUTH0_MANAGEMENT_ID__/index.js'
|
|
3
|
+
import { AUTH0_MANAGEMENT_SECRET_ } from '../AUTH0_MANAGEMENT_SECRET__/index.js'
|
|
3
4
|
/**
|
|
4
5
|
* @param {import('@ctx-core/object').Ctx}ctx
|
|
5
6
|
* @return {import('@ctx-core/auth0').auth0__oauth_token__fetch__body_T}
|
|
@@ -7,9 +8,9 @@ import { import_meta_env_ } from '@ctx-core/env'
|
|
|
7
8
|
export function auth0_management__client_credentials__body_(ctx) {
|
|
8
9
|
return {
|
|
9
10
|
grant_type: 'client_credentials',
|
|
10
|
-
client_id:
|
|
11
|
-
client_secret:
|
|
12
|
-
audience: auth0__v2__url_(ctx)
|
|
11
|
+
client_id: AUTH0_MANAGEMENT_ID_(ctx),
|
|
12
|
+
client_secret: AUTH0_MANAGEMENT_SECRET_(ctx),
|
|
13
|
+
audience: auth0__v2__url_(ctx),
|
|
13
14
|
}
|
|
14
15
|
}
|
|
15
16
|
export {
|
|
@@ -0,0 +1,8 @@
|
|
|
1
|
+
import type { Ctx } from '@ctx-core/object'
|
|
2
|
+
export declare function auth0_management__init(
|
|
3
|
+
ctx:Ctx, params:auth0_management__init__params_T
|
|
4
|
+
):void
|
|
5
|
+
export interface auth0_management__init__params_T {
|
|
6
|
+
AUTH0_MANAGEMENT_ID?:string
|
|
7
|
+
AUTH0_MANAGEMENT_SECRET?:string
|
|
8
|
+
}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { import_meta_env_ } from '@ctx-core/env'
|
|
2
|
+
import { AUTH0_MANAGEMENT_ID__set } from '../AUTH0_MANAGEMENT_ID__/index.js'
|
|
3
|
+
import { AUTH0_MANAGEMENT_SECRET__set } from '../AUTH0_MANAGEMENT_SECRET__/index.js'
|
|
4
|
+
/**
|
|
5
|
+
* @param {import('@ctx-core/object').Ctx}ctx
|
|
6
|
+
* @param {import('./index.d.ts').auth0_management__init__params_T}params
|
|
7
|
+
*/
|
|
8
|
+
export function auth0_management__init(
|
|
9
|
+
ctx, params
|
|
10
|
+
) {
|
|
11
|
+
AUTH0_MANAGEMENT_ID__set(ctx,
|
|
12
|
+
params.AUTH0_MANAGEMENT_ID
|
|
13
|
+
|| import_meta_env_().AUTH0_MANAGEMENT_ID)
|
|
14
|
+
AUTH0_MANAGEMENT_SECRET__set(ctx,
|
|
15
|
+
params.AUTH0_MANAGEMENT_SECRET
|
|
16
|
+
|| import_meta_env_().AUTH0_MANAGEMENT_SECRET)
|
|
17
|
+
}
|
|
@@ -1,13 +1,25 @@
|
|
|
1
1
|
import { auth0__oauth_token__fetch_post } from '@ctx-core/auth0'
|
|
2
|
+
import { http_error__throw } from '@ctx-core/error'
|
|
2
3
|
import { auth0_management__client_credentials__body_ } from '../auth0_management__client_credentials__body_/index.js'
|
|
4
|
+
/** @typedef {import('@ctx-core/auth0').auth0__token_T}auth0__token_T */
|
|
5
|
+
/** @typedef {import('auth0-js').Auth0Error}Auth0Error */
|
|
3
6
|
/**
|
|
4
7
|
* @param {import('@ctx-core/object').Ctx}ctx
|
|
5
|
-
* @return {Promise<
|
|
8
|
+
* @return {Promise<auth0__token_T>}
|
|
6
9
|
*/
|
|
7
10
|
export async function auth0_management__token_(ctx) {
|
|
8
|
-
const [
|
|
9
|
-
|
|
10
|
-
|
|
11
|
+
const [payload, response] =
|
|
12
|
+
await auth0__oauth_token__fetch_post(
|
|
13
|
+
ctx, auth0_management__client_credentials__body_(ctx))
|
|
14
|
+
if (!response.ok) {
|
|
15
|
+
/** @type {Auth0Error} */
|
|
16
|
+
const auth0_error = payload
|
|
17
|
+
http_error__throw({
|
|
18
|
+
http_status: response.status,
|
|
19
|
+
error_message: `${auth0_error.error}: ${auth0_error.error_description}`,
|
|
20
|
+
})
|
|
21
|
+
}
|
|
22
|
+
return payload
|
|
11
23
|
}
|
|
12
24
|
export {
|
|
13
25
|
auth0_management__token_ as auth0_management_token_,
|
package/src/index.d.ts
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export * from './auth0_management_'
|
|
2
2
|
export * from './auth0_management__client_credentials__body_'
|
|
3
|
+
export * from './auth0_management__init'
|
|
3
4
|
export * from './auth0_management__token_'
|
|
4
5
|
export * from './auth0__v2_client_grants__fetch_get'
|
|
5
6
|
export * from './auth0__v2_user__fetch_get'
|
|
6
7
|
export * from './auth0__v2_users_by_email__fetch_get'
|
|
7
8
|
export * from './auth0__v2_client__fetch_get'
|
|
8
9
|
export * from './auth0__v2_user__fetch_patch'
|
|
10
|
+
export * from './AUTH0_MANAGEMENT_ID__'
|
|
11
|
+
export * from './AUTH0_MANAGEMENT_SECRET__'
|
package/src/index.js
CHANGED
|
@@ -1,8 +1,11 @@
|
|
|
1
1
|
export * from './auth0_management_/index.js'
|
|
2
2
|
export * from './auth0_management__client_credentials__body_/index.js'
|
|
3
|
+
export * from './auth0_management__init/index.js'
|
|
3
4
|
export * from './auth0_management__token_/index.js'
|
|
4
5
|
export * from './auth0__v2_client_grants__fetch_get/index.js'
|
|
5
6
|
export * from './auth0__v2_user__fetch_get/index.js'
|
|
6
7
|
export * from './auth0__v2_users_by_email__fetch_get/index.js'
|
|
7
8
|
export * from './auth0__v2_client__fetch_get/index.js'
|
|
8
9
|
export * from './auth0__v2_user__fetch_patch/index.js'
|
|
10
|
+
export * from './AUTH0_MANAGEMENT_ID__/index.js'
|
|
11
|
+
export * from './AUTH0_MANAGEMENT_SECRET__/index.js'
|