@jskit-ai/auth-core 0.1.102 → 0.1.103

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.
@@ -1,7 +1,7 @@
1
1
  export default Object.freeze({
2
2
  "packageVersion": 1,
3
3
  "packageId": "@jskit-ai/auth-core",
4
- "version": "0.1.102",
4
+ "version": "0.1.103",
5
5
  "kind": "runtime",
6
6
  "dependsOn": [
7
7
  "@jskit-ai/value-app-config-shared"
@@ -74,7 +74,7 @@ export default Object.freeze({
74
74
  "mutations": {
75
75
  "dependencies": {
76
76
  "runtime": {
77
- "@jskit-ai/kernel": "0.1.104",
77
+ "@jskit-ai/kernel": "0.1.105",
78
78
  "@fastify/cookie": "^11.0.2",
79
79
  "@fastify/csrf-protection": "^7.1.0",
80
80
  "@fastify/rate-limit": "^10.3.0"
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@jskit-ai/auth-core",
3
- "version": "0.1.102",
3
+ "version": "0.1.103",
4
4
  "type": "module",
5
5
  "scripts": {
6
6
  "test": "node --test"
@@ -54,7 +54,7 @@
54
54
  "./shared/commands/authSessionReadCommand": "./src/shared/commands/authSessionReadCommand.js"
55
55
  },
56
56
  "dependencies": {
57
- "@jskit-ai/kernel": "0.1.104",
57
+ "@jskit-ai/kernel": "0.1.105",
58
58
  "@fastify/cookie": "^11.0.2",
59
59
  "@fastify/csrf-protection": "^7.1.0",
60
60
  "@fastify/rate-limit": "^10.3.0",
@@ -39,6 +39,7 @@ function normalizeAuthActor(value = {}, options = {}) {
39
39
  const appUserId = normalizeOpaqueId(source.appUserId || source.profileId || source.userProfileId, {
40
40
  fallback: null
41
41
  });
42
+ const id = appUserId || providerUserId;
42
43
  const authIdentityId = String(source.authIdentityId || createAuthIdentityId(provider, providerUserId)).trim();
43
44
 
44
45
  if (!providerUserId || !email) {
@@ -46,6 +47,7 @@ function normalizeAuthActor(value = {}, options = {}) {
46
47
  }
47
48
 
48
49
  return Object.freeze({
50
+ id,
49
51
  authIdentityId,
50
52
  provider,
51
53
  providerUserId,
@@ -61,9 +63,8 @@ function buildLegacyProfileFromActor(actorLike) {
61
63
  if (!actor) {
62
64
  return null;
63
65
  }
64
- const id = actor.appUserId || actor.providerUserId || actor.authIdentityId;
65
66
  return Object.freeze({
66
- id,
67
+ id: actor.id || actor.appUserId || actor.providerUserId || actor.authIdentityId,
67
68
  email: actor.email,
68
69
  displayName: actor.displayName,
69
70
  authProvider: actor.provider,
@@ -96,6 +96,7 @@ test("normalizeAuthActor builds the stable actor and legacy profile bridge", ()
96
96
  });
97
97
 
98
98
  assert.deepEqual(actor, {
99
+ id: "42",
99
100
  authIdentityId: "supabase:abc-123",
100
101
  provider: "supabase",
101
102
  providerUserId: "abc-123",
@@ -123,10 +124,36 @@ test("normalizeAuthActor preserves opaque app user ids", () => {
123
124
  profileSource: "users"
124
125
  });
125
126
 
127
+ assert.equal(actor.id, "app-user-1");
126
128
  assert.equal(actor.appUserId, "app-user-1");
127
129
  assert.equal(buildLegacyProfileFromActor(actor).id, "app-user-1");
128
130
  });
129
131
 
132
+ test("normalizeAuthActor exposes projected app user id as the stable actor id", () => {
133
+ const actor = normalizeAuthActor({
134
+ provider: "local",
135
+ providerUserId: "provider-user-1",
136
+ email: "local@example.com",
137
+ appUserId: "app-user-1"
138
+ });
139
+
140
+ assert.equal(actor.id, "app-user-1");
141
+ assert.equal(actor.appUserId, "app-user-1");
142
+ assert.equal(actor.providerUserId, "provider-user-1");
143
+ });
144
+
145
+ test("normalizeAuthActor falls back to provider user id when no app user is projected", () => {
146
+ const actor = normalizeAuthActor({
147
+ provider: "local",
148
+ providerUserId: "provider-user-1",
149
+ email: "local@example.com"
150
+ });
151
+
152
+ assert.equal(actor.id, "provider-user-1");
153
+ assert.equal(actor.appUserId, null);
154
+ assert.equal(actor.providerUserId, "provider-user-1");
155
+ });
156
+
130
157
  test("normalizeAuthSecurityStatus emits policy and legacy authPolicy aliases", () => {
131
158
  const status = buildSecurityStatusFromAuthMethodsStatus(
132
159
  {