@axa-fr/oidc-client-service-worker 7.29.7 → 7.30.0

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 (107) hide show
  1. package/README.md +64 -0
  2. package/dist/OidcServiceWorker.d.ts +2 -1
  3. package/dist/OidcServiceWorker.d.ts.map +1 -0
  4. package/dist/OidcServiceWorker.js +995 -765
  5. package/dist/OidcServiceWorker.js.map +1 -1
  6. package/dist/constants.d.ts.map +1 -0
  7. package/dist/crypto.d.ts.map +1 -0
  8. package/dist/dpop.d.ts.map +1 -0
  9. package/dist/jwt.d.ts.map +1 -0
  10. package/dist/oidcConfig.d.ts.map +1 -0
  11. package/dist/protocol.d.ts +140 -2
  12. package/dist/protocol.d.ts.map +1 -0
  13. package/dist/protocol.js +50 -2
  14. package/dist/protocol.js.map +1 -1
  15. package/dist/resource.d.ts +22 -0
  16. package/dist/resource.d.ts.map +1 -0
  17. package/dist/tokenContexts.d.ts +5 -0
  18. package/dist/tokenContexts.d.ts.map +1 -0
  19. package/dist/{src/types.d.ts → types.d.ts} +26 -1
  20. package/dist/types.d.ts.map +1 -0
  21. package/dist/utils/codeVerifier.d.ts.map +1 -0
  22. package/dist/{src/utils → utils}/domains.d.ts +2 -2
  23. package/dist/utils/domains.d.ts.map +1 -0
  24. package/dist/utils/index.d.ts.map +1 -0
  25. package/dist/utils/normalizeUrl.d.ts.map +1 -0
  26. package/dist/utils/serializeHeaders.d.ts.map +1 -0
  27. package/dist/utils/shouldBypassDestination.d.ts.map +1 -0
  28. package/dist/utils/sleep.d.ts.map +1 -0
  29. package/dist/utils/strings.d.ts.map +1 -0
  30. package/dist/{src/utils → utils}/tokens.d.ts +12 -3
  31. package/dist/utils/tokens.d.ts.map +1 -0
  32. package/dist/utils/waitForValidTokens.d.ts.map +1 -0
  33. package/dist/version.d.ts +3 -0
  34. package/dist/version.d.ts.map +1 -0
  35. package/package.json +3 -2
  36. package/src/OidcServiceWorker.ts +290 -34
  37. package/src/__tests__/jwt.spec.ts +17 -0
  38. package/src/__tests__/resource.spec.ts +98 -0
  39. package/src/__tests__/workerResource.spec.ts +919 -0
  40. package/src/jwt.ts +4 -1
  41. package/src/oidcConfig.ts +2 -1
  42. package/src/protocol.ts +16 -1
  43. package/src/resource.ts +104 -0
  44. package/src/tokenContexts.ts +39 -0
  45. package/src/types.ts +27 -1
  46. package/src/utils/domains.ts +20 -2
  47. package/src/utils/tokens.ts +155 -8
  48. package/src/version.ts +1 -1
  49. package/dist/src/OidcServiceWorker.d.ts +0 -2
  50. package/dist/src/OidcServiceWorker.d.ts.map +0 -1
  51. package/dist/src/__tests__/jwt.spec.d.ts +0 -2
  52. package/dist/src/__tests__/jwt.spec.d.ts.map +0 -1
  53. package/dist/src/__tests__/oidcConfig.spec.d.ts +0 -2
  54. package/dist/src/__tests__/oidcConfig.spec.d.ts.map +0 -1
  55. package/dist/src/__tests__/protocol.spec.d.ts +0 -2
  56. package/dist/src/__tests__/protocol.spec.d.ts.map +0 -1
  57. package/dist/src/constants.d.ts.map +0 -1
  58. package/dist/src/crypto.d.ts.map +0 -1
  59. package/dist/src/dpop.d.ts.map +0 -1
  60. package/dist/src/jwt.d.ts.map +0 -1
  61. package/dist/src/oidcConfig.d.ts.map +0 -1
  62. package/dist/src/protocol.d.ts +0 -134
  63. package/dist/src/protocol.d.ts.map +0 -1
  64. package/dist/src/types.d.ts.map +0 -1
  65. package/dist/src/utils/__tests__/codeVerifier.spec.d.ts +0 -2
  66. package/dist/src/utils/__tests__/codeVerifier.spec.d.ts.map +0 -1
  67. package/dist/src/utils/__tests__/domains.spec.d.ts +0 -2
  68. package/dist/src/utils/__tests__/domains.spec.d.ts.map +0 -1
  69. package/dist/src/utils/__tests__/normalizeUrl.spec.d.ts +0 -2
  70. package/dist/src/utils/__tests__/normalizeUrl.spec.d.ts.map +0 -1
  71. package/dist/src/utils/__tests__/serializeHeaders.spec.d.ts +0 -2
  72. package/dist/src/utils/__tests__/serializeHeaders.spec.d.ts.map +0 -1
  73. package/dist/src/utils/__tests__/shouldBypassDestination.spec.d.ts +0 -2
  74. package/dist/src/utils/__tests__/shouldBypassDestination.spec.d.ts.map +0 -1
  75. package/dist/src/utils/__tests__/strings.spec.d.ts +0 -2
  76. package/dist/src/utils/__tests__/strings.spec.d.ts.map +0 -1
  77. package/dist/src/utils/__tests__/testHelper.d.ts +0 -58
  78. package/dist/src/utils/__tests__/testHelper.d.ts.map +0 -1
  79. package/dist/src/utils/__tests__/tokens.spec.d.ts +0 -2
  80. package/dist/src/utils/__tests__/tokens.spec.d.ts.map +0 -1
  81. package/dist/src/utils/__tests__/waitForValidTokens.spec.d.ts +0 -2
  82. package/dist/src/utils/__tests__/waitForValidTokens.spec.d.ts.map +0 -1
  83. package/dist/src/utils/codeVerifier.d.ts.map +0 -1
  84. package/dist/src/utils/domains.d.ts.map +0 -1
  85. package/dist/src/utils/index.d.ts.map +0 -1
  86. package/dist/src/utils/normalizeUrl.d.ts.map +0 -1
  87. package/dist/src/utils/serializeHeaders.d.ts.map +0 -1
  88. package/dist/src/utils/shouldBypassDestination.d.ts.map +0 -1
  89. package/dist/src/utils/sleep.d.ts.map +0 -1
  90. package/dist/src/utils/strings.d.ts.map +0 -1
  91. package/dist/src/utils/tokens.d.ts.map +0 -1
  92. package/dist/src/utils/waitForValidTokens.d.ts.map +0 -1
  93. package/dist/src/version.d.ts +0 -3
  94. package/dist/src/version.d.ts.map +0 -1
  95. /package/dist/{src/constants.d.ts → constants.d.ts} +0 -0
  96. /package/dist/{src/crypto.d.ts → crypto.d.ts} +0 -0
  97. /package/dist/{src/dpop.d.ts → dpop.d.ts} +0 -0
  98. /package/dist/{src/jwt.d.ts → jwt.d.ts} +0 -0
  99. /package/dist/{src/oidcConfig.d.ts → oidcConfig.d.ts} +0 -0
  100. /package/dist/{src/utils → utils}/codeVerifier.d.ts +0 -0
  101. /package/dist/{src/utils → utils}/index.d.ts +0 -0
  102. /package/dist/{src/utils → utils}/normalizeUrl.d.ts +0 -0
  103. /package/dist/{src/utils → utils}/serializeHeaders.d.ts +0 -0
  104. /package/dist/{src/utils → utils}/shouldBypassDestination.d.ts +0 -0
  105. /package/dist/{src/utils → utils}/sleep.d.ts +0 -0
  106. /package/dist/{src/utils → utils}/strings.d.ts +0 -0
  107. /package/dist/{src/utils → utils}/waitForValidTokens.d.ts +0 -0
