@ic-reactor/react 3.12.1 → 3.12.2
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 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createIdentityAttributeHooks.d.ts","sourceRoot":"","sources":["../../src/auth/createIdentityAttributeHooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAA;AACjF,OAAO,KAAK,EACV,uBAAuB,EACvB,mCAAmC,EACnC,yCAAyC,EAC1C,MAAM,YAAY,CAAA;AAEnB,MAAM,WAAW,2BAA2B;IAC1C,iBAAiB,EAAE,CACjB,MAAM,EAAE,mCAAmC,KACxC,OAAO,CAAC,uBAAuB,CAAC,CAAA;IACrC,uBAAuB,EAAE,CACvB,MAAM,EAAE,yCAAyC,KAC9C,OAAO,CAAC,uBAAuB,CAAC,CAAA;IACrC,UAAU,EAAE,uBAAuB,GAAG,IAAI,CAAA;IAC1C,sBAAsB,EAAE,OAAO,CAAA;IAC/B,cAAc,EAAE,KAAK,GAAG,IAAI,CAAA;IAC5B,eAAe,EAAE,MAAM,IAAI,CAAA;CAC5B;AAED,wBAAgB,4BAA4B,CAC1C,kBAAkB,EAAE,yBAAyB;iCAEX,2BAA2B;
|
|
1
|
+
{"version":3,"file":"createIdentityAttributeHooks.d.ts","sourceRoot":"","sources":["../../src/auth/createIdentityAttributeHooks.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,EAAE,yBAAyB,EAAE,MAAM,kCAAkC,CAAA;AACjF,OAAO,KAAK,EACV,uBAAuB,EACvB,mCAAmC,EACnC,yCAAyC,EAC1C,MAAM,YAAY,CAAA;AAEnB,MAAM,WAAW,2BAA2B;IAC1C,iBAAiB,EAAE,CACjB,MAAM,EAAE,mCAAmC,KACxC,OAAO,CAAC,uBAAuB,CAAC,CAAA;IACrC,uBAAuB,EAAE,CACvB,MAAM,EAAE,yCAAyC,KAC9C,OAAO,CAAC,uBAAuB,CAAC,CAAA;IACrC,UAAU,EAAE,uBAAuB,GAAG,IAAI,CAAA;IAC1C,sBAAsB,EAAE,OAAO,CAAA;IAC/B,cAAc,EAAE,KAAK,GAAG,IAAI,CAAA;IAC5B,eAAe,EAAE,MAAM,IAAI,CAAA;CAC5B;AAED,wBAAgB,4BAA4B,CAC1C,kBAAkB,EAAE,yBAAyB;iCAEX,2BAA2B;EAsH9D"}
|
|
@@ -14,17 +14,27 @@ export function createIdentityAttributeHooks(identityAttributes) {
|
|
|
14
14
|
/**
|
|
15
15
|
* A request started before a sign-out or an account switch resolves after
|
|
16
16
|
* it, and publishing that result would put the previous user's decoded PII
|
|
17
|
-
* back on screen with no further auth event to clear it again.
|
|
18
|
-
*
|
|
19
|
-
* the
|
|
17
|
+
* back on screen with no further auth event to clear it again. So a result
|
|
18
|
+
* is committed only when it is the signed-in user's own: it carries the
|
|
19
|
+
* principal that is current when it resolves, or the session has not
|
|
20
|
+
* changed since it was asked for.
|
|
21
|
+
*
|
|
22
|
+
* The first test is the one the default flow needs. With `signIn: true`
|
|
23
|
+
* the request itself signs the user in, so the principal seen before the
|
|
24
|
+
* request (none, for a first sign-in; the old account, for a switch made
|
|
25
|
+
* inside the provider window) is never the one the result belongs to.
|
|
26
|
+
* Comparing against the pre-request principal alone left the hook's
|
|
27
|
+
* `attributes` null after every successful first-time sign-in.
|
|
20
28
|
*/
|
|
21
29
|
const isCurrent = useCallback((requestedFor) => requestedFor === currentPrincipal(), [currentPrincipal]);
|
|
22
30
|
const publishIfCurrent = useCallback((requestedFor, result) => {
|
|
23
|
-
|
|
31
|
+
const current = currentPrincipal();
|
|
32
|
+
if (result.principal !== current && requestedFor !== current) {
|
|
24
33
|
return false;
|
|
34
|
+
}
|
|
25
35
|
setAttributes(result);
|
|
26
36
|
return true;
|
|
27
|
-
}, [
|
|
37
|
+
}, [currentPrincipal]);
|
|
28
38
|
const requestAttributes = useCallback(async (params) => {
|
|
29
39
|
setIsRequestingAttributes(true);
|
|
30
40
|
setAttributeError(null);
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"createIdentityAttributeHooks.js","sourceRoot":"","sources":["../../src/auth/createIdentityAttributeHooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAqBhE,MAAM,UAAU,4BAA4B,CAC1C,kBAA6C;IAE7C,MAAM,qBAAqB,GAAG,GAAgC,EAAE;QAC9D,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAC/B,QAAQ,CAAiC,IAAI,CAAC,CAAA;QAChD,MAAM,CAAC,sBAAsB,EAAE,yBAAyB,CAAC,GAAG,QAAQ,CAAC,KAAK,CAAC,CAAA;QAC3E,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,QAAQ,CAAe,IAAI,CAAC,CAAA;QAExE,mEAAmE;QACnE,MAAM,gBAAgB,GAAG,WAAW,CAAC,GAAG,EAAE;YACxC,MAAM,EAAE,SAAS,EAAE,GAAG,kBAAkB,CAAC,cAAc,CAAA;YACvD,OAAO,SAAS,CAAC,eAAe;gBAC9B,CAAC,CAAC,SAAS,CAAC,QAAQ,EAAE,YAAY,EAAE,CAAC,MAAM,EAAE;gBAC7C,CAAC,CAAC,SAAS,CAAA;QACf,CAAC,EAAE,EAAE,CAAC,CAAA;QAEN
|
|
1
|
+
{"version":3,"file":"createIdentityAttributeHooks.js","sourceRoot":"","sources":["../../src/auth/createIdentityAttributeHooks.ts"],"names":[],"mappings":"AAAA,OAAO,EAAE,WAAW,EAAE,SAAS,EAAE,MAAM,EAAE,QAAQ,EAAE,MAAM,OAAO,CAAA;AAqBhE,MAAM,UAAU,4BAA4B,CAC1C,kBAA6C;IAE7C,MAAM,qBAAqB,GAAG,GAAgC,EAAE;QAC9D,MAAM,CAAC,UAAU,EAAE,aAAa,CAAC,GAC/B,QAAQ,CAAiC,IAAI,CAAC,CAA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C,CAAA;QACjE,SAAS,CAAC,GAAG,EAAE;YACb,MAAM,EAAE,cAAc,EAAE,GAAG,kBAAkB,CAAA;YAC7C,mBAAmB,CAAC,OAAO,KAA3B,mBAAmB,CAAC,OAAO,GAAK,gBAAgB,EAAE,EAAA;YAElD,OAAO,cAAc,CAAC,kBAAkB,CAAC,GAAG,EAAE;gBAC5C,MAAM,SAAS,GAAG,gBAAgB,EAAE,CAAA;gBACpC,IAAI,SAAS,KAAK,mBAAmB,CAAC,OAAO;oBAAE,OAAM;gBACrD,mBAAmB,CAAC,OAAO,GAAG,SAAS,CAAA;gBACvC,aAAa,CAAC,IAAI,CAAC,CAAA;gBACnB,iBAAiB,CAAC,IAAI,CAAC,CAAA;YACzB,CAAC,CAAC,CAAA;QACJ,CAAC,EAAE,EAAE,CAAC,CAAA;QAEN,OAAO;YACL,iBAAiB;YACjB,uBAAuB;YACvB,UAAU;YACV,sBAAsB;YACtB,cAAc;YACd,eAAe;SAChB,CAAA;IACH,CAAC,CAAA;IAED,OAAO,EAAE,qBAAqB,EAAE,CAAA;AAClC,CAAC"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@ic-reactor/react",
|
|
3
|
-
"version": "3.12.
|
|
3
|
+
"version": "3.12.2",
|
|
4
4
|
"description": "IC Reactor React library for building Internet Computer apps",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.js",
|
|
@@ -53,7 +53,7 @@
|
|
|
53
53
|
"author": "Behrad Deylami",
|
|
54
54
|
"license": "MIT",
|
|
55
55
|
"dependencies": {
|
|
56
|
-
"@ic-reactor/core": "^3.12.
|
|
56
|
+
"@ic-reactor/core": "^3.12.2"
|
|
57
57
|
},
|
|
58
58
|
"peerDependencies": {
|
|
59
59
|
"@icp-sdk/auth": "^8.0.0",
|
|
@@ -66,18 +66,18 @@
|
|
|
66
66
|
"@icp-sdk/auth": "^8.0.3",
|
|
67
67
|
"@icp-sdk/core": "^6.1.0",
|
|
68
68
|
"@size-limit/preset-small-lib": "^13.0.3",
|
|
69
|
-
"@tanstack/react-query": "^5.
|
|
69
|
+
"@tanstack/react-query": "^5.102.8",
|
|
70
70
|
"@testing-library/dom": "^10.4.1",
|
|
71
71
|
"@testing-library/jest-dom": "^7.0.1",
|
|
72
|
-
"@testing-library/react": "^16.3.
|
|
72
|
+
"@testing-library/react": "^16.3.3",
|
|
73
73
|
"@types/react": "^19.2.18",
|
|
74
|
-
"@types/react-dom": "^19.2.
|
|
74
|
+
"@types/react-dom": "^19.2.5",
|
|
75
75
|
"fake-indexeddb": "^6.2.5",
|
|
76
76
|
"jsdom": "^30.0.1",
|
|
77
77
|
"react": "^19.2.8",
|
|
78
78
|
"react-dom": "^19.2.8",
|
|
79
79
|
"size-limit": "^13.0.3",
|
|
80
|
-
"vitest": "^4.1.
|
|
80
|
+
"vitest": "^4.1.11"
|
|
81
81
|
},
|
|
82
82
|
"size-limit": [
|
|
83
83
|
{
|
|
@@ -39,9 +39,17 @@ export function createIdentityAttributeHooks(
|
|
|
39
39
|
/**
|
|
40
40
|
* A request started before a sign-out or an account switch resolves after
|
|
41
41
|
* it, and publishing that result would put the previous user's decoded PII
|
|
42
|
-
* back on screen with no further auth event to clear it again.
|
|
43
|
-
*
|
|
44
|
-
* the
|
|
42
|
+
* back on screen with no further auth event to clear it again. So a result
|
|
43
|
+
* is committed only when it is the signed-in user's own: it carries the
|
|
44
|
+
* principal that is current when it resolves, or the session has not
|
|
45
|
+
* changed since it was asked for.
|
|
46
|
+
*
|
|
47
|
+
* The first test is the one the default flow needs. With `signIn: true`
|
|
48
|
+
* the request itself signs the user in, so the principal seen before the
|
|
49
|
+
* request (none, for a first sign-in; the old account, for a switch made
|
|
50
|
+
* inside the provider window) is never the one the result belongs to.
|
|
51
|
+
* Comparing against the pre-request principal alone left the hook's
|
|
52
|
+
* `attributes` null after every successful first-time sign-in.
|
|
45
53
|
*/
|
|
46
54
|
const isCurrent = useCallback(
|
|
47
55
|
(requestedFor: string | undefined) => requestedFor === currentPrincipal(),
|
|
@@ -50,11 +58,14 @@ export function createIdentityAttributeHooks(
|
|
|
50
58
|
|
|
51
59
|
const publishIfCurrent = useCallback(
|
|
52
60
|
(requestedFor: string | undefined, result: IdentityAttributeResult) => {
|
|
53
|
-
|
|
61
|
+
const current = currentPrincipal()
|
|
62
|
+
if (result.principal !== current && requestedFor !== current) {
|
|
63
|
+
return false
|
|
64
|
+
}
|
|
54
65
|
setAttributes(result)
|
|
55
66
|
return true
|
|
56
67
|
},
|
|
57
|
-
[
|
|
68
|
+
[currentPrincipal]
|
|
58
69
|
)
|
|
59
70
|
|
|
60
71
|
const requestAttributes = useCallback(
|