@ctx-core/auth0-management 9.4.49 → 9.5.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.
package/CHANGELOG.md CHANGED
@@ -1,5 +1,23 @@
1
1
  # @ctx-core/auth0-management
2
2
 
3
+ ## 9.5.1
4
+
5
+ ### Patch Changes
6
+
7
+ - @ctx-core/auth0: ^38.3.0 -> ^38.4.0
8
+
9
+ ## 9.5.0
10
+
11
+ ### Minor Changes
12
+
13
+ - - AUTH0*MANAGEMENT_SECRET$*: aliased by AUTH0_MANAGEMENT_SECRET\_\_
14
+ - - AUTH0*MANAGEMENT_ID$*: aliased by AUTH0_MANAGEMENT_ID\_\_
15
+ - - auth0*management**token**new: aliased by auth0_management\_\_token*
16
+
17
+ ### Patch Changes
18
+
19
+ - auth0_management**token**new: error: fix: error message
20
+
3
21
  ## 9.4.49
4
22
 
5
23
  ### Patch Changes
@@ -341,10 +359,10 @@
341
359
 
342
360
  - fix: types:
343
361
 
344
- AUTH0_MANAGEMENT_ID__
362
+ AUTH0_MANAGEMENT_ID$_
345
363
  AUTH0_MANAGEMENT_ID_
346
364
  AUTH0_MANAGEMENT_ID__set
347
- AUTH0_MANAGEMENT_SECRET__
365
+ AUTH0_MANAGEMENT_SECRET$_
348
366
  AUTH0_MANAGEMENT_SECRET_
349
367
  AUTH0_MANAGEMENT_SECRET__set
350
368
 
package/COMMIT_EDITMSG ADDED
@@ -0,0 +1 @@
1
+
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@ctx-core/auth0-management",
3
- "version": "9.4.49",
3
+ "version": "9.5.1",
4
4
  "description": "ctx-core auth0 management api",
5
5
  "keywords": [
6
6
  "ctx-core",
@@ -28,7 +28,7 @@
28
28
  "getAll-client-grants-auth0": "./bin/getAll-client-grants-auth0.mjs"
29
29
  },
30
30
  "dependencies": {
31
- "@ctx-core/auth0": "^38.3.0",
31
+ "@ctx-core/auth0": "^38.4.0",
32
32
  "@ctx-core/env": "^17.2.107",
33
33
  "@ctx-core/error": "^12.3.36",
34
34
  "@ctx-core/fetch": "^12.10.19",
@@ -40,9 +40,11 @@
40
40
  },
