@fabrika/auth 0.0.13 → 0.0.15
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/package.json +2 -2
- package/src/iam.ts +5 -5
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@fabrika/auth",
|
|
3
|
-
"version": "0.0.
|
|
3
|
+
"version": "0.0.15",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"repository": {
|
|
6
6
|
"type": "git",
|
|
@@ -26,7 +26,7 @@
|
|
|
26
26
|
"test": "bun test"
|
|
27
27
|
},
|
|
28
28
|
"dependencies": {
|
|
29
|
-
"@fabrika/auth-core": "^0.0.
|
|
29
|
+
"@fabrika/auth-core": "^0.0.15",
|
|
30
30
|
"jose": "^5.9.0"
|
|
31
31
|
}
|
|
32
32
|
}
|
package/src/iam.ts
CHANGED
|
@@ -43,7 +43,7 @@ export interface IamEnv {
|
|
|
43
43
|
/** The IAM service binding. Typed as the `IamRpc` contract — never the IAM Worker. */
|
|
44
44
|
IAM?: IamRpc
|
|
45
45
|
/** IAM origin — the token `iss` this SDK verifies against. Canonicalized once in `createIam`. */
|
|
46
|
-
|
|
46
|
+
FABRIKA_IAM_ISSUER?: string
|
|
47
47
|
/** Fallback app id when `opts.appId` is omitted. */
|
|
48
48
|
FABRIKA_APP_ID?: string
|
|
49
49
|
}
|
|
@@ -278,7 +278,7 @@ export function createIam(env: IamEnv, opts: CreateIamOptions = {}): Iam {
|
|
|
278
278
|
if (binding === undefined) {
|
|
279
279
|
throw new Error('createIam: the IAM service binding is missing (env.IAM) — check the IAM ServiceReference.')
|
|
280
280
|
}
|
|
281
|
-
const issuer = canonicalIssuer(env.
|
|
281
|
+
const issuer = canonicalIssuer(env.FABRIKA_IAM_ISSUER)
|
|
282
282
|
return new Iam({
|
|
283
283
|
management: new IamClient(binding, appId),
|
|
284
284
|
binding,
|
|
@@ -294,16 +294,16 @@ export function createIam(env: IamEnv, opts: CreateIamOptions = {}): Iam {
|
|
|
294
294
|
*/
|
|
295
295
|
function canonicalIssuer(raw: string | undefined): string {
|
|
296
296
|
if (raw === undefined || raw.trim() === '') {
|
|
297
|
-
throw new Error('createIam:
|
|
297
|
+
throw new Error('createIam: FABRIKA_IAM_ISSUER is missing — it is the issuer every token is verified against.')
|
|
298
298
|
}
|
|
299
299
|
let url: URL
|
|
300
300
|
try {
|
|
301
301
|
url = new URL(raw.trim())
|
|
302
302
|
} catch {
|
|
303
|
-
throw new Error('createIam:
|
|
303
|
+
throw new Error('createIam: FABRIKA_IAM_ISSUER is not an absolute URL.')
|
|
304
304
|
}
|
|
305
305
|
if (url.protocol !== 'https:' && url.protocol !== 'http:') {
|
|
306
|
-
throw new Error('createIam:
|
|
306
|
+
throw new Error('createIam: FABRIKA_IAM_ISSUER must be an http(s) origin.')
|
|
307
307
|
}
|
|
308
308
|
return url.origin
|
|
309
309
|
}
|