@teleporthq/teleport-project-generator-next 0.44.10 → 0.44.11
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/__tests__/password-wall.test.ts +206 -0
- package/dist/cjs/index.d.ts +2 -0
- package/dist/cjs/index.d.ts.map +1 -1
- package/dist/cjs/index.js +44 -35
- package/dist/cjs/index.js.map +1 -1
- package/dist/cjs/password-wall/constants.d.ts +32 -0
- package/dist/cjs/password-wall/constants.d.ts.map +1 -0
- package/dist/cjs/password-wall/constants.js +41 -0
- package/dist/cjs/password-wall/constants.js.map +1 -0
- package/dist/cjs/password-wall/gate-source.d.ts +11 -0
- package/dist/cjs/password-wall/gate-source.d.ts.map +1 -0
- package/dist/cjs/password-wall/gate-source.js +53 -0
- package/dist/cjs/password-wall/gate-source.js.map +1 -0
- package/dist/cjs/password-wall/helper-source.d.ts +7 -0
- package/dist/cjs/password-wall/helper-source.d.ts.map +1 -0
- package/dist/cjs/password-wall/helper-source.js +12 -0
- package/dist/cjs/password-wall/helper-source.js.map +1 -0
- package/dist/cjs/password-wall/page-html.d.ts +13 -0
- package/dist/cjs/password-wall/page-html.d.ts.map +1 -0
- package/dist/cjs/password-wall/page-html.js +25 -0
- package/dist/cjs/password-wall/page-html.js.map +1 -0
- package/dist/cjs/password-wall/project-plugin.d.ts +17 -0
- package/dist/cjs/password-wall/project-plugin.d.ts.map +1 -0
- package/dist/cjs/password-wall/project-plugin.js +121 -0
- package/dist/cjs/password-wall/project-plugin.js.map +1 -0
- package/dist/cjs/password-wall/sign-in-route-source.d.ts +17 -0
- package/dist/cjs/password-wall/sign-in-route-source.d.ts.map +1 -0
- package/dist/cjs/password-wall/sign-in-route-source.js +31 -0
- package/dist/cjs/password-wall/sign-in-route-source.js.map +1 -0
- package/dist/cjs/tsconfig.tsbuildinfo +1 -1
- package/dist/esm/index.d.ts +2 -0
- package/dist/esm/index.d.ts.map +1 -1
- package/dist/esm/index.js +8 -2
- package/dist/esm/index.js.map +1 -1
- package/dist/esm/password-wall/constants.d.ts +32 -0
- package/dist/esm/password-wall/constants.d.ts.map +1 -0
- package/dist/esm/password-wall/constants.js +38 -0
- package/dist/esm/password-wall/constants.js.map +1 -0
- package/dist/esm/password-wall/gate-source.d.ts +11 -0
- package/dist/esm/password-wall/gate-source.d.ts.map +1 -0
- package/dist/esm/password-wall/gate-source.js +48 -0
- package/dist/esm/password-wall/gate-source.js.map +1 -0
- package/dist/esm/password-wall/helper-source.d.ts +7 -0
- package/dist/esm/password-wall/helper-source.d.ts.map +1 -0
- package/dist/esm/password-wall/helper-source.js +8 -0
- package/dist/esm/password-wall/helper-source.js.map +1 -0
- package/dist/esm/password-wall/page-html.d.ts +13 -0
- package/dist/esm/password-wall/page-html.d.ts.map +1 -0
- package/dist/esm/password-wall/page-html.js +21 -0
- package/dist/esm/password-wall/page-html.js.map +1 -0
- package/dist/esm/password-wall/project-plugin.d.ts +17 -0
- package/dist/esm/password-wall/project-plugin.d.ts.map +1 -0
- package/dist/esm/password-wall/project-plugin.js +118 -0
- package/dist/esm/password-wall/project-plugin.js.map +1 -0
- package/dist/esm/password-wall/sign-in-route-source.d.ts +17 -0
- package/dist/esm/password-wall/sign-in-route-source.d.ts.map +1 -0
- package/dist/esm/password-wall/sign-in-route-source.js +27 -0
- package/dist/esm/password-wall/sign-in-route-source.js.map +1 -0
- package/dist/esm/tsconfig.tsbuildinfo +1 -1
- package/package.json +21 -21
- package/src/index.ts +8 -0
- package/src/password-wall/constants.ts +41 -0
- package/src/password-wall/gate-source.ts +146 -0
- package/src/password-wall/helper-source.ts +96 -0
- package/src/password-wall/page-html.ts +123 -0
- package/src/password-wall/project-plugin.ts +77 -0
- package/src/password-wall/sign-in-route-source.ts +99 -0
|
@@ -0,0 +1,206 @@
|
|
|
1
|
+
import { createHmac, webcrypto } from 'crypto'
|
|
2
|
+
import vm from 'vm'
|
|
3
|
+
import standalone from 'prettier/standalone.js'
|
|
4
|
+
import parserBabel from 'prettier/parser-babel.js'
|
|
5
|
+
import { FileType, ProjectPluginStructure, ProjectUIDL } from '@teleporthq/teleport-types'
|
|
6
|
+
import { NextPasswordWallProjectPlugin } from '../src/password-wall/project-plugin'
|
|
7
|
+
import { buildStandaloneWallMiddleware, wrapMiddlewareWithWall } from '../src/password-wall/gate-source'
|
|
8
|
+
import { buildWallHelperSource } from '../src/password-wall/helper-source'
|
|
9
|
+
import { buildPasswordPageModule } from '../src/password-wall/page-html'
|
|
10
|
+
import { buildSignInRouteSource } from '../src/password-wall/sign-in-route-source'
|
|
11
|
+
import { WALL_ENV_KEYS, WALL_MATCHER } from '../src/password-wall/constants'
|
|
12
|
+
import { generateMiddlewareFile } from '../../teleport-plugin-next-workflows/src/auth-generator'
|
|
13
|
+
|
|
14
|
+
const structureFor = (
|
|
15
|
+
settings: Record<string, unknown> = {},
|
|
16
|
+
files: ProjectPluginStructure['files'] = new Map()
|
|
17
|
+
): ProjectPluginStructure =>
|
|
18
|
+
({
|
|
19
|
+
uidl: {
|
|
20
|
+
name: 'site',
|
|
21
|
+
globals: { settings: { title: 'Harbor Store', language: 'en', ...settings }, meta: [], assets: [] },
|
|
22
|
+
root: {} as never,
|
|
23
|
+
} as unknown as ProjectUIDL,
|
|
24
|
+
template: { name: 'site', files: [], subFolders: [] },
|
|
25
|
+
files,
|
|
26
|
+
dependencies: {},
|
|
27
|
+
devDependencies: {},
|
|
28
|
+
strategy: {} as never,
|
|
29
|
+
rootFolder: { name: 'site', files: [], subFolders: [] },
|
|
30
|
+
}) as ProjectPluginStructure
|
|
31
|
+
|
|
32
|
+
const fileOf = (files: ProjectPluginStructure['files'], key: string) => files.get(key)!.files[0]
|
|
33
|
+
|
|
34
|
+
/**
|
|
35
|
+
* A module evaluated the way the Edge runtime would: `process.env` as the
|
|
36
|
+
* publish wrote it, Web Crypto only, ESM exports collected by hand.
|
|
37
|
+
*/
|
|
38
|
+
const evaluateHelper = (env: Record<string, string>) => {
|
|
39
|
+
const source = buildWallHelperSource()
|
|
40
|
+
.replace(/export (var|function|async function) /g, '$1 ')
|
|
41
|
+
.replace(/export \{[^}]*\}/g, '')
|
|
42
|
+
const exported: Record<string, unknown> = {}
|
|
43
|
+
const script = `${source}\n;Object.assign(exported, { wallConfig, wallConfigured, isOpenPath, cookieValueFor, sameValue })`
|
|
44
|
+
vm.runInNewContext(script, {
|
|
45
|
+
process: { env },
|
|
46
|
+
TextEncoder,
|
|
47
|
+
crypto: webcrypto,
|
|
48
|
+
exported,
|
|
49
|
+
})
|
|
50
|
+
return exported as {
|
|
51
|
+
wallConfigured: () => boolean
|
|
52
|
+
isOpenPath: (path: string) => boolean
|
|
53
|
+
cookieValueFor: (version: string) => Promise<string>
|
|
54
|
+
sameValue: (a: string, b: string) => boolean
|
|
55
|
+
}
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
/**
|
|
59
|
+
* The wall is a security control: a trial site must stay behind it whatever
|
|
60
|
+
* else the site has, so the plugin must emit its four files for every site
|
|
61
|
+
* and must put the gate in FRONT of the members-only middleware, never beside
|
|
62
|
+
* it or behind it.
|
|
63
|
+
*/
|
|
64
|
+
describe('NextPasswordWallProjectPlugin', () => {
|
|
65
|
+
it('gives a site without middleware the gate, the page, the route and the helper', async () => {
|
|
66
|
+
const structure = await new NextPasswordWallProjectPlugin().runAfter(structureFor())
|
|
67
|
+
const { files, uidl } = structure
|
|
68
|
+
|
|
69
|
+
const middleware = fileOf(files, 'auth-middleware')
|
|
70
|
+
expect(files.get('auth-middleware')!.path).toEqual([])
|
|
71
|
+
expect(middleware.name).toBe('middleware')
|
|
72
|
+
expect(middleware.fileType).toBe(FileType.JS)
|
|
73
|
+
expect(middleware.content).toContain('export default async function middleware(request, event)')
|
|
74
|
+
expect(middleware.content).toContain(`matcher: ${WALL_MATCHER}`)
|
|
75
|
+
|
|
76
|
+
expect(files.get('site-wall-page')!.path).toEqual(['utils'])
|
|
77
|
+
expect(fileOf(files, 'site-wall-page').name).toBe('site-wall-page')
|
|
78
|
+
expect(files.get('site-wall-sign-in-route')!.path).toEqual(['pages', 'api'])
|
|
79
|
+
expect(fileOf(files, 'site-wall-sign-in-route').name).toBe('site-password')
|
|
80
|
+
expect(files.get('site-wall-helper')!.path).toEqual(['utils'])
|
|
81
|
+
|
|
82
|
+
for (const key of WALL_ENV_KEYS) {
|
|
83
|
+
expect(uidl.globals.env).toHaveProperty(key, '')
|
|
84
|
+
}
|
|
85
|
+
})
|
|
86
|
+
|
|
87
|
+
it('keeps an env value the project already names', async () => {
|
|
88
|
+
const structure = structureFor()
|
|
89
|
+
structure.uidl.globals.env = { TELEPORT_API_URL: 'https://api.example.com', OTHER: 'x' }
|
|
90
|
+
await new NextPasswordWallProjectPlugin().runAfter(structure)
|
|
91
|
+
expect(structure.uidl.globals.env.TELEPORT_API_URL).toBe('https://api.example.com')
|
|
92
|
+
expect(structure.uidl.globals.env.OTHER).toBe('x')
|
|
93
|
+
expect(structure.uidl.globals.env.TELEPORT_WALL).toBe('')
|
|
94
|
+
})
|
|
95
|
+
|
|
96
|
+
it('puts the gate in front of the members-only middleware the workflows plugin emitted', async () => {
|
|
97
|
+
const authSource = generateMiddlewareFile({
|
|
98
|
+
authPages: { signIn: { route: '/sign-in' } },
|
|
99
|
+
pageProtection: { p1: { route: '/account', requiresAuth: true, allowedRoles: [] } },
|
|
100
|
+
} as never)
|
|
101
|
+
const files: ProjectPluginStructure['files'] = new Map()
|
|
102
|
+
files.set('auth-middleware', {
|
|
103
|
+
path: [],
|
|
104
|
+
files: [{ name: 'middleware', fileType: FileType.JS, content: authSource }],
|
|
105
|
+
})
|
|
106
|
+
|
|
107
|
+
await new NextPasswordWallProjectPlugin().runAfter(structureFor({}, files))
|
|
108
|
+
const wrapped = fileOf(files, 'auth-middleware').content
|
|
109
|
+
|
|
110
|
+
expect(wrapped).toContain('async function middleware(request)')
|
|
111
|
+
expect(wrapped).toContain('export default __tqWalledMiddleware;')
|
|
112
|
+
expect(wrapped).not.toContain('export default middleware;')
|
|
113
|
+
expect(wrapped.indexOf('var gate = await __tqWallGate(request, event);')).toBeGreaterThan(-1)
|
|
114
|
+
expect(wrapped).toContain(`matcher: ${WALL_MATCHER}`)
|
|
115
|
+
expect(wrapped).not.toContain('favicon')
|
|
116
|
+
expect(wrapped.match(/export const config = \{/g)).toHaveLength(1)
|
|
117
|
+
expect(wrapped).toContain("from './utils/site-wall'")
|
|
118
|
+
})
|
|
119
|
+
|
|
120
|
+
it('refuses to wrap a middleware it does not recognise rather than leaving the site open', () => {
|
|
121
|
+
expect(() => wrapMiddlewareWithWall('export default function other() {}')).toThrow(
|
|
122
|
+
/default export/
|
|
123
|
+
)
|
|
124
|
+
expect(() => wrapMiddlewareWithWall('export default middleware;')).toThrow(/matcher/)
|
|
125
|
+
expect(buildStandaloneWallMiddleware()).toContain('__tqWallGate')
|
|
126
|
+
})
|
|
127
|
+
|
|
128
|
+
it('shows TeleportHQ on the password page unless a logo was set, and the route answers 401', () => {
|
|
129
|
+
const branded = buildPasswordPageModule({ siteTitle: "Harbor's Store" })
|
|
130
|
+
expect(branded).toContain('aria-label=\\"TeleportHQ\\"')
|
|
131
|
+
expect(branded).toContain("export var CUSTOM_LOGO = '';")
|
|
132
|
+
expect(branded).toContain("export var SITE_TITLE = 'Harbor\\'s Store';")
|
|
133
|
+
expect(branded).toContain("<meta name='robots' content='noindex, nofollow'>")
|
|
134
|
+
|
|
135
|
+
const own = buildPasswordPageModule({ logoUrl: 'https://cdn.example.com/logo.png' })
|
|
136
|
+
expect(own).toContain("export var CUSTOM_LOGO = 'https://cdn.example.com/logo.png';")
|
|
137
|
+
|
|
138
|
+
// Only a web address is taken as a logo.
|
|
139
|
+
expect(buildPasswordPageModule({ logoUrl: 'javascript:alert(1)' })).toContain(
|
|
140
|
+
"export var CUSTOM_LOGO = '';"
|
|
141
|
+
)
|
|
142
|
+
|
|
143
|
+
// The status is the route's: 401 in place of a gated page, 200 on the page's own address.
|
|
144
|
+
const route = buildSignInRouteSource()
|
|
145
|
+
expect(route).toContain('res.status(direct ? 200 : 401).send(renderPasswordPage())')
|
|
146
|
+
expect(route).toContain("req.query.page === '1'")
|
|
147
|
+
})
|
|
148
|
+
})
|
|
149
|
+
|
|
150
|
+
describe('every generated file is JavaScript a build accepts', () => {
|
|
151
|
+
const parses = (source: string) =>
|
|
152
|
+
standalone.format(source, { parser: 'babel', plugins: [parserBabel] })
|
|
153
|
+
|
|
154
|
+
it('parses the helper, both middlewares, the sign-in route and the page', () => {
|
|
155
|
+
expect(() => parses(buildWallHelperSource())).not.toThrow()
|
|
156
|
+
expect(() => parses(buildStandaloneWallMiddleware())).not.toThrow()
|
|
157
|
+
expect(() => parses(buildSignInRouteSource())).not.toThrow()
|
|
158
|
+
// The page once embedded the logo as bare markup instead of a string and
|
|
159
|
+
// every request answered 500; the logo is a string literal now.
|
|
160
|
+
expect(() => parses(buildPasswordPageModule({ siteTitle: "Harbor's Store" }))).not.toThrow()
|
|
161
|
+
expect(() =>
|
|
162
|
+
parses(buildPasswordPageModule({ logoUrl: 'https://cdn.example.com/logo.png' }))
|
|
163
|
+
).not.toThrow()
|
|
164
|
+
expect(buildPasswordPageModule()).toContain('var TELEPORT_LOGO = "<svg')
|
|
165
|
+
})
|
|
166
|
+
})
|
|
167
|
+
|
|
168
|
+
describe('the shared helper, as the Edge runtime runs it', () => {
|
|
169
|
+
const env = {
|
|
170
|
+
TELEPORT_WALL: 'on',
|
|
171
|
+
TELEPORT_WALL_VERSION: 'v1',
|
|
172
|
+
TELEPORT_WALL_SECRET: 'secret-123',
|
|
173
|
+
TELEPORT_PROJECT_ID: 'p1',
|
|
174
|
+
TELEPORT_API_URL: 'https://api.teleporthq.io/',
|
|
175
|
+
}
|
|
176
|
+
|
|
177
|
+
it('is off without the values the publish writes', () => {
|
|
178
|
+
expect(evaluateHelper({}).wallConfigured()).toBe(false)
|
|
179
|
+
expect(evaluateHelper({ ...env, TELEPORT_WALL_SECRET: '' }).wallConfigured()).toBe(false)
|
|
180
|
+
expect(evaluateHelper(env).wallConfigured()).toBe(true)
|
|
181
|
+
})
|
|
182
|
+
|
|
183
|
+
it('leaves the hashed assets and the API open, nothing else', () => {
|
|
184
|
+
const helper = evaluateHelper(env)
|
|
185
|
+
expect(helper.isOpenPath('/_next/static/chunks/main.js')).toBe(true)
|
|
186
|
+
expect(helper.isOpenPath('/api/webhooks/stripe')).toBe(true)
|
|
187
|
+
expect(helper.isOpenPath('/api')).toBe(true)
|
|
188
|
+
// The page's own address is the gate's to serve, not an open path.
|
|
189
|
+
expect(helper.isOpenPath('/site-password')).toBe(false)
|
|
190
|
+
expect(helper.isOpenPath('/')).toBe(false)
|
|
191
|
+
expect(helper.isOpenPath('/about')).toBe(false)
|
|
192
|
+
expect(helper.isOpenPath('/_next/image?url=x')).toBe(false)
|
|
193
|
+
expect(helper.isOpenPath('/_next/data/build/index.json')).toBe(false)
|
|
194
|
+
expect(helper.isOpenPath('/apiary')).toBe(false)
|
|
195
|
+
})
|
|
196
|
+
|
|
197
|
+
it('computes the same cookie value as the Node sign-in route', async () => {
|
|
198
|
+
const helper = evaluateHelper(env)
|
|
199
|
+
const fromEdge = await helper.cookieValueFor('v1')
|
|
200
|
+
const fromNode = createHmac('sha256', 'secret-123').update('wall:v1').digest('hex')
|
|
201
|
+
expect(fromEdge).toBe(fromNode)
|
|
202
|
+
expect(helper.sameValue(fromEdge, fromNode)).toBe(true)
|
|
203
|
+
expect(helper.sameValue(fromEdge, fromNode.slice(0, -1) + '0')).toBe(false)
|
|
204
|
+
expect(await helper.cookieValueFor('v2')).not.toBe(fromEdge)
|
|
205
|
+
})
|
|
206
|
+
})
|
package/dist/cjs/index.d.ts
CHANGED
|
@@ -36,6 +36,8 @@ export { createAIChatMarkdownStylesPlugin } from './ai-chat/markdown-styles-plug
|
|
|
36
36
|
export { createAIChatOptionChipsStylesPlugin } from './ai-chat/option-chips-styles-plugin';
|
|
37
37
|
export { createAIChatSessionPersistencePlugin } from './ai-chat/session-persistence-plugin';
|
|
38
38
|
export { NextAnalyticsProjectPlugin } from './analytics/project-plugin';
|
|
39
|
+
export { NextPasswordWallProjectPlugin } from './password-wall/project-plugin';
|
|
40
|
+
export { buildStandaloneWallMiddleware, wrapMiddlewareWithWall, } from './password-wall/gate-source';
|
|
39
41
|
export { NextEcommerceProjectPlugin } from './ecommerce/project-plugin';
|
|
40
42
|
export { NextBlogProjectPlugin } from './blog/project-plugin';
|
|
41
43
|
export { NextBookingProjectPlugin } from './bookings/project-plugin';
|
package/dist/cjs/index.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAiC,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAIzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,YAAY,MAAM,oBAAoB,CAAA;
|
|
1
|
+
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAiBA,OAAO,EAAiC,aAAa,EAAE,MAAM,4BAA4B,CAAA;AAIzF,OAAO,EAAE,kBAAkB,EAAE,MAAM,wBAAwB,CAAA;AAC3D,OAAO,YAAY,MAAM,oBAAoB,CAAA;AAoD7C;;;;;;;;;;;;;;;;;;;;;;;GAuBG;AACH,eAAO,MAAM,wBAAwB,QAAO,aAAa,EAoCxD,CAAA;AAED,QAAA,MAAM,0BAA0B,yEA4J/B,CAAA;AAED,OAAO,EAAE,0BAA0B,EAAE,kBAAkB,EAAE,YAAY,EAAE,CAAA;AACvE,OAAO,EAAE,oCAAoC,EAAE,MAAM,iCAAiC,CAAA;AACtF,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAA;AAC5E,OAAO,EAAE,uBAAuB,EAAE,MAAM,0BAA0B,CAAA;AAClE,OAAO,EAAE,kCAAkC,EAAE,MAAM,4BAA4B,CAAA;AAC/E,OAAO,EAAE,gCAAgC,EAAE,MAAM,kCAAkC,CA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AE,MAAM,iCAAiC,CAAA;AAChF,OAAO,EACL,8BAA8B,EAC9B,qCAAqC,GACtC,MAAM,+BAA+B,CAAA;AACtC,OAAO,EAAE,4BAA4B,EAAE,MAAM,+BAA+B,CAAA;AAC5E,OAAO,EAAE,2BAA2B,EAAE,MAAM,gCAAgC,CAAA;AAC5E,OAAO,EAAE,gCAAgC,EAAE,MAAM,4BAA4B,CAAA;AAC7E,OAAO,EAAE,2BAA2B,EAAE,MAAM,8BAA8B,CAAA;AAC1E,OAAO,EAAE,yBAAyB,EAAE,MAAM,4CAA4C,CAAA;AACtF,OAAO,EAAE,6BAA6B,EAAE,MAAM,iDAAiD,CAAA;AAC/F,OAAO,EAAE,oCAAoC,EAAE,MAAM,gDAAgD,CAAA;AACrG,OAAO,EAAE,8BAA8B,EAAE,MAAM,iCAAiC,CAAA;AAChF,OAAO,EACL,+BAA+B,EAC/B,mCAAmC,GACpC,MAAM,8CAA8C,CAAA;AACrD,OAAO,EAAE,0BAA0B,EAAE,MAAM,WAAW,CAAA;AACtD,YAAY,EACV,2BAA2B,EAC3B,uBAAuB,EACvB,oBAAoB,GACrB,MAAM,WAAW,CAAA;AAClB,OAAO,EAAE,gBAAgB,EAAE,MAAM,eAAe,CAAA;AAChD,YAAY,EAAE,kBAAkB,EAAE,MAAM,eAAe,CAAA"}
|
package/dist/cjs/index.js
CHANGED
|
@@ -12,7 +12,7 @@ var __importDefault = (this && this.__importDefault) || function (mod) {
|
|
|
12
12
|
return (mod && mod.__esModule) ? mod : { "default": mod };
|
|
13
13
|
};
|
|
14
14
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
15
|
-
exports.splitProjectUIDL = exports.createNextPartialGenerator = exports.createNextComponentDataSourcePlugin = exports.createNextPagesDataSourcePlugin = exports.createNextFormSubmissionPlugin = exports.createNextInternationalizationPlugin = exports.createNextLocaleFetcherPlugin = exports.NextWorkflowProjectPlugin = exports.NextDataSourceUtilityPlugin = exports.NextDataSourceDependenciesPlugin = exports.NextProjectPlugini18nConfig = exports.NextFormsCaptchaScriptPlugin = exports.INTERACTIVE_PRIMITIVE_COMPONENT_FILES = exports.createLocalComponentPathPlugin = exports.generateCountdownComponentCode = exports.generateKanbanComponentCode = exports.generateDragDropComponentCode = exports.createNextWidgetProjectPlugins = exports.NextCountdownProjectPlugin = exports.NextKanbanProjectPlugin = exports.NextDragDropProjectPlugin = exports.CALENDARKIT_VERSION = exports.CALENDARKIT_CSS = exports.NextCalendarKitProjectPlugin = exports.generateRichContentEmbedsComponentCode = exports.NextRichContentEmbedsProjectPlugin = exports.createRichTextEditorComponentPlugin = exports.NextRichTextEditorProjectPlugin = exports.createEntityMutationSsrFinalizerPlugin = exports.NextDashboardLayoutPlugin = exports.NextBookingProjectPlugin = exports.NextBlogProjectPlugin = exports.NextEcommerceProjectPlugin = exports.NextAnalyticsProjectPlugin = exports.createAIChatSessionPersistencePlugin = exports.createAIChatOptionChipsStylesPlugin = exports.createAIChatMarkdownStylesPlugin = exports.createAIChatLocalizedWelcomePlugin = exports.NextAIChatProjectPlugin = exports.NextGlobalStateProjectPlugin = exports.createNextGlobalStateComponentPlugin = exports.NextTemplate = exports.NextProjectMapping = exports.createNextProjectGenerator = exports.createNextProjectPlugins = void 0;
|
|
15
|
+
exports.splitProjectUIDL = exports.createNextPartialGenerator = exports.createNextComponentDataSourcePlugin = exports.createNextPagesDataSourcePlugin = exports.createNextFormSubmissionPlugin = exports.createNextInternationalizationPlugin = exports.createNextLocaleFetcherPlugin = exports.NextWorkflowProjectPlugin = exports.NextDataSourceUtilityPlugin = exports.NextDataSourceDependenciesPlugin = exports.NextProjectPlugini18nConfig = exports.NextFormsCaptchaScriptPlugin = exports.INTERACTIVE_PRIMITIVE_COMPONENT_FILES = exports.createLocalComponentPathPlugin = exports.generateCountdownComponentCode = exports.generateKanbanComponentCode = exports.generateDragDropComponentCode = exports.createNextWidgetProjectPlugins = exports.NextCountdownProjectPlugin = exports.NextKanbanProjectPlugin = exports.NextDragDropProjectPlugin = exports.CALENDARKIT_VERSION = exports.CALENDARKIT_CSS = exports.NextCalendarKitProjectPlugin = exports.generateRichContentEmbedsComponentCode = exports.NextRichContentEmbedsProjectPlugin = exports.createRichTextEditorComponentPlugin = exports.NextRichTextEditorProjectPlugin = exports.createEntityMutationSsrFinalizerPlugin = exports.NextDashboardLayoutPlugin = exports.NextBookingProjectPlugin = exports.NextBlogProjectPlugin = exports.NextEcommerceProjectPlugin = exports.wrapMiddlewareWithWall = exports.buildStandaloneWallMiddleware = exports.NextPasswordWallProjectPlugin = exports.NextAnalyticsProjectPlugin = exports.createAIChatSessionPersistencePlugin = exports.createAIChatOptionChipsStylesPlugin = exports.createAIChatMarkdownStylesPlugin = exports.createAIChatLocalizedWelcomePlugin = exports.NextAIChatProjectPlugin = exports.NextGlobalStateProjectPlugin = exports.createNextGlobalStateComponentPlugin = exports.NextTemplate = exports.NextProjectMapping = exports.createNextProjectGenerator = exports.createNextProjectPlugins = void 0;
|
|
16
16
|
var teleport_postprocessor_prettier_js_1 = __importDefault(require("@teleporthq/teleport-postprocessor-prettier-js"));
|
|
17
17
|
var teleport_plugin_jsx_next_image_1 = __importDefault(require("@teleporthq/teleport-plugin-jsx-next-image"));
|
|
18
18
|
var teleport_plugin_import_statements_1 = __importDefault(require("@teleporthq/teleport-plugin-import-statements"));
|
|
@@ -68,12 +68,13 @@ var project_plugin_18 = require("./play-sound/project-plugin");
|
|
|
68
68
|
var project_plugin_19 = require("./pagination-scroll/project-plugin");
|
|
69
69
|
var project_plugin_20 = require("./pwa/project-plugin");
|
|
70
70
|
var project_plugin_21 = require("./web-push/project-plugin");
|
|
71
|
+
var project_plugin_22 = require("./password-wall/project-plugin");
|
|
71
72
|
var security_headers_1 = require("./security-headers");
|
|
72
73
|
var widgets_1 = require("./widgets");
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
var
|
|
76
|
-
var
|
|
74
|
+
var project_plugin_23 = require("./snap-into-view/project-plugin");
|
|
75
|
+
var project_plugin_24 = require("./page-transition/project-plugin");
|
|
76
|
+
var project_plugin_25 = require("./scroll-rail/project-plugin");
|
|
77
|
+
var project_plugin_26 = require("./body-code/project-plugin");
|
|
77
78
|
var local_component_path_plugin_1 = require("./local-component-path-plugin");
|
|
78
79
|
/**
|
|
79
80
|
* The ordered list of Next.js PROJECT-level plugins (the ones added via
|
|
@@ -99,7 +100,7 @@ var local_component_path_plugin_1 = require("./local-component-path-plugin");
|
|
|
99
100
|
* runtime options (i18n sitemap config, forms-captcha script, cross-framework
|
|
100
101
|
* i18n files); those remain in packProject.
|
|
101
102
|
*/
|
|
102
|
-
var createNextProjectPlugins = function () { return __spreadArray([
|
|
103
|
+
var createNextProjectPlugins = function () { return __spreadArray(__spreadArray([
|
|
103
104
|
new data_source_dependencies_1.NextDataSourceDependenciesPlugin(),
|
|
104
105
|
new project_plugin_1.NextCacheRuntimePlugin(),
|
|
105
106
|
new project_plugin_2.NextPageRevalidatePlugin(),
|
|
@@ -112,10 +113,10 @@ var createNextProjectPlugins = function () { return __spreadArray([
|
|
|
112
113
|
new project_plugin_4.NextAIChatProjectPlugin(),
|
|
113
114
|
new project_plugin_5.NextAnalyticsProjectPlugin(),
|
|
114
115
|
new project_plugin_6.NextNavActiveLinkProjectPlugin(),
|
|
115
|
-
new
|
|
116
|
-
new
|
|
117
|
-
new
|
|
118
|
-
new
|
|
116
|
+
new project_plugin_23.NextSnapIntoViewProjectPlugin(),
|
|
117
|
+
new project_plugin_24.NextPageTransitionProjectPlugin(),
|
|
118
|
+
new project_plugin_25.NextScrollRailProjectPlugin(),
|
|
119
|
+
new project_plugin_26.NextBodyCodeProjectPlugin(),
|
|
119
120
|
new project_plugin_7.NextCollapsibleTextProjectPlugin(),
|
|
120
121
|
new dashboard_layout_plugin_1.NextDashboardLayoutPlugin(),
|
|
121
122
|
new project_plugin_11.NextRichTextEditorProjectPlugin(),
|
|
@@ -132,7 +133,10 @@ var createNextProjectPlugins = function () { return __spreadArray([
|
|
|
132
133
|
new security_headers_1.NextSecurityHeadersProjectPlugin(),
|
|
133
134
|
new project_plugin_20.NextPwaProjectPlugin(),
|
|
134
135
|
new project_plugin_21.NextWebPushProjectPlugin()
|
|
135
|
-
], (0, widgets_1.createNextWidgetProjectPlugins)(), true)
|
|
136
|
+
], (0, widgets_1.createNextWidgetProjectPlugins)(), true), [
|
|
137
|
+
// Last: wraps the middleware the workflows plugin may have emitted.
|
|
138
|
+
new project_plugin_22.NextPasswordWallProjectPlugin(),
|
|
139
|
+
], false); };
|
|
136
140
|
exports.createNextProjectPlugins = createNextProjectPlugins;
|
|
137
141
|
var createNextProjectGenerator = function () {
|
|
138
142
|
var headConfigPlugin = (0, teleport_plugin_jsx_head_config_1.createJSXHeadConfigPlugin)({
|
|
@@ -290,10 +294,10 @@ var createNextProjectGenerator = function () {
|
|
|
290
294
|
exports.createNextProjectGenerator = createNextProjectGenerator;
|
|
291
295
|
var component_plugin_4 = require("./global-state/component-plugin");
|
|
292
296
|
Object.defineProperty(exports, "createNextGlobalStateComponentPlugin", { enumerable: true, get: function () { return component_plugin_4.createNextGlobalStateComponentPlugin; } });
|
|
293
|
-
var
|
|
294
|
-
Object.defineProperty(exports, "NextGlobalStateProjectPlugin", { enumerable: true, get: function () { return
|
|
295
|
-
var
|
|
296
|
-
Object.defineProperty(exports, "NextAIChatProjectPlugin", { enumerable: true, get: function () { return
|
|
297
|
+
var project_plugin_27 = require("./global-state/project-plugin");
|
|
298
|
+
Object.defineProperty(exports, "NextGlobalStateProjectPlugin", { enumerable: true, get: function () { return project_plugin_27.NextGlobalStateProjectPlugin; } });
|
|
299
|
+
var project_plugin_28 = require("./ai-chat/project-plugin");
|
|
300
|
+
Object.defineProperty(exports, "NextAIChatProjectPlugin", { enumerable: true, get: function () { return project_plugin_28.NextAIChatProjectPlugin; } });
|
|
297
301
|
var component_plugin_5 = require("./ai-chat/component-plugin");
|
|
298
302
|
Object.defineProperty(exports, "createAIChatLocalizedWelcomePlugin", { enumerable: true, get: function () { return component_plugin_5.createAIChatLocalizedWelcomePlugin; } });
|
|
299
303
|
var markdown_styles_plugin_2 = require("./ai-chat/markdown-styles-plugin");
|
|
@@ -302,37 +306,42 @@ var option_chips_styles_plugin_2 = require("./ai-chat/option-chips-styles-plugin
|
|
|
302
306
|
Object.defineProperty(exports, "createAIChatOptionChipsStylesPlugin", { enumerable: true, get: function () { return option_chips_styles_plugin_2.createAIChatOptionChipsStylesPlugin; } });
|
|
303
307
|
var session_persistence_plugin_2 = require("./ai-chat/session-persistence-plugin");
|
|
304
308
|
Object.defineProperty(exports, "createAIChatSessionPersistencePlugin", { enumerable: true, get: function () { return session_persistence_plugin_2.createAIChatSessionPersistencePlugin; } });
|
|
305
|
-
var
|
|
306
|
-
Object.defineProperty(exports, "NextAnalyticsProjectPlugin", { enumerable: true, get: function () { return
|
|
307
|
-
var
|
|
308
|
-
Object.defineProperty(exports, "
|
|
309
|
-
var
|
|
310
|
-
Object.defineProperty(exports, "
|
|
311
|
-
|
|
312
|
-
|
|
309
|
+
var project_plugin_29 = require("./analytics/project-plugin");
|
|
310
|
+
Object.defineProperty(exports, "NextAnalyticsProjectPlugin", { enumerable: true, get: function () { return project_plugin_29.NextAnalyticsProjectPlugin; } });
|
|
311
|
+
var project_plugin_30 = require("./password-wall/project-plugin");
|
|
312
|
+
Object.defineProperty(exports, "NextPasswordWallProjectPlugin", { enumerable: true, get: function () { return project_plugin_30.NextPasswordWallProjectPlugin; } });
|
|
313
|
+
var gate_source_1 = require("./password-wall/gate-source");
|
|
314
|
+
Object.defineProperty(exports, "buildStandaloneWallMiddleware", { enumerable: true, get: function () { return gate_source_1.buildStandaloneWallMiddleware; } });
|
|
315
|
+
Object.defineProperty(exports, "wrapMiddlewareWithWall", { enumerable: true, get: function () { return gate_source_1.wrapMiddlewareWithWall; } });
|
|
316
|
+
var project_plugin_31 = require("./ecommerce/project-plugin");
|
|
317
|
+
Object.defineProperty(exports, "NextEcommerceProjectPlugin", { enumerable: true, get: function () { return project_plugin_31.NextEcommerceProjectPlugin; } });
|
|
318
|
+
var project_plugin_32 = require("./blog/project-plugin");
|
|
319
|
+
Object.defineProperty(exports, "NextBlogProjectPlugin", { enumerable: true, get: function () { return project_plugin_32.NextBlogProjectPlugin; } });
|
|
320
|
+
var project_plugin_33 = require("./bookings/project-plugin");
|
|
321
|
+
Object.defineProperty(exports, "NextBookingProjectPlugin", { enumerable: true, get: function () { return project_plugin_33.NextBookingProjectPlugin; } });
|
|
313
322
|
var dashboard_layout_plugin_2 = require("./dashboard-layout-plugin");
|
|
314
323
|
Object.defineProperty(exports, "NextDashboardLayoutPlugin", { enumerable: true, get: function () { return dashboard_layout_plugin_2.NextDashboardLayoutPlugin; } });
|
|
315
324
|
var entity_mutation_ssr_finalize_plugin_2 = require("./entity-mutation-ssr-finalize-plugin");
|
|
316
325
|
Object.defineProperty(exports, "createEntityMutationSsrFinalizerPlugin", { enumerable: true, get: function () { return entity_mutation_ssr_finalize_plugin_2.createEntityMutationSsrFinalizerPlugin; } });
|
|
317
|
-
var
|
|
318
|
-
Object.defineProperty(exports, "NextRichTextEditorProjectPlugin", { enumerable: true, get: function () { return
|
|
326
|
+
var project_plugin_34 = require("./rich-text-editor/project-plugin");
|
|
327
|
+
Object.defineProperty(exports, "NextRichTextEditorProjectPlugin", { enumerable: true, get: function () { return project_plugin_34.NextRichTextEditorProjectPlugin; } });
|
|
319
328
|
var component_plugin_6 = require("./rich-text-editor/component-plugin");
|
|
320
329
|
Object.defineProperty(exports, "createRichTextEditorComponentPlugin", { enumerable: true, get: function () { return component_plugin_6.createRichTextEditorComponentPlugin; } });
|
|
321
|
-
var
|
|
322
|
-
Object.defineProperty(exports, "NextRichContentEmbedsProjectPlugin", { enumerable: true, get: function () { return
|
|
330
|
+
var project_plugin_35 = require("./rich-content-embeds/project-plugin");
|
|
331
|
+
Object.defineProperty(exports, "NextRichContentEmbedsProjectPlugin", { enumerable: true, get: function () { return project_plugin_35.NextRichContentEmbedsProjectPlugin; } });
|
|
323
332
|
var embed_activator_component_1 = require("./rich-content-embeds/embed-activator-component");
|
|
324
333
|
Object.defineProperty(exports, "generateRichContentEmbedsComponentCode", { enumerable: true, get: function () { return embed_activator_component_1.generateRichContentEmbedsComponentCode; } });
|
|
325
|
-
var
|
|
326
|
-
Object.defineProperty(exports, "NextCalendarKitProjectPlugin", { enumerable: true, get: function () { return
|
|
334
|
+
var project_plugin_36 = require("./calendar/project-plugin");
|
|
335
|
+
Object.defineProperty(exports, "NextCalendarKitProjectPlugin", { enumerable: true, get: function () { return project_plugin_36.NextCalendarKitProjectPlugin; } });
|
|
327
336
|
var calendarkit_css_1 = require("./calendar/calendarkit-css");
|
|
328
337
|
Object.defineProperty(exports, "CALENDARKIT_CSS", { enumerable: true, get: function () { return calendarkit_css_1.CALENDARKIT_CSS; } });
|
|
329
338
|
Object.defineProperty(exports, "CALENDARKIT_VERSION", { enumerable: true, get: function () { return calendarkit_css_1.CALENDARKIT_VERSION; } });
|
|
330
|
-
var
|
|
331
|
-
Object.defineProperty(exports, "NextDragDropProjectPlugin", { enumerable: true, get: function () { return
|
|
332
|
-
var
|
|
333
|
-
Object.defineProperty(exports, "NextKanbanProjectPlugin", { enumerable: true, get: function () { return
|
|
334
|
-
var
|
|
335
|
-
Object.defineProperty(exports, "NextCountdownProjectPlugin", { enumerable: true, get: function () { return
|
|
339
|
+
var project_plugin_37 = require("./drag-drop/project-plugin");
|
|
340
|
+
Object.defineProperty(exports, "NextDragDropProjectPlugin", { enumerable: true, get: function () { return project_plugin_37.NextDragDropProjectPlugin; } });
|
|
341
|
+
var project_plugin_38 = require("./kanban/project-plugin");
|
|
342
|
+
Object.defineProperty(exports, "NextKanbanProjectPlugin", { enumerable: true, get: function () { return project_plugin_38.NextKanbanProjectPlugin; } });
|
|
343
|
+
var project_plugin_39 = require("./countdown/project-plugin");
|
|
344
|
+
Object.defineProperty(exports, "NextCountdownProjectPlugin", { enumerable: true, get: function () { return project_plugin_39.NextCountdownProjectPlugin; } });
|
|
336
345
|
// Re-exported so `packProject` (in @teleporthq/teleport-code-generator) can re-add
|
|
337
346
|
// the npm-backed widget primitives after it calls cleanPlugins(); the plugins
|
|
338
347
|
// registered inside createNextProjectGenerator are wiped by that path.
|
package/dist/cjs/index.js.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sHAAuE;AACvE,8GAAwE;AACxE,oHAAkF;AAClF,qFAA+E;AAC/E,yFAAmF;AACnF,qGAA8F;AAC9F,+FAAuF;AACvF,mGAAuF;AACvF,mGAAuF;AACvF,mGAGsD;AACtD,iGAGqD;AACrD,6DAAyF;AACzF,uEAAwE;AACxE,iCAA0E;AAC1E,uEAAwE;AACxE,+DAA2D;
|
|
1
|
+
{"version":3,"file":"index.js","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;AAAA,sHAAuE;AACvE,8GAAwE;AACxE,oHAAkF;AAClF,qFAA+E;AAC/E,yFAAmF;AACnF,qGAA8F;AAC9F,+FAAuF;AACvF,mGAAuF;AACvF,mGAAuF;AACvF,mGAGsD;AACtD,iGAGqD;AACrD,6DAAyF;AACzF,uEAAwE;AACxE,iCAA0E;AAC1E,uEAAwE;AACxE,+DAA2D;AAiRtB,mGAjR5B,yCAAkB,OAiR4B;AAhRvD,wEAA6C;AAgRY,uBAhRlD,0BAAY,CAgRkD;AA/QrE,0FAAqG;AACrG,+DAA+E;AAC/E,2EAAmF;AACnF,mFAA0F;AAC1F,mFAA2F;AAC3F,uEAA4E;AAC5E,4FAA+F;AAC/F,2EAAgF;AAChF,uEAA6E;AAC7E,yDAA+D;AAC/D,mEAA2E;AAC3E,2EAA0E;AAC1E,6FAGmD;AACnD,oEAAsF;AACtF,gEAA4E;AAC5E,2DAAkE;AAClE,6DAAuE;AACvE,mEAAiF;AACjF,oEAAoF;AACpF,6DAAuE;AACvE,wDAA6D;AAC7D,6DAAoE;AACpE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C,qHAAA,0BAA0B,OAAA;AAMnC,6CAAgD;AAAvC,+GAAA,gBAAgB,OAAA"}
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* The address of the password page. Not a page of the site: the middleware
|
|
3
|
+
* rewrites it, like every gated request, to the sign-in route, which serves
|
|
4
|
+
* the page with the status the wall needs.
|
|
5
|
+
*/
|
|
6
|
+
export declare const PASSWORD_PAGE_ROUTE = "/site-password";
|
|
7
|
+
/** The site's own route the password page posts to (same origin, so it stays open). */
|
|
8
|
+
export declare const SIGN_IN_ROUTE = "/api/site-password";
|
|
9
|
+
/** The cookie a visitor holds once the password was accepted. */
|
|
10
|
+
export declare const WALL_COOKIE = "tq_wall";
|
|
11
|
+
/**
|
|
12
|
+
* Written into the site's `.env` empty; the platform fills them at publish.
|
|
13
|
+
* Empty, the wall stays off: a downloaded site and a local run behave as if
|
|
14
|
+
* the files were not there.
|
|
15
|
+
*/
|
|
16
|
+
export declare const WALL_ENV_KEYS: readonly ["TELEPORT_WALL", "TELEPORT_WALL_VERSION", "TELEPORT_WALL_SECRET", "TELEPORT_PROJECT_ID", "TELEPORT_API_URL"];
|
|
17
|
+
/** Where the shared helper lands, imported by the middleware and the sign-in route. */
|
|
18
|
+
export declare const WALL_HELPER_PATH: string[];
|
|
19
|
+
export declare const WALL_HELPER_NAME = "site-wall";
|
|
20
|
+
/** The password page as HTML, next to the helper; the sign-in route serves it. */
|
|
21
|
+
export declare const WALL_PAGE_HELPER_NAME = "site-wall-page";
|
|
22
|
+
/** The `files` key the workflows plugin uses for the site's middleware. */
|
|
23
|
+
export declare const MIDDLEWARE_FILES_KEY = "auth-middleware";
|
|
24
|
+
/**
|
|
25
|
+
* The middleware runs on every page and asset except the site's own hashed
|
|
26
|
+
* scripts and styles (no content in them) and its API routes: payment
|
|
27
|
+
* webhooks, cron runs and the site's own server-side calls must keep working,
|
|
28
|
+
* and the password page posts to one of them. The bare '/' entry is required
|
|
29
|
+
* because Next.js does not run a negative-lookahead matcher for the root path.
|
|
30
|
+
*/
|
|
31
|
+
export declare const WALL_MATCHER = "['/', '/((?!api|_next/static).*)']";
|
|
32
|
+
//# sourceMappingURL=constants.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.d.ts","sourceRoot":"","sources":["../../../src/password-wall/constants.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,eAAO,MAAM,mBAAmB,mBAAmB,CAAA;AACnD,uFAAuF;AACvF,eAAO,MAAM,aAAa,uBAAuB,CAAA;AACjD,iEAAiE;AACjE,eAAO,MAAM,WAAW,YAAY,CAAA;AAEpC;;;;GAIG;AACH,eAAO,MAAM,aAAa,wHAMhB,CAAA;AAEV,uFAAuF;AACvF,eAAO,MAAM,gBAAgB,UAAY,CAAA;AACzC,eAAO,MAAM,gBAAgB,cAAc,CAAA;AAC3C,kFAAkF;AAClF,eAAO,MAAM,qBAAqB,mBAAmB,CAAA;AAErD,2EAA2E;AAC3E,eAAO,MAAM,oBAAoB,oBAAoB,CAAA;AAErD;;;;;;GAMG;AACH,eAAO,MAAM,YAAY,uCAAuC,CAAA"}
|
|
@@ -0,0 +1,41 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.WALL_MATCHER = exports.MIDDLEWARE_FILES_KEY = exports.WALL_PAGE_HELPER_NAME = exports.WALL_HELPER_NAME = exports.WALL_HELPER_PATH = exports.WALL_ENV_KEYS = exports.WALL_COOKIE = exports.SIGN_IN_ROUTE = exports.PASSWORD_PAGE_ROUTE = void 0;
|
|
4
|
+
/**
|
|
5
|
+
* The address of the password page. Not a page of the site: the middleware
|
|
6
|
+
* rewrites it, like every gated request, to the sign-in route, which serves
|
|
7
|
+
* the page with the status the wall needs.
|
|
8
|
+
*/
|
|
9
|
+
exports.PASSWORD_PAGE_ROUTE = '/site-password';
|
|
10
|
+
/** The site's own route the password page posts to (same origin, so it stays open). */
|
|
11
|
+
exports.SIGN_IN_ROUTE = '/api/site-password';
|
|
12
|
+
/** The cookie a visitor holds once the password was accepted. */
|
|
13
|
+
exports.WALL_COOKIE = 'tq_wall';
|
|
14
|
+
/**
|
|
15
|
+
* Written into the site's `.env` empty; the platform fills them at publish.
|
|
16
|
+
* Empty, the wall stays off: a downloaded site and a local run behave as if
|
|
17
|
+
* the files were not there.
|
|
18
|
+
*/
|
|
19
|
+
exports.WALL_ENV_KEYS = [
|
|
20
|
+
'TELEPORT_WALL',
|
|
21
|
+
'TELEPORT_WALL_VERSION',
|
|
22
|
+
'TELEPORT_WALL_SECRET',
|
|
23
|
+
'TELEPORT_PROJECT_ID',
|
|
24
|
+
'TELEPORT_API_URL',
|
|
25
|
+
];
|
|
26
|
+
/** Where the shared helper lands, imported by the middleware and the sign-in route. */
|
|
27
|
+
exports.WALL_HELPER_PATH = ['utils'];
|
|
28
|
+
exports.WALL_HELPER_NAME = 'site-wall';
|
|
29
|
+
/** The password page as HTML, next to the helper; the sign-in route serves it. */
|
|
30
|
+
exports.WALL_PAGE_HELPER_NAME = 'site-wall-page';
|
|
31
|
+
/** The `files` key the workflows plugin uses for the site's middleware. */
|
|
32
|
+
exports.MIDDLEWARE_FILES_KEY = 'auth-middleware';
|
|
33
|
+
/**
|
|
34
|
+
* The middleware runs on every page and asset except the site's own hashed
|
|
35
|
+
* scripts and styles (no content in them) and its API routes: payment
|
|
36
|
+
* webhooks, cron runs and the site's own server-side calls must keep working,
|
|
37
|
+
* and the password page posts to one of them. The bare '/' entry is required
|
|
38
|
+
* because Next.js does not run a negative-lookahead matcher for the root path.
|
|
39
|
+
*/
|
|
40
|
+
exports.WALL_MATCHER = "['/', '/((?!api|_next/static).*)']";
|
|
41
|
+
//# sourceMappingURL=constants.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"constants.js","sourceRoot":"","sources":["../../../src/password-wall/constants.ts"],"names":[],"mappings":";;;AAAA;;;;GAIG;AACU,QAAA,mBAAmB,GAAG,gBAAgB,CAAA;AACnD,uFAAuF;AAC1E,QAAA,aAAa,GAAG,oBAAoB,CAAA;AACjD,iEAAiE;AACpD,QAAA,WAAW,GAAG,SAAS,CAAA;AAEpC;;;;GAIG;AACU,QAAA,aAAa,GAAG;IAC3B,eAAe;IACf,uBAAuB;IACvB,sBAAsB;IACtB,qBAAqB;IACrB,kBAAkB;CACV,CAAA;AAEV,uFAAuF;AAC1E,QAAA,gBAAgB,GAAG,CAAC,OAAO,CAAC,CAAA;AAC5B,QAAA,gBAAgB,GAAG,WAAW,CAAA;AAC3C,kFAAkF;AACrE,QAAA,qBAAqB,GAAG,gBAAgB,CAAA;AAErD,2EAA2E;AAC9D,QAAA,oBAAoB,GAAG,iBAAiB,CAAA;AAErD;;;;;;GAMG;AACU,QAAA,YAAY,GAAG,oCAAoC,CAAA"}
|
|
@@ -0,0 +1,11 @@
|
|
|
1
|
+
/** `middleware.js` for a site that has no middleware of its own. */
|
|
2
|
+
export declare const buildStandaloneWallMiddleware: () => string;
|
|
3
|
+
/**
|
|
4
|
+
* Puts the gate in front of the middleware the workflows plugin generated for
|
|
5
|
+
* members-only pages: its `middleware` keeps its name and body, the module's
|
|
6
|
+
* default export becomes the gate followed by it, and the matcher widens to
|
|
7
|
+
* the wall's (a superset of the auth one; the auth code already answers
|
|
8
|
+
* `next()` for every path it does not protect).
|
|
9
|
+
*/
|
|
10
|
+
export declare const wrapMiddlewareWithWall: (authMiddlewareSource: string) => string;
|
|
11
|
+
//# sourceMappingURL=gate-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate-source.d.ts","sourceRoot":"","sources":["../../../src/password-wall/gate-source.ts"],"names":[],"mappings":"AAqGA,oEAAoE;AACpE,eAAO,MAAM,6BAA6B,QAAO,MAWhD,CAAA;AAKD;;;;;;GAMG;AACH,eAAO,MAAM,sBAAsB,yBAA0B,MAAM,KAAG,MAoBrE,CAAA"}
|
|
@@ -0,0 +1,53 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __spreadArray = (this && this.__spreadArray) || function (to, from, pack) {
|
|
3
|
+
if (pack || arguments.length === 2) for (var i = 0, l = from.length, ar; i < l; i++) {
|
|
4
|
+
if (ar || !(i in from)) {
|
|
5
|
+
if (!ar) ar = Array.prototype.slice.call(from, 0, i);
|
|
6
|
+
ar[i] = from[i];
|
|
7
|
+
}
|
|
8
|
+
}
|
|
9
|
+
return to.concat(ar || Array.prototype.slice.call(from));
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.wrapMiddlewareWithWall = exports.buildStandaloneWallMiddleware = void 0;
|
|
13
|
+
var constants_1 = require("./constants");
|
|
14
|
+
var helperImport = "import { wallConfig, wallConfigured, isOpenPath, cookieValueFor, sameValue, fetchWallState, WALL_COOKIE, PASSWORD_PAGE, SIGN_IN_ROUTE } from './".concat(__spreadArray(__spreadArray([], constants_1.WALL_HELPER_PATH, true), [
|
|
15
|
+
constants_1.WALL_HELPER_NAME,
|
|
16
|
+
], false).join('/'), "';");
|
|
17
|
+
/**
|
|
18
|
+
* The gate: the first thing the site's middleware does. Answers null when the
|
|
19
|
+
* request may go on, else the password page in place of what was asked for.
|
|
20
|
+
*
|
|
21
|
+
* The wall's state starts as the publish wrote it and is re-read from the
|
|
22
|
+
* platform once a minute per instance, in the background, so no request ever
|
|
23
|
+
* waits for the platform and the site keeps its last known state when the
|
|
24
|
+
* platform cannot be reached: a trial site stays walled, a paid site stays as
|
|
25
|
+
* last published.
|
|
26
|
+
*/
|
|
27
|
+
var gateFunctions = "\nvar __tqWallState = { on: wallConfig.defaultOn, version: wallConfig.defaultVersion, checkedAt: 0 };\nvar __tqWallCookie = { version: null, value: null };\nvar __TQ_WALL_RECHECK_MS = 60000;\n\nfunction __tqWallReadCookie(request, name) {\n try {\n var cookie = request.cookies.get(name);\n if (!cookie) return null;\n return typeof cookie === 'string' ? cookie : cookie.value || null;\n } catch (e) {\n return null;\n }\n}\n\nasync function __tqWallRefresh() {\n try {\n var next = await fetchWallState();\n __tqWallState.on = next.on;\n __tqWallState.version = next.version;\n } catch (e) {\n // The platform could not be reached or answered nonsense: keep the last\n // known state rather than opening or closing the site on a blip.\n }\n}\n\nexport async function __tqWallGate(request, event) {\n try {\n if (!wallConfigured()) return null;\n var pathname = request.nextUrl.pathname;\n if (isOpenPath(pathname)) return null;\n\n var now = Date.now();\n if (now - __tqWallState.checkedAt > __TQ_WALL_RECHECK_MS) {\n __tqWallState.checkedAt = now;\n var refresh = __tqWallRefresh();\n if (event && typeof event.waitUntil === 'function') {\n event.waitUntil(refresh);\n }\n }\n if (!__tqWallState.on) return null;\n\n // The page's own address: the page, as a page (200).\n if (pathname === PASSWORD_PAGE) {\n return __tqWallPage(request, true);\n }\n\n if (__tqWallCookie.version !== __tqWallState.version) {\n __tqWallCookie = {\n version: __tqWallState.version,\n value: await cookieValueFor(__tqWallState.version),\n };\n }\n var presented = __tqWallReadCookie(request, WALL_COOKIE);\n if (presented && sameValue(presented, __tqWallCookie.value)) return null;\n\n return __tqWallPage(request, false);\n } catch (e) {\n // A fault in the gate must not open a walled site: the publish-time state\n // decides. A site published without a wall goes on as before.\n if (wallConfig.defaultOn) {\n return __tqWallPage(request, false);\n }\n return null;\n }\n}\n\n// The password page in place of what was asked for: served by the sign-in\n// route, with a 401 unless the visitor came to the page's own address. The\n// browser keeps the address it asked for, so a reload after signing in lands\n// on the page the visitor wanted.\nfunction __tqWallPage(request, direct) {\n var url = request.nextUrl.clone();\n url.pathname = SIGN_IN_ROUTE;\n url.search = '';\n url.searchParams.set('page', '1');\n if (direct) url.searchParams.set('direct', '1');\n var response = NextResponse.rewrite(url);\n response.headers.set('cache-control', 'no-store');\n response.headers.set('x-robots-tag', 'noindex');\n return response;\n}\n";
|
|
28
|
+
/** `middleware.js` for a site that has no middleware of its own. */
|
|
29
|
+
var buildStandaloneWallMiddleware = function () { return "import { NextResponse } from 'next/server';\n".concat(helperImport, "\n").concat(gateFunctions, "\nexport default async function middleware(request, event) {\n var gate = await __tqWallGate(request, event);\n return gate || NextResponse.next();\n}\n\nexport const config = {\n matcher: ").concat(constants_1.WALL_MATCHER, ",\n};\n"); };
|
|
30
|
+
exports.buildStandaloneWallMiddleware = buildStandaloneWallMiddleware;
|
|
31
|
+
var DEFAULT_EXPORT = 'export default middleware;';
|
|
32
|
+
var MATCHER_LINE = /matcher: \[[^\]]*\],/;
|
|
33
|
+
/**
|
|
34
|
+
* Puts the gate in front of the middleware the workflows plugin generated for
|
|
35
|
+
* members-only pages: its `middleware` keeps its name and body, the module's
|
|
36
|
+
* default export becomes the gate followed by it, and the matcher widens to
|
|
37
|
+
* the wall's (a superset of the auth one; the auth code already answers
|
|
38
|
+
* `next()` for every path it does not protect).
|
|
39
|
+
*/
|
|
40
|
+
var wrapMiddlewareWithWall = function (authMiddlewareSource) {
|
|
41
|
+
if (authMiddlewareSource.indexOf(DEFAULT_EXPORT) === -1) {
|
|
42
|
+
throw new Error('The site middleware has no default export to put the password wall in front of');
|
|
43
|
+
}
|
|
44
|
+
if (!MATCHER_LINE.test(authMiddlewareSource)) {
|
|
45
|
+
throw new Error('The site middleware has no matcher to widen for the password wall');
|
|
46
|
+
}
|
|
47
|
+
var wrapped = authMiddlewareSource
|
|
48
|
+
.replace(DEFAULT_EXPORT, "async function __tqWalledMiddleware(request, event) {\n var gate = await __tqWallGate(request, event);\n if (gate) return gate;\n return middleware(request, event);\n}\n\nexport default __tqWalledMiddleware;")
|
|
49
|
+
.replace(MATCHER_LINE, "matcher: ".concat(constants_1.WALL_MATCHER, ","));
|
|
50
|
+
return "".concat(helperImport, "\n").concat(wrapped, "\n").concat(gateFunctions);
|
|
51
|
+
};
|
|
52
|
+
exports.wrapMiddlewareWithWall = wrapMiddlewareWithWall;
|
|
53
|
+
//# sourceMappingURL=gate-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"gate-source.js","sourceRoot":"","sources":["../../../src/password-wall/gate-source.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,yCAA8E;AAE9E,IAAM,YAAY,GAAG,0JAAmJ,gCACnK,4BAAgB;IACnB,4BAAgB;UAChB,IAAI,CAAC,GAAG,CAAC,OAAI,CAAA;AAEf;;;;;;;;;GASG;AACH,IAAM,aAAa,GAAG,kuFAkFrB,CAAA;AAED,oEAAoE;AAC7D,IAAM,6BAA6B,GAAG,cAAc,OAAA,uDACzD,YAAY,eACZ,aAAa,6MAOF,wBAAY,YAExB,EAX0D,CAW1D,CAAA;AAXY,QAAA,6BAA6B,iCAWzC;AAED,IAAM,cAAc,GAAG,4BAA4B,CAAA;AACnD,IAAM,YAAY,GAAG,sBAAsB,CAAA;AAE3C;;;;;;GAMG;AACI,IAAM,sBAAsB,GAAG,UAAC,oBAA4B;IACjE,IAAI,oBAAoB,CAAC,OAAO,CAAC,cAAc,CAAC,KAAK,CAAC,CAAC,EAAE;QACvD,MAAM,IAAI,KAAK,CAAC,gFAAgF,CAAC,CAAA;KAClG;IACD,IAAI,CAAC,YAAY,CAAC,IAAI,CAAC,oBAAoB,CAAC,EAAE;QAC5C,MAAM,IAAI,KAAK,CAAC,mEAAmE,CAAC,CAAA;KACrF;IACD,IAAM,OAAO,GAAG,oBAAoB;SACjC,OAAO,CACN,cAAc,EACd,oNAM+B,CAChC;SACA,OAAO,CAAC,YAAY,EAAE,mBAAY,wBAAY,MAAG,CAAC,CAAA;IACrD,OAAO,UAAG,YAAY,eAAK,OAAO,eAAK,aAAa,CAAE,CAAA;AACxD,CAAC,CAAA;AApBY,QAAA,sBAAsB,0BAoBlC"}
|
|
@@ -0,0 +1,7 @@
|
|
|
1
|
+
/**
|
|
2
|
+
* `utils/site-wall.js`: what the middleware (Edge runtime) and the sign-in
|
|
3
|
+
* route (Node runtime) share. Web APIs only — no Node module may be imported
|
|
4
|
+
* here, the middleware bundle would refuse it.
|
|
5
|
+
*/
|
|
6
|
+
export declare const buildWallHelperSource: () => string;
|
|
7
|
+
//# sourceMappingURL=helper-source.d.ts.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper-source.d.ts","sourceRoot":"","sources":["../../../src/password-wall/helper-source.ts"],"names":[],"mappings":"AAEA;;;;GAIG;AACH,eAAO,MAAM,qBAAqB,QAAO,MAwFxC,CAAA"}
|
|
@@ -0,0 +1,12 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
+
exports.buildWallHelperSource = void 0;
|
|
4
|
+
var constants_1 = require("./constants");
|
|
5
|
+
/**
|
|
6
|
+
* `utils/site-wall.js`: what the middleware (Edge runtime) and the sign-in
|
|
7
|
+
* route (Node runtime) share. Web APIs only — no Node module may be imported
|
|
8
|
+
* here, the middleware bundle would refuse it.
|
|
9
|
+
*/
|
|
10
|
+
var buildWallHelperSource = function () { return "// GENERATED by TeleportHQ \u2014 the password wall shared by middleware.js and\n// pages/api/site-password.js. Nothing here runs while the site was published\n// without a wall (the TELEPORT_WALL_* values below are empty).\n\nexport var WALL_COOKIE = '".concat(constants_1.WALL_COOKIE, "';\nexport var PASSWORD_PAGE = '").concat(constants_1.PASSWORD_PAGE_ROUTE, "';\nexport var SIGN_IN_ROUTE = '").concat(constants_1.SIGN_IN_ROUTE, "';\n\n// Literal process.env reads: Next.js hands the middleware only the variables\n// it sees named in the source.\nexport var wallConfig = {\n defaultOn: process.env.TELEPORT_WALL === 'on',\n defaultVersion: process.env.TELEPORT_WALL_VERSION || '',\n secret: process.env.TELEPORT_WALL_SECRET || '',\n projectId: process.env.TELEPORT_PROJECT_ID || '',\n apiUrl: (process.env.TELEPORT_API_URL || '').replace(/\\/+$/, ''),\n};\n\nexport function wallConfigured() {\n return !!(wallConfig.secret && wallConfig.projectId && wallConfig.apiUrl);\n}\n\n// Paths that stay open: the site's hashed scripts and styles (no content in\n// them) and its API routes (payment webhooks, cron runs, the site's own server\n// calls, and the route that serves the password page and signs in).\nexport function isOpenPath(pathname) {\n return (\n pathname.indexOf('/_next/static/') === 0 ||\n pathname === '/api' ||\n pathname.indexOf('/api/') === 0\n );\n}\n\nvar encoder = new TextEncoder();\n\nfunction toHex(buffer) {\n var bytes = new Uint8Array(buffer);\n var out = '';\n for (var i = 0; i < bytes.length; i++) {\n out += (bytes[i] < 16 ? '0' : '') + bytes[i].toString(16);\n }\n return out;\n}\n\n// What a signed-in visitor's cookie holds: HMAC-SHA256 of the wall's version\n// under the site's secret. Refreshing the password changes the version, so\n// every cookie expires at once; the password itself never reaches the site.\nexport async function cookieValueFor(version) {\n var key = await crypto.subtle.importKey(\n 'raw',\n encoder.encode(wallConfig.secret),\n { name: 'HMAC', hash: 'SHA-256' },\n false,\n ['sign']\n );\n var signature = await crypto.subtle.sign('HMAC', key, encoder.encode('wall:' + version));\n return toHex(signature);\n}\n\n// Constant-time string comparison, so a cookie cannot be guessed byte by byte.\nexport function sameValue(a, b) {\n if (typeof a !== 'string' || typeof b !== 'string' || a.length !== b.length) {\n return false;\n }\n var diff = 0;\n for (var i = 0; i < a.length; i++) {\n diff |= a.charCodeAt(i) ^ b.charCodeAt(i);\n }\n return diff === 0;\n}\n\n// Whether the site is walled right now, and the wall's version, from the\n// platform. Throws when the platform cannot be reached or answers nonsense;\n// the caller keeps the state it had.\nexport async function fetchWallState() {\n var response = await fetch(\n wallConfig.apiUrl + '/site-wall/' + encodeURIComponent(wallConfig.projectId),\n { headers: { accept: 'application/json' }, cache: 'no-store' }\n );\n if (!response.ok) {\n throw new Error('wall state answered ' + response.status);\n }\n var json = await response.json();\n if (!json || typeof json.walled !== 'boolean') {\n throw new Error('wall state malformed');\n }\n return { on: json.walled, version: typeof json.version === 'string' ? json.version : '' };\n}\n"); };
|
|
11
|
+
exports.buildWallHelperSource = buildWallHelperSource;
|
|
12
|
+
//# sourceMappingURL=helper-source.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"helper-source.js","sourceRoot":"","sources":["../../../src/password-wall/helper-source.ts"],"names":[],"mappings":";;;AAAA,yCAA6E;AAE7E;;;;GAIG;AACI,IAAM,qBAAqB,GAAG,cAAc,OAAA,uQAIvB,uBAAW,6CACT,+BAAmB,6CACnB,yBAAa,u1FAkF1C,EAxFkD,CAwFlD,CAAA;AAxFY,QAAA,qBAAqB,yBAwFjC"}
|