@ctx-core/auth0-management 9.7.0 → 9.7.8
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,67 @@
|
|
|
1
1
|
# @ctx-core/auth0-management
|
|
2
2
|
|
|
3
|
+
## 9.7.8
|
|
4
|
+
|
|
5
|
+
### Patch Changes
|
|
6
|
+
|
|
7
|
+
- @ctx-core/env: ^17.2.111 -> ^17.2.112
|
|
8
|
+
- @ctx-core/auth0: ^39.0.3 -> ^39.0.4
|
|
9
|
+
|
|
10
|
+
## 9.7.7
|
|
11
|
+
|
|
12
|
+
### Patch Changes
|
|
13
|
+
|
|
14
|
+
- Updated dependencies
|
|
15
|
+
- @ctx-core/nanostores@5.0.4
|
|
16
|
+
|
|
17
|
+
## 9.7.6
|
|
18
|
+
|
|
19
|
+
### Patch Changes
|
|
20
|
+
|
|
21
|
+
- Updated dependencies
|
|
22
|
+
- @ctx-core/nanostores@5.0.3
|
|
23
|
+
|
|
24
|
+
## 9.7.5
|
|
25
|
+
|
|
26
|
+
### Patch Changes
|
|
27
|
+
|
|
28
|
+
- @ctx-core/auth0: ^39.0.1 -> ^39.0.2
|
|
29
|
+
- @ctx-core/env: ^17.2.109 -> ^17.2.110
|
|
30
|
+
- Updated dependencies
|
|
31
|
+
- @ctx-core/auth0@39.0.3
|
|
32
|
+
- @ctx-core/env@17.2.111
|
|
33
|
+
|
|
34
|
+
## 9.7.4
|
|
35
|
+
|
|
36
|
+
### Patch Changes
|
|
37
|
+
|
|
38
|
+
- Updated dependencies
|
|
39
|
+
- @ctx-core/nanostores@5.0.2
|
|
40
|
+
|
|
41
|
+
## 9.7.3
|
|
42
|
+
|
|
43
|
+
### Patch Changes
|
|
44
|
+
|
|
45
|
+
- Updated dependencies
|
|
46
|
+
- @ctx-core/nanostores@5.0.1
|
|
47
|
+
|
|
48
|
+
## 9.7.2
|
|
49
|
+
|
|
50
|
+
### Patch Changes
|
|
51
|
+
|
|
52
|
+
- Updated dependencies
|
|
53
|
+
- @ctx-core/nanostores@5.0.0
|
|
54
|
+
- @ctx-core/auth0@39.0.1
|
|
55
|
+
- @ctx-core/env@17.2.109
|
|
56
|
+
|
|
57
|
+
## 9.7.1
|
|
58
|
+
|
|
59
|
+
### Patch Changes
|
|
60
|
+
|
|
61
|
+
- Updated dependencies
|
|
62
|
+
- Updated dependencies
|
|
63
|
+
- @ctx-core/auth0@39.0.0
|
|
64
|
+
|
|
3
65
|
## 9.7.0
|
|
4
66
|
|
|
5
67
|
### Minor Changes
|
package/COMMIT_EDITMSG
CHANGED
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ctx-core/auth0-management",
|
|
3
|
-
"version": "9.7.
|
|
3
|
+
"version": "9.7.8",
|
|
4
4
|
"description": "ctx-core auth0 management api",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"ctx-core",
|
|
@@ -28,11 +28,11 @@
|
|
|
28
28
|
"getAll-client-grants-auth0": "./bin/getAll-client-grants-auth0.mjs"
|
|
29
29
|
},
|
|
30
30
|
"dependencies": {
|
|
31
|
-
"@ctx-core/auth0": "^
|
|
32
|
-
"@ctx-core/env": "^17.2.
|
|
31
|
+
"@ctx-core/auth0": "^39.0.4",
|
|
32
|
+
"@ctx-core/env": "^17.2.112",
|
|
33
33
|
"@ctx-core/error": "^12.3.36",
|
|
34
34
|
"@ctx-core/fetch": "^12.11.1",
|
|
35
|
-
"@ctx-core/nanostores": "
|
|
35
|
+
"@ctx-core/nanostores": "5.0.4",
|
|
36
36
|
"@ctx-core/object": "^28.0.1",
|
|
37
37
|
"@ctx-core/uri": "^12.4.48",
|
|
38
38
|
"auth0": "^3.4.0"
|
|
@@ -41,9 +41,9 @@
|
|
|
41
41
|
"@types/auth0": "^3.3.3",
|
|
42
42
|
"@types/auth0-js": "^9.21.0",
|
|
43
43
|
"@types/sinon": "^10.0.15",
|
|
44
|
-
"c8": "^
|
|
44
|
+
"c8": "^8.0.0",
|
|
45
45
|
"check-dts": "^0.7.2",
|
|
46
|
-
"sinon": "^15.1.
|
|
46
|
+
"sinon": "^15.1.2",
|
|
47
47
|
"tsx": "^3.12.7",
|
|
48
48
|
"typescript": "next",
|
|
49
49
|
"uvu": "^0.5.6"
|
|
@@ -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
|
+
}
|
|
@@ -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
|