@atproto/pds 0.4.199 → 0.4.201
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/CHANGELOG.md +25 -0
- package/dist/api/com/atproto/server/createSession.d.ts.map +1 -1
- package/dist/api/com/atproto/server/createSession.js +2 -2
- package/dist/api/com/atproto/server/createSession.js.map +1 -1
- package/dist/api/com/atproto/server/getSession.js +2 -2
- package/dist/api/com/atproto/server/getSession.js.map +1 -1
- package/dist/api/com/atproto/server/refreshSession.d.ts.map +1 -1
- package/dist/api/com/atproto/server/refreshSession.js +4 -2
- package/dist/api/com/atproto/server/refreshSession.js.map +1 -1
- package/dist/lexicon/lexicons.d.ts +144 -54
- package/dist/lexicon/lexicons.d.ts.map +1 -1
- package/dist/lexicon/lexicons.js +94 -26
- package/dist/lexicon/lexicons.js.map +1 -1
- package/dist/lexicon/types/app/bsky/contact/dismissMatch.d.ts +1 -1
- package/dist/lexicon/types/app/bsky/contact/dismissMatch.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/contact/dismissMatch.js.map +1 -1
- package/dist/lexicon/types/app/bsky/contact/getMatches.d.ts +1 -1
- package/dist/lexicon/types/app/bsky/contact/getMatches.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/contact/getMatches.js.map +1 -1
- package/dist/lexicon/types/app/bsky/contact/getSyncStatus.d.ts +1 -1
- package/dist/lexicon/types/app/bsky/contact/getSyncStatus.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/contact/getSyncStatus.js.map +1 -1
- package/dist/lexicon/types/app/bsky/contact/importContacts.d.ts +1 -1
- package/dist/lexicon/types/app/bsky/contact/importContacts.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/contact/importContacts.js.map +1 -1
- package/dist/lexicon/types/app/bsky/contact/removeData.d.ts +1 -1
- package/dist/lexicon/types/app/bsky/contact/removeData.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/contact/removeData.js.map +1 -1
- package/dist/lexicon/types/app/bsky/contact/startPhoneVerification.d.ts +1 -1
- package/dist/lexicon/types/app/bsky/contact/startPhoneVerification.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/contact/startPhoneVerification.js.map +1 -1
- package/dist/lexicon/types/app/bsky/contact/verifyPhone.d.ts +1 -1
- package/dist/lexicon/types/app/bsky/contact/verifyPhone.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/contact/verifyPhone.js.map +1 -1
- package/dist/lexicon/types/app/bsky/notification/listNotifications.d.ts +1 -1
- package/dist/lexicon/types/app/bsky/notification/listNotifications.d.ts.map +1 -1
- package/dist/lexicon/types/app/bsky/notification/listNotifications.js.map +1 -1
- package/dist/lexicon/types/com/atproto/server/deleteSession.d.ts +1 -0
- package/dist/lexicon/types/com/atproto/server/deleteSession.d.ts.map +1 -1
- package/dist/lexicon/types/com/atproto/server/deleteSession.js.map +1 -1
- package/dist/lexicon/types/com/atproto/server/getSession.d.ts +3 -3
- package/dist/lexicon/types/com/atproto/server/getSession.d.ts.map +1 -1
- package/dist/lexicon/types/com/atproto/server/getSession.js.map +1 -1
- package/dist/lexicon/types/com/atproto/server/refreshSession.d.ts +4 -1
- package/dist/lexicon/types/com/atproto/server/refreshSession.d.ts.map +1 -1
- package/dist/lexicon/types/com/atproto/server/refreshSession.js.map +1 -1
- package/package.json +15 -15
- package/src/api/com/atproto/server/createSession.ts +3 -2
- package/src/api/com/atproto/server/getSession.ts +2 -2
- package/src/api/com/atproto/server/refreshSession.ts +5 -2
- package/src/lexicon/lexicons.ts +95 -26
- package/src/lexicon/types/app/bsky/contact/dismissMatch.ts +1 -1
- package/src/lexicon/types/app/bsky/contact/getMatches.ts +1 -1
- package/src/lexicon/types/app/bsky/contact/getSyncStatus.ts +1 -1
- package/src/lexicon/types/app/bsky/contact/importContacts.ts +6 -1
- package/src/lexicon/types/app/bsky/contact/removeData.ts +1 -1
- package/src/lexicon/types/app/bsky/contact/startPhoneVerification.ts +1 -1
- package/src/lexicon/types/app/bsky/contact/verifyPhone.ts +6 -1
- package/src/lexicon/types/app/bsky/notification/listNotifications.ts +1 -0
- package/src/lexicon/types/com/atproto/server/deleteSession.ts +1 -0
- package/src/lexicon/types/com/atproto/server/getSession.ts +1 -1
- package/src/lexicon/types/com/atproto/server/refreshSession.ts +4 -1
- package/tests/_puppeteer.ts +87 -0
- package/tests/oauth.test.ts +54 -94
- package/tsconfig.tests.tsbuildinfo +0 -1
package/src/lexicon/lexicons.ts
CHANGED
|
@@ -1826,7 +1826,7 @@ export const schemaDict = {
|
|
|
1826
1826
|
main: {
|
|
1827
1827
|
type: 'procedure',
|
|
1828
1828
|
description:
|
|
1829
|
-
"
|
|
1829
|
+
"Removes a match that was found via contact import. It shouldn't appear again if the same contact is re-imported. Requires authentication.",
|
|
1830
1830
|
input: {
|
|
1831
1831
|
encoding: 'application/json',
|
|
1832
1832
|
schema: {
|
|
@@ -1850,8 +1850,10 @@ export const schemaDict = {
|
|
|
1850
1850
|
},
|
|
1851
1851
|
errors: [
|
|
1852
1852
|
{
|
|
1853
|
-
name: '
|
|
1854
|
-
|
|
1853
|
+
name: 'InvalidDid',
|
|
1854
|
+
},
|
|
1855
|
+
{
|
|
1856
|
+
name: 'InternalError',
|
|
1855
1857
|
},
|
|
1856
1858
|
],
|
|
1857
1859
|
},
|
|
@@ -1864,7 +1866,7 @@ export const schemaDict = {
|
|
|
1864
1866
|
main: {
|
|
1865
1867
|
type: 'query',
|
|
1866
1868
|
description:
|
|
1867
|
-
|
|
1869
|
+
'Returns the matched contacts (contacts that were mutually imported). Excludes dismissed matches. Requires authentication.',
|
|
1868
1870
|
parameters: {
|
|
1869
1871
|
type: 'params',
|
|
1870
1872
|
properties: {
|
|
@@ -1900,8 +1902,16 @@ export const schemaDict = {
|
|
|
1900
1902
|
},
|
|
1901
1903
|
errors: [
|
|
1902
1904
|
{
|
|
1903
|
-
name: '
|
|
1904
|
-
|
|
1905
|
+
name: 'InvalidDid',
|
|
1906
|
+
},
|
|
1907
|
+
{
|
|
1908
|
+
name: 'InvalidLimit',
|
|
1909
|
+
},
|
|
1910
|
+
{
|
|
1911
|
+
name: 'InvalidCursor',
|
|
1912
|
+
},
|
|
1913
|
+
{
|
|
1914
|
+
name: 'InternalError',
|
|
1905
1915
|
},
|
|
1906
1916
|
],
|
|
1907
1917
|
},
|
|
@@ -1914,7 +1924,7 @@ export const schemaDict = {
|
|
|
1914
1924
|
main: {
|
|
1915
1925
|
type: 'query',
|
|
1916
1926
|
description:
|
|
1917
|
-
"
|
|
1927
|
+
"Gets the user's current contact import status. Requires authentication.",
|
|
1918
1928
|
parameters: {
|
|
1919
1929
|
type: 'params',
|
|
1920
1930
|
properties: {},
|
|
@@ -1935,8 +1945,10 @@ export const schemaDict = {
|
|
|
1935
1945
|
},
|
|
1936
1946
|
errors: [
|
|
1937
1947
|
{
|
|
1938
|
-
name: '
|
|
1939
|
-
|
|
1948
|
+
name: 'InvalidDid',
|
|
1949
|
+
},
|
|
1950
|
+
{
|
|
1951
|
+
name: 'InternalError',
|
|
1940
1952
|
},
|
|
1941
1953
|
],
|
|
1942
1954
|
},
|
|
@@ -1949,7 +1961,7 @@ export const schemaDict = {
|
|
|
1949
1961
|
main: {
|
|
1950
1962
|
type: 'procedure',
|
|
1951
1963
|
description:
|
|
1952
|
-
|
|
1964
|
+
'Import contacts for securely matching with other users. This follows the protocol explained in https://docs.bsky.app/blog/contact-import-rfc. Requires authentication.',
|
|
1953
1965
|
input: {
|
|
1954
1966
|
encoding: 'application/json',
|
|
1955
1967
|
schema: {
|
|
@@ -1994,8 +2006,19 @@ export const schemaDict = {
|
|
|
1994
2006
|
},
|
|
1995
2007
|
errors: [
|
|
1996
2008
|
{
|
|
1997
|
-
name: '
|
|
1998
|
-
|
|
2009
|
+
name: 'InvalidDid',
|
|
2010
|
+
},
|
|
2011
|
+
{
|
|
2012
|
+
name: 'InvalidContacts',
|
|
2013
|
+
},
|
|
2014
|
+
{
|
|
2015
|
+
name: 'TooManyContacts',
|
|
2016
|
+
},
|
|
2017
|
+
{
|
|
2018
|
+
name: 'InvalidToken',
|
|
2019
|
+
},
|
|
2020
|
+
{
|
|
2021
|
+
name: 'InternalError',
|
|
1999
2022
|
},
|
|
2000
2023
|
],
|
|
2001
2024
|
},
|
|
@@ -2008,7 +2031,7 @@ export const schemaDict = {
|
|
|
2008
2031
|
main: {
|
|
2009
2032
|
type: 'procedure',
|
|
2010
2033
|
description:
|
|
2011
|
-
|
|
2034
|
+
'Removes all stored hashes used for contact matching, existing matches, and sync status. Requires authentication.',
|
|
2012
2035
|
input: {
|
|
2013
2036
|
encoding: 'application/json',
|
|
2014
2037
|
schema: {
|
|
@@ -2025,8 +2048,10 @@ export const schemaDict = {
|
|
|
2025
2048
|
},
|
|
2026
2049
|
errors: [
|
|
2027
2050
|
{
|
|
2028
|
-
name: '
|
|
2029
|
-
|
|
2051
|
+
name: 'InvalidDid',
|
|
2052
|
+
},
|
|
2053
|
+
{
|
|
2054
|
+
name: 'InternalError',
|
|
2030
2055
|
},
|
|
2031
2056
|
],
|
|
2032
2057
|
},
|
|
@@ -2039,7 +2064,7 @@ export const schemaDict = {
|
|
|
2039
2064
|
main: {
|
|
2040
2065
|
type: 'procedure',
|
|
2041
2066
|
description:
|
|
2042
|
-
|
|
2067
|
+
'System endpoint to send notifications related to contact imports. Requires role authentication.',
|
|
2043
2068
|
input: {
|
|
2044
2069
|
encoding: 'application/json',
|
|
2045
2070
|
schema: {
|
|
@@ -2076,7 +2101,7 @@ export const schemaDict = {
|
|
|
2076
2101
|
main: {
|
|
2077
2102
|
type: 'procedure',
|
|
2078
2103
|
description:
|
|
2079
|
-
|
|
2104
|
+
'Starts a phone verification flow. The phone passed will receive a code via SMS that should be passed to `app.bsky.contact.verifyPhone`. Requires authentication.',
|
|
2080
2105
|
input: {
|
|
2081
2106
|
encoding: 'application/json',
|
|
2082
2107
|
schema: {
|
|
@@ -2099,8 +2124,16 @@ export const schemaDict = {
|
|
|
2099
2124
|
},
|
|
2100
2125
|
errors: [
|
|
2101
2126
|
{
|
|
2102
|
-
name: '
|
|
2103
|
-
|
|
2127
|
+
name: 'RateLimitExceeded',
|
|
2128
|
+
},
|
|
2129
|
+
{
|
|
2130
|
+
name: 'InvalidDid',
|
|
2131
|
+
},
|
|
2132
|
+
{
|
|
2133
|
+
name: 'InvalidPhone',
|
|
2134
|
+
},
|
|
2135
|
+
{
|
|
2136
|
+
name: 'InternalError',
|
|
2104
2137
|
},
|
|
2105
2138
|
],
|
|
2106
2139
|
},
|
|
@@ -2113,7 +2146,7 @@ export const schemaDict = {
|
|
|
2113
2146
|
main: {
|
|
2114
2147
|
type: 'procedure',
|
|
2115
2148
|
description:
|
|
2116
|
-
|
|
2149
|
+
'Verifies control over a phone number with a code received via SMS and starts a contact import session. Requires authentication.',
|
|
2117
2150
|
input: {
|
|
2118
2151
|
encoding: 'application/json',
|
|
2119
2152
|
schema: {
|
|
@@ -2149,8 +2182,19 @@ export const schemaDict = {
|
|
|
2149
2182
|
},
|
|
2150
2183
|
errors: [
|
|
2151
2184
|
{
|
|
2152
|
-
name: '
|
|
2153
|
-
|
|
2185
|
+
name: 'RateLimitExceeded',
|
|
2186
|
+
},
|
|
2187
|
+
{
|
|
2188
|
+
name: 'InvalidDid',
|
|
2189
|
+
},
|
|
2190
|
+
{
|
|
2191
|
+
name: 'InvalidPhone',
|
|
2192
|
+
},
|
|
2193
|
+
{
|
|
2194
|
+
name: 'InvalidCode',
|
|
2195
|
+
},
|
|
2196
|
+
{
|
|
2197
|
+
name: 'InternalError',
|
|
2154
2198
|
},
|
|
2155
2199
|
],
|
|
2156
2200
|
},
|
|
@@ -6803,6 +6847,7 @@ export const schemaDict = {
|
|
|
6803
6847
|
'like-via-repost',
|
|
6804
6848
|
'repost-via-repost',
|
|
6805
6849
|
'subscribed-post',
|
|
6850
|
+
'contact-match',
|
|
6806
6851
|
],
|
|
6807
6852
|
},
|
|
6808
6853
|
reasonSubject: {
|
|
@@ -12974,7 +13019,16 @@ export const schemaDict = {
|
|
|
12974
13019
|
defs: {
|
|
12975
13020
|
main: {
|
|
12976
13021
|
type: 'procedure',
|
|
12977
|
-
description:
|
|
13022
|
+
description:
|
|
13023
|
+
"Delete the current session. Requires auth using the 'refreshJwt' (not the 'accessJwt').",
|
|
13024
|
+
errors: [
|
|
13025
|
+
{
|
|
13026
|
+
name: 'InvalidToken',
|
|
13027
|
+
},
|
|
13028
|
+
{
|
|
13029
|
+
name: 'ExpiredToken',
|
|
13030
|
+
},
|
|
13031
|
+
],
|
|
12978
13032
|
},
|
|
12979
13033
|
},
|
|
12980
13034
|
},
|
|
@@ -13173,6 +13227,9 @@ export const schemaDict = {
|
|
|
13173
13227
|
type: 'string',
|
|
13174
13228
|
format: 'did',
|
|
13175
13229
|
},
|
|
13230
|
+
didDoc: {
|
|
13231
|
+
type: 'unknown',
|
|
13232
|
+
},
|
|
13176
13233
|
email: {
|
|
13177
13234
|
type: 'string',
|
|
13178
13235
|
},
|
|
@@ -13182,9 +13239,6 @@ export const schemaDict = {
|
|
|
13182
13239
|
emailAuthFactor: {
|
|
13183
13240
|
type: 'boolean',
|
|
13184
13241
|
},
|
|
13185
|
-
didDoc: {
|
|
13186
|
-
type: 'unknown',
|
|
13187
|
-
},
|
|
13188
13242
|
active: {
|
|
13189
13243
|
type: 'boolean',
|
|
13190
13244
|
},
|
|
@@ -13278,6 +13332,15 @@ export const schemaDict = {
|
|
|
13278
13332
|
didDoc: {
|
|
13279
13333
|
type: 'unknown',
|
|
13280
13334
|
},
|
|
13335
|
+
email: {
|
|
13336
|
+
type: 'string',
|
|
13337
|
+
},
|
|
13338
|
+
emailConfirmed: {
|
|
13339
|
+
type: 'boolean',
|
|
13340
|
+
},
|
|
13341
|
+
emailAuthFactor: {
|
|
13342
|
+
type: 'boolean',
|
|
13343
|
+
},
|
|
13281
13344
|
active: {
|
|
13282
13345
|
type: 'boolean',
|
|
13283
13346
|
},
|
|
@@ -13294,6 +13357,12 @@ export const schemaDict = {
|
|
|
13294
13357
|
{
|
|
13295
13358
|
name: 'AccountTakedown',
|
|
13296
13359
|
},
|
|
13360
|
+
{
|
|
13361
|
+
name: 'InvalidToken',
|
|
13362
|
+
},
|
|
13363
|
+
{
|
|
13364
|
+
name: 'ExpiredToken',
|
|
13365
|
+
},
|
|
13297
13366
|
],
|
|
13298
13367
|
},
|
|
13299
13368
|
},
|
|
@@ -37,7 +37,7 @@ export interface HandlerSuccess {
|
|
|
37
37
|
export interface HandlerError {
|
|
38
38
|
status: number
|
|
39
39
|
message?: string
|
|
40
|
-
error?: '
|
|
40
|
+
error?: 'InvalidDid' | 'InvalidLimit' | 'InvalidCursor' | 'InternalError'
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export type HandlerOutput = HandlerError | HandlerSuccess
|
|
@@ -43,7 +43,12 @@ export interface HandlerSuccess {
|
|
|
43
43
|
export interface HandlerError {
|
|
44
44
|
status: number
|
|
45
45
|
message?: string
|
|
46
|
-
error?:
|
|
46
|
+
error?:
|
|
47
|
+
| 'InvalidDid'
|
|
48
|
+
| 'InvalidContacts'
|
|
49
|
+
| 'TooManyContacts'
|
|
50
|
+
| 'InvalidToken'
|
|
51
|
+
| 'InternalError'
|
|
47
52
|
}
|
|
48
53
|
|
|
49
54
|
export type HandlerOutput = HandlerError | HandlerSuccess
|
|
@@ -37,7 +37,7 @@ export interface HandlerSuccess {
|
|
|
37
37
|
export interface HandlerError {
|
|
38
38
|
status: number
|
|
39
39
|
message?: string
|
|
40
|
-
error?: '
|
|
40
|
+
error?: 'RateLimitExceeded' | 'InvalidDid' | 'InvalidPhone' | 'InternalError'
|
|
41
41
|
}
|
|
42
42
|
|
|
43
43
|
export type HandlerOutput = HandlerError | HandlerSuccess
|
|
@@ -42,7 +42,12 @@ export interface HandlerSuccess {
|
|
|
42
42
|
export interface HandlerError {
|
|
43
43
|
status: number
|
|
44
44
|
message?: string
|
|
45
|
-
error?:
|
|
45
|
+
error?:
|
|
46
|
+
| 'RateLimitExceeded'
|
|
47
|
+
| 'InvalidDid'
|
|
48
|
+
| 'InvalidPhone'
|
|
49
|
+
| 'InvalidCode'
|
|
50
|
+
| 'InternalError'
|
|
46
51
|
}
|
|
47
52
|
|
|
48
53
|
export type HandlerOutput = HandlerError | HandlerSuccess
|
|
@@ -20,10 +20,10 @@ export type InputSchema = undefined
|
|
|
20
20
|
export interface OutputSchema {
|
|
21
21
|
handle: string
|
|
22
22
|
did: string
|
|
23
|
+
didDoc?: { [_ in string]: unknown }
|
|
23
24
|
email?: string
|
|
24
25
|
emailConfirmed?: boolean
|
|
25
26
|
emailAuthFactor?: boolean
|
|
26
|
-
didDoc?: { [_ in string]: unknown }
|
|
27
27
|
active?: boolean
|
|
28
28
|
/** If active=false, this optional field indicates a possible reason for why the account is not active. If active=false and no status is supplied, then the host makes no claim for why the repository is no longer being hosted. */
|
|
29
29
|
status?: 'takendown' | 'suspended' | 'deactivated' | (string & {})
|
|
@@ -23,6 +23,9 @@ export interface OutputSchema {
|
|
|
23
23
|
handle: string
|
|
24
24
|
did: string
|
|
25
25
|
didDoc?: { [_ in string]: unknown }
|
|
26
|
+
email?: string
|
|
27
|
+
emailConfirmed?: boolean
|
|
28
|
+
emailAuthFactor?: boolean
|
|
26
29
|
active?: boolean
|
|
27
30
|
/** Hosting status of the account. If not specified, then assume 'active'. */
|
|
28
31
|
status?: 'takendown' | 'suspended' | 'deactivated' | (string & {})
|
|
@@ -39,7 +42,7 @@ export interface HandlerSuccess {
|
|
|
39
42
|
export interface HandlerError {
|
|
40
43
|
status: number
|
|
41
44
|
message?: string
|
|
42
|
-
error?: 'AccountTakedown'
|
|
45
|
+
error?: 'AccountTakedown' | 'InvalidToken' | 'ExpiredToken'
|
|
43
46
|
}
|
|
44
47
|
|
|
45
48
|
export type HandlerOutput = HandlerError | HandlerSuccess
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
import assert from 'node:assert'
|
|
2
|
+
import { type Browser, type Page } from 'puppeteer'
|
|
3
|
+
|
|
4
|
+
export class PageHelper implements AsyncDisposable {
|
|
5
|
+
constructor(protected readonly page: Page) {}
|
|
6
|
+
|
|
7
|
+
async goto(url: string) {
|
|
8
|
+
await this.page.goto(url)
|
|
9
|
+
}
|
|
10
|
+
|
|
11
|
+
async waitForNetworkIdle() {
|
|
12
|
+
await this.page.waitForNetworkIdle()
|
|
13
|
+
}
|
|
14
|
+
|
|
15
|
+
async navigationAction(run: () => Promise<unknown>): Promise<void> {
|
|
16
|
+
const promise = this.page.waitForNavigation()
|
|
17
|
+
await run()
|
|
18
|
+
await promise
|
|
19
|
+
await this.waitForNetworkIdle()
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
async checkTitle(expected: string) {
|
|
23
|
+
await this.waitForNetworkIdle()
|
|
24
|
+
await expect(this.page.title()).resolves.toBe(expected)
|
|
25
|
+
}
|
|
26
|
+
|
|
27
|
+
async clickOn(selector: string) {
|
|
28
|
+
const elementHandle = await this.getVisibleElement(selector)
|
|
29
|
+
await elementHandle.click()
|
|
30
|
+
return elementHandle
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
async clickOnButton(text: string) {
|
|
34
|
+
return this.clickOn(`button::-p-text(${JSON.stringify(text)})`)
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
async typeIn(selector: string, text: string) {
|
|
38
|
+
const elementHandle = await this.getVisibleElement(selector)
|
|
39
|
+
elementHandle.focus()
|
|
40
|
+
await elementHandle.type(text)
|
|
41
|
+
return elementHandle
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
async typeInInput(name: string, text: string) {
|
|
45
|
+
return this.typeIn(`input[name=${JSON.stringify(name)}]`, text)
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
async ensureTextVisibility(text: string, tag = 'p') {
|
|
49
|
+
await this.page.waitForSelector(`${tag}::-p-text(${JSON.stringify(text)})`)
|
|
50
|
+
}
|
|
51
|
+
|
|
52
|
+
protected async getVisibleElement(selector: string) {
|
|
53
|
+
const elementHandle = await this.page.waitForSelector(selector)
|
|
54
|
+
|
|
55
|
+
expect(elementHandle).not.toBeNull()
|
|
56
|
+
assert(elementHandle)
|
|
57
|
+
|
|
58
|
+
await expect(elementHandle.isVisible()).resolves.toBe(true)
|
|
59
|
+
|
|
60
|
+
return elementHandle
|
|
61
|
+
}
|
|
62
|
+
|
|
63
|
+
async [Symbol.asyncDispose]() {
|
|
64
|
+
return this.page.close()
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
static async from(
|
|
68
|
+
browser: Browser,
|
|
69
|
+
options?: { languages?: readonly string[] },
|
|
70
|
+
) {
|
|
71
|
+
const page = await browser.newPage()
|
|
72
|
+
|
|
73
|
+
if (options?.languages?.length) {
|
|
74
|
+
// Spoof navigator language settings
|
|
75
|
+
await page.evaluateOnNewDocument(`
|
|
76
|
+
Object.defineProperty(navigator, 'languages', {
|
|
77
|
+
get: () => ${JSON.stringify(options.languages)},
|
|
78
|
+
})
|
|
79
|
+
Object.defineProperty(navigator, 'language', {
|
|
80
|
+
get: () => ${JSON.stringify(options.languages[0])},
|
|
81
|
+
})
|
|
82
|
+
`)
|
|
83
|
+
}
|
|
84
|
+
|
|
85
|
+
return new PageHelper(page)
|
|
86
|
+
}
|
|
87
|
+
}
|