Skip to content

Commit 4901a2c

Browse files
authored
Variously update authn.ts
* fix typos * improve readability and English of various human-directed text blocks * change `makeIndexIfNecesary` function to `makeIndexIfNecessary` (added missing `s`)
1 parent 9194749 commit 4901a2c

1 file changed

Lines changed: 48 additions & 47 deletions

File tree

src/authn/authn.ts

Lines changed: 48 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -34,26 +34,27 @@ export function findOriginOwner (doc: $rdf.NamedNode | string): string | boolean
3434

3535
// Promises versions
3636
//
37-
// These pass a context object which hold various RDF symbols
37+
// These pass a context object which holds various RDF symbols
3838
// as they become available
3939
//
40-
// me RDF symbol for the users' webid
41-
// publicProfile The user's public profile, iff loaded
42-
// preferencesFile The user's personal preferences file, iff loaded
43-
// index.public The user's public type index file
40+
// me RDF symbol for the user's WebID
41+
// publicProfile The user's public profile, iff loaded
42+
// preferencesFile The user's personal preference file, iff loaded
43+
// index.public The user's public type index file
4444
// index.private The user's private type index file
45-
// not RDF symbols:
46-
// noun A string in english for the type of thing -- like "address book"
47-
// instance An array of nodes which are existing instances
48-
// containers An array of nodes of containers of instances
49-
// div A DOM element where UI can be displayed
50-
// statusArea A DOM element (opt) progress stuff can be displayed, or error messages
45+
//
46+
// not RDF symbols:
47+
// noun A string in english for the type of thing -- like "address book"
48+
// instance An array of nodes which are existing instances
49+
// containers An array of nodes of containers of instances
50+
// div A DOM element where UI can be displayed
51+
// statusArea A DOM element (opt) progress stuff can be displayed, or error messages
5152

