@webex/plugin-authorization-browser-first-party 3.12.0-webex-services-ready.4 → 3.13.0-next.1

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.
@@ -0,0 +1,395 @@
1
+ {
2
+ "manifest_version": 1,
3
+ "repository": {
4
+ "name": "@webex/plugin-authorization-browser-first-party",
5
+ "purpose": "First-party (Webex web client) browser authorization plugin registered as webex.authorization. It starts OAuth authorization-code logins with CSRF state and PKCE (S256), completes them automatically on the redirect page load (CSRF check, URL scrubbing, best-effort preauth catalog, code exchange), supplies the browser token-refresh callback with public or confidential client authentication, handles the third-party login callback, runs device (QR code) login through the oauth-helper service with qRCodeLogin events, and redirects on logout.",
6
+ "category": "cat2-legacy",
7
+ "primary_languages": [
8
+ "javascript"
9
+ ]
10
+ },
11
+ "topology": "Orchestrator-plus-components",
12
+ "commands": {
13
+ "install": {
14
+ "command": "yarn",
15
+ "source_file": "../../../.github/workflows/deploy.yml",
16
+ "role": "install"
17
+ },
18
+ "compile": {
19
+ "command": "yarn workspace @webex/plugin-authorization-browser-first-party build:src",
20
+ "source_file": "package.json",
21
+ "role": "compile"
22
+ },
23
+ "build": {
24
+ "command": "yarn workspace @webex/plugin-authorization-browser-first-party build",
25
+ "source_file": "package.json",
26
+ "role": "package"
27
+ },
28
+ "unit-test": {
29
+ "command": "yarn workspace @webex/plugin-authorization-browser-first-party test:unit",
30
+ "source_file": "package.json",
31
+ "role": "unit-test"
32
+ },
33
+ "browser-test": {
34
+ "command": "yarn workspace @webex/plugin-authorization-browser-first-party test:browser",
35
+ "source_file": "package.json",
36
+ "role": "other"
37
+ },
38
+ "lint": {
39
+ "command": "yarn workspace @webex/plugin-authorization-browser-first-party test:style",
40
+ "source_file": "package.json",
41
+ "role": "lint"
42
+ },
43
+ "deploy": {
44
+ "command": "yarn workspace @webex/plugin-authorization-browser-first-party deploy:npm",
45
+ "source_file": "package.json",
46
+ "role": "deploy"
47
+ }
48
+ },
49
+ "toolchain": [
50
+ {
51
+ "name": "node",
52
+ "version": ">=8",
53
+ "origin": "repo-config",
54
+ "source_file": "package.json"
55
+ },
56
+ {
57
+ "name": "babel",
58
+ "version": "^7.17.10",
59
+ "origin": "repo-config",
60
+ "source_file": "package.json"
61
+ },
62
+ {
63
+ "name": "eslint",
64
+ "version": "^8.24.0",
65
+ "origin": "repo-config",
66
+ "source_file": "package.json"
67
+ },
68
+ {
69
+ "name": "prettier",
70
+ "version": "^2.7.1",
71
+ "origin": "repo-config",
72
+ "source_file": "package.json"
73
+ },
74
+ {
75
+ "name": "sinon",
76
+ "version": "^9.2.4",
77
+ "origin": "repo-config",
78
+ "source_file": "package.json"
79
+ }
80
+ ],
81
+ "tests": {
82
+ "unit": {
83
+ "command_ref": "unit-test",
84
+ "dir": "test/unit/spec",
85
+ "framework": "jest"
86
+ }
87
+ },
88
+ "quality_gates": {
89
+ "code_coverage": {
90
+ "origin": "none",
91
+ "declared_by": "rarajes2@cisco.com via bootstrap questionnaire (generator check: test:unit runs webex-legacy-tools with --runner jest; jest.config.js re-exports @webex/jest-config-legacy, which sets collectCoverage false and no coverageThreshold; package.json defines no coverage script)"
92
+ }
93
+ },
94
+ "coverage_status_definitions": {
95
+ "specced": ">=80% public surface specced, drift <5% - spec is authoritative",
96
+ "partial": "40-80% specced - spec is a hint, cross-check code",
97
+ "untracked": "<40% specced - code is the source of truth"
98
+ },
99
+ "spec_source_policy": {
100
+ "mode": "keep-separate",
101
+ "migrated_source_disposition": "retain",
102
+ "disposition_decided_by": "rarajes2@cisco.com",
103
+ "disposition_decided_at": "2026-11-03T05:46:20Z",
104
+ "decided_by": "rarajes2@cisco.com",
105
+ "decided_at": "2026-11-03T05:46:20Z",
106
+ "decision_record": "docs/adr/0001-retain-product-readme.md"
107
+ },
108
+ "spec_sources": [],
109
+ "modules": [
110
+ {
111
+ "path": "src",
112
+ "canonical_spec": "src/docs/README.md",
113
+ "coverage_status": "Partial",
114
+ "coverage_evidence": "Field coverage 93.3% (14/15) assessed 2026-11-03 by the generator; critical field coverage 8/8. The one WEAK field is test strategy: test/unit/spec/authorization.js covers startup completion, the initial-grant outcome, client authentication, login initiation, popup login, third-party login and callback, CSRF, PKCE, URL cleanup, and the QR device flow, but registration and proxies, the 400 grant-error mapping, the missing-code rejection, and the logout redirect have no unit case, the redirect-error case pins a TypeError rather than a grant error, and the automation suite is describe.skip. Held at Partial: independent validation passed on 2026-11-03 (Codex Desktop); no characterization baseline or spec-drift record exists.",
115
+ "last_assessed": "2026-11-03",
116
+ "contracts": {
117
+ "provides": [
118
+ "authorization-browser-first-party-sdk",
119
+ "authorization-plugin-events"
120
+ ],
121
+ "requires": [
122
+ "idbroker-oauth-endpoints",
123
+ "oauth-helper-device-authorization",
124
+ "webex-core-plugin-host",
125
+ "webex-core-credentials",
126
+ "webex-core-services",
127
+ "webex-common-utilities",
128
+ "crypto-js",
129
+ "uuid",
130
+ "lodash"
131
+ ]
132
+ },
133
+ "section_profile": {
134
+ "has_tiers": false,
135
+ "has_ui": false,
136
+ "crosses_service_boundaries": true,
137
+ "holds_client_state": true,
138
+ "enforces_domain_rules": true,
139
+ "is_concurrent_async": true,
140
+ "owns_persistence": false,
141
+ "stateful_transitions": true,
142
+ "exposes_wire_protocol": true,
143
+ "ui_multi_screen": false,
144
+ "large_data_model": false,
145
+ "returns_caller_errors": true,
146
+ "module_specific_conventions": true,
147
+ "published_package": true,
148
+ "embedded_in_host": false,
149
+ "has_design_tradeoff": true,
150
+ "resolved_by": "claude-code (code evidence; bootstrap questionnaire)",
151
+ "resolved_at": "2026-11-03T05:46:20Z",
152
+ "has_submodules": false,
153
+ "has_submodules_computed_by": "scripts/module_tree.py",
154
+ "has_submodules_computed_at": "2026-11-03T05:57:44Z"
155
+ }
156
+ }
157
+ ],
158
+ "contract_catalog": {
159
+ "index_path": "docs/architecture.md",
160
+ "definitions": {
161
+ "authorization-browser-first-party-sdk": {
162
+ "kind": "sdk",
163
+ "publication": "published",
164
+ "source_kind": "repository-path",
165
+ "source": "package.json",
166
+ "summary": "Published npm package. main is dist/index.js and devMain is src/index.js. Importing it registers Authorization as public plugin 'authorization' with proxies isAuthorizing and isAuthenticating and the credentials config defaults (clientType 'public', refreshCallback) from src/config.js; the first registration of the name wins. Named exports are Events, InitialAuthorizationCodeGrantOutcomes, and config. The plugin API on webex.authorization is initiateLogin, initiateAuthorizationCodeGrant, requestAuthorizationCodeGrant, initiateThirdPartyLogin, initiateThirdPartyLoginRedirect, handleThirdPartyCallback, initQRCodeLogin, cancelQRCodePolling, and logout. Per-method behavior is in src/docs/README.md; the class JSDoc marks it private to the Webex web client."
167
+ },
168
+ "authorization-plugin-events": {
169
+ "kind": "event",
170
+ "publication": "published",
171
+ "source_kind": "repository-path",
172
+ "source": "src/authorization.js",
173
+ "summary": "Events on webex.authorization.eventEmitter, which is shared by all instances: 'login' with eventType initiateLogin {hasEmail, hasState} or redirectToLoginUrl {loginUrl}, and 'qRCodeLogin' with eventType getUserCodeSuccess (userData), getUserCodeFailure, authorizationPending, authorizationSuccess, authorizationFailure (data), or pollingCanceled."
174
+ },
175
+ "idbroker-oauth-endpoints": {
176
+ "kind": "http",
177
+ "publication": "internal",
178
+ "source_kind": "external",
179
+ "source": "Identity broker authorize, logout, and token endpoints (URLs from webex-core credentials config; route definitions are not in this repository)",
180
+ "summary": "Login and logout pages are reached by navigation to URLs built by credentials. The token endpoint at config.tokenUrl receives authorization_code forms (redirect_uri, code, self_contained_token, optional code_verifier) and refresh_token forms, with client_id in the form for public clients or HTTP Basic client credentials otherwise; a 400 body carries an OAuth error string."
181
+ },
182
+ "oauth-helper-device-authorization": {
183
+ "kind": "http",
184
+ "publication": "internal",
185
+ "source_kind": "external",
186
+ "source": "oauth-helper service (reached as service name 'oauth-helper' through the services catalog; route definitions are not in this repository)",
187
+ "summary": "POST /actions/device/authorize with {client_id, scope} returns user_code, verification_uri, verification_uri_complete, device_code, interval, and expires_in; POST /actions/device/token with the device_code URN grant returns the token body, 428 while pending, or 400 with message slow_down. Both use HTTP Basic client credentials."
188
+ },
189
+ "webex-core-plugin-host": {
190
+ "kind": "sdk",
191
+ "publication": "published",
192
+ "source_kind": "external",
193
+ "source": "@webex/webex-core (workspace package; module spec consulted: packages/@webex/webex-core/src/docs/README.md)",
194
+ "summary": "Authorization extends WebexPlugin in namespace Credentials, is registered with registerPlugin (first-wins, proxies supported), sends requests with this.webex.request, reads this.webex.getWindow(), and is called by WebexCore#logout."
195
+ },
196
+ "webex-core-credentials": {
197
+ "kind": "sdk",
198
+ "publication": "published",
199
+ "source_kind": "external",
200
+ "source": "@webex/webex-core credentials (module spec consulted: packages/@webex/webex-core/src/lib/credentials/docs/README.md)",
201
+ "summary": "buildLoginUrl, buildThirdPartyLoginUrl, and buildLogoutUrl build URLs; credentials.set({supertoken}) stores tokens; grantErrors.select maps OAuth error strings; credentials calls config.refreshCallback to refresh a browser token; config.tokenUrl names the token endpoint."
202
+ },
203
+ "webex-core-services": {
204
+ "kind": "sdk",
205
+ "publication": "published",
206
+ "source_kind": "external",
207
+ "source": "@webex/webex-core services (module spec consulted: packages/@webex/webex-core/src/lib/services/docs/README.md)",
208
+ "summary": "collectPreauthCatalog(hint) is called before the startup exchange with {emailhash} or {orgId} or no hint; get('oauth-helper') supplies the helper URL embedded in the QR verification URL."
209
+ },
210
+ "webex-common-utilities": {
211
+ "kind": "sdk",
212
+ "publication": "published",
213
+ "source_kind": "external",
214
+ "source": "@webex/common (workspace package; module spec consulted: packages/@webex/common/src/docs/README.md)",
215
+ "summary": "oneFlight and whileInFlight decorate requestAuthorizationCodeGrant and initiateAuthorizationCodeGrant; encodeState and decodeState carry the OAuth state as base64url JSON."
216
+ },
217
+ "crypto-js": {
218
+ "kind": "sdk",
219
+ "publication": "published",
220
+ "source_kind": "external",
221
+ "source": "crypto-js@^4.1.1 (npm)",
222
+ "summary": "SHA256 hashes the email and the PKCE verifier; enc-base64url encodes the challenge and supplies the verifier alphabet."
223
+ },
224
+ "uuid": {
225
+ "kind": "sdk",
226
+ "publication": "published",
227
+ "source_kind": "external",
228
+ "source": "uuid@^3.3.2 (npm)",
229
+ "summary": "uuid.v4 generates the CSRF token."
230
+ },
231
+ "lodash": {
232
+ "kind": "sdk",
233
+ "publication": "published",
234
+ "source_kind": "external",
235
+ "source": "lodash@^4.17.21 (npm)",
236
+ "summary": "cloneDeep, isEmpty, omit, and isObject for option cloning, state validation, and URL cleanup."
237
+ }
238
+ }
239
+ },
240
+ "spec_policy": {
241
+ "require_what_and_why": true,
242
+ "require_provenance": true,
243
+ "protected_specs": [
244
+ "src/docs/README.md"
245
+ ]
246
+ },
247
+ "validation": {
248
+ "generator_runtime": "claude-code",
249
+ "generator_model": "claude-opus-5-5",
250
+ "generator_runtime_source": "host-metadata",
251
+ "source_commit": "108f963a6d7240fb9dab5ee1b0b09a7727646386",
252
+ "minimum_independence": "different-runtime",
253
+ "blocking_severities": [
254
+ "Blocking"
255
+ ],
256
+ "validator_runtime": "Codex Desktop",
257
+ "validator_run_id": "01a1a00a-3708-7d11-9bad-6309010d8dfb",
258
+ "validator_runtime_source": "host-metadata",
259
+ "runtime_fallback_tier": "different-runtime"
260
+ },
261
+ "layout": {
262
+ "sdd_root": ".sdd",
263
+ "docs_root": "docs",
264
+ "agent_entry_path": "AGENTS.md",
265
+ "standing_docs_root": "docs",
266
+ "spec_index_path": "docs/specs/README.md",
267
+ "module_docs_strategy": "source-local",
268
+ "module_docs_relative_path": "docs/README.md",
269
+ "module_docs_decision": {
270
+ "basis": "repo-standards-default",
271
+ "reason": "No module-local documentation existed. The source-local default gives src/docs/README.md. test:style runs eslint ./src/**/*.*, which only warns on the Markdown because the root .eslintignore ignores *.md, and build:src processes -js -ts only, so Markdown under src/ does not enter the build output.",
272
+ "decided_by": "rarajes2@cisco.com (bootstrap questionnaire)",
273
+ "decided_at": "2026-11-03T05:46:20Z"
274
+ },
275
+ "repo_context_decision": {
276
+ "path": ".repo-context.json",
277
+ "schema_path": "schemas/repo-context.schema.json",
278
+ "action": "create",
279
+ "schema_action": "create",
280
+ "reason": "Neither the operational context nor its schema existed in this package. The context is created from package evidence and the schema is copied from the repository-root .sdd/templates/repo-standards/schemas/repo-context.schema.json.",
281
+ "decided_by": "rarajes2@cisco.com (bootstrap questionnaire)",
282
+ "decided_at": "2026-11-03T05:46:20Z"
283
+ },
284
+ "artifact_decisions": [
285
+ {
286
+ "path": "docs/service.md",
287
+ "action": "omit",
288
+ "reason": "Library package, not a deployable service. package.json has no start script, container, or deployment descriptor.",
289
+ "decided_by": "claude-code (code evidence)",
290
+ "decided_at": "2026-11-03T05:46:20Z"
291
+ },
292
+ {
293
+ "path": "mkdocs.yml",
294
+ "action": "omit",
295
+ "reason": "No package-level documentation site exists. Documentation publishing stays with the workspace.",
296
+ "decided_by": "claude-code (code evidence)",
297
+ "decided_at": "2026-11-03T05:46:20Z"
298
+ },
299
+ {
300
+ "path": "api-specs/openapi.yaml",
301
+ "action": "omit",
302
+ "reason": "The package serves no HTTP routes. It is an HTTP client and browser-navigation library; its published surface is the npm export described by authorization-browser-first-party-sdk and the events described by authorization-plugin-events.",
303
+ "decided_by": "claude-code (code evidence)",
304
+ "decided_at": "2026-11-03T05:46:20Z"
305
+ },
306
+ {
307
+ "path": "SECURITY.md",
308
+ "action": "omit",
309
+ "reason": "No package-level security policy exists. The workspace owns security policy, and a per-package copy would duplicate it; security architecture is described in docs/architecture.md.",
310
+ "decided_by": "claude-code (code evidence)",
311
+ "decided_at": "2026-11-03T05:46:20Z"
312
+ },
313
+ {
314
+ "path": "CONTRIBUTING.md",
315
+ "action": "omit",
316
+ "reason": "Contribution instructions are owned at the workspace root and linked from this package README.md.",
317
+ "decided_by": "claude-code (code evidence)",
318
+ "decided_at": "2026-11-03T05:46:20Z"
319
+ },
320
+ {
321
+ "path": "CHANGELOG.md",
322
+ "action": "omit",
323
+ "reason": "Changelog generation is owned at the workspace root. This package has no changelog file.",
324
+ "decided_by": "claude-code (code evidence)",
325
+ "decided_at": "2026-11-03T05:46:20Z"
326
+ },
327
+ {
328
+ "path": "CTO_CHECKLIST.yml",
329
+ "action": "omit",
330
+ "reason": "The CTO readiness checklist applies to deployable services. This package is a library.",
331
+ "decided_by": "claude-code (code evidence)",
332
+ "decided_at": "2026-11-03T05:46:20Z"
333
+ },
334
+ {
335
+ "path": "schemas/cto-checklist.schema.json",
336
+ "action": "omit",
337
+ "reason": "Omitted together with CTO_CHECKLIST.yml.",
338
+ "decided_by": "claude-code (code evidence)",
339
+ "decided_at": "2026-11-03T05:46:20Z"
340
+ }
341
+ ],
342
+ "template_roots": {
343
+ "canonical": ".sdd/templates/repo-standards"
344
+ },
345
+ "contract_index_path": "docs/architecture.md",
346
+ "repo_skills_root": ".sdd/skills",
347
+ "monorepo_package": {
348
+ "package_path": "packages/@webex/plugin-authorization-browser-first-party",
349
+ "root_manifest_path": "../../../.sdd/manifest.json",
350
+ "templates_root_path": "../../../.sdd/templates/repo-standards"
351
+ }
352
+ },
353
+ "tooling": {
354
+ "sdlc_skills": {
355
+ "source_ref": "repo-annotation@2.3.1"
356
+ }
357
+ },
358
+ "coverage_ratchet": {
359
+ "enabled": true,
360
+ "waivers": []
361
+ },
362
+ "substrate": {
363
+ "source": "WebexTools/repo-standards@d89a7fe59126ae3ad9bac9ca352aa7f12b4c85dc",
364
+ "consumed": [
365
+ "@webex/eslint-config-legacy via .eslintrc.js",
366
+ "@webex/babel-config-legacy via babel.config.js",
367
+ "@webex/jest-config-legacy via jest.config.js",
368
+ "@webex/legacy-tools build and test runner via package.json",
369
+ "package README.md",
370
+ "Repo Standards templates at the monorepo root .sdd/templates/repo-standards, referred to through layout.monorepo_package.templates_root_path (this package holds no templates)"
371
+ ],
372
+ "compliance_tier": "baseline"
373
+ },
374
+ "section_profiles": {
375
+ "repo": {
376
+ "owns_datastore": false,
377
+ "holds_client_state": true,
378
+ "components_interact": true,
379
+ "domain_data_across_components": true,
380
+ "caches_data": false,
381
+ "observability_convention": true,
382
+ "deploys_to_infra": false,
383
+ "shared_base_libs": true,
384
+ "is_monorepo": false,
385
+ "multi_platform": false,
386
+ "published_package": true,
387
+ "embedded_in_host": false,
388
+ "cross_repo_deps_material": true,
389
+ "security_arch_warranted": true,
390
+ "exposes_commands_or_artifacts": true
391
+ },
392
+ "resolved_by": "claude-code (code evidence; bootstrap questionnaire)",
393
+ "resolved_at": "2026-11-03T05:46:20Z"
394
+ }
395
+ }
package/AGENTS.md ADDED
@@ -0,0 +1,214 @@
1
+ <!-- sdd-generated-metadata
2
+ doc_kind: agent-entry
3
+ generated_from: agents@0.3.0
4
+ generated_by: claude-code
5
+ approved_by: rarajes2@cisco.com
6
+ updated_at: 2026-11-03T06:25:15Z
7
+ validation_status: pass
8
+ -->
9
+
10
+ # AI Agent Instructions
11
+
12
+ Package-scoped SDD entry for `@webex/plugin-authorization-browser-first-party`, the first-party
13
+ browser `authorization` plugin (authorization code with PKCE and CSRF state, third-party login
14
+ callback, QR device login, and logout). This file orients agents. The monorepo root `AGENTS.md`
15
+ governs workspace-wide setup.
16
+
17
+ ## Working Method
18
+
19
+ - Read the relevant package files before editing. Do not edit blind.
20
+ - Understand the task and affected surfaces before writing code.
21
+ - Prefer focused edits over rewriting whole files.
22
+ - Do not invent commands, paths, exports, config keys, events, or storage keys. Verify them from this
23
+ package's source and tests.
24
+ - Test or validate before declaring done.
25
+ - Keep output concise. If something is uncertain, say so instead of guessing.
26
+
27
+ ## Canonical Repository Documentation
28
+
29
+ Before changing code or documentation, start with:
30
+
31
+ - [`docs/index.md`](docs/index.md) for package documentation navigation;
32
+ - [`docs/architecture.md`](docs/architecture.md) for package boundaries and interactions;
33
+ - [`docs/specs/README.md`](docs/specs/README.md) for the manifest-backed module and contract registry;
34
+ - the module specification at [`src/docs/README.md`](src/docs/README.md) (first-party browser
35
+ authorization plugin); and
36
+ - [`docs/adr/index.md`](docs/adr/index.md) plus applicable concrete ADRs.
37
+
38
+ Follow `.sdd/manifest.json` for each contract's publication state and canonical source. This package
39
+ publishes an SDK surface, so its contract artifact is `package.json` plus the `src/index.js` entry, and
40
+ its event contract is `src/authorization.js`. It serves no HTTP, so no OpenAPI applies.
41
+
42
+ ## 1. Commands (Run First)
43
+
44
+ Use only documented commands. Do not invent alternatives when a command is missing. Run workspace
45
+ commands from the monorepo root.
46
+
47
+ | Task | Command |
48
+ | ---------------------- | ------- |
49
+ | Install dependencies | `yarn` (workspace root; the deploy workflow runs the same command) |
50
+ | Start dev environment | N/A — library package with no start script in `package.json` |
51
+ | Run tests | `yarn workspace @webex/plugin-authorization-browser-first-party test:unit` (jest) after `build:src` |
52
+ | Run linters | `yarn workspace @webex/plugin-authorization-browser-first-party test:style` |
53
+ | Build/release artifact | `yarn workspace @webex/plugin-authorization-browser-first-party build` (runs `build:src`) |
54
+ | Format code | N/A — no format script; `prettier` is a devDependency used through eslint |
55
+
56
+ The `package.json` script `test` chains `test:style`, `test:unit`, `test:integration`, and
57
+ `test:browser`. `test:integration` is not defined, and `test:browser` collects `test/integration/spec`,
58
+ which does not exist, so neither the aggregate nor `test:browser` is a verification command.
59
+
60
+ If a required command is unknown, stop and ask for the exact command.
61
+
62
+ ## 2. Agent Persona and Scope
63
+
64
+ You are the Webex web client engineering assistant for `@webex/plugin-authorization-browser-first-party`.
65
+
66
+ Primary outcomes:
67
+
68
+ - Deliver production-safe changes with unit tests and lint passing.
69
+ - Preserve existing behavior unless a change request explicitly requires a behavior change.
70
+ - Keep docs and configuration aligned with code changes.
71
+
72
+ Definition of done:
73
+
74
+ 1. Requested change is implemented.
75
+ 2. Relevant tests, lint, and build checks pass locally.
76
+ 3. Updated docs cover new behavior, including the owning module spec.
77
+ 4. PR summary includes risks and rollback notes.
78
+
79
+ ## 3. Repository Knowledge
80
+
81
+ ### Tech Stack
82
+
83
+ | Area | Tooling | Version |
84
+ | ---------------- | ------- | ------- |
85
+ | Language runtime | node; JavaScript sources for the browser | `>=8` (`package.json` engines) |
86
+ | Build tool | `@webex/legacy-tools` over babel | `@babel/core` `^7.17.10` |
87
+ | Test framework | jest via `webex-legacy-tools` (`test:unit`); chai, sinon, and `@webex/test-helper-mock-webex` | sinon `^9.2.4` |
88
+ | Lint/format | eslint via `@webex/eslint-config-legacy`, prettier | eslint `^8.24.0`, prettier `^2.7.1` |
89
+
90
+ ### Project Map
91
+
92
+ - `src/index.js`: registers public plugin `authorization` with proxies `isAuthorizing` and
93
+ `isAuthenticating`; re-exports the class, `Events`, `InitialAuthorizationCodeGrantOutcomes`, and
94
+ `config`.
95
+ - `src/authorization.js`: the `Authorization` plugin. Spec: `src/docs/README.md`.
96
+ - `src/config.js`: `credentials.clientType` (default `public`), `getClientAuthenticationOptions`, and
97
+ the browser `refreshCallback`.
98
+ - `test/unit/spec/authorization.js`: the unit spec run by `test:unit`; it imports the package by name,
99
+ which loads `dist/`.
100
+ - `test/automation/spec/authorization-code-grant.js`: skipped browser automation suite; no package
101
+ script runs it.
102
+ - `process`: package-root module exporting `{browser: true}`; not imported by `src/`.
103
+ - `dist/`: generated build output. Never edit by hand.
104
+ - `README.md`: retained npm page. It is not the behavioral authority; see
105
+ [ADR-0001](docs/adr/0001-retain-product-readme.md).
106
+
107
+ ### Critical Constraints
108
+
109
+ - The CSRF token (`oauth2-csrf-token`) and PKCE verifier (`oauth2-code-verifier`) are single-use
110
+ `sessionStorage` entries removed on first read. Keep the key names; a login started by one page load
111
+ finishes on the next.
112
+ - `initiateLogin` must never send the caller's raw email; it sends only its SHA-256 (`emailHash`,
113
+ `state.emailhash`). This does not cover the callback email that `handleThirdPartyCallback` returns.
114
+ - After a successful CSRF check, `initialize` must keep scrubbing `code`, `id_token`, `email`, and
115
+ `csrf_token` from the URL (a failed check throws first and leaves them), and must set `ready` to
116
+ `true` whether the startup exchange succeeds or fails.
117
+ - The third-party callback requires a stored CSRF token (`requireMatch`); do not relax it.
118
+ - Token-endpoint requests use `shouldRefreshAccessToken: false` and client authentication from
119
+ `getClientAuthenticationOptions`.
120
+ - `eventEmitter` is shared by every instance in the page, and hosts switch on `eventType`. The QR
121
+ `authorizationSuccess` event carries the token response body, so treat its listeners as token
122
+ consumers. The `login` `redirectToLoginUrl` event carries the full login URL, including the CSRF
123
+ token and email hash. `handleThirdPartyCallback` returns the raw `idToken` and email to its caller,
124
+ and the logout redirect URL carries the `options.token` that `WebexCore#logout` supplies.
125
+ - QR success emits `authorizationSuccess` before `credentials.set`; a listener that throws skips the
126
+ set and yields `pollingCanceled` and `authorizationFailure` with no `data`. This is untested.
127
+ - The QR guards are partial: `pollingTimer` is `null` during the authorize request, and the poll-id
128
+ check stops filtering an old response once a newer poll starts. Add a fake-timer case before relying
129
+ on either.
130
+
131
+ ## 4. Testing Workflow
132
+
133
+ Run checks in this order:
134
+
135
+ 1. `yarn workspace @webex/plugin-authorization-browser-first-party build:src`
136
+ 2. `yarn workspace @webex/plugin-authorization-browser-first-party test:unit`
137
+ 3. `yarn workspace @webex/plugin-authorization-browser-first-party test:style`
138
+
139
+ Step 1 matters: the unit spec imports `@webex/plugin-authorization-browser-first-party` by name, which
140
+ resolves `main` (`dist/index.js`), so a stale `dist/` makes results meaningless.
141
+
142
+ Testing rules:
143
+
144
+ - Add or update unit cases for every behavior change. The 400 grant-error mapping, the missing-code
145
+ rejection, registration, and the logout redirect have no unit case today.
146
+ - Cover failure paths and edge cases, not only happy paths.
147
+ - Do not remove tests to make CI pass.
148
+ - Use `sinon.useFakeTimers()` for QR polling cases, as the existing cases do.
149
+
150
+ No coverage gate applies to this package; do not infer one.
151
+
152
+ ## 5. Code Style and Patterns
153
+
154
+ Coding expectations:
155
+
156
+ - Follow repository style rules and static analysis output. The local `.eslintrc.js` sets `root: true`;
157
+ `src/authorization.js` disables eslint and TypeScript checking at file level.
158
+ - Prefer small functions over large procedural blocks.
159
+ - Make error handling explicit; report QR outcomes through `qRCodeLogin` events, not rejections.
160
+ - Keep public interfaces stable unless a breaking change is requested.
161
+
162
+ Pattern example:
163
+
164
+ ```text
165
+ Preferred:
166
+ - Emit {eventType, data} or {eventType, userData} on eventEmitter for QR progress.
167
+ - Build token-endpoint auth with getClientAuthenticationOptions(this.config).
168
+ - Add a case next to the matching describe block in test/unit/spec/authorization.js.
169
+
170
+ Avoid:
171
+ - Storing secrets anywhere but the two single-use sessionStorage keys.
172
+ - Treating README.md as the list of methods or events.
173
+ - Trusting JSDoc return annotations over the code (logout returns undefined).
174
+ ```
175
+
176
+ ## 6. Git Workflow
177
+
178
+ - Branch naming: no package convention is defined; follow the workspace `CONTRIBUTING.md`.
179
+ - Commit format: conventional commits (`feat:`, `fix:`, `docs:`, `refactor:`, `test:`, `chore:`), which
180
+ the workspace `CONTRIBUTING.md` requires for pull requests.
181
+ - Keep commits focused and reversible.
182
+ - Rebase on the target branch before opening a pull request.
183
+
184
+ PR checklist:
185
+
186
+ - What changed and why.
187
+ - Tests run and results.
188
+ - Risk and impact on the Webex web client login, QR login, and logout flows.
189
+ - Rollback approach.
190
+
191
+ ## 7. Boundaries and Escalation
192
+
193
+ ### Always
194
+
195
+ - Prefer existing patterns over introducing new architecture.
196
+ - Keep changes minimal for the requested scope.
197
+ - Call out assumptions and unknowns explicitly.
198
+ - Update the owning module spec in the same change that alters observable behavior.
199
+
200
+ ### Ask First
201
+
202
+ - Adding dependencies.
203
+ - Changing CSRF, PKCE, URL-scrubbing, or client-authentication behavior.
204
+ - Changing token-endpoint or `oauth-helper` request shapes, or the QR verification host.
205
+ - Changing event names, `eventType` values, or `sessionStorage` key names.
206
+
207
+ ### Never
208
+
209
+ - Edit `dist/` by hand.
210
+ - Commit secrets, tokens, client secrets, or credentials, including in test fixtures.
211
+ - Log tokens, codes, verifiers, or raw email addresses.
212
+ - Add a `.sdd/templates` directory, a copy of the templates, or a link to them in this package. The
213
+ templates live once at the monorepo root, `../../../.sdd/templates/repo-standards`, and
214
+ `.sdd/manifest.json` refers to them through `layout.monorepo_package`.