@ctx-core/auth0-management 9.6.7 → 9.7.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 +18 -0
- package/package.json +2 -2
- package/src/auth0__user/index.d.ts +9 -0
- package/src/auth0__user/index.js +7 -0
- package/src/auth0__user/index.test.ts +49 -0
- package/src/auth0__v2_user__GET__fetch/index.test.ts +105 -0
- package/src/auth0_management__client_credentials__body__new/index.js +2 -2
- package/src/auth0_management__init/index.js +2 -2
- package/src/auth0_management__new/index.js +2 -2
- package/src/auth0_management__token__new/index.js +2 -1
- package/src/index.d.ts +3 -2
- package/src/index.js +3 -2
- package/COMMIT_EDITMSG +0 -1
- /package/src/{AUTH0_MANAGEMENT_ID$_ → AUTH0_MANAGEMENT_ID}/index.d.ts +0 -0
- /package/src/{AUTH0_MANAGEMENT_ID$_ → AUTH0_MANAGEMENT_ID}/index.js +0 -0
- /package/src/{AUTH0_MANAGEMENT_SECRET$_ → AUTH0_MANAGEMENT_SECRET}/index.d.ts +0 -0
- /package/src/{AUTH0_MANAGEMENT_SECRET$_ → AUTH0_MANAGEMENT_SECRET}/index.js +0 -0
package/CHANGELOG.md
CHANGED
|
@@ -1,5 +1,23 @@
|
|
|
1
1
|
# @ctx-core/auth0-management
|
|
2
2
|
|
|
3
|
+
## 9.7.1
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- Updated dependencies
|
|
8
|
+
- Updated dependencies
|
|
9
|
+
- @ctx-core/auth0@39.0.0
|
|
10
|
+
|
|
11
|
+
## 9.7.0
|
|
12
|
+
|
|
13
|
+
### Minor Changes
|
|
14
|
+
|
|
15
|
+
- new functions:
|
|
16
|
+
|
|
17
|
+
+ auth0__user$_
|
|
18
|
+
+ auth0__user_
|
|
19
|
+
+ auth0__user__set
|
|
20
|
+
|
|
3
21
|
## 9.6.7
|
|
4
22
|
|
|
5
23
|
### Patch Changes
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ctx-core/auth0-management",
|
|
3
|
-
"version": "9.
|
|
3
|
+
"version": "9.7.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": "^
|
|
31
|
+
"@ctx-core/auth0": "^39.0.0",
|
|
32
32
|
"@ctx-core/env": "^17.2.108",
|
|
33
33
|
"@ctx-core/error": "^12.3.36",
|
|
34
34
|
"@ctx-core/fetch": "^12.11.1",
|
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
import { ctx_ } from '@ctx-core/object'
|
|
2
|
+
import { User } from 'auth0'
|
|
3
|
+
import { test } from 'uvu'
|
|
4
|
+
import { equal } from 'uvu/assert'
|
|
5
|
+
import { auth0__user$_, auth0__user_, auth0__user__set } from '../index.js'
|
|
6
|
+
test('auth0__user', ()=>{
|
|
7
|
+
const ctx = ctx_()
|
|
8
|
+
const auth0__user = auth0__user__new()
|
|
9
|
+
equal(auth0__user$_(ctx).$, undefined)
|
|
10
|
+
equal(auth0__user_(ctx), undefined)
|
|
11
|
+
auth0__user__set(ctx, auth0__user)
|
|
12
|
+
equal(auth0__user$_(ctx).$, auth0__user)
|
|
13
|
+
equal(auth0__user_(ctx), auth0__user)
|
|
14
|
+
})
|
|
15
|
+
test.run()
|
|
16
|
+
function auth0__user__new() {
|
|
17
|
+
return {
|
|
18
|
+
"user_id": "auth0|507f1f77bcf86cd799439020",
|
|
19
|
+
"email": "john.doe@gmail.com",
|
|
20
|
+
"email_verified": false,
|
|
21
|
+
"username": "johndoe",
|
|
22
|
+
"phone_number": "+199999999999999",
|
|
23
|
+
"phone_verified": false,
|
|
24
|
+
"created_at": "",
|
|
25
|
+
"updated_at": "",
|
|
26
|
+
"identities": [
|
|
27
|
+
{
|
|
28
|
+
"connection": "Initial-Connection",
|
|
29
|
+
"user_id": "507f1f77bcf86cd799439020",
|
|
30
|
+
"provider": "auth0",
|
|
31
|
+
"isSocial": false
|
|
32
|
+
}
|
|
33
|
+
],
|
|
34
|
+
"app_metadata": {},
|
|
35
|
+
"user_metadata": {},
|
|
36
|
+
"picture": "",
|
|
37
|
+
"name": "",
|
|
38
|
+
"nickname": "",
|
|
39
|
+
"multifactor": [
|
|
40
|
+
""
|
|
41
|
+
],
|
|
42
|
+
"last_ip": "",
|
|
43
|
+
"last_login": "",
|
|
44
|
+
"logins_count": 0,
|
|
45
|
+
"blocked": false,
|
|
46
|
+
"given_name": "",
|
|
47
|
+
"family_name": ""
|
|
48
|
+
} as User
|
|
49
|
+
}
|
|
@@ -0,0 +1,105 @@
|
|
|
1
|
+
import { AUTH0_DOMAIN__set } from '@ctx-core/auth0'
|
|
2
|
+
import { ctx_ } from '@ctx-core/object'
|
|
3
|
+
import { type User } from 'auth0'
|
|
4
|
+
import { restore, stub } from 'sinon'
|
|
5
|
+
import { test } from 'uvu'
|
|
6
|
+
import { equal } from 'uvu/assert'
|
|
7
|
+
import { auth0_management__init } from '../auth0_management__init/index.js'
|
|
8
|
+
import { auth0__v2_user__GET__fetch, auth0__v2_user__GET__fetch2 } from './index.js'
|
|
9
|
+
test.after.each(()=>restore())
|
|
10
|
+
test('auth0__v2_user__GET__fetch', async ()=>{
|
|
11
|
+
const ctx = ctx_()
|
|
12
|
+
AUTH0_DOMAIN__set(ctx, 'myapp.auth0.com')
|
|
13
|
+
auth0_management__init(ctx, {
|
|
14
|
+
AUTH0_MANAGEMENT_ID: 'AUTH0_MANAGEMENT_ID',
|
|
15
|
+
AUTH0_MANAGEMENT_SECRET: 'AUTH0_MANAGEMENT_SECRET'
|
|
16
|
+
})
|
|
17
|
+
const auth0__user = auth0__user__new()
|
|
18
|
+
api_v2_user__stub(auth0__user)
|
|
19
|
+
const response = await auth0__v2_user__GET__fetch(ctx, {
|
|
20
|
+
user_id: '123'
|
|
21
|
+
})
|
|
22
|
+
equal(response.status, 200)
|
|
23
|
+
equal(await response.json(), auth0__user)
|
|
24
|
+
})
|
|
25
|
+
test('auth0__v2_user__GET__fetch2', async ()=>{
|
|
26
|
+
const ctx = ctx_()
|
|
27
|
+
AUTH0_DOMAIN__set(ctx, 'myapp.auth0.com')
|
|
28
|
+
auth0_management__init(ctx, {
|
|
29
|
+
AUTH0_MANAGEMENT_ID: 'AUTH0_MANAGEMENT_ID',
|
|
30
|
+
AUTH0_MANAGEMENT_SECRET: 'AUTH0_MANAGEMENT_SECRET'
|
|
31
|
+
})
|
|
32
|
+
const test__auth0__user = auth0__user__new()
|
|
33
|
+
api_v2_user__stub(test__auth0__user)
|
|
34
|
+
const [auth0__user, response] =
|
|
35
|
+
await auth0__v2_user__GET__fetch2(ctx, {
|
|
36
|
+
user_id: '123'
|
|
37
|
+
})
|
|
38
|
+
equal(response.status, 200)
|
|
39
|
+
equal(auth0__user, test__auth0__user)
|
|
40
|
+
})
|
|
41
|
+
test.run()
|
|
42
|
+
function auth0__user__new() {
|
|
43
|
+
return {
|
|
44
|
+
'user_id': 'auth0|507f1f77bcf86cd799439020',
|
|
45
|
+
'email': 'john.doe@gmail.com',
|
|
46
|
+
'email_verified': false,
|
|
47
|
+
'username': 'johndoe',
|
|
48
|
+
'phone_number': '+199999999999999',
|
|
49
|
+
'phone_verified': false,
|
|
50
|
+
'created_at': '',
|
|
51
|
+
'updated_at': '',
|
|
52
|
+
'identities': [
|
|
53
|
+
{
|
|
54
|
+
'connection': 'Initial-Connection',
|
|
55
|
+
'user_id': '507f1f77bcf86cd799439020',
|
|
56
|
+
'provider': 'auth0',
|
|
57
|
+
'isSocial': false
|
|
58
|
+
}
|
|
59
|
+
],
|
|
60
|
+
'app_metadata': {},
|
|
61
|
+
'user_metadata': {},
|
|
62
|
+
'picture': '',
|
|
63
|
+
'name': '',
|
|
64
|
+
'nickname': '',
|
|
65
|
+
'multifactor': [
|
|
66
|
+
''
|
|
67
|
+
],
|
|
68
|
+
'last_ip': '',
|
|
69
|
+
'last_login': '',
|
|
70
|
+
'logins_count': 0,
|
|
71
|
+
'blocked': false,
|
|
72
|
+
'given_name': '',
|
|
73
|
+
'family_name': ''
|
|
74
|
+
} as User
|
|
75
|
+
}
|
|
76
|
+
function api_v2_user__stub(auth0__user:User) {
|
|
77
|
+
const fetch = stub(globalThis, 'fetch')
|
|
78
|
+
fetch
|
|
79
|
+
.withArgs('https://myapp.auth0.com/oauth/token', {
|
|
80
|
+
method: 'POST',
|
|
81
|
+
headers: { 'Content-Type': 'application/json' },
|
|
82
|
+
body: JSON.stringify({
|
|
83
|
+
grant_type: 'client_credentials',
|
|
84
|
+
client_id: 'AUTH0_MANAGEMENT_ID',
|
|
85
|
+
client_secret: 'AUTH0_MANAGEMENT_SECRET',
|
|
86
|
+
audience: 'https://myapp.auth0.com/api/v2/',
|
|
87
|
+
})
|
|
88
|
+
})
|
|
89
|
+
.resolves(new Response(JSON.stringify({
|
|
90
|
+
access_token: 'access_token',
|
|
91
|
+
token_type: 'Bearer',
|
|
92
|
+
}), {
|
|
93
|
+
status: 200,
|
|
94
|
+
headers: {
|
|
95
|
+
'Content-Type': 'application/json'
|
|
96
|
+
}
|
|
97
|
+
}))
|
|
98
|
+
fetch.withArgs('https://myapp.auth0.com/api/v2/users/123')
|
|
99
|
+
.resolves(new Response(JSON.stringify(auth0__user), {
|
|
100
|
+
status: 200,
|
|
101
|
+
headers: {
|
|
102
|
+
'Content-Type': 'application/json'
|
|
103
|
+
}
|
|
104
|
+
}))
|
|
105
|
+
}
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
import { auth0__v2__url_ } from '@ctx-core/auth0'
|
|
2
|
-
import { AUTH0_MANAGEMENT_ID_ } from '../AUTH0_MANAGEMENT_ID
|
|
3
|
-
import { AUTH0_MANAGEMENT_SECRET_ } from '../AUTH0_MANAGEMENT_SECRET
|
|
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
|
|
3
|
-
import { AUTH0_MANAGEMENT_SECRET__set } from '../AUTH0_MANAGEMENT_SECRET
|
|
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
|
|
4
|
-
import { AUTH0_MANAGEMENT_SECRET_ } from '../AUTH0_MANAGEMENT_SECRET
|
|
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 */
|
|
@@ -16,7 +16,8 @@ export async function auth0_management__token__new(ctx) {
|
|
|
16
16
|
response
|
|
17
17
|
] =
|
|
18
18
|
await auth0__oauth_token__POST__fetch2(
|
|
19
|
-
ctx,
|
|
19
|
+
ctx,
|
|
20
|
+
auth0_management__client_credentials__body__new(ctx))
|
|
20
21
|
if (!response.ok) {
|
|
21
22
|
/** @type {Auth0Error} */
|
|
22
23
|
const auth0_error = payload
|
package/src/index.d.ts
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './auth0__user'
|
|
1
2
|
export * from './auth0_management__new'
|
|
2
3
|
export * from './auth0_management__client_credentials__body__new'
|
|
3
4
|
export * from './auth0_management__init'
|
|
@@ -7,5 +8,5 @@ export * from './auth0__v2_user__GET__fetch'
|
|
|
7
8
|
export * from './auth0__v2_users_by_email__GET__fetch'
|
|
8
9
|
export * from './auth0__v2_client__GET__fetch'
|
|
9
10
|
export * from './auth0__v2_user__PATCH__fetch'
|
|
10
|
-
export * from './AUTH0_MANAGEMENT_ID
|
|
11
|
-
export * from './AUTH0_MANAGEMENT_SECRET
|
|
11
|
+
export * from './AUTH0_MANAGEMENT_ID'
|
|
12
|
+
export * from './AUTH0_MANAGEMENT_SECRET'
|
package/src/index.js
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
1
|
+
export * from './auth0__user/index.js'
|
|
1
2
|
export * from './auth0_management__new/index.js'
|
|
2
3
|
export * from './auth0_management__client_credentials__body__new/index.js'
|
|
3
4
|
export * from './auth0_management__init/index.js'
|
|
@@ -7,5 +8,5 @@ export * from './auth0__v2_user__GET__fetch/index.js'
|
|
|
7
8
|
export * from './auth0__v2_users_by_email__GET__fetch/index.js'
|
|
8
9
|
export * from './auth0__v2_client__GET__fetch/index.js'
|
|
9
10
|
export * from './auth0__v2_user__PATCH__fetch/index.js'
|
|
10
|
-
export * from './AUTH0_MANAGEMENT_ID
|
|
11
|
-
export * from './AUTH0_MANAGEMENT_SECRET
|
|
11
|
+
export * from './AUTH0_MANAGEMENT_ID/index.js'
|
|
12
|
+
export * from './AUTH0_MANAGEMENT_SECRET/index.js'
|
package/COMMIT_EDITMSG
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|