5253
/**
5354
* @param webId
5455
* @param context
5556
*
56-
* @returns Returns the Web ID, after setting it
57+
* @returns Returns the WebID, after setting it
5758
*/
5859
export function saveUser (
5960
webId: $rdf.NamedNode | string | null,
@@ -86,7 +87,7 @@ export function defaultTestUser (): $rdf.NamedNode | null {
8687
return null
8788
}
8889

89-
/** Checks syncronously whether user is logged in
90+
/** Checks synchronously whether user is logged in
9091
*
9192
* @returns Named Node or null
9293
*/
@@ -104,7 +105,7 @@ export function currentUser (): $rdf.NamedNode | null {
104105
}
105106

106107
/**
107-
* Resolves with the logged in user's Web ID
108+
* Resolves with the logged in user's WebID
108109
*
109110
* @param context
110111
*/
@@ -159,7 +160,7 @@ export function logInLoadProfile (context: AuthenticationContext): Promise<Authe
159160
profileDocument = webID.doc()
160161
// Load the profile into the knowledge base (fetcher.store)
161162
// withCredentials: Web arch should let us just load by turning off creds helps CORS
162-
// reload: Gets around a specifc old Chrome bug caching/origin/cors
163+
// reload: Gets around a specific old Chrome bug caching/origin/cors
163164
fetcher
164165
.load(profileDocument, { withCredentials: false, cache: 'reload' })
165166
.then(_response => {
@@ -183,7 +184,7 @@ export function logInLoadProfile (context: AuthenticationContext): Promise<Authe
183184
}
184185

185186
/**
186-
* Loads preferences file
187+
* Loads preference file
187188
* Do this after having done log in and load profile
188189
*
189190
* @private
@@ -221,10 +222,10 @@ export function logInLoadPreferences (context: AuthenticationContext): Promise<A
221222
}
222223

223224
if (!preferencesFile) {
224-
return reject(new Error(`Can't find a preferences file pointer in profile ${context.publicProfile}`))
225+
return reject(new Error(`Can't find a preference file pointer in profile ${context.publicProfile}`))
225226
}
226227

227-
// //// Load preferences file
228+
// //// Load preference file
228229
return kb.fetcher
229230
.load(preferencesFile, { withCredentials: true })
230231
.then(function () {
@@ -239,42 +240,42 @@ export function logInLoadPreferences (context: AuthenticationContext): Promise<A
239240
const status = err.status
240241
const message = err.message
241242
console.log(
242-
`HTTP status ${status} for pref file ${preferencesFile}`
243+
`HTTP status ${status} for preference file ${preferencesFile}`
243244
)
244245
let m2
245246
if (status === 401) {
246-
m2 = 'Strange - you are not authenticated (properly logged on) to read preferences file.'
247+
m2 = 'Strange - you are not authenticated (properly logged in) to read preference file.'
247248
alert(m2)
248249
} else if (status === 403) {
249250
if (differentOrigin()) {
250-
m2 = `Unauthorized: Assuming prefs file blocked for origin ${window.location.origin}`
251+
m2 = `Unauthorized: Assuming preference file blocked for origin ${window.location.origin}`
251252
context.preferencesFileError = m2
252253
return resolve(context)
253254
}
254-
m2 = 'You are not authorized to read your preferences file. This may be because you are using an untrusted web app.'
255+
m2 = 'You are not authorized to read your preference file. This may be because you are using an untrusted web app.'
255256
console.warn(m2)
256257
} else if (status === 404) {
257258
if (
258-
confirm(`You do not currently have a Preferences file. Ok for me to create an empty one? ${preferencesFile}`)
259+
confirm(`You do not currently have a preference file. OK for me to create an empty one? ${preferencesFile}`)
259260
) {
260-
// @@@ code me ... weird to have a name o fthe file but no file
261+
// @@@ code me ... weird to have a name of the file but no file
261262
alert(`Sorry; I am not prepared to do this. Please create an empty file at ${preferencesFile}`)
262263
return complain(
263-
new Error('Sorry; no code yet to create a preferences file at ')
264+
new Error('Sorry; no code yet to create a preference file at ')
264265
)
265266
} else {
266267
reject(
267-
new Error(`User declined to create a preferences file at ${preferencesFile}`)
268+
new Error(`User declined to create a preference file at ${preferencesFile}`)
268269
)
269270
}
270271
} else {
271-
m2 = `Strange: Error ${status} trying to read your preferences file.${message}`
272+
m2 = `Strange: Error ${status} trying to read your preference file.${message}`
272273
alert(m2)
273274
}
274-
}) // load prefs file then
275+
}) // load preference file then
275276
})
276277
.catch(err => {
277-
// Fail initial login load prefs
278+
// Fail initial login load preferences
278279
reject(new Error(`(via loadPrefs) ${err}`))
279280
})
280281
})
@@ -342,7 +343,7 @@ async function loadIndex (
342343
}
343344
} else {
344345
console.log(
345-
'We know your preferences file is noty available, so not bothering with private type indexes.'
346+
'We know your preference file is not available, so we are not bothering with private type indexes.'
346347
)
347348
}
348349
}
@@ -366,7 +367,7 @@ async function ensureTypeIndexes (context: AuthenticationContext): Promise<Authe
366367
}
367368

368369
/* Load or create ONE type index
369-
* Find one or mke one or fail
370+
* Find one or make one or fail
370371
* Many reasons for filing including script not having permission etc
371372
*
372373
*/
@@ -376,7 +377,7 @@ async function ensureTypeIndexes (context: AuthenticationContext): Promise<Authe
376377
*/
377378

378379
async function ensureOneTypeIndex (context: AuthenticationContext, isPublic: boolean): Promise<AuthenticationContext | void> {
379-
async function makeIndexIfNecesary (context, isPublic) {
380+
async function makeIndexIfNecessary (context, isPublic) {
380381
const relevant = isPublic ? context.publicProfile : context.preferencesFile
381382
const visibility = isPublic ? 'public' : 'private'
382383

@@ -400,7 +401,7 @@ async function ensureOneTypeIndex (context: AuthenticationContext, isPublic: boo
400401
if (context.index[visibility].length === 0) {
401402
newIndex = $rdf.sym(`${relevant.dir().uri + visibility}TypeIndex.ttl`)
402403
console.log(`Linking to new fresh type index ${newIndex}`)
403-
if (!confirm(`Ok to create a new empty index file at ${newIndex}, overwriting anything that was there?`)) {
404+
if (!confirm(`OK to create a new empty index file at ${newIndex}, overwriting anything that is now there?`)) {
404405
throw new Error('cancelled by user')
405406
}
406407
console.log(`Linking to new fresh type index ${newIndex}`)
@@ -427,7 +428,7 @@ async function ensureOneTypeIndex (context: AuthenticationContext, isPublic: boo
427428
widgets.complain(context, `ensureOneTypeIndex: loading indexes ${err}`)
428429
}
429430
}
430-
} // makeIndexIfNecesary
431+
} // makeIndexIfNecessary
431432

432433
try {
433434
await loadOneTypeIndex(context, isPublic)
@@ -440,7 +441,7 @@ async function ensureOneTypeIndex (context: AuthenticationContext, isPublic: boo
440441
}
441442
return context
442443
} catch (error) {
443-
await makeIndexIfNecesary(context, isPublic)
444+
await makeIndexIfNecessary(context, isPublic)
444445
// widgets.complain(context, 'calling loadOneTypeIndex:' + error)
445446
}
446447
}
@@ -508,7 +509,7 @@ export async function findAppInstances (
508509
return context
509510
}
510511

511-
// @@@@ use teh one in rdflib.js when it is avaiable and delete this
512+
// @@@@ use the one in rdflib.js when it is available and delete this
512513
function updatePromise (
513514
updater: $rdf.UpdateManager,
514515
del: Array<$rdf.Statement>,
@@ -876,7 +877,7 @@ export function offlineTestID (): $rdf.NamedNode | null {
876877
if (!div) return null
877878
const id = div.getAttribute('testID')
878879
if (!id) return null
879-
/* me = kb.any(subject, ns.acl('owner')); // when testing on plane with no webid
880+
/* me = kb.any(subject, ns.acl('owner')); // when testing on plane with no WebID
880881
*/
881882
console.log('Assuming user is ' + id)
882883
return $rdf.sym(id)
@@ -930,7 +931,7 @@ function signInOrSignUpBox (
930931
// setUserCallback(webIdURI)
931932
const divs = dom.getElementsByClassName(magicClassName)
932933
console.log(`Logged in, ${divs.length} panels to be serviced`)
933-
// At the same time, satiffy all the other login boxes
934+
// At the same time, satisfy all the other login boxes
934935
for (let i = 0; i < divs.length; i++) {
935936
const div: any = divs[i]
936937
// @@ TODO Remove the need to manipulate HTML elements
@@ -1062,7 +1063,7 @@ export function loginStatusBox (
10621063
// UI.preferences.set('me', '')
10631064
solidAuthClient.logout().then(
10641065
function () {
1065-
const message = `Your Web ID was ${me}. It has been forgotten.`
1066+
const message = `Your WebID was ${me}. It has been forgotten.`
10661067
me = null
10671068
try {
10681069
log.alert(message)
@@ -1080,7 +1081,7 @@ export function loginStatusBox (
10801081

10811082
function logoutButton (me, options) {
10821083
const signInButtonStyle = options.buttonStyle || getDefaultSignInButtonStyle()
1083-
let logoutLabel = 'Web ID logout'
1084+
let logoutLabel = 'WebID logout'
10841085
if (me) {
10851086
const nick =
10861087
kb.any(me, ns.foaf('nick')) ||
@@ -1146,10 +1147,10 @@ export function loginStatusBox (
11461147
* Returns a UI object which, if it selects a workspace,
11471148
* will callback(workspace, newBase).
11481149
*
1149-
* If necessary, will get an account, preferences file, etc. In sequence:
1150+
* If necessary, will get an account, preference file, etc. In sequence:
11501151
*
11511152
* - If not logged in, log in.
1152-
* - Load preferences file
1153+
* - Load preference file
11531154
* - Prompt user for workspaces
11541155
* - Allows the user to just type in a URI by hand
11551156
*
@@ -1197,11 +1198,11 @@ export function selectWorkspace (
11971198
const preferencesFile = context.preferencesFile
11981199
let newBase = null
11991200

1200-
// A workspace specifically defined in the private preferences file:
1201+
// A workspace specifically defined in the private preference file:
12011202
let w = kb
12021203
.statementsMatching(
12031204
id,
1204-
ns.space('workspace'), // Only trust prefs file here
1205+
ns.space('workspace'), // Only trust preference file here
12051206
undefined,
12061207
preferencesFile
12071208
)
@@ -1220,11 +1221,11 @@ export function selectWorkspace (
12201221
newBase = figureOutBase(w[0])
12211222
// callbackWS(w[0], newBase)
12221223
} else if (w.length === 0) {
1223-
say(`You don't seem to have any workspaces. You have ${storages.length} storages.`)
1224+
say(`You don't seem to have any workspaces. You have ${storages.length} storage spaces.`)
12241225
}
12251226

12261227
// Prompt for ws selection or creation
1227-
// say( w.length + " workspaces for " + id + "Chose one.");
1228+
// say( w.length + " workspaces for " + id + "Choose one.");
12281229
const table = dom.createElement('table')
12291230
table.setAttribute('style', 'border-collapse:separate; border-spacing: 0.5em;')
12301231

@@ -1283,7 +1284,7 @@ export function selectWorkspace (
12831284
if (i === 0) {
12841285
col1 = dom.createElement('td')
12851286
col1.setAttribute('rowspan', `${w.length}1`)
1286-
col1.textContent = 'Chose a workspace for this:'
1287+
col1.textContent = 'Choose a workspace for this:'
12871288
col1.setAttribute('style', 'vertical-align:middle;')
12881289
tr.appendChild(col1)
12891290
}

0 commit comments

Comments
 (0)