package/README.md CHANGED
@@ -11,6 +11,7 @@ package directly. The clients handle worker registration and communication.
11
11
  - [How it works](#how-it-works)
12
12
  - [Getting started](#getting-started)
13
13
  - [Trusted domains](#trusted-domains)
14
+ - [Resource-specific token isolation](#resource-specific-token-isolation)
14
15
  - [Deployment and troubleshooting](#deployment-and-troubleshooting)
15
16
  - [Protocol reference](#protocol-reference)
16
17
 
@@ -84,6 +85,69 @@ application JavaScript while keeping the refresh token in the worker.
84
85
  Merge this with existing installation steps rather than replacing them.
85
86
  Deploy the copied worker with every client upgrade.
86
87
 
88
+ ## Resource-specific token isolation
89
+
90
+ Use the [local OpenIddict demos](../../examples/openiddict-server/README.md) to test
91
+ two isolated audiences and DPoP nonce challenges end to end. Their local trust
92
+ rules activate only for a localhost worker explicitly selected with
93
+ `provider=openiddict`; the online trust rules do not gain localhost access.
94
+ Generated DPoP targets exclude query strings and fragments.
95
+
96
+ The clients' [RFC 8707 resource API](../oidc-client/README.md#resource-indicators-and-multiple-apis)
97
+ uses nested resource entries in the existing named/tab session, not separate
98
+ OIDC clients. Access tokens, authorization state, PKCE, grant references, and
99
+ DPoP state remain associated with the selected resource. Default and sibling
100
+ access tokens are not replaced by acquisition or renewal.
101
+ Additional authorization requires a fresh ID token for the same authenticated
102
+ subject and transaction nonce. A resource refresh may omit an ID token even
103
+ after its earlier ID token expires.
104
+
105
+ Configure `resources` in the client and allow both API origins in the worker:
106
+
107
+ ```javascript
108
+ const trustedDomains = {
109
+ default: {
110
+ oidcDomains: [/^https:\/\/issuer\.example\.com(?:\/|$)/],
111
+ accessTokenDomains: [
112
+ /^https:\/\/orders\.example\.com(?:\/|$)/,
113
+ /^https:\/\/inventory\.example\.com(?:\/|$)/,
114
+ ],
115
+ },
116
+ };
117
+ ```
118
+
119
+ Use `fetchForResource()` or `useOidcFetchForResource()`, not automatic selection
120
+ by URL. A selected placeholder must match its exact resource context and both
121
+ the client URL mapping and worker trusted-domain rules. Managed API requests
122
+ without resource selection do not receive an arbitrary/default worker token,
123
+ including paths outside the permitted prefixes on registered API origins.
124
+ The standard provider user-info flow retains its default token handling.
125
+ Default renewal also retains its own token entry for single-resource grants.
126
+ The client sends a worker-only routing hint for explicit resource refreshes;
127
+ the worker verifies it against the OAuth resource and removes it before dispatch.
128
+ Resource tokens are always masked, including with `showAccessToken: true`.
129
+ Automatic API redirects are rejected.
130
+
131
+ Shared refresh rotation is retained centrally; independently authorized
132
+ resources keep their own grants. Clearing a resource resets only its entry;
133
+ clearing the base session removes all nested entries. Late responses cannot
134
+ recreate cleared state. Logout can revoke resource tokens through the exact
135
+ trusted revocation endpoint.
136
+
137
+ DPoP remains configured through this file's existing options. Resource API
138
+ proofs use the selected real token and its bound key/nonce; the browser receives
139
+ neither refresh tokens nor private keys from the resource API.
140
+ API nonces are retained per resource separately from authorization-server
141
+ nonces. API responses are not automatically retried.
142
+
143
+ Resource support requires the `resourceTokenManagement` capability returned by
144
+ protocol 1.1 workers. Copy and deploy the matching `OidcServiceWorker.js` with
145
+ each client upgrade. Older/unavailable workers cause explicit resource errors,
146
+ not browser-token fallback. Worker token memory is not durable: after loss,
147
+ restore or reauthenticate the original session before requesting resource
148
+ tokens. Resource entries cannot be reconstructed from stale placeholders.
149
+ See the core guide for provider/opaque-token limitations.
150
+
87
151
  ## Trusted domains
88
152
 
89
153
  Keep provider endpoints and API destinations separate:
@@ -1 +1,2 @@
1
- export {}
1
+ export {};
2
+ //# sourceMappingURL=OidcServiceWorker.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"OidcServiceWorker.d.ts","sourceRoot":"","sources":["../src/OidcServiceWorker.ts"],"names":[],"mappings":""}