@nodehive/nextjs 0.1.2 → 0.2.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.
- package/README.md +1 -1
- package/dist/auth/index.d.ts +2 -3
- package/dist/auth/index.js.map +1 -1
- package/dist/auth/internal/config.d.ts +15 -5
- package/dist/auth/internal/config.js.map +1 -1
- package/dist/auth/internal/draft-mode.d.ts +2 -3
- package/dist/auth/internal/draft-mode.js +3 -20
- package/dist/auth/internal/draft-mode.js.map +1 -1
- package/dist/auth/internal/editor-locale.d.ts +0 -1
- package/dist/auth/internal/handoff.d.ts +0 -1
- package/dist/auth/internal/has-session.d.ts +0 -1
- package/dist/auth/internal/has-session.js +1 -1
- package/dist/auth/internal/has-session.js.map +1 -1
- package/dist/auth/internal/i18n.d.ts +10 -0
- package/dist/auth/internal/i18n.js +25 -0
- package/dist/auth/internal/i18n.js.map +1 -0
- package/dist/auth/internal/logout.d.ts +1 -2
- package/dist/auth/internal/logout.js +3 -3
- package/dist/auth/internal/logout.js.map +1 -1
- package/dist/auth/internal/next-cookie-storage.d.ts +5 -2
- package/dist/auth/internal/next-cookie-storage.js +8 -1
- package/dist/auth/internal/next-cookie-storage.js.map +1 -1
- package/dist/auth/internal/nodehive-client.d.ts +6 -4
- package/dist/auth/internal/nodehive-client.js +6 -4
- package/dist/auth/internal/nodehive-client.js.map +1 -1
- package/dist/auth/internal/oauth-config.d.ts +0 -1
- package/dist/auth/internal/proxy-helpers.d.ts +0 -1
- package/dist/auth/internal/proxy-helpers.js +4 -4
- package/dist/auth/internal/proxy-helpers.js.map +1 -1
- package/dist/auth/internal/refresh.d.ts +1 -2
- package/dist/auth/internal/refresh.js +4 -4
- package/dist/auth/internal/refresh.js.map +1 -1
- package/dist/auth/internal/require-auth.d.ts +0 -1
- package/dist/auth/internal/require-auth.js +1 -1
- package/dist/auth/internal/require-auth.js.map +1 -1
- package/dist/auth/internal/return-to.d.ts +0 -1
- package/dist/auth/internal/roles.d.ts +17 -0
- package/dist/auth/internal/roles.js +39 -0
- package/dist/auth/internal/roles.js.map +1 -0
- package/dist/auth/internal/routes/callback.d.ts +1 -2
- package/dist/auth/internal/routes/callback.js +6 -6
- package/dist/auth/internal/routes/callback.js.map +1 -1
- package/dist/auth/internal/routes/chips-exchange.d.ts +1 -2
- package/dist/auth/internal/routes/chips-exchange.js +5 -5
- package/dist/auth/internal/routes/chips-exchange.js.map +1 -1
- package/dist/auth/internal/routes/draft.d.ts +1 -2
- package/dist/auth/internal/routes/draft.js +3 -3
- package/dist/auth/internal/routes/draft.js.map +1 -1
- package/dist/auth/internal/routes/index.d.ts +4 -2
- package/dist/auth/internal/routes/index.js +7 -7
- package/dist/auth/internal/routes/index.js.map +1 -1
- package/dist/auth/internal/routes/login.d.ts +0 -1
- package/dist/auth/internal/routes/login.js +3 -3
- package/dist/auth/internal/routes/login.js.map +1 -1
- package/dist/auth/internal/routes/popup-done.d.ts +2 -2
- package/dist/auth/internal/routes/popup-done.js +9 -7
- package/dist/auth/internal/routes/popup-done.js.map +1 -1
- package/dist/auth/internal/routes/refresh.d.ts +2 -5
- package/dist/auth/internal/routes/refresh.js +8 -2
- package/dist/auth/internal/routes/refresh.js.map +1 -1
- package/dist/auth/internal/same-origin.d.ts +0 -1
- package/dist/auth/internal/session-gates.d.ts +27 -3
- package/dist/auth/internal/session-gates.js +35 -3
- package/dist/auth/internal/session-gates.js.map +1 -1
- package/dist/auth/internal/update-session.d.ts +1 -2
- package/dist/auth/internal/update-session.js +1 -1
- package/dist/auth/internal/update-session.js.map +1 -1
- package/dist/auth/internal/use-editor-login.d.ts +0 -1
- package/dist/auth/internal/use-editor-login.js +2 -3
- package/dist/auth/internal/use-editor-login.js.map +1 -1
- package/dist/auth/proxy.d.ts +7 -8
- package/dist/auth/proxy.js +6 -6
- package/dist/auth/proxy.js.map +1 -1
- package/dist/auth/react.d.ts +1 -2
- package/dist/auth/react.js +1 -1
- package/dist/auth/react.js.map +1 -1
- package/dist/auth/routes.d.ts +3 -3
- package/dist/auth/routes.js +1 -1
- package/dist/auth/routes.js.map +1 -1
- package/dist/auth/server.d.ts +14 -12
- package/dist/auth/server.js +14 -9
- package/dist/auth/server.js.map +1 -1
- package/dist/bridge-protocol/index.d.ts +50 -0
- package/dist/bridge-protocol/index.js +25 -0
- package/dist/bridge-protocol/index.js.map +1 -0
- package/dist/puck-editor/editor.d.ts +8 -0
- package/dist/puck-editor/editor.js +9 -0
- package/dist/puck-editor/editor.js.map +1 -0
- package/dist/puck-editor/fields.d.ts +6 -7
- package/dist/puck-editor/fields.js +3 -3
- package/dist/puck-editor/fields.js.map +1 -1
- package/dist/puck-editor/index.d.ts +17 -14
- package/dist/puck-editor/index.js +13 -11
- package/dist/puck-editor/index.js.map +1 -1
- package/dist/puck-editor/internal/api/client.d.ts +19 -4
- package/dist/puck-editor/internal/api/client.js +56 -19
- package/dist/puck-editor/internal/api/client.js.map +1 -1
- package/dist/puck-editor/internal/api/config.d.ts +36 -3
- package/dist/puck-editor/internal/api/config.js.map +1 -1
- package/dist/puck-editor/internal/api/create-puck-api.d.ts +1 -2
- package/dist/puck-editor/internal/api/create-puck-api.js +10 -13
- package/dist/puck-editor/internal/api/create-puck-api.js.map +1 -1
- package/dist/puck-editor/internal/api/handlers/create-page.d.ts +1 -2
- package/dist/puck-editor/internal/api/handlers/create-page.js +6 -4
- package/dist/puck-editor/internal/api/handlers/create-page.js.map +1 -1
- package/dist/puck-editor/internal/api/handlers/entities.d.ts +6 -5
- package/dist/puck-editor/internal/api/handlers/entities.js +60 -15
- package/dist/puck-editor/internal/api/handlers/entities.js.map +1 -1
- package/dist/puck-editor/internal/api/handlers/publish.d.ts +3 -6
- package/dist/puck-editor/internal/api/handlers/publish.js +57 -14
- package/dist/puck-editor/internal/api/handlers/publish.js.map +1 -1
- package/dist/puck-editor/internal/api/handlers/template.d.ts +5 -2
- package/dist/puck-editor/internal/api/handlers/template.js +28 -60
- package/dist/puck-editor/internal/api/handlers/template.js.map +1 -1
- package/dist/puck-editor/internal/api/handlers/upload.d.ts +10 -2
- package/dist/puck-editor/internal/api/handlers/upload.js +93 -28
- package/dist/puck-editor/internal/api/handlers/upload.js.map +1 -1
- package/dist/puck-editor/internal/api/localize-message.d.ts +15 -0
- package/dist/puck-editor/internal/api/localize-message.js +15 -0
- package/dist/puck-editor/internal/api/localize-message.js.map +1 -0
- package/dist/puck-editor/internal/api/media-params.d.ts +3 -3
- package/dist/puck-editor/internal/api/media-params.js +23 -19
- package/dist/puck-editor/internal/api/media-params.js.map +1 -1
- package/dist/puck-editor/internal/api/media-upload.d.ts +5 -3
- package/dist/puck-editor/internal/api/media-upload.js +33 -22
- package/dist/puck-editor/internal/api/media-upload.js.map +1 -1
- package/dist/puck-editor/internal/api/message-codes.d.ts +2 -0
- package/dist/puck-editor/internal/api/message-codes.js +2 -0
- package/dist/puck-editor/internal/api/message-codes.js.map +1 -0
- package/dist/puck-editor/internal/api/space.d.ts +0 -1
- package/dist/puck-editor/internal/api/type-segment.d.ts +2 -0
- package/dist/puck-editor/internal/api/type-segment.js +9 -0
- package/dist/puck-editor/internal/api/type-segment.js.map +1 -0
- package/dist/puck-editor/internal/content-model.d.ts +31 -3
- package/dist/puck-editor/internal/content-model.js +76 -6
- package/dist/puck-editor/internal/content-model.js.map +1 -1
- package/dist/puck-editor/internal/dictionaries.d.ts +225 -0
- package/dist/puck-editor/internal/dictionaries.js +673 -0
- package/dist/puck-editor/internal/dictionaries.js.map +1 -0
- package/dist/puck-editor/internal/editor/allowed-types.d.ts +1 -2
- package/dist/puck-editor/internal/editor/allowed-types.js +2 -2
- package/dist/puck-editor/internal/editor/allowed-types.js.map +1 -1
- package/dist/puck-editor/internal/editor/canvas-add-picker.d.ts +0 -1
- package/dist/puck-editor/internal/editor/canvas-add-picker.js +108 -135
- package/dist/puck-editor/internal/editor/canvas-add-picker.js.map +1 -1
- package/dist/puck-editor/internal/editor/canvas-empty-state.d.ts +0 -1
- package/dist/puck-editor/internal/editor/canvas-empty-state.js +4 -4
- package/dist/puck-editor/internal/editor/canvas-empty-state.js.map +1 -1
- package/dist/puck-editor/internal/editor/canvas-quick-add.d.ts +0 -1
- package/dist/puck-editor/internal/editor/canvas-quick-add.js +28 -41
- package/dist/puck-editor/internal/editor/canvas-quick-add.js.map +1 -1
- package/dist/puck-editor/internal/editor/canvas-scroll.d.ts +0 -1
- package/dist/puck-editor/internal/editor/component-icons.d.ts +1 -2
- package/dist/puck-editor/internal/editor/component-icons.js.map +1 -1
- package/dist/puck-editor/internal/editor/component-item.d.ts +0 -1
- package/dist/puck-editor/internal/editor/component-item.js +2 -2
- package/dist/puck-editor/internal/editor/component-item.js.map +1 -1
- package/dist/puck-editor/internal/editor/compose-save-issues.d.ts +15 -0
- package/dist/puck-editor/internal/editor/compose-save-issues.js +16 -0
- package/dist/puck-editor/internal/editor/compose-save-issues.js.map +1 -0
- package/dist/puck-editor/internal/editor/dirty-state.d.ts +3 -0
- package/dist/puck-editor/internal/editor/dirty-state.js +7 -0
- package/dist/puck-editor/internal/editor/dirty-state.js.map +1 -0
- package/dist/puck-editor/internal/editor/draft-restore-banner.d.ts +9 -0
- package/dist/puck-editor/internal/editor/draft-restore-banner.js +289 -0
- package/dist/puck-editor/internal/editor/draft-restore-banner.js.map +1 -0
- package/dist/puck-editor/internal/editor/draft-storage.d.ts +41 -0
- package/dist/puck-editor/internal/editor/draft-storage.js +129 -0
- package/dist/puck-editor/internal/editor/draft-storage.js.map +1 -0
- package/dist/puck-editor/internal/editor/editor-action-bar.d.ts +0 -1
- package/dist/puck-editor/internal/editor/editor-action-bar.js +4 -4
- package/dist/puck-editor/internal/editor/editor-action-bar.js.map +1 -1
- package/dist/puck-editor/internal/editor/editor-header-actions.d.ts +6 -4
- package/dist/puck-editor/internal/editor/editor-header-actions.js +119 -60
- package/dist/puck-editor/internal/editor/editor-header-actions.js.map +1 -1
- package/dist/puck-editor/internal/editor/find-missing-required-fields.d.ts +0 -1
- package/dist/puck-editor/internal/editor/grouped-drawer-panel.d.ts +1 -2
- package/dist/puck-editor/internal/editor/grouped-drawer-panel.js +6 -6
- package/dist/puck-editor/internal/editor/grouped-drawer-panel.js.map +1 -1
- package/dist/puck-editor/internal/editor/grouped-entry-list.d.ts +7 -5
- package/dist/puck-editor/internal/editor/grouped-entry-list.js +85 -56
- package/dist/puck-editor/internal/editor/grouped-entry-list.js.map +1 -1
- package/dist/puck-editor/internal/editor/header-save-button.d.ts +4 -4
- package/dist/puck-editor/internal/editor/header-save-button.js +66 -27
- package/dist/puck-editor/internal/editor/header-save-button.js.map +1 -1
- package/dist/puck-editor/internal/editor/leave-confirm-dialog.d.ts +5 -0
- package/dist/puck-editor/internal/editor/leave-confirm-dialog.js +140 -0
- package/dist/puck-editor/internal/editor/leave-confirm-dialog.js.map +1 -0
- package/dist/puck-editor/internal/editor/page-template-picker.d.ts +0 -1
- package/dist/puck-editor/internal/editor/page-template-picker.js +5 -5
- package/dist/puck-editor/internal/editor/page-template-picker.js.map +1 -1
- package/dist/puck-editor/internal/editor/picker-entry-item.d.ts +1 -2
- package/dist/puck-editor/internal/editor/picker-entry-item.js +4 -4
- package/dist/puck-editor/internal/editor/picker-entry-item.js.map +1 -1
- package/dist/puck-editor/internal/editor/picker-model.d.ts +14 -5
- package/dist/puck-editor/internal/editor/picker-model.js +157 -132
- package/dist/puck-editor/internal/editor/picker-model.js.map +1 -1
- package/dist/puck-editor/internal/editor/publish-puck-data.d.ts +18 -4
- package/dist/puck-editor/internal/editor/publish-puck-data.js +25 -4
- package/dist/puck-editor/internal/editor/publish-puck-data.js.map +1 -1
- package/dist/puck-editor/internal/editor/puck-editor.d.ts +6 -4
- package/dist/puck-editor/internal/editor/puck-editor.js +270 -209
- package/dist/puck-editor/internal/editor/puck-editor.js.map +1 -1
- package/dist/puck-editor/internal/editor/save-guard.d.ts +15 -0
- package/dist/puck-editor/internal/editor/save-guard.js +30 -0
- package/dist/puck-editor/internal/editor/save-guard.js.map +1 -0
- package/dist/puck-editor/internal/editor/save-page-context.d.ts +8 -0
- package/dist/puck-editor/internal/editor/save-page-context.js +34 -0
- package/dist/puck-editor/internal/editor/save-page-context.js.map +1 -0
- package/dist/puck-editor/internal/editor/section-template-modal.d.ts +0 -1
- package/dist/puck-editor/internal/editor/section-template-modal.js +2 -2
- package/dist/puck-editor/internal/editor/section-template-modal.js.map +1 -1
- package/dist/puck-editor/internal/editor/unsaved-changes-guard.d.ts +3 -0
- package/dist/puck-editor/internal/editor/unsaved-changes-guard.js +38 -0
- package/dist/puck-editor/internal/editor/unsaved-changes-guard.js.map +1 -0
- package/dist/puck-editor/internal/editor/use-dirty-baseline.d.ts +5 -0
- package/dist/puck-editor/internal/editor/use-dirty-baseline.js +72 -0
- package/dist/puck-editor/internal/editor/use-dirty-baseline.js.map +1 -0
- package/dist/puck-editor/internal/editor/use-draft-recovery.d.ts +16 -0
- package/dist/puck-editor/internal/editor/use-draft-recovery.js +194 -0
- package/dist/puck-editor/internal/editor/use-draft-recovery.js.map +1 -0
- package/dist/puck-editor/internal/editor/use-frame-zoom.d.ts +1 -0
- package/dist/puck-editor/internal/editor/use-frame-zoom.js +59 -0
- package/dist/puck-editor/internal/editor/use-frame-zoom.js.map +1 -0
- package/dist/puck-editor/internal/editor/use-is-dirty.d.ts +1 -0
- package/dist/puck-editor/internal/editor/use-is-dirty.js +32 -0
- package/dist/puck-editor/internal/editor/use-is-dirty.js.map +1 -0
- package/dist/puck-editor/internal/editor/use-scroll-lock-outside.d.ts +0 -1
- package/dist/puck-editor/internal/editor-config.d.ts +16 -3
- package/dist/puck-editor/internal/editor-config.js +8 -1
- package/dist/puck-editor/internal/editor-config.js.map +1 -1
- package/dist/puck-editor/internal/editor-query-client.d.ts +0 -1
- package/dist/puck-editor/internal/fields/checkbox-group/checkbox-group-field.d.ts +0 -1
- package/dist/puck-editor/internal/fields/checkbox-group/checkbox-group-field.js +2 -2
- package/dist/puck-editor/internal/fields/checkbox-group/checkbox-group-field.js.map +1 -1
- package/dist/puck-editor/internal/fields/checkbox-group/create-checkbox-group-field.d.ts +0 -1
- package/dist/puck-editor/internal/fields/checkbox-group/create-checkbox-group-field.js +1 -1
- package/dist/puck-editor/internal/fields/checkbox-group/create-checkbox-group-field.js.map +1 -1
- package/dist/puck-editor/internal/fields/date-picker/create-date-picker-field.d.ts +0 -1
- package/dist/puck-editor/internal/fields/date-picker/create-date-picker-field.js +1 -1
- package/dist/puck-editor/internal/fields/date-picker/create-date-picker-field.js.map +1 -1
- package/dist/puck-editor/internal/fields/date-picker/date-picker.d.ts +0 -1
- package/dist/puck-editor/internal/fields/date-picker/date-picker.js +90 -73
- package/dist/puck-editor/internal/fields/date-picker/date-picker.js.map +1 -1
- package/dist/puck-editor/internal/fields/index.d.ts +10 -10
- package/dist/puck-editor/internal/fields/index.js +10 -9
- package/dist/puck-editor/internal/fields/index.js.map +1 -1
- package/dist/puck-editor/internal/fields/link-picker/anchor.d.ts +0 -1
- package/dist/puck-editor/internal/fields/link-picker/anchor.js +1 -1
- package/dist/puck-editor/internal/fields/link-picker/anchor.js.map +1 -1
- package/dist/puck-editor/internal/fields/link-picker/create-link-field.d.ts +1 -2
- package/dist/puck-editor/internal/fields/link-picker/create-link-field.js +1 -1
- package/dist/puck-editor/internal/fields/link-picker/create-link-field.js.map +1 -1
- package/dist/puck-editor/internal/fields/link-picker/humanize.d.ts +0 -1
- package/dist/puck-editor/internal/fields/link-picker/link-picker-control.d.ts +0 -1
- package/dist/puck-editor/internal/fields/link-picker/link-picker-control.js +208 -140
- package/dist/puck-editor/internal/fields/link-picker/link-picker-control.js.map +1 -1
- package/dist/puck-editor/internal/fields/link-picker/link-picker-field.d.ts +1 -2
- package/dist/puck-editor/internal/fields/link-picker/link-picker-field.js +6 -6
- package/dist/puck-editor/internal/fields/link-picker/link-picker-field.js.map +1 -1
- package/dist/puck-editor/internal/fields/link-picker/link-value.d.ts +25 -5
- package/dist/puck-editor/internal/fields/link-picker/link-value.js +56 -6
- package/dist/puck-editor/internal/fields/link-picker/link-value.js.map +1 -1
- package/dist/puck-editor/internal/fields/link-picker/rich-text-link-button.d.ts +0 -1
- package/dist/puck-editor/internal/fields/link-picker/rich-text-link-button.js +4 -4
- package/dist/puck-editor/internal/fields/link-picker/rich-text-link-button.js.map +1 -1
- package/dist/puck-editor/internal/fields/link-picker/richtext-extensions.d.ts +0 -1
- package/dist/puck-editor/internal/fields/link-picker/segmented-control.d.ts +0 -1
- package/dist/puck-editor/internal/fields/link-picker/segmented-control.js +3 -3
- package/dist/puck-editor/internal/fields/link-picker/segmented-control.js.map +1 -1
- package/dist/puck-editor/internal/fields/link-picker/types.d.ts +0 -1
- package/dist/puck-editor/internal/fields/media-array/create-media-array-field.d.ts +2 -3
- package/dist/puck-editor/internal/fields/media-array/create-media-array-field.js +1 -1
- package/dist/puck-editor/internal/fields/media-array/create-media-array-field.js.map +1 -1
- package/dist/puck-editor/internal/fields/media-array/media-array-field.d.ts +2 -3
- package/dist/puck-editor/internal/fields/media-array/media-array-field.js +124 -115
- package/dist/puck-editor/internal/fields/media-array/media-array-field.js.map +1 -1
- package/dist/puck-editor/internal/fields/media-array/reorder.d.ts +0 -1
- package/dist/puck-editor/internal/fields/media-selector/create-media-selector-field.d.ts +2 -3
- package/dist/puck-editor/internal/fields/media-selector/create-media-selector-field.js +1 -1
- package/dist/puck-editor/internal/fields/media-selector/create-media-selector-field.js.map +1 -1
- package/dist/puck-editor/internal/fields/media-selector/crop-editor-dialog.d.ts +1 -2
- package/dist/puck-editor/internal/fields/media-selector/crop-editor-dialog.js +4 -4
- package/dist/puck-editor/internal/fields/media-selector/crop-editor-dialog.js.map +1 -1
- package/dist/puck-editor/internal/fields/media-selector/crop-types.d.ts +0 -1
- package/dist/puck-editor/internal/fields/media-selector/extract-fields.d.ts +0 -1
- package/dist/puck-editor/internal/fields/media-selector/image-upload-form.d.ts +0 -1
- package/dist/puck-editor/internal/fields/media-selector/image-upload-form.js +19 -10
- package/dist/puck-editor/internal/fields/media-selector/image-upload-form.js.map +1 -1
- package/dist/puck-editor/internal/fields/media-selector/media-selector-field.d.ts +8 -3
- package/dist/puck-editor/internal/fields/media-selector/media-selector-field.js +59 -61
- package/dist/puck-editor/internal/fields/media-selector/media-selector-field.js.map +1 -1
- package/dist/puck-editor/internal/fields/media-selector/media-selector-modal.d.ts +1 -2
- package/dist/puck-editor/internal/fields/media-selector/media-selector-modal.js +281 -255
- package/dist/puck-editor/internal/fields/media-selector/media-selector-modal.js.map +1 -1
- package/dist/puck-editor/internal/fields/media-selector/use-debounced-value.d.ts +0 -1
- package/dist/puck-editor/internal/fields/media-selector/use-media-library.d.ts +15 -2
- package/dist/puck-editor/internal/fields/media-selector/use-media-library.js +23 -18
- package/dist/puck-editor/internal/fields/media-selector/use-media-library.js.map +1 -1
- package/dist/puck-editor/internal/fields/media-selector/video-upload-form.d.ts +0 -1
- package/dist/puck-editor/internal/fields/media-selector/video-upload-form.js +12 -6
- package/dist/puck-editor/internal/fields/media-selector/video-upload-form.js.map +1 -1
- package/dist/puck-editor/internal/fields/node-selector/create-node-selector-field.d.ts +0 -1
- package/dist/puck-editor/internal/fields/node-selector/create-node-selector-field.js +2 -2
- package/dist/puck-editor/internal/fields/node-selector/create-node-selector-field.js.map +1 -1
- package/dist/puck-editor/internal/fields/required-field-label.d.ts +0 -1
- package/dist/puck-editor/internal/fields/required-field-label.js +1 -1
- package/dist/puck-editor/internal/fields/required-field-label.js.map +1 -1
- package/dist/puck-editor/internal/fields/required.d.ts +0 -1
- package/dist/puck-editor/internal/fields/rich-text/create-rich-text-field.d.ts +13 -3
- package/dist/puck-editor/internal/fields/rich-text/create-rich-text-field.js +32 -22
- package/dist/puck-editor/internal/fields/rich-text/create-rich-text-field.js.map +1 -1
- package/dist/puck-editor/internal/i18n.d.ts +2 -181
- package/dist/puck-editor/internal/i18n.js +2 -358
- package/dist/puck-editor/internal/i18n.js.map +1 -1
- package/dist/puck-editor/internal/locale.d.ts +0 -1
- package/dist/puck-editor/internal/localize.d.ts +1 -2
- package/dist/puck-editor/internal/localize.js.map +1 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/agent-bridge.d.ts +3 -3
- package/dist/puck-editor/internal/plugins/agent-plugin/agent-bridge.js +41 -32
- package/dist/puck-editor/internal/plugins/agent-plugin/agent-bridge.js.map +1 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/agent-info-panel.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/agent-info-panel.js +2 -2
- package/dist/puck-editor/internal/plugins/agent-plugin/agent-info-panel.js.map +1 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/agent-plugin.d.ts +3 -3
- package/dist/puck-editor/internal/plugins/agent-plugin/agent-plugin.js.map +1 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/apply-patch-to-puck.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/apply-patch-to-puck.js +1 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/apply-patch-to-puck.js.map +1 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/catalog.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/constants.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/create-page.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/find-component-location.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/help.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/index.d.ts +1 -2
- package/dist/puck-editor/internal/plugins/agent-plugin/index.js +1 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/index.js.map +1 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/list-media.d.ts +2 -2
- package/dist/puck-editor/internal/plugins/agent-plugin/list-media.js +4 -3
- package/dist/puck-editor/internal/plugins/agent-plugin/list-media.js.map +1 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/templates.d.ts +5 -6
- package/dist/puck-editor/internal/plugins/agent-plugin/templates.js +2 -2
- package/dist/puck-editor/internal/plugins/agent-plugin/templates.js.map +1 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/upload-media.d.ts +1 -2
- package/dist/puck-editor/internal/plugins/agent-plugin/use-agent-handle.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/use-agent-handle.js +2 -2
- package/dist/puck-editor/internal/plugins/agent-plugin/use-agent-handle.js.map +1 -1
- package/dist/puck-editor/internal/plugins/blocks-plugin/blocks-panel.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/blocks-plugin/blocks-panel.js +3 -3
- package/dist/puck-editor/internal/plugins/blocks-plugin/blocks-panel.js.map +1 -1
- package/dist/puck-editor/internal/plugins/blocks-plugin/blocks-plugin.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/blocks-plugin/blocks-plugin.js +1 -1
- package/dist/puck-editor/internal/plugins/blocks-plugin/blocks-plugin.js.map +1 -1
- package/dist/puck-editor/internal/plugins/blocks-plugin/index.d.ts +1 -2
- package/dist/puck-editor/internal/plugins/blocks-plugin/index.js +1 -1
- package/dist/puck-editor/internal/plugins/blocks-plugin/index.js.map +1 -1
- package/dist/puck-editor/internal/plugins/outline-plugin/index.d.ts +1 -2
- package/dist/puck-editor/internal/plugins/outline-plugin/index.js +1 -1
- package/dist/puck-editor/internal/plugins/outline-plugin/index.js.map +1 -1
- package/dist/puck-editor/internal/plugins/outline-plugin/outline-panel.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/outline-plugin/outline-panel.js +8 -8
- package/dist/puck-editor/internal/plugins/outline-plugin/outline-panel.js.map +1 -1
- package/dist/puck-editor/internal/plugins/outline-plugin/outline-plugin.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/outline-plugin/outline-plugin.js +1 -1
- package/dist/puck-editor/internal/plugins/outline-plugin/outline-plugin.js.map +1 -1
- package/dist/puck-editor/internal/plugins/outline-plugin/outline-tree.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/sections-plugin/index.d.ts +1 -2
- package/dist/puck-editor/internal/plugins/sections-plugin/index.js +1 -1
- package/dist/puck-editor/internal/plugins/sections-plugin/index.js.map +1 -1
- package/dist/puck-editor/internal/plugins/sections-plugin/sections-panel.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/sections-plugin/sections-panel.js +5 -5
- package/dist/puck-editor/internal/plugins/sections-plugin/sections-panel.js.map +1 -1
- package/dist/puck-editor/internal/plugins/sections-plugin/sections-plugin.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/sections-plugin/sections-plugin.js +1 -1
- package/dist/puck-editor/internal/plugins/sections-plugin/sections-plugin.js.map +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/ai-options-fields.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/ai-options-fields.js +2 -2
- package/dist/puck-editor/internal/plugins/templates-plugin/ai-options-fields.js.map +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/apply-vehicle-slot-constraints.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/apply-vehicle-slot-constraints.js +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/apply-vehicle-slot-constraints.js.map +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/component-template-modal.d.ts +1 -2
- package/dist/puck-editor/internal/plugins/templates-plugin/component-template-modal.js +3 -3
- package/dist/puck-editor/internal/plugins/templates-plugin/component-template-modal.js.map +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/custom-template-list.d.ts +1 -2
- package/dist/puck-editor/internal/plugins/templates-plugin/custom-template-list.js +224 -219
- package/dist/puck-editor/internal/plugins/templates-plugin/custom-template-list.js.map +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/index.d.ts +5 -6
- package/dist/puck-editor/internal/plugins/templates-plugin/index.js +5 -5
- package/dist/puck-editor/internal/plugins/templates-plugin/index.js.map +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/root-drop-zone.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/root-drop-zone.js +3 -3
- package/dist/puck-editor/internal/plugins/templates-plugin/root-drop-zone.js.map +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/template-form.d.ts +1 -2
- package/dist/puck-editor/internal/plugins/templates-plugin/template-form.js +17 -16
- package/dist/puck-editor/internal/plugins/templates-plugin/template-form.js.map +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/template-vehicles.d.ts +1 -2
- package/dist/puck-editor/internal/plugins/templates-plugin/template-vehicles.js +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/template-vehicles.js.map +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/templates-panel.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/templates-panel.js +171 -161
- package/dist/puck-editor/internal/plugins/templates-plugin/templates-panel.js.map +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/templates-plugin.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/templates-plugin.js +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/templates-plugin.js.map +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/templates.d.ts +2 -3
- package/dist/puck-editor/internal/plugins/templates-plugin/templates.js +9 -2
- package/dist/puck-editor/internal/plugins/templates-plugin/templates.js.map +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/use-template-dnd.d.ts +0 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/use-template-dnd.js +22 -20
- package/dist/puck-editor/internal/plugins/templates-plugin/use-template-dnd.js.map +1 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/use-templates.d.ts +14 -5
- package/dist/puck-editor/internal/plugins/templates-plugin/use-templates.js +23 -15
- package/dist/puck-editor/internal/plugins/templates-plugin/use-templates.js.map +1 -1
- package/dist/puck-editor/internal/puck-augmentation.d.ts +0 -1
- package/dist/puck-editor/internal/puck-editor-provider.d.ts +0 -1
- package/dist/puck-editor/internal/puck-node.d.ts +0 -1
- package/dist/puck-editor/internal/puck-props.d.ts +13 -0
- package/dist/puck-editor/internal/puck-props.js +2 -0
- package/dist/puck-editor/internal/puck-props.js.map +1 -0
- package/dist/puck-editor/internal/puck-wrapper.d.ts +25 -6
- package/dist/puck-editor/internal/puck-wrapper.js +124 -115
- package/dist/puck-editor/internal/puck-wrapper.js.map +1 -1
- package/dist/puck-editor/internal/render/cropped-image.d.ts +1 -2
- package/dist/puck-editor/internal/render/cropped-image.js.map +1 -1
- package/dist/puck-editor/internal/smart-actions/action-selection.d.ts +8 -0
- package/dist/puck-editor/internal/smart-actions/action-selection.js +10 -0
- package/dist/puck-editor/internal/smart-actions/action-selection.js.map +1 -0
- package/dist/puck-editor/internal/smart-actions/index.d.ts +10 -4
- package/dist/puck-editor/internal/smart-actions/index.js +27 -12
- package/dist/puck-editor/internal/smart-actions/index.js.map +1 -1
- package/dist/puck-editor/internal/smart-actions/new-page.d.ts +3 -2
- package/dist/puck-editor/internal/smart-actions/new-page.js +6 -6
- package/dist/puck-editor/internal/smart-actions/new-page.js.map +1 -1
- package/dist/puck-editor/internal/smart-actions/open-puck-editor.d.ts +3 -2
- package/dist/puck-editor/internal/smart-actions/open-puck-editor.js +49 -37
- package/dist/puck-editor/internal/smart-actions/open-puck-editor.js.map +1 -1
- package/dist/puck-editor/internal/ui/calendar.d.ts +0 -1
- package/dist/puck-editor/internal/ui/calendar.js +1 -1
- package/dist/puck-editor/internal/ui/calendar.js.map +1 -1
- package/dist/puck-editor/internal/ui/component-list-accordion.d.ts +0 -1
- package/dist/puck-editor/internal/ui/dialog.d.ts +0 -1
- package/dist/puck-editor/internal/ui/dialog.js +33 -20
- package/dist/puck-editor/internal/ui/dialog.js.map +1 -1
- package/dist/puck-editor/internal/ui/drawer-item-content.d.ts +0 -1
- package/dist/puck-editor/internal/ui/icon-button.d.ts +0 -1
- package/dist/puck-editor/internal/ui/icon-button.js +1 -1
- package/dist/puck-editor/internal/ui/icon-button.js.map +1 -1
- package/dist/puck-editor/internal/ui/load-error-notice.d.ts +6 -0
- package/dist/puck-editor/internal/ui/load-error-notice.js +81 -0
- package/dist/puck-editor/internal/ui/load-error-notice.js.map +1 -0
- package/dist/puck-editor/internal/ui/popover.d.ts +0 -1
- package/dist/puck-editor/internal/ui/popover.js +1 -1
- package/dist/puck-editor/internal/ui/popover.js.map +1 -1
- package/dist/puck-editor/internal/ui/required-mark.d.ts +0 -1
- package/dist/puck-editor/internal/ui/search-control.d.ts +3 -3
- package/dist/puck-editor/internal/ui/search-control.js +29 -26
- package/dist/puck-editor/internal/ui/search-control.js.map +1 -1
- package/dist/puck-editor/internal/ui/use-panel-search-focus.d.ts +0 -1
- package/dist/puck-editor/internal/use-puck-overlay.d.ts +1 -2
- package/dist/puck-editor/internal/use-puck-overlay.js +6 -5
- package/dist/puck-editor/internal/use-puck-overlay.js.map +1 -1
- package/dist/puck-editor/internal/utils.d.ts +0 -1
- package/dist/puck-editor/render.d.ts +2 -3
- package/dist/puck-editor/render.js +1 -1
- package/dist/puck-editor/render.js.map +1 -1
- package/dist/puck-editor/server.d.ts +3 -4
- package/dist/puck-editor/server.js +1 -1
- package/dist/puck-editor/server.js.map +1 -1
- package/dist/puck-editor/smart-actions.d.ts +1 -2
- package/dist/puck-editor/smart-actions.js +1 -1
- package/dist/puck-editor/smart-actions.js.map +1 -1
- package/dist/shared/cn.d.ts +0 -1
- package/dist/shared/i18n.d.ts +0 -1
- package/dist/shared/revalidate-path.d.ts +1 -0
- package/dist/shared/revalidate-path.js +2 -0
- package/dist/shared/revalidate-path.js.map +1 -0
- package/dist/shared/toolbar-action.d.ts +0 -1
- package/dist/shared/use-is-hydrated.d.ts +0 -1
- package/dist/shared/use-is-in-iframe.d.ts +0 -1
- package/dist/shared/use-is-in-iframe.js +1 -1
- package/dist/shared/use-is-in-iframe.js.map +1 -1
- package/dist/smart-actions/internal/assemble-smart-actions.d.ts +14 -0
- package/dist/smart-actions/internal/assemble-smart-actions.js +11 -0
- package/dist/smart-actions/internal/assemble-smart-actions.js.map +1 -0
- package/dist/smart-actions/internal/backend-edit-link.d.ts +6 -0
- package/dist/smart-actions/internal/backend-edit-link.js +60 -0
- package/dist/smart-actions/internal/backend-edit-link.js.map +1 -0
- package/dist/smart-actions/internal/get-smart-actions-context.d.ts +1 -2
- package/dist/smart-actions/internal/get-smart-actions-context.js +2 -2
- package/dist/smart-actions/internal/get-smart-actions-context.js.map +1 -1
- package/dist/smart-actions/internal/i18n.d.ts +1 -2
- package/dist/smart-actions/internal/i18n.js +16 -2
- package/dist/smart-actions/internal/i18n.js.map +1 -1
- package/dist/smart-actions/internal/logout-form.d.ts +2 -2
- package/dist/smart-actions/internal/logout-form.js +47 -40
- package/dist/smart-actions/internal/logout-form.js.map +1 -1
- package/dist/smart-actions/internal/refresh-page.d.ts +3 -2
- package/dist/smart-actions/internal/refresh-page.js +60 -53
- package/dist/smart-actions/internal/refresh-page.js.map +1 -1
- package/dist/smart-actions/internal/smart-actions-button.d.ts +22 -4
- package/dist/smart-actions/internal/smart-actions-button.js +36 -13
- package/dist/smart-actions/internal/smart-actions-button.js.map +1 -1
- package/dist/smart-actions/internal/smart-actions-config.d.ts +12 -4
- package/dist/smart-actions/internal/smart-actions-config.js +36 -80
- package/dist/smart-actions/internal/smart-actions-config.js.map +1 -1
- package/dist/smart-actions/internal/smart-actions-toolbar-client.d.ts +5 -11
- package/dist/smart-actions/internal/smart-actions-toolbar-client.js +13 -53
- package/dist/smart-actions/internal/smart-actions-toolbar-client.js.map +1 -1
- package/dist/smart-actions/internal/toolbar/smart-actions-toolbar.d.ts +1 -2
- package/dist/smart-actions/internal/toolbar/smart-actions-toolbar.js +4 -4
- package/dist/smart-actions/internal/toolbar/smart-actions-toolbar.js.map +1 -1
- package/dist/smart-actions/internal/toolbar/storage.d.ts +1 -2
- package/dist/smart-actions/internal/toolbar/storage.js.map +1 -1
- package/dist/smart-actions/internal/toolbar/types.d.ts +1 -2
- package/dist/smart-actions/internal/toolbar/types.js.map +1 -1
- package/dist/smart-actions/internal/toolbar/use-smart-actions-toolbar-mode.d.ts +1 -2
- package/dist/smart-actions/internal/toolbar/use-smart-actions-toolbar-mode.js +1 -1
- package/dist/smart-actions/internal/toolbar/use-smart-actions-toolbar-mode.js.map +1 -1
- package/dist/smart-actions/internal/ui/tooltip.d.ts +0 -1
- package/dist/smart-actions/internal/ui/tooltip.js +1 -1
- package/dist/smart-actions/internal/ui/tooltip.js.map +1 -1
- package/dist/smart-actions/internal/user-profile.d.ts +0 -1
- package/dist/smart-actions/internal/user-profile.js +71 -24
- package/dist/smart-actions/internal/user-profile.js.map +1 -1
- package/dist/smart-actions/server.d.ts +5 -4
- package/dist/smart-actions/server.js +2 -2
- package/dist/smart-actions/server.js.map +1 -1
- package/dist/theme.css +1 -1
- package/dist/visual-editor/index.d.ts +3 -4
- package/dist/visual-editor/index.js +3 -3
- package/dist/visual-editor/index.js.map +1 -1
- package/dist/visual-editor/internal/bridge/connector.d.ts +4 -3
- package/dist/visual-editor/internal/bridge/connector.js +22 -21
- package/dist/visual-editor/internal/bridge/connector.js.map +1 -1
- package/dist/visual-editor/internal/bridge/draft-mode-self-heal.d.ts +0 -1
- package/dist/visual-editor/internal/bridge/editor-auth-gate-server.d.ts +5 -3
- package/dist/visual-editor/internal/bridge/editor-auth-gate-server.js +7 -8
- package/dist/visual-editor/internal/bridge/editor-auth-gate-server.js.map +1 -1
- package/dist/visual-editor/internal/bridge/editor-auth-gate.d.ts +3 -3
- package/dist/visual-editor/internal/bridge/editor-auth-gate.js +4 -2
- package/dist/visual-editor/internal/bridge/editor-auth-gate.js.map +1 -1
- package/dist/visual-editor/internal/i18n.d.ts +3 -2
- package/dist/visual-editor/internal/i18n.js +32 -4
- package/dist/visual-editor/internal/i18n.js.map +1 -1
- package/dist/visual-editor/internal/overlays/drupal-origin.d.ts +1 -7
- package/dist/visual-editor/internal/overlays/drupal-origin.js +16 -3
- package/dist/visual-editor/internal/overlays/drupal-origin.js.map +1 -1
- package/dist/visual-editor/internal/overlays/edit-button.d.ts +5 -4
- package/dist/visual-editor/internal/overlays/edit-button.js +46 -44
- package/dist/visual-editor/internal/overlays/edit-button.js.map +1 -1
- package/dist/visual-editor/internal/overlays/edit-icon.d.ts +0 -1
- package/dist/visual-editor/internal/overlays/fragment/fragment-wrapper.d.ts +11 -2
- package/dist/visual-editor/internal/overlays/fragment/fragment-wrapper.js +18 -7
- package/dist/visual-editor/internal/overlays/fragment/fragment-wrapper.js.map +1 -1
- package/dist/visual-editor/internal/overlays/iframe-wrapper.d.ts +0 -1
- package/dist/visual-editor/internal/overlays/iframe-wrapper.js +1 -1
- package/dist/visual-editor/internal/overlays/iframe-wrapper.js.map +1 -1
- package/dist/visual-editor/internal/overlays/menu/menu-wrapper.d.ts +12 -3
- package/dist/visual-editor/internal/overlays/menu/menu-wrapper.js +14 -5
- package/dist/visual-editor/internal/overlays/menu/menu-wrapper.js.map +1 -1
- package/dist/visual-editor/internal/overlays/node/node-metadata.d.ts +4 -2
- package/dist/visual-editor/internal/overlays/node/node-metadata.js +10 -4
- package/dist/visual-editor/internal/overlays/node/node-metadata.js.map +1 -1
- package/dist/visual-editor/internal/overlays/node/node-wrapper.d.ts +5 -3
- package/dist/visual-editor/internal/overlays/node/node-wrapper.js +4 -2
- package/dist/visual-editor/internal/overlays/node/node-wrapper.js.map +1 -1
- package/dist/visual-editor/internal/overlays/paragraph/paragraph-wrapper.d.ts +11 -2
- package/dist/visual-editor/internal/overlays/paragraph/paragraph-wrapper.js +18 -7
- package/dist/visual-editor/internal/overlays/paragraph/paragraph-wrapper.js.map +1 -1
- package/dist/visual-editor/internal/revalidate-route.d.ts +0 -1
- package/dist/visual-editor/internal/revalidate-route.js +1 -1
- package/dist/visual-editor/internal/revalidate-route.js.map +1 -1
- package/dist/visual-editor/server.d.ts +6 -7
- package/dist/visual-editor/server.js +6 -6
- package/dist/visual-editor/server.js.map +1 -1
- package/package.json +19 -3
- package/dist/auth/index.d.ts.map +0 -1
- package/dist/auth/internal/config.d.ts.map +0 -1
- package/dist/auth/internal/draft-mode.d.ts.map +0 -1
- package/dist/auth/internal/editor-locale.d.ts.map +0 -1
- package/dist/auth/internal/handoff.d.ts.map +0 -1
- package/dist/auth/internal/has-session.d.ts.map +0 -1
- package/dist/auth/internal/logout.d.ts.map +0 -1
- package/dist/auth/internal/next-cookie-storage.d.ts.map +0 -1
- package/dist/auth/internal/nodehive-client.d.ts.map +0 -1
- package/dist/auth/internal/oauth-config.d.ts.map +0 -1
- package/dist/auth/internal/proxy-helpers.d.ts.map +0 -1
- package/dist/auth/internal/refresh.d.ts.map +0 -1
- package/dist/auth/internal/require-auth.d.ts.map +0 -1
- package/dist/auth/internal/return-to.d.ts.map +0 -1
- package/dist/auth/internal/routes/callback.d.ts.map +0 -1
- package/dist/auth/internal/routes/chips-exchange.d.ts.map +0 -1
- package/dist/auth/internal/routes/draft.d.ts.map +0 -1
- package/dist/auth/internal/routes/index.d.ts.map +0 -1
- package/dist/auth/internal/routes/login.d.ts.map +0 -1
- package/dist/auth/internal/routes/popup-done.d.ts.map +0 -1
- package/dist/auth/internal/routes/refresh.d.ts.map +0 -1
- package/dist/auth/internal/same-origin.d.ts.map +0 -1
- package/dist/auth/internal/session-gates.d.ts.map +0 -1
- package/dist/auth/internal/update-session.d.ts.map +0 -1
- package/dist/auth/internal/use-editor-login.d.ts.map +0 -1
- package/dist/auth/proxy.d.ts.map +0 -1
- package/dist/auth/react.d.ts.map +0 -1
- package/dist/auth/routes.d.ts.map +0 -1
- package/dist/auth/server.d.ts.map +0 -1
- package/dist/puck-editor/fields.d.ts.map +0 -1
- package/dist/puck-editor/index.d.ts.map +0 -1
- package/dist/puck-editor/internal/api/client.d.ts.map +0 -1
- package/dist/puck-editor/internal/api/config.d.ts.map +0 -1
- package/dist/puck-editor/internal/api/create-puck-api.d.ts.map +0 -1
- package/dist/puck-editor/internal/api/handlers/create-page.d.ts.map +0 -1
- package/dist/puck-editor/internal/api/handlers/entities.d.ts.map +0 -1
- package/dist/puck-editor/internal/api/handlers/publish.d.ts.map +0 -1
- package/dist/puck-editor/internal/api/handlers/template.d.ts.map +0 -1
- package/dist/puck-editor/internal/api/handlers/upload.d.ts.map +0 -1
- package/dist/puck-editor/internal/api/media-params.d.ts.map +0 -1
- package/dist/puck-editor/internal/api/media-upload.d.ts.map +0 -1
- package/dist/puck-editor/internal/api/space.d.ts.map +0 -1
- package/dist/puck-editor/internal/content-model.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor/allowed-types.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor/canvas-add-picker.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor/canvas-empty-state.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor/canvas-quick-add.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor/canvas-scroll.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor/component-icons.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor/component-item.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor/editor-action-bar.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor/editor-header-actions.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor/find-missing-required-fields.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor/grouped-drawer-panel.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor/grouped-entry-list.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor/header-save-button.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor/page-template-picker.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor/picker-entry-item.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor/picker-model.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor/publish-puck-data.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor/puck-editor.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor/section-template-modal.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor/use-scroll-lock-outside.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor-config.d.ts.map +0 -1
- package/dist/puck-editor/internal/editor-query-client.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/checkbox-group/checkbox-group-field.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/checkbox-group/create-checkbox-group-field.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/date-picker/create-date-picker-field.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/date-picker/date-picker.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/index.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/link-picker/anchor.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/link-picker/create-link-field.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/link-picker/humanize.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/link-picker/link-picker-control.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/link-picker/link-picker-field.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/link-picker/link-value.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/link-picker/rich-text-link-button.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/link-picker/richtext-extensions.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/link-picker/segmented-control.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/link-picker/types.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/media-array/create-media-array-field.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/media-array/media-array-field.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/media-array/reorder.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/media-selector/create-media-selector-field.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/media-selector/crop-editor-dialog.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/media-selector/crop-types.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/media-selector/extract-fields.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/media-selector/image-upload-form.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/media-selector/media-selector-field.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/media-selector/media-selector-modal.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/media-selector/use-debounced-value.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/media-selector/use-media-library.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/media-selector/video-upload-form.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/node-selector/create-node-selector-field.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/required-field-label.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/required.d.ts.map +0 -1
- package/dist/puck-editor/internal/fields/rich-text/create-rich-text-field.d.ts.map +0 -1
- package/dist/puck-editor/internal/i18n.d.ts.map +0 -1
- package/dist/puck-editor/internal/locale.d.ts.map +0 -1
- package/dist/puck-editor/internal/localize.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/agent-bridge.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/agent-info-panel.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/agent-plugin.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/apply-patch-to-puck.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/catalog.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/constants.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/create-page.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/find-component-location.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/help.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/index.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/list-media.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/templates.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/upload-media.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/agent-plugin/use-agent-handle.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/blocks-plugin/blocks-panel.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/blocks-plugin/blocks-plugin.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/blocks-plugin/index.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/outline-plugin/index.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/outline-plugin/outline-panel.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/outline-plugin/outline-plugin.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/outline-plugin/outline-tree.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/sections-plugin/index.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/sections-plugin/sections-panel.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/sections-plugin/sections-plugin.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/ai-options-fields.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/apply-vehicle-slot-constraints.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/component-template-modal.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/custom-template-list.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/index.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/root-drop-zone.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/template-form.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/template-vehicles.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/templates-panel.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/templates-plugin.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/templates.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/use-template-dnd.d.ts.map +0 -1
- package/dist/puck-editor/internal/plugins/templates-plugin/use-templates.d.ts.map +0 -1
- package/dist/puck-editor/internal/puck-augmentation.d.ts.map +0 -1
- package/dist/puck-editor/internal/puck-editor-provider.d.ts.map +0 -1
- package/dist/puck-editor/internal/puck-node.d.ts.map +0 -1
- package/dist/puck-editor/internal/puck-wrapper.d.ts.map +0 -1
- package/dist/puck-editor/internal/render/cropped-image.d.ts.map +0 -1
- package/dist/puck-editor/internal/smart-actions/index.d.ts.map +0 -1
- package/dist/puck-editor/internal/smart-actions/new-page.d.ts.map +0 -1
- package/dist/puck-editor/internal/smart-actions/open-puck-editor.d.ts.map +0 -1
- package/dist/puck-editor/internal/ui/calendar.d.ts.map +0 -1
- package/dist/puck-editor/internal/ui/component-list-accordion.d.ts.map +0 -1
- package/dist/puck-editor/internal/ui/dialog.d.ts.map +0 -1
- package/dist/puck-editor/internal/ui/drawer-item-content.d.ts.map +0 -1
- package/dist/puck-editor/internal/ui/icon-button.d.ts.map +0 -1
- package/dist/puck-editor/internal/ui/popover.d.ts.map +0 -1
- package/dist/puck-editor/internal/ui/required-mark.d.ts.map +0 -1
- package/dist/puck-editor/internal/ui/search-control.d.ts.map +0 -1
- package/dist/puck-editor/internal/ui/use-panel-search-focus.d.ts.map +0 -1
- package/dist/puck-editor/internal/use-puck-overlay.d.ts.map +0 -1
- package/dist/puck-editor/internal/utils.d.ts.map +0 -1
- package/dist/puck-editor/render.d.ts.map +0 -1
- package/dist/puck-editor/server.d.ts.map +0 -1
- package/dist/puck-editor/smart-actions.d.ts.map +0 -1
- package/dist/shared/cn.d.ts.map +0 -1
- package/dist/shared/i18n.d.ts.map +0 -1
- package/dist/shared/toolbar-action.d.ts.map +0 -1
- package/dist/shared/use-is-hydrated.d.ts.map +0 -1
- package/dist/shared/use-is-in-iframe.d.ts.map +0 -1
- package/dist/smart-actions/internal/get-smart-actions-context.d.ts.map +0 -1
- package/dist/smart-actions/internal/i18n.d.ts.map +0 -1
- package/dist/smart-actions/internal/logout-form.d.ts.map +0 -1
- package/dist/smart-actions/internal/refresh-page.d.ts.map +0 -1
- package/dist/smart-actions/internal/smart-actions-button.d.ts.map +0 -1
- package/dist/smart-actions/internal/smart-actions-config.d.ts.map +0 -1
- package/dist/smart-actions/internal/smart-actions-toolbar-client.d.ts.map +0 -1
- package/dist/smart-actions/internal/toolbar/smart-actions-toolbar.d.ts.map +0 -1
- package/dist/smart-actions/internal/toolbar/storage.d.ts.map +0 -1
- package/dist/smart-actions/internal/toolbar/types.d.ts.map +0 -1
- package/dist/smart-actions/internal/toolbar/use-smart-actions-toolbar-mode.d.ts.map +0 -1
- package/dist/smart-actions/internal/ui/tooltip.d.ts.map +0 -1
- package/dist/smart-actions/internal/user-profile.d.ts.map +0 -1
- package/dist/smart-actions/server.d.ts.map +0 -1
- package/dist/visual-editor/index.d.ts.map +0 -1
- package/dist/visual-editor/internal/bridge/connector.d.ts.map +0 -1
- package/dist/visual-editor/internal/bridge/draft-mode-self-heal.d.ts.map +0 -1
- package/dist/visual-editor/internal/bridge/editor-auth-gate-server.d.ts.map +0 -1
- package/dist/visual-editor/internal/bridge/editor-auth-gate.d.ts.map +0 -1
- package/dist/visual-editor/internal/i18n.d.ts.map +0 -1
- package/dist/visual-editor/internal/overlays/drupal-origin.d.ts.map +0 -1
- package/dist/visual-editor/internal/overlays/edit-button.d.ts.map +0 -1
- package/dist/visual-editor/internal/overlays/edit-icon.d.ts.map +0 -1
- package/dist/visual-editor/internal/overlays/fragment/fragment-wrapper.d.ts.map +0 -1
- package/dist/visual-editor/internal/overlays/iframe-wrapper.d.ts.map +0 -1
- package/dist/visual-editor/internal/overlays/menu/menu-wrapper.d.ts.map +0 -1
- package/dist/visual-editor/internal/overlays/node/node-metadata.d.ts.map +0 -1
- package/dist/visual-editor/internal/overlays/node/node-wrapper.d.ts.map +0 -1
- package/dist/visual-editor/internal/overlays/paragraph/paragraph-wrapper.d.ts.map +0 -1
- package/dist/visual-editor/internal/revalidate-route.d.ts.map +0 -1
- package/dist/visual-editor/server.d.ts.map +0 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.js","names":["AuthenticationError","DRAFT_MODE_COOKIE","appendClearedAuthCookie","NextCookieStorage","buildUserClient","REFRESH_TOKEN_MAX_AGE","MAX_RETRIES","BACKOFF_MS","ROTATION_GRACE_MS","refreshDeadlineMs","setRefreshDeadlineMsForTesting","ms","wait","Promise","resolve","setTimeout","withDeadline","promise","race","_","reject","timer","Error","unref","activeRefreshes","Map","recentRotations","rememberRotation","oldToken","result","expiresAt","Date","now","set","delete","getRecentRotation","entry","get","console","info","shouldRefreshSession","request","keys","cookieKeys","token","cookies","value","refreshToken","refresh_token","token_expires_at","expiresAtNumber","Number","tokenExpiresSoon","isFinite","refreshSession","response","config","refreshOnce","clearAuthCookies","name","Object","values","isAuthFailure","error","status","details","applyLoginResult","context","storage","maxAge","expires_in","undefined","tokenOptions","String","user","JSON","stringify","recent","existing","then","client","underlying","refreshWithRetries","finally","lastError","attempt","auth","warn"],"sources":["../../../src/auth/internal/refresh.ts"],"sourcesContent":["import type { NextRequest, NextResponse } from 'next/server';\nimport { AuthenticationError, type LoginResult } from 'nodehive-js';\n\nimport type { NodeHiveAuthConfig } from './config';\nimport { DRAFT_MODE_COOKIE } from './draft-mode';\nimport {\n appendClearedAuthCookie,\n NextCookieStorage,\n type ProxyContext,\n} from './next-cookie-storage';\nimport { buildUserClient } from './nodehive-client';\nimport { REFRESH_TOKEN_MAX_AGE } from './oauth-config';\n\nconst MAX_RETRIES = 3;\nconst BACKOFF_MS = 200;\nconst ROTATION_GRACE_MS = 30_000;\n// Hard ceiling for a whole refresh (incl. retries). The proxy awaits this on\n// nearly every request, and the SDK's token fetch has no timeout of its own, so\n// without this a slow/hung Drupal would stall every page load. On timeout the\n// error is non-auth → treated as transient → the stale session is kept.\nlet refreshDeadlineMs = 5_000;\n\nexport function setRefreshDeadlineMsForTesting(ms: number) {\n refreshDeadlineMs = ms;\n}\n\nconst wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\n\nfunction withDeadline<T>(promise: Promise<T>, ms: number): Promise<T> {\n return Promise.race([\n promise,\n new Promise<T>((_, reject) => {\n const timer = setTimeout(\n () => reject(new Error('Token refresh timed out')),\n ms\n );\n timer.unref?.();\n }),\n ]);\n}\n\n// Per-user dedup: prevents concurrent requests from racing on token rotation.\n// Note: This Map is per-isolate — on serverless deployments, dedup is best-effort\n// and not guaranteed across concurrent isolates. On long-running servers it works fully.\nconst activeRefreshes = new Map<string, Promise<LoginResult>>();\n\n// Grace cache for recently rotated refresh tokens.\n//\n// OAuth refresh tokens are single-use: each successful refresh invalidates the\n// previous one. But the browser can have parallel requests in flight carrying\n// the old refresh-token cookie when the rotation happens. Without this cache,\n// stale requests arriving just AFTER the original refresh completed (so the\n// `activeRefreshes` dedup map is already empty) trigger a second refresh that\n// fails with invalid_grant and logs the user out.\n//\n// Mapping: old refresh_token → fresh LoginResult, valid for ROTATION_GRACE_MS.\nconst recentRotations = new Map<\n string,\n { result: LoginResult; expiresAt: number }\n>();\n\nfunction rememberRotation(oldToken: string, result: LoginResult) {\n const expiresAt = Date.now() + ROTATION_GRACE_MS;\n recentRotations.set(oldToken, { result, expiresAt });\n setTimeout(\n () => recentRotations.delete(oldToken),\n ROTATION_GRACE_MS\n ).unref?.();\n}\n\nfunction getRecentRotation(oldToken: string): LoginResult | null {\n const entry = recentRotations.get(oldToken);\n if (!entry) return null;\n if (entry.expiresAt < Date.now()) {\n recentRotations.delete(oldToken);\n return null;\n }\n console.info('[Refresh] grace cache hit — stale refresh-token reused');\n return entry.result;\n}\n\nexport function shouldRefreshSession(request: NextRequest): boolean {\n const keys = NextCookieStorage.cookieKeys();\n const token = request.cookies.get(keys.token)?.value;\n const refreshToken = request.cookies.get(keys.refresh_token)?.value;\n const expiresAt = request.cookies.get(keys.token_expires_at)?.value;\n\n if (!refreshToken) return false;\n\n const expiresAtNumber = expiresAt ? Number(expiresAt) : null;\n const tokenExpiresSoon =\n typeof expiresAtNumber === 'number' &&\n Number.isFinite(expiresAtNumber) &&\n expiresAtNumber <= Date.now() + 60_000;\n\n return !token || tokenExpiresSoon;\n}\n\n/**\n * Mutates request.cookies and sets Set-Cookie on `response`; the caller must\n * have created `response` with `{ request }` so the mutations are forwarded via\n * x-middleware-request-* headers. Throws on failure — caller decides handling.\n */\nexport async function refreshSession(\n request: NextRequest,\n response: NextResponse,\n config: NodeHiveAuthConfig\n): Promise<void> {\n const keys = NextCookieStorage.cookieKeys();\n const refreshToken = request.cookies.get(keys.refresh_token)?.value;\n\n if (!refreshToken) {\n throw new AuthenticationError('No refresh token available');\n }\n\n await refreshOnce(refreshToken, { request, response }, config);\n}\n\nexport function clearAuthCookies(\n request: NextRequest,\n response: NextResponse\n): void {\n const keys = NextCookieStorage.cookieKeys();\n // Draft cookie included: a dead session must not strand the visitor in\n // token-less draft mode. Raw headers — middleware cannot call draftMode().\n for (const name of [...Object.values(keys), DRAFT_MODE_COOKIE]) {\n request.cookies.delete(name);\n appendClearedAuthCookie(response, name);\n }\n}\n\n// Auth failure (invalid/expired refresh token) vs transient (network, timeout,\n// 5xx): transient errors keep the session, auth failures clear it.\nexport function isAuthFailure(error: unknown): boolean {\n if (!(error instanceof AuthenticationError)) return false;\n const status = error.details?.status;\n return status === 400 || status === 401 || status === 403;\n}\n\n// When the refresh is served from the grace cache or an in-flight dedup, the SDK\n// never ran for THIS request, so its cookies were never written. Mirror the\n// tokens onto the current request/response so this navigation renders logged-in\n// and the browser receives the fresh cookies.\nasync function applyLoginResult(\n context: ProxyContext,\n result: LoginResult\n): Promise<LoginResult> {\n const storage = new NextCookieStorage(context);\n const maxAge = result.expires_in ?? undefined;\n const tokenOptions = maxAge ? { maxAge } : undefined;\n\n await storage.set('token', result.token, tokenOptions);\n if (result.refresh_token) {\n await storage.set('refresh_token', result.refresh_token, {\n maxAge: REFRESH_TOKEN_MAX_AGE,\n });\n }\n if (maxAge) {\n await storage.set(\n 'token_expires_at',\n String(Date.now() + maxAge * 1000),\n tokenOptions\n );\n }\n if (result.user) {\n await storage.set(\n 'user_details',\n typeof result.user === 'string'\n ? result.user\n : JSON.stringify(result.user),\n tokenOptions\n );\n }\n return result;\n}\n\nfunction refreshOnce(\n refreshToken: string,\n context: ProxyContext,\n config: NodeHiveAuthConfig\n): Promise<LoginResult> {\n const recent = getRecentRotation(refreshToken);\n if (recent) return applyLoginResult(context, recent);\n\n const existing = activeRefreshes.get(refreshToken);\n if (existing) {\n return withDeadline(\n existing.then((result) => applyLoginResult(context, result)),\n refreshDeadlineMs\n );\n }\n\n const client = buildUserClient(config, context);\n\n // rememberRotation and the dedup cleanup hang off the underlying refresh, NOT\n // the deadline-raced promise: if Drupal answers after the deadline the\n // refresh token is already consumed, so it must still be grace-cached or the\n // next request gets invalid_grant.\n const underlying = refreshWithRetries(client)\n .then((result) => {\n rememberRotation(refreshToken, result);\n return result;\n })\n .finally(() => {\n activeRefreshes.delete(refreshToken);\n });\n\n activeRefreshes.set(refreshToken, underlying);\n return withDeadline(underlying, refreshDeadlineMs);\n}\n\nasync function refreshWithRetries(\n client: ReturnType<typeof buildUserClient>\n): Promise<LoginResult> {\n let lastError: unknown;\n\n for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {\n try {\n return await client.auth.refreshToken();\n } catch (error) {\n lastError = error;\n\n // Don't retry auth failures (invalid/expired refresh token)\n if (isAuthFailure(error)) {\n throw error;\n }\n\n if (attempt < MAX_RETRIES) {\n console.warn(`[Refresh] Attempt ${attempt} failed, retrying...`, error);\n await wait(BACKOFF_MS * 2 ** (attempt - 1));\n }\n }\n }\n\n throw lastError;\n}\n"],"mappings":"AACA,SAASA,mBAAmB,QAA0B,aAAa;AAGnE,SAASC,iBAAiB,QAAQ,cAAc;AAChD,SACEC,uBAAuB,EACvBC,iBAAiB,QAEZ,uBAAuB;AAC9B,SAASC,eAAe,QAAQ,mBAAmB;AACnD,SAASC,qBAAqB,QAAQ,gBAAgB;AAEtD,MAAMC,WAAW,GAAG,CAAC;AACrB,MAAMC,UAAU,GAAG,GAAG;AACtB,MAAMC,iBAAiB,GAAG,MAAM;AAChC;AACA;AACA;AACA;AACA,IAAIC,iBAAiB,GAAG,KAAK;AAE7B,OAAO,SAASC,8BAA8BA,CAACC,E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U,MAAM,CAACa,YAAY,CAAC;EACtC,CAAC,CAAC;EAEJvB,eAAe,CAACS,GAAG,CAACc,YAAY,EAAEkC,UAAU,CAAC;EAC7C,OAAOjE,YAAY,CAACiE,UAAU,EAAExE,iBAAiB,CAAC;AACpD;AAEA,eAAeyE,kBAAkBA,CAC/BF,MAA0C,EACpB;EACtB,IAAII,SAAkB;EAEtB,KAAK,IAAIC,OAAO,GAAG,CAAC,EAAEA,OAAO,IAAI/E,WAAW,EAAE+E,OAAO,EAAE,EAAE;IACvD,IAAI;MACF,OAAO,MAAML,MAAM,CAACM,IAAI,CAACvC,YAAY,CAAC,CAAC;IACzC,CAAC,CAAC,OAAOgB,KAAK,EAAE;MACdqB,SAAS,GAAGrB,KAAK;;MAEjB;MACA,IAAID,aAAa,CAACC,KAAK,CAAC,EAAE;QACxB,MAAMA,KAAK;MACb;MAEA,IAAIsB,OAAO,GAAG/E,WAAW,EAAE;QACzBgC,OAAO,CAACiD,IAAI,CAAC,qBAAqBF,OAAO,sBAAsB,EAAEtB,KAAK,CAAC;QACvE,MAAMnD,IAAI,CAACL,UAAU,GAAG,CAAC,KAAK8E,OAAO,GAAG,CAAC,CAAC,CAAC;MAC7C;IACF;EACF;EAEA,MAAMD,SAAS;AACjB","ignoreList":[]}
|
|
1
|
+
{"version":3,"file":"refresh.js","names":["AuthenticationError","DRAFT_MODE_COOKIE","appendClearedAuthCookie","NextCookieStorage","buildUserClient","REFRESH_TOKEN_MAX_AGE","MAX_RETRIES","BACKOFF_MS","ROTATION_GRACE_MS","refreshDeadlineMs","setRefreshDeadlineMsForTesting","ms","wait","Promise","resolve","setTimeout","withDeadline","promise","race","_","reject","timer","Error","unref","activeRefreshes","Map","recentRotations","rememberRotation","oldToken","result","expiresAt","Date","now","set","delete","getRecentRotation","entry","get","console","info","shouldRefreshSession","request","keys","cookieKeys","token","cookies","value","refreshToken","refresh_token","token_expires_at","expiresAtNumber","Number","tokenExpiresSoon","isFinite","refreshSession","response","config","refreshOnce","clearAuthCookies","name","Object","values","isAuthFailure","error","status","details","applyLoginResult","context","storage","maxAge","expires_in","undefined","tokenOptions","String","user","JSON","stringify","recent","existing","then","client","underlying","refreshWithRetries","finally","lastError","attempt","auth","warn"],"sources":["../../../src/auth/internal/refresh.ts"],"sourcesContent":["import type { NextRequest, NextResponse } from 'next/server';\nimport { AuthenticationError, type LoginResult } from 'nodehive-js';\n\nimport type { NodeHiveAuthConfig } from './config.ts';\nimport { DRAFT_MODE_COOKIE } from './draft-mode.ts';\nimport {\n appendClearedAuthCookie,\n NextCookieStorage,\n type ProxyContext,\n} from './next-cookie-storage.ts';\nimport { buildUserClient } from './nodehive-client.ts';\nimport { REFRESH_TOKEN_MAX_AGE } from './oauth-config.ts';\n\nconst MAX_RETRIES = 3;\nconst BACKOFF_MS = 200;\nconst ROTATION_GRACE_MS = 30_000;\n// Hard ceiling for a whole refresh (incl. retries). The proxy awaits this on\n// nearly every request, and the SDK's token fetch has no timeout of its own, so\n// without this a slow/hung Drupal would stall every page load. On timeout the\n// error is non-auth → treated as transient → the stale session is kept.\nlet refreshDeadlineMs = 5_000;\n\nexport function setRefreshDeadlineMsForTesting(ms: number) {\n refreshDeadlineMs = ms;\n}\n\nconst wait = (ms: number) => new Promise((resolve) => setTimeout(resolve, ms));\n\nfunction withDeadline<T>(promise: Promise<T>, ms: number): Promise<T> {\n return Promise.race([\n promise,\n new Promise<T>((_, reject) => {\n const timer = setTimeout(\n () => reject(new Error('Token refresh timed out')),\n ms\n );\n timer.unref?.();\n }),\n ]);\n}\n\n// Per-user dedup: prevents concurrent requests from racing on token rotation.\n// Note: This Map is per-isolate — on serverless deployments, dedup is best-effort\n// and not guaranteed across concurrent isolates. On long-running servers it works fully.\nconst activeRefreshes = new Map<string, Promise<LoginResult>>();\n\n// Grace cache for recently rotated refresh tokens.\n//\n// OAuth refresh tokens are single-use: each successful refresh invalidates the\n// previous one. But the browser can have parallel requests in flight carrying\n// the old refresh-token cookie when the rotation happens. Without this cache,\n// stale requests arriving just AFTER the original refresh completed (so the\n// `activeRefreshes` dedup map is already empty) trigger a second refresh that\n// fails with invalid_grant and logs the user out.\n//\n// Mapping: old refresh_token → fresh LoginResult, valid for ROTATION_GRACE_MS.\nconst recentRotations = new Map<\n string,\n { result: LoginResult; expiresAt: number }\n>();\n\nfunction rememberRotation(oldToken: string, result: LoginResult) {\n const expiresAt = Date.now() + ROTATION_GRACE_MS;\n recentRotations.set(oldToken, { result, expiresAt });\n setTimeout(\n () => recentRotations.delete(oldToken),\n ROTATION_GRACE_MS\n ).unref?.();\n}\n\nfunction getRecentRotation(oldToken: string): LoginResult | null {\n const entry = recentRotations.get(oldToken);\n if (!entry) return null;\n if (entry.expiresAt < Date.now()) {\n recentRotations.delete(oldToken);\n return null;\n }\n console.info('[Refresh] grace cache hit — stale refresh-token reused');\n return entry.result;\n}\n\nexport function shouldRefreshSession(request: NextRequest): boolean {\n const keys = NextCookieStorage.cookieKeys();\n const token = request.cookies.get(keys.token)?.value;\n const refreshToken = request.cookies.get(keys.refresh_token)?.value;\n const expiresAt = request.cookies.get(keys.token_expires_at)?.value;\n\n if (!refreshToken) return false;\n\n const expiresAtNumber = expiresAt ? Number(expiresAt) : null;\n const tokenExpiresSoon =\n typeof expiresAtNumber === 'number' &&\n Number.isFinite(expiresAtNumber) &&\n expiresAtNumber <= Date.now() + 60_000;\n\n return !token || tokenExpiresSoon;\n}\n\n/**\n * Mutates request.cookies and sets Set-Cookie on `response`; the caller must\n * have created `response` with `{ request }` so the mutations are forwarded via\n * x-middleware-request-* headers. Throws on failure — caller decides handling.\n */\nexport async function refreshSession(\n request: NextRequest,\n response: NextResponse,\n config: NodeHiveAuthConfig\n): Promise<void> {\n const keys = NextCookieStorage.cookieKeys();\n const refreshToken = request.cookies.get(keys.refresh_token)?.value;\n\n if (!refreshToken) {\n throw new AuthenticationError('No refresh token available');\n }\n\n await refreshOnce(refreshToken, { request, response }, config);\n}\n\nexport function clearAuthCookies(\n request: NextRequest,\n response: NextResponse\n): void {\n const keys = NextCookieStorage.cookieKeys();\n // Draft cookie included: a dead session must not strand the visitor in\n // token-less draft mode. Raw headers — middleware cannot call draftMode().\n for (const name of [...Object.values(keys), DRAFT_MODE_COOKIE]) {\n request.cookies.delete(name);\n appendClearedAuthCookie(response, name);\n }\n}\n\n// Auth failure (invalid/expired refresh token) vs transient (network, timeout,\n// 5xx): transient errors keep the session, auth failures clear it.\nexport function isAuthFailure(error: unknown): boolean {\n if (!(error instanceof AuthenticationError)) return false;\n const status = error.details?.status;\n return status === 400 || status === 401 || status === 403;\n}\n\n// When the refresh is served from the grace cache or an in-flight dedup, the SDK\n// never ran for THIS request, so its cookies were never written. Mirror the\n// tokens onto the current request/response so this navigation renders logged-in\n// and the browser receives the fresh cookies.\nasync function applyLoginResult(\n context: ProxyContext,\n result: LoginResult\n): Promise<LoginResult> {\n const storage = new NextCookieStorage(context);\n const maxAge = result.expires_in ?? undefined;\n const tokenOptions = maxAge ? { maxAge } : undefined;\n\n await storage.set('token', result.token, tokenOptions);\n if (result.refresh_token) {\n await storage.set('refresh_token', result.refresh_token, {\n maxAge: REFRESH_TOKEN_MAX_AGE,\n });\n }\n if (maxAge) {\n await storage.set(\n 'token_expires_at',\n String(Date.now() + maxAge * 1000),\n tokenOptions\n );\n }\n if (result.user) {\n await storage.set(\n 'user_details',\n typeof result.user === 'string'\n ? result.user\n : JSON.stringify(result.user),\n tokenOptions\n );\n }\n return result;\n}\n\nfunction refreshOnce(\n refreshToken: string,\n context: ProxyContext,\n config: NodeHiveAuthConfig\n): Promise<LoginResult> {\n const recent = getRecentRotation(refreshToken);\n if (recent) return applyLoginResult(context, recent);\n\n const existing = activeRefreshes.get(refreshToken);\n if (existing) {\n return withDeadline(\n existing.then((result) => applyLoginResult(context, result)),\n refreshDeadlineMs\n );\n }\n\n const client = buildUserClient(config, context);\n\n // rememberRotation and the dedup cleanup hang off the underlying refresh, NOT\n // the deadline-raced promise: if Drupal answers after the deadline the\n // refresh token is already consumed, so it must still be grace-cached or the\n // next request gets invalid_grant.\n const underlying = refreshWithRetries(client)\n .then((result) => {\n rememberRotation(refreshToken, result);\n return result;\n })\n .finally(() => {\n activeRefreshes.delete(refreshToken);\n });\n\n activeRefreshes.set(refreshToken, underlying);\n return withDeadline(underlying, refreshDeadlineMs);\n}\n\nasync function refreshWithRetries(\n client: ReturnType<typeof buildUserClient>\n): Promise<LoginResult> {\n let lastError: unknown;\n\n for (let attempt = 1; attempt <= MAX_RETRIES; attempt++) {\n try {\n return await client.auth.refreshToken();\n } catch (error) {\n lastError = error;\n\n // Don't retry auth failures (invalid/expired refresh token)\n if (isAuthFailure(error)) {\n throw error;\n }\n\n if (attempt < MAX_RETRIES) {\n console.warn(`[Refresh] Attempt ${attempt} failed, retrying...`, error);\n await wait(BACKOFF_MS * 2 ** (attempt - 1));\n }\n }\n }\n\n throw lastError;\n}\n"],"mappings":"AACA,SAASA,mBAAmB,QAA0B,aAAa;AAGnE,SAASC,iBAAiB,QAAQ,iBAAiB;AACnD,SACEC,uBAAuB,EACvBC,iBAAiB,QAEZ,0BAA0B;AACjC,SAASC,eAAe,QAAQ,sBAAsB;AACtD,SAASC,qBAAqB,QAAQ,mBAAmB;AAEzD,MAAMC,WAAW,GAAG,CAAC;AACrB,MAAMC,UAAU,GAAG,GAAG;AACtB,MAAMC,iBAAiB,GAAG,MAAM;AAChC;AACA;AACA;AACA;AACA,IAAIC,iBAAiB,GAAG,KAAK;AAE7B,OAAO,SAASC,8BAA8BA,CAACC,EAAU,EAAE;EACzDF,iBAAiB,GAAGE,EAAE;AACxB;AAEA,MAAMC,IAAI,GAAID,EAAU,IAAK,IAAIE,OAAO,CAAEC,OAAO,IAAKC,UAAU,CAACD,OAAO,EAAEH,EAAE,CAAC,CAAC;AAE9E,SAASK,YAAYA,CAAIC,OAAmB,EAAEN,EAAU,EAAc;EACpE,OAAOE,OAAO,CAACK,IAAI,CAAC,CAClBD,OAAO,EACP,IAAIJ,OAAO,CAAI,CAACM,CAAC,EAAEC,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O,EAAE,EAAE;IACvD,IAAI;MACF,OAAO,MAAML,MAAM,CAACM,IAAI,CAACvC,YAAY,CAAC,CAAC;IACzC,CAAC,CAAC,OAAOgB,KAAK,EAAE;MACdqB,SAAS,GAAGrB,KAAK;;MAEjB;MACA,IAAID,aAAa,CAACC,KAAK,CAAC,EAAE;QACxB,MAAMA,KAAK;MACb;MAEA,IAAIsB,OAAO,GAAG/E,WAAW,EAAE;QACzBgC,OAAO,CAACiD,IAAI,CAAC,qBAAqBF,OAAO,sBAAsB,EAAEtB,KAAK,CAAC;QACvE,MAAMnD,IAAI,CAACL,UAAU,GAAG,CAAC,KAAK8E,OAAO,GAAG,CAAC,CAAC,CAAC;MAC7C;IACF;EACF;EAEA,MAAMD,SAAS;AACjB","ignoreList":[]}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"require-auth.js","names":["checkHasSession","requireAuth","Response","status","headers"],"sources":["../../../src/auth/internal/require-auth.ts"],"sourcesContent":["import { checkHasSession } from './has-session';\n\nexport async function requireAuth(): Promise<Response | null> {\n if (await checkHasSession()) return null;\n\n return new Response('Unauthorized', {\n status: 401,\n headers: { 'Content-Type': 'text/plain' },\n });\n}\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,
|
|
1
|
+
{"version":3,"file":"require-auth.js","names":["checkHasSession","requireAuth","Response","status","headers"],"sources":["../../../src/auth/internal/require-auth.ts"],"sourcesContent":["import { checkHasSession } from './has-session.ts';\n\nexport async function requireAuth(): Promise<Response | null> {\n if (await checkHasSession()) return null;\n\n return new Response('Unauthorized', {\n status: 401,\n headers: { 'Content-Type': 'text/plain' },\n });\n}\n"],"mappings":"AAAA,SAASA,eAAe,QAAQ,kBAAkB;AAElD,OAAO,eAAeC,WAAWA,CAAA,EAA6B;EAC5D,IAAI,MAAMD,eAAe,CAAC,CAAC,EAAE,OAAO,IAAI;EAExC,OAAO,IAAIE,QAAQ,CAAC,cAAc,EAAE;IAClCC,MAAM,EAAE,GAAG;IACXC,OAAO,EAAE;MAAE,cAAc,EAAE;IAAa;EAC1C,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -0,0 +1,17 @@
|
|
|
1
|
+
import { type ProxyContext } from './next-cookie-storage.js';
|
|
2
|
+
export declare function extractRoles(userDetails: unknown): string[];
|
|
3
|
+
/**
|
|
4
|
+
* The Drupal roles carried by the current session's `user_details` cookie.
|
|
5
|
+
*
|
|
6
|
+
* Same source of truth as the internal draft-mode role gate — no new data path.
|
|
7
|
+
* UI-gating only: real authorization lives in Drupal, which authorizes every
|
|
8
|
+
* fetch by the actual token.
|
|
9
|
+
*
|
|
10
|
+
* Fails closed: no session / no `user_details` cookie, or unparseable details →
|
|
11
|
+
* `[]`.
|
|
12
|
+
*
|
|
13
|
+
* Pass the proxy context where cookies were just written through it (refresh
|
|
14
|
+
* route) so the read sees the fresh `user_details`.
|
|
15
|
+
*/
|
|
16
|
+
export declare function getUserRoles(proxyContext?: ProxyContext): Promise<string[]>;
|
|
17
|
+
export declare function hasAnyRole(userRoles: string[], required: string[]): boolean;
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
import { NextCookieStorage } from "./next-cookie-storage.js";
|
|
2
|
+
|
|
3
|
+
// user_details is the Drupal core REST user entity: roles come as
|
|
4
|
+
// [{ target_id: 'editor' }]; plain string arrays are accepted too.
|
|
5
|
+
export function extractRoles(userDetails) {
|
|
6
|
+
const roles = userDetails?.roles;
|
|
7
|
+
if (!Array.isArray(roles)) return [];
|
|
8
|
+
return roles.map(role => typeof role === 'string' ? role : role?.target_id).filter(id => typeof id === 'string');
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
/**
|
|
12
|
+
* The Drupal roles carried by the current session's `user_details` cookie.
|
|
13
|
+
*
|
|
14
|
+
* Same source of truth as the internal draft-mode role gate — no new data path.
|
|
15
|
+
* UI-gating only: real authorization lives in Drupal, which authorizes every
|
|
16
|
+
* fetch by the actual token.
|
|
17
|
+
*
|
|
18
|
+
* Fails closed: no session / no `user_details` cookie, or unparseable details →
|
|
19
|
+
* `[]`.
|
|
20
|
+
*
|
|
21
|
+
* Pass the proxy context where cookies were just written through it (refresh
|
|
22
|
+
* route) so the read sees the fresh `user_details`.
|
|
23
|
+
*/
|
|
24
|
+
export async function getUserRoles(proxyContext) {
|
|
25
|
+
const raw = await new NextCookieStorage(proxyContext).get('user_details');
|
|
26
|
+
if (!raw) return [];
|
|
27
|
+
try {
|
|
28
|
+
return extractRoles(JSON.parse(raw));
|
|
29
|
+
} catch {
|
|
30
|
+
return [];
|
|
31
|
+
}
|
|
32
|
+
}
|
|
33
|
+
|
|
34
|
+
// Any-of: matches the draft-mode role gate semantic. Empty `required` → false
|
|
35
|
+
// (fails closed).
|
|
36
|
+
export function hasAnyRole(userRoles, required) {
|
|
37
|
+
return required.some(role => userRoles.includes(role));
|
|
38
|
+
}
|
|
39
|
+
//# sourceMappingURL=roles.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"roles.js","names":["NextCookieStorage","extractRoles","userDetails","roles","Array","isArray","map","role","target_id","filter","id","getUserRoles","proxyContext","raw","get","JSON","parse","hasAnyRole","userRoles","required","some","includes"],"sources":["../../../src/auth/internal/roles.ts"],"sourcesContent":["import { NextCookieStorage, type ProxyContext } from './next-cookie-storage.ts';\n\n// user_details is the Drupal core REST user entity: roles come as\n// [{ target_id: 'editor' }]; plain string arrays are accepted too.\nexport function extractRoles(userDetails: unknown): string[] {\n const roles = (userDetails as { roles?: unknown } | null)?.roles;\n if (!Array.isArray(roles)) return [];\n return roles\n .map((role) =>\n typeof role === 'string'\n ? role\n : (role as { target_id?: unknown } | null)?.target_id\n )\n .filter((id): id is string => typeof id === 'string');\n}\n\n/**\n * The Drupal roles carried by the current session's `user_details` cookie.\n *\n * Same source of truth as the internal draft-mode role gate — no new data path.\n * UI-gating only: real authorization lives in Drupal, which authorizes every\n * fetch by the actual token.\n *\n * Fails closed: no session / no `user_details` cookie, or unparseable details →\n * `[]`.\n *\n * Pass the proxy context where cookies were just written through it (refresh\n * route) so the read sees the fresh `user_details`.\n */\nexport async function getUserRoles(\n proxyContext?: ProxyContext\n): Promise<string[]> {\n const raw = await new NextCookieStorage(proxyContext).get('user_details');\n if (!raw) return [];\n\n try {\n return extractRoles(JSON.parse(raw));\n } catch {\n return [];\n }\n}\n\n// Any-of: matches the draft-mode role gate semantic. Empty `required` → false\n// (fails closed).\nexport function hasAnyRole(userRoles: string[], required: string[]): boolean {\n return required.some((role) => userRoles.includes(role));\n}\n"],"mappings":"AAAA,SAASA,iBAAiB,QAA2B,0BAA0B;;AAE/E;AACA;AACA,OAAO,SAASC,YAAYA,CAACC,WAAoB,EAAY;EAC3D,MAAMC,KAAK,GAAID,WAAW,EAAiCC,KAAK;EAChE,IAAI,CAACC,KAAK,CAACC,OAAO,CAACF,KAAK,CAAC,EAAE,OAAO,EAAE;EACpC,OAAOA,KAAK,CACTG,GAAG,CAAEC,IAAI,IACR,OAAOA,IAAI,KAAK,QAAQ,GACpBA,IAAI,GACHA,IAAI,EAAqCC,SAChD,CAAC,CACAC,MAAM,CAAEC,EAAE,IAAmB,OAAOA,EAAE,KAAK,QAAQ,CAAC;AACzD;;AAEA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,eAAeC,YAAYA,CAChCC,YAA2B,EACR;EACnB,MAAMC,GAAG,GAAG,MAAM,IAAIb,iBAAiB,CAACY,YAAY,CAAC,CAACE,GAAG,CAAC,cAAc,CAAC;EACzE,IAAI,CAACD,GAAG,EAAE,OAAO,EAAE;EAEnB,IAAI;IACF,OAAOZ,YAAY,CAACc,IAAI,CAACC,KAAK,CAACH,GAAG,CAAC,CAAC;EACtC,CAAC,CAAC,MAAM;IACN,OAAO,EAAE;EACX;AACF;;AAEA;AACA;AACA,OAAO,SAASI,UAAUA,CAACC,SAAmB,EAAEC,QAAkB,EAAW;EAC3E,OAAOA,QAAQ,CAACC,IAAI,CAAEb,IAAI,IAAKW,SAAS,CAACG,QAAQ,CAACd,IAAI,CAAC,CAAC;AAC1D","ignoreList":[]}
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { NextResponse, type NextRequest } from 'next/server';
|
|
2
|
-
import type { NodeHiveAuthConfig } from '../config';
|
|
2
|
+
import type { NodeHiveAuthConfig } from '../config.js';
|
|
3
3
|
export type CallbackError = 'state' | 'exchange' | 'unavailable' | 'denied';
|
|
4
4
|
export interface CallbackOptions {
|
|
5
5
|
/** Page path (without locale prefix) to bounce to on error. */
|
|
@@ -8,4 +8,3 @@ export interface CallbackOptions {
|
|
|
8
8
|
popupReturnTo: string;
|
|
9
9
|
}
|
|
10
10
|
export declare function handleCallback(request: NextRequest, config: NodeHiveAuthConfig, options: CallbackOptions): Promise<NextResponse<unknown>>;
|
|
11
|
-
//# sourceMappingURL=callback.d.ts.map
|
|
@@ -1,12 +1,12 @@
|
|
|
1
1
|
import { cookies } from 'next/headers';
|
|
2
2
|
import { NextResponse } from 'next/server';
|
|
3
3
|
import { AuthenticationError } from 'nodehive-js';
|
|
4
|
-
import { enablePersistentDraftMode, shouldEnableDraftMode } from
|
|
5
|
-
import { encryptHandoff } from
|
|
6
|
-
import { NextCookieStorage } from
|
|
7
|
-
import { buildUserClient } from
|
|
8
|
-
import { getRedirectUri, getRequestOrigin } from
|
|
9
|
-
import { validateReturnTo } from
|
|
4
|
+
import { enablePersistentDraftMode, shouldEnableDraftMode } from "../draft-mode.js";
|
|
5
|
+
import { encryptHandoff } from "../handoff.js";
|
|
6
|
+
import { NextCookieStorage } from "../next-cookie-storage.js";
|
|
7
|
+
import { buildUserClient } from "../nodehive-client.js";
|
|
8
|
+
import { getRedirectUri, getRequestOrigin } from "../oauth-config.js";
|
|
9
|
+
import { validateReturnTo } from "../return-to.js";
|
|
10
10
|
export async function handleCallback(request, config, options) {
|
|
11
11
|
const cookieStore = await cookies();
|
|
12
12
|
const keys = NextCookieStorage.cookieKeys();
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"callback.js","names":["cookies","NextResponse","AuthenticationError","enablePersistentDraftMode","shouldEnableDraftMode","encryptHandoff","NextCookieStorage","buildUserClient","getRedirectUri","getRequestOrigin","validateReturnTo","handleCallback","request","config","options","cookieStore","keys","cookieKeys","loginLandingUrl","error","prefix","multilingual","defaultLocale","url","URL","loginLandingPath","searchParams","set","idpError","nextUrl","get","code","state","storedState","oauth_state","value","codeVerifier","pkce_verifier","returnTo","return_to","redirectUri","redirect_uri","clearTransactionCookies","delete","reason","console","warn","redirect","client","auth","exchangeCode","redirectUrl","popupReturnTo","process","env","NODEHIVE_HANDOFF_SECRET","token","refreshToken","refresh_token","hash","token_expires_at","user_details","status","details","undefined"],"sources":["../../../../src/auth/internal/routes/callback.ts"],"sourcesContent":["import { cookies } from 'next/headers';\nimport { NextResponse, type NextRequest } from 'next/server';\nimport { AuthenticationError } from 'nodehive-js';\n\nimport type { NodeHiveAuthConfig } from '../config';\nimport {\n enablePersistentDraftMode,\n shouldEnableDraftMode,\n} from '../draft-mode';\nimport { encryptHandoff } from '../handoff';\nimport { NextCookieStorage } from '../next-cookie-storage';\nimport { buildUserClient } from '../nodehive-client';\nimport { getRedirectUri, getRequestOrigin } from '../oauth-config';\nimport { validateReturnTo } from '../return-to';\n\nexport type CallbackError = 'state' | 'exchange' | 'unavailable' | 'denied';\n\nexport interface CallbackOptions {\n /** Page path (without locale prefix) to bounce to on error. */\n loginLandingPath: string;\n /** returnTo value that triggers the CHIPS editor handoff. */\n popupReturnTo: string;\n}\n\nexport async function handleCallback(\n request: NextRequest,\n config: NodeHiveAuthConfig,\n options: CallbackOptions\n) {\n const cookieStore = await cookies();\n const keys = NextCookieStorage.cookieKeys();\n\n const loginLandingUrl = (error?: CallbackError): URL => {\n const prefix = config.multilingual ? `/${config.defaultLocale}` : '';\n const url = new URL(\n `${prefix}${options.loginLandingPath}`,\n getRequestOrigin(request)\n );\n if (error) url.searchParams.set('error', error);\n return url;\n };\n\n const idpError = request.nextUrl.searchParams.get('error');\n const code = request.nextUrl.searchParams.get('code');\n const state = request.nextUrl.searchParams.get('state');\n const storedState = cookieStore.get(keys.oauth_state)?.value;\n const codeVerifier = cookieStore.get(keys.pkce_verifier)?.value;\n const returnTo = validateReturnTo(cookieStore.get(keys.return_to)?.value);\n // Reuse the exact redirect_uri the login leg sent to Drupal; fall back to\n // deriving it only if the cookie is somehow missing.\n const redirectUri =\n cookieStore.get(keys.redirect_uri)?.value || getRedirectUri(request);\n\n const clearTransactionCookies = () => {\n cookieStore.delete(keys.oauth_state);\n cookieStore.delete(keys.pkce_verifier);\n cookieStore.delete(keys.return_to);\n cookieStore.delete(keys.redirect_uri);\n };\n\n // Drupal reported an error instead of issuing a code (e.g. user clicked\n // \"Deny\" → access_denied). Surface that, don't mislabel it as expired state.\n if (idpError) {\n clearTransactionCookies();\n const reason: CallbackError =\n idpError === 'access_denied' ? 'denied' : 'exchange';\n console.warn('[OAuth callback] IdP returned error', idpError);\n return NextResponse.redirect(loginLandingUrl(reason));\n }\n\n // State / verifier missing or mismatched → CSRF guard tripped or cookie\n // expired (10 min TTL). Cannot trust this callback.\n if (\n !code ||\n !state ||\n !storedState ||\n state !== storedState ||\n !codeVerifier\n ) {\n clearTransactionCookies();\n return NextResponse.redirect(loginLandingUrl('state'));\n }\n\n try {\n const client = buildUserClient(config);\n await client.auth.exchangeCode({\n code,\n codeVerifier,\n redirectUri,\n });\n clearTransactionCookies();\n\n // Editors see drafts and fresh data on public URLs.\n if (await shouldEnableDraftMode(config)) {\n await enablePersistentDraftMode();\n }\n\n const redirectUrl = new URL(returnTo, getRequestOrigin(request));\n\n // Cross-site editor iframe (CHIPS): pass the session tokens to popup-done as\n // an encrypted blob in the URL FRAGMENT — too big for a 4 KB cookie, and the\n // fragment is never sent to the server (kept out of access logs / Referer).\n // popup-done reads it client-side. Skipped without a secret, the gate then\n // falls back to the storage-access path.\n if (\n returnTo === options.popupReturnTo &&\n process.env.NODEHIVE_HANDOFF_SECRET\n ) {\n const token = cookieStore.get(keys.token)?.value;\n const refreshToken = cookieStore.get(keys.refresh_token)?.value;\n if (token && refreshToken) {\n redirectUrl.hash = `h=${encryptHandoff({\n token,\n refresh_token: refreshToken,\n token_expires_at: cookieStore.get(keys.token_expires_at)?.value,\n user_details: cookieStore.get(keys.user_details)?.value,\n })}`;\n }\n }\n\n return NextResponse.redirect(redirectUrl);\n } catch (error) {\n clearTransactionCookies();\n const status =\n error instanceof AuthenticationError ? error.details?.status : undefined;\n // 4xx = bad code/verifier (exchange); 5xx or no status (Drupal down /\n // network) = unavailable.\n const reason: CallbackError =\n typeof status === 'number' && status < 500 ? 'exchange' : 'unavailable';\n console.error('[OAuth callback] code exchange failed', error);\n return NextResponse.redirect(loginLandingUrl(reason));\n }\n}\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,cAAc;AACtC,SAASC,YAAY,QAA0B,aAAa;AAC5D,SAASC,mBAAmB,QAAQ,aAAa;AAGjD,SACEC,yBAAyB,EACzBC,qBAAqB,QAChB,
|
|
1
|
+
{"version":3,"file":"callback.js","names":["cookies","NextResponse","AuthenticationError","enablePersistentDraftMode","shouldEnableDraftMode","encryptHandoff","NextCookieStorage","buildUserClient","getRedirectUri","getRequestOrigin","validateReturnTo","handleCallback","request","config","options","cookieStore","keys","cookieKeys","loginLandingUrl","error","prefix","multilingual","defaultLocale","url","URL","loginLandingPath","searchParams","set","idpError","nextUrl","get","code","state","storedState","oauth_state","value","codeVerifier","pkce_verifier","returnTo","return_to","redirectUri","redirect_uri","clearTransactionCookies","delete","reason","console","warn","redirect","client","auth","exchangeCode","redirectUrl","popupReturnTo","process","env","NODEHIVE_HANDOFF_SECRET","token","refreshToken","refresh_token","hash","token_expires_at","user_details","status","details","undefined"],"sources":["../../../../src/auth/internal/routes/callback.ts"],"sourcesContent":["import { cookies } from 'next/headers';\nimport { NextResponse, type NextRequest } from 'next/server';\nimport { AuthenticationError } from 'nodehive-js';\n\nimport type { NodeHiveAuthConfig } from '../config.ts';\nimport {\n enablePersistentDraftMode,\n shouldEnableDraftMode,\n} from '../draft-mode.ts';\nimport { encryptHandoff } from '../handoff.ts';\nimport { NextCookieStorage } from '../next-cookie-storage.ts';\nimport { buildUserClient } from '../nodehive-client.ts';\nimport { getRedirectUri, getRequestOrigin } from '../oauth-config.ts';\nimport { validateReturnTo } from '../return-to.ts';\n\nexport type CallbackError = 'state' | 'exchange' | 'unavailable' | 'denied';\n\nexport interface CallbackOptions {\n /** Page path (without locale prefix) to bounce to on error. */\n loginLandingPath: string;\n /** returnTo value that triggers the CHIPS editor handoff. */\n popupReturnTo: string;\n}\n\nexport async function handleCallback(\n request: NextRequest,\n config: NodeHiveAuthConfig,\n options: CallbackOptions\n) {\n const cookieStore = await cookies();\n const keys = NextCookieStorage.cookieKeys();\n\n const loginLandingUrl = (error?: CallbackError): URL => {\n const prefix = config.multilingual ? `/${config.defaultLocale}` : '';\n const url = new URL(\n `${prefix}${options.loginLandingPath}`,\n getRequestOrigin(request)\n );\n if (error) url.searchParams.set('error', error);\n return url;\n };\n\n const idpError = request.nextUrl.searchParams.get('error');\n const code = request.nextUrl.searchParams.get('code');\n const state = request.nextUrl.searchParams.get('state');\n const storedState = cookieStore.get(keys.oauth_state)?.value;\n const codeVerifier = cookieStore.get(keys.pkce_verifier)?.value;\n const returnTo = validateReturnTo(cookieStore.get(keys.return_to)?.value);\n // Reuse the exact redirect_uri the login leg sent to Drupal; fall back to\n // deriving it only if the cookie is somehow missing.\n const redirectUri =\n cookieStore.get(keys.redirect_uri)?.value || getRedirectUri(request);\n\n const clearTransactionCookies = () => {\n cookieStore.delete(keys.oauth_state);\n cookieStore.delete(keys.pkce_verifier);\n cookieStore.delete(keys.return_to);\n cookieStore.delete(keys.redirect_uri);\n };\n\n // Drupal reported an error instead of issuing a code (e.g. user clicked\n // \"Deny\" → access_denied). Surface that, don't mislabel it as expired state.\n if (idpError) {\n clearTransactionCookies();\n const reason: CallbackError =\n idpError === 'access_denied' ? 'denied' : 'exchange';\n console.warn('[OAuth callback] IdP returned error', idpError);\n return NextResponse.redirect(loginLandingUrl(reason));\n }\n\n // State / verifier missing or mismatched → CSRF guard tripped or cookie\n // expired (10 min TTL). Cannot trust this callback.\n if (\n !code ||\n !state ||\n !storedState ||\n state !== storedState ||\n !codeVerifier\n ) {\n clearTransactionCookies();\n return NextResponse.redirect(loginLandingUrl('state'));\n }\n\n try {\n const client = buildUserClient(config);\n await client.auth.exchangeCode({\n code,\n codeVerifier,\n redirectUri,\n });\n clearTransactionCookies();\n\n // Editors see drafts and fresh data on public URLs.\n if (await shouldEnableDraftMode(config)) {\n await enablePersistentDraftMode();\n }\n\n const redirectUrl = new URL(returnTo, getRequestOrigin(request));\n\n // Cross-site editor iframe (CHIPS): pass the session tokens to popup-done as\n // an encrypted blob in the URL FRAGMENT — too big for a 4 KB cookie, and the\n // fragment is never sent to the server (kept out of access logs / Referer).\n // popup-done reads it client-side. Skipped without a secret, the gate then\n // falls back to the storage-access path.\n if (\n returnTo === options.popupReturnTo &&\n process.env.NODEHIVE_HANDOFF_SECRET\n ) {\n const token = cookieStore.get(keys.token)?.value;\n const refreshToken = cookieStore.get(keys.refresh_token)?.value;\n if (token && refreshToken) {\n redirectUrl.hash = `h=${encryptHandoff({\n token,\n refresh_token: refreshToken,\n token_expires_at: cookieStore.get(keys.token_expires_at)?.value,\n user_details: cookieStore.get(keys.user_details)?.value,\n })}`;\n }\n }\n\n return NextResponse.redirect(redirectUrl);\n } catch (error) {\n clearTransactionCookies();\n const status =\n error instanceof AuthenticationError ? error.details?.status : undefined;\n // 4xx = bad code/verifier (exchange); 5xx or no status (Drupal down /\n // network) = unavailable.\n const reason: CallbackError =\n typeof status === 'number' && status < 500 ? 'exchange' : 'unavailable';\n console.error('[OAuth callback] code exchange failed', error);\n return NextResponse.redirect(loginLandingUrl(reason));\n }\n}\n"],"mappings":"AAAA,SAASA,OAAO,QAAQ,cAAc;AACtC,SAASC,YAAY,QAA0B,aAAa;AAC5D,SAASC,mBAAmB,QAAQ,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IACzEjB,OAAO,CAAC1B,KAAK,CAAC,uCAAuC,EAAEA,KAAK,CAAC;IAC7D,OAAOlB,YAAY,CAAC8C,QAAQ,CAAC7B,eAAe,CAAC0B,MAAM,CAAC,CAAC;EACvD;AACF","ignoreList":[]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { NextResponse, type NextRequest } from 'next/server';
|
|
2
|
-
import type { NodeHiveAuthConfig } from '../config';
|
|
2
|
+
import type { NodeHiveAuthConfig } from '../config.js';
|
|
3
3
|
export declare function handleChipsExchange(request: NextRequest, config: NodeHiveAuthConfig): Promise<NextResponse<unknown>>;
|
|
4
|
-
//# sourceMappingURL=chips-exchange.d.ts.map
|
|
@@ -1,9 +1,9 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server';
|
|
2
|
-
import { enablePersistentDraftMode, shouldEnableDraftMode } from
|
|
3
|
-
import { decryptHandoff } from
|
|
4
|
-
import { NextCookieStorage } from
|
|
5
|
-
import { REFRESH_TOKEN_MAX_AGE } from
|
|
6
|
-
import { isSameOriginRequest } from
|
|
2
|
+
import { enablePersistentDraftMode, shouldEnableDraftMode } from "../draft-mode.js";
|
|
3
|
+
import { decryptHandoff } from "../handoff.js";
|
|
4
|
+
import { NextCookieStorage } from "../next-cookie-storage.js";
|
|
5
|
+
import { REFRESH_TOKEN_MAX_AGE } from "../oauth-config.js";
|
|
6
|
+
import { isSameOriginRequest } from "../same-origin.js";
|
|
7
7
|
|
|
8
8
|
// POST /api/auth/chips-exchange — called from the editor iframe with the handoff
|
|
9
9
|
// blob. Because the request originates in the iframe, the Set-Cookie lands in the
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"chips-exchange.js","names":["NextResponse","enablePersistentDraftMode","shouldEnableDraftMode","decryptHandoff","NextCookieStorage","REFRESH_TOKEN_MAX_AGE","isSameOriginRequest","handleChipsExchange","request","config","status","blob","json","handoff","payload","expiresAt","Number","token_expires_at","tokenMaxAge","isFinite","Date","now","Math","max","floor","entries","token","refresh_token","user_details","storage","key","value","maxAge","undefined","set","ok"],"sources":["../../../../src/auth/internal/routes/chips-exchange.ts"],"sourcesContent":["import { NextResponse, type NextRequest } from 'next/server';\n\nimport type { NodeHiveAuthConfig } from '../config';\nimport {\n enablePersistentDraftMode,\n shouldEnableDraftMode,\n} from '../draft-mode';\nimport { decryptHandoff } from '../handoff';\nimport { NextCookieStorage } from '../next-cookie-storage';\nimport { REFRESH_TOKEN_MAX_AGE } from '../oauth-config';\nimport { isSameOriginRequest } from '../same-origin';\n\n// POST /api/auth/chips-exchange — called from the editor iframe with the handoff\n// blob. Because the request originates in the iframe, the Set-Cookie lands in the\n// iframe's partition (CHIPS). Guarded by Sec-Fetch-Site like the proxy CSRF guard.\nexport async function handleChipsExchange(\n request: NextRequest,\n config: NodeHiveAuthConfig\n) {\n if (!isSameOriginRequest(request)) {\n return new NextResponse('Forbidden', { status: 403 });\n }\n\n let blob: string | undefined;\n try {\n blob = (await request.json())?.handoff;\n } catch {\n return new NextResponse('Bad Request', { status: 400 });\n }\n if (typeof blob !== 'string' || !blob) {\n return new NextResponse('Bad Request', { status: 400 });\n }\n\n const payload = decryptHandoff(blob);\n if (!payload) {\n return new NextResponse('Invalid or expired handoff', { status: 401 });\n }\n\n // Pin the access-token cookie to its real (short) expiry; the rest live as long\n // as the refresh token (the proxy renews the access token via token_expires_at).\n // Floor at 60 s so a near-expired token never becomes maxAge:0 (which deletes\n // the cookie); unknown expiry → short-lived so the proxy refreshes promptly.\n const expiresAt = Number(payload.token_expires_at);\n const tokenMaxAge =\n Number.isFinite(expiresAt) && expiresAt > Date.now()\n ? Math.max(60, Math.floor((expiresAt - Date.now()) / 1000))\n : 3600;\n\n // Re-set via the storage adapter so the cookies inherit BASE_COOKIE_OPTIONS\n // (None; Secure; Partitioned; httpOnly).\n const entries: Array<[string, string | undefined, number]> = [\n ['token', payload.token, tokenMaxAge],\n ['refresh_token', payload.refresh_token, REFRESH_TOKEN_MAX_AGE],\n ['token_expires_at', payload.token_expires_at, REFRESH_TOKEN_MAX_AGE],\n ['user_details', payload.user_details, REFRESH_TOKEN_MAX_AGE],\n ];\n const storage = new NextCookieStorage();\n for (const [key, value, maxAge] of entries) {\n if (value === undefined) continue;\n await storage.set(key, value, { maxAge });\n }\n\n // The iframe partition never sees the popup's draft cookie — enable here,\n // where the Set-Cookie lands in the right partition.\n if (await shouldEnableDraftMode(config)) {\n await enablePersistentDraftMode();\n }\n\n return NextResponse.json({ ok: true });\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAA0B,aAAa;AAG5D,SACEC,yBAAyB,EACzBC,qBAAqB,QAChB,
|
|
1
|
+
{"version":3,"file":"chips-exchange.js","names":["NextResponse","enablePersistentDraftMode","shouldEnableDraftMode","decryptHandoff","NextCookieStorage","REFRESH_TOKEN_MAX_AGE","isSameOriginRequest","handleChipsExchange","request","config","status","blob","json","handoff","payload","expiresAt","Number","token_expires_at","tokenMaxAge","isFinite","Date","now","Math","max","floor","entries","token","refresh_token","user_details","storage","key","value","maxAge","undefined","set","ok"],"sources":["../../../../src/auth/internal/routes/chips-exchange.ts"],"sourcesContent":["import { NextResponse, type NextRequest } from 'next/server';\n\nimport type { NodeHiveAuthConfig } from '../config.ts';\nimport {\n enablePersistentDraftMode,\n shouldEnableDraftMode,\n} from '../draft-mode.ts';\nimport { decryptHandoff } from '../handoff.ts';\nimport { NextCookieStorage } from '../next-cookie-storage.ts';\nimport { REFRESH_TOKEN_MAX_AGE } from '../oauth-config.ts';\nimport { isSameOriginRequest } from '../same-origin.ts';\n\n// POST /api/auth/chips-exchange — called from the editor iframe with the handoff\n// blob. Because the request originates in the iframe, the Set-Cookie lands in the\n// iframe's partition (CHIPS). Guarded by Sec-Fetch-Site like the proxy CSRF guard.\nexport async function handleChipsExchange(\n request: NextRequest,\n config: NodeHiveAuthConfig\n) {\n if (!isSameOriginRequest(request)) {\n return new NextResponse('Forbidden', { status: 403 });\n }\n\n let blob: string | undefined;\n try {\n blob = (await request.json())?.handoff;\n } catch {\n return new NextResponse('Bad Request', { status: 400 });\n }\n if (typeof blob !== 'string' || !blob) {\n return new NextResponse('Bad Request', { status: 400 });\n }\n\n const payload = decryptHandoff(blob);\n if (!payload) {\n return new NextResponse('Invalid or expired handoff', { status: 401 });\n }\n\n // Pin the access-token cookie to its real (short) expiry; the rest live as long\n // as the refresh token (the proxy renews the access token via token_expires_at).\n // Floor at 60 s so a near-expired token never becomes maxAge:0 (which deletes\n // the cookie); unknown expiry → short-lived so the proxy refreshes promptly.\n const expiresAt = Number(payload.token_expires_at);\n const tokenMaxAge =\n Number.isFinite(expiresAt) && expiresAt > Date.now()\n ? Math.max(60, Math.floor((expiresAt - Date.now()) / 1000))\n : 3600;\n\n // Re-set via the storage adapter so the cookies inherit BASE_COOKIE_OPTIONS\n // (None; Secure; Partitioned; httpOnly).\n const entries: Array<[string, string | undefined, number]> = [\n ['token', payload.token, tokenMaxAge],\n ['refresh_token', payload.refresh_token, REFRESH_TOKEN_MAX_AGE],\n ['token_expires_at', payload.token_expires_at, REFRESH_TOKEN_MAX_AGE],\n ['user_details', payload.user_details, REFRESH_TOKEN_MAX_AGE],\n ];\n const storage = new NextCookieStorage();\n for (const [key, value, maxAge] of entries) {\n if (value === undefined) continue;\n await storage.set(key, value, { maxAge });\n }\n\n // The iframe partition never sees the popup's draft cookie — enable here,\n // where the Set-Cookie lands in the right partition.\n if (await shouldEnableDraftMode(config)) {\n await enablePersistentDraftMode();\n }\n\n return NextResponse.json({ ok: true });\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAA0B,aAAa;AAG5D,SACEC,yBAAyB,EACzBC,qBAAqB,QAChB,kBAAkB;AACzB,SAASC,cAAc,QAAQ,eAAe;AAC9C,SAASC,iBAAiB,QAAQ,2BAA2B;AAC7D,SAASC,qBAAqB,QAAQ,oBAAoB;AAC1D,SAASC,mBAAmB,QAAQ,mBAAmB;;AAEvD;AACA;AACA;AACA,OAAO,eAAeC,mBAAmBA,CACvCC,OAAoB,EACpBC,MAA0B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,CAACG,gBAAgB,EAAEZ,qBAAqB,CAAC,EACrE,CAAC,cAAc,EAAES,OAAO,CAACc,YAAY,EAAEvB,qBAAqB,CAAC,CAC9D;EACD,MAAMwB,OAAO,GAAG,IAAIzB,iBAAiB,CAAC,CAAC;EACvC,KAAK,MAAM,CAAC0B,GAAG,EAAEC,KAAK,EAAEC,MAAM,CAAC,IAAIP,OAAO,EAAE;IAC1C,IAAIM,KAAK,KAAKE,SAAS,EAAE;IACzB,MAAMJ,OAAO,CAACK,GAAG,CAACJ,GAAG,EAAEC,KAAK,EAAE;MAAEC;IAAO,CAAC,CAAC;EAC3C;;EAEA;EACA;EACA,IAAI,MAAM9B,qBAAqB,CAACO,MAAM,CAAC,EAAE;IACvC,MAAMR,yBAAyB,CAAC,CAAC;EACnC;EAEA,OAAOD,YAAY,CAACY,IAAI,CAAC;IAAEuB,EAAE,EAAE;EAAK,CAAC,CAAC;AACxC","ignoreList":[]}
|
|
@@ -1,4 +1,3 @@
|
|
|
1
1
|
import { NextResponse, type NextRequest } from 'next/server';
|
|
2
|
-
import type { NodeHiveAuthConfig } from '../config';
|
|
2
|
+
import type { NodeHiveAuthConfig } from '../config.js';
|
|
3
3
|
export declare function handleDraft(request: NextRequest, config: NodeHiveAuthConfig): Promise<NextResponse<unknown>>;
|
|
4
|
-
//# sourceMappingURL=draft.d.ts.map
|
|
@@ -1,7 +1,7 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server';
|
|
2
|
-
import { enablePersistentDraftMode, shouldEnableDraftMode } from
|
|
3
|
-
import { NextCookieStorage } from
|
|
4
|
-
import { isSameOriginRequest } from
|
|
2
|
+
import { enablePersistentDraftMode, shouldEnableDraftMode } from "../draft-mode.js";
|
|
3
|
+
import { NextCookieStorage } from "../next-cookie-storage.js";
|
|
4
|
+
import { isSameOriginRequest } from "../same-origin.js";
|
|
5
5
|
|
|
6
6
|
// POST /api/auth/draft — self-heal: the bypass value rotates per build, so a
|
|
7
7
|
// deploy invalidates draft cookies while the session lives on.
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"draft.js","names":["NextResponse","enablePersistentDraftMode","shouldEnableDraftMode","NextCookieStorage","isSameOriginRequest","handleDraft","request","config","status","hasSession","get","json","ok"],"sources":["../../../../src/auth/internal/routes/draft.ts"],"sourcesContent":["import { NextResponse, type NextRequest } from 'next/server';\n\nimport type { NodeHiveAuthConfig } from '../config';\nimport {\n enablePersistentDraftMode,\n shouldEnableDraftMode,\n} from '../draft-mode';\nimport { NextCookieStorage } from '../next-cookie-storage';\nimport { isSameOriginRequest } from '../same-origin';\n\n// POST /api/auth/draft — self-heal: the bypass value rotates per build, so a\n// deploy invalidates draft cookies while the session lives on.\nexport async function handleDraft(\n request: NextRequest,\n config: NodeHiveAuthConfig\n) {\n if (!isSameOriginRequest(request)) {\n return new NextResponse('Forbidden', { status: 403 });\n }\n\n // Routing hint only — Drupal authorizes every draft fetch by the actual token.\n const hasSession = !!(await new NextCookieStorage().get('refresh_token'));\n if (!hasSession) {\n return NextResponse.json({ ok: false }, { status: 401 });\n }\n\n if (!(await shouldEnableDraftMode(config))) {\n return new NextResponse('Not Found', { status: 404 });\n }\n\n await enablePersistentDraftMode();\n return NextResponse.json({ ok: true });\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAA0B,aAAa;AAG5D,SACEC,yBAAyB,EACzBC,qBAAqB,QAChB,
|
|
1
|
+
{"version":3,"file":"draft.js","names":["NextResponse","enablePersistentDraftMode","shouldEnableDraftMode","NextCookieStorage","isSameOriginRequest","handleDraft","request","config","status","hasSession","get","json","ok"],"sources":["../../../../src/auth/internal/routes/draft.ts"],"sourcesContent":["import { NextResponse, type NextRequest } from 'next/server';\n\nimport type { NodeHiveAuthConfig } from '../config.ts';\nimport {\n enablePersistentDraftMode,\n shouldEnableDraftMode,\n} from '../draft-mode.ts';\nimport { NextCookieStorage } from '../next-cookie-storage.ts';\nimport { isSameOriginRequest } from '../same-origin.ts';\n\n// POST /api/auth/draft — self-heal: the bypass value rotates per build, so a\n// deploy invalidates draft cookies while the session lives on.\nexport async function handleDraft(\n request: NextRequest,\n config: NodeHiveAuthConfig\n) {\n if (!isSameOriginRequest(request)) {\n return new NextResponse('Forbidden', { status: 403 });\n }\n\n // Routing hint only — Drupal authorizes every draft fetch by the actual token.\n const hasSession = !!(await new NextCookieStorage().get('refresh_token'));\n if (!hasSession) {\n return NextResponse.json({ ok: false }, { status: 401 });\n }\n\n if (!(await shouldEnableDraftMode(config))) {\n return new NextResponse('Not Found', { status: 404 });\n }\n\n await enablePersistentDraftMode();\n return NextResponse.json({ ok: true });\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAA0B,aAAa;AAG5D,SACEC,yBAAyB,EACzBC,qBAAqB,QAChB,kBAAkB;AACzB,SAASC,iBAAiB,QAAQ,2BAA2B;AAC7D,SAASC,mBAAmB,QAAQ,mBAAmB;;AAEvD;AACA;AACA,OAAO,eAAeC,WAAWA,CAC/BC,OAAoB,EACpBC,MAA0B,EAC1B;EACA,IAAI,CAACH,mBAAmB,CAACE,OAAO,CAAC,EAAE;IACjC,OAAO,IAAIN,YAAY,CAAC,WAAW,EAAE;MAAEQ,MAAM,EAAE;IAAI,CAAC,CAAC;EACvD;;EAEA;EACA,MAAMC,UAAU,GAAG,CAAC,EAAE,MAAM,IAAIN,iBAAiB,CAAC,CAAC,CAACO,GAAG,CAAC,eAAe,CAAC,CAAC;EACzE,IAAI,CAACD,UAAU,EAAE;IACf,OAAOT,YAAY,CAACW,IAAI,CAAC;MAAEC,EAAE,EAAE;IAAM,CAAC,EAAE;MAAEJ,MAAM,EAAE;IAAI,CAAC,CAAC;EAC1D;EAEA,IAAI,EAAE,MAAMN,qBAAqB,CAACK,MAAM,CAAC,CAAC,EAAE;IAC1C,OAAO,IAAIP,YAAY,CAAC,WAAW,EAAE;MAAEQ,MAAM,EAAE;IAAI,CAAC,CAAC;EACvD;EAEA,MAAMP,yBAAyB,CAAC,CAAC;EACjC,OAAOD,YAAY,CAACW,IAAI,CAAC;IAAEC,EAAE,EAAE;EAAK,CAAC,CAAC;AACxC","ignoreList":[]}
|
|
@@ -1,10 +1,13 @@
|
|
|
1
1
|
import { NextResponse, type NextRequest } from 'next/server';
|
|
2
|
-
import type { NodeHiveAuthConfig } from '../config';
|
|
2
|
+
import type { NodeHiveAuthConfig } from '../config.js';
|
|
3
|
+
import type { AuthDictionaryOverrides } from '../i18n.js';
|
|
3
4
|
export interface AuthRouteOptions {
|
|
4
5
|
/** Page path (no locale prefix) the callback bounces to on error. Default '/nodehive/login'. */
|
|
5
6
|
loginLandingPath?: string;
|
|
6
7
|
/** returnTo that triggers the CHIPS handoff (editor popup). Default '/api/auth/popup-done'. */
|
|
7
8
|
popupReturnTo?: string;
|
|
9
|
+
/** Per-section label overrides merged over the resolved dictionary (popup-done message). */
|
|
10
|
+
dictionaryOverrides?: AuthDictionaryOverrides;
|
|
8
11
|
}
|
|
9
12
|
type RouteContext = {
|
|
10
13
|
params: Promise<{
|
|
@@ -22,4 +25,3 @@ export declare function createAuthRouteHandlers(config: NodeHiveAuthConfig, opti
|
|
|
22
25
|
POST: (request: NextRequest, context: RouteContext) => Promise<NextResponse<unknown>>;
|
|
23
26
|
};
|
|
24
27
|
export {};
|
|
25
|
-
//# sourceMappingURL=index.d.ts.map
|
|
@@ -1,10 +1,10 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server';
|
|
2
|
-
import { handleCallback } from
|
|
3
|
-
import { handleChipsExchange } from
|
|
4
|
-
import { handleDraft } from
|
|
5
|
-
import { handleLogin } from
|
|
6
|
-
import { handlePopupDone } from
|
|
7
|
-
import { handleRefresh } from
|
|
2
|
+
import { handleCallback } from "./callback.js";
|
|
3
|
+
import { handleChipsExchange } from "./chips-exchange.js";
|
|
4
|
+
import { handleDraft } from "./draft.js";
|
|
5
|
+
import { handleLogin } from "./login.js";
|
|
6
|
+
import { handlePopupDone } from "./popup-done.js";
|
|
7
|
+
import { handleRefresh } from "./refresh.js";
|
|
8
8
|
/**
|
|
9
9
|
* Catch-all factory for the OAuth routes. Mount under
|
|
10
10
|
* app/api/auth/[...nodehive]/route.ts:
|
|
@@ -31,7 +31,7 @@ export function createAuthRouteHandlers(config, options) {
|
|
|
31
31
|
case 'callback':
|
|
32
32
|
return handleCallback(request, config, callbackOptions);
|
|
33
33
|
case 'popup-done':
|
|
34
|
-
return handlePopupDone(request);
|
|
34
|
+
return handlePopupDone(request, options?.dictionaryOverrides);
|
|
35
35
|
default:
|
|
36
36
|
return new NextResponse('Not Found', {
|
|
37
37
|
status: 404
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","names":["NextResponse","handleCallback","handleChipsExchange","handleDraft","handleLogin","handlePopupDone","handleRefresh","createAuthRouteHandlers","config","options","callbackOptions","loginLandingPath","popupReturnTo","GET","request","context","segments","params","nodehive","length","status","POST"],"sources":["../../../../src/auth/internal/routes/index.ts"],"sourcesContent":["import { NextResponse, type NextRequest } from 'next/server';\n\nimport type { NodeHiveAuthConfig } from '../config';\nimport { handleCallback } from './callback';\nimport { handleChipsExchange } from './chips-exchange';\nimport { handleDraft } from './draft';\nimport { handleLogin } from './login';\nimport { handlePopupDone } from './popup-done';\nimport { handleRefresh } from './refresh';\n\nexport interface AuthRouteOptions {\n /** Page path (no locale prefix) the callback bounces to on error. Default '/nodehive/login'. */\n loginLandingPath?: string;\n /** returnTo that triggers the CHIPS handoff (editor popup). Default '/api/auth/popup-done'. */\n popupReturnTo?: string;\n}\n\ntype RouteContext = { params: Promise<{ nodehive?: string[] }> };\n\n/**\n * Catch-all factory for the OAuth routes. Mount under\n * app/api/auth/[...nodehive]/route.ts:\n * const { GET, POST } = createAuthRouteHandlers(authConfig);\n * export { GET, POST };\n */\nexport function createAuthRouteHandlers(\n config: NodeHiveAuthConfig,\n options?: AuthRouteOptions\n) {\n const callbackOptions = {\n loginLandingPath: options?.loginLandingPath ?? '/nodehive/login',\n popupReturnTo: options?.popupReturnTo ?? '/api/auth/popup-done',\n };\n\n async function GET(request: NextRequest, context: RouteContext) {\n const segments = (await context.params).nodehive;\n // Match exactly one segment — /api/auth/login/anything must 404, not run a\n // handler on an unbounded URL set.\n if (segments?.length !== 1) {\n return new NextResponse('Not Found', { status: 404 });\n }\n switch (segments[0]) {\n case 'login':\n return handleLogin(request);\n case 'callback':\n return handleCallback(request, config, callbackOptions);\n case 'popup-done':\n return handlePopupDone(request);\n default:\n return new NextResponse('Not Found', { status: 404 });\n }\n }\n\n async function POST(request: NextRequest, context: RouteContext) {\n const segments = (await context.params).nodehive;\n if (segments?.length !== 1) {\n return new NextResponse('Not Found', { status: 404 });\n }\n switch (segments[0]) {\n case 'refresh':\n return handleRefresh(request, config);\n case 'chips-exchange':\n return handleChipsExchange(request, config);\n case 'draft':\n return handleDraft(request, config);\n default:\n return new NextResponse('Not Found', { status: 404 });\n }\n }\n\n return { GET, POST };\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAA0B,aAAa;
|
|
1
|
+
{"version":3,"file":"index.js","names":["NextResponse","handleCallback","handleChipsExchange","handleDraft","handleLogin","handlePopupDone","handleRefresh","createAuthRouteHandlers","config","options","callbackOptions","loginLandingPath","popupReturnTo","GET","request","context","segments","params","nodehive","length","status","dictionaryOverrides","POST"],"sources":["../../../../src/auth/internal/routes/index.ts"],"sourcesContent":["import { NextResponse, type NextRequest } from 'next/server';\n\nimport type { NodeHiveAuthConfig } from '../config.ts';\nimport type { AuthDictionaryOverrides } from '../i18n.ts';\nimport { handleCallback } from './callback.ts';\nimport { handleChipsExchange } from './chips-exchange.ts';\nimport { handleDraft } from './draft.ts';\nimport { handleLogin } from './login.ts';\nimport { handlePopupDone } from './popup-done.ts';\nimport { handleRefresh } from './refresh.ts';\n\nexport interface AuthRouteOptions {\n /** Page path (no locale prefix) the callback bounces to on error. Default '/nodehive/login'. */\n loginLandingPath?: string;\n /** returnTo that triggers the CHIPS handoff (editor popup). Default '/api/auth/popup-done'. */\n popupReturnTo?: string;\n /** Per-section label overrides merged over the resolved dictionary (popup-done message). */\n dictionaryOverrides?: AuthDictionaryOverrides;\n}\n\ntype RouteContext = { params: Promise<{ nodehive?: string[] }> };\n\n/**\n * Catch-all factory for the OAuth routes. Mount under\n * app/api/auth/[...nodehive]/route.ts:\n * const { GET, POST } = createAuthRouteHandlers(authConfig);\n * export { GET, POST };\n */\nexport function createAuthRouteHandlers(\n config: NodeHiveAuthConfig,\n options?: AuthRouteOptions\n) {\n const callbackOptions = {\n loginLandingPath: options?.loginLandingPath ?? '/nodehive/login',\n popupReturnTo: options?.popupReturnTo ?? '/api/auth/popup-done',\n };\n\n async function GET(request: NextRequest, context: RouteContext) {\n const segments = (await context.params).nodehive;\n // Match exactly one segment — /api/auth/login/anything must 404, not run a\n // handler on an unbounded URL set.\n if (segments?.length !== 1) {\n return new NextResponse('Not Found', { status: 404 });\n }\n switch (segments[0]) {\n case 'login':\n return handleLogin(request);\n case 'callback':\n return handleCallback(request, config, callbackOptions);\n case 'popup-done':\n return handlePopupDone(request, options?.dictionaryOverrides);\n default:\n return new NextResponse('Not Found', { status: 404 });\n }\n }\n\n async function POST(request: NextRequest, context: RouteContext) {\n const segments = (await context.params).nodehive;\n if (segments?.length !== 1) {\n return new NextResponse('Not Found', { status: 404 });\n }\n switch (segments[0]) {\n case 'refresh':\n return handleRefresh(request, config);\n case 'chips-exchange':\n return handleChipsExchange(request, config);\n case 'draft':\n return handleDraft(request, config);\n default:\n return new NextResponse('Not Found', { status: 404 });\n }\n }\n\n return { GET, POST };\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAA0B,aAAa;AAI5D,SAASC,cAAc,QAAQ,eAAe;AAC9C,SAASC,mBAAmB,QAAQ,qBAAqB;AACzD,SAASC,WAAW,QAAQ,YAAY;AACxC,SAASC,WAAW,QAAQ,YAAY;AACxC,SAASC,eAAe,QAAQ,iBAAiB;AACjD,SAASC,aAAa,QAAQ,cAAc;AAa5C;AACA;AACA;AACA;AACA;AACA;AACA,OAAO,SAASC,uBAAuBA,CACrCC,MAA0B,EAC1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MAAM,CAAC;MAC7C,KAAK,OAAO;QACV,OAAOL,WAAW,CAACW,OAAO,EAAEN,MAAM,CAAC;MACrC;QACE,OAAO,IAAIR,YAAY,CAAC,WAAW,EAAE;UAAEoB,MAAM,EAAE;QAAI,CAAC,CAAC;IACzD;EACF;EAEA,OAAO;IAAEP,GAAG;IAAES;EAAK,CAAC;AACtB","ignoreList":[]}
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server';
|
|
2
2
|
import { buildAuthorizeUrl, generatePKCE, generateState } from 'nodehive-js';
|
|
3
|
-
import { NextCookieStorage } from
|
|
4
|
-
import { getAuthorizeUrl, getClientId, getRedirectUri } from
|
|
5
|
-
import { validateReturnTo } from
|
|
3
|
+
import { NextCookieStorage } from "../next-cookie-storage.js";
|
|
4
|
+
import { getAuthorizeUrl, getClientId, getRedirectUri } from "../oauth-config.js";
|
|
5
|
+
import { validateReturnTo } from "../return-to.js";
|
|
6
6
|
|
|
7
7
|
// 10 minutes — the user has this long to complete the Drupal login.
|
|
8
8
|
const TX_COOKIE_MAX_AGE = 600;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"login.js","names":["NextResponse","buildAuthorizeUrl","generatePKCE","generateState","NextCookieStorage","getAuthorizeUrl","getClientId","getRedirectUri","validateReturnTo","TX_COOKIE_MAX_AGE","handleLogin","request","returnTo","nextUrl","searchParams","get","codeVerifier","codeChallenge","codeChallengeMethod","state","redirectUri","authorizeUrl","clientId","response","redirect","keys","cookieKeys","txCookieOptions","httpOnly","sameSite","secure","process","env","NODE_ENV","path","maxAge","cookies","set","oauth_state","pkce_verifier","return_to","redirect_uri"],"sources":["../../../../src/auth/internal/routes/login.ts"],"sourcesContent":["import { NextResponse, type NextRequest } from 'next/server';\nimport { buildAuthorizeUrl, generatePKCE, generateState } from 'nodehive-js';\n\nimport { NextCookieStorage } from '../next-cookie-storage';\nimport {
|
|
1
|
+
{"version":3,"file":"login.js","names":["NextResponse","buildAuthorizeUrl","generatePKCE","generateState","NextCookieStorage","getAuthorizeUrl","getClientId","getRedirectUri","validateReturnTo","TX_COOKIE_MAX_AGE","handleLogin","request","returnTo","nextUrl","searchParams","get","codeVerifier","codeChallenge","codeChallengeMethod","state","redirectUri","authorizeUrl","clientId","response","redirect","keys","cookieKeys","txCookieOptions","httpOnly","sameSite","secure","process","env","NODE_ENV","path","maxAge","cookies","set","oauth_state","pkce_verifier","return_to","redirect_uri"],"sources":["../../../../src/auth/internal/routes/login.ts"],"sourcesContent":["import { NextResponse, type NextRequest } from 'next/server';\nimport { buildAuthorizeUrl, generatePKCE, generateState } from 'nodehive-js';\n\nimport { NextCookieStorage } from '../next-cookie-storage.ts';\nimport {\n getAuthorizeUrl,\n getClientId,\n getRedirectUri,\n} from '../oauth-config.ts';\nimport { validateReturnTo } from '../return-to.ts';\n\n// 10 minutes — the user has this long to complete the Drupal login.\nconst TX_COOKIE_MAX_AGE = 600;\n\nexport async function handleLogin(request: NextRequest) {\n const returnTo = validateReturnTo(\n request.nextUrl.searchParams.get('returnTo')\n );\n\n const { codeVerifier, codeChallenge, codeChallengeMethod } =\n await generatePKCE();\n const state = generateState();\n // Compute the redirect_uri once and persist it, so the callback exchanges the\n // code with the EXACT same value (Simple OAuth matches it byte-for-byte).\n // Recomputing it from headers on the callback leg risks a mismatch (e.g.\n // apex vs www, or a differing X-Forwarded-Host) → invalid_grant.\n const redirectUri = getRedirectUri(request);\n\n const authorizeUrl = buildAuthorizeUrl({\n authorizeUrl: getAuthorizeUrl(),\n clientId: getClientId(),\n redirectUri,\n state,\n codeChallenge,\n codeChallengeMethod,\n });\n\n const response = NextResponse.redirect(authorizeUrl);\n\n const keys = NextCookieStorage.cookieKeys();\n // Lax (not None) keeps state/PKCE out of cross-site contexts; only the session\n // cookies need None for the iframe.\n const txCookieOptions = {\n httpOnly: true,\n sameSite: 'lax' as const,\n secure: process.env.NODE_ENV === 'production',\n path: '/' as const,\n maxAge: TX_COOKIE_MAX_AGE,\n };\n response.cookies.set(keys.oauth_state, state, txCookieOptions);\n response.cookies.set(keys.pkce_verifier, codeVerifier, txCookieOptions);\n response.cookies.set(keys.return_to, returnTo, txCookieOptions);\n response.cookies.set(keys.redirect_uri, redirectUri, txCookieOptions);\n\n return response;\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAA0B,aAAa;AAC5D,SAASC,iBAAiB,EAAEC,YAAY,EAAEC,aAAa,QAAQ,aAAa;AAE5E,SAASC,iBAAiB,QAAQ,2BAA2B;AAC7D,SACEC,eAAe,EACfC,WAAW,EACXC,cAAc,QACT,oBAAoB;AAC3B,SAASC,gBAAgB,QAAQ,iBAAiB;;AAElD;AACA,MAAMC,iBAAiB,GAAG,GAAG;AAE7B,OAAO,eAAeC,WAAWA,CAACC,OAAoB,EAAE;EACtD,MAAMC,QAAQ,GAAGJ,gBAAgB,CAC/BG,OAAO,CAACE,OAAO,CAACC,YAAY,CAACC,GAAG,CAAC,UAAU,CAC7C,CAAC;EAED,MAAM;IAAEC,YAAY;IAAEC,aAAa;IAAEC;EAAoB,CAAC,GACxD,MAAMhB,YAAY,CAAC,CAAC;EACtB,MAAMiB,KAAK,GAAGhB,aAAa,CAAC,CAAC;EAC7B;EACA;EACA;EACA;EACA,MAAMiB,WAAW,GAAGb,cAAc,CAACI,OAAO,CAAC;EAE3C,MAAMU,YAAY,GAAGpB,iBAAiB,CAAC;IACrCoB,YAAY,EAAEhB,eAAe,CAAC,CAAC;IAC/BiB,QAAQ,EAAEhB,WAAW,CAAC,CAAC;IACvBc,WAAW;IACXD,KAAK;IACLF,aAAa;IACbC;EACF,CAAC,CAAC;EAEF,MAAMK,QAAQ,GAAGvB,YAAY,CAACwB,QAAQ,CAACH,YAAY,CAAC;EAEpD,MAAMI,IAAI,GAAGrB,iBAAiB,CAACsB,UAAU,CAAC,CAAC;EAC3C;EACA;EACA,MAAMC,eAAe,GAAG;IACtBC,QAAQ,EAAE,IAAI;IACdC,QAAQ,EAAE,KAAc;IACxBC,MAAM,EAAEC,OAAO,CAACC,GAAG,CAACC,QAAQ,KAAK,YAAY;IAC7CC,IAAI,EAAE,GAAY;IAClBC,MAAM,EAAE1B;EACV,CAAC;EACDc,QAAQ,CAACa,OAAO,CAACC,GAAG,CAACZ,IAAI,CAACa,WAAW,EAAEnB,KAAK,EAAEQ,eAAe,CAAC;EAC9DJ,QAAQ,CAACa,OAAO,CAACC,GAAG,CAACZ,IAAI,CAACc,aAAa,EAAEvB,YAAY,EAAEW,eAAe,CAAC;EACvEJ,QAAQ,CAACa,OAAO,CAACC,GAAG,CAACZ,IAAI,CAACe,SAAS,EAAE5B,QAAQ,EAAEe,eAAe,CAAC;EAC/DJ,QAAQ,CAACa,OAAO,CAACC,GAAG,CAACZ,IAAI,CAACgB,YAAY,EAAErB,WAAW,EAAEO,eAAe,CAAC;EAErE,OAAOJ,QAAQ;AACjB","ignoreList":[]}
|
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
import { NextRequest, NextResponse } from 'next/server';
|
|
2
|
-
|
|
3
|
-
|
|
2
|
+
import { type AuthDictionaryOverrides } from '../i18n.js';
|
|
3
|
+
export declare function handlePopupDone(request?: NextRequest, dictionaryOverrides?: AuthDictionaryOverrides): NextResponse<unknown>;
|
|
@@ -1,4 +1,6 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server';
|
|
2
|
+
import { AUTH_DONE_TYPE } from "../../../bridge-protocol/index.js";
|
|
3
|
+
import { getAuthDictionary } from "../i18n.js";
|
|
2
4
|
|
|
3
5
|
// GET /api/auth/popup-done — login-popup landing page. The CHIPS handoff blob
|
|
4
6
|
// rides in the URL fragment (never sent to the server), so this response is
|
|
@@ -6,14 +8,14 @@ import { NextResponse } from 'next/server';
|
|
|
6
8
|
// blob to the opener iframe, strips it from history, then self-closes. The
|
|
7
9
|
// message language is negotiated from Accept-Language (the popup shows for
|
|
8
10
|
// ~150ms; no user preference is available at this point in the OAuth flow).
|
|
9
|
-
const
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
};
|
|
13
|
-
const html = message => `<!doctype html><html><head><meta charset="utf-8"><title>login</title></head><body style="font:14px system-ui;padding:24px"><p>${message}</p><script>try{var h=new URLSearchParams(location.hash.slice(1)).get('h')||'';window.opener&&window.opener.postMessage({type:'nh:auth-done',via:'oauth',handoff:h},location.origin)}catch(e){}try{history.replaceState(null,'',location.pathname)}catch(e){}setTimeout(function(){window.close()},150)</script></body></html>`;
|
|
14
|
-
export function handlePopupDone(request) {
|
|
11
|
+
const escapeHtml = text => text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');
|
|
12
|
+
const html = message => `<!doctype html><html><head><meta charset="utf-8"><title>login</title></head><body style="font:14px system-ui;padding:24px"><p>${escapeHtml(message)}</p><script>try{var h=new URLSearchParams(location.hash.slice(1)).get('h')||'';window.opener&&window.opener.postMessage({type:'${AUTH_DONE_TYPE}',via:'oauth',handoff:h},location.origin)}catch(e){}try{history.replaceState(null,'',location.pathname)}catch(e){}setTimeout(function(){window.close()},150)</script></body></html>`;
|
|
13
|
+
export function handlePopupDone(request, dictionaryOverrides) {
|
|
15
14
|
const acceptLanguage = request?.headers.get('accept-language') ?? '';
|
|
16
|
-
const
|
|
15
|
+
const locale = acceptLanguage.split(',')[0]?.split('-')[0]?.trim().toLowerCase() || 'en';
|
|
16
|
+
const {
|
|
17
|
+
message
|
|
18
|
+
} = getAuthDictionary(locale, dictionaryOverrides).popupDone;
|
|
17
19
|
return new NextResponse(html(message), {
|
|
18
20
|
headers: {
|
|
19
21
|
'content-type': 'text/html; charset=utf-8',
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"popup-done.js","names":["NextResponse","
|
|
1
|
+
{"version":3,"file":"popup-done.js","names":["NextResponse","AUTH_DONE_TYPE","getAuthDictionary","escapeHtml","text","replace","html","message","handlePopupDone","request","dictionaryOverrides","acceptLanguage","headers","get","locale","split","trim","toLowerCase","popupDone","vary"],"sources":["../../../../src/auth/internal/routes/popup-done.ts"],"sourcesContent":["import { NextRequest, NextResponse } from 'next/server';\n\nimport { AUTH_DONE_TYPE } from '../../../bridge-protocol/index.ts';\nimport { getAuthDictionary, type AuthDictionaryOverrides } from '../i18n.ts';\n\n// GET /api/auth/popup-done — login-popup landing page. The CHIPS handoff blob\n// rides in the URL fragment (never sent to the server), so this response is\n// static per language: the inline script reads location.hash, relays the opaque\n// blob to the opener iframe, strips it from history, then self-closes. The\n// message language is negotiated from Accept-Language (the popup shows for\n// ~150ms; no user preference is available at this point in the OAuth flow).\nconst escapeHtml = (text: string) =>\n text.replace(/&/g, '&').replace(/</g, '<').replace(/>/g, '>');\n\nconst html = (message: string) =>\n `<!doctype html><html><head><meta charset=\"utf-8\"><title>login</title></head><body style=\"font:14px system-ui;padding:24px\"><p>${escapeHtml(message)}</p><script>try{var h=new URLSearchParams(location.hash.slice(1)).get('h')||'';window.opener&&window.opener.postMessage({type:'${AUTH_DONE_TYPE}',via:'oauth',handoff:h},location.origin)}catch(e){}try{history.replaceState(null,'',location.pathname)}catch(e){}setTimeout(function(){window.close()},150)</script></body></html>`;\n\nexport function handlePopupDone(\n request?: NextRequest,\n dictionaryOverrides?: AuthDictionaryOverrides\n) {\n const acceptLanguage = request?.headers.get('accept-language') ?? '';\n const locale =\n acceptLanguage.split(',')[0]?.split('-')[0]?.trim().toLowerCase() || 'en';\n const { message } = getAuthDictionary(locale, dictionaryOverrides).popupDone;\n return new NextResponse(html(message), {\n headers: {\n 'content-type': 'text/html; charset=utf-8',\n vary: 'Accept-Language',\n },\n });\n}\n"],"mappings":"AAAA,SAAsBA,YAAY,QAAQ,aAAa;AAEvD,SAASC,cAAc,QAAQ,mCAAmC;AAClE,SAASC,iBAAiB,QAAsC,YAAY;;AAE5E;AACA;AACA;AACA;AACA;AACA;AACA,MAAMC,UAAU,GAAIC,IAAY,IAC9BA,IAAI,CAACC,OAAO,CAAC,IAAI,EAAE,OAAO,CAAC,CAACA,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC,CAACA,OAAO,CAAC,IAAI,EAAE,MAAM,CAAC;AAEzE,MAAMC,IAAI,GAAIC,OAAe,IAC3B,iIAAiIJ,UAAU,CAACI,OAAO,CAAC,kIAAkIN,cAAc,qLAAqL;AAE3d,OAAO,SAASO,eAAeA,CAC7BC,OAAqB,EACrBC,mBAA6C,EAC7C;EACA,MAAMC,cAAc,GAAGF,OAAO,EAAEG,OAAO,CAACC,GAAG,CAAC,iBAAiB,CAAC,IAAI,EAAE;EACpE,MAAMC,MAAM,GACVH,cAAc,CAACI,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAEA,KAAK,CAAC,GAAG,CAAC,CAAC,CAAC,CAAC,EAAEC,IAAI,CAAC,CAAC,CAACC,WAAW,CAAC,CAAC,IAAI,IAAI;EAC3E,MAAM;IAAEV;EAAQ,CAAC,GAAGL,iBAAiB,CAACY,MAAM,EAAEJ,mBAAmB,CAAC,CAACQ,SAAS;EAC5E,OAAO,IAAIlB,YAAY,CAACM,IAAI,CAACC,OAAO,CAAC,EAAE;IACrCK,OAAO,EAAE;MACP,cAAc,EAAE,0BAA0B;MAC1CO,IAAI,EAAE;IACR;EACF,CAAC,CAAC;AACJ","ignoreList":[]}
|
|
@@ -1,6 +1,3 @@
|
|
|
1
1
|
import { NextResponse, type NextRequest } from 'next/server';
|
|
2
|
-
import type { NodeHiveAuthConfig } from '../config';
|
|
3
|
-
export declare function handleRefresh(request: NextRequest, config: NodeHiveAuthConfig): Promise<NextResponse<
|
|
4
|
-
ok: boolean;
|
|
5
|
-
}>>;
|
|
6
|
-
//# sourceMappingURL=refresh.d.ts.map
|
|
2
|
+
import type { NodeHiveAuthConfig } from '../config.js';
|
|
3
|
+
export declare function handleRefresh(request: NextRequest, config: NodeHiveAuthConfig): Promise<NextResponse<unknown>>;
|
|
@@ -1,10 +1,16 @@
|
|
|
1
1
|
import { NextResponse } from 'next/server';
|
|
2
|
-
import { enablePersistentDraftMode, shouldEnableDraftMode } from
|
|
3
|
-
import { clearAuthCookies, isAuthFailure, refreshSession } from
|
|
2
|
+
import { enablePersistentDraftMode, shouldEnableDraftMode } from "../draft-mode.js";
|
|
3
|
+
import { clearAuthCookies, isAuthFailure, refreshSession } from "../refresh.js";
|
|
4
|
+
import { isSameOriginRequest } from "../same-origin.js";
|
|
4
5
|
|
|
5
6
|
// The primary refresh path is the silent middleware refresh in src/proxy.ts;
|
|
6
7
|
// this route exposes the same race-protected primitive for explicit triggers.
|
|
7
8
|
export async function handleRefresh(request, config) {
|
|
9
|
+
if (!isSameOriginRequest(request)) {
|
|
10
|
+
return new NextResponse('Forbidden', {
|
|
11
|
+
status: 403
|
|
12
|
+
});
|
|
13
|
+
}
|
|
8
14
|
const response = NextResponse.json({
|
|
9
15
|
ok: true
|
|
10
16
|
}, {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"refresh.js","names":["NextResponse","enablePersistentDraftMode","shouldEnableDraftMode","clearAuthCookies","isAuthFailure","refreshSession","handleRefresh","request","config","response","json","ok","
|
|
1
|
+
{"version":3,"file":"refresh.js","names":["NextResponse","enablePersistentDraftMode","shouldEnableDraftMode","clearAuthCookies","isAuthFailure","refreshSession","isSameOriginRequest","handleRefresh","request","config","status","response","json","ok","error","unauthorized","console","warn"],"sources":["../../../../src/auth/internal/routes/refresh.ts"],"sourcesContent":["import { NextResponse, type NextRequest } from 'next/server';\n\nimport type { NodeHiveAuthConfig } from '../config.ts';\nimport {\n enablePersistentDraftMode,\n shouldEnableDraftMode,\n} from '../draft-mode.ts';\nimport { clearAuthCookies, isAuthFailure, refreshSession } from '../refresh.ts';\nimport { isSameOriginRequest } from '../same-origin.ts';\n\n// The primary refresh path is the silent middleware refresh in src/proxy.ts;\n// this route exposes the same race-protected primitive for explicit triggers.\nexport async function handleRefresh(\n request: NextRequest,\n config: NodeHiveAuthConfig\n) {\n if (!isSameOriginRequest(request)) {\n return new NextResponse('Forbidden', { status: 403 });\n }\n\n const response = NextResponse.json({ ok: true }, { status: 200 });\n\n try {\n await refreshSession(request, response, config);\n // Session proven valid → also renew the draft cookie's lifetime. The\n // proxy context sees the user_details the refresh just wrote.\n if (await shouldEnableDraftMode(config, { request, response })) {\n await enablePersistentDraftMode();\n }\n return response;\n } catch (error) {\n if (isAuthFailure(error)) {\n const unauthorized = NextResponse.json(\n { ok: false, error: 'invalid_grant' },\n { status: 401 }\n );\n clearAuthCookies(request, unauthorized);\n return unauthorized;\n }\n console.warn('[OAuth refresh] transient failure', error);\n return NextResponse.json(\n { ok: false, error: 'unavailable' },\n { status: 503 }\n );\n }\n}\n"],"mappings":"AAAA,SAASA,YAAY,QAA0B,aAAa;AAG5D,SACEC,yBAAyB,EACzBC,qBAAqB,QAChB,kBAAkB;AACzB,SAASC,gBAAgB,EAAEC,aAAa,EAAEC,cAAc,QAAQ,eAAe;AAC/E,SAASC,mBAAmB,QAAQ,mBAAmB;;AAEvD;AACA;AACA,OAAO,eAAeC,aAAaA,CACjCC,OAAoB,EACpBC,MAA0B,EAC1B;EACA,IAAI,CAACH,mBAAmB,CAACE,OAAO,CAAC,EAAE;IACjC,OAAO,IAAIR,YAAY,CAAC,WAAW,EAAE;MAAEU,MAAM,EAAE;IAAI,CAAC,CAAC;EACvD;EAEA,MAAMC,QAAQ,GAAGX,YAAY,CAACY,IAAI,CAAC;IAAEC,EAAE,EAAE;EAAK,CAAC,EAAE;IAAEH,MAAM,EAAE;EAAI,CAAC,CAAC;EAEjE,IAAI;IACF,MAAML,cAAc,CAACG,OAAO,EAAEG,QAAQ,EAAEF,MAAM,CAAC;IAC/C;IACA;IACA,IAAI,MAAMP,qBAAqB,CAACO,MAAM,EAAE;MAAED,OAAO;MAAEG;IAAS,CAAC,CAAC,EAAE;MAC9D,MAAMV,yBAAyB,CAAC,CAAC;IACnC;IACA,OAAOU,QAAQ;EACjB,CAAC,CAAC,OAAOG,KAAK,EAAE;IACd,IAAIV,aAAa,CAACU,KAAK,CAAC,EAAE;MACxB,MAAMC,YAAY,GAAGf,YAAY,CAACY,IAAI,CACpC;QAAEC,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