diff --git a/package-lock.json b/package-lock.json index c77bb47..6b699bf 100644 --- a/package-lock.json +++ b/package-lock.json @@ -15,9 +15,10 @@ "axios-retry": "^4.4.2" }, "devDependencies": { - "@seamapi/fake-seam-connect": "1.71.0", - "@seamapi/types": "1.292.2", + "@seamapi/fake-seam-connect": "^1.72.1", + "@seamapi/types": "1.294.0", "@types/eslint": "^8.44.2", + "@types/jsonwebtoken": "^9.0.6", "@types/node": "^20.8.10", "ava": "^5.0.1", "c8": "^10.1.2", @@ -32,6 +33,7 @@ "eslint-plugin-simple-import-sort": "^12.0.0", "eslint-plugin-unused-imports": "^3.0.0", "execa": "^9.2.0", + "jsonwebtoken": "^9.0.2", "landlubber": "^2.0.0", "nock": "^13.4.0", "node-fetch": "^3.3.2", @@ -47,7 +49,7 @@ "npm": ">= 9.0.0" }, "peerDependencies": { - "@seamapi/types": "^1.292.2" + "@seamapi/types": "^1.294.0" }, "peerDependenciesMeta": { "@seamapi/types": { @@ -1045,9 +1047,9 @@ } }, "node_modules/@seamapi/fake-seam-connect": { - "version": "1.71.0", - "resolved": "https://registry.npmjs.org/@seamapi/fake-seam-connect/-/fake-seam-connect-1.71.0.tgz", - "integrity": "sha512-yhGB/kgOEj/nQv8GMMS27JezVwuQgr7bH1bugKxVVcvrKJVnJpebDUZCT1TeBUoc6P4rtE/BcL6TJPxrQmfRNw==", + "version": "1.72.1", + "resolved": "https://registry.npmjs.org/@seamapi/fake-seam-connect/-/fake-seam-connect-1.72.1.tgz", + "integrity": "sha512-ydDnKE+iOVRU0xEBpTYwpNjIRgV/pVkmPvXNRG76JBYtYf2whZxAPhcMUEjQbRk6tW1r8ykY051aLsWoKfjNPQ==", "dev": true, "license": "MIT", "bin": { @@ -1064,9 +1066,9 @@ } }, "node_modules/@seamapi/types": { - "version": "1.292.2", - "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.292.2.tgz", - "integrity": "sha512-mOCFatzYy89uzu4IEV3kFoPz5SCVd3w2TMC0G3hVrzxL3PYFRnuUa4LNKMsd583prDgoh6rmEHhKEAICqibXFQ==", + "version": "1.294.0", + "resolved": "https://registry.npmjs.org/@seamapi/types/-/types-1.294.0.tgz", + "integrity": "sha512-NcZemUYBNECpMXJnBgteRwPrri0jZSUPKPJTdeOM7X0ba3kWpuj3nvA5JESsLArFB7Tv7kUAVngIvY2vWrc7aw==", "dev": true, "license": "MIT", "engines": { @@ -1213,6 +1215,16 @@ "license": "MIT", "peer": true }, + "node_modules/@types/jsonwebtoken": { + "version": "9.0.7", + "resolved": "https://registry.npmjs.org/@types/jsonwebtoken/-/jsonwebtoken-9.0.7.tgz", + "integrity": "sha512-ugo316mmTYBl2g81zDFnZ7cfxlut3o+/EQdaP7J8QN2kY6lJ22hmQYCK5EHcJHbrW+dkCGSCPgbG8JtYj6qSrg==", + "dev": true, + "license": "MIT", + "dependencies": { + "@types/node": "*" + } + }, "node_modules/@types/mdast": { "version": "4.0.4", "resolved": "https://registry.npmjs.org/@types/mdast/-/mdast-4.0.4.tgz", @@ -2026,6 +2038,13 @@ "ieee754": "^1.2.1" } }, + "node_modules/buffer-equal-constant-time": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/buffer-equal-constant-time/-/buffer-equal-constant-time-1.0.1.tgz", + "integrity": "sha512-zRpUiDwd/xk6ADqPMATG8vc9VPrkck7T07OIx0gnjmJAnHnTVXNQG3vfvWNuiZIkwu9KrKdA1iJKfsfTVxE6NA==", + "dev": true, + "license": "BSD-3-Clause" + }, "node_modules/builtin-modules": { "version": "3.3.0", "resolved": "https://registry.npmjs.org/builtin-modules/-/builtin-modules-3.3.0.tgz", @@ -2973,6 +2992,16 @@ "dev": true, "license": "MIT" }, + "node_modules/ecdsa-sig-formatter": { + "version": "1.0.11", + "resolved": "https://registry.npmjs.org/ecdsa-sig-formatter/-/ecdsa-sig-formatter-1.0.11.tgz", + "integrity": "sha512-nagl3RYrbNv6kQkeJIpt6NJZy8twLB/2vtz6yN9Z4vRKHN4/QZJIEbqohALSgwKdnksuY3k5Addp5lg8sVoVcQ==", + "dev": true, + "license": "Apache-2.0", + "dependencies": { + "safe-buffer": "^5.0.1" + } + }, "node_modules/emittery": { "version": "1.0.3", "resolved": "https://registry.npmjs.org/emittery/-/emittery-1.0.3.tgz", @@ -5433,6 +5462,52 @@ "json5": "lib/cli.js" } }, + "node_modules/jsonwebtoken": { + "version": "9.0.2", + "resolved": "https://registry.npmjs.org/jsonwebtoken/-/jsonwebtoken-9.0.2.tgz", + "integrity": "sha512-PRp66vJ865SSqOlgqS8hujT5U4AOgMfhrwYIuIhfKaoSCZcirrmASQr8CX7cUg+RMih+hgznrjp99o+W4pJLHQ==", + "dev": true, + "license": "MIT", + "dependencies": { + "jws": "^3.2.2", + "lodash.includes": "^4.3.0", + "lodash.isboolean": "^3.0.3", + "lodash.isinteger": "^4.0.4", + "lodash.isnumber": "^3.0.3", + "lodash.isplainobject": "^4.0.6", + "lodash.isstring": "^4.0.1", + "lodash.once": "^4.0.0", + "ms": "^2.1.1", + "semver": "^7.5.4" + }, + "engines": { + "node": ">=12", + "npm": ">=6" + } + }, + "node_modules/jwa": { + "version": "1.4.1", + "resolved": "https://registry.npmjs.org/jwa/-/jwa-1.4.1.tgz", + "integrity": "sha512-qiLX/xhEEFKUAJ6FiBMbes3w9ATzyk5W7Hvzpa/SLYdxNtng+gcurvrI7TbACjIXlsJyr05/S1oUhZrc63evQA==", + "dev": true, + "license": "MIT", + "dependencies": { + "buffer-equal-constant-time": "1.0.1", + "ecdsa-sig-formatter": "1.0.11", + "safe-buffer": "^5.0.1" + } + }, + "node_modules/jws": { + "version": "3.2.2", + "resolved": "https://registry.npmjs.org/jws/-/jws-3.2.2.tgz", + "integrity": "sha512-YHlZCB6lMTllWDtSPHz/ZXTsi8S00usEV6v1tjq8tOUZzw7DpSDWVXjXDre6ed1w/pd495ODpHZYSdkRTsa0HA==", + "dev": true, + "license": "MIT", + "dependencies": { + "jwa": "^1.4.1", + "safe-buffer": "^5.0.1" + } + }, "node_modules/keyv": { "version": "4.5.4", "resolved": "https://registry.npmjs.org/keyv/-/keyv-4.5.4.tgz", @@ -5550,6 +5625,48 @@ "dev": true, "license": "MIT" }, + "node_modules/lodash.includes": { + "version": "4.3.0", + "resolved": "https://registry.npmjs.org/lodash.includes/-/lodash.includes-4.3.0.tgz", + "integrity": "sha512-W3Bx6mdkRTGtlJISOvVD/lbqjTlPPUDTMnlXZFnVwi9NKJ6tiAk6LVdlhZMm17VZisqhKcgzpO5Wz91PCt5b0w==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.isboolean": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isboolean/-/lodash.isboolean-3.0.3.tgz", + "integrity": "sha512-Bz5mupy2SVbPHURB98VAcw+aHh4vRV5IPNhILUCsOzRmsTmSQ17jIuqopAentWoehktxGd9e/hbIXq980/1QJg==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.isinteger": { + "version": "4.0.4", + "resolved": "https://registry.npmjs.org/lodash.isinteger/-/lodash.isinteger-4.0.4.tgz", + "integrity": "sha512-DBwtEWN2caHQ9/imiNeEA5ys1JoRtRfY3d7V9wkqtbycnAmTvRRmbHKDV4a0EYc678/dia0jrte4tjYwVBaZUA==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.isnumber": { + "version": "3.0.3", + "resolved": "https://registry.npmjs.org/lodash.isnumber/-/lodash.isnumber-3.0.3.tgz", + "integrity": "sha512-QYqzpfwO3/CWf3XP+Z+tkQsfaLL/EnUlXWVkIk5FUPc4sBdTehEqZONuyRt2P67PXAk+NXmTBcc97zw9t1FQrw==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.isplainobject": { + "version": "4.0.6", + "resolved": "https://registry.npmjs.org/lodash.isplainobject/-/lodash.isplainobject-4.0.6.tgz", + "integrity": "sha512-oSXzaWypCMHkPC3NvBEaPHf0KsA5mvPrOPgQWDsbg8n7orZ290M0BmC/jgRZ4vcJ6DTAhjrsSYgdsW/F+MFOBA==", + "dev": true, + "license": "MIT" + }, + "node_modules/lodash.isstring": { + "version": "4.0.1", + "resolved": "https://registry.npmjs.org/lodash.isstring/-/lodash.isstring-4.0.1.tgz", + "integrity": "sha512-0wJxfxH1wgO3GrbuP+dTTk7op+6L41QCXbGINEmD+ny/G/eCqGzxyCsh7159S+mgDDcoarnBw6PC1PS5+wUGgw==", + "dev": true, + "license": "MIT" + }, "node_modules/lodash.merge": { "version": "4.6.2", "resolved": "https://registry.npmjs.org/lodash.merge/-/lodash.merge-4.6.2.tgz", @@ -5557,6 +5674,13 @@ "dev": true, "license": "MIT" }, + "node_modules/lodash.once": { + "version": "4.1.1", + "resolved": "https://registry.npmjs.org/lodash.once/-/lodash.once-4.1.1.tgz", + "integrity": "sha512-Sb487aTOCr9drQVL8pIxOzVhafOjZN9UU54hiN8PU3uAiSV7lx1yYNpbNmex2PK6dSJoNTSJUUswT651yww3Mg==", + "dev": true, + "license": "MIT" + }, "node_modules/lodash.sortby": { "version": "4.7.0", "resolved": "https://registry.npmjs.org/lodash.sortby/-/lodash.sortby-4.7.0.tgz", diff --git a/package.json b/package.json index ef4f66f..120a29a 100644 --- a/package.json +++ b/package.json @@ -84,7 +84,7 @@ "npm": ">= 9.0.0" }, "peerDependencies": { - "@seamapi/types": "^1.292.2" + "@seamapi/types": "^1.294.0" }, "peerDependenciesMeta": { "@seamapi/types": { @@ -98,9 +98,10 @@ "axios-retry": "^4.4.2" }, "devDependencies": { - "@seamapi/fake-seam-connect": "1.71.0", - "@seamapi/types": "1.292.2", + "@seamapi/fake-seam-connect": "^1.72.1", + "@seamapi/types": "1.294.0", "@types/eslint": "^8.44.2", + "@types/jsonwebtoken": "^9.0.6", "@types/node": "^20.8.10", "ava": "^5.0.1", "c8": "^10.1.2", @@ -115,6 +116,7 @@ "eslint-plugin-simple-import-sort": "^12.0.0", "eslint-plugin-unused-imports": "^3.0.0", "execa": "^9.2.0", + "jsonwebtoken": "^9.0.2", "landlubber": "^2.0.0", "nock": "^13.4.0", "node-fetch": "^3.3.2", diff --git a/test/seam/connect/client-session-token.test.ts b/test/seam/connect/client-session-token.test.ts index f15f10c..c58bca5 100644 --- a/test/seam/connect/client-session-token.test.ts +++ b/test/seam/connect/client-session-token.test.ts @@ -56,13 +56,21 @@ test('SeamHttp: updateClientSessionToken returns instance authorized with a new const seam = SeamHttp.fromClientSessionToken(seed.seam_cst1_token, { endpoint, }) - const { token } = await seam.clientSessions.create({ + + const devices = await seam.devices.list() + t.true(devices.length > 0) + + const seamUsingApiKey = SeamHttp.fromApiKey(seed.seam_apikey2_token, { + endpoint, + }) + + const { token } = await seamUsingApiKey.clientSessions.create({ user_identifier_key: 'some-new-user-identifier-key', }) await seam.updateClientSessionToken(token) - const devices = await seam.devices.list() - t.is(devices.length, 0) + const devicesFromNewSession = await seam.devices.list() + t.is(devicesFromNewSession.length, 0) }) test('SeamHttp: updateClientSessionToken fails if no existing clientSessionToken', async (t) => { @@ -92,6 +100,5 @@ test('SeamHttp: updateClientSessionToken checks clientSessionToken is authorized instanceOf: SeamHttpApiError, }, ) - t.is(err?.statusCode, 404) - t.is(err?.code, 'client_session_token_not_found') + t.is(err?.statusCode, 401) }) diff --git a/test/seam/connect/client.test.ts b/test/seam/connect/client.test.ts index 737063e..9c1a7bc 100644 --- a/test/seam/connect/client.test.ts +++ b/test/seam/connect/client.test.ts @@ -108,54 +108,45 @@ test('SeamHttp: merges axios headers when creating client', async (t) => { t.is(device.device_id, seed.august_device_1) }) -// UPSTREAM: Fake does not support personal access token. -// https://github.com/seamapi/fake-seam-connect/issues/126 -test.failing( - 'SeamHttpMultiWorkspace: fromClient returns instance that uses client', - async (t) => { - const { endpoint } = await getTestServer(t) - const seam = SeamHttpMultiWorkspace.fromClient( - SeamHttpMultiWorkspace.fromPersonalAccessToken('seam_at_TODO', { - endpoint, - }).client, - ) - const workspaces = await seam.workspaces.list() - t.true(workspaces.length > 0) - }, -) +test('SeamHttpMultiWorkspace: fromClient returns instance that uses client', async (t) => { + const { seed, endpoint } = await getTestServer(t) + const seam = SeamHttpMultiWorkspace.fromClient( + SeamHttpMultiWorkspace.fromPersonalAccessToken(seed.seam_at1_token, { + endpoint, + }).client, + ) + const workspaces = await seam.workspaces.list() + t.true(workspaces.length > 0) +}) -// UPSTREAM: Fake does not support personal access token. -// https://github.com/seamapi/fake-seam-connect/issues/126 -test.failing( - 'SeamHttpMultiWorkspace: constructor returns instance that uses client', - async (t) => { - const { endpoint } = await getTestServer(t) - const seam = new SeamHttpMultiWorkspace({ - client: SeamHttpMultiWorkspace.fromPersonalAccessToken('seam_at_TODO', { +test('SeamHttpMultiWorkspace: constructor returns instance that uses client', async (t) => { + const { seed, endpoint } = await getTestServer(t) + const seam = new SeamHttpMultiWorkspace({ + client: SeamHttpMultiWorkspace.fromPersonalAccessToken( + seed.seam_at1_token, + { endpoint, - }).client, - }) - const workspaces = await seam.workspaces.list() - t.true(workspaces.length > 0) - }, -) + }, + ).client, + }) + const workspaces = await seam.workspaces.list() + t.true(workspaces.length > 0) +}) -// UPSTREAM: Fake does not support personal access token. -// https://github.com/seamapi/fake-seam-connect/issues/126 -test.failing( - 'SeamHttpMultiWorkspace: can use client to make requests', - async (t) => { - const { endpoint } = await getTestServer(t) - const seam = new SeamHttpMultiWorkspace({ - client: SeamHttpMultiWorkspace.fromPersonalAccessToken('seam_at_TODO', { +test('SeamHttpMultiWorkspace: can use client to make requests', async (t) => { + const { seed, endpoint } = await getTestServer(t) + const seam = new SeamHttpMultiWorkspace({ + client: SeamHttpMultiWorkspace.fromPersonalAccessToken( + seed.seam_at1_token, + { endpoint, - }).client, - }) - const { - data: { workspaces }, - status, - } = await seam.client.get('/workspaces/list') - t.is(status, 200) - t.true(workspaces.length > 0) - }, -) + }, + ).client, + }) + const { + data: { workspaces }, + status, + } = await seam.client.get('/workspaces/list') + t.is(status, 200) + t.true(workspaces.length > 0) +}) diff --git a/test/seam/connect/console-session-token.test.ts b/test/seam/connect/console-session-token.test.ts index 4728abe..7fcf041 100644 --- a/test/seam/connect/console-session-token.test.ts +++ b/test/seam/connect/console-session-token.test.ts @@ -1,5 +1,6 @@ import test from 'ava' import { getTestServer } from 'fixtures/seam/connect/api.js' +import jwt from 'jsonwebtoken' import { SeamHttp, @@ -7,45 +8,53 @@ import { SeamHttpMultiWorkspace, } from '@seamapi/http/connect' -// UPSTREAM: Fake does not support JWT. -// https://github.com/seamapi/fake-seam-connect/issues/124 -test.failing( - 'SeamHttp: fromConsoleSessionToken returns instance authorized with consoleSessionToken', - async (t) => { - const { seed, endpoint } = await getTestServer(t) - const seam = SeamHttp.fromConsoleSessionToken( - 'ey_TODO', - seed.seed_workspace_1, - { - endpoint, - }, - ) - const device = await seam.devices.get({ - device_id: seed.august_device_1, - }) - t.is(device.workspace_id, seed.seed_workspace_1) - t.is(device.device_id, seed.august_device_1) - }, -) +test('SeamHttp: fromConsoleSessionToken returns instance authorized with consoleSessionToken', async (t) => { + const { seed, endpoint } = await getTestServer(t) -// UPSTREAM: Fake does not support JWT. -// https://github.com/seamapi/fake-seam-connect/issues/124 -test.failing( - 'SeamHttp: constructor returns instance authorized with consoleSessionToken', - async (t) => { - const { seed, endpoint } = await getTestServer(t) - const seam = new SeamHttp({ - consoleSessionToken: 'ey_TODO', - workspaceId: seed.seed_workspace_1, + const consoleSessionToken = jwt.sign( + { + user_id: seed.john_user_id, + key: seed.john_user_key, + }, + 'secret', + ) + + const seam = SeamHttp.fromConsoleSessionToken( + consoleSessionToken, + seed.seed_workspace_1, + { endpoint, - }) - const device = await seam.devices.get({ - device_id: seed.august_device_1, - }) - t.is(device.workspace_id, seed.seed_workspace_1) - t.is(device.device_id, seed.august_device_1) - }, -) + }, + ) + const device = await seam.devices.get({ + device_id: seed.august_device_1, + }) + t.is(device.workspace_id, seed.seed_workspace_1) + t.is(device.device_id, seed.august_device_1) +}) + +test('SeamHttp: constructor returns instance authorized with consoleSessionToken', async (t) => { + const { seed, endpoint } = await getTestServer(t) + + const consoleSessionToken = jwt.sign( + { + user_id: seed.john_user_id, + key: seed.john_user_key, + }, + 'secret', + ) + + const seam = new SeamHttp({ + consoleSessionToken, + workspaceId: seed.seed_workspace_1, + endpoint, + }) + const device = await seam.devices.get({ + device_id: seed.august_device_1, + }) + t.is(device.workspace_id, seed.seed_workspace_1) + t.is(device.device_id, seed.august_device_1) +}) test('SeamHttp: checks consoleSessionToken format', (t) => { const workspaceId = 'e4203e37-e569-4a5a-bfb7-e3e8de66161d' @@ -74,34 +83,43 @@ test('SeamHttp: checks consoleSessionToken format', (t) => { }) }) -// UPSTREAM: Fake does not support JWT. -// https://github.com/seamapi/fake-seam-connect/issues/124 -test.failing( - 'SeamHttpMultiWorkspace: fromConsoleSessionToken returns instance authorized with consoleSessionToken', - async (t) => { - const { endpoint } = await getTestServer(t) - const seam = SeamHttpMultiWorkspace.fromConsoleSessionToken('ey_TODO', { - endpoint, - }) - const workspaces = await seam.workspaces.list() - t.true(workspaces.length > 0) - }, -) +test('SeamHttpMultiWorkspace: fromConsoleSessionToken returns instance authorized with consoleSessionToken', async (t) => { + const { seed, endpoint } = await getTestServer(t) + const consoleSessionToken = jwt.sign( + { + user_id: seed.john_user_id, + key: seed.john_user_key, + }, + 'secret', + ) -// UPSTREAM: Fake does not support JWT. -// https://github.com/seamapi/fake-seam-connect/issues/124 -test.failing( - 'SeamHttpMultiWorkspace: constructor returns instance authorized with consoleSessionToken', - async (t) => { - const { endpoint } = await getTestServer(t) - const seam = new SeamHttpMultiWorkspace({ - consoleSessionToken: 'ey_TODO', + const seam = SeamHttpMultiWorkspace.fromConsoleSessionToken( + consoleSessionToken, + { endpoint, - }) - const workspaces = await seam.workspaces.list() - t.true(workspaces.length > 0) - }, -) + }, + ) + const workspaces = await seam.workspaces.list() + t.true(workspaces.length > 0) +}) + +test('SeamHttpMultiWorkspace: constructor returns instance authorized with consoleSessionToken', async (t) => { + const { seed, endpoint } = await getTestServer(t) + const consoleSessionToken = jwt.sign( + { + user_id: seed.john_user_id, + key: seed.john_user_key, + }, + 'secret', + ) + + const seam = new SeamHttpMultiWorkspace({ + consoleSessionToken, + endpoint, + }) + const workspaces = await seam.workspaces.list() + t.true(workspaces.length > 0) +}) test('SeamHttpMultiWorkspace: checks consoleSessionToken format', (t) => { t.throws( diff --git a/test/seam/connect/env.test.ts b/test/seam/connect/env.test.ts index 20ddcdb..17c65f1 100644 --- a/test/seam/connect/env.test.ts +++ b/test/seam/connect/env.test.ts @@ -2,6 +2,7 @@ import { env } from 'node:process' import test from 'ava' import { getTestServer } from 'fixtures/seam/connect/api.js' +import jwt from 'jsonwebtoken' import { SeamHttp, SeamHttpInvalidOptionsError } from '@seamapi/http/connect' @@ -194,15 +195,20 @@ test.serial( }, ) -// UPSTREAM: Fake does not support JWT. -// https://github.com/seamapi/fake-seam-connect/issues/124 -test.serial.failing( +test.serial( 'SeamHttp: SEAM_API_KEY environment variable is ignored with fromConsoleSessionToken', async (t) => { const { seed, endpoint } = await getTestServer(t) env.SEAM_API_KEY = seed.seam_apikey1_token + const consoleSessionToken = jwt.sign( + { + user_id: seed.john_user_id, + key: seed.john_user_key, + }, + 'secret', + ) const seam = SeamHttp.fromConsoleSessionToken( - 'ey_TODO', + consoleSessionToken, seed.seed_workspace_1, { endpoint, @@ -216,15 +222,13 @@ test.serial.failing( }, ) -// UPSTREAM: Fake does not support personal access token. -// https://github.com/seamapi/fake-seam-connect/issues/126 -test.serial.failing( +test.serial( 'SeamHttp: SEAM_API_KEY environment variable is ignored with personalAccessToken', async (t) => { const { seed, endpoint } = await getTestServer(t) env.SEAM_API_KEY = seed.seam_apikey1_token const seam = SeamHttp.fromPersonalAccessToken( - 'seam_at_TODO', + seed.seam_at1_token, seed.seed_workspace_1, { endpoint, diff --git a/test/seam/connect/personal-access-token.test.ts b/test/seam/connect/personal-access-token.test.ts index 66f5a39..04bef94 100644 --- a/test/seam/connect/personal-access-token.test.ts +++ b/test/seam/connect/personal-access-token.test.ts @@ -7,45 +7,35 @@ import { SeamHttpMultiWorkspace, } from '@seamapi/http/connect' -// UPSTREAM: Fake does not support personal access token. -// https://github.com/seamapi/fake-seam-connect/issues/126 -test.failing( - 'SeamHttp: fromPersonalAccessToken returns instance authorized with personalAccessToken', - async (t) => { - const { seed, endpoint } = await getTestServer(t) - const seam = SeamHttp.fromPersonalAccessToken( - 'seam_at_TODO', - seed.seed_workspace_1, - { - endpoint, - }, - ) - const device = await seam.devices.get({ - device_id: seed.august_device_1, - }) - t.is(device.workspace_id, seed.seed_workspace_1) - t.is(device.device_id, seed.august_device_1) - }, -) - -// UPSTREAM: Fake does not support personal access token. -// https://github.com/seamapi/fake-seam-connect/issues/126 -test.failing( - 'SeamHttp: constructor returns instance authorized with personalAccessToken', - async (t) => { - const { seed, endpoint } = await getTestServer(t) - const seam = new SeamHttp({ - personalAccessToken: 'seam_at_TODO', - workspaceId: seed.seed_workspace_1, +test('SeamHttp: fromPersonalAccessToken returns instance authorized with personalAccessToken', async (t) => { + const { seed, endpoint } = await getTestServer(t) + const seam = SeamHttp.fromPersonalAccessToken( + seed.seam_at1_token, + seed.seed_workspace_1, + { endpoint, - }) - const device = await seam.devices.get({ - device_id: seed.august_device_1, - }) - t.is(device.workspace_id, seed.seed_workspace_1) - t.is(device.device_id, seed.august_device_1) - }, -) + }, + ) + const device = await seam.devices.get({ + device_id: seed.august_device_1, + }) + t.is(device.workspace_id, seed.seed_workspace_1) + t.is(device.device_id, seed.august_device_1) +}) + +test('SeamHttp: constructor returns instance authorized with personalAccessToken', async (t) => { + const { seed, endpoint } = await getTestServer(t) + const seam = new SeamHttp({ + personalAccessToken: seed.seam_at1_token, + workspaceId: seed.seed_workspace_1, + endpoint, + }) + const device = await seam.devices.get({ + device_id: seed.august_device_1, + }) + t.is(device.workspace_id, seed.seed_workspace_1) + t.is(device.device_id, seed.august_device_1) +}) test('SeamHttp: checks personalAccessToken format', (t) => { const workspaceId = 'e4203e37-e569-4a5a-bfb7-e3e8de66161d' @@ -74,37 +64,27 @@ test('SeamHttp: checks personalAccessToken format', (t) => { }) }) -// UPSTREAM: Fake does not support personal access token. -// https://github.com/seamapi/fake-seam-connect/issues/126 -test.failing( - 'SeamHttpMultiWorkspace: fromPersonalAccessToken returns instance authorized with personalAccessToken', - async (t) => { - const { endpoint } = await getTestServer(t) - const seam = SeamHttpMultiWorkspace.fromPersonalAccessToken( - 'seam_at_TODO', - { - endpoint, - }, - ) - const workspaces = await seam.workspaces.list() - t.true(workspaces.length > 0) - }, -) - -// UPSTREAM: Fake does not support personal access token. -// https://github.com/seamapi/fake-seam-connect/issues/126 -test.failing( - 'SeamHttpMultiWorkspace: constructor returns instance authorized with personalAccessToken', - async (t) => { - const { endpoint } = await getTestServer(t) - const seam = new SeamHttpMultiWorkspace({ - personalAccessToken: 'seam_at_TODO', +test('SeamHttpMultiWorkspace: fromPersonalAccessToken returns instance authorized with personalAccessToken', async (t) => { + const { seed, endpoint } = await getTestServer(t) + const seam = SeamHttpMultiWorkspace.fromPersonalAccessToken( + seed.seam_at1_token, + { endpoint, - }) - const workspaces = await seam.workspaces.list() - t.true(workspaces.length > 0) - }, -) + }, + ) + const workspaces = await seam.workspaces.list() + t.true(workspaces.length > 0) +}) + +test('SeamHttpMultiWorkspace: constructor returns instance authorized with personalAccessToken', async (t) => { + const { seed, endpoint } = await getTestServer(t) + const seam = new SeamHttpMultiWorkspace({ + personalAccessToken: seed.seam_at1_token, + endpoint, + }) + const workspaces = await seam.workspaces.list() + t.true(workspaces.length > 0) +}) test('SeamHttpMultiWorkspace: checks personalAccessToken format', (t) => { t.throws(