41
41
  "devDependencies": {
42
42
  "@types/auth0": "^3.3.2",
43
- "@types/auth0-js": "^9.14.7",
43
+ "@types/auth0-js": "^9.21.0",
44
+ "@types/sinon": "^10.0.15",
44
45
  "c8": "^7.14.0",
45
46
  "check-dts": "^0.7.2",
47
+ "sinon": "^15.1.0",
46
48
  "tsx": "^3.12.7",
47
49
  "typescript": "next",
48
50
  "uvu": "^0.5.6"
@@ -1,8 +1,11 @@
1
1
  import type { be_atom_triple_T, WritableAtom_ } from '@ctx-core/nanostores'
2
2
  export declare const [
3
- AUTH0_MANAGEMENT_ID__,
3
+ AUTH0_MANAGEMENT_ID$_,
4
4
  AUTH0_MANAGEMENT_ID_,
5
5
  AUTH0_MANAGEMENT_ID__set,
6
6
  ]:be_atom_triple_T<
7
7
  WritableAtom_<string>
8
8
  >
9
+ export {
10
+ AUTH0_MANAGEMENT_ID$_ as AUTH0_MANAGEMENT_ID__,
11
+ }
@@ -1,8 +1,11 @@
1
1
  import { import_meta_env_ } from '@ctx-core/env'
2
2
  import { atom_, be_atom_triple_ } from '@ctx-core/nanostores'
3
3
  export const [
4
- AUTH0_MANAGEMENT_ID__,
4
+ AUTH0_MANAGEMENT_ID$_,
5
5
  AUTH0_MANAGEMENT_ID_,
6
6
  AUTH0_MANAGEMENT_ID__set,
7
7
  ] = be_atom_triple_(()=>
8
8
  atom_(import_meta_env_().AUTH0_MANAGEMENT_ID))
9
+ export {
10
+ AUTH0_MANAGEMENT_ID$_ as AUTH0_MANAGEMENT_ID__,
11
+ }
@@ -1,8 +1,11 @@
1
1
  import type { be_atom_triple_T, WritableAtom_ } from '@ctx-core/nanostores'
2
2
  export declare const [
3
- AUTH0_MANAGEMENT_SECRET__,
3
+ AUTH0_MANAGEMENT_SECRET$_,
4
4
  AUTH0_MANAGEMENT_SECRET_,
5
5
  AUTH0_MANAGEMENT_SECRET__set,
6
6
  ]:be_atom_triple_T<
7
7
  WritableAtom_<string>
8
8
  >
9
+ export {
10
+ AUTH0_MANAGEMENT_SECRET$_ as AUTH0_MANAGEMENT_SECRET__,
11
+ }
@@ -1,8 +1,11 @@
1
1
  import { import_meta_env_ } from '@ctx-core/env'
2
2
  import { atom_, be_atom_triple_ } from '@ctx-core/nanostores'
3
3
  export const [
4
- AUTH0_MANAGEMENT_SECRET__,
4
+ AUTH0_MANAGEMENT_SECRET$_,
5
5
  AUTH0_MANAGEMENT_SECRET_,
6
6
  AUTH0_MANAGEMENT_SECRET__set,
7
7
  ] = be_atom_triple_(()=>
8
8
  atom_(import_meta_env_().AUTH0_MANAGEMENT_SECRET))
9
+ export {
10
+ AUTH0_MANAGEMENT_SECRET$_ as AUTH0_MANAGEMENT_SECRET__,
11
+ }
@@ -1,6 +1,6 @@
1
1
  import { AUTH0_CLIENT_ID_, AUTH0_DOMAIN_, header__access_token__verify } from '@ctx-core/auth0'
2
2
  import { fetch, fetch__template_pair_ } from '@ctx-core/fetch-undici'
3
- import { auth0_management__token_ } from '../auth0_management__token_/index.js'
3
+ import { auth0_management__token__new } from '../auth0_management__token__new/index.js'
4
4
  /** @typedef {import('@ctx-core/fetch').response_pair_T}response_pair_T */
5
5
  /** @typedef {import('@ctx-core/object').Ctx}Ctx */
6
6
  /** @typedef {import('auth0').Client}Client */
@@ -23,7 +23,7 @@ export const [
23
23
  body,
24
24
  json,
25
25
  } = params
26
- const auth0_management__token = await auth0_management__token_(ctx)
26
+ const auth0_management__token = await auth0_management__token__new(ctx)
27
27
  const authorization = header__access_token__verify(auth0_management__token)
28
28
  const url = `https://${AUTH0_DOMAIN_(ctx)}/api/v2/clients/${client_id}`
29
29
  return fetch(url, {
@@ -1,7 +1,7 @@
1
1
  import { AUTH0_DOMAIN_, header__access_token__verify } from '@ctx-core/auth0'
2
2
  import { fetch, fetch__template_pair_ } from '@ctx-core/fetch-undici'
3
3
  import { query_str_ } from '@ctx-core/uri'
4
- import { auth0_management__token_ } from '../auth0_management__token_/index.js'
4
+ import { auth0_management__token__new } from '../auth0_management__token__new/index.js'
5
5
  /** @typedef {import('@ctx-core/fetch').response_pair_T}response_pair_T */
6
6
  /** @typedef {import('@ctx-core/object').Ctx}Ctx */
7
7
  /** @typedef {import('auth0').CreateClientGrant}CreateClientGrant */
@@ -17,7 +17,7 @@ export const [
17
17
  */
18
18
  async(ctx, params)=>{
19
19
  const { query, json } = params
20
- const auth0__token = await auth0_management__token_(ctx)
20
+ const auth0__token = await auth0_management__token__new(ctx)
21
21
  const authorization = header__access_token__verify(auth0__token)
22
22
  const url = `https://${AUTH0_DOMAIN_(ctx)}/api/v2/client-grants?${query || query_str_(json)}`
23
23
  return fetch(url, {
@@ -1,6 +1,6 @@
1
1
  import { AUTH0_DOMAIN_, header__access_token__verify } from '@ctx-core/auth0'
2
2
  import { fetch, fetch__template_pair_ } from '@ctx-core/fetch-undici'
3
- import { auth0_management__token_ } from '../auth0_management__token_/index.js'
3
+ import { auth0_management__token__new } from '../auth0_management__token__new/index.js'
4
4
  /** @typedef {import('@ctx-core/object').Ctx}Ctx */
5
5
  /** @typedef {import('auth0').User}User */
6
6
  /** @typedef {import('./auth0__v2_user__GET__fetch2.d.ts').auth0__v2_user__GET__fetch__params_T}auth0__v2_user__GET__fetch__params_T */
@@ -16,7 +16,7 @@ export const [
16
16
  async(ctx, params)=>{
17
17
  const AUTH0_DOMAIN = params.AUTH0_DOMAIN || AUTH0_DOMAIN_(ctx)
18
18
  const { user_id } = params
19
- const auth0__token = await auth0_management__token_(ctx)
19
+ const auth0__token = await auth0_management__token__new(ctx)
20
20
  const authorization = header__access_token__verify(auth0__token)
21
21
  const url = `https://${AUTH0_DOMAIN}/api/v2/users/${user_id}`
22
22
  return fetch(url, {
@@ -1,6 +1,8 @@
1
1
  import { AUTH0_DOMAIN_, header__access_token__verify } from '@ctx-core/auth0'
2
2
  import { fetch, fetch__template_pair_ } from '@ctx-core/fetch-undici'
3
- import { auth0_management__token_ } from '../auth0_management__token_/index.js'
3
+ import {
4
+ auth0_management__token__new
5
+ } from '../auth0_management__token__new/index.js'
4
6
  /** @typedef {import('@ctx-core/object').Ctx}Ctx */
5
7
  /** @typedef {import('auth0').UpdateUserData}UpdateUserData */
6
8
  /** @typedef {import('./auth0__v2_user__PATCH__fetch2.d.ts').auth0__v2_user__PATCH__fetch__data_T}auth0__v2_user__PATCH__fetch__data_T */
@@ -20,12 +22,12 @@ export const [
20
22
  * @see {@link https://auth0.com/docs/api-auth/grant/authorization-code}
21
23
  * @see {@link https://auth0.com/docs/protocols/oauth2}
22
24
  */
23
- async(
25
+ async (
24
26
  ctx,
25
27
  user_id,
26
28
  data
27
29
  )=>{
28
- const auth0_management_token = await auth0_management__token_(ctx)
30
+ const auth0_management_token = await auth0_management__token__new(ctx)
29
31
  const authorization = header__access_token__verify(auth0_management_token)
30
32
  const url = `https://${AUTH0_DOMAIN_(ctx)}/api/v2/users/${user_id}`
31
33
  return fetch(url, {
@@ -1,6 +1,6 @@
1
1
  import { AUTH0_DOMAIN_, header__access_token__verify } from '@ctx-core/auth0'
2
2
  import { fetch, fetch__template_pair_ } from '@ctx-core/fetch-undici'
3
- import { auth0_management__token_ } from '../auth0_management__token_/index.js'
3
+ import { auth0_management__token__new } from '../auth0_management__token__new/index.js'
4
4
  /** @typedef {import('@ctx-core/object').Ctx}Ctx */
5
5
  /** @type {import('auth0-js').Auth0UserProfile}Auth0UserProfile */
6
6
  /** @typedef {import('./auth0__v2_users_by_email__GET__fetch2.d.ts').auth0__v2_users_by_email__GET__fetch__params_T}auth0__v2_users_by_email__GET__fetch__params_T */
@@ -16,7 +16,7 @@ export const [
16
16
  async (ctx, params)=>{
17
17
  const { email } = params
18
18
  const AUTH0_DOMAIN = params.AUTH0_DOMAIN || AUTH0_DOMAIN_(ctx)
19
- const auth0__token = await auth0_management__token_(ctx)
19
+ const auth0__token = await auth0_management__token__new(ctx)
20
20
  const authorization = header__access_token__verify(auth0__token)
21
21
  const url = `https://${AUTH0_DOMAIN}/api/v2/users-by-email?email=${encodeURIComponent(email)}`
22
22
  const res = await fetch(url, {
@@ -1,6 +1,6 @@
1
1
  import { auth0__v2__url_ } from '@ctx-core/auth0'
2
- import { AUTH0_MANAGEMENT_ID_ } from '../AUTH0_MANAGEMENT_ID__/index.js'
3
- import { AUTH0_MANAGEMENT_SECRET_ } from '../AUTH0_MANAGEMENT_SECRET__/index.js'
2
+ import { AUTH0_MANAGEMENT_ID_ } from '../AUTH0_MANAGEMENT_ID$_/index.js'
3
+ import { AUTH0_MANAGEMENT_SECRET_ } from '../AUTH0_MANAGEMENT_SECRET$_/index.js'
4
4
  /**
5
5
  * @param {import('@ctx-core/object').Ctx}ctx
6
6
  * @return {import('@ctx-core/auth0').auth0__oauth_token__fetch__body_T}
@@ -1,6 +1,6 @@
1
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'
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
4
  /** @typedef {import('@ctx-core/object').Ctx}Ctx */
5
5
  /** @typedef {import('./index.d.ts').auth0_management__init__params_T}auth0_management__init__params_T */
6
6
  /**
@@ -1,7 +1,7 @@
1
1
  import { AUTH0_DOMAIN_ } from '@ctx-core/auth0'
2
2
  import { createRequire } from 'module'
3
- import { AUTH0_MANAGEMENT_ID_ } from '../AUTH0_MANAGEMENT_ID__/index.js'
4
- import { AUTH0_MANAGEMENT_SECRET_ } from '../AUTH0_MANAGEMENT_SECRET__/index.js'
3
+ import { AUTH0_MANAGEMENT_ID_ } from '../AUTH0_MANAGEMENT_ID$_/index.js'
4
+ import { AUTH0_MANAGEMENT_SECRET_ } from '../AUTH0_MANAGEMENT_SECRET$_/index.js'
5
5
  const require = createRequire(import.meta.url)
6
6
  const { ManagementClient } = require('auth0')
7
7
  /** @typedef {import('@ctx-core/object').Ctx}Ctx */
@@ -38,4 +38,4 @@ export function auth0_management__new(
38
38
  }
39
39
  export {
40
40
  auth0_management__new as auth0_management_
41
- }
41
+ }
@@ -1,8 +1,8 @@
1
1
  import type { auth0__token_T } from '@ctx-core/auth0'
2
2
  import type { Ctx } from '@ctx-core/object'
3
- export declare function auth0_management__token_(
3
+ export declare function auth0_management__token__new(
4
4
  ctx:Ctx
5
5
  ):Promise<auth0__token_T>
6
6
  export {
7
- auth0_management__token_ as auth0_management_token_,
7
+ auth0_management__token__new as auth0_management_token_,
8
8
  }
@@ -10,7 +10,7 @@ import {
10
10
  * @param {Ctx}ctx
11
11
  * @return {Promise<auth0__token_T>}
12
12
  */
13
- export async function auth0_management__token_(ctx) {
13
+ export async function auth0_management__token__new(ctx) {
14
14
  const [
15
15
  payload,
16
16
  response
@@ -20,13 +20,15 @@ export async function auth0_management__token_(ctx) {
20
20
  if (!response.ok) {
21
21
  /** @type {Auth0Error} */
22
22
  const auth0_error = payload
23
- http_error__throw({
24
- http__status: response.status,
25
- error_message: `${auth0_error.error}: ${auth0_error.error_description}`,
26
- })
23
+ http_error__throw(
24
+ `${auth0_error.error}: ${auth0_error.error_description}`,
25
+ {
26
+ http__status: response.status,
27
+ })
27
28
  }
28
29
  return payload
29
30
  }
30
31
  export {
31
- auth0_management__token_ as auth0_management_token_,
32
+ auth0_management__token__new as auth0_management__token_,
33
+ auth0_management__token__new as auth0_management_token_,
32
34
  }
@@ -0,0 +1,41 @@
1
+ import { AUTH0_DOMAIN__set } from '@ctx-core/auth0'
2
+ import { ctx_ } from '@ctx-core/object'
3
+ import { restore, stub } from 'sinon'
4
+ import { test } from 'uvu'
5
+ import { equal, throws } from 'uvu/assert'
6
+ import { AUTH0_MANAGEMENT_ID__set } from '../AUTH0_MANAGEMENT_ID$_/index.js'
7
+ import { AUTH0_MANAGEMENT_SECRET__set } from '../AUTH0_MANAGEMENT_SECRET$_/index.js'
8
+ import { auth0_management__token__new } from './index.js'
9
+ test.after.each(()=>restore())
10
+ test('auth0_management__token__new|error', async ()=>{
11
+ const ctx = ctx_()
12
+ AUTH0_DOMAIN__set(ctx, 'myapp.auth0.com')
13
+ AUTH0_MANAGEMENT_ID__set(ctx, 'AUTH0_MANAGEMENT_ID')
14
+ AUTH0_MANAGEMENT_SECRET__set(ctx, 'AUTH0_MANAGEMENT_SECRET')
15
+ const _stub = stub(globalThis, 'fetch')
16
+ .withArgs('https://myapp.auth0.com/oauth/token', {
17
+ method: 'POST',
18
+ headers: { 'Content-Type': 'application/json' },
19
+ body: JSON.stringify({
20
+ grant_type: 'client_credentials',
21
+ client_id: 'AUTH0_MANAGEMENT_ID',
22
+ client_secret: 'AUTH0_MANAGEMENT_SECRET',
23
+ audience: 'https://myapp.auth0.com/api/v2/',
24
+ })
25
+ })
26
+ .resolves(new Response(JSON.stringify({
27
+ error: 'security error',
28
+ error_description: 'invalid credentials'
29
+ }), {
30
+ status: 403,
31
+ headers: {
32
+ 'Content-Type': 'application/json',
33
+ }
34
+ }))
35
+ let err
36
+ await auth0_management__token__new(ctx)
37
+ .catch($err=>err = $err)
38
+ equal(!!err, true)
39
+ equal(err.message, 'security error: invalid credentials')
40
+ })
41
+ test.run()
package/src/index.d.ts CHANGED
@@ -1,11 +1,11 @@
1
1
  export * from './auth0_management__new'
2
2
  export * from './auth0_management__client_credentials__body__new'
3
3
  export * from './auth0_management__init'
4
- export * from './auth0_management__token_'
4
+ export * from './auth0_management__token__new'
5
5
  export * from './auth0__v2_client_grants__GET__fetch'
6
6
  export * from './auth0__v2_user__GET__fetch'
7
7
  export * from './auth0__v2_users_by_email__GET__fetch'
8
8
  export * from './auth0__v2_client__GET__fetch'
9
9
  export * from './auth0__v2_user__PATCH__fetch'
10
- export * from './AUTH0_MANAGEMENT_ID__'
11
- export * from './AUTH0_MANAGEMENT_SECRET__'
10
+ export * from './AUTH0_MANAGEMENT_ID$_'
11
+ export * from './AUTH0_MANAGEMENT_SECRET$_'
package/src/index.js CHANGED
@@ -1,11 +1,11 @@
1
1
  export * from './auth0_management__new/index.js'
2
2
  export * from './auth0_management__client_credentials__body__new/index.js'
3
3
  export * from './auth0_management__init/index.js'
4
- export * from './auth0_management__token_/index.js'
4
+ export * from './auth0_management__token__new/index.js'
5
5
  export * from './auth0__v2_client_grants__GET__fetch/index.js'
6
6
  export * from './auth0__v2_user__GET__fetch/index.js'
7
7
  export * from './auth0__v2_users_by_email__GET__fetch/index.js'
8
8
  export * from './auth0__v2_client__GET__fetch/index.js'
9
9
  export * from './auth0__v2_user__PATCH__fetch/index.js'
10
- export * from './AUTH0_MANAGEMENT_ID__/index.js'
11
- export * from './AUTH0_MANAGEMENT_SECRET__/index.js'
10
+ export * from './AUTH0_MANAGEMENT_ID$_/index.js'
11
+ export * from './AUTH0_MANAGEMENT_SECRET$_/index.js'