@ic-reactor/react 3.13.0 → 4.0.0-beta.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.
Files changed (174) hide show
  1. package/README.md +237 -787
  2. package/dist/index.d.ts +260 -16
  3. package/dist/index.d.ts.map +1 -1
  4. package/dist/index.js +471 -23
  5. package/dist/index.js.map +1 -1
  6. package/llms.txt +82 -278
  7. package/package.json +11 -39
  8. package/src/index.tsx +612 -0
  9. package/dist/auth/auth-client-compat.d.ts +0 -122
  10. package/dist/auth/auth-client-compat.d.ts.map +0 -1
  11. package/dist/auth/auth-client-compat.js +0 -162
  12. package/dist/auth/auth-client-compat.js.map +0 -1
  13. package/dist/auth/authentication-manager.d.ts +0 -405
  14. package/dist/auth/authentication-manager.d.ts.map +0 -1
  15. package/dist/auth/authentication-manager.js +0 -1537
  16. package/dist/auth/authentication-manager.js.map +0 -1
  17. package/dist/auth/constants.d.ts +0 -24
  18. package/dist/auth/constants.d.ts.map +0 -1
  19. package/dist/auth/constants.js +0 -24
  20. package/dist/auth/constants.js.map +0 -1
  21. package/dist/auth/createIdentityAttributeHooks.d.ts +0 -14
  22. package/dist/auth/createIdentityAttributeHooks.d.ts.map +0 -1
  23. package/dist/auth/createIdentityAttributeHooks.js +0 -122
  24. package/dist/auth/createIdentityAttributeHooks.js.map +0 -1
  25. package/dist/auth/identity-attributes-manager.d.ts +0 -27
  26. package/dist/auth/identity-attributes-manager.d.ts.map +0 -1
  27. package/dist/auth/identity-attributes-manager.js +0 -191
  28. package/dist/auth/identity-attributes-manager.js.map +0 -1
  29. package/dist/auth/identity-attributes.d.ts +0 -19
  30. package/dist/auth/identity-attributes.d.ts.map +0 -1
  31. package/dist/auth/identity-attributes.js +0 -227
  32. package/dist/auth/identity-attributes.js.map +0 -1
  33. package/dist/auth/index.d.ts +0 -8
  34. package/dist/auth/index.d.ts.map +0 -1
  35. package/dist/auth/index.js +0 -8
  36. package/dist/auth/index.js.map +0 -1
  37. package/dist/auth/local-ii-probe.d.ts +0 -57
  38. package/dist/auth/local-ii-probe.d.ts.map +0 -1
  39. package/dist/auth/local-ii-probe.js +0 -121
  40. package/dist/auth/local-ii-probe.js.map +0 -1
  41. package/dist/auth/types.d.ts +0 -222
  42. package/dist/auth/types.d.ts.map +0 -1
  43. package/dist/auth/types.js +0 -2
  44. package/dist/auth/types.js.map +0 -1
  45. package/dist/createActorHooks.d.ts +0 -41
  46. package/dist/createActorHooks.d.ts.map +0 -1
  47. package/dist/createActorHooks.js +0 -17
  48. package/dist/createActorHooks.js.map +0 -1
  49. package/dist/createInfiniteQuery.d.ts +0 -185
  50. package/dist/createInfiniteQuery.d.ts.map +0 -1
  51. package/dist/createInfiniteQuery.js +0 -198
  52. package/dist/createInfiniteQuery.js.map +0 -1
  53. package/dist/createMutation.d.ts +0 -33
  54. package/dist/createMutation.d.ts.map +0 -1
  55. package/dist/createMutation.js +0 -199
  56. package/dist/createMutation.js.map +0 -1
  57. package/dist/createQuery.d.ts +0 -63
  58. package/dist/createQuery.d.ts.map +0 -1
  59. package/dist/createQuery.js +0 -204
  60. package/dist/createQuery.js.map +0 -1
  61. package/dist/createReactorProvider.d.ts +0 -158
  62. package/dist/createReactorProvider.d.ts.map +0 -1
  63. package/dist/createReactorProvider.js +0 -256
  64. package/dist/createReactorProvider.js.map +0 -1
  65. package/dist/createSuspenseInfiniteQuery.d.ts +0 -154
  66. package/dist/createSuspenseInfiniteQuery.d.ts.map +0 -1
  67. package/dist/createSuspenseInfiniteQuery.js +0 -209
  68. package/dist/createSuspenseInfiniteQuery.js.map +0 -1
  69. package/dist/createSuspenseQuery.d.ts +0 -46
  70. package/dist/createSuspenseQuery.d.ts.map +0 -1
  71. package/dist/createSuspenseQuery.js +0 -158
  72. package/dist/createSuspenseQuery.js.map +0 -1
  73. package/dist/defineDisplayReactor.d.ts +0 -43
  74. package/dist/defineDisplayReactor.d.ts.map +0 -1
  75. package/dist/defineDisplayReactor.js +0 -42
  76. package/dist/defineDisplayReactor.js.map +0 -1
  77. package/dist/defineReactor.d.ts +0 -99
  78. package/dist/defineReactor.d.ts.map +0 -1
  79. package/dist/defineReactor.js +0 -15
  80. package/dist/defineReactor.js.map +0 -1
  81. package/dist/defineReactorShared.d.ts +0 -84
  82. package/dist/defineReactorShared.d.ts.map +0 -1
  83. package/dist/defineReactorShared.js +0 -139
  84. package/dist/defineReactorShared.js.map +0 -1
  85. package/dist/hooks/createAuthHooks.d.ts +0 -50
  86. package/dist/hooks/createAuthHooks.d.ts.map +0 -1
  87. package/dist/hooks/createAuthHooks.js +0 -291
  88. package/dist/hooks/createAuthHooks.js.map +0 -1
  89. package/dist/hooks/index.d.ts +0 -21
  90. package/dist/hooks/index.d.ts.map +0 -1
  91. package/dist/hooks/index.js +0 -24
  92. package/dist/hooks/index.js.map +0 -1
  93. package/dist/hooks/useActorInfiniteQuery.d.ts +0 -67
  94. package/dist/hooks/useActorInfiniteQuery.d.ts.map +0 -1
  95. package/dist/hooks/useActorInfiniteQuery.js +0 -89
  96. package/dist/hooks/useActorInfiniteQuery.js.map +0 -1
  97. package/dist/hooks/useActorMethod.d.ts +0 -148
  98. package/dist/hooks/useActorMethod.d.ts.map +0 -1
  99. package/dist/hooks/useActorMethod.js +0 -394
  100. package/dist/hooks/useActorMethod.js.map +0 -1
  101. package/dist/hooks/useActorMutation.d.ts +0 -51
  102. package/dist/hooks/useActorMutation.d.ts.map +0 -1
  103. package/dist/hooks/useActorMutation.js +0 -70
  104. package/dist/hooks/useActorMutation.js.map +0 -1
  105. package/dist/hooks/useActorQuery.d.ts +0 -45
  106. package/dist/hooks/useActorQuery.d.ts.map +0 -1
  107. package/dist/hooks/useActorQuery.js +0 -67
  108. package/dist/hooks/useActorQuery.js.map +0 -1
  109. package/dist/hooks/useActorSuspenseInfiniteQuery.d.ts +0 -51
  110. package/dist/hooks/useActorSuspenseInfiniteQuery.d.ts.map +0 -1
  111. package/dist/hooks/useActorSuspenseInfiniteQuery.js +0 -76
  112. package/dist/hooks/useActorSuspenseInfiniteQuery.js.map +0 -1
  113. package/dist/hooks/useActorSuspenseQuery.d.ts +0 -32
  114. package/dist/hooks/useActorSuspenseQuery.d.ts.map +0 -1
  115. package/dist/hooks/useActorSuspenseQuery.js +0 -58
  116. package/dist/hooks/useActorSuspenseQuery.js.map +0 -1
  117. package/dist/ownedAuthentication.d.ts +0 -52
  118. package/dist/ownedAuthentication.d.ts.map +0 -1
  119. package/dist/ownedAuthentication.js +0 -49
  120. package/dist/ownedAuthentication.js.map +0 -1
  121. package/dist/server.d.ts +0 -21
  122. package/dist/server.d.ts.map +0 -1
  123. package/dist/server.js +0 -23
  124. package/dist/server.js.map +0 -1
  125. package/dist/testing.d.ts +0 -19
  126. package/dist/testing.d.ts.map +0 -1
  127. package/dist/testing.js +0 -19
  128. package/dist/testing.js.map +0 -1
  129. package/dist/types.d.ts +0 -671
  130. package/dist/types.d.ts.map +0 -1
  131. package/dist/types.js +0 -5
  132. package/dist/types.js.map +0 -1
  133. package/dist/utils.d.ts +0 -207
  134. package/dist/utils.d.ts.map +0 -1
  135. package/dist/utils.js +0 -405
  136. package/dist/utils.js.map +0 -1
  137. package/dist/validation.d.ts +0 -136
  138. package/dist/validation.d.ts.map +0 -1
  139. package/dist/validation.js +0 -144
  140. package/dist/validation.js.map +0 -1
  141. package/src/auth/auth-client-compat.ts +0 -273
  142. package/src/auth/authentication-manager.ts +0 -1682
  143. package/src/auth/constants.ts +0 -32
  144. package/src/auth/createIdentityAttributeHooks.ts +0 -169
  145. package/src/auth/identity-attributes-manager.ts +0 -226
  146. package/src/auth/identity-attributes.ts +0 -345
  147. package/src/auth/index.ts +0 -7
  148. package/src/auth/local-ii-probe.ts +0 -173
  149. package/src/auth/types.ts +0 -243
  150. package/src/createActorHooks.ts +0 -208
  151. package/src/createInfiniteQuery.ts +0 -670
  152. package/src/createMutation.ts +0 -324
  153. package/src/createQuery.ts +0 -369
  154. package/src/createReactorProvider.ts +0 -365
  155. package/src/createSuspenseInfiniteQuery.ts +0 -651
  156. package/src/createSuspenseQuery.ts +0 -304
  157. package/src/defineDisplayReactor.ts +0 -62
  158. package/src/defineReactor.ts +0 -142
  159. package/src/defineReactorShared.ts +0 -268
  160. package/src/hooks/createAuthHooks.ts +0 -371
  161. package/src/hooks/index.ts +0 -103
  162. package/src/hooks/useActorInfiniteQuery.ts +0 -278
  163. package/src/hooks/useActorMethod.ts +0 -710
  164. package/src/hooks/useActorMutation.ts +0 -205
  165. package/src/hooks/useActorQuery.ts +0 -157
  166. package/src/hooks/useActorSuspenseInfiniteQuery.ts +0 -248
  167. package/src/hooks/useActorSuspenseQuery.ts +0 -147
  168. package/src/index.ts +0 -31
  169. package/src/ownedAuthentication.ts +0 -81
  170. package/src/server.ts +0 -23
  171. package/src/testing.ts +0 -18
  172. package/src/types.ts +0 -948
  173. package/src/utils.ts +0 -505
  174. package/src/validation.ts +0 -226
