@streamlayer/sdk-web-anonymous-auth
Advanced tools
Comparing version 0.2.0 to 0.2.1
{ | ||
"name": "@streamlayer/sdk-web-anonymous-auth", | ||
"version": "0.2.0", | ||
"version": "0.2.1", | ||
"type": "module", | ||
@@ -5,0 +5,0 @@ "main": "./src/index.js", |
@@ -7,2 +7,2 @@ import { StreamLayerContext } from '@streamlayer/sdk-web'; | ||
} | ||
export declare const anonymous: (instance: StreamLayerContext, opts: any, done: any) => void; | ||
export declare const anonymous: (instance: StreamLayerContext, opts: unknown, done: () => void) => void; |
@@ -8,6 +8,9 @@ import { queries } from '@streamlayer/sdk-web-api'; | ||
} || opts; | ||
const organization = await instance.sdk.sdkStore().getStoreItem('organizationSettings').getValue(); | ||
const userKey = `${organization.pub.kid}`; | ||
const organization = await instance.stores.organizationSettings.getValue(); | ||
if (!organization) { | ||
throw new Error('unknown organization'); | ||
} | ||
const userKey = `${organization.pub?.kid}`; | ||
const schema = `${schemaName}:${organization.id}`; | ||
const anonymous = await queries.bypassAuth(instance.sdk.transport, { | ||
const anonymous = await queries.bypassAuth(instance.transport, { | ||
userKey, | ||
@@ -17,3 +20,3 @@ schema, | ||
}); | ||
const token = anonymous.meta.token; | ||
const token = anonymous.meta?.token; | ||
const pubKey = organization.pub; | ||
@@ -28,3 +31,3 @@ const pub = await importJWK({ | ||
}).setProtectedHeader({ | ||
alg: pubKey.alg, | ||
alg: pubKey.alg || '', | ||
enc: 'A256CBC-HS512', | ||
@@ -31,0 +34,0 @@ kid: pubKey.kid |
Sorry, the diff of this file is not supported yet
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
5716
47
0