@@ -1,122 +0,0 @@
1
- /**
2
- * Bridges IC Reactor's stable authentication options onto whichever
3
- * `@icp-sdk/auth` major is installed.
4
- *
5
- * `@icp-sdk/auth` v9 reshaped the `AuthClient` constructor and v10 moved its
6
- * `@icp-sdk/core` peer to `^6`. The *method* surface IC Reactor calls --
7
- * `signIn`, `signOut`, `getIdentity`, `isAuthenticated`, `requestAttributes`,
8
- * `memoize` -- is byte-identical across v8 and v10, so only the option objects
9
- * handed to the constructor and to `signIn` have to be translated.
10
- *
11
- * The translation lives here rather than in `AuthenticationManager` so that
12
- * {@link AuthenticationClientOptions} stays IC Reactor's own contract. Callers
13
- * keep writing `identityProvider: "https://id.ai/authorize"` whichever peer
14
- * they installed, and the shapes diverge only at the boundary.
15
- *
16
- * Why both majors: v8 peers `@icp-sdk/core@^5` while IC Reactor needs `^6`, so
17
- * a strict `npm install` resolving v8 fails with `ERESOLVE` unless the app adds
18
- * an `overrides` block. v10 is the first release whose peer is `^6`, which
19
- * removes that workaround -- but pinning v10 alone would break every app
20
- * already installed on v8.
21
- */
22
- import type { AuthClientSignInOptions, AuthenticationClientOptions } from "./types.js";
23
- /**
24
- * Which options contract the installed `AuthClient` accepts.
25
- *
26
- * - `legacy` -- v8. `identityProvider` is a URL; `storage`, `keyType`,
27
- * `idleOptions` and `identity` are constructor options; `signIn` takes
28
- * `targets`.
29
- * - `session` -- v9/v10. `identityProvider` is an `{ authorizeUrl, canisterId }`
30
- * pair, credentials moved behind `credentialStorage`, idle moved to the
31
- * identity provider canister, and `signIn` no longer takes `targets`.
32
- */
33
- export type AuthClientFlavor = "legacy" | "session";
34
- /** The `{ authorizeUrl, canisterId }` pair a v9+ client names a deployment by. */
35
- export interface SessionIdentityProvider {
36
- authorizeUrl: string | URL;
37
- canisterId: string;
38
- }
39
- /**
40
- * Which canister a v9+ client should pair with the configured
41
- * `identityProvider` URL, as `AuthenticationManager` works it out.
42
- *
43
- * - `mainnet`: the URL is mainnet's and nothing overrides the canister, so the
44
- * option is omitted and the client uses mainnet for both halves.
45
- * - `pair`: the canister is known, from `internetIdentityId` or because the URL
46
- * is one IC Reactor derived for a local deployment.
47
- * - `unknown`: a URL the caller configured with no canister to go with it.
48
- */
49
- export type IdentityProviderPairing = {
50
- kind: "mainnet";
51
- } | {
52
- kind: "pair";
53
- canisterId: string;
54
- } | {
55
- kind: "unknown";
56
- };
57
- /**
58
- * Detects the contract from the constructor itself rather than from the
59
- * module's exports.
60
- *
61
- * `getStatus`, `getPrincipal`, `subscribe` and `dispose` were added to
62
- * `AuthClient` in v9 and have no v8 counterpart. Reading them off the prototype
63
- * beats sniffing the module namespace: a bundler may drop an unreferenced named
64
- * export (`IdbStorage`, `IdleManager`) from the namespace object it synthesizes
65
- * for a dynamic import, but it never drops a class's own methods.
66
- *
67
- * Two markers rather than one, because a single name is a coincidence away from
68
- * matching some future shim. An unrecognised constructor is treated as `legacy`
69
- * -- the shape IC Reactor's own options already mirror, so a wrong guess there
70
- * passes the values through untouched instead of rewriting them into a shape
71
- * nothing understands.
72
- */
73
- export declare function detectAuthClientFlavor(AuthClient: unknown): AuthClientFlavor;
74
- /**
75
- * Detects the contract of a client the caller built and passed in.
76
- *
77
- * Such a client never goes through the module loader, so there is no
78
- * constructor to hand {@link detectAuthClientFlavor}. The markers are the same
79
- * two methods, reached through the instance instead of the prototype.
80
- */
81
- export declare function detectAuthClientInstanceFlavor(client: unknown): AuthClientFlavor;
82
- /** @internal Test seam -- lets a suite assert the first warning every time. */
83
- export declare function resetAuthCompatWarnings(): void;
84
- /**
85
- * Translates IC Reactor's constructor options into the installed client's shape.
86
- *
87
- * On `legacy` the object is already the right shape and is returned as-is,
88
- * except for `disableBrowserActivity`. That option exists only on v10, so it is
89
- * dropped with a one-time warning rather than handed to a v8 client that
90
- * ignores it.
91
- *
92
- * On `session` the identity provider becomes a pair. The canister is not
93
- * derived from the URL, because v9+ is explicit that the origin serving a
94
- * ceremony is not a promise about which canister mints there. `pairing` says
95
- * which canister goes with the URL. When nothing does, this throws rather than
96
- * guessing: a guessed canister sends the delegation calls to a different
97
- * deployment than the one the user signs in at, and sign-in fails later with an
98
- * error that names neither.
99
- *
100
- * @param options - IC Reactor's resolved options, in the v8-shaped contract.
101
- * @param flavor - The contract the installed client accepts.
102
- * @param pairing - Which canister goes with `options.identityProvider`.
103
- * @param agentOptions - Options for the agent a v9+ client mints delegations
104
- * with. v8 has no such agent, so a `legacy` client never receives them.
105
- */
106
- export declare function toAuthClientConstructorOptions(options: AuthenticationClientOptions | undefined, flavor: AuthClientFlavor, pairing?: IdentityProviderPairing, agentOptions?: Record<string, unknown>): AuthenticationClientOptions | Record<string, unknown> | undefined;
107
- /**
108
- * Translates `signIn` options into the installed client's shape.
109
- *
110
- * `targets` is the one that matters. v8 forwards it to restrict the delegation
111
- * to named canisters; v9+ removed it, and scoping is decided by the identity
112
- * provider against the app's own canister. Passing it to a v9+ client does not
113
- * fail -- it is simply ignored, and the delegation that comes back is broader
114
- * than the caller asked for. That is a security-relevant difference, so it
115
- * warns unconditionally rather than only in development.
116
- *
117
- * `maxTimeToIdle` goes the other way. It exists only on v10, so a v10 client
118
- * receives it, and a v8 client, whose sign-in has no idle limit, gets it
119
- * dropped with a one-time warning.
120
- */
121
- export declare function toAuthClientSignInOptions(options: AuthClientSignInOptions | undefined, flavor: AuthClientFlavor): AuthClientSignInOptions | undefined;
122
- //# sourceMappingURL=auth-client-compat.d.ts.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth-client-compat.d.ts","sourceRoot":"","sources":["../../src/auth/auth-client-compat.ts"],"names":[],"mappings":"AAAA;;;;;;;;;;;;;;;;;;;;GAoBG;AACH,OAAO,KAAK,EACV,uBAAuB,EACvB,2BAA2B,EAC5B,MAAM,YAAY,CAAA;AAEnB;;;;;;;;;GASG;AACH,MAAM,MAAM,gBAAgB,GAAG,QAAQ,GAAG,SAAS,CAAA;AAEnD,kFAAkF;AAClF,MAAM,WAAW,uBAAuB;IACtC,YAAY,EAAE,MAAM,GAAG,GAAG,CAAA;IAC1B,UAAU,EAAE,MAAM,CAAA;CACnB;AAED;;;;;;;;;GASG;AACH,MAAM,MAAM,uBAAuB,GAC/B;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,GACnB;IAAE,IAAI,EAAE,MAAM,CAAC;IAAC,UAAU,EAAE,MAAM,CAAA;CAAE,GACpC;IAAE,IAAI,EAAE,SAAS,CAAA;CAAE,CAAA;AAEvB;;;;;;;;;;;;;;;GAeG;AACH,wBAAgB,sBAAsB,CAAC,UAAU,EAAE,OAAO,GAAG,gBAAgB,CAY5E;AAED;;;;;;GAMG;AACH,wBAAgB,8BAA8B,CAC5C,MAAM,EAAE,OAAO,GACd,gBAAgB,CAOlB;AA4BD,+EAA+E;AAC/E,wBAAgB,uBAAuB,SAEtC;AAED;;;;;;;;;;;;;;;;;;;;;GAqBG;AACH,wBAAgB,8BAA8B,CAC5C,OAAO,EAAE,2BAA2B,GAAG,SAAS,EAChD,MAAM,EAAE,gBAAgB,EACxB,OAAO,GAAE,uBAA6C,EACtD,YAAY,CAAC,EAAE,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GACrC,2BAA2B,GAAG,MAAM,CAAC,MAAM,EAAE,OAAO,CAAC,GAAG,SAAS,CA2DnE;AAED;;;;;;;;;;;;;GAaG;AACH,wBAAgB,yBAAyB,CACvC,OAAO,EAAE,uBAAuB,GAAG,SAAS,EAC5C,MAAM,EAAE,gBAAgB,GACvB,uBAAuB,GAAG,SAAS,CA6BrC"}
@@ -1,162 +0,0 @@
1
- /**
2
- * Detects the contract from the constructor itself rather than from the
3
- * module's exports.
4
- *
5
- * `getStatus`, `getPrincipal`, `subscribe` and `dispose` were added to
6
- * `AuthClient` in v9 and have no v8 counterpart. Reading them off the prototype
7
- * beats sniffing the module namespace: a bundler may drop an unreferenced named
8
- * export (`IdbStorage`, `IdleManager`) from the namespace object it synthesizes
9
- * for a dynamic import, but it never drops a class's own methods.
10
- *
11
- * Two markers rather than one, because a single name is a coincidence away from
12
- * matching some future shim. An unrecognised constructor is treated as `legacy`
13
- * -- the shape IC Reactor's own options already mirror, so a wrong guess there
14
- * passes the values through untouched instead of rewriting them into a shape
15
- * nothing understands.
16
- */
17
- export function detectAuthClientFlavor(AuthClient) {
18
- const prototype = AuthClient
19
- ?.prototype;
20
- if (!prototype) {
21
- return "legacy";
22
- }
23
- return typeof prototype.getStatus === "function" &&
24
- typeof prototype.getPrincipal === "function"
25
- ? "session"
26
- : "legacy";
27
- }
28
- /**
29
- * Detects the contract of a client the caller built and passed in.
30
- *
31
- * Such a client never goes through the module loader, so there is no
32
- * constructor to hand {@link detectAuthClientFlavor}. The markers are the same
33
- * two methods, reached through the instance instead of the prototype.
34
- */
35
- export function detectAuthClientInstanceFlavor(client) {
36
- const instance = client;
37
- return typeof instance?.getStatus === "function" &&
38
- typeof instance?.getPrincipal === "function"
39
- ? "session"
40
- : "legacy";
41
- }
42
- /**
43
- * Options a `session`-era client drops on the floor, and what replaced them.
44
- *
45
- * Each is a real capability in v8 with no v9+ constructor equivalent, so the
46
- * only honest thing to do is say so rather than pass a key that is ignored.
47
- */
48
- const DROPPED_CONSTRUCTOR_OPTIONS = {
49
- storage: "`storage` (an AuthClientStorage) has no v9+ equivalent: credentials moved behind `credentialStorage`, whose store also generates identities and holds a delegation alongside each key, so an AuthClientStorage cannot be adapted into one. Construct the client yourself and pass it as `authClient` to keep a custom store.",
50
- keyType: "`keyType` was removed in v9+: the credential store decides the key type, because a store that has to serialise needs an extractable key and one that does not should not hold one.",
51
- idleOptions: "`idleOptions` was removed in v9+: the idle timeout belongs to the identity provider canister. Pass `maxTimeToIdle` to `login()` instead, and set `disableBrowserActivity` in the AuthenticationManager options to stop the client watching the browser.",
52
- identity: "`identity` was removed from v9+ constructor options: the agent signs as the session rather than as an identity handed in at construction.",
53
- };
54
- /** Emits each distinct warning once per process, so a render loop cannot spam. */
55
- const warned = new Set();
56
- function warnOnce(key, message) {
57
- if (warned.has(key))
58
- return;
59
- warned.add(key);
60
- console.warn(`[ic-reactor] ${message}`);
61
- }
62
- /** @internal Test seam -- lets a suite assert the first warning every time. */
63
- export function resetAuthCompatWarnings() {
64
- warned.clear();
65
- }
66
- /**
67
- * Translates IC Reactor's constructor options into the installed client's shape.
68
- *
69
- * On `legacy` the object is already the right shape and is returned as-is,
70
- * except for `disableBrowserActivity`. That option exists only on v10, so it is
71
- * dropped with a one-time warning rather than handed to a v8 client that
72
- * ignores it.
73
- *
74
- * On `session` the identity provider becomes a pair. The canister is not
75
- * derived from the URL, because v9+ is explicit that the origin serving a
76
- * ceremony is not a promise about which canister mints there. `pairing` says
77
- * which canister goes with the URL. When nothing does, this throws rather than
78
- * guessing: a guessed canister sends the delegation calls to a different
79
- * deployment than the one the user signs in at, and sign-in fails later with an
80
- * error that names neither.
81
- *
82
- * @param options - IC Reactor's resolved options, in the v8-shaped contract.
83
- * @param flavor - The contract the installed client accepts.
84
- * @param pairing - Which canister goes with `options.identityProvider`.
85
- * @param agentOptions - Options for the agent a v9+ client mints delegations
86
- * with. v8 has no such agent, so a `legacy` client never receives them.
87
- */
88
- export function toAuthClientConstructorOptions(options, flavor, pairing = { kind: "unknown" }, agentOptions) {
89
- if (!options) {
90
- return options;
91
- }
92
- if (flavor === "legacy") {
93
- if (options.disableBrowserActivity === undefined) {
94
- return options;
95
- }
96
- warnOnce("constructor:disableBrowserActivity", "`disableBrowserActivity` needs @icp-sdk/auth v10 and is ignored by v8, which has no equivalent. On v8, `idleOptions` controls idle handling.");
97
- const { disableBrowserActivity: _disableBrowserActivity, ...legacy } = options;
98
- return legacy;
99
- }
100
- // Prefixed with `_` because they are destructured only to keep them out of
101
- // `carried`: a v9+ constructor has no equivalent for any of them, and the
102
- // loop below is what actually reports each one that was set.
103
- const { identityProvider, storage: _storage, keyType: _keyType, idleOptions: _idleOptions, identity: _identity, ...carried } = options;
104
- for (const [name, explanation] of Object.entries(DROPPED_CONSTRUCTOR_OPTIONS)) {
105
- if (options[name] !== undefined) {
106
- warnOnce(`constructor:${name}`, explanation);
107
- }
108
- }
109
- const translated = { ...carried };
110
- if (agentOptions !== undefined) {
111
- translated.agentOptions = agentOptions;
112
- }
113
- if (identityProvider !== undefined) {
114
- if (pairing.kind === "unknown") {
115
- throw new Error(`[ic-reactor] identityProvider ${String(identityProvider)} needs internetIdentityId with @icp-sdk/auth v10, which names a provider by its authorize URL and the canister that mints its delegations. Set internetIdentityId to the canister that serves that URL.`);
116
- }
117
- // An absent option is how v9+ says "both values are mainnet's".
118
- if (pairing.kind === "pair") {
119
- translated.identityProvider = {
120
- authorizeUrl: identityProvider,
121
- canisterId: pairing.canisterId,
122
- };
123
- }
124
- }
125
- return translated;
126
- }
127
- /**
128
- * Translates `signIn` options into the installed client's shape.
129
- *
130
- * `targets` is the one that matters. v8 forwards it to restrict the delegation
131
- * to named canisters; v9+ removed it, and scoping is decided by the identity
132
- * provider against the app's own canister. Passing it to a v9+ client does not
133
- * fail -- it is simply ignored, and the delegation that comes back is broader
134
- * than the caller asked for. That is a security-relevant difference, so it
135
- * warns unconditionally rather than only in development.
136
- *
137
- * `maxTimeToIdle` goes the other way. It exists only on v10, so a v10 client
138
- * receives it, and a v8 client, whose sign-in has no idle limit, gets it
139
- * dropped with a one-time warning.
140
- */
141
- export function toAuthClientSignInOptions(options, flavor) {
142
- if (!options) {
143
- return options;
144
- }
145
- if (flavor === "legacy") {
146
- if (options.maxTimeToIdle === undefined) {
147
- return options;
148
- }
149
- warnOnce("signIn:maxTimeToIdle", "`maxTimeToIdle` needs @icp-sdk/auth v10 and is ignored by v8, whose sign-in has no idle limit. On v8, set `idleOptions` instead.");
150
- const { maxTimeToIdle: _maxTimeToIdle, ...legacy } = options;
151
- return legacy;
152
- }
153
- const { targets, ...carried } = options;
154
- if (targets !== undefined) {
155
- // Every time, not once: each sign-in that passes `targets` receives a
156
- // delegation broader than it asked for, and a warning spent on an earlier
157
- // one says nothing about this one.
158
- console.warn("[ic-reactor] `targets` was removed in @icp-sdk/auth v9+ and is ignored: the delegation you receive is NOT restricted to those canisters. The identity provider scopes a session to the application canister instead. Remove `targets`, or pin @icp-sdk/auth to ^8 if you depend on canister-scoped delegations.");
159
- }
160
- return carried;
161
- }
162
- //# sourceMappingURL=auth-client-compat.js.map
@@ -1 +0,0 @@
1
- {"version":3,"file":"auth-client-compat.js","sourceRoot":"","sources":["../../src/auth/auth-client-compat.ts"],"names":[],"mappings":"AA2DA;;;;;;;;;;;;;;;GAeG;AACH,MAAM,UAAU,sBAAsB,CAAC,UAAmB;IACxD,MAAM,SAAS,GAAI,UAAsD;QACvE,EAAE,SAAS,CAAA;IAEb,IAAI,CAAC,SAAS,EAAE,CAAC;QACf,OAAO,QAAQ,CAAA;IACjB,CAAC;IAED,OAAO,OAAO,SAAS,CAAC,SAAS,KAAK,UAAU;QAC9C,OAAO,SAAS,CAAC,YAAY,KAAK,UAAU;QAC5C,CAAC,CAAC,SAAS;QACX,CAAC,CAAC,QAAQ,CAAA;AACd,CAAC;AAED;;;;;;GAMG;AACH,MAAM,UAAU,8BAA8B,CAC5C,MAAe;IAEf,MAAM,QAAQ,GAAG,MAA6C,C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